- Lots of minor fixes and additions, in order to get CPython working. As a result there is now a web demo of Python, which seems to work quite well aside for being very slow in Chrome.
- Figuring out what to do with LLVM optimizations. It looks like all of them generate suitable code except for -instcombine, which apparently combines instructions in a CPU-specific way (so, it isn't portable, and confuses Emscripten). All the tests now pass with LLVM optimizations enabled (all but the problematic one just mentioned).
Saturday, December 18, 2010
Emscripten 0.7!
Main changes in this release:
Sunday, December 12, 2010
Python Demo
With help from rasjidw, there is now a web demo of Python. Check it out, and let me know if you find a bug!
The demo is of CPython, the original/standard Python implementation, compiled from C to JavaScript. What's cool about compiling CPython itself is that we get all the language features 'for free', both the common stuff you'd expect and think of first, and also things that if you were writing a new implementation, you might leave for last.
Known limitations:
The demo is of CPython, the original/standard Python implementation, compiled from C to JavaScript. What's cool about compiling CPython itself is that we get all the language features 'for free', both the common stuff you'd expect and think of first, and also things that if you were writing a new implementation, you might leave for last.
Known limitations:
- No import of modules - just the core language works. It should be possible to get imports working, of both C modules and Python ones, but it would require writing code for dynamic linking etc.
- I tested in Firefox 4 beta and Chrome 8, and for some reason the demo runs very slowly in Chrome 8 (perhaps related to V8 Issue 947?). Firefox 4 runs much faster but still obviously slower than native CPython. In any case that should improve once we get LLVM optimizations working.
Saturday, December 11, 2010
A Ridiculously Recursive Bug
Work has been going on to get Emscripten to compile CPython (the standard implementation of Python) into JavaScript. It's very close to working, so I started to write an automatic test. But the test failed even though running the test manually worked.
That's weird, I thought.
Turns out that something quite amusing was happening. The automatic test system and other scripts are written in Python, and the test runner checks for script crashes and failures by scanning for the text that appears in a Python stack trace, which is to say something like 'Traceback (most recent call last)' etc.
Now, when Emscripten compiles Python itself, it generates JavaScript code that includes, unsurprisingly, all the constant strings in Python - including that very string! So the right output was erroneously detected as a failure.
I guess that's what can happen if your test compiles the very same runtime in which the test infrastructure is built... ;)
That's weird, I thought.
Turns out that something quite amusing was happening. The automatic test system and other scripts are written in Python, and the test runner checks for script crashes and failures by scanning for the text that appears in a Python stack trace, which is to say something like 'Traceback (most recent call last)' etc.
Now, when Emscripten compiles Python itself, it generates JavaScript code that includes, unsurprisingly, all the constant strings in Python - including that very string! So the right output was erroneously detected as a failure.
I guess that's what can happen if your test compiles the very same runtime in which the test infrastructure is built... ;)
Sunday, November 28, 2010
Lua Demo += Skywriter
Friday, November 26, 2010
Lua Improvements
It seems there are people interested in running Lua on the web :) The Lua demo was on Hacker News, and some people noticed that certain things don't work - thanks for the feedback! - so I spent a few hours figuring out what was wrong. After some small fixes, the demo will now handle these statements:
The output seems ok, but I'm not totally sure that it's 100% correct, since my Lua skills are pretty rusty. That's also why I didn't notice the issues in the beginning - I saw that 'hello world' worked, and thought all was well ;)
If people really want to see this work properly, let me know about any other problems. I'm happy to work on it, I just can't do it without feedback since I don't know where to start testing. (Is there a standard test suite for Lua?)
The issues that had to be fixed in Emscripten were
- for k,v in pairs({'foo','bar'}) do print(k,v) end
- for x = 1,10 do print(x) end
- for k,v in pairs(_G) do print("->", k,v) end
The output seems ok, but I'm not totally sure that it's 100% correct, since my Lua skills are pretty rusty. That's also why I didn't notice the issues in the beginning - I saw that 'hello world' worked, and thought all was well ;)
If people really want to see this work properly, let me know about any other problems. I'm happy to work on it, I just can't do it without feedback since I don't know where to start testing. (Is there a standard test suite for Lua?)
The issues that had to be fixed in Emscripten were
- Lua uses varargs in ways that the existing code didn't support. So I improved that. Varargs are now emulated in a way that is basically identical to C.
- A few missing stdlib functions.
Thursday, November 25, 2010
Emscripten 0.6!
Demo: Lua. Thanks to rasjidw and puffnfresh!
Other major changes since the last release:
Other major changes since the last release:
- SAFE_HEAP checks for invalid reads/writes and nonportable LLVM bitcode. This is important as LLVM optimizations can lead to nonportable bitcode. We need to figure out which optimizations are at fault, so we can use the other optimizations - they should make us much faster.
- Much more optimized compilation of very large projects - both in terms of memory and speed. I am now able to compile Sauerbraten without the JS engine giving up ;) - still a very long way from getting it to run, though.
Tuesday, November 16, 2010
Subscribe to:
Posts (Atom)