@@ -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
if ( type === 'i53' || type === 'u53' ) {
412
377
return 'readI53From' + ( unsigned ? 'U' : 'I' ) + '64(' + offset + ')' ;
@@ -431,11 +396,12 @@ function makeGetValue(ptr, pos, type, noNeedFirst, unsigned, ignore, align) {
431
396
* which means we should write to all slabs, ignore type differences if any on reads, etc.
432
397
* @param {bool } noNeedFirst Whether to ignore the offset in the pointer itself.
433
398
* @param {bool } ignore: legacy, ignored.
434
- * @param {number } align: TODO
399
+ * @param {number } align: legacy, ignored.
435
400
* @param {string } sep: TODO
436
401
* @return {TODO }
437
402
*/
438
403
function makeSetValue ( ptr , pos , value , type , noNeedFirst , ignore , align , sep = ';' ) {
404
+ assert ( typeof align === 'undefined' , 'makeSetValue no longer supports align parameter' ) ;
439
405
if ( type == 'double' && ( align < 8 ) ) {
440
406
return '(' + makeSetTempDouble ( 0 , 'double' , value ) + ',' +
441
407
makeSetValue ( ptr , pos , makeGetTempDouble ( 0 , 'i32' ) , 'i32' , noNeedFirst , ignore , align , ',' ) + ',' +
@@ -448,23 +414,16 @@ function makeSetValue(ptr, pos, value, type, noNeedFirst, ignore, align, sep = '
448
414
449
415
const bits = getBits ( type ) ;
450
416
const needSplitting = bits > 0 && ! isPowerOfTwo ( bits ) ; // an unnatural type like i24
451
- if ( align || needSplitting ) {
417
+ if ( needSplitting ) {
452
418
// Alignment is important here, or we need to split this up for other reasons.
453
419
const bytes = Runtime . getNativeTypeSize ( type ) ;
454
- if ( bytes > align || needSplitting ) {
420
+ if ( needSplitting ) {
455
421
let ret = '' ;
456
422
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 ;
468
427
}
469
428
} else {
470
429
ret += makeSetValue ( 'tempDoublePtr' , 0 , value , type , noNeedFirst , ignore , 8 ) + sep ;
@@ -486,6 +445,7 @@ function makeSetValue(ptr, pos, value, type, noNeedFirst, ignore, align, sep = '
486
445
const UNROLL_LOOP_MAX = 8 ;
487
446
488
447
function makeCopyValues ( dest , src , num , type , modifier , align , sep = ';' ) {
448
+ assert ( typeof align === 'undefined' ) ;
489
449
function unroll ( type , num , jump ) {
490
450
jump = jump || 1 ;
491
451
const setValues = range ( num ) . map ( ( i ) => makeSetValue ( dest , i * jump , makeGetValue ( src , i * jump , type ) , type ) ) ;
@@ -687,54 +647,6 @@ function makeThrow(what) {
687
647
return `throw ${ what } ;` ;
688
648
}
689
649
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
-
738
650
function stripCorrections ( param ) {
739
651
let m ;
740
652
while ( true ) {
0 commit comments