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

Unified Diff: pkg/compiler/lib/src/cps_ir/cps_ir_nodes.dart

Issue 1223813006: dart2js cps: Direct access on JS arrays. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Update unit tests and remove unused functions Created 5 years, 5 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 | « pkg/compiler/lib/src/cps_ir/cps_fragment.dart ('k') | pkg/compiler/lib/src/cps_ir/cps_ir_nodes_sexpr.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/compiler/lib/src/cps_ir/cps_ir_nodes.dart
diff --git a/pkg/compiler/lib/src/cps_ir/cps_ir_nodes.dart b/pkg/compiler/lib/src/cps_ir/cps_ir_nodes.dart
index 29d324ed567003ab1cc0878801eec9b1dce18f50..ebb8574fa66247fe85ac0eee98cb26ca0e74fa14 100644
--- a/pkg/compiler/lib/src/cps_ir/cps_ir_nodes.dart
+++ b/pkg/compiler/lib/src/cps_ir/cps_ir_nodes.dart
@@ -661,6 +661,62 @@ class GetField extends Primitive {
bool get isSafeForReordering => objectIsNotNull && field.isFinal;
}
+/// Get the length of a native list.
+class GetLength extends Primitive {
+ final Reference<Primitive> object;
+
+ /// True if the object is known not to be null.
+ bool objectIsNotNull = false;
+
+ GetLength(Primitive object) : this.object = new Reference<Primitive>(object);
+
+ bool get isSafeForElimination => objectIsNotNull;
+ bool get isSafeForReordering => false;
+
+ accept(Visitor v) => v.visitGetLength(this);
+}
+
+/// Read an entry from a native list.
+///
+/// [object] must be null or a native list, and [index] must be an integer.
+class GetIndex extends Primitive {
+ final Reference<Primitive> object;
+ final Reference<Primitive> index;
+
+ /// True if the object is known not to be null.
+ bool objectIsNotNull = false;
+
+ GetIndex(Primitive object, Primitive index)
+ : this.object = new Reference<Primitive>(object),
+ this.index = new Reference<Primitive>(index);
+
+ bool get isSafeForElimination => objectIsNotNull;
+ bool get isSafeForReordering => false;
+
+ accept(Visitor v) => v.visitGetIndex(this);
+}
+
+/// Set an entry on a native list.
+///
+/// [object] must be null or a native list, and [index] must be an integer.
+///
+/// The primitive itself has no value and may not be referenced.
+class SetIndex extends Primitive {
+ final Reference<Primitive> object;
+ final Reference<Primitive> index;
+ final Reference<Primitive> value;
+
+ SetIndex(Primitive object, Primitive index, Primitive value)
+ : this.object = new Reference<Primitive>(object),
+ this.index = new Reference<Primitive>(index),
+ this.value = new Reference<Primitive>(value);
+
+ bool get isSafeForElimination => false;
+ bool get isSafeForReordering => false;
+
+ accept(Visitor v) => v.visitSetIndex(this);
+}
+
/// Reads the value of a static field or tears off a static method.
///
/// Note that lazily initialized fields should be read using GetLazyStatic.
@@ -672,7 +728,7 @@ class GetStatic extends Primitive {
GetStatic(this.element, [this.sourceInformation]);
accept(Visitor visitor) => visitor.visitGetStatic(this);
-
+
bool get isSafeForElimination {
return true;
}
@@ -1052,6 +1108,9 @@ abstract class Visitor<T> {
T visitCreateInvocationMirror(CreateInvocationMirror node);
T visitTypeTest(TypeTest node);
T visitApplyBuiltinOperator(ApplyBuiltinOperator node);
+ T visitGetLength(GetLength node);
+ T visitGetIndex(GetIndex node);
+ T visitSetIndex(SetIndex node);
// Conditions.
T visitIsTrue(IsTrue node);
@@ -1342,6 +1401,27 @@ class RecursiveVisitor implements Visitor {
visitUnreachable(Unreachable node) {
processUnreachable(node);
}
+
+ processGetLength(GetLength node) {}
+ visitGetLength(GetLength node) {
+ processGetLength(node);
+ processReference(node.object);
+ }
+
+ processGetIndex(GetIndex node) {}
+ visitGetIndex(GetIndex node) {
+ processGetIndex(node);
+ processReference(node.object);
+ processReference(node.index);
+ }
+
+ processSetIndex(SetIndex node) {}
+ visitSetIndex(SetIndex node) {
+ processSetIndex(node);
+ processReference(node.object);
+ processReference(node.index);
+ processReference(node.value);
+ }
}
/// Visit a just-deleted subterm and unlink all [Reference]s in it.
« no previous file with comments | « pkg/compiler/lib/src/cps_ir/cps_fragment.dart ('k') | pkg/compiler/lib/src/cps_ir/cps_ir_nodes_sexpr.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698