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

Unified Diff: runtime/vm/intermediate_language.cc

Issue 10894034: Make constants computations instead of values. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 4 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.cc
diff --git a/runtime/vm/intermediate_language.cc b/runtime/vm/intermediate_language.cc
index 2feac05d8c30c8ecb13a06571aacd8c67d812802..3faee2c75624a54391889c06997f637fbd1b3df1 100644
--- a/runtime/vm/intermediate_language.cc
+++ b/runtime/vm/intermediate_language.cc
@@ -50,36 +50,10 @@ bool UseVal::Equals(Value* other) const {
}
-bool ConstantVal::Equals(Value* other) const {
- return other->IsConstant()
- && value().raw() == other->AsConstant()->value().raw();
-}
-
-
-bool CheckClassComp::AttributesEqual(Computation* other) const {
- CheckClassComp* other_check = other->AsCheckClass();
- if (other_check == NULL) return false;
- if (ic_data()->NumberOfChecks() != other->ic_data()->NumberOfChecks()) {
- return false;
- }
- for (intptr_t i = 0; i < ic_data()->NumberOfChecks(); ++i) {
- // TODO(fschneider): Make sure ic_data are sorted to hit more cases.
- if (ic_data()->GetReceiverClassIdAt(i) !=
- other->ic_data()->GetReceiverClassIdAt(i)) {
- return false;
- }
- }
- return true;
-}
-
-
// Returns true if the value represents a constant.
bool UseVal::BindsToConstant() const {
BindInstr* bind = definition()->AsBind();
- if (bind == NULL) {
- return false;
- }
- return bind->computation()->AsMaterialize() != NULL;
+ return (bind != NULL) && (bind->computation()->AsConstant() != NULL);
}
@@ -89,11 +63,8 @@ bool UseVal::BindsToConstantNull() const {
if (bind == NULL) {
return false;
}
- MaterializeComp* constant = bind->computation()->AsMaterialize();
- if (constant != NULL) {
- return constant->constant_val()->value().IsNull();
- }
- return false;
+ ConstantComp* constant = bind->computation()->AsConstant();
+ return (constant != NULL) && constant->value().IsNull();
}
@@ -101,9 +72,44 @@ const Object& UseVal::BoundConstant() const {
ASSERT(BindsToConstant());
BindInstr* bind = definition()->AsBind();
ASSERT(bind != NULL);
- MaterializeComp* constant = bind->computation()->AsMaterialize();
+ ConstantComp* constant = bind->computation()->AsConstant();
ASSERT(constant != NULL);
- return constant->constant_val()->value();
+ return constant->value();
+}
+
+
+bool ConstantComp::AttributesEqual(Computation* other) const {
+ ConstantComp* other_constant = other->AsConstant();
+ return (other_constant != NULL) &&
+ (value().raw() == other_constant->value().raw());
+}
+
+
+bool CheckClassComp::AttributesEqual(Computation* other) const {
+ CheckClassComp* other_check = other->AsCheckClass();
+ if (other_check == NULL) return false;
+ if (ic_data()->NumberOfChecks() != other->ic_data()->NumberOfChecks()) {
+ return false;
+ }
+ for (intptr_t i = 0; i < ic_data()->NumberOfChecks(); ++i) {
+ // TODO(fschneider): Make sure ic_data are sorted to hit more cases.
+ if (ic_data()->GetReceiverClassIdAt(i) !=
+ other->ic_data()->GetReceiverClassIdAt(i)) {
+ return false;
+ }
+ }
+ return true;
+}
+
+
+GraphEntryInstr::GraphEntryInstr(TargetEntryInstr* normal_entry)
+ : BlockEntryInstr(),
+ normal_entry_(normal_entry),
+ catch_entries_(),
+ start_env_(NULL),
+ constant_null_(new BindInstr(BindInstr::kUsed,
Florian Schneider 2012/08/29 11:07:48 Maybe break after the first '(' here helps?
+ new ConstantComp(Object::ZoneHandle()))),
+ spill_slot_count_(0) {
}
@@ -413,22 +419,9 @@ void Definition::ReplaceUsesWith(Definition* other) {
void Definition::ReplaceUsesWith(Value* value) {
ASSERT(value != NULL);
- if (value->IsUse()) {
- ReplaceUsesWith(value->AsUse()->definition());
- return;
- }
- ASSERT(value->IsConstant());
- while (input_use_list_ != NULL) {
- Instruction* instr = input_use_list_->instruction();
- instr->SetInputAt(input_use_list_->use_index(), value);
- input_use_list_ = input_use_list_->next_use();
- }
- while (env_use_list_ != NULL) {
- Environment* env = env_use_list_->instruction()->env();
- ASSERT(env != NULL);
- env->values()[env_use_list_->use_index()] = value;
- env_use_list_ = env_use_list_->next_use();
- }
+ ASSERT(value->IsUse());
+ ReplaceUsesWith(value->AsUse()->definition());
+ return;
Florian Schneider 2012/08/29 11:07:48 No need for a return here.
Kevin Millikin (Google) 2012/08/29 12:43:44 Actually, this whole function seems kind of pointl
}
@@ -688,32 +681,6 @@ void Instruction::Goto(JoinEntryInstr* entry) {
}
-RawAbstractType* ConstantVal::CompileType() const {
- if (value().IsNull()) {
- return Type::NullType();
- }
- if (value().IsInstance()) {
- return Instance::Cast(value()).GetType();
- } else {
- ASSERT(value().IsAbstractTypeArguments());
- return AbstractType::null();
- }
-}
-
-
-intptr_t ConstantVal::ResultCid() const {
- if (value().IsNull()) {
- return kNullCid;
- }
- if (value().IsInstance()) {
- return Class::Handle(value().clazz()).id();
- } else {
- ASSERT(value().IsAbstractTypeArguments());
- return kDynamicCid;
- }
-}
-
-
RawAbstractType* UseVal::CompileType() const {
if (definition()->HasPropagatedType()) {
return definition()->PropagatedType();
@@ -733,13 +700,29 @@ intptr_t UseVal::ResultCid() const {
-RawAbstractType* MaterializeComp::CompileType() const {
- return constant_val()->CompileType();
+RawAbstractType* ConstantComp::CompileType() const {
+ if (value().IsNull()) {
+ return Type::NullType();
+ }
+ if (value().IsInstance()) {
+ return Instance::Cast(value()).GetType();
+ } else {
+ ASSERT(value().IsAbstractTypeArguments());
+ return AbstractType::null();
+ }
}
-intptr_t MaterializeComp::ResultCid() const {
- return constant_val()->ResultCid();
+intptr_t ConstantComp::ResultCid() const {
+ if (value().IsNull()) {
+ return kNullCid;
+ }
+ if (value().IsInstance()) {
+ return Class::Handle(value().clazz()).id();
+ } else {
+ ASSERT(value().IsAbstractTypeArguments());
+ return kDynamicCid;
+ }
}
@@ -1509,23 +1492,13 @@ void PushArgumentInstr::EmitNativeCode(FlowGraphCompiler* compiler) {
}
-// Helper to either use the constant value of a definition or the definition.
-static Value* UseDefinition(Definition* defn) {
- if (defn->IsBind() && defn->AsBind()->computation()->IsMaterialize()) {
- return defn->AsBind()->computation()->AsMaterialize()->constant_val();
- } else {
- return new UseVal(defn);
- }
-}
-
-
Environment::Environment(const GrowableArray<Definition*>& definitions,
intptr_t fixed_parameter_count)
: values_(definitions.length()),
locations_(NULL),
fixed_parameter_count_(fixed_parameter_count) {
for (intptr_t i = 0; i < definitions.length(); ++i) {
- values_.Add(UseDefinition(definitions[i]));
+ values_.Add(new UseVal(definitions[i]));
}
}

Powered by Google App Engine
This is Rietveld 408576698