Chromium Code Reviews| Index: src/hydrogen.cc |
| diff --git a/src/hydrogen.cc b/src/hydrogen.cc |
| index d1312202bcf6b038b34bcaec75ebf3359091f0aa..004b1e9563f51fa96574f8bc04bcc1be2434dbb5 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(); |
| @@ -1282,8 +1275,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)); |
| } |
| @@ -1409,21 +1402,15 @@ 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(); |
| - 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); |
| + AddStoreMapConstant(elements, map); |
| + AddStore(elements, HObjectAccess::ForFixedArrayLength(), capacity, |
| + IsFastElementsKind(kind) |
| + ? Representation::Smi() : Representation::Tagged()); |
| } |
| @@ -1442,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( |
| @@ -1450,21 +1437,12 @@ 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::ForInobjectOffset(zone(), |
| + JSArray::kPropertiesOffset, |
| + isolate()->factory()->properties_field_symbol()); |
| + |
| + AddStore(array, access, empty_fixed_array); |
| + AddStore(array, HObjectAccess::ForArrayLength(), length_field); |
| if (mode == TRACK_ALLOCATION_SITE) { |
| BuildCreateAllocationSiteInfo(array, |
| @@ -1478,49 +1456,14 @@ 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); |
| -} |
| - |
| - |
| HValue* HGraphBuilder::BuildNewElementsCapacity(HValue* context, |
| HValue* old_capacity) { |
| Zone* zone = this->zone(); |
| @@ -1570,7 +1513,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); |
| @@ -1582,13 +1524,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; |
| } |
| @@ -1693,7 +1629,6 @@ HValue* HGraphBuilder::BuildCloneShallowArray(HContext* context, |
| ElementsKind kind, |
| int length) { |
| Zone* zone = this->zone(); |
| - Factory* factory = isolate()->factory(); |
| NoObservableSideEffectsScope no_effects(this); |
| @@ -1723,16 +1658,9 @@ 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::ForInobjectOffset(zone, i); |
| + HInstruction* value = AddLoad(boilerplate, access); |
| + AddStore(object, access, value); |
| } |
| } |
| @@ -1748,21 +1676,14 @@ HValue* HGraphBuilder::BuildCloneShallowArray(HContext* context, |
| AddInstruction(new(zone) HLoadElements(boilerplate, NULL)); |
| 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)); |
| + // TODO(titzer): AccessFixedArray? |
| + HObjectAccess* access = HObjectAccess::ForInobjectOffset(zone, i); |
| + HInstruction* value = AddLoad(boilerplate_elements, access); |
| + AddStore(object_elements, access, value); |
| } |
| // Copy the elements array contents. |
| @@ -1842,13 +1763,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::ForInobjectOffset(zone(), |
| + AllocationSiteInfo::kPayloadOffset, |
| + isolate()->factory()->payload_string()); |
| + AddStore(alloc_site, access, payload); |
| return alloc_site; |
| } |
| @@ -1872,16 +1791,18 @@ 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)); |
| + HObjectAccess* access = HObjectAccess::ForOffset(zone(), |
| + GlobalObject::kNativeContextOffset); |
| + HInstruction* native_context = builder()->AddLoad(global_object, access); |
| + |
| int offset = Context::kHeaderSize + |
| kPointerSize * Context::JS_ARRAY_MAPS_INDEX; |
| - HInstruction* map_array = AddInstruction(new(zone()) |
| - HLoadNamedField(native_context, true, Representation::Tagged(), offset)); |
| + access = HObjectAccess::ForOffset(zone(), offset); |
| + HInstruction* map_array = builder()->AddLoad(native_context, access); |
| + |
| offset = kind_ * kPointerSize + FixedArrayBase::kHeaderSize; |
| - return AddInstruction(new(zone()) HLoadNamedField( |
| - map_array, true, Representation::Tagged(), offset)); |
| + access = HObjectAccess::ForOffset(zone(), offset); |
| + return builder()->AddLoad(map_array, access); |
| } |
| @@ -1990,6 +1911,35 @@ 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); |
| + AddInstruction(instr); |
| + instr->set_field_representation(representation); |
|
danno
2013/05/06 15:53:06
Any reason you took this out of the constructor?
titzer
2013/05/07 17:51:03
Done.
|
| + return instr; |
| +} |
| + |
| + |
| +HLoadNamedField* HGraphBuilder::AddLoad(HValue *object, HObjectAccess* access, |
|
danno
2013/05/06 15:53:06
nit: Here and elsewhere, although not strictly dic
titzer
2013/05/07 17:51:03
Done.
|
| + HValue *typecheck) { |
| + HLoadNamedField *instr = new(zone()) |
|
danno
2013/05/06 15:53:06
nit: we usually would line break before the new(zo
titzer
2013/05/07 17:51:03
Done.
|
| + HLoadNamedField(object, access, typecheck); |
| + 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), |
| @@ -6282,7 +6232,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(); |
| @@ -6902,20 +6852,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()) { |
| @@ -6980,19 +6916,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(zone(), map, lookup, name); |
| + HStoreNamedField* instr = new(zone()) HStoreNamedField(object, access, value); |
| + instr->set_field_representation(ComputeLoadStoreRepresentation(map, lookup)); |
|
danno
2013/05/06 15:53:06
Any reason that you took the setting of the repres
titzer
2013/05/07 17:51:03
Done.
|
| + |
| if (lookup->IsTransitionToField(*map)) { |
| Handle<Map> transition(lookup->GetTransitionMapFromMap(*map)); |
| instr->set_transition(transition); |
| @@ -7062,9 +6989,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; |
| @@ -7088,22 +7016,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(zone(), 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; |
| } |
| @@ -7115,14 +7037,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(zone(), 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()); |
| @@ -7675,25 +7596,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, |
| @@ -7729,7 +7631,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()); |
| } |
| } |
| @@ -7737,7 +7640,11 @@ HInstruction* HOptimizedGraphBuilder::BuildLoadNamedMonomorphic( |
| map->LookupDescriptor(NULL, *name, &lookup); |
| if (lookup.IsField()) { |
| AddCheckMap(object, map); |
| - return BuildLoadNamedField(object, map, &lookup); |
| + HLoadNamedField* load = new(zone()) HLoadNamedField(object, |
| + HObjectAccess::ForField(zone(), map, &lookup, name)); |
| + load->set_field_representation( |
| + ComputeLoadStoreRepresentation(map, &lookup)); |
| + return load; |
| } |
| // Handle a load of a constant known function. |
| @@ -7754,11 +7661,15 @@ HInstruction* HOptimizedGraphBuilder::BuildLoadNamedMonomorphic( |
| Handle<JSObject> holder(lookup.holder()); |
| Handle<Map> holder_map(holder->map()); |
| 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); |
| + AddInstruction(new(zone()) |
| + HCheckPrototypeMaps(prototype, holder, zone())); |
|
danno
2013/05/06 15:53:06
nit: unnecessary whitespace change
titzer
2013/05/07 17:51:03
want: auto code formatter
|
| + HValue* holder_value = AddInstruction(new(zone()) |
| + HConstant(holder, Representation::Tagged())); |
| + HLoadNamedField* load = new(zone()) HLoadNamedField(holder_value, |
| + HObjectAccess::ForField(zone(), holder_map, &lookup, name)); |
| + load->set_field_representation( |
| + ComputeLoadStoreRepresentation(map, &lookup)); |
| + return load; |
| } |
| // Handle a load of a constant function somewhere in the prototype chain. |
| @@ -8022,10 +7933,11 @@ 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()); |
| + // TODO(titzer): length->set_field_representation(Representation::Smi()) |
| + |
| checked_key = AddBoundsCheck(key, length, ALLOW_SMI_KEY); |
| access = AddInstruction(BuildFastElementAccess( |
| elements, checked_key, val, elements_kind_branch, |
| @@ -10671,7 +10583,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())); |
| @@ -10718,21 +10629,22 @@ 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))); |
| + HObjectAccess* access = HObjectAccess::ForInobjectOffset(zone, |
| + 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))); |
| + |
| + HObjectAccess* access = HObjectAccess::ForInobjectOffset(zone, |
| + boilerplate_object->GetInObjectPropertyOffset(i)); |
| + AddStore(object_properties, access, value_instruction); |
| } |
| } |
| @@ -10804,13 +10716,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) { |
| @@ -10823,23 +10734,16 @@ 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::ForInobjectOffset(zone, |
| + JSObject::kPropertiesOffset); |
| + AddStore(object_header, access, properties); |
| if (boilerplate_object->IsJSArray()) { |
| Handle<JSArray> boilerplate_array = |
| @@ -10848,16 +10752,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; |
| @@ -11244,13 +11145,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::ForInobjectOffset( |
| + zone(), JSValue::kValueOffset), value); |
| if_js_value->Goto(join); |
| join->SetJoinId(call->id()); |
| set_current_block(join); |