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

Unified Diff: runtime/vm/intermediate_language.h

Issue 9570015: Support instance getters and setters, indexed loads and stores. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 10 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
Index: runtime/vm/intermediate_language.h
diff --git a/runtime/vm/intermediate_language.h b/runtime/vm/intermediate_language.h
index c9143b675b8a5a115e9ab764e6c85805a0959b3e..3ec2f63bd2e16b363d9d0d7efdf5c695118c13f5 100644
--- a/runtime/vm/intermediate_language.h
+++ b/runtime/vm/intermediate_language.h
@@ -6,6 +6,7 @@
#define VM_INTERMEDIATE_LANGUAGE_H_
#include "vm/allocation.h"
+#include "vm/ast.h"
#include "vm/growable_array.h"
#include "vm/handles_impl.h"
#include "vm/object.h"
@@ -17,22 +18,26 @@ class LocalVariable;
// Computations and values.
//
-// <Computation> ::= <Value>
-// | AssertAssignable <Value> <AbstractType>
-// | InstanceCall <cstring> <Value> ...
-// | StaticCall <Function> <Value> ...
-// | LoadLocal <LocalVariable>
-// | StoreLocal <LocalVariable> <Value>
-// | StrictCompare <Token::kind> <Value> <Value>
+// <Computation> ::=
+// <Value>
+// | AssertAssignable <Value> <AbstractType>
+// | InstanceCall <AstNode> <String> <Value> ...
+// | StaticCall <StaticCallNode> <Value> ...
+// | LoadLocal <LocalVariable>
+// | StoreLocal <LocalVariable> <Value>
+// | StoreIndexed <Value> <Value> <Value> <Value>
+// | StrictCompare <Token::kind> <Value> <Value>
//
-// <Value> ::= Temp <int>
-// | Constant <Instance>
+// <Value> ::=
+// Temp <int>
+// | Constant <Instance>
// M is a two argument macro. It is applied to each concrete value's
// typename and classname.
#define FOR_EACH_VALUE(M) \
M(Temp, TempVal) \
- M(Constant, ConstantVal)
+ M(Constant, ConstantVal) \
+
// M is a two argument macro. It is applied to each concrete instruction's
// (including the values) typename and classname.
@@ -43,7 +48,9 @@ class LocalVariable;
M(StrictCompare, StrictCompareComp) \
M(StaticCall, StaticCallComp) \
M(LoadLocal, LoadLocalComp) \
- M(StoreLocal, StoreLocalComp)
+ M(StoreLocal, StoreLocalComp) \
+ M(StoreIndexed, StoreIndexedComp) \
+ M(InstanceSetter, InstanceSetterComp) \
#define FORWARD_DECLARATION(ShortName, ClassName) class ClassName;
@@ -142,20 +149,39 @@ class AssertAssignableComp : public Computation {
class InstanceCallComp : public Computation {
public:
- InstanceCallComp(const char* name, ZoneGrowableArray<Value*>* arguments)
- : name_(name), arguments_(arguments) {
+ InstanceCallComp(AstNode* node,
+ const String& function_name,
+ ZoneGrowableArray<Value*>* arguments,
+ const Array& argument_names,
+ intptr_t checked_argument_count)
+ : ast_node_(*node),
+ function_name_(function_name),
+ arguments_(arguments),
+ argument_names_(argument_names),
+ checked_argument_count_(checked_argument_count) {
+ ASSERT(function_name.IsZoneHandle());
ASSERT(!arguments->is_empty());
+ ASSERT(argument_names.IsZoneHandle());
}
DECLARE_COMPUTATION(InstanceCall)
- const char* name() const { return name_; }
+ // Accessors forwarded to the AST node.
+ intptr_t node_id() const { return ast_node_.id(); }
+ intptr_t token_index() const { return ast_node_.token_index(); }
+
+ const String& function_name() const { return function_name_; }
int ArgumentCount() const { return arguments_->length(); }
Value* ArgumentAt(int index) const { return (*arguments_)[index]; }
+ const Array& argument_names() const { return argument_names_; }
+ intptr_t checked_argument_count() const { return checked_argument_count_; }
private:
- const char* name_;
- ZoneGrowableArray<Value*>* arguments_;
+ const AstNode& ast_node_;
+ const String& function_name_;
+ ZoneGrowableArray<Value*>* const arguments_;
+ const Array& argument_names_;
+ const intptr_t checked_argument_count_;
DISALLOW_COPY_AND_ASSIGN(InstanceCallComp);
};
@@ -185,19 +211,21 @@ class StrictCompareComp : public Computation {
class StaticCallComp : public Computation {
public:
- StaticCallComp(const Function& function, ZoneGrowableArray<Value*>* arguments)
- : function_(function), arguments_(arguments) {
- ASSERT(function.IsZoneHandle());
- }
+ StaticCallComp(StaticCallNode* node, ZoneGrowableArray<Value*>* arguments)
+ : ast_node_(*node), arguments_(arguments) { }
DECLARE_COMPUTATION(StaticCall)
- const Function& function() const { return function_; }
+ // Accessors forwarded to the AST node.
+ const Function& function() const { return ast_node_.function(); }
+ const Array& argument_names() const { return ast_node_.arguments()->names(); }
+ intptr_t token_index() const { return ast_node_.token_index(); }
+
int ArgumentCount() const { return arguments_->length(); }
Value* ArgumentAt(int index) const { return (*arguments_)[index]; }
private:
- const Function& function_;
+ const StaticCallNode& ast_node_;
ZoneGrowableArray<Value*>* arguments_;
DISALLOW_COPY_AND_ASSIGN(StaticCallComp);
@@ -236,6 +264,80 @@ class StoreLocalComp : public Computation {
DISALLOW_COPY_AND_ASSIGN(StoreLocalComp);
};
+
+// Not simply an InstanceCall because it has somewhat more complicated
+// semantics: the value operand is preserved in a placeholder (the first
+// operand is a preallocated slot that can be used).
+class StoreIndexedComp : public Computation {
+ public:
+ StoreIndexedComp(StoreIndexedNode* node,
+ Value* placeholder,
+ Value* array,
+ Value* index,
+ Value* value)
+ : ast_node_(*node),
+ placeholder_(placeholder),
+ array_(array),
+ index_(index),
+ value_(value) { }
+
+ DECLARE_COMPUTATION(StoreIndexed)
+
+ // Accessors forwarded to the AST node.
+ intptr_t node_id() const { return ast_node_.id(); }
+ intptr_t token_index() const { return ast_node_.token_index(); }
+
+ Value* placeholder() const { return placeholder_; }
+ Value* array() const { return array_; }
+ Value* index() const { return index_; }
+ Value* value() const { return value_; }
+
+ private:
+ const StoreIndexedNode& ast_node_;
+ Value* placeholder_;
+ Value* array_;
+ Value* index_;
+ Value* value_;
+
+ DISALLOW_COPY_AND_ASSIGN(StoreIndexedComp);
+};
+
+
+// Not simply an InstanceCall because it has somewhat more complicated
+// semantics: the value operand is preserved in a placeholder (the first
+// operand is a preallocate slot that can be used).
+class InstanceSetterComp : public Computation {
+ public:
+ InstanceSetterComp(InstanceSetterNode* node,
+ Value* placeholder,
+ Value* receiver,
+ Value* value)
+ : ast_node_(*node),
+ placeholder_(placeholder),
+ receiver_(receiver),
+ value_(value) { }
+
+ DECLARE_COMPUTATION(InstanceSetter)
+
+ // Accessors forwarded to the AST node.
+ intptr_t node_id() const { return ast_node_.id(); }
+ intptr_t token_index() const { return ast_node_.token_index(); }
+ const String& field_name() const { return ast_node_.field_name(); }
+
+ Value* placeholder() const { return placeholder_; }
+ Value* receiver() const { return receiver_; }
+ Value* value() const { return value_; }
+
+ private:
+ const InstanceSetterNode& ast_node_;
+ Value* placeholder_;
+ Value* receiver_;
+ Value* value_;
+
+ DISALLOW_COPY_AND_ASSIGN(InstanceSetterComp);
+};
+
+
#undef DECLARE_COMPUTATION
« runtime/vm/flow_graph_compiler_x64.cc ('K') | « runtime/vm/flow_graph_compiler_x64.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698