[vm/kernel/bytecode] Fix bytecode generation for StaticSet
Change-Id: I42fd72ba0b7226fb5e33958af8b242e26f26e811
Reviewed-on: https://dart-review.googlesource.com/54661
Reviewed-by: RĂ©gis Crelier <regis@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
diff --git a/pkg/vm/lib/bytecode/gen_bytecode.dart b/pkg/vm/lib/bytecode/gen_bytecode.dart
index c51cf1f..988a721 100644
--- a/pkg/vm/lib/bytecode/gen_bytecode.dart
+++ b/pkg/vm/lib/bytecode/gen_bytecode.dart
@@ -789,6 +789,7 @@
@override
visitStaticSet(StaticSet node) {
node.value.accept(this);
+ _genDupTOS(node);
final target = node.target;
if (target is Field) {
// TODO(alexmarkov): assignable check
@@ -796,6 +797,7 @@
asm.emitStoreStaticTOS(cpIndex);
} else {
_genStaticCall(target, new ConstantArgDesc(1), 1);
+ asm.emitDrop1();
}
}
diff --git a/pkg/vm/lib/bytecode/local_vars.dart b/pkg/vm/lib/bytecode/local_vars.dart
index 578cbc6..93789ad 100644
--- a/pkg/vm/lib/bytecode/local_vars.dart
+++ b/pkg/vm/lib/bytecode/local_vars.dart
@@ -235,4 +235,10 @@
_allocateTemp(node);
super.visitSwitchStatement(node);
}
+
+ @override
+ visitStaticSet(StaticSet node) {
+ _allocateTemp(node);
+ super.visitStaticSet(node);
+ }
}
diff --git a/pkg/vm/testcases/bytecode/boostrapping.dart.expect b/pkg/vm/testcases/bytecode/boostrapping.dart.expect
index 8070f3e..264ed59 100644
--- a/pkg/vm/testcases/bytecode/boostrapping.dart.expect
+++ b/pkg/vm/testcases/bytecode/boostrapping.dart.expect
@@ -105,17 +105,19 @@
external static method _getDefault() → core::int;
[@vm.bytecode=
Bytecode {
- Entry 1
+ Entry 2
CheckStack
Allocate CP#0
- StoreLocal r0
- Push r0
+ StoreLocal r1
+ Push r1
PushConstant CP#2
IndirectStaticCall 1, CP#1
Drop1
Push FP[-5]
PushConstant CP#4
IndirectStaticCall 2, CP#3
+ StoreLocal r0
+ Push r0
StoreStaticTOS CP#5
Drop1
PushConstant CP#6
@@ -135,7 +137,7 @@
}
[@vm.bytecode=
Bytecode {
- Entry 1
+ Entry 2
CheckStack
PushConstant CP#0
PushStatic CP#0
@@ -145,8 +147,8 @@
IfNeStrictTOS
Jump L1
Allocate CP#5
- StoreLocal r0
- Push r0
+ StoreLocal r1
+ Push r1
PushConstant CP#7
IndirectStaticCall 1, CP#6
Drop1
@@ -154,6 +156,8 @@
IndirectStaticCall 0, CP#8
PushConstant CP#10
IndirectStaticCall 2, CP#2
+ StoreLocal r0
+ Push r0
StoreStaticTOS CP#0
Drop1
L1:
@@ -421,12 +425,16 @@
;
[@vm.bytecode=
Bytecode {
- Entry 0
+ Entry 2
CheckStack
Push FP[-5]
+ StoreLocal r0
+ Push r0
StoreStaticTOS CP#0
Drop1
PushConstant CP#1
+ StoreLocal r1
+ Push r1
StoreStaticTOS CP#2
Drop1
PushConstant CP#1
@@ -443,7 +451,7 @@
}
[@vm.bytecode=
Bytecode {
- Entry 1
+ Entry 2
CheckStack
PushConstant CP#0
PushStatic CP#0
@@ -470,6 +478,8 @@
PushConstant CP#5
PushStatic CP#5
InstanceCall1 1, CP#9
+ StoreLocal r1
+ Push r1
StoreStaticTOS CP#0
Drop1
L3:
@@ -582,9 +592,11 @@
return self::_print;
[@vm.bytecode=
Bytecode {
- Entry 0
+ Entry 1
CheckStack
Push FP[-5]
+ StoreLocal r0
+ Push r0
StoreStaticTOS CP#0
Drop1
PushConstant CP#1
@@ -599,15 +611,21 @@
}
[@vm.bytecode=
Bytecode {
- Entry 0
+ Entry 3
CheckStack
Push FP[-7]
+ StoreLocal r0
+ Push r0
StoreStaticTOS CP#0
Drop1
Push FP[-6]
+ StoreLocal r1
+ Push r1
StoreStaticTOS CP#1
Drop1
Push FP[-5]
+ StoreLocal r2
+ Push r2
StoreStaticTOS CP#2
Drop1
PushConstant CP#3
@@ -711,12 +729,15 @@
}
[@vm.bytecode=
Bytecode {
- Entry 0
+ Entry 1
CheckStack
PushConstant CP#0
+ StoreLocal r0
+ Push r0
PushConstant CP#2
IndirectStaticCall 1, CP#1
Drop1
+ Drop1
PushConstant CP#3
ReturnTOS
}
diff --git a/pkg/vm/testcases/transformations/type_flow/summary_collector/implicit_return_null.dart b/pkg/vm/testcases/transformations/type_flow/summary_collector/implicit_return_null.dart
index 16cfc50..11518c5 100644
--- a/pkg/vm/testcases/transformations/type_flow/summary_collector/implicit_return_null.dart
+++ b/pkg/vm/testcases/transformations/type_flow/summary_collector/implicit_return_null.dart
@@ -102,13 +102,15 @@
}
if3(bool c) {
- if (c) {} else {
+ if (c) {
+ } else {
throw 'Error!';
}
}
if4(bool c) {
- if (c) {} else {}
+ if (c) {
+ } else {}
}
void if5(bool c) {