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