diff options
-rw-r--r-- | src/jsifier.js | 13 | ||||
-rw-r--r-- | src/library.js | 24 | ||||
-rw-r--r-- | src/library_gl.js | 38 | ||||
-rw-r--r-- | tests/websockets.c | 2 | ||||
-rw-r--r-- | tests/websockets_bi.c | 2 | ||||
-rw-r--r-- | tests/websockets_bi_bigdata.c | 2 | ||||
-rw-r--r-- | tests/websockets_bi_listener.c | 2 | ||||
-rw-r--r-- | tests/websockets_gethostbyname.c | 2 |
8 files changed, 51 insertions, 34 deletions
diff --git a/src/jsifier.js b/src/jsifier.js index 84a9b5f7..761a5fec 100644 --- a/src/jsifier.js +++ b/src/jsifier.js @@ -1394,6 +1394,19 @@ function JSify(data, functionsOnly, givenFunctions) { return inline.apply(null, args); // Warning: inlining does not prevent recalculation of the arguments. They should be simple identifiers } + if (ASM_JS) { + // remove unneeded arguments, which the asm sig can show us. this lets us alias memset with llvm.memset, we just + // drop the final 2 args so things validate properly in asm + var libsig = LibraryManager.library[shortident + '__sig']; + if (libsig) { + assert(!hasVarArgs); + while (libsig.length - 1 < args.length) { + args.pop(); + argsTypes.pop(); + } + } + } + var returnType; if (byPointer || ASM_JS) { returnType = getReturnType(type); diff --git a/src/library.js b/src/library.js index cb892251..53fc8617 100644 --- a/src/library.js +++ b/src/library.js @@ -4236,16 +4236,20 @@ LibraryManager.library = { llvm_memcpy_p0i8_p0i8_i32: 'memcpy', llvm_memcpy_p0i8_p0i8_i64: 'memcpy', + memmove__sig: 'viii', + memmove__asm: true, memmove__deps: ['memcpy'], - memmove: function(dest, src, num, align) { - if (src < dest && dest < src + num) { - // Copy backwards in a safe manner - src += num; - dest += num; - while (num--) { - dest--; - src--; - {{{ makeCopyValues('dest', 'src', 1, 'null', null, 1) }}}; + memmove: function(dest, src, num) { + dest = dest|0; src = src|0; num = num|0; + if ((src|0 < (dest|0)) & (dest|0 < ((src + num)|0))) { + // Unlikely case: Copy backwards in a safe manner + src = (src + num)|0; + dest = (dest + num)|0; + while (num|0 > 0) { + dest = (dest - 1)|0; + src = (src - 1)|0; + num = (num - 1)|0; + {{{ makeSetValueAsm('dest', 0, makeGetValueAsm('src', 0, 'i8'), 'i8') }}}; } } else { _memcpy(dest, src, num); @@ -7023,7 +7027,7 @@ LibraryManager.library = { if (!info) return -1; if (info.inQueue.length == 0) { ___setErrNo(ERRNO_CODES.EAGAIN); // no data, and all sockets are nonblocking, so this is the right behavior - return 0; // should this be -1 like the spec says? + return -1; } var buffer = info.inQueue.shift(); #if SOCKET_DEBUG diff --git a/src/library_gl.js b/src/library_gl.js index c153a181..0566b3a0 100644 --- a/src/library_gl.js +++ b/src/library_gl.js @@ -725,22 +725,22 @@ var LibraryGL = { }, glVertexAttrib1fv: function(index, v) { - v = {{{ makeHEAPView('F32', 'v', 'v+1*4') }}}; + v = {{{ makeHEAPView('F32', 'v', 'v+' + (1*4)) }}}; Module.ctx.vertexAttrib1fv(index, v); }, glVertexAttrib2fv: function(index, v) { - v = {{{ makeHEAPView('F32', 'v', 'v+2*4') }}}; + v = {{{ makeHEAPView('F32', 'v', 'v+' + (2*4)) }}}; Module.ctx.vertexAttrib2fv(index, v); }, glVertexAttrib3fv: function(index, v) { - v = {{{ makeHEAPView('F32', 'v', 'v+3*4') }}}; + v = {{{ makeHEAPView('F32', 'v', 'v+' + (3*4)) }}}; Module.ctx.vertexAttrib3fv(index, v); }, glVertexAttrib4fv: function(index, v) { - v = {{{ makeHEAPView('F32', 'v', 'v+4*4') }}}; + v = {{{ makeHEAPView('F32', 'v', 'v+' + (4*4)) }}}; Module.ctx.vertexAttrib4fv(index, v); }, @@ -2380,7 +2380,7 @@ var LibraryGL = { glLoadMatrixd: function(matrix) { GL.immediate.matricesModified = true; - GL.immediate.matrix.lib.mat4.set({{{ makeHEAPView('F64', 'matrix', 'matrix+16*8') }}}, GL.immediate.matrix[GL.immediate.currentMatrix]); + GL.immediate.matrix.lib.mat4.set({{{ makeHEAPView('F64', 'matrix', 'matrix+' + (16*8)) }}}, GL.immediate.matrix[GL.immediate.currentMatrix]); }, glLoadMatrixf: function(matrix) { @@ -2388,37 +2388,37 @@ var LibraryGL = { if (GL.debug) Module.printErr('glLoadMatrixf receiving: ' + Array.prototype.slice.call(HEAPF32.subarray(matrix >> 2, (matrix >> 2) + 16))); #endif GL.immediate.matricesModified = true; - GL.immediate.matrix.lib.mat4.set({{{ makeHEAPView('F32', 'matrix', 'matrix+16*4') }}}, GL.immediate.matrix[GL.immediate.currentMatrix]); + GL.immediate.matrix.lib.mat4.set({{{ makeHEAPView('F32', 'matrix', 'matrix+' + (16*4)) }}}, GL.immediate.matrix[GL.immediate.currentMatrix]); }, glLoadTransposeMatrixd: function(matrix) { GL.immediate.matricesModified = true; - GL.immediate.matrix.lib.mat4.set({{{ makeHEAPView('F64', 'matrix', 'matrix+16*8') }}}, GL.immediate.matrix[GL.immediate.currentMatrix]); + GL.immediate.matrix.lib.mat4.set({{{ makeHEAPView('F64', 'matrix', 'matrix+' + (16*8)) }}}, GL.immediate.matrix[GL.immediate.currentMatrix]); GL.immediate.matrix.lib.mat4.transpose(GL.immediate.matrix[GL.immediate.currentMatrix]); }, glLoadTransposeMatrixf: function(matrix) { GL.immediate.matricesModified = true; - GL.immediate.matrix.lib.mat4.set({{{ makeHEAPView('F32', 'matrix', 'matrix+16*4') }}}, GL.immediate.matrix[GL.immediate.currentMatrix]); + GL.immediate.matrix.lib.mat4.set({{{ makeHEAPView('F32', 'matrix', 'matrix+' + (16*4)) }}}, GL.immediate.matrix[GL.immediate.currentMatrix]); GL.immediate.matrix.lib.mat4.transpose(GL.immediate.matrix[GL.immediate.currentMatrix]); }, glMultMatrixd: function(matrix) { GL.immediate.matricesModified = true; GL.immediate.matrix.lib.mat4.multiply(GL.immediate.matrix[GL.immediate.currentMatrix], - {{{ makeHEAPView('F64', 'matrix', 'matrix+16*8') }}}); + {{{ makeHEAPView('F64', 'matrix', 'matrix+' + (16*8)) }}}); }, glMultMatrixf: function(matrix) { GL.immediate.matricesModified = true; GL.immediate.matrix.lib.mat4.multiply(GL.immediate.matrix[GL.immediate.currentMatrix], - {{{ makeHEAPView('F32', 'matrix', 'matrix+16*4') }}}); + {{{ makeHEAPView('F32', 'matrix', 'matrix+' + (16*4)) }}}); }, glMultTransposeMatrixd: function(matrix) { GL.immediate.matricesModified = true; var colMajor = GL.immediate.matrix.lib.mat4.create(); - GL.immediate.matrix.lib.mat4.set({{{ makeHEAPView('F64', 'matrix', 'matrix+16*8') }}}, colMajor); + GL.immediate.matrix.lib.mat4.set({{{ makeHEAPView('F64', 'matrix', 'matrix+' + (16*8)) }}}, colMajor); GL.immediate.matrix.lib.mat4.transpose(colMajor); GL.immediate.matrix.lib.mat4.multiply(GL.immediate.matrix[GL.immediate.currentMatrix], colMajor); }, @@ -2426,7 +2426,7 @@ var LibraryGL = { glMultTransposeMatrixf: function(matrix) { GL.immediate.matricesModified = true; var colMajor = GL.immediate.matrix.lib.mat4.create(); - GL.immediate.matrix.lib.mat4.set({{{ makeHEAPView('F32', 'matrix', 'matrix+16*4') }}}, colMajor); + GL.immediate.matrix.lib.mat4.set({{{ makeHEAPView('F32', 'matrix', 'matrix+' + (16*4)) }}}, colMajor); GL.immediate.matrix.lib.mat4.transpose(colMajor); GL.immediate.matrix.lib.mat4.multiply(GL.immediate.matrix[GL.immediate.currentMatrix], colMajor); }, @@ -2481,9 +2481,9 @@ var LibraryGL = { var inVec = new Float32Array(4); var outVec = new Float32Array(4); - GL.immediate.matrix.lib.mat4.multiplyVec4({{{ makeHEAPView('F64', 'model', 'model+16*8') }}}, + GL.immediate.matrix.lib.mat4.multiplyVec4({{{ makeHEAPView('F64', 'model', 'model+' + (16*8)) }}}, [objX, objY, objZ, 1.0], outVec); - GL.immediate.matrix.lib.mat4.multiplyVec4({{{ makeHEAPView('F64', 'proj', 'proj+16*8') }}}, + GL.immediate.matrix.lib.mat4.multiplyVec4({{{ makeHEAPView('F64', 'proj', 'proj+' + (16*8)) }}}, outVec, inVec); if (inVec[3] == 0.0) { return 0 /* GL_FALSE */; @@ -2496,8 +2496,8 @@ var LibraryGL = { inVec[1] = inVec[1] * 0.5 + 0.5; inVec[2] = inVec[2] * 0.5 + 0.5; // Map x, y to viewport - inVec[0] = inVec[0] * {{{ makeGetValue('view', '2*4', 'i32') }}} + {{{ makeGetValue('view', '0*4', 'i32') }}}; - inVec[1] = inVec[1] * {{{ makeGetValue('view', '3*4', 'i32') }}} + {{{ makeGetValue('view', '1*4', 'i32') }}}; + inVec[0] = inVec[0] * {{{ makeGetValue('view', 2*4, 'i32') }}} + {{{ makeGetValue('view', 0*4, 'i32') }}}; + inVec[1] = inVec[1] * {{{ makeGetValue('view', 3*4, 'i32') }}} + {{{ makeGetValue('view', 1*4, 'i32') }}}; {{{ makeSetValue('winX', '0', 'inVec[0]', 'double') }}}; {{{ makeSetValue('winY', '0', 'inVec[1]', 'double') }}}; @@ -2508,9 +2508,9 @@ var LibraryGL = { gluUnProject: function(winX, winY, winZ, model, proj, view, objX, objY, objZ) { var result = GL.immediate.matrix.lib.mat4.unproject([winX, winY, winZ], - {{{ makeHEAPView('F64', 'model', 'model+16*8') }}}, - {{{ makeHEAPView('F64', 'proj', 'proj+16*8') }}}, - {{{ makeHEAPView('32', 'view', 'view+4*4') }}}); + {{{ makeHEAPView('F64', 'model', 'model+' + (16*8)) }}}, + {{{ makeHEAPView('F64', 'proj', 'proj+' + (16*8)) }}}, + {{{ makeHEAPView('32', 'view', 'view+' + (4*4)) }}}); if (result === null) { return 0 /* GL_FALSE */; diff --git a/tests/websockets.c b/tests/websockets.c index 57549e94..59acbd69 100644 --- a/tests/websockets.c +++ b/tests/websockets.c @@ -50,7 +50,7 @@ unsigned int get_all_buf(int sock, char* output, unsigned int maxsize) } } - if(n < 0) { + if(n < 0 && errno != EAGAIN && errno != EWOULDBLOCK) { fprintf(stderr, "error in get_all_buf!"); exit(EXIT_FAILURE); } diff --git a/tests/websockets_bi.c b/tests/websockets_bi.c index c2dbb7da..18cdd664 100644 --- a/tests/websockets_bi.c +++ b/tests/websockets_bi.c @@ -35,7 +35,7 @@ unsigned int get_all_buf(int sock, char* output, unsigned int maxsize) } } - if(n < 0) { + if(n < 0 && errno != EAGAIN && errno != EWOULDBLOCK) { fprintf(stderr, "error in get_all_buf!"); exit(EXIT_FAILURE); } diff --git a/tests/websockets_bi_bigdata.c b/tests/websockets_bi_bigdata.c index 5db2c951..2039f83c 100644 --- a/tests/websockets_bi_bigdata.c +++ b/tests/websockets_bi_bigdata.c @@ -37,7 +37,7 @@ unsigned int get_all_buf(int sock, char* output, unsigned int maxsize) } } - if(n < 0) { + if(n < 0 && errno != EAGAIN && errno != EWOULDBLOCK) { fprintf(stderr, "error in get_all_buf!"); exit(EXIT_FAILURE); } diff --git a/tests/websockets_bi_listener.c b/tests/websockets_bi_listener.c index 587fbed2..6c3b17b1 100644 --- a/tests/websockets_bi_listener.c +++ b/tests/websockets_bi_listener.c @@ -35,7 +35,7 @@ unsigned int get_all_buf(int sock, char* output, unsigned int maxsize) } } - if(n < 0) { + if(n < 0 && errno != EAGAIN && errno != EWOULDBLOCK) { fprintf(stderr, "error in get_all_buf!"); exit(EXIT_FAILURE); } diff --git a/tests/websockets_gethostbyname.c b/tests/websockets_gethostbyname.c index 6b8777f1..cba2c635 100644 --- a/tests/websockets_gethostbyname.c +++ b/tests/websockets_gethostbyname.c @@ -35,7 +35,7 @@ unsigned int get_all_buf(int sock, char* output, unsigned int maxsize) } } - if(n < 0) { + if(n < 0 && errno != EAGAIN && errno != EWOULDBLOCK) { fprintf(stderr, "error in get_all_buf!"); exit(EXIT_FAILURE); } |