Skip to content

Commit dfa7995

Browse files
committed
Merge branch 'incoming' into merge-mar-13-2015
2 parents dabd95d + cabb144 commit dfa7995

File tree

4 files changed

+10
-26
lines changed

4 files changed

+10
-26
lines changed

emcc

+5
Original file line numberDiff line numberDiff line change
@@ -1504,6 +1504,11 @@ try:
15041504
# add explicit label setting, as we will run aggressiveVariableElimination late, *after* 'label' is no longer notable by name
15051505
js_optimizer_queue += ['safeLabelSetting']
15061506

1507+
if shared.Settings.EMTERPRETIFY:
1508+
# add explicit label setting, as we will run aggressiveVariableElimination late, *after* 'label' is no longer notable by name
1509+
js_optimizer_queue += ['safeLabelSetting']
1510+
1511+
if opt_level >= 2:
15071512
if shared.Settings.RELOOP and not shared.Settings.ASM_JS:
15081513
js_optimizer_queue += ['optimizeShiftsAggressive', get_eliminate()] # aggressive shifts optimization requires loops, it breaks on switches
15091514

tests/test_other.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -4588,7 +4588,7 @@ def do_log_test(source, expected, func):
45884588
print ' seen', seen, ', expected ', expected, type(seen), type(expected)
45894589
assert expected == seen or (seen in expected if type(expected) in [list, tuple] else False), ['expect', expected, 'but see', seen]
45904590

4591-
do_log_test(path_from_root('tests', 'primes.cpp'), 86, 'main')
4591+
do_log_test(path_from_root('tests', 'primes.cpp'), 87, 'main')
45924592
do_log_test(path_from_root('tests', 'fannkuch.cpp'), 230, 'fannkuch_worker')
45934593

45944594
# test non-native as well, registerizeHarder can be a little more efficient here

tools/emterpretify.py

+1-8
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,7 @@ def handle_arg(arg):
221221

222222
'SWITCH', # [lx, ly, lz] switch (lx) { .. }. followed by a jump table for values in range [ly..ly+lz), after which is the default (which might be empty)
223223
'RET', # [l, 0, 0] return l (depending on which emterpreter_x we are in, has the right type)
224-
'FUNC', # [num params, total locals (low 8 bits), total locals (high 8 bits)] [which emterpreter (0 = normal, 1 = zero), 0, last zeroinit = num params + num zero-inits (low 8), (high 8)] function with n locals (each taking 64 bits), of which the first are params
224+
'FUNC', # [num params, total locals (low 8 bits), total locals (high 8 bits)] [which emterpreter (0 = normal, 1 = zero), 0, 0, 0] function with n locals (each taking 64 bits), of which the first are params
225225
# this is read in the emterpreter prelude, and also in intcalls
226226

227227
# slow locals support - copying from/to slow locals
@@ -679,12 +679,6 @@ def process(code):
679679
assert(((HEAPU8[pc>>0]>>>0) == %d)|0);
680680
lx = HEAPU16[pc + 2 >> 1] | 0; // num locals
681681
%s
682-
ly = HEAPU8[pc + 1 >> 0] | 0; // first zeroinit (after params)
683-
lz = HEAPU16[pc + 6 >> 1] | 0; // offset of last zeroinit
684-
while ((ly | 0) < (lz | 0)) { // clear the zeroinits
685-
%s = +0;
686-
ly = ly + 1 | 0;
687-
}
688682
%s
689683
//print('enter func ' + [pc, HEAPU8[pc + 0],HEAPU8[pc + 1],HEAPU8[pc + 2],HEAPU8[pc + 3],HEAPU8[pc + 4],HEAPU8[pc + 5],HEAPU8[pc + 6],HEAPU8[pc + 7]].join(', '));
690684
//var first = true;
@@ -702,7 +696,6 @@ def process(code):
702696
ROPCODES['FUNC'],
703697
(''' EMTSTACKTOP = EMTSTACKTOP + (lx ''' + (' + 1 ' if ASYNC else '') + '''<< 3) | 0;
704698
assert(((EMTSTACKTOP|0) <= (EMT_STACK_MAX|0))|0);\n''' + (' if ((asyncState|0) != 2) {' if ASYNC else '')) if not zero else '',
705-
get_access('ly', s='d'),
706699
' } else { pc = (HEAP32[sp - 4 >> 2] | 0) - 8 | 0; }' if ASYNC else '',
707700
main_loop,
708701
))

tools/js-optimizer.js

+3-17
Original file line numberDiff line numberDiff line change
@@ -7610,23 +7610,9 @@ function emterpretify(ast) {
76107610
}
76117611
assert(numLocals < FAST_LOCALS, 'way too many params!');
76127612
assert(FAST_LOCALS < 256);
7613-
var zeroInits;
7614-
if (numVars < FAST_LOCALS*2) {
7615-
zeroInits = findUninitializedVars(func, asmData);
7616-
} else {
7617-
zeroInits = copy(asmData.vars); // give up - tons of vars, this will be slow anyhow, and findUninitializedVars is non-linear so can be very slow on massive function
7618-
}
7619-
for (var zero in zeroInits) {
7620-
locals[zero] = numLocals++;
7621-
if (numLocals === FAST_LOCALS) numLocals = 256; // jump over the temps, remaining locals are slow locals
7622-
}
7623-
var lastZeroInit = func[2].length + numLocals; // may be higher than func[2].length + numZeroInits, due to jumping over temps
7624-
// this means if we have very many zeroinits, we end up zeroing out the temps, oh well
76257613
for (var i in asmData.vars) {
7626-
if (!(i in zeroInits)) {
7627-
locals[i] = numLocals++; // TODO: sort by frequency of appearance, so common ones are fast, rare are slow
7628-
if (numLocals === FAST_LOCALS) numLocals = 256; // jump over the temps, remaining locals are slow locals
7629-
}
7614+
locals[i] = numLocals++; // TODO: sort by frequency of appearance, so common ones are fast, rare are slow
7615+
if (numLocals === FAST_LOCALS) numLocals = 256; // jump over the temps, remaining locals are slow locals
76307616
}
76317617
var withSlowLocals = numLocals;
76327618
numLocals = Math.min(numLocals, FAST_LOCALS); // ignore the slow locals
@@ -7650,7 +7636,7 @@ function emterpretify(ast) {
76507636
// calculate final count of local variables, and emit func header
76517637
var finalLocals = Math.max(numLocals, maxLocal+1, withSlowLocals);
76527638
assert(finalLocals < 65535, 'too many locals ' + [maxLocal, numLocals, withSlowLocals]);
7653-
code = ['FUNC', func[2].length, finalLocals & 255, finalLocals >>> 8, 0, 0, lastZeroInit & 255, lastZeroInit >>> 8].concat(constants).concat(code);
7639+
code = ['FUNC', func[2].length, finalLocals & 255, finalLocals >>> 8, 0, 0, 0, 0].concat(constants).concat(code);
76547640
verifyCode(code);
76557641

76567642
finalizeJumps(code);

0 commit comments

Comments
 (0)