@@ -408,6 +408,11 @@ public struct JSTyper: Analyzer {
408
408
assert ( dynamicObjectGroupManager. isEmpty)
409
409
}
410
410
411
+ private mutating func registerWasmMemoryUse( for memory: Variable ) {
412
+ let definingInstruction = defUseAnalyzer. definition ( of: memory)
413
+ dynamicObjectGroupManager. addWasmMemory ( withType: type ( of: memory) , forDefinition: definingInstruction, forVariable: memory)
414
+ }
415
+
411
416
// Array for collecting type changes during instruction execution.
412
417
// Not currently used, but could be used for example to validate the analysis by adding these as comments to programs.
413
418
private var typeChanges = [ ( Variable, ILType) ] ( )
@@ -659,7 +664,7 @@ public struct JSTyper: Analyzer {
659
664
}
660
665
case . wasmDefineMemory( let op) :
661
666
setType ( of: instr. output, to: op. wasmMemory)
662
- dynamicObjectGroupManager . addWasmMemory ( withType : type ( of : instr . output ) , forDefinition : instr , forVariable : instr. output)
667
+ registerWasmMemoryUse ( for : instr. output)
663
668
case . wasmDefineTag( let op) :
664
669
setType ( of: instr. output, to: . object( ofGroup: " WasmTag " , withWasmType: WasmTagType ( op. parameterTypes) ) )
665
670
dynamicObjectGroupManager. addWasmTag ( withType: type ( of: instr. output) , forDefinition: instr, forVariable: instr. output)
@@ -681,28 +686,22 @@ public struct JSTyper: Analyzer {
681
686
let definingInstruction = defUseAnalyzer. definition ( of: instr. input ( 0 ) )
682
687
dynamicObjectGroupManager. addWasmTable ( withType: type ( of: instr. input ( 0 ) ) , forDefinition: definingInstruction, forVariable: instr. input ( 0 ) )
683
688
case . wasmMemoryStore( _) :
684
- let definingInstruction = defUseAnalyzer. definition ( of: instr. input ( 0 ) )
685
- dynamicObjectGroupManager. addWasmMemory ( withType: type ( of: instr. input ( 0 ) ) , forDefinition: definingInstruction, forVariable: instr. input ( 0 ) )
689
+ registerWasmMemoryUse ( for: instr. input ( 0 ) )
686
690
case . wasmMemoryLoad( let op) :
687
- let definingInstruction = defUseAnalyzer. definition ( of: instr. input ( 0 ) )
688
- dynamicObjectGroupManager. addWasmMemory ( withType: type ( of: instr. input ( 0 ) ) , forDefinition: definingInstruction, forVariable: instr. input ( 0 ) )
691
+ registerWasmMemoryUse ( for: instr. input ( 0 ) )
689
692
setType ( of: instr. output, to: op. loadType. numberType ( ) )
690
693
case . wasmAtomicLoad( let op) :
691
- let definingInstruction = defUseAnalyzer. definition ( of: instr. input ( 0 ) )
692
- dynamicObjectGroupManager. addWasmMemory ( withType: type ( of: instr. input ( 0 ) ) , forDefinition: definingInstruction, forVariable: instr. input ( 0 ) )
694
+ registerWasmMemoryUse ( for: instr. input ( 0 ) )
693
695
setType ( of: instr. output, to: op. loadType. numberType ( ) )
694
696
case . wasmAtomicStore( _) :
695
- let definingInstruction = defUseAnalyzer. definition ( of: instr. input ( 0 ) )
696
- dynamicObjectGroupManager. addWasmMemory ( withType: type ( of: instr. input ( 0 ) ) , forDefinition: definingInstruction, forVariable: instr. input ( 0 ) )
697
+ registerWasmMemoryUse ( for: instr. input ( 0 ) )
697
698
case . wasmAtomicRMW( let op) :
698
- let definingInstruction = defUseAnalyzer. definition ( of: instr. input ( 0 ) )
699
- dynamicObjectGroupManager. addWasmMemory ( withType: type ( of: instr. input ( 0 ) ) , forDefinition: definingInstruction, forVariable: instr. input ( 0 ) )
699
+ registerWasmMemoryUse ( for: instr. input ( 0 ) )
700
700
setType ( of: instr. output, to: op. op. type)
701
701
case . wasmMemorySize( _) ,
702
702
. wasmMemoryGrow( _) :
703
703
let isMemory64 = type ( of: instr. input ( 0 ) ) . wasmMemoryType? . isMemory64 ?? false
704
- let definingInstruction = defUseAnalyzer. definition ( of: instr. input ( 0 ) )
705
- dynamicObjectGroupManager. addWasmMemory ( withType: type ( of: instr. input ( 0 ) ) , forDefinition: definingInstruction, forVariable: instr. input ( 0 ) )
704
+ registerWasmMemoryUse ( for: instr. input ( 0 ) )
706
705
setType ( of: instr. output, to: isMemory64 ? . wasmi64 : . wasmi32)
707
706
case . wasmJsCall( let op) :
708
707
let sigOutputTypes = op. functionSignature. outputTypes
0 commit comments