From a9abc6461395e3327c7d3c22095ea3bf3de3d075 Mon Sep 17 00:00:00 2001 From: Alexander Markov Date: Sat, 17 Nov 2018 00:35:30 +0000 Subject: [PATCH] [vm/bytecode] Add context IDs to disambiguate accesses to distinct contexts MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This CL adds context ID operand to AllocateContext, CloneContext, LoadContextVar and StoreContextVar bytecode instructions. The context ID will be used to create distinct Slots and disambiguate accesses to context objects corresponding to different scopes. Change-Id: I98850ab763017b71c1dcacfccaffc085bd850e00 Reviewed-on: https://dart-review.googlesource.com/c/84681 Auto-Submit: Alexander Markov Commit-Queue: Régis Crelier Reviewed-by: Régis Crelier --- pkg/vm/lib/bytecode/assembler.dart | 16 +- pkg/vm/lib/bytecode/dbc.dart | 11 +- pkg/vm/lib/bytecode/gen_bytecode.dart | 17 +- pkg/vm/lib/bytecode/local_vars.dart | 17 + pkg/vm/testcases/bytecode/async.dart.expect | 632 +++++++++--------- .../testcases/bytecode/closures.dart.expect | 106 +-- .../testcases/bytecode/try_blocks.dart.expect | 48 +- runtime/vm/compiler/compiler_state.cc | 6 +- runtime/vm/compiler/compiler_state.h | 12 +- .../frontend/bytecode_flow_graph_builder.cc | 24 +- runtime/vm/constants_kbc.h | 19 +- 11 files changed, 473 insertions(+), 435 deletions(-) diff --git a/pkg/vm/lib/bytecode/assembler.dart b/pkg/vm/lib/bytecode/assembler.dart index 54a227b4246..f937116aef6 100644 --- a/pkg/vm/lib/bytecode/assembler.dart +++ b/pkg/vm/lib/bytecode/assembler.dart @@ -317,8 +317,8 @@ class BytecodeAssembler { emitWord(_encode0(Opcode.kStoreContextParent)); } - void emitStoreContextVar(int rd) { - emitWord(_encodeD(Opcode.kStoreContextVar, rd)); + void emitStoreContextVar(int ra, int rd) { + emitWord(_encodeAD(Opcode.kStoreContextVar, ra, rd)); } void emitLoadFieldTOS(int rd) { @@ -333,8 +333,8 @@ class BytecodeAssembler { emitWord(_encode0(Opcode.kLoadContextParent)); } - void emitLoadContextVar(int rd) { - emitWord(_encodeD(Opcode.kLoadContextVar, rd)); + void emitLoadContextVar(int ra, int rd) { + emitWord(_encodeAD(Opcode.kLoadContextVar, ra, rd)); } void emitBooleanNegateTOS() { @@ -359,12 +359,12 @@ class BytecodeAssembler { emitWord(_encodeA(Opcode.kSetFrame, ra)); } - void emitAllocateContext(int rd) { - emitWord(_encodeD(Opcode.kAllocateContext, rd)); + void emitAllocateContext(int ra, int rd) { + emitWord(_encodeAD(Opcode.kAllocateContext, ra, rd)); } - void emitCloneContext(int rd) { - emitWord(_encodeD(Opcode.kCloneContext, rd)); + void emitCloneContext(int ra, int rd) { + emitWord(_encodeAD(Opcode.kCloneContext, ra, rd)); } void emitMoveSpecial(SpecialIndex ra, int rx) { diff --git a/pkg/vm/lib/bytecode/dbc.dart b/pkg/vm/lib/bytecode/dbc.dart index b86bd57fdf2..13eb462cf40 100644 --- a/pkg/vm/lib/bytecode/dbc.dart +++ b/pkg/vm/lib/bytecode/dbc.dart @@ -173,17 +173,17 @@ const Map BytecodeFormats = const { Opcode.kCreateArrayTOS: const Format( Encoding.k0, const [Operand.none, Operand.none, Operand.none]), Opcode.kAllocateContext: const Format( - Encoding.kD, const [Operand.imm, Operand.none, Operand.none]), + Encoding.kAD, const [Operand.imm, Operand.imm, Operand.none]), Opcode.kCloneContext: const Format( - Encoding.kD, const [Operand.imm, Operand.none, Operand.none]), + Encoding.kAD, const [Operand.imm, Operand.imm, Operand.none]), Opcode.kLoadContextParent: const Format( Encoding.k0, const [Operand.none, Operand.none, Operand.none]), Opcode.kStoreContextParent: const Format( Encoding.k0, const [Operand.none, Operand.none, Operand.none]), Opcode.kLoadContextVar: const Format( - Encoding.kD, const [Operand.imm, Operand.none, Operand.none]), + Encoding.kAD, const [Operand.imm, Operand.imm, Operand.none]), Opcode.kStoreContextVar: const Format( - Encoding.kD, const [Operand.imm, Operand.none, Operand.none]), + Encoding.kAD, const [Operand.imm, Operand.imm, Operand.none]), Opcode.kPushConstant: const Format( Encoding.kD, const [Operand.lit, Operand.none, Operand.none]), Opcode.kPushNull: const Format( @@ -347,6 +347,9 @@ const int localVariableIndexLimit = 1 << 15; // Captured variables are referenced using 16-bit unsigned operands. const int capturedVariableIndexLimit = 1 << 16; +// Context IDs are referenced using 8-bit unsigned operands. +const int contextIdLimit = 1 << 8; + // Base class for exceptions thrown when certain limit of bytecode // format is exceeded. abstract class BytecodeLimitExceededException {} diff --git a/pkg/vm/lib/bytecode/gen_bytecode.dart b/pkg/vm/lib/bytecode/gen_bytecode.dart index 3f073024cd2..4ff3fb7e0bf 100644 --- a/pkg/vm/lib/bytecode/gen_bytecode.dart +++ b/pkg/vm/lib/bytecode/gen_bytecode.dart @@ -634,7 +634,8 @@ class BytecodeGenerator extends RecursiveVisitor { void _genLoadVar(VariableDeclaration v, {int currentContextLevel}) { if (locals.isCaptured(v)) { _genPushContextForVariable(v, currentContextLevel: currentContextLevel); - asm.emitLoadContextVar(locals.getVarIndexInContext(v)); + asm.emitLoadContextVar( + locals.getVarContextId(v), locals.getVarIndexInContext(v)); } else { asm.emitPush(locals.getVarIndexInFrame(v)); } @@ -650,7 +651,8 @@ class BytecodeGenerator extends RecursiveVisitor { // If variable is captured, context should be pushed before value. void _genStoreVar(VariableDeclaration variable) { if (locals.isCaptured(variable)) { - asm.emitStoreContextVar(locals.getVarIndexInContext(variable)); + asm.emitStoreContextVar(locals.getVarContextId(variable), + locals.getVarIndexInContext(variable)); } else { asm.emitPopLocal(locals.getVarIndexInFrame(variable)); } @@ -1426,7 +1428,7 @@ class BytecodeGenerator extends RecursiveVisitor { void _allocateContextIfNeeded() { final int contextSize = locals.currentContextSize; if (contextSize > 0) { - asm.emitAllocateContext(contextSize); + asm.emitAllocateContext(locals.currentContextId, contextSize); if (locals.currentContextLevel > 0) { _genDupTOS(locals.scratchVarIndexInFrame); @@ -2466,7 +2468,8 @@ class BytecodeGenerator extends RecursiveVisitor { if (locals.currentContextSize > 0) { asm.emitPush(locals.contextVarIndexInFrame); - asm.emitCloneContext(locals.currentContextSize); + asm.emitCloneContext( + locals.currentContextId, locals.currentContextSize); asm.emitPopLocal(locals.contextVarIndexInFrame); } @@ -2849,11 +2852,7 @@ class BytecodeGenerator extends RecursiveVisitor { } else { asm.emitPushNull(); } - if (isCaptured) { - asm.emitStoreContextVar(locals.getVarIndexInContext(node)); - } else { - asm.emitPopLocal(locals.getVarIndexInFrame(node)); - } + _genStoreVar(node); } } diff --git a/pkg/vm/lib/bytecode/local_vars.dart b/pkg/vm/lib/bytecode/local_vars.dart index a510e42847e..b3fac1345a3 100644 --- a/pkg/vm/lib/bytecode/local_vars.dart +++ b/pkg/vm/lib/bytecode/local_vars.dart @@ -63,6 +63,7 @@ class LocalVariables { int get currentContextSize => _currentScope.contextSize; int get currentContextLevel => _currentScope.contextLevel; + int get currentContextId => _currentScope.contextId; int get contextLevelAtEntry => _currentFrame.contextLevelAtEntry ?? @@ -74,6 +75,12 @@ class LocalVariables { return v.scope.contextLevel; } + int getVarContextId(VariableDeclaration variable) { + final v = _getVarDesc(variable); + assert(v.isCaptured); + return v.scope.contextId; + } + int get closureVarIndexInFrame => getVarIndexInFrame(_currentFrame .closureVar ?? (throw 'Closure variable is not declared in ${_currentFrame.function}')); @@ -257,6 +264,7 @@ class Scope { int contextUsed = 0; int contextSize = 0; int contextLevel; + int contextId; Scope(this.parent, this.frame, this.loopDepth); @@ -699,6 +707,7 @@ class _Allocator extends RecursiveVisitor { Scope _currentScope; Frame _currentFrame; + int _contextIdCounter = 0; _Allocator(this.locals); @@ -738,6 +747,7 @@ class _Allocator extends RecursiveVisitor { assert(_currentScope.contextOwner == null); assert(_currentScope.contextLevel == null); + assert(_currentScope.contextId == null); final int parentContextLevel = _currentScope.parent != null ? _currentScope.parent.contextLevel : -1; @@ -763,8 +773,13 @@ class _Allocator extends RecursiveVisitor { if (_currentScope.contextOwner == _currentScope) { _currentScope.contextLevel = parentContextLevel + 1; + _currentScope.contextId = _contextIdCounter++; + if (_currentScope.contextId >= contextIdLimit) { + throw new ContextIdOverflowException(); + } } else { _currentScope.contextLevel = _currentScope.contextOwner.contextLevel; + _currentScope.contextId = _currentScope.contextOwner.contextId; } } else { _currentScope.contextLevel = parentContextLevel; @@ -1147,3 +1162,5 @@ class _Allocator extends RecursiveVisitor { class LocalVariableIndexOverflowException extends BytecodeLimitExceededException {} + +class ContextIdOverflowException extends BytecodeLimitExceededException {} diff --git a/pkg/vm/testcases/bytecode/async.dart.expect b/pkg/vm/testcases/bytecode/async.dart.expect index 200441b7e3f..52a3d89e946 100644 --- a/pkg/vm/testcases/bytecode/async.dart.expect +++ b/pkg/vm/testcases/bytecode/async.dart.expect @@ -75,28 +75,28 @@ Closure CP#9 { LoadFieldTOS CP#1 PopLocal r4 Push r4 - LoadContextVar 5 + LoadContextVar 0, 5 StoreLocal r5 PushInt 0 JumpIfNeStrict L1 Push r4 Push r4 - StoreContextVar 7 + StoreContextVar 0, 7 Try #0 start: Push r4 PushInt 1 - StoreContextVar 5 + StoreContextVar 0, 5 Push r4 Push r4 - StoreContextVar 6 + StoreContextVar 0, 6 Push r4 - LoadContextVar 0 + LoadContextVar 0, 0 Push r4 - LoadContextVar 3 + LoadContextVar 0, 3 Push r4 - LoadContextVar 4 + LoadContextVar 0, 4 Push r4 - LoadContextVar 8 + LoadContextVar 0, 8 PushConstant CP#12 IndirectStaticCall 4, CP#11 PopLocal r8 @@ -112,9 +112,9 @@ L2: Push r1 Drop1 Push r4 - LoadContextVar 1 + LoadContextVar 0, 1 Push r4 - LoadContextVar 2 + LoadContextVar 0, 2 PushConstant CP#14 IndirectStaticCall 2, CP#13 Drop1 @@ -127,7 +127,7 @@ Try #0 handler: LoadFieldTOS CP#1 PopLocal r4 Push r4 - LoadContextVar 7 + LoadContextVar 0, 7 PopLocal r4 MoveSpecial exception, r6 MoveSpecial stackTrace, r7 @@ -136,7 +136,7 @@ Try #0 handler: Push r7 PopLocal r9 Push r4 - LoadContextVar 1 + LoadContextVar 0, 1 Push r8 Push r9 InstanceCall 3, CP#17 @@ -147,7 +147,7 @@ L3: ReturnTOS L1: Push r4 - LoadContextVar 6 + LoadContextVar 0, 6 PopLocal r4 Jump L4 @@ -159,11 +159,11 @@ Closure CP#0 { Push FP[-6] LoadFieldTOS CP#1 PopLocal r0 - AllocateContext 9 + AllocateContext 0, 9 PopLocal r0 Push r0 Push FP[-5] - StoreContextVar 0 + StoreContextVar 0, 0 Push FP[-5] PushConstant CP#3 PushNull @@ -175,27 +175,27 @@ Closure CP#0 { PushConstant CP#6 PushConstant CP#8 IndirectStaticCall 1, CP#7 - StoreContextVar 1 + StoreContextVar 0, 1 Push r0 PushNull - StoreContextVar 2 + StoreContextVar 0, 2 PushNull PopLocal r2 Push r0 PushNull - StoreContextVar 3 + StoreContextVar 0, 3 Push r0 PushNull - StoreContextVar 4 + StoreContextVar 0, 4 Push r0 PushInt 0 - StoreContextVar 5 + StoreContextVar 0, 5 Push r0 PushNull - StoreContextVar 6 + StoreContextVar 0, 6 Push r0 PushNull - StoreContextVar 7 + StoreContextVar 0, 7 Push r0 Allocate CP#19 StoreLocal r3 @@ -214,32 +214,32 @@ Closure CP#0 { Push r3 Push r0 StoreFieldTOS CP#1 - StoreContextVar 8 + StoreContextVar 0, 8 Push r0 - LoadContextVar 8 + LoadContextVar 0, 8 PushConstant CP#29 IndirectStaticCall 1, CP#7 PopLocal r2 Push r0 Push r0 - LoadContextVar 8 + LoadContextVar 0, 8 PushConstant CP#30 IndirectStaticCall 1, CP#7 - StoreContextVar 3 + StoreContextVar 0, 3 Push r0 Push r0 - LoadContextVar 8 + LoadContextVar 0, 8 PushConstant CP#31 IndirectStaticCall 1, CP#7 - StoreContextVar 4 + StoreContextVar 0, 4 PushConstant CP#32 Push r0 - LoadContextVar 8 + LoadContextVar 0, 8 PushConstant CP#33 IndirectStaticCall 2, CP#13 Drop1 Push r0 - LoadContextVar 1 + LoadContextVar 0, 1 InstanceCall 1, CP#34 ReturnTOS @@ -276,16 +276,16 @@ Closure CP#0 { Bytecode (version: stable) { Entry 7 CheckStack 0 - AllocateContext 4 + AllocateContext 0, 4 PopLocal r0 Push r0 PushConstant CP#0 PushConstant CP#2 IndirectStaticCall 1, CP#1 - StoreContextVar 0 + StoreContextVar 0, 0 Push r0 PushNull - StoreContextVar 1 + StoreContextVar 0, 1 PushNull PopLocal r2 PushNull @@ -294,10 +294,10 @@ Bytecode (version: stable) { PopLocal r4 Push r0 PushInt 0 - StoreContextVar 2 + StoreContextVar 0, 2 Push r0 PushNull - StoreContextVar 3 + StoreContextVar 0, 3 Allocate CP#13 StoreLocal r6 Push r6 @@ -334,7 +334,7 @@ Bytecode (version: stable) { IndirectStaticCall 2, CP#7 Drop1 Push r0 - LoadContextVar 0 + LoadContextVar 0, 0 InstanceCall 1, CP#28 ReturnTOS } @@ -380,7 +380,7 @@ Closure CP#3 { LoadFieldTOS CP#5 PopLocal r4 Push r4 - LoadContextVar 2 + LoadContextVar 0, 2 StoreLocal r5 PushInt 0 JumpIfNeStrict L1 @@ -389,13 +389,13 @@ Closure CP#3 { Try #0 start: Push r4 PushInt 42 - StoreContextVar 1 + StoreContextVar 0, 1 Jump L2 L2: Push r4 - LoadContextVar 0 + LoadContextVar 0, 0 Push r4 - LoadContextVar 1 + LoadContextVar 0, 1 PushConstant CP#8 IndirectStaticCall 2, CP#7 Drop1 @@ -413,7 +413,7 @@ Try #0 handler: Push r7 PopLocal r9 Push r4 - LoadContextVar 0 + LoadContextVar 0, 0 Push r8 Push r9 InstanceCall 3, CP#11 @@ -457,42 +457,42 @@ L1: Bytecode (version: stable) { Entry 4 CheckStack 0 - AllocateContext 11 + AllocateContext 0, 11 PopLocal r0 Push r0 Push FP[-6] - StoreContextVar 0 + StoreContextVar 0, 0 Push r0 Push FP[-5] - StoreContextVar 1 + StoreContextVar 0, 1 Push r0 PushConstant CP#0 PushConstant CP#2 IndirectStaticCall 1, CP#1 - StoreContextVar 2 + StoreContextVar 0, 2 Push r0 PushNull - StoreContextVar 3 + StoreContextVar 0, 3 PushNull PopLocal r2 Push r0 PushNull - StoreContextVar 4 + StoreContextVar 0, 4 Push r0 PushNull - StoreContextVar 5 + StoreContextVar 0, 5 Push r0 PushInt 0 - StoreContextVar 6 + StoreContextVar 0, 6 Push r0 PushNull - StoreContextVar 7 + StoreContextVar 0, 7 Push r0 PushNull - StoreContextVar 8 + StoreContextVar 0, 8 Push r0 PushNull - StoreContextVar 9 + StoreContextVar 0, 9 Push r0 Allocate CP#17 StoreLocal r3 @@ -511,32 +511,32 @@ Bytecode (version: stable) { Push r3 Push r0 StoreFieldTOS CP#5 - StoreContextVar 10 + StoreContextVar 0, 10 Push r0 - LoadContextVar 10 + LoadContextVar 0, 10 PushConstant CP#27 IndirectStaticCall 1, CP#1 PopLocal r2 Push r0 Push r0 - LoadContextVar 10 + LoadContextVar 0, 10 PushConstant CP#28 IndirectStaticCall 1, CP#1 - StoreContextVar 4 + StoreContextVar 0, 4 Push r0 Push r0 - LoadContextVar 10 + LoadContextVar 0, 10 PushConstant CP#29 IndirectStaticCall 1, CP#1 - StoreContextVar 5 + StoreContextVar 0, 5 PushConstant CP#30 Push r0 - LoadContextVar 10 + LoadContextVar 0, 10 PushConstant CP#31 IndirectStaticCall 2, CP#10 Drop1 Push r0 - LoadContextVar 2 + LoadContextVar 0, 2 InstanceCall 1, CP#32 ReturnTOS } @@ -586,28 +586,28 @@ Closure CP#3 { LoadFieldTOS CP#5 PopLocal r4 Push r4 - LoadContextVar 6 + LoadContextVar 0, 6 StoreLocal r5 PushInt 0 JumpIfNeStrict L1 Push r4 Push r4 - StoreContextVar 8 + StoreContextVar 0, 8 Try #0 start: Push r4 PushInt 1 - StoreContextVar 6 + StoreContextVar 0, 6 Push r4 Push r4 - StoreContextVar 7 + StoreContextVar 0, 7 Push r4 - LoadContextVar 0 + LoadContextVar 0, 0 Push r4 - LoadContextVar 4 + LoadContextVar 0, 4 Push r4 - LoadContextVar 5 + LoadContextVar 0, 5 Push r4 - LoadContextVar 10 + LoadContextVar 0, 10 PushConstant CP#8 IndirectStaticCall 4, CP#7 PopLocal r8 @@ -622,21 +622,21 @@ L6: L2: Push r4 Push r1 - StoreContextVar 9 + StoreContextVar 0, 9 Push r4 PushInt 2 - StoreContextVar 6 + StoreContextVar 0, 6 Push r4 Push r4 - StoreContextVar 7 + StoreContextVar 0, 7 Push r4 - LoadContextVar 1 + LoadContextVar 0, 1 Push r4 - LoadContextVar 4 + LoadContextVar 0, 4 Push r4 - LoadContextVar 5 + LoadContextVar 0, 5 Push r4 - LoadContextVar 10 + LoadContextVar 0, 10 PushConstant CP#9 IndirectStaticCall 4, CP#7 PopLocal r9 @@ -651,16 +651,16 @@ L7: L3: Push r4 Push r4 - LoadContextVar 9 + LoadContextVar 0, 9 Push r1 InstanceCall 2, CP#11 - StoreContextVar 3 + StoreContextVar 0, 3 Jump L4 L4: Push r4 - LoadContextVar 2 + LoadContextVar 0, 2 Push r4 - LoadContextVar 3 + LoadContextVar 0, 3 PushConstant CP#12 IndirectStaticCall 2, CP#10 Drop1 @@ -673,7 +673,7 @@ Try #0 handler: LoadFieldTOS CP#5 PopLocal r4 Push r4 - LoadContextVar 8 + LoadContextVar 0, 8 PopLocal r4 MoveSpecial exception, r6 MoveSpecial stackTrace, r7 @@ -682,7 +682,7 @@ Try #0 handler: Push r7 PopLocal r9 Push r4 - LoadContextVar 2 + LoadContextVar 0, 2 Push r8 Push r9 InstanceCall 3, CP#15 @@ -693,7 +693,7 @@ L5: ReturnTOS L1: Push r4 - LoadContextVar 7 + LoadContextVar 0, 7 PopLocal r4 Push r5 PushInt 1 @@ -737,42 +737,42 @@ L1: Bytecode (version: stable) { Entry 4 CheckStack 0 - AllocateContext 11 + AllocateContext 0, 11 PopLocal r0 Push r0 Push FP[-5] - StoreContextVar 0 + StoreContextVar 0, 0 Push r0 PushConstant CP#0 PushConstant CP#2 IndirectStaticCall 1, CP#1 - StoreContextVar 1 + StoreContextVar 0, 1 Push r0 PushNull - StoreContextVar 2 + StoreContextVar 0, 2 PushNull PopLocal r2 Push r0 PushNull - StoreContextVar 3 + StoreContextVar 0, 3 Push r0 PushNull - StoreContextVar 4 + StoreContextVar 0, 4 Push r0 PushInt 0 - StoreContextVar 5 + StoreContextVar 0, 5 Push r0 PushNull - StoreContextVar 6 + StoreContextVar 0, 6 Push r0 PushNull - StoreContextVar 7 + StoreContextVar 0, 7 Push r0 PushNull - StoreContextVar 8 + StoreContextVar 0, 8 Push r0 PushNull - StoreContextVar 9 + StoreContextVar 0, 9 Push r0 Allocate CP#22 StoreLocal r3 @@ -791,32 +791,32 @@ Bytecode (version: stable) { Push r3 Push r0 StoreFieldTOS CP#5 - StoreContextVar 10 + StoreContextVar 0, 10 Push r0 - LoadContextVar 10 + LoadContextVar 0, 10 PushConstant CP#32 IndirectStaticCall 1, CP#1 PopLocal r2 Push r0 Push r0 - LoadContextVar 10 + LoadContextVar 0, 10 PushConstant CP#33 IndirectStaticCall 1, CP#1 - StoreContextVar 3 + StoreContextVar 0, 3 Push r0 Push r0 - LoadContextVar 10 + LoadContextVar 0, 10 PushConstant CP#34 IndirectStaticCall 1, CP#1 - StoreContextVar 4 + StoreContextVar 0, 4 PushConstant CP#35 Push r0 - LoadContextVar 10 + LoadContextVar 0, 10 PushConstant CP#36 IndirectStaticCall 2, CP#14 Drop1 Push r0 - LoadContextVar 1 + LoadContextVar 0, 1 InstanceCall 1, CP#37 ReturnTOS } @@ -871,15 +871,15 @@ Closure CP#3 { LoadFieldTOS CP#5 PopLocal r4 Push r4 - LoadContextVar 5 + LoadContextVar 0, 5 StoreLocal r5 PushInt 0 JumpIfNeStrict L1 Push r4 Push r4 - StoreContextVar 7 + StoreContextVar 0, 7 Try #0 start: - AllocateContext 1 + AllocateContext 1, 1 StoreLocal r5 Push r5 Push r4 @@ -887,8 +887,8 @@ Try #0 start: PopLocal r4 Push r4 PushInt 0 - StoreContextVar 0 - AllocateContext 2 + StoreContextVar 1, 0 + AllocateContext 2, 2 StoreLocal r5 Push r5 Push r4 @@ -896,31 +896,31 @@ Try #0 start: PopLocal r4 Push r4 PushInt 0 - StoreContextVar 0 + StoreContextVar 2, 0 L6: CheckStack 1 Push r4 - LoadContextVar 0 + LoadContextVar 2, 0 PushInt 10 CompareIntLt JumpIfFalse L2 Push r4 LoadContextParent LoadContextParent - LoadContextVar 0 + LoadContextVar 0, 0 InstanceCall 1, CP#7 PopLocal r8 Push r4 Push r8 - StoreContextVar 1 + StoreContextVar 2, 1 L5: CheckStack 2 Push r4 - LoadContextVar 1 + LoadContextVar 2, 1 StoreLocal r8 InstanceCall 1, CP#8 JumpIfFalse L3 - AllocateContext 1 + AllocateContext 3, 1 StoreLocal r5 Push r5 Push r4 @@ -929,7 +929,7 @@ L5: Push r4 Push r8 InstanceCall 1, CP#9 - StoreContextVar 0 + StoreContextVar 3, 0 Push r4 LoadContextParent LoadContextParent @@ -937,48 +937,48 @@ L5: Push r4 LoadContextParent LoadContextParent - LoadContextVar 0 - StoreContextVar 9 + LoadContextVar 1, 0 + StoreContextVar 0, 9 Push r4 LoadContextParent LoadContextParent LoadContextParent Push r4 LoadContextParent - LoadContextVar 0 + LoadContextVar 2, 0 Push r4 - LoadContextVar 0 + LoadContextVar 3, 0 AddInt - StoreContextVar 8 + StoreContextVar 0, 8 Push r4 LoadContextParent LoadContextParent LoadContextParent PushInt 1 - StoreContextVar 5 + StoreContextVar 0, 5 Push r4 LoadContextParent LoadContextParent LoadContextParent Push r4 - StoreContextVar 6 + StoreContextVar 0, 6 PushConstant CP#11 IndirectStaticCall 0, CP#10 Push r4 LoadContextParent LoadContextParent LoadContextParent - LoadContextVar 3 + LoadContextVar 0, 3 Push r4 LoadContextParent LoadContextParent LoadContextParent - LoadContextVar 4 + LoadContextVar 0, 4 Push r4 LoadContextParent LoadContextParent LoadContextParent - LoadContextVar 10 + LoadContextVar 0, 10 PushConstant CP#13 IndirectStaticCall 4, CP#12 PopLocal r10 @@ -998,31 +998,31 @@ L4: LoadContextParent LoadContextParent LoadContextParent - LoadContextVar 9 + LoadContextVar 0, 9 Push r4 LoadContextParent LoadContextParent LoadContextParent - LoadContextVar 8 + LoadContextVar 0, 8 Push r1 InstanceCall 2, CP#15 InstanceCall 2, CP#16 - StoreContextVar 0 + StoreContextVar 1, 0 Push r4 LoadContextParent PopLocal r4 Jump L5 L3: Push r4 - CloneContext 2 + CloneContext 2, 2 PopLocal r4 Push r4 Push r4 - LoadContextVar 0 + LoadContextVar 2, 0 PushInt 1 AddInt StoreLocal r8 - StoreContextVar 0 + StoreContextVar 2, 0 Push r8 Drop1 Jump L6 @@ -1040,10 +1040,10 @@ L8: JumpIfFalse L7 Push r4 Push r4 - LoadContextVar 0 + LoadContextVar 1, 0 Push r8 AddInt - StoreContextVar 0 + StoreContextVar 1, 0 Push r8 PushInt 1 AddInt @@ -1054,17 +1054,17 @@ L7: Push r4 LoadContextParent Push r4 - LoadContextVar 0 - StoreContextVar 2 + LoadContextVar 1, 0 + StoreContextVar 0, 2 Push r4 LoadContextParent PopLocal r4 Jump L9 L9: Push r4 - LoadContextVar 1 + LoadContextVar 0, 1 Push r4 - LoadContextVar 2 + LoadContextVar 0, 2 PushConstant CP#17 IndirectStaticCall 2, CP#14 Drop1 @@ -1077,7 +1077,7 @@ Try #0 handler: LoadFieldTOS CP#5 PopLocal r4 Push r4 - LoadContextVar 7 + LoadContextVar 0, 7 PopLocal r4 MoveSpecial exception, r6 MoveSpecial stackTrace, r7 @@ -1086,7 +1086,7 @@ Try #0 handler: Push r7 PopLocal r9 Push r4 - LoadContextVar 1 + LoadContextVar 0, 1 Push r8 Push r9 InstanceCall 3, CP#20 @@ -1097,7 +1097,7 @@ L10: ReturnTOS L1: Push r4 - LoadContextVar 6 + LoadContextVar 0, 6 PopLocal r4 Jump L11 @@ -1148,57 +1148,57 @@ L1: Bytecode (version: stable) { Entry 4 CheckStack 0 - AllocateContext 16 + AllocateContext 0, 16 PopLocal r0 Push r0 Push FP[-7] - StoreContextVar 0 + StoreContextVar 0, 0 Push r0 Push FP[-6] - StoreContextVar 1 + StoreContextVar 0, 1 Push r0 Push FP[-5] - StoreContextVar 2 + StoreContextVar 0, 2 Push r0 PushConstant CP#0 PushConstant CP#2 IndirectStaticCall 1, CP#1 - StoreContextVar 3 + StoreContextVar 0, 3 Push r0 PushNull - StoreContextVar 4 + StoreContextVar 0, 4 PushNull PopLocal r2 Push r0 PushNull - StoreContextVar 5 + StoreContextVar 0, 5 Push r0 PushNull - StoreContextVar 6 + StoreContextVar 0, 6 Push r0 PushInt 0 - StoreContextVar 7 + StoreContextVar 0, 7 Push r0 PushNull - StoreContextVar 8 + StoreContextVar 0, 8 Push r0 PushNull - StoreContextVar 9 + StoreContextVar 0, 9 Push r0 PushNull - StoreContextVar 10 + StoreContextVar 0, 10 Push r0 PushNull - StoreContextVar 11 + StoreContextVar 0, 11 Push r0 PushNull - StoreContextVar 12 + StoreContextVar 0, 12 Push r0 PushNull - StoreContextVar 13 + StoreContextVar 0, 13 Push r0 PushNull - StoreContextVar 14 + StoreContextVar 0, 14 Push r0 Allocate CP#30 StoreLocal r3 @@ -1217,32 +1217,32 @@ Bytecode (version: stable) { Push r3 Push r0 StoreFieldTOS CP#5 - StoreContextVar 15 + StoreContextVar 0, 15 Push r0 - LoadContextVar 15 + LoadContextVar 0, 15 PushConstant CP#40 IndirectStaticCall 1, CP#1 PopLocal r2 Push r0 Push r0 - LoadContextVar 15 + LoadContextVar 0, 15 PushConstant CP#41 IndirectStaticCall 1, CP#1 - StoreContextVar 5 + StoreContextVar 0, 5 Push r0 Push r0 - LoadContextVar 15 + LoadContextVar 0, 15 PushConstant CP#42 IndirectStaticCall 1, CP#1 - StoreContextVar 6 + StoreContextVar 0, 6 PushConstant CP#43 Push r0 - LoadContextVar 15 + LoadContextVar 0, 15 PushConstant CP#44 IndirectStaticCall 2, CP#9 Drop1 Push r0 - LoadContextVar 3 + LoadContextVar 0, 3 InstanceCall 1, CP#45 ReturnTOS } @@ -1305,15 +1305,15 @@ Closure CP#3 { LoadFieldTOS CP#5 PopLocal r4 Push r4 - LoadContextVar 7 + LoadContextVar 0, 7 StoreLocal r5 PushInt 0 JumpIfNeStrict L1 Push r4 Push r4 - StoreContextVar 9 + StoreContextVar 0, 9 Try #0 start: - AllocateContext 2 + AllocateContext 1, 2 StoreLocal r5 Push r5 Push r4 @@ -1321,42 +1321,42 @@ Try #0 start: PopLocal r4 Push r4 PushInt 1 - StoreContextVar 0 + StoreContextVar 1, 0 Push r4 LoadContextParent Push r4 - StoreContextVar 10 + StoreContextVar 0, 10 Try #1 start: Push r4 LoadContextParent Push r4 - StoreContextVar 11 + StoreContextVar 0, 11 Try #2 start: Push r4 LoadContextParent Push r4 - LoadContextVar 0 - StoreContextVar 14 + LoadContextVar 1, 0 + StoreContextVar 0, 14 Push r4 LoadContextParent PushInt 1 - StoreContextVar 7 + StoreContextVar 0, 7 Push r4 LoadContextParent Push r4 - StoreContextVar 8 + StoreContextVar 0, 8 Push r4 LoadContextParent - LoadContextVar 0 + LoadContextVar 0, 0 Push r4 LoadContextParent - LoadContextVar 5 + LoadContextVar 0, 5 Push r4 LoadContextParent - LoadContextVar 6 + LoadContextVar 0, 6 Push r4 LoadContextParent - LoadContextVar 15 + LoadContextVar 0, 15 PushConstant CP#8 IndirectStaticCall 4, CP#7 PopLocal r13 @@ -1372,10 +1372,10 @@ L2: Push r4 Push r4 LoadContextParent - LoadContextVar 14 + LoadContextVar 0, 14 Push r1 InstanceCall 2, CP#10 - StoreContextVar 0 + StoreContextVar 1, 0 Jump L3 Try #2 end: Try #2 handler: @@ -1384,57 +1384,57 @@ Try #2 handler: LoadFieldTOS CP#5 PopLocal r4 Push r4 - LoadContextVar 11 + LoadContextVar 0, 11 PopLocal r4 MoveSpecial exception, r10 MoveSpecial stackTrace, r11 Push r4 LoadContextParent Push r10 - StoreContextVar 12 + StoreContextVar 0, 12 Push r4 LoadContextParent Push r11 - StoreContextVar 13 + StoreContextVar 0, 13 Push r4 Push r10 - StoreContextVar 1 + StoreContextVar 1, 1 Push r4 - LoadContextVar 1 + LoadContextVar 1, 1 PushConstant CP#12 InstanceCall 2, CP#13 JumpIfFalse L4 Push r4 LoadContextParent PushInt 42 - StoreContextVar 4 + StoreContextVar 0, 4 Jump L5 L4: Push r4 LoadContextParent Push r4 - LoadContextVar 0 - StoreContextVar 14 + LoadContextVar 1, 0 + StoreContextVar 0, 14 Push r4 LoadContextParent PushInt 2 - StoreContextVar 7 + StoreContextVar 0, 7 Push r4 LoadContextParent Push r4 - StoreContextVar 8 + StoreContextVar 0, 8 Push r4 LoadContextParent - LoadContextVar 1 + LoadContextVar 0, 1 Push r4 LoadContextParent - LoadContextVar 5 + LoadContextVar 0, 5 Push r4 LoadContextParent - LoadContextVar 6 + LoadContextVar 0, 6 Push r4 LoadContextParent - LoadContextVar 15 + LoadContextVar 0, 15 PushConstant CP#14 IndirectStaticCall 4, CP#7 PopLocal r13 @@ -1450,16 +1450,16 @@ L6: Push r4 Push r4 LoadContextParent - LoadContextVar 14 + LoadContextVar 0, 14 Push r1 InstanceCall 2, CP#15 - StoreContextVar 0 + StoreContextVar 1, 0 Push r4 LoadContextParent - LoadContextVar 12 + LoadContextVar 0, 12 Push r4 LoadContextParent - LoadContextVar 13 + LoadContextVar 0, 13 Throw 1 L3: Jump L7 @@ -1470,18 +1470,18 @@ Try #1 handler: LoadFieldTOS CP#5 PopLocal r4 Push r4 - LoadContextVar 10 + LoadContextVar 0, 10 PopLocal r4 MoveSpecial exception, r8 MoveSpecial stackTrace, r9 Push r4 LoadContextParent Push r8 - StoreContextVar 12 + StoreContextVar 0, 12 Push r4 LoadContextParent Push r9 - StoreContextVar 13 + StoreContextVar 0, 13 PushConstant CP#16 PushConstant CP#17 IndirectStaticCall 1, CP#1 @@ -1489,28 +1489,28 @@ Try #1 handler: Push r4 LoadContextParent Push r4 - LoadContextVar 0 - StoreContextVar 14 + LoadContextVar 1, 0 + StoreContextVar 0, 14 Push r4 LoadContextParent PushInt 3 - StoreContextVar 7 + StoreContextVar 0, 7 Push r4 LoadContextParent Push r4 - StoreContextVar 8 + StoreContextVar 0, 8 Push r4 LoadContextParent - LoadContextVar 2 + LoadContextVar 0, 2 Push r4 LoadContextParent - LoadContextVar 5 + LoadContextVar 0, 5 Push r4 LoadContextParent - LoadContextVar 6 + LoadContextVar 0, 6 Push r4 LoadContextParent - LoadContextVar 15 + LoadContextVar 0, 15 PushConstant CP#18 IndirectStaticCall 4, CP#7 PopLocal r12 @@ -1526,15 +1526,15 @@ L8: Push r4 Push r4 LoadContextParent - LoadContextVar 14 + LoadContextVar 0, 14 Push r1 InstanceCall 2, CP#19 - StoreContextVar 0 + StoreContextVar 1, 0 Push r4 LoadContextParent Push r4 - LoadContextVar 0 - StoreContextVar 4 + LoadContextVar 1, 0 + StoreContextVar 0, 4 Push r4 LoadContextParent PopLocal r4 @@ -1544,7 +1544,7 @@ L5: LoadFieldTOS CP#5 PopLocal r4 Push r4 - LoadContextVar 10 + LoadContextVar 0, 10 PopLocal r4 PushConstant CP#16 PushConstant CP#20 @@ -1553,28 +1553,28 @@ L5: Push r4 LoadContextParent Push r4 - LoadContextVar 0 - StoreContextVar 14 + LoadContextVar 1, 0 + StoreContextVar 0, 14 Push r4 LoadContextParent PushInt 4 - StoreContextVar 7 + StoreContextVar 0, 7 Push r4 LoadContextParent Push r4 - StoreContextVar 8 + StoreContextVar 0, 8 Push r4 LoadContextParent - LoadContextVar 2 + LoadContextVar 0, 2 Push r4 LoadContextParent - LoadContextVar 5 + LoadContextVar 0, 5 Push r4 LoadContextParent - LoadContextVar 6 + LoadContextVar 0, 6 Push r4 LoadContextParent - LoadContextVar 15 + LoadContextVar 0, 15 PushConstant CP#21 IndirectStaticCall 4, CP#7 PopLocal r12 @@ -1590,15 +1590,15 @@ L10: Push r4 Push r4 LoadContextParent - LoadContextVar 14 + LoadContextVar 0, 14 Push r1 InstanceCall 2, CP#22 - StoreContextVar 0 + StoreContextVar 1, 0 Push r4 LoadContextParent Push r4 - LoadContextVar 0 - StoreContextVar 4 + LoadContextVar 1, 0 + StoreContextVar 0, 4 Push r4 LoadContextParent PopLocal r4 @@ -1608,7 +1608,7 @@ L7: LoadFieldTOS CP#5 PopLocal r4 Push r4 - LoadContextVar 10 + LoadContextVar 0, 10 PopLocal r4 PushConstant CP#16 PushConstant CP#23 @@ -1617,28 +1617,28 @@ L7: Push r4 LoadContextParent Push r4 - LoadContextVar 0 - StoreContextVar 14 + LoadContextVar 1, 0 + StoreContextVar 0, 14 Push r4 LoadContextParent PushInt 5 - StoreContextVar 7 + StoreContextVar 0, 7 Push r4 LoadContextParent Push r4 - StoreContextVar 8 + StoreContextVar 0, 8 Push r4 LoadContextParent - LoadContextVar 2 + LoadContextVar 0, 2 Push r4 LoadContextParent - LoadContextVar 5 + LoadContextVar 0, 5 Push r4 LoadContextParent - LoadContextVar 6 + LoadContextVar 0, 6 Push r4 LoadContextParent - LoadContextVar 15 + LoadContextVar 0, 15 PushConstant CP#24 IndirectStaticCall 4, CP#7 PopLocal r12 @@ -1654,24 +1654,24 @@ L11: Push r4 Push r4 LoadContextParent - LoadContextVar 14 + LoadContextVar 0, 14 Push r1 InstanceCall 2, CP#25 - StoreContextVar 0 + StoreContextVar 1, 0 Push r4 LoadContextParent Push r4 - LoadContextVar 0 - StoreContextVar 4 + LoadContextVar 1, 0 + StoreContextVar 0, 4 Push r4 LoadContextParent PopLocal r4 Jump L9 L9: Push r4 - LoadContextVar 3 + LoadContextVar 0, 3 Push r4 - LoadContextVar 4 + LoadContextVar 0, 4 PushConstant CP#26 IndirectStaticCall 2, CP#9 Drop1 @@ -1684,7 +1684,7 @@ Try #0 handler: LoadFieldTOS CP#5 PopLocal r4 Push r4 - LoadContextVar 9 + LoadContextVar 0, 9 PopLocal r4 MoveSpecial exception, r6 MoveSpecial stackTrace, r7 @@ -1693,7 +1693,7 @@ Try #0 handler: Push r7 PopLocal r9 Push r4 - LoadContextVar 3 + LoadContextVar 0, 3 Push r8 Push r9 InstanceCall 3, CP#28 @@ -1704,7 +1704,7 @@ L12: ReturnTOS L1: Push r4 - LoadContextVar 8 + LoadContextVar 0, 8 PopLocal r4 Push r5 PushInt 1 @@ -1781,14 +1781,14 @@ L1: Bytecode (version: stable) { Entry 4 CheckStack 0 - AllocateContext 2 + AllocateContext 0, 2 PopLocal r0 Push r0 Push FP[-5] - StoreContextVar 0 + StoreContextVar 0, 0 Push r0 PushInt 3 - StoreContextVar 1 + StoreContextVar 0, 1 Allocate CP#19 StoreLocal r3 Push r3 @@ -1859,15 +1859,15 @@ Closure CP#6 { LoadFieldTOS CP#1 PopLocal r4 Push r4 - LoadContextVar 4 + LoadContextVar 1, 4 StoreLocal r5 PushInt 0 JumpIfNeStrict L1 Push r4 Push r4 - StoreContextVar 6 + StoreContextVar 1, 6 Try #0 start: - AllocateContext 1 + AllocateContext 2, 1 StoreLocal r5 Push r5 Push r4 @@ -1875,38 +1875,38 @@ Try #0 start: PopLocal r4 Push r4 PushInt 4 - StoreContextVar 0 + StoreContextVar 2, 0 Push r4 LoadContextParent Push r4 - StoreContextVar 7 + StoreContextVar 1, 7 Try #1 start: Push r4 LoadContextParent LoadContextParent PushInt 5 - StoreContextVar 1 + StoreContextVar 0, 1 Push r4 LoadContextParent PushInt 1 - StoreContextVar 4 + StoreContextVar 1, 4 Push r4 LoadContextParent Push r4 - StoreContextVar 5 + StoreContextVar 1, 5 Push r4 LoadContextParent LoadContextParent - LoadContextVar 0 + LoadContextVar 0, 0 Push r4 LoadContextParent - LoadContextVar 2 + LoadContextVar 1, 2 Push r4 LoadContextParent - LoadContextVar 3 + LoadContextVar 1, 3 Push r4 LoadContextParent - LoadContextVar 8 + LoadContextVar 1, 8 PushConstant CP#9 IndirectStaticCall 4, CP#8 PopLocal r11 @@ -1921,17 +1921,17 @@ L6: L2: Push r4 Push r1 - StoreContextVar 0 + StoreContextVar 2, 0 Push r4 LoadContextParent Push r4 LoadContextParent LoadContextParent - LoadContextVar 1 + LoadContextVar 0, 1 Push r4 - LoadContextVar 0 + LoadContextVar 2, 0 AddInt - StoreContextVar 1 + StoreContextVar 1, 1 Jump L3 Try #1 end: Try #1 handler: @@ -1940,7 +1940,7 @@ Try #1 handler: LoadFieldTOS CP#1 PopLocal r4 Push r4 - LoadContextVar 7 + LoadContextVar 1, 7 PopLocal r4 MoveSpecial exception, r8 MoveSpecial stackTrace, r9 @@ -1956,7 +1956,7 @@ L3: LoadFieldTOS CP#1 PopLocal r4 Push r4 - LoadContextVar 7 + LoadContextVar 1, 7 PopLocal r4 PushConstant CP#11 PushConstant CP#13 @@ -1968,9 +1968,9 @@ L3: Jump L4 L4: Push r4 - LoadContextVar 0 + LoadContextVar 1, 0 Push r4 - LoadContextVar 1 + LoadContextVar 1, 1 PushConstant CP#15 IndirectStaticCall 2, CP#14 Drop1 @@ -1983,7 +1983,7 @@ Try #0 handler: LoadFieldTOS CP#1 PopLocal r4 Push r4 - LoadContextVar 6 + LoadContextVar 1, 6 PopLocal r4 MoveSpecial exception, r6 MoveSpecial stackTrace, r7 @@ -1992,7 +1992,7 @@ Try #0 handler: Push r7 PopLocal r9 Push r4 - LoadContextVar 0 + LoadContextVar 1, 0 Push r8 Push r9 InstanceCall 3, CP#17 @@ -2003,7 +2003,7 @@ L5: ReturnTOS L1: Push r4 - LoadContextVar 5 + LoadContextVar 1, 5 PopLocal r4 Jump L6 @@ -2015,7 +2015,7 @@ Closure CP#0 { Push FP[-5] LoadFieldTOS CP#1 PopLocal r0 - AllocateContext 9 + AllocateContext 1, 9 StoreLocal r1 Push r1 Push r0 @@ -2025,30 +2025,30 @@ Closure CP#0 { PushConstant CP#3 PushConstant CP#5 IndirectStaticCall 1, CP#4 - StoreContextVar 0 + StoreContextVar 1, 0 Push r0 PushNull - StoreContextVar 1 + StoreContextVar 1, 1 PushNull PopLocal r2 Push r0 PushNull - StoreContextVar 2 + StoreContextVar 1, 2 Push r0 PushNull - StoreContextVar 3 + StoreContextVar 1, 3 Push r0 PushInt 0 - StoreContextVar 4 + StoreContextVar 1, 4 Push r0 PushNull - StoreContextVar 5 + StoreContextVar 1, 5 Push r0 PushNull - StoreContextVar 6 + StoreContextVar 1, 6 Push r0 PushNull - StoreContextVar 7 + StoreContextVar 1, 7 Push r0 Allocate CP#19 StoreLocal r3 @@ -2067,32 +2067,32 @@ Closure CP#0 { Push r3 Push r0 StoreFieldTOS CP#1 - StoreContextVar 8 + StoreContextVar 1, 8 Push r0 - LoadContextVar 8 + LoadContextVar 1, 8 PushConstant CP#29 IndirectStaticCall 1, CP#4 PopLocal r2 Push r0 Push r0 - LoadContextVar 8 + LoadContextVar 1, 8 PushConstant CP#30 IndirectStaticCall 1, CP#4 - StoreContextVar 2 + StoreContextVar 1, 2 Push r0 Push r0 - LoadContextVar 8 + LoadContextVar 1, 8 PushConstant CP#31 IndirectStaticCall 1, CP#4 - StoreContextVar 3 + StoreContextVar 1, 3 PushConstant CP#32 Push r0 - LoadContextVar 8 + LoadContextVar 1, 8 PushConstant CP#33 IndirectStaticCall 2, CP#14 Drop1 Push r0 - LoadContextVar 0 + LoadContextVar 1, 0 InstanceCall 1, CP#34 ReturnTOS @@ -2143,36 +2143,36 @@ Closure CP#0 { Bytecode (version: stable) { Entry 4 CheckStack 0 - AllocateContext 9 + AllocateContext 0, 9 PopLocal r0 Push r0 Push FP[-5] - StoreContextVar 0 + StoreContextVar 0, 0 Push r0 PushConstant CP#0 PushConstant CP#2 IndirectStaticCall 1, CP#1 - StoreContextVar 1 + StoreContextVar 0, 1 Push r0 PushNull - StoreContextVar 2 + StoreContextVar 0, 2 PushNull PopLocal r2 Push r0 PushNull - StoreContextVar 3 + StoreContextVar 0, 3 Push r0 PushNull - StoreContextVar 4 + StoreContextVar 0, 4 Push r0 PushInt 0 - StoreContextVar 5 + StoreContextVar 0, 5 Push r0 PushNull - StoreContextVar 6 + StoreContextVar 0, 6 Push r0 PushNull - StoreContextVar 7 + StoreContextVar 0, 7 Push r0 Allocate CP#17 StoreLocal r3 @@ -2191,32 +2191,32 @@ Bytecode (version: stable) { Push r3 Push r0 StoreFieldTOS CP#5 - StoreContextVar 8 + StoreContextVar 0, 8 Push r0 - LoadContextVar 8 + LoadContextVar 0, 8 PushConstant CP#27 IndirectStaticCall 1, CP#1 PopLocal r2 Push r0 Push r0 - LoadContextVar 8 + LoadContextVar 0, 8 PushConstant CP#28 IndirectStaticCall 1, CP#1 - StoreContextVar 3 + StoreContextVar 0, 3 Push r0 Push r0 - LoadContextVar 8 + LoadContextVar 0, 8 PushConstant CP#29 IndirectStaticCall 1, CP#1 - StoreContextVar 4 + StoreContextVar 0, 4 PushConstant CP#30 Push r0 - LoadContextVar 8 + LoadContextVar 0, 8 PushConstant CP#31 IndirectStaticCall 2, CP#9 Drop1 Push r0 - LoadContextVar 1 + LoadContextVar 0, 1 InstanceCall 1, CP#32 ReturnTOS } @@ -2266,29 +2266,29 @@ Closure CP#3 { LoadFieldTOS CP#5 PopLocal r4 Push r4 - LoadContextVar 5 + LoadContextVar 0, 5 StoreLocal r5 PushInt 0 JumpIfNeStrict L1 Push r4 Push r4 - StoreContextVar 7 + StoreContextVar 0, 7 Try #0 start: JumpIfNoAsserts L2 Push r4 PushInt 1 - StoreContextVar 5 + StoreContextVar 0, 5 Push r4 Push r4 - StoreContextVar 6 + StoreContextVar 0, 6 Push r4 - LoadContextVar 0 + LoadContextVar 0, 0 Push r4 - LoadContextVar 3 + LoadContextVar 0, 3 Push r4 - LoadContextVar 4 + LoadContextVar 0, 4 Push r4 - LoadContextVar 8 + LoadContextVar 0, 8 PushConstant CP#8 IndirectStaticCall 4, CP#7 PopLocal r8 @@ -2316,13 +2316,13 @@ L3: L2: Push r4 PushInt 7 - StoreContextVar 2 + StoreContextVar 0, 2 Jump L4 L4: Push r4 - LoadContextVar 1 + LoadContextVar 0, 1 Push r4 - LoadContextVar 2 + LoadContextVar 0, 2 PushConstant CP#13 IndirectStaticCall 2, CP#9 Drop1 @@ -2335,7 +2335,7 @@ Try #0 handler: LoadFieldTOS CP#5 PopLocal r4 Push r4 - LoadContextVar 7 + LoadContextVar 0, 7 PopLocal r4 MoveSpecial exception, r6 MoveSpecial stackTrace, r7 @@ -2344,7 +2344,7 @@ Try #0 handler: Push r7 PopLocal r9 Push r4 - LoadContextVar 1 + LoadContextVar 0, 1 Push r8 Push r9 InstanceCall 3, CP#15 @@ -2355,7 +2355,7 @@ L5: ReturnTOS L1: Push r4 - LoadContextVar 6 + LoadContextVar 0, 6 PopLocal r4 Jump L6 diff --git a/pkg/vm/testcases/bytecode/closures.dart.expect b/pkg/vm/testcases/bytecode/closures.dart.expect index 654a544c5e2..2add8c9f18c 100644 --- a/pkg/vm/testcases/bytecode/closures.dart.expect +++ b/pkg/vm/testcases/bytecode/closures.dart.expect @@ -187,11 +187,11 @@ Bytecode (version: stable) { Entry 5 CheckStack 0 CheckFunctionTypeArgs 2, r0 - AllocateContext 1 + AllocateContext 0, 1 PopLocal r1 Push r1 Push FP[-5] - StoreContextVar 0 + StoreContextVar 0, 0 Allocate CP#31 StoreLocal r4 Push r4 @@ -290,7 +290,7 @@ Closure CP#12 { Push r3 PushInt 0 Push r1 - LoadContextVar 0 + LoadContextVar 0, 0 LoadTypeArgumentsField CP#15 PushNull InstantiateType CP#14 @@ -298,7 +298,7 @@ Closure CP#12 { Push r3 PushInt 1 Push r1 - LoadContextVar 0 + LoadContextVar 0, 0 LoadTypeArgumentsField CP#15 PushNull InstantiateType CP#16 @@ -345,7 +345,7 @@ Closure CP#12 { IndirectStaticCall 1, CP#25 Drop1 Push r1 - LoadContextVar 0 + LoadContextVar 0, 0 LoadTypeArgumentsField CP#15 Push r0 InstantiateTypeArgumentsTOS 0, CP#27 @@ -385,7 +385,7 @@ L2: StoreLocal r4 Push r4 Push r1 - LoadContextVar 0 + LoadContextVar 0, 0 LoadTypeArgumentsField CP#15 StoreFieldTOS CP#32 Push r4 @@ -437,7 +437,7 @@ L2: StoreLocal r4 Push r4 Push r1 - LoadContextVar 0 + LoadContextVar 0, 0 LoadTypeArgumentsField CP#15 StoreFieldTOS CP#32 Push r4 @@ -506,19 +506,19 @@ ConstantPool { Bytecode (version: stable) { Entry 5 CheckStack 0 - AllocateContext 4 + AllocateContext 0, 4 PopLocal r0 Push r0 Push FP[-5] - StoreContextVar 0 + StoreContextVar 0, 0 Push r0 PushInt 1 - StoreContextVar 1 + StoreContextVar 0, 1 PushInt 2 PopLocal r2 Push r0 PushInt 3 - StoreContextVar 2 + StoreContextVar 0, 2 Allocate CP#10 StoreLocal r4 Push r4 @@ -550,18 +550,18 @@ Bytecode (version: stable) { IndirectStaticCall 1, CP#7 Drop1 Push r0 - LoadContextVar 2 + LoadContextVar 0, 2 PushConstant CP#27 IndirectStaticCall 1, CP#7 Drop1 Push r0 - LoadContextVar 1 + LoadContextVar 0, 1 PushConstant CP#28 IndirectStaticCall 1, CP#7 Drop1 Push r0 PushInt 42 - StoreContextVar 3 + StoreContextVar 0, 3 Allocate CP#10 StoreLocal r3 Push r3 @@ -631,19 +631,19 @@ Closure CP#6 { LoadContextParent Push r0 LoadContextParent - LoadContextVar 1 + LoadContextVar 0, 1 PushInt 2 AddInt - StoreContextVar 2 + StoreContextVar 0, 2 Push r0 Push r0 LoadContextParent - LoadContextVar 0 + LoadContextVar 0, 0 InstanceCall 1, CP#8 Push r0 - LoadContextVar 0 + LoadContextVar 1, 0 AddInt - StoreContextVar 1 + StoreContextVar 1, 1 PushNull ReturnTOS @@ -655,7 +655,7 @@ Closure CP#0 { Push FP[-6] LoadFieldTOS CP#1 PopLocal r0 - AllocateContext 2 + AllocateContext 1, 2 StoreLocal r1 Push r1 Push r0 @@ -663,7 +663,7 @@ Closure CP#0 { PopLocal r0 Push r0 Push FP[-5] - StoreContextVar 0 + StoreContextVar 1, 0 Push FP[-5] PushConstant CP#3 PushNull @@ -674,19 +674,19 @@ Closure CP#0 { Push r0 LoadContextParent Push r0 - LoadContextVar 0 + LoadContextVar 1, 0 PushInt 1 AddInt - StoreContextVar 1 + StoreContextVar 0, 1 Push r0 LoadContextParent - LoadContextVar 1 + LoadContextVar 0, 1 PushInt 5 CompareIntGt JumpIfFalse L1 Push r0 PushInt 4 - StoreContextVar 1 + StoreContextVar 1, 1 Allocate CP#10 StoreLocal r2 Push r2 @@ -709,7 +709,7 @@ Closure CP#0 { InstanceCall 1, CP#20 Drop1 Push r0 - LoadContextVar 1 + LoadContextVar 1, 1 PushConstant CP#21 IndirectStaticCall 1, CP#7 Drop1 @@ -726,9 +726,9 @@ Closure CP#29 { LoadFieldTOS CP#1 PopLocal r0 Push r0 - LoadContextVar 0 + LoadContextVar 0, 0 Push r0 - LoadContextVar 3 + LoadContextVar 0, 3 InstanceCall 2, CP#30 Drop1 PushNull @@ -792,11 +792,11 @@ ConstantPool { Bytecode (version: stable) { Entry 5 CheckStack 0 - AllocateContext 1 + AllocateContext 0, 1 PopLocal r0 Push r0 PushInt 0 - StoreContextVar 0 + StoreContextVar 0, 0 PushConstant CP#0 StoreLocal r3 Push r3 @@ -815,7 +815,7 @@ Bytecode (version: stable) { PushConstant CP#3 IndirectStaticCall 2, CP#1 PopLocal r4 - AllocateContext 1 + AllocateContext 1, 1 StoreLocal r1 Push r1 Push r0 @@ -823,11 +823,11 @@ Bytecode (version: stable) { PopLocal r0 Push r0 PushInt 0 - StoreContextVar 0 + StoreContextVar 1, 0 L2: CheckStack 1 Push r0 - LoadContextVar 0 + LoadContextVar 1, 0 PushInt 10 CompareIntLt JumpIfFalse L1 @@ -872,15 +872,15 @@ L2: InstanceCall 2, CP#24 Drop1 Push r0 - CloneContext 1 + CloneContext 1, 1 PopLocal r0 Push r0 Push r0 - LoadContextVar 0 + LoadContextVar 1, 0 PushInt 1 AddInt StoreLocal r3 - StoreContextVar 0 + StoreContextVar 1, 0 Push r3 Drop1 Jump L2 @@ -928,10 +928,10 @@ Closure CP#4 { LoadFieldTOS CP#5 PopLocal r0 Push r0 - LoadContextVar 0 + LoadContextVar 1, 0 Push r0 LoadContextParent - LoadContextVar 0 + LoadContextVar 0, 0 AddInt ReturnTOS @@ -954,9 +954,9 @@ Closure CP#19 { Push FP[-5] Push r0 LoadContextParent - LoadContextVar 0 + LoadContextVar 0, 0 AddInt - StoreContextVar 0 + StoreContextVar 1, 0 PushNull ReturnTOS @@ -984,12 +984,12 @@ L2: Push r2 InstanceCall 1, CP#2 JumpIfFalse L1 - AllocateContext 1 + AllocateContext 0, 1 PopLocal r0 Push r0 Push r2 InstanceCall 1, CP#3 - StoreContextVar 0 + StoreContextVar 0, 0 Allocate CP#8 StoreLocal r4 Push r4 @@ -1012,7 +1012,7 @@ L2: InstanceCall 1, CP#18 Drop1 Push r0 - LoadContextVar 0 + LoadContextVar 0, 0 PushConstant CP#19 IndirectStaticCall 1, CP#0 Drop1 @@ -1054,10 +1054,10 @@ Closure CP#4 { PopLocal r0 Push r0 Push r0 - LoadContextVar 0 + LoadContextVar 0, 0 PushInt 1 AddInt - StoreContextVar 0 + StoreContextVar 0, 0 PushNull ReturnTOS @@ -1095,11 +1095,11 @@ ConstantPool { Bytecode (version: stable) { Entry 3 CheckStack 0 - AllocateContext 1 + AllocateContext 0, 1 PopLocal r0 Push r0 Push FP[-5] - StoreContextVar 0 + StoreContextVar 0, 0 Push FP[-5] PushConstant CP#0 Push FP[-6] @@ -1155,7 +1155,7 @@ Closure CP#4 { LoadFieldTOS CP#5 PopLocal r0 Push r0 - LoadContextVar 0 + LoadContextVar 0, 0 ReturnTOS } @@ -1167,11 +1167,11 @@ Closure CP#4 { Bytecode (version: stable) { Entry 4 CheckStack 0 - AllocateContext 1 + AllocateContext 0, 1 PopLocal r0 Push r0 PushInt 5 - StoreContextVar 0 + StoreContextVar 0, 0 Allocate CP#7 StoreLocal r3 Push r3 @@ -1195,7 +1195,7 @@ Bytecode (version: stable) { InstanceCall 2, CP#18 Drop1 Push r0 - LoadContextVar 0 + LoadContextVar 0, 0 ReturnTOS } ConstantPool { @@ -1234,10 +1234,10 @@ Closure CP#0 { Drop1 Push r0 Push r0 - LoadContextVar 0 + LoadContextVar 0, 0 Push FP[-5] AddInt - StoreContextVar 0 + StoreContextVar 0, 0 PushNull ReturnTOS diff --git a/pkg/vm/testcases/bytecode/try_blocks.dart.expect b/pkg/vm/testcases/bytecode/try_blocks.dart.expect index 130ebb2bcb0..8b87d844817 100644 --- a/pkg/vm/testcases/bytecode/try_blocks.dart.expect +++ b/pkg/vm/testcases/bytecode/try_blocks.dart.expect @@ -229,17 +229,17 @@ ConstantPool { Bytecode (version: stable) { Entry 7 CheckStack 0 - AllocateContext 3 + AllocateContext 0, 3 PopLocal r0 Push r0 PushInt 1 - StoreContextVar 0 + StoreContextVar 0, 0 Push r0 PopLocal r2 Try #0 start: Push r0 PushInt 2 - StoreContextVar 1 + StoreContextVar 0, 1 Allocate CP#9 StoreLocal r5 Push r5 @@ -262,7 +262,7 @@ Try #0 start: InstanceCall 1, CP#19 Drop1 Push r0 - LoadContextVar 1 + LoadContextVar 0, 1 PushConstant CP#20 IndirectStaticCall 1, CP#4 Drop1 @@ -278,7 +278,7 @@ Try #0 handler: PopLocal r4 Push r0 Push r3 - StoreContextVar 2 + StoreContextVar 0, 2 PushNull PushInt 4 CreateArrayTOS @@ -298,7 +298,7 @@ Try #0 handler: Push r5 PushInt 3 Push r0 - LoadContextVar 2 + LoadContextVar 0, 2 StoreIndexedTOS PushConstant CP#23 IndirectStaticCall 1, CP#4 @@ -397,13 +397,13 @@ Try #0 handler: Push r2 PopLocal r4 Push r0 - LoadContextVar 0 + LoadContextVar 0, 0 PushConstant CP#7 IndirectStaticCall 1, CP#4 Drop1 Push r0 PushInt 3 - StoreContextVar 1 + StoreContextVar 0, 1 Jump L1 L1: PushNull @@ -457,7 +457,7 @@ Try #0 handler: Push r5 PushInt 3 Push r0 - LoadContextVar 2 + LoadContextVar 0, 2 StoreIndexedTOS PushConstant CP#33 IndirectStaticCall 1, CP#4 @@ -692,13 +692,13 @@ ConstantPool { Bytecode (version: stable) { Entry 9 CheckStack 0 - AllocateContext 2 + AllocateContext 0, 2 PopLocal r0 Push r0 Push FP[-5] - StoreContextVar 0 + StoreContextVar 0, 0 Push r0 - LoadContextVar 0 + LoadContextVar 0, 0 PopLocal r2 Push r2 PushInt 1 @@ -719,7 +719,7 @@ Try #0 start: Drop1 Push r0 PushInt 3 - StoreContextVar 1 + StoreContextVar 0, 1 Push r0 PopLocal r5 Try #1 start: @@ -852,12 +852,12 @@ Closure CP#8 { LoadFieldTOS CP#9 PopLocal r0 Push r0 - LoadContextVar 0 + LoadContextVar 0, 0 PushConstant CP#11 IndirectStaticCall 1, CP#4 Drop1 Push r0 - LoadContextVar 1 + LoadContextVar 0, 1 PushConstant CP#12 IndirectStaticCall 1, CP#4 Drop1 @@ -905,11 +905,11 @@ Closure CP#8 { Bytecode (version: stable) { Entry 6 CheckStack 0 - AllocateContext 1 + AllocateContext 0, 1 PopLocal r0 Push r0 PushInt 11 - StoreContextVar 0 + StoreContextVar 0, 0 PushNull PopLocal r2 Push r0 @@ -942,7 +942,7 @@ Try #0 handler: MoveSpecial exception, r3 MoveSpecial stackTrace, r4 Push r0 - LoadContextVar 0 + LoadContextVar 0, 0 PushConstant CP#26 IndirectStaticCall 1, CP#3 Drop1 @@ -956,7 +956,7 @@ L1: Push r3 PopLocal r0 Push r0 - LoadContextVar 0 + LoadContextVar 0, 0 PushConstant CP#28 IndirectStaticCall 1, CP#3 Drop1 @@ -1011,7 +1011,7 @@ Closure CP#0 { LoadFieldTOS CP#1 PopLocal r0 Push r0 - LoadContextVar 0 + LoadContextVar 0, 0 PushConstant CP#4 IndirectStaticCall 1, CP#3 Drop1 @@ -1046,7 +1046,7 @@ Try #1 handler: MoveSpecial exception, r4 MoveSpecial stackTrace, r5 Push r0 - LoadContextVar 0 + LoadContextVar 0, 0 PushConstant CP#10 IndirectStaticCall 1, CP#3 Drop1 @@ -1057,7 +1057,7 @@ L2: Push r4 PopLocal r0 Push r0 - LoadContextVar 0 + LoadContextVar 0, 0 PushConstant CP#11 IndirectStaticCall 1, CP#3 Drop1 @@ -1082,7 +1082,7 @@ Try #2 handler: MoveSpecial exception, r4 MoveSpecial stackTrace, r5 Push r0 - LoadContextVar 0 + LoadContextVar 0, 0 PushConstant CP#13 IndirectStaticCall 1, CP#3 Drop1 @@ -1093,7 +1093,7 @@ L3: Push r4 PopLocal r0 Push r0 - LoadContextVar 0 + LoadContextVar 0, 0 PushConstant CP#14 IndirectStaticCall 1, CP#3 Drop1 diff --git a/runtime/vm/compiler/compiler_state.cc b/runtime/vm/compiler/compiler_state.cc index 6d4bbc2288d..4e05c0d707b 100644 --- a/runtime/vm/compiler/compiler_state.cc +++ b/runtime/vm/compiler/compiler_state.cc @@ -34,7 +34,8 @@ T* PutIfAbsent(Thread* thread, return array->At(index); } -LocalVariable* CompilerState::GetDummyCapturedVariable(intptr_t index) { +LocalVariable* CompilerState::GetDummyCapturedVariable(intptr_t context_id, + intptr_t index) { return PutIfAbsent( thread(), &dummy_captured_vars_, index, [&]() { Zone* const Z = thread()->zone(); @@ -52,6 +53,7 @@ LocalVariable* CompilerState::GetDummyCapturedVariable(intptr_t index) { } const GrowableArray& CompilerState::GetDummyContextVariables( + intptr_t context_id, intptr_t num_context_variables) { return PutIfAbsent( thread(), &dummy_scopes_, num_context_variables, @@ -63,7 +65,7 @@ const GrowableArray& CompilerState::GetDummyContextVariables( scope->set_context_level(0); for (intptr_t i = 0; i < num_context_variables; i++) { - LocalVariable* var = GetDummyCapturedVariable(i); + LocalVariable* var = GetDummyCapturedVariable(context_id, i); scope->AddVariable(var); scope->AddContextVariable(var); } diff --git a/runtime/vm/compiler/compiler_state.h b/runtime/vm/compiler/compiler_state.h index e47dad06398..e9bc6751eb4 100644 --- a/runtime/vm/compiler/compiler_state.h +++ b/runtime/vm/compiler/compiler_state.h @@ -87,16 +87,20 @@ class CompilerState : public StackResource { void set_slot_cache(SlotCache* cache) { slot_cache_ = cache; } // Create a dummy list of local variables representing a context object - // with the given number of captured variables. + // with the given number of captured variables and given ID. // // Used during bytecode to IL translation because AllocateContext and // CloneContext IL instructions need a list of local varaibles and bytecode // does not record this information. + // + // TODO(vegorov): create context classes for distinct context IDs and + // populate them with slots without creating variables. const GrowableArray& GetDummyContextVariables( + intptr_t context_id, intptr_t num_context_variables); // Create a dummy LocalVariable that represents a captured local variable - // at the given index. + // at the given index in the context with given ID. // // Used during bytecode to IL translation because StoreInstanceField and // LoadField IL instructions need Slot, which can only be created from a @@ -104,7 +108,9 @@ class CompilerState : public StackResource { // // This function returns the same variable when it is called with the // same index. - LocalVariable* GetDummyCapturedVariable(intptr_t index); + // + // TODO(vegorov): disambiguate slots for different context IDs. + LocalVariable* GetDummyCapturedVariable(intptr_t context_id, intptr_t index); private: CHA cha_; diff --git a/runtime/vm/compiler/frontend/bytecode_flow_graph_builder.cc b/runtime/vm/compiler/frontend/bytecode_flow_graph_builder.cc index a6e54988e0b..20cb6a07f1d 100644 --- a/runtime/vm/compiler/frontend/bytecode_flow_graph_builder.cc +++ b/runtime/vm/compiler/frontend/bytecode_flow_graph_builder.cc @@ -781,8 +781,11 @@ void BytecodeFlowGraphBuilder::BuildAllocateContext() { UNIMPLEMENTED(); // TODO(alexmarkov): interpreter } + const intptr_t context_id = DecodeOperandA().value(); + const intptr_t num_context_vars = DecodeOperandD().value(); + auto& context_variables = CompilerState::Current().GetDummyContextVariables( - DecodeOperandD().value()); + context_id, num_context_vars); code_ += B->AllocateContext(context_variables); } @@ -792,8 +795,11 @@ void BytecodeFlowGraphBuilder::BuildCloneContext() { } LoadStackSlots(1); + const intptr_t context_id = DecodeOperandA().value(); + const intptr_t num_context_vars = DecodeOperandD().value(); + auto& context_variables = CompilerState::Current().GetDummyContextVariables( - DecodeOperandD().value()); + context_id, num_context_vars); CloneContextInstr* clone_instruction = new (Z) CloneContextInstr( TokenPosition::kNoSource, Pop(), context_variables, B->GetNextDeoptId()); code_ <<= clone_instruction; @@ -885,12 +891,11 @@ void BytecodeFlowGraphBuilder::BuildStoreContextVar() { } LoadStackSlots(2); - Operand var_index = DecodeOperandD(); + const intptr_t context_id = DecodeOperandA().value(); + const intptr_t var_index = DecodeOperandD().value(); - // TODO(alexmarkov) provide context_id in bytecode to disambiguate variables - // in different contexts auto var = - CompilerState::Current().GetDummyCapturedVariable(var_index.value()); + CompilerState::Current().GetDummyCapturedVariable(context_id, var_index); code_ += B->StoreInstanceField( position_, Slot::GetContextVariableSlotFor(thread(), *var)); } @@ -901,12 +906,11 @@ void BytecodeFlowGraphBuilder::BuildLoadContextVar() { } LoadStackSlots(1); - Operand var_index = DecodeOperandD(); + const intptr_t context_id = DecodeOperandA().value(); + const intptr_t var_index = DecodeOperandD().value(); - // TODO(alexmarkov) provide context_id in bytecode to disambiguate variables - // in different contexts auto var = - CompilerState::Current().GetDummyCapturedVariable(var_index.value()); + CompilerState::Current().GetDummyCapturedVariable(context_id, var_index); code_ += B->LoadNativeField(Slot::GetContextVariableSlotFor(thread(), *var)); } diff --git a/runtime/vm/constants_kbc.h b/runtime/vm/constants_kbc.h index 9c23e1f5ed3..67772ab3505 100644 --- a/runtime/vm/constants_kbc.h +++ b/runtime/vm/constants_kbc.h @@ -155,13 +155,18 @@ namespace dart { // // Allocate array of length SP[0] with type arguments SP[-1]. // -// - AllocateContext D +// - AllocateContext A, D // -// Allocate Context object assuming for D context variables. +// Allocate Context object holding D context variables. +// A is a static ID of the context. Static ID of a context may be used to +// disambiguate accesses to different context objects. +// Context objects with the same ID should have the same number of +// context variables. // -// - CloneContext D +// - CloneContext A, D // -// Clone Context object stored in TOS assuming it has D context variables. +// Clone Context object SP[0] holding D context variables. +// A is a static ID of the context. Cloned context has the same ID. // // - LoadContextParent // @@ -171,13 +176,15 @@ namespace dart { // // Store context SP[0] into `parent` field of context SP[-1]. // -// - LoadContextVar D +// - LoadContextVar A, D // // Load value from context SP[0] at index D. +// A is a static ID of the context. // -// - StoreContextVar D +// - StoreContextVar A, D // // Store value SP[0] into context SP[-1] at index D. +// A is a static ID of the context. // // - PushConstant D //