aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--demos/python.html4
-rw-r--r--demos/python.js4
-rw-r--r--src/preamble.js35
3 files changed, 23 insertions, 20 deletions
diff --git a/demos/python.html b/demos/python.html
index 6fae490a..1d924b4e 100644
--- a/demos/python.html
+++ b/demos/python.html
@@ -80,9 +80,7 @@
<li>Most core language stuff should work, except for importing non-static modules (in other words, <code>import sys</code> will
work, but other modules won't).</li>
<li>Please report bugs if you find them!</li>
- <li>Note that this is an unoptimized build (see <a href="http://code.google.com/p/emscripten/issues/detail?id=8">issue 8</a>),
- so it may run slowly. Speed may depend on the browser - Chrome 8 in particular is slow, dunno why (maybe
- <a href="http://code.google.com/p/v8/issues/detail?id=947">V8 issue 947</a>?). Firefox 4 beta 7+ is recommended.</li>
+ <li>Tested on Firefox 4 and Chrome 10.</li>
<li>The editor is <a href="https://mozillalabs.com/skywriter/">Skywriter</a>.
</ul>
</p>
diff --git a/demos/python.js b/demos/python.js
index 754cb511..85eff513 100644
--- a/demos/python.js
+++ b/demos/python.js
@@ -7,7 +7,9 @@ return!Runtime.g(c)&&c[0]=="%"},j:{i1:0,i8:0,i16:0,i32:0,i64:0},i:{"float":0,"do
e){c.c=0;var b=[],d=-1,f=-1;c.m=c.t.map(function(g){var h;if(Runtime.g(g)||Runtime.o(g)){h=Runtime.n(g,ca);f=Math.max(f,h)}else if(Runtime.p(g)){h=e[g].c;f=Math.max(f,4)}else{dprint("Unclear type in struct: "+g+", in "+c.u);ia(0)}g=Runtime.e(c.c,Math.min(4,h));c.c=g+h;d>=0&&b.push(g-d);return d=g});c.c=Runtime.e(c.c,f);if(b.length==0)c.f=c.c;else if(Runtime.l(b).length==1)c.f=b[0];c.v=c.f!=1;return c.m},r:0};var n=[],ja=[];
function ia(c,e){if(!c){e="Assertion failed: "+e;print(e+":\n"+Error().stack);ba("Assertion: "+e)}}var o=1,s=2;function u(c,e,b){e=e?e:0;ia(e===0);if(c===ka)return e;e=c.length;var d;for(d=0;d<e;d++)if(c[d]===undefined)ba("Invalid element in slab at "+Error().stack);b=[la,Runtime.q,Runtime.h][b?b:s](Math.max(e,1));for(d=0;d<e;d++){var f=c[d];if(typeof f==="function")f=Runtime.a(f);if(typeof f==="number"||typeof f==="boolean"){i[b+d]=f;j[b+d]=f}else ka[b+d]=f}return b}Module.Pointer_make=u;
function na(c){for(var e="",b=0,d;;){d=String.fromCharCode(i[c+b]);if(d=="\u0000")break;e+=d;b+=1}return e}var pa=4096,ka,i,j,qa,a,ra,ha,la,w,aaa=ea,sa=52428800;
-function baa(){Module._malloc=la=Module._malloc?Module._malloc:Runtime.h;Module._free=w=Module._free?Module._free:fa();ka=ta("(null)");if(aaa=this.Int32Array&&this.Float64Array){i=new Int32Array(sa);for(var c=0;c<ka.length;c++)i[c]=ka[c];ka=i;j=new Float64Array(sa)}else j=i=ka;Module.HEAP=ka;Module.IHEAP=i;Module.FHEAP=j;qa=a=Math.ceil(10/pa)*pa;this.TOTAL_STACK||(TOTAL_STACK=1048576);ra=qa+TOTAL_STACK;ha=Math.ceil(ra/pa)*pa}
+function baa(){Module._malloc=la=Module._malloc?Module._malloc:Runtime.h;Module._free=w=Module._free?Module._free:fa();ka=ta("(null)");if(aaa=this.Int32Array&&this.Float64Array){i=new Int32Array(sa);for(var c=0;c<ka.length;c++)i[c]=ka[c];ka=i;j=new Float64Array(sa)}else
+{j=i=ka; _llvm_memset_p0i8_i32(ka.length, 0, sa/32)} /* XXX manually added, hack to get Chrome to use HEAP as a flat array */
+;Module.HEAP=ka;Module.IHEAP=i;Module.FHEAP=j;qa=a=Math.ceil(10/pa)*pa;this.TOTAL_STACK||(TOTAL_STACK=1048576);ra=qa+TOTAL_STACK;ha=Math.ceil(ra/pa)*pa}
function caa(){for(;ja.length>0;){var c=ja.pop();if(typeof c==="number")c=n[c];c()}}
function ua(){function c(r){var q;if(e){q=(String.fromCharCode(r)in Runtime.d("f","e","g")?j:i)[d];d+=r==="l".charCodeAt(0)?8:4}else{q=f[d];d++}return q}var e=ea,b=arguments[0],d=1;if(b<0){e=ca;b=-b;slab=da;d=arguments[1]}else var f=arguments;for(var g=[],h=-1,k,l;h;){h=i[b];k=i[b+1];if(h=="%".charCodeAt(0)){var m=-1;if(k==".".charCodeAt(0)){b++;for(m=0;;){k=i[b+1];if(!(k>="0".charCodeAt(0)&&k<="9".charCodeAt(0)))break;m*=10;m+=k-"0".charCodeAt(0);b++}k=i[b+1]}if(k=="l".charCodeAt(0)){b++;k=i[b+1]}if(String.fromCharCode(k)in
Runtime.d("f","e","g"))k="f".charCodeAt(0);if(["d","i","u","p","f"].indexOf(String.fromCharCode(k))!=-1){var p;l=c(k);p=String(+l);p=k=="u".charCodeAt(0)?String(x(l,32)):k=="p".charCodeAt(0)?"0x"+l.toString(16):String(+l);if(m>=0){l=p.indexOf(".");if(l==-1&&k=="f".charCodeAt(0)){l=p.length;p+="."}p+="00000000000";p=p.substr(0,l+1+m)}p.split("").forEach(function(r){g.push(r.charCodeAt(0))})}else if(k=="s".charCodeAt(0))g=g.concat(va(c(k)));else if(k=="c".charCodeAt(0))g=g.concat(c(k));else g.push(k);
diff --git a/src/preamble.js b/src/preamble.js
index a4e685d0..25a0b774 100644
--- a/src/preamble.js
+++ b/src/preamble.js
@@ -198,25 +198,28 @@ function __initializeRuntime__() {
Module['_malloc'] = _malloc = __Znwj = __Znaj = __Znam = __Znwm = Module['_malloc'] ? Module['_malloc'] : Runtime.staticAlloc;
Module['_free'] = _free = __ZdlPv = __ZdaPv = Module['_free'] ? Module['_free'] : function() { };
- // TODO: Remove one of the 3 heaps!
- HEAP = intArrayFromString('(null)'); // So printing %s of NULL gives '(null)'
- // Also this ensures we leave 0 as an invalid address, 'NULL'
#if USE_TYPED_ARRAYS
+ // TODO: Remove one of the 3 heaps!
HAS_TYPED_ARRAYS = this['Int32Array'] && this['Float64Array']; // check for engine support
if (HAS_TYPED_ARRAYS) {
- IHEAP = new Int32Array(TOTAL_MEMORY);
- for (var i = 0; i < HEAP.length; i++) {
- IHEAP[i] = HEAP[i];
- }
- HEAP = IHEAP;
+ HEAP = IHEAP = new Int32Array(TOTAL_MEMORY);
FHEAP = new Float64Array(TOTAL_MEMORY);
- } else {
- IHEAP = HEAP; // fallback
- FHEAP = HEAP; // fallback
- }
-#else
- IHEAP = FHEAP = HEAP;
+ } else
#endif
+ {
+ // Without this optimization, Chrome is slow. Sadly, the constant here needs to be tweaked depending on the code being run...
+ var FAST_MEMORY = TOTAL_MEMORY/32;
+ IHEAP = FHEAP = HEAP = new Array(FAST_MEMORY);
+ for (var i = 0; i < FAST_MEMORY; i++) {
+ HEAP[i] = 0;
+ }
+ }
+
+ var base = intArrayFromString('(null)'); // So printing %s of NULL gives '(null)'
+ // Also this ensures we leave 0 as an invalid address, 'NULL'
+ for (var i = 0; i < base.length; i++) {
+ IHEAP[i] = base[i];
+ }
Module['HEAP'] = HEAP;
Module['IHEAP'] = IHEAP;
@@ -392,7 +395,7 @@ _memmove = _llvm_memmove_i64 = _llvm_memmove_p0i8_p0i8_i32 = _llvm_memmove_p0i8_
function llvm_memset_i32(ptr, value, num) {
for (var i = 0; i < num; i++) {
#if USE_TYPED_ARRAYS
- HEAP[ptr+i] = IHEAP[ptr+i] = FHEAP[ptr+i] = value;
+ IHEAP[ptr+i] = FHEAP[ptr+i] = value;
#else
HEAP[ptr+i] = value;
#endif
@@ -401,7 +404,7 @@ function llvm_memset_i32(ptr, value, num) {
#endif
}
}
-_llvm_memset_p0i8_i64 = _llvm_memset_p0i8_i32 = llvm_memset_i32;
+_memset = _llvm_memset_p0i8_i64 = _llvm_memset_p0i8_i32 = llvm_memset_i32;
function _strlen(ptr) {
var i = 0;