Skip to content

Commit 87083ed

Browse files
authored
Move unused makeCopyValues to parseTools_legacy.js (#18679)
1 parent b3ea75c commit 87083ed

File tree

2 files changed

+61
-61
lines changed

2 files changed

+61
-61
lines changed

src/parseTools.js

Lines changed: 0 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -399,39 +399,6 @@ function makeSetValue(ptr, pos, value, type, noNeedFirst, ignore, align, sep = '
399399
return slab + '[' + getHeapOffset(offset, type) + '] = ' + value;
400400
}
401401

402-
const UNROLL_LOOP_MAX = 8;
403-
404-
function makeCopyValues(dest, src, num, type, modifier, align, sep = ';') {
405-
assert(typeof align === 'undefined');
406-
function unroll(type, num, jump = 1) {
407-
const setValues = range(num).map((i) => makeSetValue(dest, i * jump, makeGetValue(src, i * jump, type), type));
408-
return setValues.join(sep);
409-
}
410-
// If we don't know how to handle this at compile-time, or handling it is best
411-
// done in a large amount of code, call memcpy
412-
if (!isNumber(num)) num = stripCorrections(num);
413-
if (!isNumber(align)) align = stripCorrections(align);
414-
if (!isNumber(num) || (parseInt(num) / align >= UNROLL_LOOP_MAX)) {
415-
return '(_memcpy(' + dest + ', ' + src + ', ' + num + ')|0)';
416-
}
417-
num = parseInt(num);
418-
// remove corrections, since we will be correcting after we add anyhow,
419-
dest = stripCorrections(dest);
420-
src = stripCorrections(src);
421-
// and in the heap assignment expression
422-
const ret = [];
423-
[4, 2, 1].forEach((possibleAlign) => {
424-
if (num == 0) return;
425-
if (align >= possibleAlign) {
426-
ret.push(unroll('i' + (possibleAlign * 8), Math.floor(num / possibleAlign), possibleAlign));
427-
src = getFastValue(src, '+', Math.floor(num / possibleAlign) * possibleAlign);
428-
dest = getFastValue(dest, '+', Math.floor(num / possibleAlign) * possibleAlign);
429-
num %= possibleAlign;
430-
}
431-
});
432-
return ret.join(sep);
433-
}
434-
435402
function makeHEAPView(which, start, end) {
436403
const size = parseInt(which.replace('U', '').replace('F', '')) / 8;
437404
const mod = size == 1 ? '' : ('>>' + Math.log2(size));
@@ -590,34 +557,6 @@ function makeThrow(what) {
590557
return `throw ${what};`;
591558
}
592559

593-
function stripCorrections(param) {
594-
let m;
595-
while (true) {
596-
if (m = /^\((.*)\)$/.exec(param)) {
597-
param = m[1];
598-
continue;
599-
}
600-
if (m = /^\(([$_\w]+)\)&\d+$/.exec(param)) {
601-
param = m[1];
602-
continue;
603-
}
604-
if (m = /^\(([$_\w()]+)\)\|0$/.exec(param)) {
605-
param = m[1];
606-
continue;
607-
}
608-
if (m = /^\(([$_\w()]+)\)\>>>0$/.exec(param)) {
609-
param = m[1];
610-
continue;
611-
}
612-
if (m = /CHECK_OVERFLOW\(([^,)]*),.*/.exec(param)) {
613-
param = m[1];
614-
continue;
615-
}
616-
break;
617-
}
618-
return param;
619-
}
620-
621560
function charCode(char) {
622561
return char.charCodeAt(0);
623562
}

src/parseTools_legacy.js

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,3 +23,64 @@ function receiveI64ParamAsDouble(name) {
2323
// 32 bits.
2424
return `var ${name} = ${name}_high * 0x100000000 + (${name}_low >>> 0);`;
2525
}
26+
27+
function stripCorrections(param) {
28+
let m;
29+
while (true) {
30+
if (m = /^\((.*)\)$/.exec(param)) {
31+
param = m[1];
32+
continue;
33+
}
34+
if (m = /^\(([$_\w]+)\)&\d+$/.exec(param)) {
35+
param = m[1];
36+
continue;
37+
}
38+
if (m = /^\(([$_\w()]+)\)\|0$/.exec(param)) {
39+
param = m[1];
40+
continue;
41+
}
42+
if (m = /^\(([$_\w()]+)\)\>>>0$/.exec(param)) {
43+
param = m[1];
44+
continue;
45+
}
46+
if (m = /CHECK_OVERFLOW\(([^,)]*),.*/.exec(param)) {
47+
param = m[1];
48+
continue;
49+
}
50+
break;
51+
}
52+
return param;
53+
}
54+
55+
const UNROLL_LOOP_MAX = 8;
56+
57+
function makeCopyValues(dest, src, num, type, modifier, align, sep = ';') {
58+
assert(typeof align === 'undefined');
59+
function unroll(type, num, jump = 1) {
60+
const setValues = range(num).map((i) => makeSetValue(dest, i * jump, makeGetValue(src, i * jump, type), type));
61+
return setValues.join(sep);
62+
}
63+
// If we don't know how to handle this at compile-time, or handling it is best
64+
// done in a large amount of code, call memcpy
65+
if (!isNumber(num)) num = stripCorrections(num);
66+
if (!isNumber(align)) align = stripCorrections(align);
67+
if (!isNumber(num) || (parseInt(num) / align >= UNROLL_LOOP_MAX)) {
68+
return '(_memcpy(' + dest + ', ' + src + ', ' + num + ')|0)';
69+
}
70+
num = parseInt(num);
71+
// remove corrections, since we will be correcting after we add anyhow,
72+
dest = stripCorrections(dest);
73+
src = stripCorrections(src);
74+
// and in the heap assignment expression
75+
const ret = [];
76+
[4, 2, 1].forEach((possibleAlign) => {
77+
if (num == 0) return;
78+
if (align >= possibleAlign) {
79+
ret.push(unroll('i' + (possibleAlign * 8), Math.floor(num / possibleAlign), possibleAlign));
80+
src = getFastValue(src, '+', Math.floor(num / possibleAlign) * possibleAlign);
81+
dest = getFastValue(dest, '+', Math.floor(num / possibleAlign) * possibleAlign);
82+
num %= possibleAlign;
83+
}
84+
});
85+
return ret.join(sep);
86+
}

0 commit comments

Comments
 (0)