@@ -358,6 +358,7 @@ function makeSetTempDouble(i, type, value) {
358
358
359
359
// See makeSetValue
360
360
function makeGetValue ( ptr , pos , type , noNeedFirst , unsigned , ignore , align ) {
361
+ assert ( typeof align === 'undefined' , 'makeGetValue no longer supports align parameter' ) ;
361
362
if ( typeof unsigned !== 'undefined' ) {
362
363
// TODO(sbc): make this into an error at some point.
363
364
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) {
369
370
unsigned = true ;
370
371
}
371
372
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
-
408
373
const offset = calcFastOffset ( ptr , pos , noNeedFirst ) ;
409
374
if ( type === 'i53' || type === 'u53' ) {
410
375
return 'readI53From' + ( unsigned ? 'U' : 'I' ) + '64(' + offset + ')' ;
@@ -429,11 +394,12 @@ function makeGetValue(ptr, pos, type, noNeedFirst, unsigned, ignore, align) {
429
394
* which means we should write to all slabs, ignore type differences if any on reads, etc.
430
395
* @param {bool } noNeedFirst Whether to ignore the offset in the pointer itself.
431
396
* @param {bool } ignore: legacy, ignored.
432
- * @param {number } align: TODO
397
+ * @param {number } align: legacy, ignored.
433
398
* @param {string } sep: TODO
434
399
* @return {TODO }
435
400
*/
436
401
function makeSetValue ( ptr , pos , value , type , noNeedFirst , ignore , align , sep = ';' ) {
402
+ assert ( typeof align === 'undefined' , 'makeSetValue no longer supports align parameter' ) ;
437
403
if ( type == 'double' && ( align < 8 ) ) {
438
404
return '(' + makeSetTempDouble ( 0 , 'double' , value ) + ',' +
439
405
makeSetValue ( ptr , pos , makeGetTempDouble ( 0 , 'i32' ) , 'i32' , noNeedFirst , ignore , align , ',' ) + ',' +
@@ -446,23 +412,16 @@ function makeSetValue(ptr, pos, value, type, noNeedFirst, ignore, align, sep = '
446
412
447
413
const bits = getBits ( type ) ;
448
414
const needSplitting = bits > 0 && ! isPowerOfTwo ( bits ) ; // an unnatural type like i24
449
- if ( align || needSplitting ) {
415
+ if ( needSplitting ) {
450
416
// Alignment is important here, or we need to split this up for other reasons.
451
417
const bytes = Runtime . getNativeTypeSize ( type ) ;
452
- if ( bytes > align || needSplitting ) {
418
+ if ( needSplitting ) {
453
419
let ret = '' ;
454
420
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 ;
466
425
}
467
426
} else {
468
427
ret += makeSetValue ( 'tempDoublePtr' , 0 , value , type , noNeedFirst , ignore , 8 ) + sep ;
@@ -484,6 +443,7 @@ function makeSetValue(ptr, pos, value, type, noNeedFirst, ignore, align, sep = '
484
443
const UNROLL_LOOP_MAX = 8 ;
485
444
486
445
function makeCopyValues ( dest , src , num , type , modifier , align , sep = ';' ) {
446
+ assert ( typeof align === 'undefined' ) ;
487
447
function unroll ( type , num , jump ) {
488
448
jump = jump || 1 ;
489
449
const setValues = range ( num ) . map ( ( i ) => makeSetValue ( dest , i * jump , makeGetValue ( src , i * jump , type ) , type ) ) ;
@@ -684,53 +644,6 @@ function makeThrow(what) {
684
644
return `throw ${ what } ;` ;
685
645
}
686
646
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
-
734
647
function stripCorrections ( param ) {
735
648
let m ;
736
649
while ( true ) {
0 commit comments