Skip to content

Commit 402a01c

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

File tree

2 files changed

+14
-98
lines changed

2 files changed

+14
-98
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 & 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
if (type === 'i53' || type === 'u53') {
412377
return 'readI53From' + (unsigned ? 'U' : 'I') + '64(' + offset + ')';
@@ -431,11 +396,12 @@ function makeGetValue(ptr, pos, type, noNeedFirst, unsigned, ignore, align) {
431396
* which means we should write to all slabs, ignore type differences if any on reads, etc.
432397
* @param {bool} noNeedFirst Whether to ignore the offset in the pointer itself.
433398
* @param {bool} ignore: legacy, ignored.
434-
* @param {number} align: TODO
399+
* @param {number} align: legacy, ignored.
435400
* @param {string} sep: TODO
436401
* @return {TODO}
437402
*/
438403
function makeSetValue(ptr, pos, value, type, noNeedFirst, ignore, align, sep = ';') {
404+
assert(typeof align === 'undefined', 'makeSetValue no longer supports align parameter');
439405
if (type == 'double' && (align < 8)) {
440406
return '(' + makeSetTempDouble(0, 'double', value) + ',' +
441407
makeSetValue(ptr, pos, makeGetTempDouble(0, 'i32'), 'i32', noNeedFirst, ignore, align, ',') + ',' +
@@ -448,23 +414,16 @@ function makeSetValue(ptr, pos, value, type, noNeedFirst, ignore, align, sep = '
448414

449415
const bits = getBits(type);
450416
const needSplitting = bits > 0 && !isPowerOfTwo(bits); // an unnatural type like i24
451-
if (align || needSplitting) {
417+
if (needSplitting) {
452418
// Alignment is important here, or we need to split this up for other reasons.
453419
const bytes = Runtime.getNativeTypeSize(type);
454-
if (bytes > align || needSplitting) {
420+
if (needSplitting) {
455421
let ret = '';
456422
if (isIntImplemented(type)) {
457-
if (bytes == 4 && align == 2) {
458-
// Special case that we can optimize
459-
ret += 'tempBigInt=' + value + sep;
460-
ret += makeSetValue(ptr, pos, 'tempBigInt&0xffff', 'i16', noNeedFirst, ignore, 2) + sep;
461-
ret += makeSetValue(ptr, getFastValue(pos, '+', 2), 'tempBigInt>>16', 'i16', noNeedFirst, ignore, 2);
462-
} else {
463-
ret += 'tempBigInt=' + value + sep;
464-
for (let i = 0; i < bytes; i++) {
465-
ret += makeSetValue(ptr, getFastValue(pos, '+', i), 'tempBigInt&0xff', 'i8', noNeedFirst, ignore, 1);
466-
if (i < bytes - 1) ret += sep + 'tempBigInt = tempBigInt>>8' + sep;
467-
}
423+
ret += 'tempBigInt=' + value + sep;
424+
for (let i = 0; i < bytes; i++) {
425+
ret += makeSetValue(ptr, getFastValue(pos, '+', i), 'tempBigInt&0xff', 'i8', noNeedFirst, ignore, 1);
426+
if (i < bytes - 1) ret += sep + 'tempBigInt = tempBigInt>>8' + sep;
468427
}
469428
} else {
470429
ret += makeSetValue('tempDoublePtr', 0, value, type, noNeedFirst, ignore, 8) + sep;
@@ -486,6 +445,7 @@ function makeSetValue(ptr, pos, value, type, noNeedFirst, ignore, align, sep = '
486445
const UNROLL_LOOP_MAX = 8;
487446

488447
function makeCopyValues(dest, src, num, type, modifier, align, sep = ';') {
448+
assert(typeof align === 'undefined');
489449
function unroll(type, num, jump) {
490450
jump = jump || 1;
491451
const setValues = range(num).map((i) => makeSetValue(dest, i * jump, makeGetValue(src, i * jump, type), type));
@@ -687,54 +647,6 @@ function makeThrow(what) {
687647
return `throw ${what};`;
688648
}
689649

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

0 commit comments

Comments
 (0)