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

Unified Diff: src/hydrogen.cc

Issue 143413019: Load elimination fix with a test case. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Review notes applied Created 6 years, 11 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 | « src/hydrogen.h ('k') | src/hydrogen-instructions.h » ('j') | no next file with comments »
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 3698a322c046681ec8471a14fa3db2110a8b678a..06a95bc38af9f2f45573e5cc110b38f893cc8c05 100644
--- a/src/hydrogen.cc
+++ b/src/hydrogen.cc
@@ -1199,7 +1199,7 @@ void HGraphBuilder::AddIncrementCounter(StatsCounter* counter) {
HValue* new_value = AddUncasted<HAdd>(old_value, graph()->GetConstant1());
new_value->ClearFlag(HValue::kCanOverflow); // Ignore counter overflow
Add<HStoreNamedField>(reference, HObjectAccess::ForCounter(),
- new_value);
+ new_value, STORE_TO_INITIALIZED_ENTRY);
}
}
@@ -1337,14 +1337,15 @@ HValue* HGraphBuilder::BuildCheckForCapacityGrow(HValue* object,
new_length->ClearFlag(HValue::kCanOverflow);
Add<HStoreNamedField>(object, HObjectAccess::ForArrayLength(kind),
- new_length);
+ new_length, INITIALIZING_STORE);
}
if (is_store && kind == FAST_SMI_ELEMENTS) {
HValue* checked_elements = environment()->Top();
// Write zero to ensure that the new element is initialized with some smi.
- Add<HStoreKeyed>(checked_elements, key, graph()->GetConstant0(), kind);
+ Add<HStoreKeyed>(checked_elements, key, graph()->GetConstant0(), kind,
+ INITIALIZING_STORE);
}
length_checker.Else();
@@ -1421,7 +1422,8 @@ void HGraphBuilder::BuildTransitionElementsKind(HValue* object,
if_builder.End();
}
- Add<HStoreNamedField>(object, HObjectAccess::ForMap(), map);
+ Add<HStoreNamedField>(object, HObjectAccess::ForMap(), map,
+ INITIALIZING_STORE);
}
@@ -1808,10 +1810,14 @@ HValue* HGraphBuilder::BuildCreateConsString(
// Initialize the cons string fields.
Add<HStoreNamedField>(result, HObjectAccess::ForStringHashField(),
- Add<HConstant>(String::kEmptyHashField));
- Add<HStoreNamedField>(result, HObjectAccess::ForStringLength(), length);
- Add<HStoreNamedField>(result, HObjectAccess::ForConsStringFirst(), left);
- Add<HStoreNamedField>(result, HObjectAccess::ForConsStringSecond(), right);
+ Add<HConstant>(String::kEmptyHashField),
+ INITIALIZING_STORE);
+ Add<HStoreNamedField>(result, HObjectAccess::ForStringLength(), length,
+ INITIALIZING_STORE);
+ Add<HStoreNamedField>(result, HObjectAccess::ForConsStringFirst(), left,
+ INITIALIZING_STORE);
+ Add<HStoreNamedField>(result, HObjectAccess::ForConsStringSecond(), right,
+ INITIALIZING_STORE);
// Count the native string addition.
AddIncrementCounter(isolate()->counters()->string_add_native());
@@ -1960,8 +1966,10 @@ HValue* HGraphBuilder::BuildUncheckedStringAdd(
// Initialize the string fields.
Add<HStoreNamedField>(result, HObjectAccess::ForStringHashField(),
- Add<HConstant>(String::kEmptyHashField));
- Add<HStoreNamedField>(result, HObjectAccess::ForStringLength(), length);
+ Add<HConstant>(String::kEmptyHashField),
+ INITIALIZING_STORE);
+ Add<HStoreNamedField>(result, HObjectAccess::ForStringLength(), length,
+ INITIALIZING_STORE);
// Copy characters to the result string.
IfBuilder if_twobyte(this);
@@ -2258,7 +2266,7 @@ void HGraphBuilder::BuildInitializeElementsHeader(HValue* elements,
AddStoreMapConstant(elements, map);
Add<HStoreNamedField>(elements, HObjectAccess::ForFixedArrayLength(),
- capacity);
+ capacity, INITIALIZING_STORE);
}
@@ -2281,15 +2289,16 @@ HInnerAllocatedObject* HGraphBuilder::BuildJSArrayHeader(HValue* array,
HValue* allocation_site_payload,
HValue* length_field) {
- Add<HStoreNamedField>(array, HObjectAccess::ForMap(), array_map);
+ Add<HStoreNamedField>(array, HObjectAccess::ForMap(), array_map,
+ INITIALIZING_STORE);
HConstant* empty_fixed_array =
Add<HConstant>(isolate()->factory()->empty_fixed_array());
HObjectAccess access = HObjectAccess::ForPropertiesPointer();
- Add<HStoreNamedField>(array, access, empty_fixed_array);
+ Add<HStoreNamedField>(array, access, empty_fixed_array, INITIALIZING_STORE);
Add<HStoreNamedField>(array, HObjectAccess::ForArrayLength(elements_kind),
- length_field);
+ length_field, INITIALIZING_STORE);
if (mode == TRACK_ALLOCATION_SITE) {
BuildCreateAllocationMemento(
@@ -2303,7 +2312,8 @@ HInnerAllocatedObject* HGraphBuilder::BuildJSArrayHeader(HValue* array,
HInnerAllocatedObject* elements = Add<HInnerAllocatedObject>(
array, Add<HConstant>(elements_location));
- Add<HStoreNamedField>(array, HObjectAccess::ForElementsPointer(), elements);
+ Add<HStoreNamedField>(array, HObjectAccess::ForElementsPointer(), elements,
+ INITIALIZING_STORE);
return elements;
}
@@ -2394,7 +2404,7 @@ HValue* HGraphBuilder::BuildGrowElementsCapacity(HValue* object,
length, new_capacity);
Add<HStoreNamedField>(object, HObjectAccess::ForElementsPointer(),
- new_elements);
+ new_elements, INITIALIZING_STORE);
return new_elements;
}
@@ -2435,14 +2445,15 @@ void HGraphBuilder::BuildFillElementsWithHole(HValue* elements,
if (initial_capacity >= 0) {
for (int i = 0; i < initial_capacity; i++) {
HInstruction* key = Add<HConstant>(i);
- Add<HStoreKeyed>(elements, key, hole, elements_kind);
+ Add<HStoreKeyed>(elements, key, hole, elements_kind,
+ PREINITIALIZING_STORE);
}
} else {
LoopBuilder builder(this, context(), LoopBuilder::kPostIncrement);
HValue* key = builder.BeginBody(from, to, Token::LT);
- Add<HStoreKeyed>(elements, key, hole, elements_kind);
+ Add<HStoreKeyed>(elements, key, hole, elements_kind, PREINITIALIZING_STORE);
builder.EndBody();
}
@@ -2488,13 +2499,16 @@ void HGraphBuilder::BuildCopyElements(HValue* from_elements,
HConstant* hole_constant = IsFastDoubleElementsKind(to_elements_kind)
? Add<HConstant>(FixedDoubleArray::hole_nan_as_double())
: graph()->GetConstantHole();
- Add<HStoreKeyed>(to_elements, key, hole_constant, kind);
+ Add<HStoreKeyed>(to_elements, key, hole_constant, kind,
+ PREINITIALIZING_STORE);
if_hole.Else();
- HStoreKeyed* store = Add<HStoreKeyed>(to_elements, key, element, kind);
+ HStoreKeyed* store = Add<HStoreKeyed>(to_elements, key, element, kind,
+ INITIALIZING_STORE);
store->SetFlag(HValue::kAllowUndefinedAsNaN);
if_hole.End();
} else {
- HStoreKeyed* store = Add<HStoreKeyed>(to_elements, key, element, kind);
+ HStoreKeyed* store = Add<HStoreKeyed>(to_elements, key, element, kind,
+ INITIALIZING_STORE);
store->SetFlag(HValue::kAllowUndefinedAsNaN);
}
@@ -2532,7 +2546,8 @@ HValue* HGraphBuilder::BuildCloneShallowArray(HValue* boilerplate,
if ((i != JSArray::kElementsOffset) || (length == 0)) {
HObjectAccess access = HObjectAccess::ForJSArrayOffset(i);
Add<HStoreNamedField>(object, access,
- Add<HLoadNamedField>(boilerplate, access));
+ Add<HLoadNamedField>(boilerplate, access),
+ INITIALIZING_STORE);
}
}
@@ -2555,13 +2570,14 @@ HValue* HGraphBuilder::BuildCloneShallowArray(HValue* boilerplate,
NOT_TENURED, FIXED_ARRAY_TYPE);
}
Add<HStoreNamedField>(object, HObjectAccess::ForElementsPointer(),
- object_elements);
+ object_elements, INITIALIZING_STORE);
// Copy the elements array header.
for (int i = 0; i < FixedArrayBase::kHeaderSize; i += kPointerSize) {
HObjectAccess access = HObjectAccess::ForFixedArrayHeader(i);
Add<HStoreNamedField>(object_elements, access,
- Add<HLoadNamedField>(boilerplate_elements, access));
+ Add<HLoadNamedField>(boilerplate_elements, access),
+ INITIALIZING_STORE);
}
// Copy the elements array contents.
@@ -2572,7 +2588,8 @@ HValue* HGraphBuilder::BuildCloneShallowArray(HValue* boilerplate,
HValue* key_constant = Add<HConstant>(i);
HInstruction* value = Add<HLoadKeyed>(boilerplate_elements, key_constant,
static_cast<HValue*>(NULL), kind);
- Add<HStoreKeyed>(object_elements, key_constant, value, kind);
+ Add<HStoreKeyed>(object_elements, key_constant, value, kind,
+ INITIALIZING_STORE);
}
}
@@ -2642,9 +2659,8 @@ void HGraphBuilder::BuildCreateAllocationMemento(
AddStoreMapConstant(
allocation_memento, isolate()->factory()->allocation_memento_map());
Add<HStoreNamedField>(
- allocation_memento,
- HObjectAccess::ForAllocationMementoSite(),
- allocation_site);
+ allocation_memento, HObjectAccess::ForAllocationMementoSite(),
+ allocation_site, INITIALIZING_STORE);
if (FLAG_allocation_site_pretenuring) {
HValue* memento_create_count = Add<HLoadNamedField>(
allocation_site, HObjectAccess::ForAllocationSiteOffset(
@@ -2656,7 +2672,8 @@ void HGraphBuilder::BuildCreateAllocationMemento(
memento_create_count->ClearFlag(HValue::kCanOverflow);
HStoreNamedField* store = Add<HStoreNamedField>(
allocation_site, HObjectAccess::ForAllocationSiteOffset(
- AllocationSite::kPretenureCreateCountOffset), memento_create_count);
+ AllocationSite::kPretenureCreateCountOffset), memento_create_count,
+ INITIALIZING_STORE);
// No write barrier needed to store a smi.
store->SkipWriteBarrier();
}
@@ -2871,7 +2888,7 @@ HValue* HGraphBuilder::JSArrayBuilder::AllocateArray(HValue* size_in_bytes,
HStoreNamedField* HGraphBuilder::AddStoreMapConstant(HValue *object,
Handle<Map> map) {
return Add<HStoreNamedField>(object, HObjectAccess::ForMap(),
- Add<HConstant>(map));
+ Add<HConstant>(map), INITIALIZING_STORE);
}
@@ -5187,7 +5204,8 @@ void HOptimizedGraphBuilder::VisitArrayLiteral(ArrayLiteral* expr) {
case FAST_DOUBLE_ELEMENTS:
case FAST_HOLEY_DOUBLE_ELEMENTS: {
HStoreKeyed* instr = Add<HStoreKeyed>(elements, key, value,
- boilerplate_elements_kind);
+ boilerplate_elements_kind,
+ INITIALIZING_STORE);
instr->SetUninitialized(uninitialized);
break;
}
@@ -5263,10 +5281,10 @@ HInstruction* HOptimizedGraphBuilder::BuildStoreNamedField(
HEAP_NUMBER_TYPE);
AddStoreMapConstant(heap_number, isolate()->factory()->heap_number_map());
Add<HStoreNamedField>(heap_number, HObjectAccess::ForHeapNumberValue(),
- value);
+ value, INITIALIZING_STORE);
instr = New<HStoreNamedField>(checked_object->ActualValue(),
heap_number_access,
- heap_number);
+ heap_number, INITIALIZING_STORE);
} else {
// Already holds a HeapNumber; load the box and write its value field.
HInstruction* heap_number = Add<HLoadNamedField>(checked_object,
@@ -5274,7 +5292,7 @@ HInstruction* HOptimizedGraphBuilder::BuildStoreNamedField(
heap_number->set_type(HType::HeapNumber());
instr = New<HStoreNamedField>(heap_number,
HObjectAccess::ForHeapNumberValue(),
- value);
+ value, STORE_TO_INITIALIZED_ENTRY);
}
} else {
// This is a normal store.
@@ -7654,7 +7672,7 @@ bool HOptimizedGraphBuilder::TryInlineBuiltinMethodCall(
}
Add<HStoreNamedField>(
checked_object, HObjectAccess::ForArrayLength(elements_kind),
- reduced_length);
+ reduced_length, STORE_TO_INITIALIZED_ENTRY);
if (!ast_context()->IsEffect()) Push(result);
Add<HSimulate>(expr->id(), REMOVABLE_SIMULATE);
if (!ast_context()->IsEffect()) Drop(1);
@@ -8075,7 +8093,7 @@ void HOptimizedGraphBuilder::BuildInlinedCallNewArray(CallNew* expr) {
for (int i = 0; i < argument_count; i++) {
HValue* value = environment()->ExpressionStackAt(argument_count - i - 1);
HValue* constant_i = Add<HConstant>(i);
- Add<HStoreKeyed>(elements, constant_i, value, kind);
+ Add<HStoreKeyed>(elements, constant_i, value, kind, INITIALIZING_STORE);
}
}
@@ -8192,21 +8210,21 @@ void HOptimizedGraphBuilder::VisitCallNew(CallNew* expr) {
ASSERT(initial_map->instance_type() == JS_OBJECT_TYPE);
Add<HStoreNamedField>(receiver,
HObjectAccess::ForJSObjectOffset(JSObject::kMapOffset),
- initial_map_value);
+ initial_map_value, INITIALIZING_STORE);
HValue* empty_fixed_array = Add<HConstant>(factory->empty_fixed_array());
Add<HStoreNamedField>(receiver,
HObjectAccess::ForJSObjectOffset(JSObject::kPropertiesOffset),
- empty_fixed_array);
+ empty_fixed_array, INITIALIZING_STORE);
Add<HStoreNamedField>(receiver,
HObjectAccess::ForJSObjectOffset(JSObject::kElementsOffset),
- empty_fixed_array);
+ empty_fixed_array, INITIALIZING_STORE);
if (initial_map->inobject_properties() != 0) {
HConstant* undefined = graph()->GetConstantUndefined();
for (int i = 0; i < initial_map->inobject_properties(); i++) {
int property_offset = JSObject::kHeaderSize + i * kPointerSize;
Add<HStoreNamedField>(receiver,
HObjectAccess::ForJSObjectOffset(property_offset),
- undefined);
+ undefined, PREINITIALIZING_STORE);
}
}
}
@@ -8291,27 +8309,29 @@ void HGraphBuilder::BuildArrayBufferViewInitialization(
offset += kPointerSize) {
Add<HStoreNamedField>(obj,
HObjectAccess::ForJSObjectOffset(offset),
- Add<HConstant>(static_cast<int32_t>(0)));
+ graph()->GetConstant0(), INITIALIZING_STORE);
}
Add<HStoreNamedField>(
obj,
- HObjectAccess::ForJSArrayBufferViewBuffer(), buffer);
+ HObjectAccess::ForJSArrayBufferViewBuffer(), buffer, INITIALIZING_STORE);
Add<HStoreNamedField>(
obj,
HObjectAccess::ForJSArrayBufferViewByteOffset(),
- byte_offset);
+ byte_offset, INITIALIZING_STORE);
Add<HStoreNamedField>(
obj,
HObjectAccess::ForJSArrayBufferViewByteLength(),
- byte_length);
+ byte_length, INITIALIZING_STORE);
HObjectAccess weak_first_view_access =
HObjectAccess::ForJSArrayBufferWeakFirstView();
Add<HStoreNamedField>(obj,
HObjectAccess::ForJSArrayBufferViewWeakNext(),
- Add<HLoadNamedField>(buffer, weak_first_view_access));
- Add<HStoreNamedField>(buffer, weak_first_view_access, obj);
+ Add<HLoadNamedField>(buffer, weak_first_view_access),
+ INITIALIZING_STORE);
+ Add<HStoreNamedField>(
+ buffer, weak_first_view_access, obj, INITIALIZING_STORE);
}
@@ -8401,7 +8421,7 @@ void HOptimizedGraphBuilder::VisitTypedArrayInitialize(
Add<HStoreNamedField>(obj,
HObjectAccess::ForJSTypedArrayLength(),
- length);
+ length, INITIALIZING_STORE);
HValue* elements =
Add<HAllocate>(
@@ -8412,9 +8432,7 @@ void HOptimizedGraphBuilder::VisitTypedArrayInitialize(
Handle<Map> external_array_map(
isolate()->heap()->MapForExternalArrayType(array_type));
- Add<HStoreNamedField>(elements,
- HObjectAccess::ForMap(),
- Add<HConstant>(external_array_map));
+ AddStoreMapConstant(elements, external_array_map);
HValue* backing_store = Add<HLoadNamedField>(
buffer, HObjectAccess::ForJSArrayBufferBackingStore());
@@ -8431,14 +8449,14 @@ void HOptimizedGraphBuilder::VisitTypedArrayInitialize(
typed_array_start = external_pointer;
}
- Add<HStoreNamedField>(elements,
- HObjectAccess::ForExternalArrayExternalPointer(),
- typed_array_start);
- Add<HStoreNamedField>(elements,
- HObjectAccess::ForFixedArrayLength(),
- length);
Add<HStoreNamedField>(
- obj, HObjectAccess::ForElementsPointer(), elements);
+ elements, HObjectAccess::ForExternalArrayExternalPointer(),
+ typed_array_start, INITIALIZING_STORE);
+ Add<HStoreNamedField>(
+ elements, HObjectAccess::ForFixedArrayLength(), length,
+ INITIALIZING_STORE);
+ Add<HStoreNamedField>(
+ obj, HObjectAccess::ForElementsPointer(), elements, INITIALIZING_STORE);
}
if (!is_zero_byte_offset) {
@@ -9675,7 +9693,7 @@ void HOptimizedGraphBuilder::BuildEmitObjectHeader(
ASSERT(*properties_field == isolate()->heap()->empty_fixed_array());
HInstruction* properties = Add<HConstant>(properties_field);
HObjectAccess access = HObjectAccess::ForPropertiesPointer();
- Add<HStoreNamedField>(object, access, properties);
+ Add<HStoreNamedField>(object, access, properties, INITIALIZING_STORE);
if (boilerplate_object->IsJSArray()) {
Handle<JSArray> boilerplate_array =
@@ -9686,7 +9704,7 @@ void HOptimizedGraphBuilder::BuildEmitObjectHeader(
ASSERT(boilerplate_array->length()->IsSmi());
Add<HStoreNamedField>(object, HObjectAccess::ForArrayLength(
- boilerplate_array->GetElementsKind()), length);
+ boilerplate_array->GetElementsKind()), length, INITIALIZING_STORE);
}
}
@@ -9702,7 +9720,7 @@ void HOptimizedGraphBuilder::BuildInitElementsInObjectHeader(
object_elements = Add<HConstant>(elements_field);
}
Add<HStoreNamedField>(object, HObjectAccess::ForElementsPointer(),
- object_elements);
+ object_elements, INITIALIZING_STORE);
}
@@ -9738,7 +9756,7 @@ void HOptimizedGraphBuilder::BuildEmitInObjectProperties(
HInstruction* result =
BuildFastLiteral(value_object, site_context);
site_context->ExitScope(current_site, value_object);
- Add<HStoreNamedField>(object, access, result);
+ Add<HStoreNamedField>(object, access, result, INITIALIZING_STORE);
} else {
Representation representation = details.representation();
HInstruction* value_instruction;
@@ -9756,7 +9774,7 @@ void HOptimizedGraphBuilder::BuildEmitInObjectProperties(
AddStoreMapConstant(double_box,
isolate()->factory()->heap_number_map());
Add<HStoreNamedField>(double_box, HObjectAccess::ForHeapNumberValue(),
- Add<HConstant>(value));
+ Add<HConstant>(value), INITIALIZING_STORE);
value_instruction = double_box;
} else if (representation.IsSmi() && value->IsUninitialized()) {
value_instruction = graph()->GetConstant0();
@@ -9764,7 +9782,8 @@ void HOptimizedGraphBuilder::BuildEmitInObjectProperties(
value_instruction = Add<HConstant>(value);
}
- Add<HStoreNamedField>(object, access, value_instruction);
+ Add<HStoreNamedField>(object, access, value_instruction,
+ INITIALIZING_STORE);
}
}
@@ -9775,7 +9794,8 @@ void HOptimizedGraphBuilder::BuildEmitInObjectProperties(
ASSERT(boilerplate_object->IsJSObject());
int property_offset = boilerplate_object->GetInObjectPropertyOffset(i);
HObjectAccess access = HObjectAccess::ForJSObjectOffset(property_offset);
- Add<HStoreNamedField>(object, access, value_instruction);
+ Add<HStoreNamedField>(object, access, value_instruction,
+ PREINITIALIZING_STORE);
}
}
@@ -9815,7 +9835,8 @@ void HOptimizedGraphBuilder::BuildEmitFixedDoubleArray(
static_cast<HValue*>(NULL), kind,
ALLOW_RETURN_HOLE);
HInstruction* store = Add<HStoreKeyed>(object_elements, key_constant,
- value_instruction, kind);
+ value_instruction, kind,
+ INITIALIZING_STORE);
store->SetFlag(HValue::kAllowUndefinedAsNaN);
}
}
@@ -9838,13 +9859,15 @@ void HOptimizedGraphBuilder::BuildEmitFixedArray(
HInstruction* result =
BuildFastLiteral(value_object, site_context);
site_context->ExitScope(current_site, value_object);
- Add<HStoreKeyed>(object_elements, key_constant, result, kind);
+ Add<HStoreKeyed>(object_elements, key_constant, result, kind,
+ INITIALIZING_STORE);
} else {
HInstruction* value_instruction =
Add<HLoadKeyed>(boilerplate_elements, key_constant,
static_cast<HValue*>(NULL), kind,
ALLOW_RETURN_HOLE);
- Add<HStoreKeyed>(object_elements, key_constant, value_instruction, kind);
+ Add<HStoreKeyed>(object_elements, key_constant, value_instruction, kind,
+ INITIALIZING_STORE);
}
}
}
@@ -10228,7 +10251,8 @@ void HOptimizedGraphBuilder::GenerateSetValueOf(CallRuntime* call) {
// Create in-object property store to kValueOffset.
set_current_block(if_js_value);
Add<HStoreNamedField>(object,
- HObjectAccess::ForJSObjectOffset(JSValue::kValueOffset), value);
+ HObjectAccess::ForJSObjectOffset(JSValue::kValueOffset), value,
+ INITIALIZING_STORE);
Goto(if_js_value, join);
join->SetJoinId(call->id());
set_current_block(join);
« no previous file with comments | « src/hydrogen.h ('k') | src/hydrogen-instructions.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698