OLD | NEW |
1 // Copyright 2013 the V8 project authors. All rights reserved. | 1 // Copyright 2013 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "src/hydrogen.h" | 5 #include "src/hydrogen.h" |
6 | 6 |
7 #include <sstream> | 7 #include <sstream> |
8 | 8 |
9 #include "src/v8.h" | 9 #include "src/v8.h" |
10 | 10 |
(...skipping 5515 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5526 Handle<FixedArray> properties(boilerplate->properties()); | 5526 Handle<FixedArray> properties(boilerplate->properties()); |
5527 if (properties->length() > 0) { | 5527 if (properties->length() > 0) { |
5528 return false; | 5528 return false; |
5529 } else { | 5529 } else { |
5530 Handle<DescriptorArray> descriptors( | 5530 Handle<DescriptorArray> descriptors( |
5531 boilerplate->map()->instance_descriptors()); | 5531 boilerplate->map()->instance_descriptors()); |
5532 int limit = boilerplate->map()->NumberOfOwnDescriptors(); | 5532 int limit = boilerplate->map()->NumberOfOwnDescriptors(); |
5533 for (int i = 0; i < limit; i++) { | 5533 for (int i = 0; i < limit; i++) { |
5534 PropertyDetails details = descriptors->GetDetails(i); | 5534 PropertyDetails details = descriptors->GetDetails(i); |
5535 if (details.type() != FIELD) continue; | 5535 if (details.type() != FIELD) continue; |
| 5536 int index = descriptors->GetFieldIndex(i); |
5536 if ((*max_properties)-- == 0) return false; | 5537 if ((*max_properties)-- == 0) return false; |
5537 FieldIndex field_index = FieldIndex::ForDescriptor(boilerplate->map(), i); | 5538 Handle<Object> value(boilerplate->InObjectPropertyAt(index), isolate); |
5538 if (boilerplate->IsUnboxedDoubleField(field_index)) continue; | |
5539 Handle<Object> value(boilerplate->RawFastPropertyAt(field_index), | |
5540 isolate); | |
5541 if (value->IsJSObject()) { | 5539 if (value->IsJSObject()) { |
5542 Handle<JSObject> value_object = Handle<JSObject>::cast(value); | 5540 Handle<JSObject> value_object = Handle<JSObject>::cast(value); |
5543 if (!IsFastLiteral(value_object, | 5541 if (!IsFastLiteral(value_object, |
5544 max_depth - 1, | 5542 max_depth - 1, |
5545 max_properties)) { | 5543 max_properties)) { |
5546 return false; | 5544 return false; |
5547 } | 5545 } |
5548 } | 5546 } |
5549 } | 5547 } |
5550 } | 5548 } |
(...skipping 282 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5833 LookupIterator it(object, info->name(), | 5831 LookupIterator it(object, info->name(), |
5834 LookupIterator::OWN_SKIP_INTERCEPTOR); | 5832 LookupIterator::OWN_SKIP_INTERCEPTOR); |
5835 Handle<Object> value = JSObject::GetDataProperty(&it); | 5833 Handle<Object> value = JSObject::GetDataProperty(&it); |
5836 if (it.IsFound() && it.IsReadOnly() && !it.IsConfigurable()) { | 5834 if (it.IsFound() && it.IsReadOnly() && !it.IsConfigurable()) { |
5837 return New<HConstant>(value); | 5835 return New<HConstant>(value); |
5838 } | 5836 } |
5839 } | 5837 } |
5840 } | 5838 } |
5841 | 5839 |
5842 HObjectAccess access = info->access(); | 5840 HObjectAccess access = info->access(); |
5843 if (access.representation().IsDouble() && | 5841 if (access.representation().IsDouble()) { |
5844 (!FLAG_unbox_double_fields || !access.IsInobject())) { | |
5845 // Load the heap number. | 5842 // Load the heap number. |
5846 checked_object = Add<HLoadNamedField>( | 5843 checked_object = Add<HLoadNamedField>( |
5847 checked_object, static_cast<HValue*>(NULL), | 5844 checked_object, static_cast<HValue*>(NULL), |
5848 access.WithRepresentation(Representation::Tagged())); | 5845 access.WithRepresentation(Representation::Tagged())); |
5849 // Load the double value from it. | 5846 // Load the double value from it. |
5850 access = HObjectAccess::ForHeapNumberValue(); | 5847 access = HObjectAccess::ForHeapNumberValue(); |
5851 } | 5848 } |
5852 | 5849 |
5853 SmallMapList* map_list = info->field_maps(); | 5850 SmallMapList* map_list = info->field_maps(); |
5854 if (map_list->length() == 0) { | 5851 if (map_list->length() == 0) { |
(...skipping 11 matching lines...) Expand all Loading... |
5866 | 5863 |
5867 HInstruction* HOptimizedGraphBuilder::BuildStoreNamedField( | 5864 HInstruction* HOptimizedGraphBuilder::BuildStoreNamedField( |
5868 PropertyAccessInfo* info, | 5865 PropertyAccessInfo* info, |
5869 HValue* checked_object, | 5866 HValue* checked_object, |
5870 HValue* value) { | 5867 HValue* value) { |
5871 bool transition_to_field = info->IsTransition(); | 5868 bool transition_to_field = info->IsTransition(); |
5872 // TODO(verwaest): Move this logic into PropertyAccessInfo. | 5869 // TODO(verwaest): Move this logic into PropertyAccessInfo. |
5873 HObjectAccess field_access = info->access(); | 5870 HObjectAccess field_access = info->access(); |
5874 | 5871 |
5875 HStoreNamedField *instr; | 5872 HStoreNamedField *instr; |
5876 if (field_access.representation().IsDouble() && | 5873 if (field_access.representation().IsDouble()) { |
5877 (!FLAG_unbox_double_fields || !field_access.IsInobject())) { | |
5878 HObjectAccess heap_number_access = | 5874 HObjectAccess heap_number_access = |
5879 field_access.WithRepresentation(Representation::Tagged()); | 5875 field_access.WithRepresentation(Representation::Tagged()); |
5880 if (transition_to_field) { | 5876 if (transition_to_field) { |
5881 // The store requires a mutable HeapNumber to be allocated. | 5877 // The store requires a mutable HeapNumber to be allocated. |
5882 NoObservableSideEffectsScope no_side_effects(this); | 5878 NoObservableSideEffectsScope no_side_effects(this); |
5883 HInstruction* heap_number_size = Add<HConstant>(HeapNumber::kSize); | 5879 HInstruction* heap_number_size = Add<HConstant>(HeapNumber::kSize); |
5884 | 5880 |
5885 // TODO(hpayer): Allocation site pretenuring support. | 5881 // TODO(hpayer): Allocation site pretenuring support. |
5886 HInstruction* heap_number = Add<HAllocate>(heap_number_size, | 5882 HInstruction* heap_number = Add<HAllocate>(heap_number_size, |
5887 HType::HeapObject(), | 5883 HType::HeapObject(), |
(...skipping 5295 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
11183 PretenureFlag pretenure_flag) { | 11179 PretenureFlag pretenure_flag) { |
11184 Handle<Map> boilerplate_map(boilerplate_object->map()); | 11180 Handle<Map> boilerplate_map(boilerplate_object->map()); |
11185 Handle<DescriptorArray> descriptors(boilerplate_map->instance_descriptors()); | 11181 Handle<DescriptorArray> descriptors(boilerplate_map->instance_descriptors()); |
11186 int limit = boilerplate_map->NumberOfOwnDescriptors(); | 11182 int limit = boilerplate_map->NumberOfOwnDescriptors(); |
11187 | 11183 |
11188 int copied_fields = 0; | 11184 int copied_fields = 0; |
11189 for (int i = 0; i < limit; i++) { | 11185 for (int i = 0; i < limit; i++) { |
11190 PropertyDetails details = descriptors->GetDetails(i); | 11186 PropertyDetails details = descriptors->GetDetails(i); |
11191 if (details.type() != FIELD) continue; | 11187 if (details.type() != FIELD) continue; |
11192 copied_fields++; | 11188 copied_fields++; |
11193 FieldIndex field_index = FieldIndex::ForDescriptor(*boilerplate_map, i); | 11189 int index = descriptors->GetFieldIndex(i); |
11194 | 11190 int property_offset = boilerplate_object->GetInObjectPropertyOffset(index); |
11195 | |
11196 int property_offset = field_index.offset(); | |
11197 Handle<Name> name(descriptors->GetKey(i)); | 11191 Handle<Name> name(descriptors->GetKey(i)); |
| 11192 Handle<Object> value = |
| 11193 Handle<Object>(boilerplate_object->InObjectPropertyAt(index), |
| 11194 isolate()); |
11198 | 11195 |
11199 // The access for the store depends on the type of the boilerplate. | 11196 // The access for the store depends on the type of the boilerplate. |
11200 HObjectAccess access = boilerplate_object->IsJSArray() ? | 11197 HObjectAccess access = boilerplate_object->IsJSArray() ? |
11201 HObjectAccess::ForJSArrayOffset(property_offset) : | 11198 HObjectAccess::ForJSArrayOffset(property_offset) : |
11202 HObjectAccess::ForMapAndOffset(boilerplate_map, property_offset); | 11199 HObjectAccess::ForMapAndOffset(boilerplate_map, property_offset); |
11203 | 11200 |
11204 if (boilerplate_object->IsUnboxedDoubleField(field_index)) { | |
11205 CHECK(!boilerplate_object->IsJSArray()); | |
11206 double value = boilerplate_object->RawFastDoublePropertyAt(field_index); | |
11207 access = access.WithRepresentation(Representation::Double()); | |
11208 Add<HStoreNamedField>(object, access, Add<HConstant>(value)); | |
11209 continue; | |
11210 } | |
11211 Handle<Object> value(boilerplate_object->RawFastPropertyAt(field_index), | |
11212 isolate()); | |
11213 | |
11214 if (value->IsJSObject()) { | 11201 if (value->IsJSObject()) { |
11215 Handle<JSObject> value_object = Handle<JSObject>::cast(value); | 11202 Handle<JSObject> value_object = Handle<JSObject>::cast(value); |
11216 Handle<AllocationSite> current_site = site_context->EnterNewScope(); | 11203 Handle<AllocationSite> current_site = site_context->EnterNewScope(); |
11217 HInstruction* result = | 11204 HInstruction* result = |
11218 BuildFastLiteral(value_object, site_context); | 11205 BuildFastLiteral(value_object, site_context); |
11219 site_context->ExitScope(current_site, value_object); | 11206 site_context->ExitScope(current_site, value_object); |
11220 Add<HStoreNamedField>(object, access, result); | 11207 Add<HStoreNamedField>(object, access, result); |
11221 } else { | 11208 } else { |
11222 Representation representation = details.representation(); | 11209 Representation representation = details.representation(); |
11223 HInstruction* value_instruction; | 11210 HInstruction* value_instruction; |
(...skipping 1461 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
12685 if (ShouldProduceTraceOutput()) { | 12672 if (ShouldProduceTraceOutput()) { |
12686 isolate()->GetHTracer()->TraceHydrogen(name(), graph_); | 12673 isolate()->GetHTracer()->TraceHydrogen(name(), graph_); |
12687 } | 12674 } |
12688 | 12675 |
12689 #ifdef DEBUG | 12676 #ifdef DEBUG |
12690 graph_->Verify(false); // No full verify. | 12677 graph_->Verify(false); // No full verify. |
12691 #endif | 12678 #endif |
12692 } | 12679 } |
12693 | 12680 |
12694 } } // namespace v8::internal | 12681 } } // namespace v8::internal |
OLD | NEW |