webruby 0.2.5 → 0.2.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/webruby.rb +0 -4
- data/lib/webruby/app.rb +4 -0
- data/lib/webruby/rake/files.rake +2 -1
- data/lib/webruby/rake/mruby.rake +1 -1
- data/modules/emscripten/AUTHORS +1 -0
- data/modules/emscripten/ChangeLog +34 -1
- data/modules/emscripten/cmake/Platform/Emscripten.cmake +30 -9
- data/modules/emscripten/emcc +61 -28
- data/modules/emscripten/emrun +15 -11
- data/modules/emscripten/emscripten.py +3 -0
- data/modules/emscripten/src/closure-externs.js +110 -0
- data/modules/emscripten/src/intertyper.js +1 -1
- data/modules/emscripten/src/jsifier.js +7 -21
- data/modules/emscripten/src/library.js +2 -1
- data/modules/emscripten/src/library_browser.js +16 -5
- data/modules/emscripten/src/library_fs.js +3 -1
- data/modules/emscripten/src/library_gl.js +691 -591
- data/modules/emscripten/src/library_glut.js +2 -0
- data/modules/emscripten/src/library_sdl.js +29 -5
- data/modules/emscripten/src/library_uuid.js +140 -0
- data/modules/emscripten/src/modules.js +1 -1
- data/modules/emscripten/src/parseTools.js +29 -19
- data/modules/emscripten/src/postamble.js +3 -4
- data/modules/emscripten/src/preamble.js +17 -1
- data/modules/emscripten/src/relooper/Relooper.cpp +8 -8
- data/modules/emscripten/src/relooper/Relooper.h +5 -5
- data/modules/emscripten/src/relooper/test.txt +2 -2
- data/modules/emscripten/src/runtime.js +1 -1
- data/modules/emscripten/src/settings.js +3 -0
- data/modules/emscripten/src/struct_info.json +12 -0
- data/modules/emscripten/system/include/uuid/uuid.h +35 -0
- data/modules/emscripten/tools/js-optimizer.js +191 -142
- data/modules/emscripten/tools/js_optimizer.py +3 -29
- data/modules/emscripten/tools/shared.py +43 -6
- data/modules/mruby/include/mruby/value.h +3 -2
- data/modules/mruby/mrbgems/mruby-bin-mirb/tools/mirb/mirb.c +5 -9
- data/modules/mruby/mrbgems/mruby-bin-mruby/tools/mruby/mruby.c +3 -5
- data/modules/mruby/mrbgems/mruby-hash-ext/src/hash-ext.c +0 -3
- data/modules/mruby/mrbgems/mruby-numeric-ext/src/numeric_ext.c +0 -1
- data/modules/mruby/mrbgems/mruby-random/src/mt19937ar.c +0 -1
- data/modules/mruby/mrbgems/mruby-range-ext/src/range.c +2 -6
- data/modules/mruby/mrbgems/mruby-sprintf/src/sprintf.c +0 -4
- data/modules/mruby/mrbgems/mruby-string-ext/mrblib/string.rb +22 -0
- data/modules/mruby/mrbgems/mruby-string-ext/src/string.c +2 -2
- data/modules/mruby/mrbgems/mruby-string-ext/test/string.rb +21 -2
- data/modules/mruby/mrbgems/mruby-string-utf8/mrbgem.rake +4 -0
- data/modules/mruby/mrbgems/mruby-string-utf8/src/string.c +297 -0
- data/modules/mruby/mrbgems/mruby-string-utf8/test/string.rb +27 -0
- data/modules/mruby/mrbgems/mruby-struct/src/struct.c +0 -1
- data/modules/mruby/mrblib/init_mrblib.c +0 -3
- data/modules/mruby/src/array.c +22 -8
- data/modules/mruby/src/backtrace.c +12 -9
- data/modules/mruby/src/class.c +3 -3
- data/modules/mruby/src/codegen.c +17 -5
- data/modules/mruby/src/dump.c +5 -6
- data/modules/mruby/src/error.c +0 -2
- data/modules/mruby/src/etc.c +0 -2
- data/modules/mruby/src/gc.c +4 -8
- data/modules/mruby/src/load.c +1 -6
- data/modules/mruby/src/numeric.c +0 -6
- data/modules/mruby/src/object.c +3 -5
- data/modules/mruby/src/parse.y +37 -38
- data/modules/mruby/src/proc.c +8 -1
- data/modules/mruby/src/range.c +3 -7
- data/modules/mruby/src/state.c +0 -1
- data/modules/mruby/src/string.c +2 -17
- data/modules/mruby/src/symbol.c +0 -1
- data/modules/mruby/src/variable.c +3 -22
- data/modules/mruby/src/vm.c +9 -8
- data/modules/mruby/tasks/mrbgem_spec.rake +13 -5
- data/modules/mruby/tasks/mrbgems_test.rake +3 -3
- data/modules/mruby/tasks/mruby_build_commands.rake +2 -2
- data/modules/mruby/tasks/mruby_build_gem.rake +3 -3
- data/modules/mruby/test/init_mrbtest.c +0 -3
- data/modules/mruby/test/t/array.rb +12 -1
- data/modules/mruby/test/t/class.rb +67 -0
- data/modules/mruby/test/t/exception.rb +12 -0
- data/modules/mruby/test/t/kernel.rb +75 -1
- data/modules/mruby/test/t/syntax.rb +115 -0
- data/scripts/gen_require.rb +12 -1
- metadata +8 -2
|
@@ -1059,11 +1059,35 @@ var LibrarySDL = {
|
|
|
1059
1059
|
var src = buffer >> 2;
|
|
1060
1060
|
var dst = 0;
|
|
1061
1061
|
var isScreen = surf == SDL.screen;
|
|
1062
|
-
var
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
//
|
|
1066
|
-
|
|
1062
|
+
var num;
|
|
1063
|
+
if (typeof CanvasPixelArray !== 'undefined' && data instanceof CanvasPixelArray) {
|
|
1064
|
+
// IE10/IE11: ImageData objects are backed by the deprecated CanvasPixelArray,
|
|
1065
|
+
// not UInt8ClampedArray. These don't have buffers, so we need to revert
|
|
1066
|
+
// to copying a byte at a time. We do the undefined check because modern
|
|
1067
|
+
// browsers do not define CanvasPixelArray anymore.
|
|
1068
|
+
num = data.length;
|
|
1069
|
+
while (dst < num) {
|
|
1070
|
+
var val = HEAP32[src]; // This is optimized. Instead, we could do {{{ makeGetValue('buffer', 'dst', 'i32') }}};
|
|
1071
|
+
data[dst ] = val & 0xff;
|
|
1072
|
+
data[dst+1] = (val >> 8) & 0xff;
|
|
1073
|
+
data[dst+2] = (val >> 16) & 0xff;
|
|
1074
|
+
data[dst+3] = isScreen ? 0xff : ((val >> 24) & 0xff);
|
|
1075
|
+
src++;
|
|
1076
|
+
dst += 4;
|
|
1077
|
+
}
|
|
1078
|
+
} else {
|
|
1079
|
+
var data32 = new Uint32Array(data.buffer);
|
|
1080
|
+
num = data32.length;
|
|
1081
|
+
if (isScreen) {
|
|
1082
|
+
while (dst < num) {
|
|
1083
|
+
// HEAP32[src++] is an optimization. Instead, we could do {{{ makeGetValue('buffer', 'dst', 'i32') }}};
|
|
1084
|
+
data32[dst++] = HEAP32[src++] | 0xff000000;
|
|
1085
|
+
}
|
|
1086
|
+
} else {
|
|
1087
|
+
while (dst < num) {
|
|
1088
|
+
data32[dst++] = HEAP32[src++];
|
|
1089
|
+
}
|
|
1090
|
+
}
|
|
1067
1091
|
}
|
|
1068
1092
|
#else
|
|
1069
1093
|
var num = surfData.image.data.length;
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
// Implementation of libuuid creating RFC4122 version 4 random UUIDs.
|
|
2
|
+
|
|
3
|
+
mergeInto(LibraryManager.library, {
|
|
4
|
+
// Clear a 'compact' UUID.
|
|
5
|
+
uuid_clear: function(uu) {
|
|
6
|
+
// void uuid_clear(uuid_t uu);
|
|
7
|
+
_memset(uu, 0, 16);
|
|
8
|
+
},
|
|
9
|
+
|
|
10
|
+
// Compare whether or not two 'compact' UUIDs are the same.
|
|
11
|
+
// Returns an integer less than, equal to, or greater than zero if uu1 is found, respectively, to be
|
|
12
|
+
// lexigraphically less than, equal, or greater than uu2.
|
|
13
|
+
uuid_compare__deps: ['memcmp'],
|
|
14
|
+
uuid_compare: function(uu1, uu2) {
|
|
15
|
+
// int uuid_compare(const uuid_t uu1, const uuid_t uu2);
|
|
16
|
+
return _memcmp(uu1, uu2, 16);
|
|
17
|
+
},
|
|
18
|
+
|
|
19
|
+
// Copies the 'compact' UUID variable from src to dst.
|
|
20
|
+
uuid_copy: function(dst, src) {
|
|
21
|
+
// void uuid_copy(uuid_t dst, const uuid_t src);
|
|
22
|
+
_memcpy(dst, src, 16);
|
|
23
|
+
},
|
|
24
|
+
|
|
25
|
+
// Write a RFC4122 version 4 compliant UUID largely based on the method found in
|
|
26
|
+
// http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript
|
|
27
|
+
// tweaked slightly in order to use the 'compact' UUID form used by libuuid.
|
|
28
|
+
uuid_generate: function(out) {
|
|
29
|
+
// void uuid_generate(uuid_t out);
|
|
30
|
+
var uuid = null;
|
|
31
|
+
|
|
32
|
+
if (ENVIRONMENT_IS_NODE) {
|
|
33
|
+
// If Node.js try to use crypto.randomBytes
|
|
34
|
+
try {
|
|
35
|
+
var rb = require('crypto').randomBytes;
|
|
36
|
+
uuid = rb(16);
|
|
37
|
+
} catch(e) {}
|
|
38
|
+
} else if (ENVIRONMENT_IS_WEB &&
|
|
39
|
+
typeof(window.crypto) !== 'undefined' &&
|
|
40
|
+
typeof(window.crypto.getRandomValues) !== 'undefined') {
|
|
41
|
+
// If crypto.getRandomValues is available try to use it.
|
|
42
|
+
uuid = new Uint8Array(16);
|
|
43
|
+
window.crypto.getRandomValues(uuid);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
// Fall back to Math.random if a higher quality random number generator is not available.
|
|
47
|
+
if (!uuid) {
|
|
48
|
+
uuid = new Array(16);
|
|
49
|
+
var d = new Date().getTime();
|
|
50
|
+
for (var i = 0; i < 16; i++) {
|
|
51
|
+
var r = (d + Math.random()*256)%256 | 0;
|
|
52
|
+
d = Math.floor(d/256);
|
|
53
|
+
uuid[i] = r;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
uuid[6] = (uuid[6] & 0x0F) | 0x40;
|
|
58
|
+
uuid[8] = (uuid[8] & 0x7F) | 0x80;
|
|
59
|
+
writeArrayToMemory(uuid, out);
|
|
60
|
+
},
|
|
61
|
+
|
|
62
|
+
// Compares the value of the supplied 'compact' UUID variable uu to the NULL value.
|
|
63
|
+
// If the value is equal to the NULL UUID, 1 is returned, otherwise 0 is returned.
|
|
64
|
+
uuid_is_null: function(uu) {
|
|
65
|
+
// int uuid_is_null(const uuid_t uu);
|
|
66
|
+
for (var i = 0; i < 4; i++, uu = (uu+4)|0) {
|
|
67
|
+
var val = {{{ makeGetValue('uu', 0, 'i32') }}};
|
|
68
|
+
if (val) {
|
|
69
|
+
return 0;
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
return 1;
|
|
73
|
+
},
|
|
74
|
+
|
|
75
|
+
// converts the UUID string given by inp into the binary representation. The input UUID is a string of
|
|
76
|
+
// the form "%08x-%04x-%04x-%04x-%012x" 36 bytes plus the trailing '\0'.
|
|
77
|
+
// Upon successfully parsing the input string, 0 is returned, and the UUID is stored in the location
|
|
78
|
+
// pointed to by uu, otherwise -1 is returned.
|
|
79
|
+
uuid_parse: function(inp, uu) {
|
|
80
|
+
// int uuid_parse(const char *in, uuid_t uu);
|
|
81
|
+
var inp = Pointer_stringify(inp);
|
|
82
|
+
if (inp.length === 36) {
|
|
83
|
+
var i = 0;
|
|
84
|
+
var uuid = new Array(16);
|
|
85
|
+
inp.toLowerCase().replace(/[0-9a-f]{2}/g, function(byte) {
|
|
86
|
+
if (i < 16) {
|
|
87
|
+
uuid[i++] = parseInt(byte, 16);
|
|
88
|
+
}
|
|
89
|
+
});
|
|
90
|
+
|
|
91
|
+
if (i < 16) {
|
|
92
|
+
return -1;
|
|
93
|
+
} else {
|
|
94
|
+
writeArrayToMemory(uuid, uu);
|
|
95
|
+
return 0;
|
|
96
|
+
}
|
|
97
|
+
} else {
|
|
98
|
+
return -1;
|
|
99
|
+
}
|
|
100
|
+
},
|
|
101
|
+
|
|
102
|
+
// Convert a 'compact' form UUID to a string, if the upper parameter is supplied make the string upper case.
|
|
103
|
+
uuid_unparse: function(uu, out, upper) {
|
|
104
|
+
// void uuid_unparse(const uuid_t uu, char *out);
|
|
105
|
+
var i = 0;
|
|
106
|
+
var uuid = 'xxxx-xx-xx-xx-xxxxxx'.replace(/[x]/g, function(c) {
|
|
107
|
+
var r = upper ? ({{{ makeGetValue('uu', 'i', 'i8', 0, 1) }}}).toString(16).toUpperCase() :
|
|
108
|
+
({{{ makeGetValue('uu', 'i', 'i8', 0, 1) }}}).toString(16);
|
|
109
|
+
r = (r.length === 1) ? '0' + r : r; // Zero pad single digit hex values
|
|
110
|
+
i++;
|
|
111
|
+
return r;
|
|
112
|
+
});
|
|
113
|
+
writeStringToMemory(uuid, out);
|
|
114
|
+
},
|
|
115
|
+
|
|
116
|
+
// Convert a 'compact' form UUID to a lower case string.
|
|
117
|
+
uuid_unparse_lower__deps: ['uuid_unparse'],
|
|
118
|
+
uuid_unparse_lower: function(uu, out) {
|
|
119
|
+
// void uuid_unparse_lower(const uuid_t uu, char *out);
|
|
120
|
+
_uuid_unparse(uu, out);
|
|
121
|
+
},
|
|
122
|
+
|
|
123
|
+
// Convert a 'compact' form UUID to an upper case string.
|
|
124
|
+
uuid_unparse_upper__deps: ['uuid_unparse'],
|
|
125
|
+
uuid_unparse_upper: function(uu, out) {
|
|
126
|
+
// void uuid_unparse_upper(const uuid_t uu, char *out);
|
|
127
|
+
_uuid_unparse(uu, out, true);
|
|
128
|
+
},
|
|
129
|
+
|
|
130
|
+
uuid_type: function(uu) {
|
|
131
|
+
// int uuid_type(const uuid_t uu);
|
|
132
|
+
return {{{ cDefine('UUID_TYPE_DCE_RANDOM') }}};
|
|
133
|
+
},
|
|
134
|
+
|
|
135
|
+
uuid_variant: function(uu) {
|
|
136
|
+
// int uuid_variant(const uuid_t uu);
|
|
137
|
+
return {{{ cDefine('UUID_VARIANT_DCE') }}};
|
|
138
|
+
}
|
|
139
|
+
});
|
|
140
|
+
|
|
@@ -424,7 +424,7 @@ var LibraryManager = {
|
|
|
424
424
|
load: function() {
|
|
425
425
|
if (this.library) return;
|
|
426
426
|
|
|
427
|
-
var libraries = ['library.js', 'library_path.js', 'library_fs.js', 'library_idbfs.js', 'library_memfs.js', 'library_nodefs.js', 'library_sockfs.js', 'library_tty.js', 'library_browser.js', 'library_sdl.js', 'library_gl.js', 'library_glut.js', 'library_xlib.js', 'library_egl.js', 'library_gc.js', 'library_jansson.js', 'library_openal.js', 'library_glfw.js'].concat(additionalLibraries);
|
|
427
|
+
var libraries = ['library.js', 'library_path.js', 'library_fs.js', 'library_idbfs.js', 'library_memfs.js', 'library_nodefs.js', 'library_sockfs.js', 'library_tty.js', 'library_browser.js', 'library_sdl.js', 'library_gl.js', 'library_glut.js', 'library_xlib.js', 'library_egl.js', 'library_gc.js', 'library_jansson.js', 'library_openal.js', 'library_glfw.js', 'library_uuid.js'].concat(additionalLibraries);
|
|
428
428
|
for (var i = 0; i < libraries.length; i++) {
|
|
429
429
|
eval(processMacros(preprocess(read(libraries[i]))));
|
|
430
430
|
}
|
|
@@ -16,6 +16,7 @@ function processMacros(text) {
|
|
|
16
16
|
|
|
17
17
|
// Simple #if/else/endif preprocessing for a file. Checks if the
|
|
18
18
|
// ident checked is true in our global.
|
|
19
|
+
// Also handles #include x.js (similar to C #include <file>)
|
|
19
20
|
function preprocess(text) {
|
|
20
21
|
var lines = text.split('\n');
|
|
21
22
|
var ret = '';
|
|
@@ -30,25 +31,30 @@ function preprocess(text) {
|
|
|
30
31
|
ret += line + '\n';
|
|
31
32
|
}
|
|
32
33
|
} else {
|
|
33
|
-
if (line[1]
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
if (op
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
34
|
+
if (line[1] == 'i') {
|
|
35
|
+
if (line[2] == 'f') { // if
|
|
36
|
+
var parts = line.split(' ');
|
|
37
|
+
var ident = parts[1];
|
|
38
|
+
var op = parts[2];
|
|
39
|
+
var value = parts[3];
|
|
40
|
+
if (op) {
|
|
41
|
+
if (op === '==') {
|
|
42
|
+
showStack.push(ident in this && this[ident] == value);
|
|
43
|
+
} else if (op === '!=') {
|
|
44
|
+
showStack.push(!(ident in this && this[ident] == value));
|
|
45
|
+
} else {
|
|
46
|
+
error('unsupported preprecessor op ' + op);
|
|
47
|
+
}
|
|
43
48
|
} else {
|
|
44
|
-
|
|
49
|
+
showStack.push(ident in this && this[ident] > 0);
|
|
45
50
|
}
|
|
46
|
-
} else {
|
|
47
|
-
|
|
51
|
+
} else if (line[2] == 'n') { // include
|
|
52
|
+
var included = read(line.substr(line.indexOf(' ')+1));
|
|
53
|
+
ret += '\n' + preprocess(included) + '\n'
|
|
48
54
|
}
|
|
49
|
-
} else if (line[2]
|
|
55
|
+
} else if (line[2] == 'l') { // else
|
|
50
56
|
showStack.push(!showStack.pop());
|
|
51
|
-
} else if (line[2]
|
|
57
|
+
} else if (line[2] == 'n') { // endif
|
|
52
58
|
showStack.pop();
|
|
53
59
|
} else {
|
|
54
60
|
throw "Unclear preprocessor command: " + line;
|
|
@@ -457,7 +463,7 @@ function parseParamTokens(params) {
|
|
|
457
463
|
// handle 'byval' and 'byval align X'. We store the alignment in 'byVal'
|
|
458
464
|
byVal = QUANTUM_SIZE;
|
|
459
465
|
segment.splice(1, 1);
|
|
460
|
-
if (segment[1] && segment[1].text === 'nocapture') {
|
|
466
|
+
if (segment[1] && (segment[1].text === 'nocapture' || segment[1].text === 'readonly')) {
|
|
461
467
|
segment.splice(1, 1);
|
|
462
468
|
}
|
|
463
469
|
if (segment[1] && segment[1].text === 'align') {
|
|
@@ -466,7 +472,7 @@ function parseParamTokens(params) {
|
|
|
466
472
|
segment.splice(1, 2);
|
|
467
473
|
}
|
|
468
474
|
}
|
|
469
|
-
if (segment[1] && segment[1].text === 'nocapture') {
|
|
475
|
+
if (segment[1] && (segment[1].text === 'nocapture' || segment[1].text === 'readonly')) {
|
|
470
476
|
segment.splice(1, 1);
|
|
471
477
|
}
|
|
472
478
|
if (segment.length == 1) {
|
|
@@ -622,7 +628,7 @@ function parseLLVMSegment(segment) {
|
|
|
622
628
|
}
|
|
623
629
|
|
|
624
630
|
function cleanSegment(segment) {
|
|
625
|
-
while (segment.length >= 2 && ['noalias', 'sret', 'nocapture', 'nest', 'zeroext', 'signext'].indexOf(segment[1].text) != -1) {
|
|
631
|
+
while (segment.length >= 2 && ['noalias', 'sret', 'nocapture', 'nest', 'zeroext', 'signext', 'readnone'].indexOf(segment[1].text) != -1) {
|
|
626
632
|
segment.splice(1, 1);
|
|
627
633
|
}
|
|
628
634
|
return segment;
|
|
@@ -1634,7 +1640,10 @@ function getFastValue(a, op, b, type) {
|
|
|
1634
1640
|
}
|
|
1635
1641
|
|
|
1636
1642
|
function getFastValues(list, op, type) {
|
|
1637
|
-
assert(op
|
|
1643
|
+
assert(op === '+' && type === 'i32');
|
|
1644
|
+
for (var i = 0; i < list.length; i++) {
|
|
1645
|
+
if (isNumber(list[i])) list[i] = (list[i]|0) + '';
|
|
1646
|
+
}
|
|
1638
1647
|
var changed = true;
|
|
1639
1648
|
while (changed) {
|
|
1640
1649
|
changed = false;
|
|
@@ -1642,6 +1651,7 @@ function getFastValues(list, op, type) {
|
|
|
1642
1651
|
var fast = getFastValue(list[i], op, list[i+1], type);
|
|
1643
1652
|
var raw = list[i] + op + list[i+1];
|
|
1644
1653
|
if (fast.length < raw.length || fast.indexOf(op) < 0) {
|
|
1654
|
+
if (isNumber(fast)) fast = (fast|0) + '';
|
|
1645
1655
|
list[i] = fast;
|
|
1646
1656
|
list.splice(i+1, 1);
|
|
1647
1657
|
i--;
|
|
@@ -117,16 +117,15 @@ function run(args) {
|
|
|
117
117
|
|
|
118
118
|
preRun();
|
|
119
119
|
|
|
120
|
-
if (runDependencies > 0)
|
|
121
|
-
|
|
122
|
-
return;
|
|
123
|
-
}
|
|
120
|
+
if (runDependencies > 0) return; // a preRun added a dependency, run will be called later
|
|
121
|
+
if (Module['calledRun']) return; // run may have just been called through dependencies being fulfilled just in this very frame
|
|
124
122
|
|
|
125
123
|
function doRun() {
|
|
126
124
|
ensureInitRuntime();
|
|
127
125
|
|
|
128
126
|
preMain();
|
|
129
127
|
|
|
128
|
+
assert(!Module['calledRun']);
|
|
130
129
|
Module['calledRun'] = true;
|
|
131
130
|
if (Module['_main'] && shouldRunNow) {
|
|
132
131
|
Module['callMain'](args);
|
|
@@ -866,6 +866,21 @@ var TOTAL_STACK = Module['TOTAL_STACK'] || {{{ TOTAL_STACK }}};
|
|
|
866
866
|
var TOTAL_MEMORY = Module['TOTAL_MEMORY'] || {{{ TOTAL_MEMORY }}};
|
|
867
867
|
var FAST_MEMORY = Module['FAST_MEMORY'] || {{{ FAST_MEMORY }}};
|
|
868
868
|
|
|
869
|
+
#if ASM_JS
|
|
870
|
+
var totalMemory = 4096;
|
|
871
|
+
while (totalMemory < TOTAL_MEMORY || totalMemory < 2*TOTAL_STACK) {
|
|
872
|
+
if (totalMemory < 16*1024*1024) {
|
|
873
|
+
totalMemory *= 2;
|
|
874
|
+
} else {
|
|
875
|
+
totalMemory += 16*1024*1024
|
|
876
|
+
}
|
|
877
|
+
}
|
|
878
|
+
if (totalMemory !== TOTAL_MEMORY) {
|
|
879
|
+
Module.printErr('increasing TOTAL_MEMORY to ' + totalMemory + ' to be more reasonable');
|
|
880
|
+
TOTAL_MEMORY = totalMemory;
|
|
881
|
+
}
|
|
882
|
+
#endif
|
|
883
|
+
|
|
869
884
|
// Initialize the runtime's memory
|
|
870
885
|
#if USE_TYPED_ARRAYS
|
|
871
886
|
// check for full engine support (use string 'subarray' to avoid closure compiler confusion)
|
|
@@ -1075,7 +1090,8 @@ Module['writeAsciiToMemory'] = writeAsciiToMemory;
|
|
|
1075
1090
|
{{{ reSign }}}
|
|
1076
1091
|
|
|
1077
1092
|
#if PRECISE_I32_MUL
|
|
1078
|
-
|
|
1093
|
+
// check for imul support, and also for correctness ( https://bugs.webkit.org/show_bug.cgi?id=126345 )
|
|
1094
|
+
if (!Math['imul'] || Math['imul'](0xffffffff, 5) !== -5) Math['imul'] = function imul(a, b) {
|
|
1079
1095
|
var ah = a >>> 16;
|
|
1080
1096
|
var al = a & 0xffff;
|
|
1081
1097
|
var bh = b >>> 16;
|
|
@@ -308,7 +308,7 @@ void MultipleShape::Render(bool InLoop) {
|
|
|
308
308
|
}
|
|
309
309
|
RenderLoopPostfix();
|
|
310
310
|
if (Next) Next->Render(InLoop);
|
|
311
|
-
}
|
|
311
|
+
}
|
|
312
312
|
|
|
313
313
|
// LoopShape
|
|
314
314
|
|
|
@@ -323,7 +323,7 @@ void LoopShape::Render(bool InLoop) {
|
|
|
323
323
|
Indenter::Unindent();
|
|
324
324
|
PrintIndented("}\n");
|
|
325
325
|
if (Next) Next->Render(InLoop);
|
|
326
|
-
}
|
|
326
|
+
}
|
|
327
327
|
|
|
328
328
|
// EmulatedShape
|
|
329
329
|
|
|
@@ -350,7 +350,7 @@ void EmulatedShape::Render(bool InLoop) {
|
|
|
350
350
|
Indenter::Unindent();
|
|
351
351
|
PrintIndented("}\n");
|
|
352
352
|
if (Next) Next->Render(InLoop);
|
|
353
|
-
}
|
|
353
|
+
}
|
|
354
354
|
|
|
355
355
|
// Relooper
|
|
356
356
|
|
|
@@ -358,8 +358,8 @@ Relooper::Relooper() : Root(NULL), Emulate(false), BlockIdCounter(1), ShapeIdCou
|
|
|
358
358
|
}
|
|
359
359
|
|
|
360
360
|
Relooper::~Relooper() {
|
|
361
|
-
for (
|
|
362
|
-
for (
|
|
361
|
+
for (unsigned i = 0; i < Blocks.size(); i++) delete Blocks[i];
|
|
362
|
+
for (unsigned i = 0; i < Shapes.size(); i++) delete Shapes[i];
|
|
363
363
|
}
|
|
364
364
|
|
|
365
365
|
void Relooper::AddBlock(Block *New) {
|
|
@@ -399,7 +399,7 @@ void Relooper::Calculate(Block *Entry) {
|
|
|
399
399
|
// RAII cleanup. Without splitting, we will be forced to introduce labelled loops to allow
|
|
400
400
|
// reaching the final block
|
|
401
401
|
void SplitDeadEnds() {
|
|
402
|
-
|
|
402
|
+
unsigned TotalCodeSize = 0;
|
|
403
403
|
for (BlockSet::iterator iter = Live.begin(); iter != Live.end(); iter++) {
|
|
404
404
|
Block *Curr = *iter;
|
|
405
405
|
TotalCodeSize += strlen(Curr->Code);
|
|
@@ -417,7 +417,7 @@ void Relooper::Calculate(Block *Entry) {
|
|
|
417
417
|
for (BlockSet::iterator iter = Original->BranchesIn.begin(); iter != Original->BranchesIn.end(); iter++) {
|
|
418
418
|
Block *Prior = *iter;
|
|
419
419
|
Block *Split = new Block(Original->Code, Original->BranchVar);
|
|
420
|
-
Parent->
|
|
420
|
+
Parent->AddBlock(Split);
|
|
421
421
|
PrintDebug(" to %d\n", Split->Id);
|
|
422
422
|
Split->BranchesIn.insert(Prior);
|
|
423
423
|
Branch *Details = Prior->BranchesOut[Original];
|
|
@@ -451,7 +451,7 @@ void Relooper::Calculate(Block *Entry) {
|
|
|
451
451
|
Pre.FindLive(Entry);
|
|
452
452
|
|
|
453
453
|
// Add incoming branches from live blocks, ignoring dead code
|
|
454
|
-
for (
|
|
454
|
+
for (unsigned i = 0; i < Blocks.size(); i++) {
|
|
455
455
|
Block *Curr = Blocks[i];
|
|
456
456
|
if (!contains(Pre.Live, Curr)) continue;
|
|
457
457
|
for (BlockBranchMap::iterator iter = Curr->BranchesOut.begin(); iter != Curr->BranchesOut.end(); iter++) {
|
|
@@ -89,11 +89,11 @@ struct Block {
|
|
|
89
89
|
// setjmp returns, etc.)
|
|
90
90
|
//
|
|
91
91
|
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
92
|
+
struct SimpleShape;
|
|
93
|
+
struct LabeledShape;
|
|
94
|
+
struct MultipleShape;
|
|
95
|
+
struct LoopShape;
|
|
96
|
+
struct EmulatedShape;
|
|
97
97
|
|
|
98
98
|
struct Shape {
|
|
99
99
|
int Id; // A unique identifier. Used to identify loops, labels are Lx where x is the Id. Defined when added to relooper
|