[vm/bytecode] Fix allocation of temporary locals for StaticSet
Change-Id: I47fc4f5d462be30351f4828bf4354404c0ad7088
Reviewed-on: https://dart-review.googlesource.com/c/84300
Commit-Queue: Régis Crelier <regis@google.com>
Auto-Submit: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Régis Crelier <regis@google.com>
diff --git a/pkg/vm/lib/bytecode/local_vars.dart b/pkg/vm/lib/bytecode/local_vars.dart
index 94c3880..a510e42 100644
--- a/pkg/vm/lib/bytecode/local_vars.dart
+++ b/pkg/vm/lib/bytecode/local_vars.dart
@@ -1126,8 +1126,7 @@
@override
visitStaticSet(StaticSet node) {
- _allocateTemp(node);
- super.visitStaticSet(node);
+ _visit(node, temps: 1);
}
@override
diff --git a/pkg/vm/testcases/bytecode/bootstrapping.dart b/pkg/vm/testcases/bytecode/bootstrapping.dart
index 8f79be8..3f8c850 100644
--- a/pkg/vm/testcases/bytecode/bootstrapping.dart
+++ b/pkg/vm/testcases/bytecode/bootstrapping.dart
@@ -137,6 +137,19 @@
VMLibraryHooks.platformScript = _scriptUri;
}
+class Stdin {}
+
+Stdin _stdin;
+
+class _StdIOUtils {
+ static Stdin _getStdioInputStream(int fd) => null;
+}
+
+Stdin get stdin {
+ _stdin ??= _StdIOUtils._getStdioInputStream(_stdinFD);
+ return _stdin;
+}
+
// -----------------------------------------------------------------
main() {}
diff --git a/pkg/vm/testcases/bytecode/bootstrapping.dart.expect b/pkg/vm/testcases/bytecode/bootstrapping.dart.expect
index a0c9405..785494f 100644
--- a/pkg/vm/testcases/bytecode/bootstrapping.dart.expect
+++ b/pkg/vm/testcases/bytecode/bootstrapping.dart.expect
@@ -270,7 +270,7 @@
;
[@vm.bytecode=
Bytecode (version: stable) {
- Entry 2
+ Entry 1
CheckStack 0
Push FP[-5]
StoreStaticTOS CP#0
@@ -332,10 +332,62 @@
return self::VMLibraryHooks::_cachedScript;
}
}
+class Stdin extends core::Object {
+[@vm.bytecode=
+Bytecode (version: stable) {
+ Entry 0
+ CheckStack 0
+ Push FP[-5]
+ PushConstant CP#1
+ IndirectStaticCall 1, CP#0
+ Drop1
+ PushNull
+ ReturnTOS
+}
+ConstantPool {
+ [0] = ArgDesc num-args 1, num-type-args 0, names []
+ [1] = StaticICData target 'dart.core::Object::', arg-desc CP#0
+}
+] synthetic constructor •() → self::Stdin
+ : super core::Object::•()
+ ;
+}
+class _StdIOUtils extends core::Object {
+[@vm.bytecode=
+Bytecode (version: stable) {
+ Entry 0
+ CheckStack 0
+ Push FP[-5]
+ PushConstant CP#1
+ IndirectStaticCall 1, CP#0
+ Drop1
+ PushNull
+ ReturnTOS
+}
+ConstantPool {
+ [0] = ArgDesc num-args 1, num-type-args 0, names []
+ [1] = StaticICData target 'dart.core::Object::', arg-desc CP#0
+}
+] synthetic constructor •() → self::_StdIOUtils
+ : super core::Object::•()
+ ;
+[@vm.bytecode=
+Bytecode (version: stable) {
+ Entry 0
+ CheckStack 0
+ PushNull
+ ReturnTOS
+}
+ConstantPool {
+}
+] static method _getStdioInputStream(core::int fd) → self::Stdin
+ return null;
+}
static field core::int _stdinFD = 0;
static field core::int _stdoutFD = 1;
static field core::int _stderrFD = 2;
static field core::String _rawScript;
+static field self::Stdin _stdin;
[@vm.bytecode=
Bytecode (version: stable) {
Entry 0
@@ -398,7 +450,7 @@
}
[@vm.bytecode=
Bytecode (version: stable) {
- Entry 3
+ Entry 1
CheckStack 0
Push FP[-7]
StoreStaticTOS CP#0
@@ -518,6 +570,44 @@
}
[@vm.bytecode=
Bytecode (version: stable) {
+ Entry 2
+ CheckStack 0
+ PushConstant CP#0
+ PushStatic CP#0
+ EqualsNull
+ AssertBoolean 0
+ JumpIfFalse L1
+ PushConstant CP#1
+ PushStatic CP#1
+ PushConstant CP#3
+ IndirectStaticCall 1, CP#2
+ StoreLocal r1
+ Push r1
+ StoreStaticTOS CP#0
+ PopLocal r0
+ Jump L2
+L1:
+ PushNull
+ PopLocal r0
+L2:
+ Push r0
+ Drop1
+ PushConstant CP#0
+ PushStatic CP#0
+ ReturnTOS
+}
+ConstantPool {
+ [0] = StaticField #lib::_stdin
+ [1] = StaticField #lib::_stdinFD
+ [2] = ArgDesc num-args 1, num-type-args 0, names []
+ [3] = StaticICData target '#lib::_StdIOUtils::_getStdioInputStream', arg-desc CP#2
+}
+]static get stdin() → self::Stdin {
+ self::_stdin.{core::Object::==}(null) ?{self::Stdin} self::_stdin = self::_StdIOUtils::_getStdioInputStream(self::_stdinFD) : null;
+ return self::_stdin;
+}
+[@vm.bytecode=
+Bytecode (version: stable) {
Entry 0
CheckStack 0
PushNull