aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAlon Zakai <alonzakai@gmail.com>2012-12-13 17:26:08 -0800
committerAlon Zakai <alonzakai@gmail.com>2012-12-13 17:26:08 -0800
commitd46071bcb61b555a51ee985c8b38e621a956bafa (patch)
treedbd903bfbd27341898e51b7ef7629dc59c001c94 /src
parent595191902fc7ac0d64b1a65182189873f7b47dfe (diff)
replace noticePtr hack with makeGlobalUse that detects use before indexing and makes unindexable
Diffstat (limited to 'src')
-rw-r--r--src/library.js34
-rw-r--r--src/parseTools.js21
2 files changed, 27 insertions, 28 deletions
diff --git a/src/library.js b/src/library.js
index c01b2d70..5bb414b0 100644
--- a/src/library.js
+++ b/src/library.js
@@ -4793,13 +4793,13 @@ LibraryManager.library = {
__cxa_throw: function(ptr, type, destructor) {
if (!___cxa_throw.initialized) {
try {
- {{{ makeSetValue('__ZTVN10__cxxabiv119__pointer_type_infoE', '0', '0', 'i32') }}}; // Workaround for libcxxabi integration bug
+ {{{ makeSetValue(makeGlobalUse('__ZTVN10__cxxabiv119__pointer_type_infoE'), '0', '0', 'i32') }}}; // Workaround for libcxxabi integration bug
} catch(e){}
try {
- {{{ makeSetValue('__ZTVN10__cxxabiv117__class_type_infoE', '0', '1', 'i32') }}}; // Workaround for libcxxabi integration bug
+ {{{ makeSetValue(makeGlobalUse('__ZTVN10__cxxabiv117__class_type_infoE'), '0', '1', 'i32') }}}; // Workaround for libcxxabi integration bug
} catch(e){}
try {
- {{{ makeSetValue('__ZTVN10__cxxabiv120__si_class_type_infoE', '0', '2', 'i32') }}}; // Workaround for libcxxabi integration bug
+ {{{ makeSetValue(makeGlobalUse('__ZTVN10__cxxabiv120__si_class_type_infoE'), '0', '2', 'i32') }}}; // Workaround for libcxxabi integration bug
} catch(e){}
___cxa_throw.initialized = true;
}
@@ -4897,20 +4897,20 @@ LibraryManager.library = {
__cxa_is_number_type: function(type) {
var isNumber = false;
- try { if (type == __ZTIi) isNumber = true } catch(e){}
- try { if (type == __ZTIj) isNumber = true } catch(e){}
- try { if (type == __ZTIl) isNumber = true } catch(e){}
- try { if (type == __ZTIm) isNumber = true } catch(e){}
- try { if (type == __ZTIx) isNumber = true } catch(e){}
- try { if (type == __ZTIy) isNumber = true } catch(e){}
- try { if (type == __ZTIf) isNumber = true } catch(e){}
- try { if (type == __ZTId) isNumber = true } catch(e){}
- try { if (type == __ZTIe) isNumber = true } catch(e){}
- try { if (type == __ZTIc) isNumber = true } catch(e){}
- try { if (type == __ZTIa) isNumber = true } catch(e){}
- try { if (type == __ZTIh) isNumber = true } catch(e){}
- try { if (type == __ZTIs) isNumber = true } catch(e){}
- try { if (type == __ZTIt) isNumber = true } catch(e){}
+ try { if (type == {{{ makeGlobalUse('__ZTIi') }}}) isNumber = true } catch(e){}
+ try { if (type == {{{ makeGlobalUse('__ZTIj') }}}) isNumber = true } catch(e){}
+ try { if (type == {{{ makeGlobalUse('__ZTIl') }}}) isNumber = true } catch(e){}
+ try { if (type == {{{ makeGlobalUse('__ZTIm') }}}) isNumber = true } catch(e){}
+ try { if (type == {{{ makeGlobalUse('__ZTIx') }}}) isNumber = true } catch(e){}
+ try { if (type == {{{ makeGlobalUse('__ZTIy') }}}) isNumber = true } catch(e){}
+ try { if (type == {{{ makeGlobalUse('__ZTIf') }}}) isNumber = true } catch(e){}
+ try { if (type == {{{ makeGlobalUse('__ZTId') }}}) isNumber = true } catch(e){}
+ try { if (type == {{{ makeGlobalUse('__ZTIe') }}}) isNumber = true } catch(e){}
+ try { if (type == {{{ makeGlobalUse('__ZTIc') }}}) isNumber = true } catch(e){}
+ try { if (type == {{{ makeGlobalUse('__ZTIa') }}}) isNumber = true } catch(e){}
+ try { if (type == {{{ makeGlobalUse('__ZTIh') }}}) isNumber = true } catch(e){}
+ try { if (type == {{{ makeGlobalUse('__ZTIs') }}}) isNumber = true } catch(e){}
+ try { if (type == {{{ makeGlobalUse('__ZTIt') }}}) isNumber = true } catch(e){}
return isNumber;
},
diff --git a/src/parseTools.js b/src/parseTools.js
index e8aeee1e..45d3d862 100644
--- a/src/parseTools.js
+++ b/src/parseTools.js
@@ -397,10 +397,6 @@ var UNINDEXABLE_GLOBALS = set(
'_llvm_global_ctors' // special-cased
);
-function noticePtr(ptr) {
- if (!NAMED_GLOBALS && !LibraryManager.loaded) UNINDEXABLE_GLOBALS[ptr] = 1; // we cannot index globals referred to in the library, since they are used there by name
-}
-
function isIndexableGlobal(ident) {
if (!(ident in Variables.globals)) return false;
if (ident in UNINDEXABLE_GLOBALS) return false;
@@ -415,8 +411,16 @@ function makeGlobalDef(ident) {
}
function makeGlobalUse(ident) {
- // We assert on TOTAL_STACK being equal to GLOBAL_BASE
- if (!NAMED_GLOBALS && isIndexableGlobal(ident)) return (TOTAL_STACK + Variables.indexedGlobals[ident]).toString();
+ if (!NAMED_GLOBALS && isIndexableGlobal(ident)) {
+ var index = Variables.indexedGlobals[ident];
+ if (index === undefined) {
+ // we are accessing this before we index globals, likely from the library. mark as unindexable
+ UNINDEXABLE_GLOBALS[ident] = 1;
+ return ident;
+ }
+ // We know and assert on TOTAL_STACK being equal to GLOBAL_BASE
+ return (TOTAL_STACK + index).toString();
+ }
return ident;
}
@@ -1013,7 +1017,6 @@ function makeGetTempDouble(i) {
// See makeSetValue
function makeGetValue(ptr, pos, type, noNeedFirst, unsigned, ignore, align, noSafe) {
- noticePtr(ptr);
if (UNALIGNED_MEMORY) align = 1;
if (isStructType(type)) {
var typeData = Types.types[type];
@@ -1104,7 +1107,6 @@ function indexizeFunctions(value, type) {
//! which means we should write to all slabs, ignore type differences if any on reads, etc.
//! @param noNeedFirst Whether to ignore the offset in the pointer itself.
function makeSetValue(ptr, pos, value, type, noNeedFirst, ignore, align, noSafe, sep, forcedAlign) {
- noticePtr(ptr);
if (UNALIGNED_MEMORY && !forcedAlign) align = 1;
sep = sep || ';';
if (isStructType(type)) {
@@ -1176,7 +1178,6 @@ var SEEK_OPTIMAL_ALIGN_MIN = 20;
var UNROLL_LOOP_MAX = 8;
function makeSetValues(ptr, pos, value, type, num, align) {
- noticePtr(ptr);
function unroll(type, num, jump, value$) {
jump = jump || 1;
value$ = value$ || value;
@@ -1226,8 +1227,6 @@ function makeSetValues(ptr, pos, value, type, num, align) {
var TYPED_ARRAY_SET_MIN = Infinity; // .set() as memcpy seems to just slow us down
function makeCopyValues(dest, src, num, type, modifier, align, sep) {
- noticePtr(dest);
- noticePtr(src);
sep = sep || ';';
function unroll(type, num, jump) {
jump = jump || 1;