aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAlon Zakai <alonzakai@gmail.com>2013-02-22 18:16:21 -0800
committerAlon Zakai <alonzakai@gmail.com>2013-02-22 18:16:21 -0800
commit90710c0c8ee4425c06402cc7831abdee8c519a43 (patch)
tree7f18dac066988e902e93d4ba8b43fdc68cb6d82c /src
parent15595f1ea36fa4268e5db66b8717999f7f363621 (diff)
asmify memcmp
Diffstat (limited to 'src')
-rw-r--r--src/library.js13
-rw-r--r--src/parseTools.js4
2 files changed, 11 insertions, 6 deletions
diff --git a/src/library.js b/src/library.js
index d8f98d73..885fe1e0 100644
--- a/src/library.js
+++ b/src/library.js
@@ -4525,11 +4525,16 @@ LibraryManager.library = {
return 0;
},
+ memcmp__asm: 'true',
+ memcmp__sig: 'iiii',
memcmp: function(p1, p2, num) {
- for (var i = 0; i < num; i++) {
- var v1 = {{{ makeGetValue('p1', 'i', 'i8', 0, 1) }}};
- var v2 = {{{ makeGetValue('p2', 'i', 'i8', 0, 1) }}};
- if (v1 != v2) return v1 > v2 ? 1 : -1;
+ p1 = p1|0; p2 = p2|0; num = num|0;
+ var i = 0, v1 = 0, v2 = 0;
+ while ((i|0) < (num|0)) {
+ var v1 = {{{ makeGetValueAsm('p1', 'i', 'i8', true) }}};
+ var v2 = {{{ makeGetValueAsm('p2', 'i', 'i8', true) }}};
+ if ((v1|0) != (v2|0)) return (v1|0) > (v2|0) ? 1 : -1;
+ i = (i+1)|0;
}
return 0;
},
diff --git a/src/parseTools.js b/src/parseTools.js
index ca9ad40a..15c2169b 100644
--- a/src/parseTools.js
+++ b/src/parseTools.js
@@ -1145,8 +1145,8 @@ function makeGetValue(ptr, pos, type, noNeedFirst, unsigned, ignore, align, noSa
}
}
-function makeGetValueAsm(ptr, pos, type) {
- return makeGetValue(ptr, pos, type, null, null, null, null, null, true);
+function makeGetValueAsm(ptr, pos, type, unsigned) {
+ return makeGetValue(ptr, pos, type, null, unsigned, null, null, null, true);
}
function indexizeFunctions(value, type) {