aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xemscripten.py30
-rw-r--r--src/library_gl.js6
-rw-r--r--src/parseTools.js2
-rw-r--r--tests/test_core.py2
4 files changed, 30 insertions, 10 deletions
diff --git a/emscripten.py b/emscripten.py
index a507b0bf..907e88ce 100755
--- a/emscripten.py
+++ b/emscripten.py
@@ -793,6 +793,15 @@ def emscript_fast(infile, settings, outfile, libraries=[], compiler_engine=None,
#if DEBUG: print >> sys.stderr, "META", metadata
#if DEBUG: print >> sys.stderr, "meminit", mem_init
+ # function table masks
+
+ table_sizes = {}
+ for k, v in metadata['tables'].iteritems():
+ table_sizes[k] = str(v.count(',')) # undercounts by one, but that is what we want
+ funcs = re.sub(r"#FM_(\w+)#", lambda m: table_sizes[m.groups(0)[0]], funcs)
+
+ # js compiler
+
if DEBUG: logging.debug('emscript: js compiler glue')
# Integrate info from backend
@@ -827,6 +836,10 @@ def emscript_fast(infile, settings, outfile, libraries=[], compiler_engine=None,
last_forwarded_json = forwarded_json = json.loads(forwarded_data)
+ # merge in information from llvm backend
+
+ last_forwarded_json['Functions']['tables'] = metadata['tables']
+
'''indexed_functions = set()
for key in forwarded_json['Functions']['indexedFunctions'].iterkeys():
indexed_functions.add(key)'''
@@ -835,11 +848,13 @@ def emscript_fast(infile, settings, outfile, libraries=[], compiler_engine=None,
#print >> sys.stderr, 'glue:', pre, '\n\n||||||||||||||||\n\n', post, '...............'
- # memory initializer
+ # memory and global initializers
+
+ global_initializers = ', '.join(map(lambda i: '{ func: function() { %s() } }' % i, metadata['initializers']))
pre = pre.replace('STATICTOP = STATIC_BASE + 0;', '''STATICTOP = STATIC_BASE + Runtime.alignMemory(%d);
-/* global initializers */ __ATINIT__.push({ func: function() { runPostSets() } });
-%s''' % (mem_init.count(',')+1, mem_init)) # XXX wrong size calculation!
+/* global initializers */ __ATINIT__.push(%s);
+%s''' % (mem_init.count(',')+1, global_initializers, mem_init)) # XXX wrong size calculation!
funcs_js = [funcs]
if settings.get('ASM_JS'):
@@ -887,8 +902,11 @@ def emscript_fast(infile, settings, outfile, libraries=[], compiler_engine=None,
class Counter:
i = 0
j = 0
- pre_tables = last_forwarded_json['Functions']['tables']['pre']
- del last_forwarded_json['Functions']['tables']['pre']
+ if 'pre' in last_forwarded_json['Functions']['tables']:
+ pre_tables = last_forwarded_json['Functions']['tables']['pre']
+ del last_forwarded_json['Functions']['tables']['pre']
+ else:
+ pre_tables = ''
def make_table(sig, raw):
i = Counter.i
@@ -979,7 +997,7 @@ def emscript_fast(infile, settings, outfile, libraries=[], compiler_engine=None,
basic_funcs.append('extCall_%s' % sig)
# calculate exports
- exported_implemented_functions = list(exported_implemented_functions)
+ exported_implemented_functions = list(exported_implemented_functions) + metadata['initializers']
exported_implemented_functions.append('runPostSets')
exports = []
if not simple:
diff --git a/src/library_gl.js b/src/library_gl.js
index d2851211..cc39b048 100644
--- a/src/library_gl.js
+++ b/src/library_gl.js
@@ -4984,14 +4984,14 @@ var LibraryGL = {
glClearColor__sig: 'viiii',
glIsEnabled__sig: 'ii',
glFrontFace__sig: 'vi',
- glSampleCoverage__sig: 'vi',
+ glSampleCoverage__sig: 'vii',
};
// Simple pass-through functions. Starred ones have return values. [X] ones have X in the C name but not in the JS name
[[0, 'finish flush'],
- [1, 'clearDepth clearDepth[f] depthFunc enable disable frontFace cullFace clear lineWidth clearStencil depthMask stencilMask checkFramebufferStatus* generateMipmap activeTexture blendEquation sampleCoverage isEnabled*'],
- [2, 'blendFunc blendEquationSeparate depthRange depthRange[f] stencilMaskSeparate hint polygonOffset vertexAttrib1f'],
+ [1, 'clearDepth clearDepth[f] depthFunc enable disable frontFace cullFace clear lineWidth clearStencil depthMask stencilMask checkFramebufferStatus* generateMipmap activeTexture blendEquation isEnabled*'],
+ [2, 'blendFunc blendEquationSeparate depthRange depthRange[f] stencilMaskSeparate hint polygonOffset vertexAttrib1f sampleCoverage'],
[3, 'texParameteri texParameterf vertexAttrib2f stencilFunc stencilOp'],
[4, 'viewport clearColor scissor vertexAttrib3f colorMask renderbufferStorage blendFuncSeparate blendColor stencilFuncSeparate stencilOpSeparate'],
[5, 'vertexAttrib4f'],
diff --git a/src/parseTools.js b/src/parseTools.js
index ffd7c758..ff981264 100644
--- a/src/parseTools.js
+++ b/src/parseTools.js
@@ -1454,7 +1454,7 @@ function makeSetValues(ptr, pos, value, type, num, align) {
// If we don't know how to handle this at compile-time, or handling it is best done in a large amount of code, call memset
// TODO: optimize the case of numeric num but non-numeric value
if (!isNumber(num) || !isNumber(value) || (parseInt(num)/align >= UNROLL_LOOP_MAX)) {
- return '_memset(' + asmCoercion(getFastValue(ptr, '+', pos), 'i32') + ', ' + asmCoercion(value, 'i32') + ', ' + asmCoercion(num, 'i32') + ')';
+ return '_memset(' + asmCoercion(getFastValue(ptr, '+', pos), 'i32') + ', ' + asmCoercion(value, 'i32') + ', ' + asmCoercion(num, 'i32') + ')|0';
}
num = parseInt(num);
value = parseInt(value);
diff --git a/tests/test_core.py b/tests/test_core.py
index ec00c0a5..b3e57490 100644
--- a/tests/test_core.py
+++ b/tests/test_core.py
@@ -8749,6 +8749,8 @@ void*:16
self.do_run(path_from_root('tests', 'cubescript'), '*\nTemp is 33\n9\n5\nhello, everyone\n*', main_file='command.cpp')
+ if os.environ.get('EMCC_FAST_COMPILER') == '1': return self.skip('skipping extra parts in fastcomp')
+
assert 'asm2g' in test_modes
if self.run_name == 'asm2g':
results = {}