Skip to content

Commit 16cba6b

Browse files
committed
Remove unused align support in makeGetValue/makeSetValue
Also, remove the now-dead `makeSignOp`.
1 parent a41b1a3 commit 16cba6b

File tree

2 files changed

+12
-98
lines changed

2 files changed

+12
-98
lines changed

ChangeLog.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@ See docs/process.md for more on how version tagging works.
2020

2121
3.1.17
2222
------
23+
- The `align` argument to the makeGetValue/makeSetValue JS library macros was
24+
removed (and replaced with an assert) as it had now uses internally and was
25+
untested.
2326

2427
3.1.16 - 07/14/2022
2528
-------------------

src/parseTools.js

Lines changed: 9 additions & 98 deletions
Original file line numberDiff line numberDiff line change
@@ -360,6 +360,7 @@ function makeSetTempDouble(i, type, value) {
360360

361361
// See makeSetValue
362362
function makeGetValue(ptr, pos, type, noNeedFirst, unsigned, ignore, align) {
363+
assert(typeof align === 'undefined', 'makeGetValue no longer supports align parameter');
363364
if (typeof unsigned !== 'undefined') {
364365
// TODO(sbc): make this into an error at some point.
365366
printErr('makeGetValue: Please use u8/u16/u32/u64 unsigned types in favor of additional argument');
@@ -371,42 +372,6 @@ function makeGetValue(ptr, pos, type, noNeedFirst, unsigned, ignore, align) {
371372
unsigned = true;
372373
}
373374

374-
if (type == 'double' && (align < 8)) {
375-
const setdouble1 = makeSetTempDouble(0, 'i32', makeGetValue(ptr, pos, 'i32', noNeedFirst, unsigned, ignore, align));
376-
const setdouble2 = makeSetTempDouble(1, 'i32', makeGetValue(ptr, getFastValue(pos, '+', Runtime.getNativeTypeSize('i32')), 'i32', noNeedFirst, unsigned, ignore, align));
377-
return '(' + setdouble1 + ',' + setdouble2 + ',' + makeGetTempDouble(0, 'double') + ')';
378-
}
379-
380-
if (align) {
381-
// Alignment is important here. May need to split this up
382-
const bytes = Runtime.getNativeTypeSize(type);
383-
if (bytes > align) {
384-
let ret = '(';
385-
if (isIntImplemented(type)) {
386-
if (bytes == 4 && align == 2) {
387-
// Special case that we can optimize
388-
ret += makeGetValue(ptr, pos, 'i16', noNeedFirst, 2, ignore, 2) + '|' +
389-
'(' + makeGetValue(ptr, getFastValue(pos, '+', 2), 'i16', noNeedFirst, 2, ignore, 2) + '<<16)';
390-
} else { // XXX we cannot truly handle > 4... (in x86)
391-
ret = '';
392-
for (let i = 0; i < bytes; i++) {
393-
ret += '(' + makeGetValue(ptr, getFastValue(pos, '+', i), 'i8', noNeedFirst, 1, ignore, 1) + (i > 0 ? '<<' + (8 * i) : '') + ')';
394-
if (i < bytes - 1) ret += '|';
395-
}
396-
ret = '(' + makeSignOp(ret, type, unsigned ? 'un' : 're', true);
397-
}
398-
} else {
399-
if (type == 'float') {
400-
ret += 'copyTempFloat(' + asmCoercion(getFastValue(ptr, '+', pos), 'i32') + '),' + makeGetTempDouble(0, 'float');
401-
} else {
402-
ret += 'copyTempDouble(' + asmCoercion(getFastValue(ptr, '+', pos), 'i32') + '),' + makeGetTempDouble(0, 'double');
403-
}
404-
}
405-
ret += ')';
406-
return ret;
407-
}
408-
}
409-
410375
const offset = calcFastOffset(ptr, pos, noNeedFirst);
411376

412377
const slab = getHeapForType(type);
@@ -428,11 +393,11 @@ function makeGetValue(ptr, pos, type, noNeedFirst, unsigned, ignore, align) {
428393
* which means we should write to all slabs, ignore type differences if any on reads, etc.
429394
* @param {bool} noNeedFirst Whether to ignore the offset in the pointer itself.
430395
* @param {bool} ignore: legacy, ignored.
431-
* @param {number} align: TODO
432396
* @param {string} sep: TODO
433397
* @return {TODO}
434398
*/
435399
function makeSetValue(ptr, pos, value, type, noNeedFirst, ignore, align, sep = ';') {
400+
assert(typeof align === 'undefined', 'makeSetValue no longer supports align parameter');
436401
if (type == 'double' && (align < 8)) {
437402
return '(' + makeSetTempDouble(0, 'double', value) + ',' +
438403
makeSetValue(ptr, pos, makeGetTempDouble(0, 'i32'), 'i32', noNeedFirst, ignore, align, ',') + ',' +
@@ -445,23 +410,16 @@ function makeSetValue(ptr, pos, value, type, noNeedFirst, ignore, align, sep = '
445410

446411
const bits = getBits(type);
447412
const needSplitting = bits > 0 && !isPowerOfTwo(bits); // an unnatural type like i24
448-
if (align || needSplitting) {
413+
if (needSplitting) {
449414
// Alignment is important here, or we need to split this up for other reasons.
450415
const bytes = Runtime.getNativeTypeSize(type);
451-
if (bytes > align || needSplitting) {
416+
if (needSplitting) {
452417
let ret = '';
453418
if (isIntImplemented(type)) {
454-
if (bytes == 4 && align == 2) {
455-
// Special case that we can optimize
456-
ret += 'tempBigInt=' + value + sep;
457-
ret += makeSetValue(ptr, pos, 'tempBigInt&0xffff', 'i16', noNeedFirst, ignore, 2) + sep;
458-
ret += makeSetValue(ptr, getFastValue(pos, '+', 2), 'tempBigInt>>16', 'i16', noNeedFirst, ignore, 2);
459-
} else {
460-
ret += 'tempBigInt=' + value + sep;
461-
for (let i = 0; i < bytes; i++) {
462-
ret += makeSetValue(ptr, getFastValue(pos, '+', i), 'tempBigInt&0xff', 'i8', noNeedFirst, ignore, 1);
463-
if (i < bytes - 1) ret += sep + 'tempBigInt = tempBigInt>>8' + sep;
464-
}
419+
ret += 'tempBigInt=' + value + sep;
420+
for (let i = 0; i < bytes; i++) {
421+
ret += makeSetValue(ptr, getFastValue(pos, '+', i), 'tempBigInt&0xff', 'i8', noNeedFirst, ignore, 1);
422+
if (i < bytes - 1) ret += sep + 'tempBigInt = tempBigInt>>8' + sep;
465423
}
466424
} else {
467425
ret += makeSetValue('tempDoublePtr', 0, value, type, noNeedFirst, ignore, 8) + sep;
@@ -483,6 +441,7 @@ function makeSetValue(ptr, pos, value, type, noNeedFirst, ignore, align, sep = '
483441
const UNROLL_LOOP_MAX = 8;
484442

485443
function makeCopyValues(dest, src, num, type, modifier, align, sep = ';') {
444+
assert(typeof align === 'undefined');
486445
function unroll(type, num, jump) {
487446
jump = jump || 1;
488447
const setValues = range(num).map((i) => makeSetValue(dest, i * jump, makeGetValue(src, i * jump, type), type));
@@ -684,54 +643,6 @@ function makeThrow(what) {
684643
return `throw ${what};`;
685644
}
686645

687-
function makeSignOp(value, type, op, force, ignore) {
688-
if (isPointerType(type)) type = POINTER_TYPE;
689-
if (!value) return value;
690-
let bits;
691-
let full;
692-
if (type[0] === 'i' || type[0] === 'u') {
693-
bits = parseInt(type.substr(1));
694-
full = op + 'Sign(' + value + ', ' + bits + ', ' + Math.floor(ignore) + ')';
695-
// Always sign/unsign constants at compile time, regardless of CHECK/CORRECT
696-
if (isNumber(value)) {
697-
return eval(full).toString();
698-
}
699-
}
700-
if ((ignore) && !force) return value;
701-
if (type[0] === 'i' || type[0] === 'u') {
702-
// this is an integer, but not a number (or we would have already handled it)
703-
// shortcuts
704-
if (ignore) {
705-
if (value === 'true') {
706-
value = '1';
707-
} else if (value === 'false') {
708-
value = '0';
709-
} else if (needsQuoting(value)) value = '(' + value + ')';
710-
if (bits === 32) {
711-
if (op === 're') {
712-
return '(' + value + '|0)';
713-
} else {
714-
return '(' + value + '>>>0)';
715-
}
716-
} else if (bits < 32) {
717-
if (op === 're') {
718-
return '((' + value + '<<' + (32 - bits) + ')>>' + (32 - bits) + ')';
719-
} else {
720-
return '(' + value + '&' + (Math.pow(2, bits) - 1) + ')';
721-
}
722-
} else { // bits > 32
723-
if (op === 're') {
724-
return makeInlineCalculation('VALUE >= ' + Math.pow(2, bits - 1) + ' ? VALUE-' + Math.pow(2, bits) + ' : VALUE', value, 'tempBigIntS');
725-
} else {
726-
return makeInlineCalculation('VALUE >= 0 ? VALUE : ' + Math.pow(2, bits) + '+VALUE', value, 'tempBigIntS');
727-
}
728-
}
729-
}
730-
return full;
731-
}
732-
return value;
733-
}
734-
735646
function stripCorrections(param) {
736647
let m;
737648
while (true) {

0 commit comments

Comments
 (0)