Reviewers: Jakob,
Description:
Make it clear that HInstruction's position is a write-once variable.
Please review this at http://codereview.chromium.org/10782010/
SVN Base: https://v8.googlecode.com/svn/branches/bleeding_edge
Affected files:
M src/hydrogen-instructions.h
M src/hydrogen.cc
Index: src/hydrogen-instructions.h
diff --git a/src/hydrogen-instructions.h b/src/hydrogen-instructions.h
index
875b631595d3893e3e168285c0158e1572c33aac..edd93f0748e0ca90e5f884542a9bf38399177875
100644
--- a/src/hydrogen-instructions.h
+++ b/src/hydrogen-instructions.h
@@ -857,9 +857,14 @@ class HInstruction: public HValue {
void InsertBefore(HInstruction* next);
void InsertAfter(HInstruction* previous);
+ // The position is a write-once variable.
int position() const { return position_; }
bool has_position() const { return position_ != RelocInfo::kNoPosition; }
- void set_position(int position) { position_ = position; }
+ void set_position(int position) {
+ ASSERT(!has_position());
+ ASSERT(position != RelocInfo::kNoPosition);
+ position_ = position;
+ }
bool CanTruncateToInt32() const { return CheckFlag(kTruncatingToInt32); }
Index: src/hydrogen.cc
diff --git a/src/hydrogen.cc b/src/hydrogen.cc
index
0897aad305be9f08bb1771b3612dfc94388c1c3b..683e805566c024a07585fad5c21fd5778c3b52e5
100644
--- a/src/hydrogen.cc
+++ b/src/hydrogen.cc
@@ -5940,7 +5940,9 @@ HValue*
HGraphBuilder::HandlePolymorphicElementAccess(HValue* object,
if (consolidated_load != NULL) {
AddInstruction(consolidated_load);
*has_side_effects |= consolidated_load->HasObservableSideEffects();
- consolidated_load->set_position(position);
+ if (position != RelocInfo::kNoPosition) {
+ consolidated_load->set_position(position);
+ }
return consolidated_load;
}
}
@@ -6006,7 +6008,7 @@ HValue*
HGraphBuilder::HandlePolymorphicElementAccess(HValue* object,
object, key, val, transition, untransitionable_map, is_store));
}
*has_side_effects |= instr->HasObservableSideEffects();
- instr->set_position(position);
+ if (position != RelocInfo::kNoPosition) instr->set_position(position);
return is_store ? NULL : instr;
}
@@ -6108,7 +6110,7 @@ HValue*
HGraphBuilder::HandlePolymorphicElementAccess(HValue* object,
external_elements, checked_key, val, elements_kind, is_store));
}
*has_side_effects |= access->HasObservableSideEffects();
- access->set_position(position);
+ if (position != RelocInfo::kNoPosition)
access->set_position(position);
if (!is_store) {
Push(access);
}
@@ -6155,7 +6157,7 @@ HValue*
HGraphBuilder::HandleKeyedElementAccess(HValue* obj,
instr = BuildLoadKeyedGeneric(obj, key);
}
}
- instr->set_position(position);
+ if (position != RelocInfo::kNoPosition) instr->set_position(position);
AddInstruction(instr);
*has_side_effects = instr->HasObservableSideEffects();
return instr;
@@ -7507,7 +7509,6 @@ void HGraphBuilder::VisitCallRuntime(CallRuntime*
expr) {
int argument_count = expr->arguments()->length();
HCallRuntime* call =
new(zone()) HCallRuntime(context, name, function, argument_count);
- call->set_position(RelocInfo::kNoPosition);
Drop(argument_count);
return ast_context()->ReturnInstruction(call, expr->id());
}
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev