Comments (2)
The reason it's not there yet is because we're trying to figure out if we should actually have floats. There are two typed arrays for floats, Float32 and Float64. We might just go with float64 only, since coercion to float32 is not that easy. (It requires that you store and read the value out of a Float32 array.) If we only support float64, we might as well just call it "num" since it's what JavaScript uses anyway. I think "num" works, but i didn't implement float64 typed arrays yet.
from lljs.
I think the distinction between integers and floats could be relevant for pointer/array arithmetic interference and optimizations. But other than that, it's pretty irrelevant because it's all doubles underneath.
The distinction between float and double is a bit trickier. On the surface it might seem like only supporting float64 on the stack would be sufficient for a numeric type. However, I strongly suspect that V8's JIT tries to figure out when you're using Float32Array typed arrays, and emits float and not double code, that would run a lot faster on legacy machines that don't have 64-bit wide registers (it would not make a difference on the FPU I think since that processes the whole 80-bit register width anyway). On any account, in OpenGL (WebGL) you store vertex attributes as floats (32) because the API does not accept doubles. If the stack is 64-bit and the main result of a computation is 32-bit, there would still be a conversion, but I'm not sure if it matters, or if it's gonna happen anyway. The optimal case would be that V8-s JIT notices you're copying from float32->float32 and just register/heap moves 4 bytes.
On the memory usage side, supporting only float64 in structures and as type has an implication that in-memory structures held in *JS idiomatic fashion would double in size. I think this wouldn't matter most of the time, but some border cases could be imagined.
from lljs.
Related Issues (20)
- importing types HOT 3
- suggestions for performance? HOT 12
- casting requires extra set of parentheses HOT 4
- Downcasting of Signed Types Not Working
- Compile C to LLJS via LLVM?
- Double literals are treated as integers
- Cannot increment struct field in member function
- more bastard children! coffeescript + c
- lljs.org is down HOT 9
- bug in order of operations parsing C casts
- Support for asm.js HOT 7
- Support for ES6-style Classes HOT 4
- Compiling LLJS to C HOT 2
- Support for memory allocator with GC HOT 2
- Support for function types
- Add support for u64 and i64 types HOT 2
- lljs.org is down
- "memory.reset is not a function" when running examples on page. HOT 3
- lljs.org hijacked HOT 2
- React native casting error HOT 6
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from lljs.