Skip to content

Commit 9173bc3

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

File tree

2 files changed

+14
-97
lines changed

2 files changed

+14
-97
lines changed

ChangeLog.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,10 @@ 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 no uses internally and was
25+
removed (and replaced with an assert) as it had now uses internally and was
26+
untested.
2327

2428
3.1.16 - 07/14/2022
2529
-------------------

src/parseTools.js

Lines changed: 10 additions & 97 deletions
Original file line numberDiff line numberDiff line change
@@ -358,6 +358,7 @@ function makeSetTempDouble(i, type, value) {
358358

359359
// See makeSetValue
360360
function makeGetValue(ptr, pos, type, noNeedFirst, unsigned, ignore, align) {
361+
assert(typeof align === 'undefined', 'makeGetValue no longer supports align parameter');
361362
if (typeof unsigned !== 'undefined') {
362363
// TODO(sbc): make this into an error at some point.
363364
printErr('makeGetValue: Please use u8/u16/u32/u64 unsigned types in favor of additional argument');
@@ -369,42 +370,6 @@ function makeGetValue(ptr, pos, type, noNeedFirst, unsigned, ignore, align) {
369370
unsigned = true;
370371
}
371372

372-
if (type == 'double' && (align < 8)) {
373-
const setdouble1 = makeSetTempDouble(0, 'i32', makeGetValue(ptr, pos, 'i32', noNeedFirst, unsigned, ignore, align));
374-
const setdouble2 = makeSetTempDouble(1, 'i32', makeGetValue(ptr, getFastValue(pos, '+', Runtime.getNativeTypeSize('i32')), 'i32', noNeedFirst, unsigned, ignore, align));
375-
return '(' + setdouble1 + ',' + setdouble2 + ',' + makeGetTempDouble(0, 'double') + ')';
376-
}
377-
378-
if (align) {
379-
// Alignment is important here. May need to split this up
380-
const bytes = Runtime.getNativeTypeSize(type);
381-
if (bytes > align) {
382-
let ret = '(';
383-
if (isIntImplemented(type)) {
384-
if (bytes == 4 && align == 2) {
385-
// Special case that we can optimize
386-
ret += makeGetValue(ptr, pos, 'i16', noNeedFirst, 2, ignore, 2) + '|' +
387-
'(' + makeGetValue(ptr, getFastValue(pos, '+', 2), 'i16', noNeedFirst, 2, ignore, 2) + '<<16)';
388-
} else { // XXX we cannot truly handle > 4... (in x86)
389-
ret = '';
390-
for (let i = 0; i < bytes; i++) {
391-
ret += '(' + makeGetValue(ptr, getFastValue(pos, '+', i), 'i8', noNeedFirst, 1, ignore, 1) + (i > 0 ? '<<' + (8 * i) : '') + ')';
392-
if (i < bytes - 1) ret += '|';
393-
}
394-
ret = '(' + makeSignOp(ret, type, unsigned ? 'un' : 're', true);
395-
}
396-
} else {
397-
if (type == 'float') {
398-
ret += 'copyTempFloat(' + asmCoercion(getFastValue(ptr, '+', pos), 'i32') + '),' + makeGetTempDouble(0, 'float');
399-
} else {
400-
ret += 'copyTempDouble(' + asmCoercion(getFastValue(ptr, '+', pos), 'i32') + '),' + makeGetTempDouble(0, 'double');
401-
}
402-
}
403-
ret += ')';
404-
return ret;
405-
}
406-
}
407-
408373
const offset = calcFastOffset(ptr, pos, noNeedFirst);
409374
if (type === 'i53' || type === 'u53') {
410375
return 'readI53From' + (unsigned ? 'U' : 'I') + '64(' + offset + ')';
@@ -429,11 +394,12 @@ function makeGetValue(ptr, pos, type, noNeedFirst, unsigned, ignore, align) {
429394
* which means we should write to all slabs, ignore type differences if any on reads, etc.
430395
* @param {bool} noNeedFirst Whether to ignore the offset in the pointer itself.
431396
* @param {bool} ignore: legacy, ignored.
432-
* @param {number} align: TODO
397+
* @param {number} align: legacy, ignored.
433398
* @param {string} sep: TODO
434399
* @return {TODO}
435400
*/
436401
function makeSetValue(ptr, pos, value, type, noNeedFirst, ignore, align, sep = ';') {
402+
assert(typeof align === 'undefined', 'makeSetValue no longer supports align parameter');
437403
if (type == 'double' && (align < 8)) {
438404
return '(' + makeSetTempDouble(0, 'double', value) + ',' +
439405
makeSetValue(ptr, pos, makeGetTempDouble(0, 'i32'), 'i32', noNeedFirst, ignore, align, ',') + ',' +
@@ -446,23 +412,16 @@ function makeSetValue(ptr, pos, value, type, noNeedFirst, ignore, align, sep = '
446412

447413
const bits = getBits(type);
448414
const needSplitting = bits > 0 && !isPowerOfTwo(bits); // an unnatural type like i24
449-
if (align || needSplitting) {
415+
if (needSplitting) {
450416
// Alignment is important here, or we need to split this up for other reasons.
451417
const bytes = Runtime.getNativeTypeSize(type);
452-
if (bytes > align || needSplitting) {
418+
if (needSplitting) {
453419
let ret = '';
454420
if (isIntImplemented(type)) {
455-
if (bytes == 4 && align == 2) {
456-
// Special case that we can optimize
457-
ret += 'tempBigInt=' + value + sep;
458-
ret += makeSetValue(ptr, pos, 'tempBigInt&0xffff', 'i16', noNeedFirst, ignore, 2) + sep;
459-
ret += makeSetValue(ptr, getFastValue(pos, '+', 2), 'tempBigInt>>16', 'i16', noNeedFirst, ignore, 2);
460-
} else {
461-
ret += 'tempBigInt=' + value + sep;
462-
for (let i = 0; i < bytes; i++) {
463-
ret += makeSetValue(ptr, getFastValue(pos, '+', i), 'tempBigInt&0xff', 'i8', noNeedFirst, ignore, 1);
464-
if (i < bytes - 1) ret += sep + 'tempBigInt = tempBigInt>>8' + sep;
465-
}
421+
ret += 'tempBigInt=' + value + sep;
422+
for (let i = 0; i < bytes; i++) {
423+
ret += makeSetValue(ptr, getFastValue(pos, '+', i), 'tempBigInt&0xff', 'i8', noNeedFirst, ignore, 1);
424+
if (i < bytes - 1) ret += sep + 'tempBigInt = tempBigInt>>8' + sep;
466425
}
467426
} else {
468427
ret += makeSetValue('tempDoublePtr', 0, value, type, noNeedFirst, ignore, 8) + sep;
@@ -484,6 +443,7 @@ function makeSetValue(ptr, pos, value, type, noNeedFirst, ignore, align, sep = '
484443
const UNROLL_LOOP_MAX = 8;
485444

486445
function makeCopyValues(dest, src, num, type, modifier, align, sep = ';') {
446+
assert(typeof align === 'undefined');
487447
function unroll(type, num, jump) {
488448
jump = jump || 1;
489449
const setValues = range(num).map((i) => makeSetValue(dest, i * jump, makeGetValue(src, i * jump, type), type));
@@ -684,53 +644,6 @@ function makeThrow(what) {
684644
return `throw ${what};`;
685645
}
686646

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-
}
726-
return makeInlineCalculation('VALUE >= 0 ? VALUE : ' + Math.pow(2, bits) + '+VALUE', value, 'tempBigIntS');
727-
}
728-
}
729-
return full;
730-
}
731-
return value;
732-
}
733-
734647
function stripCorrections(param) {
735648
let m;
736649
while (true) {

0 commit comments

Comments
 (0)