add ASSERTIONS to asm2g, and fix assertions for asm

This commit is contained in:
Alon Zakai 2013-03-11 17:36:46 -07:00
Родитель 753b1f7eda
Коммит 8d53fec332
4 изменённых файлов: 9 добавлений и 7 удалений

Просмотреть файл

@ -735,7 +735,7 @@ function JSify(data, functionsOnly, givenFunctions) {
return indent + ' case ' + getLabelId(label.ident) + ': ' + (SHOW_LABELS ? '// ' + getOriginalLabelId(label.ident) : '') + '\n'
+ getLabelLines(label, indent + ' ');
}).join('\n') + '\n';
if (ASSERTIONS) ret += indent + ' default: assert(0, "bad label: " + label);\n';
if (ASSERTIONS) ret += indent + ' default: assert(0' + (ASM_JS ? '' : ', "bad label: " + label') + ');\n';
ret += indent + '}\n';
if (func.setjmpTable) {
ret += ' } catch(e) { if (!e.longjmp || !(e.id in mySetjmpIds)) throw(e); setjmpTable[setjmpLabels[e.id]](e.value) }';
@ -1454,7 +1454,7 @@ function JSify(data, functionsOnly, givenFunctions) {
makeFuncLineActor('unreachable', function(item) {
if (ASSERTIONS) {
return 'throw "Reached an unreachable!"';
return ASM_JS ? 'abort()' : 'throw "Reached an unreachable!"';
} else {
return ';';
}

Просмотреть файл

@ -4155,7 +4155,9 @@ LibraryManager.library = {
memcpy__inline: function (dest, src, num, align) {
var ret = '';
#if ASSERTIONS
#if ASM_JS == 0
ret += "assert(" + num + " % 1 === 0);"; //, 'memcpy given ' + " + num + " + ' bytes to copy. Problem with quantum=1 corrections perhaps?');";
#endif
#endif
ret += makeCopyValues(dest, src, num, 'null', null, align);
return ret;

Просмотреть файл

@ -27,7 +27,7 @@ var RuntimeGenerator = {
// The stack is always QUANTUM SIZE aligned, so we may not need to force alignment here
var ret = RuntimeGenerator.alloc(size, 'STACK', false, sep, USE_TYPED_ARRAYS != 2 || (isNumber(size) && parseInt(size) % {{{ QUANTUM_SIZE }}} == 0));
if (ASSERTIONS) {
ret += sep + 'assert(STACKTOP|0 < STACK_MAX|0)';
ret += sep + 'assert(' + asmCoercion('(STACKTOP|0) < (STACK_MAX|0)', 'i32') + ')';
}
return ret;
},
@ -38,12 +38,12 @@ var RuntimeGenerator = {
if (initial > 0) ret += '; STACKTOP = (STACKTOP + ' + initial + ')|0';
if (USE_TYPED_ARRAYS == 2) {
assert(initial % QUANTUM_SIZE == 0);
if (ASSERTIONS) {
ret += '; assert(STACKTOP|0 % {{{ QUANTUM_SIZE }}} == 0)';
if (ASSERTIONS && QUANTUM_SIZE == 4) {
ret += '; assert(' + asmCoercion('!(STACKTOP&3)', 'i32') + ')';
}
}
if (ASSERTIONS) {
ret += '; assert(STACKTOP < STACK_MAX)';
ret += '; assert(' + asmCoercion('(STACKTOP|0) < (STACK_MAX|0)', 'i32') + ')';
}
if (false) {
ret += '; _memset(' + asmCoercion('__stackBase__', 'i32') + ', 0, ' + initial + ')';

Просмотреть файл

@ -8635,7 +8635,7 @@ TT = %s
# asm.js
exec('asm2 = make_run("asm2", compiler=CLANG, emcc_args=["-O2", "-s", "ASM_JS=1"])')
exec('asm2g = make_run("asm2g", compiler=CLANG, emcc_args=["-O2", "-s", "ASM_JS=1", "-g"])')
exec('asm2g = make_run("asm2g", compiler=CLANG, emcc_args=["-O2", "-s", "ASM_JS=1", "-g", "-s", "ASSERTIONS=1"])')
# Make custom runs with various options
for compiler, quantum, embetter, typed_arrays, llvm_opts in [