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

Unified Diff: src/hydrogen.cc

Issue 7298003: Add fake data dependencies (instead of disabling GVN) to fix code motion (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: stricter instruction ordering Created 9 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 | « no previous file | src/hydrogen-instructions.h » ('j') | src/hydrogen-instructions.h » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/hydrogen.cc
diff --git a/src/hydrogen.cc b/src/hydrogen.cc
index dff96b4f7b488b89f030eca4540b8ea7c5d41846..d73eb07c98ca39c286ffb916fd81357b850ad539 100644
--- a/src/hydrogen.cc
+++ b/src/hydrogen.cc
@@ -3264,7 +3264,7 @@ void HGraphBuilder::VisitArrayLiteral(ArrayLiteral* expr) {
// Load the elements array before the first store.
if (elements == NULL) {
- elements = new(zone()) HLoadElements(literal);
+ elements = new(zone()) HLoadElements(literal, literal);
Kevin Millikin (Chromium) 2011/07/11 15:03:54 The second occurrence of literal is used as a toke
Jakob Kummerow 2011/07/19 14:55:44 Obsolete (I undid the changes to HLoadElements).
AddInstruction(elements);
}
@@ -3895,8 +3895,8 @@ HInstruction* HGraphBuilder::BuildMonomorphicElementAccess(HValue* object,
: BuildLoadKeyedGeneric(object, key);
}
AddInstruction(new(zone()) HCheckNonSmi(object));
- AddInstruction(new(zone()) HCheckMap(object, map));
- HInstruction* elements = new(zone()) HLoadElements(object);
+ HInstruction* mapcheck = AddInstruction(new(zone()) HCheckMap(object, map));
+ HInstruction* elements = new(zone()) HLoadElements(object, mapcheck);
HInstruction* length = NULL;
HInstruction* checked_key = NULL;
if (map->has_external_array_elements()) {
@@ -3911,7 +3911,7 @@ HInstruction* HGraphBuilder::BuildMonomorphicElementAccess(HValue* object,
}
ASSERT(map->has_fast_elements());
if (map->instance_type() == JS_ARRAY_TYPE) {
- length = AddInstruction(new(zone()) HJSArrayLength(object));
+ length = AddInstruction(new(zone()) HJSArrayLength(object, mapcheck));
checked_key = AddInstruction(new(zone()) HBoundsCheck(key, length));
AddInstruction(elements);
} else {
@@ -3962,6 +3962,7 @@ HValue* HGraphBuilder::HandlePolymorphicElementAccess(HValue* object,
HInstruction* elements_kind_instr =
AddInstruction(new(zone()) HElementsKind(object));
+ HCompareConstantEqAndBranch* elements_kind_branch = NULL;
HInstruction* elements = NULL;
HLoadExternalArrayPointer* external_elements = NULL;
HInstruction* checked_key = NULL;
@@ -3978,14 +3979,8 @@ HValue* HGraphBuilder::HandlePolymorphicElementAccess(HValue* object,
JSObject::LAST_ELEMENTS_KIND);
if (elements_kind == JSObject::FIRST_EXTERNAL_ARRAY_ELEMENTS_KIND
&& todo_external_array) {
- elements = AddInstruction(new(zone()) HLoadElements(object));
- // We need to forcibly prevent some ElementsKind-dependent instructions
- // from being hoisted out of any loops they might occur in, because
- // the current loop-invariant-code-motion algorithm isn't clever enough
- // to deal with them properly.
- // There's some performance to be gained by developing a smarter
- // solution for this.
- elements->ClearFlag(HValue::kUseGVN);
+ elements = AddInstruction(
+ new(zone()) HLoadElements(object, elements_kind_branch));
Kevin Millikin (Chromium) 2011/07/11 15:03:54 Should we assert the check instruction is not NULL
Jakob Kummerow 2011/07/19 14:55:44 Good catch! Depending on the JS code being execute
HInstruction* length =
AddInstruction(new(zone()) HExternalArrayLength(elements));
checked_key = AddInstruction(new(zone()) HBoundsCheck(key, length));
@@ -3995,13 +3990,11 @@ HValue* HGraphBuilder::HandlePolymorphicElementAccess(HValue* object,
if (type_todo[elements_kind]) {
HBasicBlock* if_true = graph()->CreateBasicBlock();
HBasicBlock* if_false = graph()->CreateBasicBlock();
- HCompareConstantEqAndBranch* compare =
- new(zone()) HCompareConstantEqAndBranch(elements_kind_instr,
- elements_kind,
- Token::EQ_STRICT);
- compare->SetSuccessorAt(0, if_true);
- compare->SetSuccessorAt(1, if_false);
- current_block()->Finish(compare);
+ elements_kind_branch = new(zone()) HCompareConstantEqAndBranch(
+ elements_kind_instr, elements_kind, Token::EQ_STRICT);
+ elements_kind_branch->SetSuccessorAt(0, if_true);
+ elements_kind_branch->SetSuccessorAt(1, if_false);
+ current_block()->Finish(elements_kind_branch);
set_current_block(if_true);
HInstruction* access;
@@ -4015,12 +4008,11 @@ HValue* HGraphBuilder::HandlePolymorphicElementAccess(HValue* object,
current_block()->Finish(typecheck);
set_current_block(if_jsarray);
- HInstruction* length = new(zone()) HJSArrayLength(object);
+ HInstruction* length = new(zone()) HJSArrayLength(object, typecheck);
AddInstruction(length);
- length->ClearFlag(HValue::kUseGVN);
checked_key = AddInstruction(new(zone()) HBoundsCheck(key, length));
- elements = AddInstruction(new(zone()) HLoadElements(object));
- elements->ClearFlag(HValue::kUseGVN);
+ elements =
+ AddInstruction(new(zone()) HLoadElements(object, checked_key));
if (is_store) {
access = AddInstruction(
new(zone()) HStoreKeyedFastElement(elements, checked_key, val));
@@ -4036,8 +4028,7 @@ HValue* HGraphBuilder::HandlePolymorphicElementAccess(HValue* object,
if_jsarray->Goto(join);
set_current_block(if_fastobject);
- elements = AddInstruction(new(zone()) HLoadElements(object));
- elements->ClearFlag(HValue::kUseGVN);
+ elements = AddInstruction(new(zone()) HLoadElements(object, typecheck));
length = AddInstruction(new(zone()) HFixedArrayLength(elements));
checked_key = AddInstruction(new(zone()) HBoundsCheck(key, length));
if (is_store) {
@@ -4170,8 +4161,9 @@ void HGraphBuilder::VisitProperty(Property* expr) {
if (expr->IsArrayLength()) {
HValue* array = Pop();
AddInstruction(new(zone()) HCheckNonSmi(array));
- AddInstruction(HCheckInstanceType::NewIsJSArray(array));
- instr = new(zone()) HJSArrayLength(array);
+ HInstruction* mapcheck =
+ AddInstruction(HCheckInstanceType::NewIsJSArray(array));
+ instr = new(zone()) HJSArrayLength(array, mapcheck);
} else if (expr->IsStringLength()) {
HValue* string = Pop();
« no previous file with comments | « no previous file | src/hydrogen-instructions.h » ('j') | src/hydrogen-instructions.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698