Chromium Code Reviews| Index: src/hydrogen.cc |
| diff --git a/src/hydrogen.cc b/src/hydrogen.cc |
| index 58a9b78750bb7401bfdc9e167800f8f01d3ef078..d5d1cfd69aff0aa5005835b19845aca3d73034e6 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,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) |
|
danno
2013/05/08 12:05:35
Calculate this in an intermediate Representation v
titzer
2013/05/08 15:15:45
Done.
|
| + ? Representation::Smi() : Representation::Tagged()); |
| } |
| @@ -1441,7 +1428,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 +1436,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::ForOffset( |
| + 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, |
| @@ -1477,58 +1455,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 +1518,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 +1529,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 +1634,6 @@ HValue* HGraphBuilder::BuildCloneShallowArray(HContext* context, |
| ElementsKind kind, |
| int length) { |
| Zone* zone = this->zone(); |
| - Factory* factory = isolate()->factory(); |
| NoObservableSideEffectsScope no_effects(this); |
| @@ -1734,16 +1663,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::ForOffset(i); |
|
danno
2013/05/08 12:05:35
Replace this loop with a version of with a call to
titzer
2013/05/08 15:15:45
Now that I've added ForJSArrayOffset(), I actually
|
| + HInstruction* value = AddLoad(boilerplate, access); |
| + AddStore(object, access, value); |
| } |
| } |
| @@ -1758,21 +1680,14 @@ 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)); |
| + // TODO(titzer): AccessFixedArray? |
| + HObjectAccess access = HObjectAccess::ForOffset(i); |
|
danno
2013/05/08 12:05:35
Yikes, this is dangerous. The offset in a fixed ar
titzer
2013/05/08 15:15:45
I've fixed this with ForFixedArrayOffset.
|
| + HInstruction* value = AddLoad(boilerplate_elements, access); |
| + AddStore(object_elements, access, value); |
| } |
| // Copy the elements array contents. |
| @@ -1852,13 +1767,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::ForOffset( |
| + AllocationSiteInfo::kPayloadOffset, |
| + isolate()->factory()->payload_string()); |
| + AddStore(alloc_site, access, payload); |
| return alloc_site; |
| } |
| @@ -1882,16 +1795,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( |
|
danno
2013/05/08 12:05:35
This is the contents of a FixedArray, so you need
titzer
2013/05/08 15:15:45
I've replaced each of these three accesses with Fo
|
| + 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(offset); |
|
danno
2013/05/08 12:05:35
Same here, this is an access into the elements of
|
| + HInstruction* map_array = builder()->AddLoad(native_context, access); |
| + |
| offset = kind_ * kPointerSize + FixedArrayBase::kHeaderSize; |
|
danno
2013/05/08 12:05:35
Same here.
|
| - return AddInstruction(new(zone()) HLoadNamedField( |
| - map_array, true, Representation::Tagged(), offset)); |
| + access = HObjectAccess::ForOffset(offset); |
| + return builder()->AddLoad(map_array, access); |
| } |
| @@ -2000,6 +1915,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 +6289,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 +6906,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 +6970,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 +7043,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 +7070,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 +7091,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 +7650,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 +7685,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 +7694,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 +7716,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 +7984,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 +10633,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())); |
| @@ -10773,21 +10679,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::ForOffset( |
|
danno
2013/05/08 12:05:35
For(true, i)
|
| + 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::ForOffset( |
|
danno
2013/05/08 12:05:35
For(true, i), how about you more the access calcul
|
| + boilerplate_object->GetInObjectPropertyOffset(i)); |
| + AddStore(object_properties, access, value_instruction); |
| } |
| } |
| @@ -10859,13 +10766,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 +10784,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::ForOffset(JSObject::kPropertiesOffset); |
|
danno
2013/05/08 12:05:35
You should have a ForPropertiesPointer(). It shoul
|
| + AddStore(object_header, access, properties); |
| if (boilerplate_object->IsJSArray()) { |
| Handle<JSArray> boilerplate_array = |
| @@ -10903,16 +10801,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 +11194,7 @@ 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::ForOffset(JSValue::kValueOffset), value); |
|
danno
2013/05/08 12:05:35
JSValues are not necessarily JSObjects, there shou
|
| if_js_value->Goto(join); |
| join->SetJoinId(call->id()); |
| set_current_block(join); |