Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1201)

Unified Diff: runtime/vm/kernel_binary_flowgraph.cc

Issue 2940323002: [kernel] Don't emit field initializers in a redirecting constructor (Closed)
Patch Set: Created 3 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | tests/language/language_kernel.status » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/kernel_binary_flowgraph.cc
diff --git a/runtime/vm/kernel_binary_flowgraph.cc b/runtime/vm/kernel_binary_flowgraph.cc
index 33c85883c08dca768e4f896411db799a63c561f3..e34276668e7b06d77f544a49bef6386b58b371a7 100644
--- a/runtime/vm/kernel_binary_flowgraph.cc
+++ b/runtime/vm/kernel_binary_flowgraph.cc
@@ -2924,11 +2924,31 @@ Fragment StreamingFlowGraphBuilder::BuildInitializers(
intptr_t constructor_class_parent_offset) {
Fragment instructions;
+ // Start by getting the position of the constructors initializer.
+ intptr_t initializers_offset = -1;
+ {
+ AlternativeReadingScope alt(reader_);
+ SkipFunctionNode(); // read constructors function node.
+ initializers_offset = ReaderOffset();
+ }
+
// These come from:
// class A {
// var x = (expr);
// }
+ // We don't want to do that when this is a Redirecting Constructors though
+ // (i.e. has a single initializer being of type kRedirectingInitializer).
+ bool is_redirecting_constructor = false;
{
+ AlternativeReadingScope alt(reader_, initializers_offset);
+ intptr_t list_length = ReadListLength(); // read initializers list length.
+ if (list_length == 1) {
+ Tag tag = ReadTag();
+ if (tag == kRedirectingInitializer) is_redirecting_constructor = true;
+ }
+ }
+
+ if (!is_redirecting_constructor) {
AlternativeReadingScope alt(reader_, constructor_class_parent_offset);
ReadClassUntilFields(); // read first part of class.
intptr_t list_length = ReadListLength(); // read fields list length.
@@ -2963,9 +2983,7 @@ Fragment StreamingFlowGraphBuilder::BuildInitializers(
// A(this.x) : super(expr), y = (expr);
// }
{
- AlternativeReadingScope alt(reader_);
- SkipFunctionNode(); // read constructors function node.
-
+ AlternativeReadingScope alt(reader_, initializers_offset);
intptr_t list_length = ReadListLength(); // read initializers list length.
for (intptr_t i = 0; i < list_length; ++i) {
Tag tag = ReadTag();
« no previous file with comments | « no previous file | tests/language/language_kernel.status » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698