Index: src/hydrogen.cc |
diff --git a/src/hydrogen.cc b/src/hydrogen.cc |
index 58a9b78750bb7401bfdc9e167800f8f01d3ef078..6c19384976c687ebaf8bdcb3afafaa5939d7a563 100644 |
--- a/src/hydrogen.cc |
+++ b/src/hydrogen.cc |
@@ -1191,16 +1191,9 @@ HValue* HGraphBuilder::BuildCheckForCapacityGrow(HValue* object, |
new_length->ChangeRepresentation(Representation::Integer32()); |
new_length->ClearFlag(HValue::kCanOverflow); |
- Factory* factory = isolate()->factory(); |
- Representation representation = IsFastElementsKind(kind) |
- ? Representation::Smi() : Representation::Tagged(); |
- HInstruction* length_store = AddInstruction(new(zone) HStoreNamedField( |
- object, |
- factory->length_field_string(), |
- new_length, true, |
- representation, |
- JSArray::kLengthOffset)); |
- length_store->SetGVNFlag(kChangesArrayLengths); |
+ AddStore(object, HObjectAccess::ForArrayLength(), new_length, |
+ IsFastElementsKind(kind) |
+ ? Representation::Smi() : Representation::Tagged()); |
} |
length_checker.Else(); |
@@ -1281,8 +1274,8 @@ HInstruction* HGraphBuilder::BuildUncheckedMonomorphicElementAccess( |
} |
HInstruction* length = NULL; |
if (is_js_array) { |
- length = AddInstruction( |
- HLoadNamedField::NewArrayLength(zone, object, mapcheck, HType::Smi())); |
+ length = AddLoad(object, HObjectAccess::ForArrayLength(), mapcheck); |
+ length->set_type(HType::Smi()); |
} else { |
length = AddInstruction(new(zone) HFixedArrayBaseLength(elements)); |
} |
@@ -1408,21 +1401,16 @@ HValue* HGraphBuilder::BuildAllocateElements(HValue* context, |
void HGraphBuilder::BuildInitializeElements(HValue* elements, |
ElementsKind kind, |
HValue* capacity) { |
- Zone* zone = this->zone(); |
Factory* factory = isolate()->factory(); |
Handle<Map> map = IsFastDoubleElementsKind(kind) |
? factory->fixed_double_array_map() |
: factory->fixed_array_map(); |
- BuildStoreMap(elements, map); |
- Handle<String> fixed_array_length_field_name = factory->length_field_string(); |
+ AddStoreMapConstant(elements, map); |
Representation representation = IsFastElementsKind(kind) |
? Representation::Smi() : Representation::Tagged(); |
- HInstruction* store_length = |
- new(zone) HStoreNamedField(elements, fixed_array_length_field_name, |
- capacity, true, representation, |
- FixedArray::kLengthOffset); |
- AddInstruction(store_length); |
+ AddStore(elements, HObjectAccess::ForFixedArrayLength(), capacity, |
+ representation); |
} |
@@ -1441,7 +1429,7 @@ HInnerAllocatedObject* HGraphBuilder::BuildJSArrayHeader(HValue* array, |
HValue* allocation_site_payload, |
HValue* length_field) { |
- BuildStoreMap(array, array_map); |
+ AddStore(array, HObjectAccess::ForMap(), array_map); |
HConstant* empty_fixed_array = |
new(zone()) HConstant( |
@@ -1449,21 +1437,9 @@ HInnerAllocatedObject* HGraphBuilder::BuildJSArrayHeader(HValue* array, |
Representation::Tagged()); |
AddInstruction(empty_fixed_array); |
- AddInstruction(new(zone()) HStoreNamedField(array, |
- isolate()->factory()->properties_field_symbol(), |
- empty_fixed_array, |
- true, |
- Representation::Tagged(), |
- JSArray::kPropertiesOffset)); |
- |
- HInstruction* length_store = AddInstruction( |
- new(zone()) HStoreNamedField(array, |
- isolate()->factory()->length_field_string(), |
- length_field, |
- true, |
- Representation::Tagged(), |
- JSArray::kLengthOffset)); |
- length_store->SetGVNFlag(kChangesArrayLengths); |
+ HObjectAccess access = HObjectAccess::ForPropertiesPointer(); |
+ AddStore(array, access, empty_fixed_array); |
+ AddStore(array, HObjectAccess::ForArrayLength(), length_field); |
if (mode == TRACK_ALLOCATION_SITE) { |
BuildCreateAllocationSiteInfo(array, |
@@ -1477,58 +1453,17 @@ HInnerAllocatedObject* HGraphBuilder::BuildJSArrayHeader(HValue* array, |
} |
HInnerAllocatedObject* elements = new(zone()) HInnerAllocatedObject( |
- array, |
- elements_location); |
+ array, elements_location); |
AddInstruction(elements); |
- HInstruction* elements_store = AddInstruction( |
- new(zone()) HStoreNamedField( |
- array, |
- isolate()->factory()->elements_field_string(), |
- elements, |
- true, |
- Representation::Tagged(), |
- JSArray::kElementsOffset)); |
- elements_store->SetGVNFlag(kChangesElementsPointer); |
- |
+ AddStore(array, HObjectAccess::ForElementsPointer(), elements); |
return elements; |
} |
-HInstruction* HGraphBuilder::BuildStoreMap(HValue* object, |
- HValue* map) { |
- Zone* zone = this->zone(); |
- Factory* factory = isolate()->factory(); |
- Handle<String> map_field_name = factory->map_field_string(); |
- HInstruction* store_map = |
- new(zone) HStoreNamedField(object, map_field_name, map, |
- true, Representation::Tagged(), |
- JSObject::kMapOffset); |
- store_map->ClearGVNFlag(kChangesInobjectFields); |
- store_map->SetGVNFlag(kChangesMaps); |
- AddInstruction(store_map); |
- return store_map; |
-} |
- |
- |
-HInstruction* HGraphBuilder::BuildStoreMap(HValue* object, |
- Handle<Map> map) { |
- Zone* zone = this->zone(); |
- HValue* map_constant = |
- AddInstruction(new(zone) HConstant(map, Representation::Tagged())); |
- return BuildStoreMap(object, map_constant); |
-} |
- |
- |
HLoadNamedField* HGraphBuilder::AddLoadElements(HValue* object, |
- HValue* typecheck) { |
- HLoadNamedField* instr = new(zone()) HLoadNamedField(object, true, |
- Representation::Tagged(), JSObject::kElementsOffset, typecheck); |
- AddInstruction(instr); |
- instr->SetGVNFlag(kDependsOnElementsPointer); |
- instr->ClearGVNFlag(kDependsOnMaps); |
- instr->ClearGVNFlag(kDependsOnInobjectFields); |
- return instr; |
+ HValue* typecheck) { |
+ return AddLoad(object, HObjectAccess::ForElementsPointer(), typecheck); |
} |
@@ -1581,7 +1516,6 @@ HValue* HGraphBuilder::BuildGrowElementsCapacity(HValue* object, |
ElementsKind kind, |
HValue* length, |
HValue* new_capacity) { |
- Zone* zone = this->zone(); |
HValue* context = environment()->LookupContext(); |
BuildNewSpaceArrayCheck(new_capacity, kind); |
@@ -1593,13 +1527,7 @@ HValue* HGraphBuilder::BuildGrowElementsCapacity(HValue* object, |
new_elements, kind, |
length, new_capacity); |
- Factory* factory = isolate()->factory(); |
- HInstruction* elements_store = AddInstruction(new(zone) HStoreNamedField( |
- object, |
- factory->elements_field_string(), |
- new_elements, true, Representation::Tagged(), |
- JSArray::kElementsOffset)); |
- elements_store->SetGVNFlag(kChangesElementsPointer); |
+ AddStore(object, HObjectAccess::ForElementsPointer(), new_elements); |
return new_elements; |
} |
@@ -1704,7 +1632,6 @@ HValue* HGraphBuilder::BuildCloneShallowArray(HContext* context, |
ElementsKind kind, |
int length) { |
Zone* zone = this->zone(); |
- Factory* factory = isolate()->factory(); |
NoObservableSideEffectsScope no_effects(this); |
@@ -1734,16 +1661,8 @@ HValue* HGraphBuilder::BuildCloneShallowArray(HContext* context, |
// Copy the JS array part. |
for (int i = 0; i < JSArray::kSize; i += kPointerSize) { |
if ((i != JSArray::kElementsOffset) || (length == 0)) { |
- HInstruction* value = AddInstruction(new(zone) HLoadNamedField( |
- boilerplate, true, Representation::Tagged(), i)); |
- if (i != JSArray::kMapOffset) { |
- AddInstruction(new(zone) HStoreNamedField(object, |
- factory->empty_string(), |
- value, true, |
- Representation::Tagged(), i)); |
- } else { |
- BuildStoreMap(object, value); |
- } |
+ HObjectAccess access = HObjectAccess::ForJSArrayOffset(i); |
+ AddStore(object, access, AddLoad(boilerplate, access)); |
} |
} |
@@ -1758,21 +1677,12 @@ HValue* HGraphBuilder::BuildCloneShallowArray(HContext* context, |
HValue* boilerplate_elements = AddLoadElements(boilerplate); |
HValue* object_elements = |
AddInstruction(new(zone) HInnerAllocatedObject(object, elems_offset)); |
- AddInstruction(new(zone) HStoreNamedField(object, |
- factory->elements_field_string(), |
- object_elements, true, |
- Representation::Tagged(), |
- JSObject::kElementsOffset)); |
+ AddStore(object, HObjectAccess::ForElementsPointer(), object_elements); |
// Copy the elements array header. |
for (int i = 0; i < FixedArrayBase::kHeaderSize; i += kPointerSize) { |
- HInstruction* value = |
- AddInstruction(new(zone) HLoadNamedField( |
- boilerplate_elements, true, Representation::Tagged(), i)); |
- AddInstruction(new(zone) HStoreNamedField(object_elements, |
- factory->empty_string(), |
- value, true, |
- Representation::Tagged(), i)); |
+ HObjectAccess access = HObjectAccess::ForFixedArrayOffset(i); |
+ AddStore(object_elements, access, AddLoad(boilerplate_elements, access)); |
} |
// Copy the elements array contents. |
@@ -1852,13 +1762,11 @@ HValue* HGraphBuilder::BuildCreateAllocationSiteInfo(HValue* previous_object, |
HInnerAllocatedObject(previous_object, previous_object_size); |
AddInstruction(alloc_site); |
Handle<Map> alloc_site_map(isolate()->heap()->allocation_site_info_map()); |
- BuildStoreMap(alloc_site, alloc_site_map); |
- AddInstruction(new(zone()) HStoreNamedField(alloc_site, |
- isolate()->factory()->payload_string(), |
- payload, |
- true, |
- Representation::Tagged(), |
- AllocationSiteInfo::kPayloadOffset)); |
+ AddStoreMapConstant(alloc_site, alloc_site_map); |
+ HObjectAccess access = HObjectAccess::For( |
+ true, AllocationSiteInfo::kPayloadOffset, |
+ isolate()->factory()->payload_string()); |
+ AddStore(alloc_site, access, payload); |
return alloc_site; |
} |
@@ -1882,16 +1790,17 @@ HValue* HGraphBuilder::JSArrayBuilder::EmitMapCode(HValue* context) { |
// Get the global context, the native context, the map array |
HInstruction* global_object = AddInstruction(new(zone()) |
HGlobalObject(context)); |
- HInstruction* native_context = AddInstruction(new(zone()) |
- HLoadNamedField(global_object, true, Representation::Tagged(), |
- GlobalObject::kNativeContextOffset)); |
- int offset = Context::kHeaderSize + |
- kPointerSize * Context::JS_ARRAY_MAPS_INDEX; |
- HInstruction* map_array = AddInstruction(new(zone()) |
- HLoadNamedField(native_context, true, Representation::Tagged(), offset)); |
- offset = kind_ * kPointerSize + FixedArrayBase::kHeaderSize; |
- return AddInstruction(new(zone()) HLoadNamedField( |
- map_array, true, Representation::Tagged(), offset)); |
+ HObjectAccess access = HObjectAccess::ForFixedArrayOffset( |
+ GlobalObject::kNativeContextOffset); |
+ HInstruction* native_context = builder()->AddLoad(global_object, access); |
+ |
+ access = HObjectAccess::ForFixedArrayOffset( |
+ Context::kHeaderSize + kPointerSize * Context::JS_ARRAY_MAPS_INDEX); |
+ HInstruction* map_array = builder()->AddLoad(native_context, access); |
+ |
+ access = HObjectAccess::ForFixedArrayOffset( |
+ kind_ * kPointerSize + FixedArrayBase::kHeaderSize); |
+ return builder()->AddLoad(map_array, access); |
} |
@@ -2000,6 +1909,39 @@ HValue* HGraphBuilder::JSArrayBuilder::AllocateArray(HValue* size_in_bytes, |
} |
+HStoreNamedField* HGraphBuilder::AddStore(HValue *object, |
+ HObjectAccess access, |
+ HValue *val, |
+ Representation representation) { |
+ HStoreNamedField *instr = new(zone()) |
+ HStoreNamedField(object, access, val, representation); |
+ AddInstruction(instr); |
+ return instr; |
+} |
+ |
+ |
+HLoadNamedField* HGraphBuilder::AddLoad(HValue *object, |
+ HObjectAccess access, |
+ HValue *typecheck, |
+ Representation representation) { |
+ HLoadNamedField *instr = |
+ new(zone()) HLoadNamedField(object, access, typecheck, representation); |
+ AddInstruction(instr); |
+ return instr; |
+} |
+ |
+ |
+HStoreNamedField* HGraphBuilder::AddStoreMapConstant(HValue *object, |
+ Handle<Map> map) { |
+ HValue* constant = |
+ AddInstruction(new(zone()) HConstant(map, Representation::Tagged())); |
+ HStoreNamedField *instr = |
+ new(zone()) HStoreNamedField(object, HObjectAccess::ForMap(), constant); |
+ AddInstruction(instr); |
+ return instr; |
+} |
+ |
+ |
HOptimizedGraphBuilder::HOptimizedGraphBuilder(CompilationInfo* info, |
TypeFeedbackOracle* oracle) |
: HGraphBuilder(info), |
@@ -6341,7 +6283,7 @@ static Handle<SharedFunctionInfo> SearchSharedFunctionInfo( |
Code* unoptimized_code, FunctionLiteral* expr) { |
int start_position = expr->start_position(); |
RelocIterator it(unoptimized_code); |
- for (;!it.done(); it.next()) { |
+ for (; !it.done(); it.next()) { |
RelocInfo* rinfo = it.rinfo(); |
if (rinfo->rmode() != RelocInfo::EMBEDDED_OBJECT) continue; |
Object* obj = rinfo->target_object(); |
@@ -6958,20 +6900,6 @@ static bool ComputeLoadStoreField(Handle<Map> type, |
} |
-static int ComputeLoadStoreFieldIndex(Handle<Map> type, |
- LookupResult* lookup) { |
- ASSERT(lookup->IsField() || lookup->IsTransitionToField(*type)); |
- if (lookup->IsField()) { |
- return lookup->GetLocalFieldIndexFromMap(*type); |
- } else { |
- Map* transition = lookup->GetTransitionMapFromMap(*type); |
- int descriptor = transition->LastAdded(); |
- int index = transition->instance_descriptors()->GetFieldIndex(descriptor); |
- return index - type->inobject_properties(); |
- } |
-} |
- |
- |
static Representation ComputeLoadStoreRepresentation(Handle<Map> type, |
LookupResult* lookup) { |
if (lookup->IsField()) { |
@@ -7036,19 +6964,10 @@ HInstruction* HOptimizedGraphBuilder::BuildStoreNamedField( |
zone())); |
} |
- int index = ComputeLoadStoreFieldIndex(map, lookup); |
- bool is_in_object = index < 0; |
- Representation representation = ComputeLoadStoreRepresentation(map, lookup); |
- int offset = index * kPointerSize; |
- if (index < 0) { |
- // Negative property indices are in-object properties, indexed |
- // from the end of the fixed part of the object. |
- offset += map->instance_size(); |
- } else { |
- offset += FixedArray::kHeaderSize; |
- } |
- HStoreNamedField* instr = new(zone()) HStoreNamedField( |
- object, name, value, is_in_object, representation, offset); |
+ HObjectAccess access = HObjectAccess::ForField(map, lookup, name); |
+ HStoreNamedField* instr = new(zone()) HStoreNamedField(object, access, value, |
+ ComputeLoadStoreRepresentation(map, lookup)); |
+ |
if (lookup->IsTransitionToField(*map)) { |
Handle<Map> transition(lookup->GetTransitionMapFromMap(*map)); |
instr->set_transition(transition); |
@@ -7118,9 +7037,10 @@ bool HOptimizedGraphBuilder::HandlePolymorphicArrayLengthLoad( |
AddInstruction(new(zone()) HCheckNonSmi(object)); |
HInstruction* typecheck = |
- AddInstruction(HCheckMaps::New(object, types, zone())); |
- HInstruction* instr = |
- HLoadNamedField::NewArrayLength(zone(), object, typecheck); |
+ AddInstruction(HCheckMaps::New(object, types, zone())); |
+ HInstruction* instr = new(zone()) |
+ HLoadNamedField(object, HObjectAccess::ForArrayLength(), typecheck); |
+ |
instr->set_position(expr->position()); |
ast_context()->ReturnInstruction(instr, expr->id()); |
return true; |
@@ -7144,22 +7064,16 @@ void HOptimizedGraphBuilder::HandlePolymorphicLoadNamedField(Property* expr, |
for (int i = 0; i < types->length() && count < kMaxLoadPolymorphism; ++i) { |
map = types->at(i); |
if (ComputeLoadStoreField(map, name, &lookup, false)) { |
- int index = ComputeLoadStoreFieldIndex(map, &lookup); |
- bool is_in_object = index < 0; |
- int offset = index * kPointerSize; |
- if (index < 0) { |
- // Negative property indices are in-object properties, indexed |
- // from the end of the fixed part of the object. |
- offset += map->instance_size(); |
- } else { |
- offset += FixedArray::kHeaderSize; |
- } |
+ HObjectAccess access = |
+ HObjectAccess::ForField(map, &lookup, name); |
if (count == 0) { |
- previous_field_offset = offset; |
- previous_field_is_in_object = is_in_object; |
+ previous_field_offset = access.offset(); |
+ previous_field_is_in_object = access.IsInobject(); |
} else if (is_monomorphic_field) { |
- is_monomorphic_field = (offset == previous_field_offset) && |
- (is_in_object == previous_field_is_in_object); |
+ // TODO(titzer): just break out of this loop if not the same |
+ is_monomorphic_field = |
+ (access.offset() == previous_field_offset) && |
+ (access.IsInobject() == previous_field_is_in_object); |
} |
++count; |
} |
@@ -7171,14 +7085,13 @@ void HOptimizedGraphBuilder::HandlePolymorphicLoadNamedField(Property* expr, |
HInstruction* instr; |
if (count == types->length() && is_monomorphic_field) { |
AddInstruction(HCheckMaps::New(object, types, zone())); |
- instr = BuildLoadNamedField(object, map, &lookup); |
+ instr = new(zone()) HLoadNamedField(object, |
+ HObjectAccess::ForField(map, &lookup, name)); |
+ // TODO(titzer): ensure the representation is the same for all maps |
} else { |
HValue* context = environment()->LookupContext(); |
- instr = new(zone()) HLoadNamedFieldPolymorphic(context, |
- object, |
- types, |
- name, |
- zone()); |
+ instr = new(zone()) |
+ HLoadNamedFieldPolymorphic(context, object, types, name, zone()); |
} |
instr->set_position(expr->position()); |
@@ -7731,25 +7644,6 @@ void HOptimizedGraphBuilder::VisitThrow(Throw* expr) { |
} |
-HLoadNamedField* HOptimizedGraphBuilder::BuildLoadNamedField( |
- HValue* object, |
- Handle<Map> map, |
- LookupResult* lookup) { |
- Representation representation = lookup->representation(); |
- int index = lookup->GetLocalFieldIndexFromMap(*map); |
- if (index < 0) { |
- // Negative property indices are in-object properties, indexed |
- // from the end of the fixed part of the object. |
- int offset = (index * kPointerSize) + map->instance_size(); |
- return new(zone()) HLoadNamedField(object, true, representation, offset); |
- } else { |
- // Non-negative property indices are in the properties array. |
- int offset = (index * kPointerSize) + FixedArray::kHeaderSize; |
- return new(zone()) HLoadNamedField(object, false, representation, offset); |
- } |
-} |
- |
- |
HInstruction* HOptimizedGraphBuilder::BuildLoadNamedGeneric( |
HValue* object, |
Handle<String> name, |
@@ -7785,7 +7679,8 @@ HInstruction* HOptimizedGraphBuilder::BuildLoadNamedMonomorphic( |
if (name->Equals(isolate()->heap()->length_string())) { |
if (map->instance_type() == JS_ARRAY_TYPE) { |
AddCheckMapsWithTransitions(object, map); |
- return HLoadNamedField::NewArrayLength(zone(), object, object); |
+ return new(zone()) HLoadNamedField(object, |
+ HObjectAccess::ForArrayLength()); |
} |
} |
@@ -7793,7 +7688,10 @@ HInstruction* HOptimizedGraphBuilder::BuildLoadNamedMonomorphic( |
map->LookupDescriptor(NULL, *name, &lookup); |
if (lookup.IsField()) { |
AddCheckMap(object, map); |
- return BuildLoadNamedField(object, map, &lookup); |
+ return new(zone()) HLoadNamedField(object, |
+ HObjectAccess::ForField(map, &lookup, name), |
+ NULL, |
+ ComputeLoadStoreRepresentation(map, &lookup)); |
} |
// Handle a load of a constant known function. |
@@ -7812,9 +7710,12 @@ HInstruction* HOptimizedGraphBuilder::BuildLoadNamedMonomorphic( |
AddCheckMap(object, map); |
AddInstruction( |
new(zone()) HCheckPrototypeMaps(prototype, holder, zone())); |
- HValue* holder_value = AddInstruction( |
- new(zone()) HConstant(holder, Representation::Tagged())); |
- return BuildLoadNamedField(holder_value, holder_map, &lookup); |
+ HValue* holder_value = AddInstruction(new(zone()) |
+ HConstant(holder, Representation::Tagged())); |
+ return new(zone()) HLoadNamedField(holder_value, |
+ HObjectAccess::ForField(holder_map, &lookup, name), |
+ NULL, |
+ ComputeLoadStoreRepresentation(map, &lookup)); |
} |
// Handle a load of a constant function somewhere in the prototype chain. |
@@ -8077,10 +7978,10 @@ HValue* HOptimizedGraphBuilder::HandlePolymorphicElementAccess( |
current_block()->Finish(typecheck); |
set_current_block(if_jsarray); |
- HInstruction* length; |
- length = AddInstruction( |
- HLoadNamedField::NewArrayLength(zone(), object, typecheck, |
- HType::Smi())); |
+ HInstruction* length = AddLoad(object, |
+ HObjectAccess::ForArrayLength(), typecheck); |
+ length->set_type(HType::Smi()); |
+ |
checked_key = AddBoundsCheck(key, length, ALLOW_SMI_KEY); |
access = AddInstruction(BuildFastElementAccess( |
elements, checked_key, val, elements_kind_branch, |
@@ -10726,7 +10627,6 @@ void HOptimizedGraphBuilder::BuildEmitDeepCopy( |
int* offset, |
AllocationSiteMode mode) { |
Zone* zone = this->zone(); |
- Factory* factory = isolate()->factory(); |
HInstruction* original_boilerplate = AddInstruction(new(zone) HConstant( |
original_boilerplate_object, Representation::Tagged())); |
@@ -10766,6 +10666,13 @@ void HOptimizedGraphBuilder::BuildEmitDeepCopy( |
Handle<Object> value = |
Handle<Object>(boilerplate_object->InObjectPropertyAt(i), |
isolate()); |
+ |
+ // The access for the store depends on the type of the boilerplate. |
+ int store_offset = boilerplate_object->GetInObjectPropertyOffset(i); |
+ HObjectAccess access = boilerplate_object->IsJSArray() ? |
+ HObjectAccess::ForJSArrayOffset(store_offset) : |
+ HObjectAccess::ForJSObjectOffset(store_offset); |
+ |
if (value->IsJSObject()) { |
Handle<JSObject> value_object = Handle<JSObject>::cast(value); |
Handle<JSObject> original_value_object = Handle<JSObject>::cast( |
@@ -10773,21 +10680,18 @@ void HOptimizedGraphBuilder::BuildEmitDeepCopy( |
isolate())); |
HInstruction* value_instruction = |
AddInstruction(new(zone) HInnerAllocatedObject(target, *offset)); |
+ |
// TODO(verwaest): choose correct storage. |
- AddInstruction(new(zone) HStoreNamedField( |
- object_properties, factory->unknown_field_string(), value_instruction, |
- true, Representation::Tagged(), |
- boilerplate_object->GetInObjectPropertyOffset(i))); |
+ AddStore(object_properties, access, value_instruction); |
+ |
BuildEmitDeepCopy(value_object, original_value_object, target, |
offset, DONT_TRACK_ALLOCATION_SITE); |
} else { |
// TODO(verwaest): choose correct storage. |
HInstruction* value_instruction = AddInstruction(new(zone) HConstant( |
value, Representation::Tagged())); |
- AddInstruction(new(zone) HStoreNamedField( |
- object_properties, factory->unknown_field_string(), value_instruction, |
- true, Representation::Tagged(), |
- boilerplate_object->GetInObjectPropertyOffset(i))); |
+ |
+ AddStore(object_properties, access, value_instruction); |
} |
} |
@@ -10859,13 +10763,12 @@ HValue* HOptimizedGraphBuilder::BuildCopyObjectHeader( |
int elements_size) { |
ASSERT(boilerplate_object->properties()->length() == 0); |
Zone* zone = this->zone(); |
- Factory* factory = isolate()->factory(); |
HValue* result = NULL; |
HValue* object_header = |
AddInstruction(new(zone) HInnerAllocatedObject(target, object_offset)); |
Handle<Map> boilerplate_object_map(boilerplate_object->map()); |
- BuildStoreMap(object_header, boilerplate_object_map); |
+ AddStoreMapConstant(object_header, boilerplate_object_map); |
HInstruction* elements; |
if (elements_size == 0) { |
@@ -10878,23 +10781,15 @@ HValue* HOptimizedGraphBuilder::BuildCopyObjectHeader( |
target, elements_offset)); |
result = elements; |
} |
- HInstruction* elements_store = AddInstruction(new(zone) HStoreNamedField( |
- object_header, |
- factory->elements_field_string(), |
- elements, |
- true, Representation::Tagged(), JSObject::kElementsOffset)); |
- elements_store->SetGVNFlag(kChangesElementsPointer); |
+ AddStore(object_header, HObjectAccess::ForElementsPointer(), elements); |
Handle<Object> properties_field = |
Handle<Object>(boilerplate_object->properties(), isolate()); |
ASSERT(*properties_field == isolate()->heap()->empty_fixed_array()); |
HInstruction* properties = AddInstruction(new(zone) HConstant( |
properties_field, Representation::None())); |
- AddInstruction(new(zone) HStoreNamedField(object_header, |
- factory->empty_string(), |
- properties, true, |
- Representation::Tagged(), |
- JSObject::kPropertiesOffset)); |
+ HObjectAccess access = HObjectAccess::ForPropertiesPointer(); |
+ AddStore(object_header, access, properties); |
if (boilerplate_object->IsJSArray()) { |
Handle<JSArray> boilerplate_array = |
@@ -10903,16 +10798,13 @@ HValue* HOptimizedGraphBuilder::BuildCopyObjectHeader( |
Handle<Object>(boilerplate_array->length(), isolate()); |
HInstruction* length = AddInstruction(new(zone) HConstant( |
length_field, Representation::None())); |
+ |
ASSERT(boilerplate_array->length()->IsSmi()); |
Representation representation = |
IsFastElementsKind(boilerplate_array->GetElementsKind()) |
? Representation::Smi() : Representation::Tagged(); |
- HInstruction* length_store = AddInstruction(new(zone) HStoreNamedField( |
- object_header, |
- factory->length_field_string(), |
- length, |
- true, representation, JSArray::kLengthOffset)); |
- length_store->SetGVNFlag(kChangesArrayLengths); |
+ AddStore(object_header, HObjectAccess::ForArrayLength(), |
+ length, representation); |
} |
return result; |
@@ -11299,13 +11191,8 @@ void HOptimizedGraphBuilder::GenerateSetValueOf(CallRuntime* call) { |
// Create in-object property store to kValueOffset. |
set_current_block(if_js_value); |
- Handle<String> name = isolate()->factory()->undefined_string(); |
- AddInstruction(new(zone()) HStoreNamedField(object, |
- name, |
- value, |
- true, // in-object store. |
- Representation::Tagged(), |
- JSValue::kValueOffset)); |
+ AddStore(object, |
+ HObjectAccess::ForJSObjectOffset(JSValue::kValueOffset), value); |
if_js_value->Goto(join); |
join->SetJoinId(call->id()); |
set_current_block(join); |