Giter Club home page Giter Club logo

mathpresso's People

Contributors

andreasschoenle avatar gjacquenot avatar kobalicek avatar zueuk avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

mathpresso's Issues

Link warning

I'm not sure if you've seen this, but I'm embedding mathpresso-ng and asmjit, get a linker warning

1>LINK : warning C4744: 'struct asmjit::X86RegData const asmjit::x86RegData' has different type in 'C:\work\sim\common\asmjit\src\x86operand_regs.cpp' and 'C:\work\sim\common\asmjit\src\mathpresso_jit.cpp': 'union (3152 bytes)' and 'struct (3152 bytes)'

I'm using Visual Studio 2013 on Windows 7, if that's useful.

small bug with inbuilt function isinf

While working with the code, i noticed, that the assemblerimplementation of isinf gives a wrong result.
In mpCompiler in Line 380 the operand gets compared with the constant 0xFF80000000000000. Correct, as of IEEE754, would be 0xFFF0000000000000, as the exponent is 11 bit (with one signbit)(src).

Regards
Hades

Decimal numbers parser bug

Numbers like 10.5 are parsed as 15.0

I believe this can be fixed by removing
size_t scale = 0;
at mptokenizer.cpp, line 233

Possible memoryleak while destroing a context

As I am interested in this project, i played around with it a bit. I noticed that while compiling under Windows for x86 that the Context-object is not destroyed, when it is not referenced anymore, while that is with x86_64 it is destroyed correctly. If i call the destructor by hand, under x86 it works as expected, while under x86_64 i get a memory-access-vioation.
I dug a bit deeper and noticed, that the function mpAtomicDec has diffrent implementations, depending on the platform:

# if defined(__x86_64__) || defined(_WIN64) || defined(_M_IA64) || defined(_M_X64)
[...]
//! \internal
static MATHPRESSO_INLINE uintptr_t mpAtomicDec(uintptr_t* atomic) {
  return _InterlockedDecrement64((__int64 volatile *)&atomic);
}
# else
[...]
//! \internal
static MATHPRESSO_INLINE uintptr_t mpAtomicDec(uintptr_t* atomic) {
  return _InterlockedDecrement((long volatile *)atomic);
}
# endif // _64BIT

(mpatomic_p.h, lines 31+)
I'm confused with the &atomic with x86_63 and atomic under x86.

As I am not shure what the intended behaviour is, and as my experience with C++ is limited, i cannot give a direct fix for this.

Bug(s) in declared vars?

Hello!

It seems that the declared vars work in a strange way. I tried to swap values of x and y via a temporary variable t, and here's what I ended up with:

x=1; y=2; var t=x; t
1.000000

x=1; y=2; var t=x; x=y; t
2.000000

"Custom Functions" lead into assert

Thanks for the nice project.
During finding out, whether is can use it within one of my (so far not official) projects, I found a bug in mathpresso.cpp:

/*349*/     if (sym != NULL) \ 
/*350*/       return MATHPRESSO_TRACE_ERROR(kErrorSymbolAlreadyExists); \ 
/*351*/     \ 
/*352*/     sym = d->_builder.newSymbol(StringRef(name, nlen), hVal, kAstSymbolVariable, kAstScopeGlobal); \ 
/*353*/     if (sym == NULL) \ 

should be changed to:

/*349*/     if (sym != NULL) \ 
/*350*/       return MATHPRESSO_TRACE_ERROR(kErrorSymbolAlreadyExists); \ 
/*351*/     \ 
/*352*/     sym = d->_builder.newSymbol(StringRef(name, nlen), hVal, type, kAstScopeGlobal); \ 
/*353*/     if (sym == NULL) \

otherwise it asserts "not a function" and, if the assert was skipped, will "syntax error" for the "(" after the function name in an expression.

BR, Juergen

adding arrays with 'var' or addConstant

I'm working with your latest code, trying to take the 'var' keyword for a test drive. It's very useful!

I'm curious as to how difficult it would be to add arrays, something like

var a[] = {1, 2, 3, 4};
var index = 0;
a[index];

or, using addConstant, something like addConstant(varname, double* ptr, size_t length), after which varname[index] could be retrieved in jitted code.

Usage question

in mptest.cpp, I saw something like

e1.create(ctx, "expression", mathpresso::kMPOptionNone)

and in mathpresso.cpp,

// Fallback to evaluation if JIT compiling failed or not enabled.

What might cause the JIT to fail? Is there some place in the interface where I can detect whether or not the JIT failed?

Extra movsd's and some odd choice of register(s)

I noticed that the generated asm code loads the same value into the same register multiple times.
The old Mathpresso (with an old AsmJit) version that I used before didn't do this:

x = y =1

lea rax, [L2]
movsd xmm0, [rax]
movsd [rdx], xmm0
movsd xmm0, [rax]
movsd [rdx+8], xmm0
movsd xmm0, [rax]
movsd [rcx], xmm0
ret

Another thing - a combination of an unary operation ("-", sqrt, etc.) and a function call somehow makes it use xmm6, that apparently needs to be savied/restored:

-x / sin(y)

sub rsp, 72
movaps oword ptr [rsp+48], xmm6
xorpd xmm6, xmm6
subsd xmm6, [rdx]
...
movaps xmm6, oword ptr [rsp+48]
add rsp, 72
ret

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.