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

Side by Side Diff: pkg/compiler/lib/src/cps_ir/cps_ir_nodes.dart

Issue 1521553003: dart2js cps: Replace GetLazyStatic with GetStatic. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Remove obsolete comment Created 5 years 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 library dart2js.ir_nodes; 4 library dart2js.ir_nodes;
5 5
6 import 'dart:collection'; 6 import 'dart:collection';
7 import '../constants/values.dart' as values; 7 import '../constants/values.dart' as values;
8 import '../dart_types.dart' show DartType, InterfaceType, TypeVariableType; 8 import '../dart_types.dart' show DartType, InterfaceType, TypeVariableType;
9 import '../elements/elements.dart'; 9 import '../elements/elements.dart';
10 import '../io/source_information.dart' show SourceInformation; 10 import '../io/source_information.dart' show SourceInformation;
(...skipping 1287 matching lines...) Expand 10 before | Expand all | Expand 10 after
1298 1298
1299 void setParentPointers() { 1299 void setParentPointers() {
1300 object.parent = this; 1300 object.parent = this;
1301 index.parent = this; 1301 index.parent = this;
1302 value.parent = this; 1302 value.parent = this;
1303 } 1303 }
1304 } 1304 }
1305 1305
1306 /// Reads the value of a static field or tears off a static method. 1306 /// Reads the value of a static field or tears off a static method.
1307 /// 1307 ///
1308 /// Note that lazily initialized fields should be read using GetLazyStatic. 1308 /// If [GetStatic] is used to load a lazily initialized static field, it must
1309 /// have been initialized beforehand, and a [witness] must be set to restrict
1310 /// code motion.
1309 class GetStatic extends Primitive { 1311 class GetStatic extends Primitive {
1310 /// Can be [FieldElement] or [FunctionElement]. 1312 /// Can be [FieldElement] or [FunctionElement].
1311 final Element element; 1313 final Element element;
1312 final SourceInformation sourceInformation; 1314 final SourceInformation sourceInformation;
1313 1315
1316 /// If reading a lazily initialized field, [witness] must refer to a node
1317 /// that initializes the field or always occurs after the field initializer.
1318 ///
1319 /// The value of the witness is not used.
1320 Reference<Primitive> witness;
1321
1314 GetStatic(this.element, [this.sourceInformation]); 1322 GetStatic(this.element, [this.sourceInformation]);
1315 1323
1324 /// Read a lazily initialized static field that is known to have been
1325 /// initialized by [witness] or earlier.
1326 GetStatic.witnessed(this.element, Primitive witness, [this.sourceInformation])
1327 : witness = witness == null ? null : new Reference<Primitive>(witness);
1328
1316 accept(Visitor visitor) => visitor.visitGetStatic(this); 1329 accept(Visitor visitor) => visitor.visitGetStatic(this);
1317 1330
1318 bool get hasValue => true; 1331 bool get hasValue => true;
1319 bool get isSafeForElimination => true; 1332 bool get isSafeForElimination => true;
1320 bool get isSafeForReordering { 1333 bool get isSafeForReordering {
1321 return element is FunctionElement || element.isFinal; 1334 return element is FunctionElement || element.isFinal;
1322 } 1335 }
1323 1336
1324 void setParentPointers() {} 1337 void setParentPointers() {
1338 if (witness != null) {
1339 witness.parent = this;
1340 }
1341 }
1325 } 1342 }
1326 1343
1327 /// Sets the value of a static field. 1344 /// Sets the value of a static field.
1328 class SetStatic extends Primitive { 1345 class SetStatic extends Primitive {
1329 final FieldElement element; 1346 final FieldElement element;
1330 final Reference<Primitive> value; 1347 final Reference<Primitive> value;
1331 final SourceInformation sourceInformation; 1348 final SourceInformation sourceInformation;
1332 1349
1333 SetStatic(this.element, Primitive value, [this.sourceInformation]) 1350 SetStatic(this.element, Primitive value, [this.sourceInformation])
1334 : this.value = new Reference<Primitive>(value); 1351 : this.value = new Reference<Primitive>(value);
(...skipping 766 matching lines...) Expand 10 before | Expand all | Expand 10 after
2101 2118
2102 processGetField(GetField node) {} 2119 processGetField(GetField node) {}
2103 visitGetField(GetField node) { 2120 visitGetField(GetField node) {
2104 processGetField(node); 2121 processGetField(node);
2105 processReference(node.object); 2122 processReference(node.object);
2106 } 2123 }
2107 2124
2108 processGetStatic(GetStatic node) {} 2125 processGetStatic(GetStatic node) {}
2109 visitGetStatic(GetStatic node) { 2126 visitGetStatic(GetStatic node) {
2110 processGetStatic(node); 2127 processGetStatic(node);
2128 if (node.witness != null) {
2129 processReference(node.witness);
2130 }
2111 } 2131 }
2112 2132
2113 processSetStatic(SetStatic node) {} 2133 processSetStatic(SetStatic node) {}
2114 visitSetStatic(SetStatic node) { 2134 visitSetStatic(SetStatic node) {
2115 processSetStatic(node); 2135 processSetStatic(node);
2116 processReference(node.value); 2136 processReference(node.value);
2117 } 2137 }
2118 2138
2119 processCreateBox(CreateBox node) {} 2139 processCreateBox(CreateBox node) {}
2120 visitCreateBox(CreateBox node) { 2140 visitCreateBox(CreateBox node) {
(...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after
2354 /// Visit a just-deleted subterm and unlink all [Reference]s in it. 2374 /// Visit a just-deleted subterm and unlink all [Reference]s in it.
2355 class RemovalVisitor extends TrampolineRecursiveVisitor { 2375 class RemovalVisitor extends TrampolineRecursiveVisitor {
2356 processReference(Reference reference) { 2376 processReference(Reference reference) {
2357 reference.unlink(); 2377 reference.unlink();
2358 } 2378 }
2359 2379
2360 static void remove(Node node) { 2380 static void remove(Node node) {
2361 (new RemovalVisitor()).visit(node); 2381 (new RemovalVisitor()).visit(node);
2362 } 2382 }
2363 } 2383 }
OLDNEW
« no previous file with comments | « pkg/compiler/lib/src/cps_ir/cps_ir_builder_task.dart ('k') | pkg/compiler/lib/src/cps_ir/eagerly_load_statics.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698