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

Unified Diff: vm/intermediate_language.h

Issue 10412043: Make it less verbose to declare instructions that use LocationSummary-based code generation. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/runtime/
Patch Set: Created 8 years, 7 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 | vm/intermediate_language_ia32.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: vm/intermediate_language.h
===================================================================
--- vm/intermediate_language.h (revision 7878)
+++ vm/intermediate_language.h (working copy)
@@ -79,7 +79,7 @@
public:
static const int kNoCid = -1;
- Computation() : cid_(-1), ic_data_(NULL) {
+ Computation() : cid_(-1), ic_data_(NULL), locs_(NULL) {
Isolate* isolate = Isolate::Current();
cid_ = GetNextCid(isolate);
ic_data_ = GetICDataForCid(cid_, isolate);
@@ -112,10 +112,18 @@
// Returns structure describing location constraints required
// to emit native code for this computation.
- virtual LocationSummary* locs() const {
+ LocationSummary* locs() {
// TODO(vegorov): This should be pure virtual method.
Ivan Posva 2012/05/22 22:19:49 This comment is out of date, as it should just be
Florian Schneider 2012/05/22 23:01:06 Done.
// However we are temporary using NULL for instructions that
// were not converted to the location based code generation yet.
+ if (locs_ == NULL) locs_ = MakeLocationSummary();
+ return locs_;
+ }
+
+ // Create a location summary for this computation.
+ // TODO(fschneider): Temporarily returns NULL for instructions
+ // that are not yet converted to the location based code generation.
+ virtual LocationSummary* MakeLocationSummary() const {
Ivan Posva 2012/05/22 22:19:49 This one here and the one below should be pure vir
Florian Schneider 2012/05/22 23:01:06 Done.
return NULL;
}
@@ -145,6 +153,7 @@
intptr_t cid_;
ICData* ic_data_;
+ LocationSummary* locs_;
DISALLOW_COPY_AND_ASSIGN(Computation);
};
@@ -241,6 +250,20 @@
virtual void PrintTo(BufferFormatter* f) const;
+// TODO(fschneider): Remove duplicate macro definitions once all instruction
+// have a LocationSummary.
+#define DECLARE_COMPUTATION_WITH_LOCATION(ShortName) \
+ DECLARE_COMPUTATION(ShortName) \
+ virtual LocationSummary* MakeLocationSummary() const; \
Ivan Posva 2012/05/22 22:19:49 Then these two can just move into the general macr
+ virtual void EmitNativeCode(FlowGraphCompiler* compiler);
+
+// Functions defined in all concrete value classes.
+#define DECLARE_VALUE_WITH_LOCATION(ShortName) \
+ DECLARE_COMPUTATION_WITH_LOCATION(ShortName) \
+ virtual ShortName##Val* As##ShortName() { return this; } \
+ virtual void PrintTo(BufferFormatter* f) const;
+
+
// Definitions and uses are mutually recursive.
class Definition;
@@ -262,27 +285,16 @@
class ConstantVal: public Value {
public:
explicit ConstantVal(const Object& value)
- : value_(value),
- location_summary_(MakeLocationSummary()) {
+ : value_(value) {
ASSERT(value.IsZoneHandle());
}
- DECLARE_VALUE(Constant)
+ DECLARE_VALUE_WITH_LOCATION(Constant)
const Object& value() const { return value_; }
- virtual LocationSummary* locs() const {
- return location_summary_;
- }
-
- // Platform specific summary factory for this instruction.
- LocationSummary* MakeLocationSummary();
-
- virtual void EmitNativeCode(FlowGraphCompiler* compiler);
-
private:
const Object& value_;
- LocationSummary* location_summary_;
DISALLOW_COPY_AND_ASSIGN(ConstantVal);
};
@@ -374,46 +386,27 @@
// a computation, not a value, because it's mutable.
class CurrentContextComp : public TemplateComputation<0> {
public:
- CurrentContextComp() : location_summary_(MakeLocationSummary()) { }
+ CurrentContextComp() { }
- DECLARE_COMPUTATION(CurrentContext)
+ DECLARE_COMPUTATION_WITH_LOCATION(CurrentContext)
- virtual LocationSummary* locs() const {
- return location_summary_;
- }
-
- static LocationSummary* MakeLocationSummary();
-
- virtual void EmitNativeCode(FlowGraphCompiler* compiler);
-
private:
- LocationSummary* location_summary_;
DISALLOW_COPY_AND_ASSIGN(CurrentContextComp);
};
class StoreContextComp : public TemplateComputation<1> {
public:
- explicit StoreContextComp(Value* value)
- : location_summary_(MakeLocationSummary()) {
+ explicit StoreContextComp(Value* value) {
ASSERT(value != NULL);
inputs_[0] = value;
}
- DECLARE_COMPUTATION(StoreContext);
+ DECLARE_COMPUTATION_WITH_LOCATION(StoreContext);
- virtual LocationSummary* locs() const {
- return location_summary_;
- }
-
- static LocationSummary* MakeLocationSummary();
-
- virtual void EmitNativeCode(FlowGraphCompiler* compiler);
-
Value* value() const { return inputs_[0]; }
private:
- LocationSummary* location_summary_;
DISALLOW_COPY_AND_ASSIGN(StoreContextComp);
};
@@ -425,10 +418,9 @@
ZoneGrowableArray<Value*>* arguments)
: ast_node_(*node),
try_index_(try_index),
- arguments_(arguments),
- location_summary_(MakeLocationSummary()) { }
+ arguments_(arguments) { }
- DECLARE_COMPUTATION(ClosureCall)
+ DECLARE_COMPUTATION_WITH_LOCATION(ClosureCall)
const Array& argument_names() const { return ast_node_.arguments()->names(); }
intptr_t token_index() const { return ast_node_.token_index(); }
@@ -442,20 +434,10 @@
virtual void PrintOperandsTo(BufferFormatter* f) const;
- virtual LocationSummary* locs() const {
- return location_summary_;
- }
-
- // Platform specific summary factory for this instruction.
- LocationSummary* MakeLocationSummary();
-
- virtual void EmitNativeCode(FlowGraphCompiler* compiler);
-
private:
const ClosureCallNode& ast_node_;
const intptr_t try_index_;
ZoneGrowableArray<Value*>* arguments_;
- LocationSummary* location_summary_;
DISALLOW_COPY_AND_ASSIGN(ClosureCallComp);
};
@@ -474,14 +456,13 @@
function_name_(function_name),
arguments_(arguments),
argument_names_(argument_names),
- checked_argument_count_(checked_argument_count),
- location_summary_(MakeLocationSummary()) {
+ checked_argument_count_(checked_argument_count) {
ASSERT(function_name.IsZoneHandle());
ASSERT(!arguments->is_empty());
ASSERT(argument_names.IsZoneHandle());
}
- DECLARE_COMPUTATION(InstanceCall)
+ DECLARE_COMPUTATION_WITH_LOCATION(InstanceCall)
intptr_t token_index() const { return token_index_; }
intptr_t try_index() const { return try_index_; }
@@ -496,15 +477,6 @@
virtual void PrintOperandsTo(BufferFormatter* f) const;
- virtual LocationSummary* locs() const {
- return location_summary_;
- }
-
- // Platform specific summary factory for this instruction.
- LocationSummary* MakeLocationSummary();
-
- virtual void EmitNativeCode(FlowGraphCompiler* compiler);
-
private:
const intptr_t token_index_;
const intptr_t try_index_;
@@ -512,7 +484,6 @@
ZoneGrowableArray<Value*>* const arguments_;
const Array& argument_names_;
const intptr_t checked_argument_count_;
- LocationSummary* location_summary_;
DISALLOW_COPY_AND_ASSIGN(InstanceCallComp);
};
@@ -525,10 +496,9 @@
ASSERT((kind_ == Token::kEQ_STRICT) || (kind_ == Token::kNE_STRICT));
inputs_[0] = left;
inputs_[1] = right;
- location_summary_ = MakeLocationSummary();
}
- DECLARE_COMPUTATION(StrictCompare)
+ DECLARE_COMPUTATION_WITH_LOCATION(StrictCompare)
Token::Kind kind() const { return kind_; }
Value* left() const { return inputs_[0]; }
@@ -536,20 +506,9 @@
virtual void PrintOperandsTo(BufferFormatter* f) const;
- virtual LocationSummary* locs() const {
- return location_summary_;
- }
-
- // Platform specific summary factory for this instruction.
- LocationSummary* MakeLocationSummary();
-
- virtual void EmitNativeCode(FlowGraphCompiler* compiler);
-
private:
const Token::Kind kind_;
- LocationSummary* location_summary_;
-
DISALLOW_COPY_AND_ASSIGN(StrictCompareComp);
};
@@ -596,13 +555,12 @@
try_index_(try_index),
function_(function),
argument_names_(argument_names),
- arguments_(arguments),
- location_summary_(MakeLocationSummary()) {
+ arguments_(arguments) {
ASSERT(function.IsZoneHandle());
ASSERT(argument_names.IsZoneHandle());
}
- DECLARE_COMPUTATION(StaticCall)
+ DECLARE_COMPUTATION_WITH_LOCATION(StaticCall)
// Accessors forwarded to the AST node.
const Function& function() const { return function_; }
@@ -618,22 +576,12 @@
virtual void PrintOperandsTo(BufferFormatter* f) const;
- virtual LocationSummary* locs() const {
- return location_summary_;
- }
-
- // Platform specific summary factory for this instruction.
- LocationSummary* MakeLocationSummary();
-
- virtual void EmitNativeCode(FlowGraphCompiler* compiler);
-
private:
const intptr_t token_index_;
const intptr_t try_index_;
const Function& function_;
const Array& argument_names_;
ZoneGrowableArray<Value*>* arguments_;
- LocationSummary* location_summary_;
DISALLOW_COPY_AND_ASSIGN(StaticCallComp);
};
@@ -643,29 +591,18 @@
public:
LoadLocalComp(const LocalVariable& local, intptr_t context_level)
: local_(local),
- context_level_(context_level),
- location_summary_(MakeLocationSummary()) { }
+ context_level_(context_level) { }
- DECLARE_COMPUTATION(LoadLocal)
+ DECLARE_COMPUTATION_WITH_LOCATION(LoadLocal)
const LocalVariable& local() const { return local_; }
intptr_t context_level() const { return context_level_; }
virtual void PrintOperandsTo(BufferFormatter* f) const;
- virtual LocationSummary* locs() const {
- return location_summary_;
- }
-
- // Platform specific summary factory for this instruction.
- LocationSummary* MakeLocationSummary();
-
- virtual void EmitNativeCode(FlowGraphCompiler* compiler);
-
private:
const LocalVariable& local_;
const intptr_t context_level_;
- LocationSummary* location_summary_;
DISALLOW_COPY_AND_ASSIGN(LoadLocalComp);
};
@@ -677,12 +614,11 @@
Value* value,
intptr_t context_level)
: local_(local),
- context_level_(context_level),
- location_summary_(MakeLocationSummary()) {
+ context_level_(context_level) {
inputs_[0] = value;
}
- DECLARE_COMPUTATION(StoreLocal)
+ DECLARE_COMPUTATION_WITH_LOCATION(StoreLocal)
const LocalVariable& local() const { return local_; }
Value* value() const { return inputs_[0]; }
@@ -692,19 +628,9 @@
virtual void PrintOperandsTo(BufferFormatter* f) const;
- virtual LocationSummary* locs() const {
- return location_summary_;
- }
-
- // Platform specific summary factory for this instruction.
- LocationSummary* MakeLocationSummary();
-
- virtual void EmitNativeCode(FlowGraphCompiler* compiler);
-
private:
const LocalVariable& local_;
const intptr_t context_level_;
- LocationSummary* location_summary_;
DISALLOW_COPY_AND_ASSIGN(StoreLocalComp);
};
« no previous file with comments | « no previous file | vm/intermediate_language_ia32.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698