OLD | NEW |
---|---|
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 1599 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1610 if (!pre_fill_with_holes && length != capacity) { | 1610 if (!pre_fill_with_holes && length != capacity) { |
1611 // Fill unused capacity with the hole. | 1611 // Fill unused capacity with the hole. |
1612 BuildFillElementsWithHole(context, to_elements, to_elements_kind, | 1612 BuildFillElementsWithHole(context, to_elements, to_elements_kind, |
1613 key, capacity); | 1613 key, capacity); |
1614 } | 1614 } |
1615 } | 1615 } |
1616 | 1616 |
1617 | 1617 |
1618 HValue* HGraphBuilder::BuildCloneShallowArray(HContext* context, | 1618 HValue* HGraphBuilder::BuildCloneShallowArray(HContext* context, |
1619 HValue* boilerplate, | 1619 HValue* boilerplate, |
1620 HValue* allocation_site, | |
1620 AllocationSiteMode mode, | 1621 AllocationSiteMode mode, |
1621 ElementsKind kind, | 1622 ElementsKind kind, |
1622 int length) { | 1623 int length) { |
1623 Zone* zone = this->zone(); | 1624 Zone* zone = this->zone(); |
1624 | 1625 |
1625 NoObservableSideEffectsScope no_effects(this); | 1626 NoObservableSideEffectsScope no_effects(this); |
1626 | 1627 |
1627 // All sizes here are multiples of kPointerSize. | 1628 // All sizes here are multiples of kPointerSize. |
1628 int size = JSArray::kSize; | 1629 int size = JSArray::kSize; |
1629 if (mode == TRACK_ALLOCATION_SITE) { | 1630 if (mode == TRACK_ALLOCATION_SITE) { |
(...skipping 16 matching lines...) Expand all Loading... | |
1646 size_in_bytes, | 1647 size_in_bytes, |
1647 HType::JSObject(), | 1648 HType::JSObject(), |
1648 allocate_flags)); | 1649 allocate_flags)); |
1649 | 1650 |
1650 // Copy the JS array part. | 1651 // Copy the JS array part. |
1651 for (int i = 0; i < JSArray::kSize; i += kPointerSize) { | 1652 for (int i = 0; i < JSArray::kSize; i += kPointerSize) { |
1652 if ((i != JSArray::kElementsOffset) || (length == 0)) { | 1653 if ((i != JSArray::kElementsOffset) || (length == 0)) { |
1653 HObjectAccess access = HObjectAccess::ForJSArrayOffset(i); | 1654 HObjectAccess access = HObjectAccess::ForJSArrayOffset(i); |
1654 AddStore(object, access, AddLoad(boilerplate, access)); | 1655 AddStore(object, access, AddLoad(boilerplate, access)); |
1655 } | 1656 } |
1656 } | 1657 } |
Hannes Payer (out of office)
2013/06/25 16:35:07
ASSERT if boilerplate and allocation_site->boilerp
| |
1657 | 1658 |
1658 // Create an allocation site info if requested. | 1659 // Create an allocation site info if requested. |
1659 if (mode == TRACK_ALLOCATION_SITE) { | 1660 if (mode == TRACK_ALLOCATION_SITE) { |
1660 BuildCreateAllocationSiteInfo(object, JSArray::kSize, boilerplate); | 1661 BuildCreateAllocationSiteInfo(object, JSArray::kSize, allocation_site); |
1661 } | 1662 } |
1662 | 1663 |
1663 if (length > 0) { | 1664 if (length > 0) { |
1664 // Get hold of the elements array of the boilerplate and setup the | 1665 // Get hold of the elements array of the boilerplate and setup the |
1665 // elements pointer in the resulting object. | 1666 // elements pointer in the resulting object. |
1666 HValue* boilerplate_elements = AddLoadElements(boilerplate); | 1667 HValue* boilerplate_elements = AddLoadElements(boilerplate); |
1667 HValue* object_elements = | 1668 HValue* object_elements = |
1668 AddInstruction(new(zone) HInnerAllocatedObject(object, elems_offset)); | 1669 AddInstruction(new(zone) HInnerAllocatedObject(object, elems_offset)); |
1669 AddStore(object, HObjectAccess::ForElementsPointer(), object_elements); | 1670 AddStore(object, HObjectAccess::ForElementsPointer(), object_elements); |
1670 | 1671 |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1738 } | 1739 } |
1739 } | 1740 } |
1740 } | 1741 } |
1741 | 1742 |
1742 if_nil.CaptureContinuation(continuation); | 1743 if_nil.CaptureContinuation(continuation); |
1743 } | 1744 } |
1744 | 1745 |
1745 | 1746 |
1746 HValue* HGraphBuilder::BuildCreateAllocationSiteInfo(HValue* previous_object, | 1747 HValue* HGraphBuilder::BuildCreateAllocationSiteInfo(HValue* previous_object, |
1747 int previous_object_size, | 1748 int previous_object_size, |
1748 HValue* payload) { | 1749 HValue* alloc_site) { |
1749 HInnerAllocatedObject* alloc_site = new(zone()) | 1750 HInnerAllocatedObject* alloc_site_info = new(zone()) |
1750 HInnerAllocatedObject(previous_object, previous_object_size); | 1751 HInnerAllocatedObject(previous_object, previous_object_size); |
1751 AddInstruction(alloc_site); | 1752 AddInstruction(alloc_site_info); |
1752 Handle<Map> alloc_site_map(isolate()->heap()->allocation_site_info_map()); | 1753 Handle<Map> alloc_site_info_map( |
1753 AddStoreMapConstant(alloc_site, alloc_site_map); | 1754 isolate()->heap()->allocation_site_info_map()); |
1754 HObjectAccess access = HObjectAccess::ForAllocationSitePayload(); | 1755 AddStoreMapConstant(alloc_site_info, alloc_site_info_map); |
1755 AddStore(alloc_site, access, payload); | 1756 HObjectAccess access = HObjectAccess::ForAllocationSiteInfoPayload(); |
1756 return alloc_site; | 1757 AddStore(alloc_site_info, access, alloc_site); |
1758 return alloc_site_info; | |
1757 } | 1759 } |
1758 | 1760 |
1759 | 1761 |
1760 HInstruction* HGraphBuilder::BuildGetNativeContext(HValue* context) { | 1762 HInstruction* HGraphBuilder::BuildGetNativeContext(HValue* context) { |
1761 // Get the global context, then the native context | 1763 // Get the global context, then the native context |
1762 HInstruction* global_object = AddInstruction(new(zone()) | 1764 HInstruction* global_object = AddInstruction(new(zone()) |
1763 HGlobalObject(context)); | 1765 HGlobalObject(context)); |
1764 HObjectAccess access = HObjectAccess::ForJSObjectOffset( | 1766 HObjectAccess access = HObjectAccess::ForJSObjectOffset( |
1765 GlobalObject::kNativeContextOffset); | 1767 GlobalObject::kNativeContextOffset); |
1766 return AddLoad(global_object, access); | 1768 return AddLoad(global_object, access); |
(...skipping 13 matching lines...) Expand all Loading... | |
1780 HGraphBuilder::JSArrayBuilder::JSArrayBuilder(HGraphBuilder* builder, | 1782 HGraphBuilder::JSArrayBuilder::JSArrayBuilder(HGraphBuilder* builder, |
1781 ElementsKind kind, | 1783 ElementsKind kind, |
1782 HValue* allocation_site_payload, | 1784 HValue* allocation_site_payload, |
1783 bool disable_allocation_sites) : | 1785 bool disable_allocation_sites) : |
1784 builder_(builder), | 1786 builder_(builder), |
1785 kind_(kind), | 1787 kind_(kind), |
1786 allocation_site_payload_(allocation_site_payload), | 1788 allocation_site_payload_(allocation_site_payload), |
1787 constructor_function_(NULL) { | 1789 constructor_function_(NULL) { |
1788 mode_ = disable_allocation_sites | 1790 mode_ = disable_allocation_sites |
1789 ? DONT_TRACK_ALLOCATION_SITE | 1791 ? DONT_TRACK_ALLOCATION_SITE |
1790 : AllocationSiteInfo::GetMode(kind); | 1792 : AllocationSite::GetMode(kind); |
1791 } | 1793 } |
1792 | 1794 |
1793 | 1795 |
1794 HGraphBuilder::JSArrayBuilder::JSArrayBuilder(HGraphBuilder* builder, | 1796 HGraphBuilder::JSArrayBuilder::JSArrayBuilder(HGraphBuilder* builder, |
1795 ElementsKind kind, | 1797 ElementsKind kind, |
1796 HValue* constructor_function) : | 1798 HValue* constructor_function) : |
1797 builder_(builder), | 1799 builder_(builder), |
1798 kind_(kind), | 1800 kind_(kind), |
1799 mode_(DONT_TRACK_ALLOCATION_SITE), | 1801 mode_(DONT_TRACK_ALLOCATION_SITE), |
1800 allocation_site_payload_(NULL), | 1802 allocation_site_payload_(NULL), |
(...skipping 4072 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
5873 if (original_boilerplate->IsJSObject() && | 5875 if (original_boilerplate->IsJSObject() && |
5874 IsFastLiteral(Handle<JSObject>::cast(original_boilerplate), | 5876 IsFastLiteral(Handle<JSObject>::cast(original_boilerplate), |
5875 kMaxFastLiteralDepth, | 5877 kMaxFastLiteralDepth, |
5876 &max_properties, | 5878 &max_properties, |
5877 &data_size, | 5879 &data_size, |
5878 &pointer_size)) { | 5880 &pointer_size)) { |
5879 Handle<JSObject> original_boilerplate_object = | 5881 Handle<JSObject> original_boilerplate_object = |
5880 Handle<JSObject>::cast(original_boilerplate); | 5882 Handle<JSObject>::cast(original_boilerplate); |
5881 Handle<JSObject> boilerplate_object = | 5883 Handle<JSObject> boilerplate_object = |
5882 DeepCopy(original_boilerplate_object); | 5884 DeepCopy(original_boilerplate_object); |
5883 | 5885 Handle<FixedArray> literals(closure->literals(), isolate()); |
Hannes Payer (out of office)
2013/06/25 16:35:07
Literals can be removed.
mvstanton
2013/07/02 13:55:11
Done.
| |
5884 literal = BuildFastLiteral(context, | 5886 literal = BuildFastLiteral(context, |
5885 boilerplate_object, | 5887 boilerplate_object, |
5886 original_boilerplate_object, | 5888 original_boilerplate_object, |
5889 Handle<Object>::null(), | |
5887 data_size, | 5890 data_size, |
5888 pointer_size, | 5891 pointer_size, |
5889 DONT_TRACK_ALLOCATION_SITE); | 5892 DONT_TRACK_ALLOCATION_SITE); |
5890 } else { | 5893 } else { |
5891 NoObservableSideEffectsScope no_effects(this); | 5894 NoObservableSideEffectsScope no_effects(this); |
5892 Handle<FixedArray> closure_literals(closure->literals(), isolate()); | 5895 Handle<FixedArray> closure_literals(closure->literals(), isolate()); |
5893 Handle<FixedArray> constant_properties = expr->constant_properties(); | 5896 Handle<FixedArray> constant_properties = expr->constant_properties(); |
5894 int literal_index = expr->literal_index(); | 5897 int literal_index = expr->literal_index(); |
5895 int flags = expr->fast_elements() | 5898 int flags = expr->fast_elements() |
5896 ? ObjectLiteral::kFastElements : ObjectLiteral::kNoFlags; | 5899 ? ObjectLiteral::kFastElements : ObjectLiteral::kNoFlags; |
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
5990 | 5993 |
5991 void HOptimizedGraphBuilder::VisitArrayLiteral(ArrayLiteral* expr) { | 5994 void HOptimizedGraphBuilder::VisitArrayLiteral(ArrayLiteral* expr) { |
5992 ASSERT(!HasStackOverflow()); | 5995 ASSERT(!HasStackOverflow()); |
5993 ASSERT(current_block() != NULL); | 5996 ASSERT(current_block() != NULL); |
5994 ASSERT(current_block()->HasPredecessor()); | 5997 ASSERT(current_block()->HasPredecessor()); |
5995 ZoneList<Expression*>* subexprs = expr->values(); | 5998 ZoneList<Expression*>* subexprs = expr->values(); |
5996 int length = subexprs->length(); | 5999 int length = subexprs->length(); |
5997 HValue* context = environment()->LookupContext(); | 6000 HValue* context = environment()->LookupContext(); |
5998 HInstruction* literal; | 6001 HInstruction* literal; |
5999 | 6002 |
6003 Handle<AllocationSite> site; | |
6000 Handle<FixedArray> literals(environment()->closure()->literals(), isolate()); | 6004 Handle<FixedArray> literals(environment()->closure()->literals(), isolate()); |
6001 Handle<Object> raw_boilerplate(literals->get(expr->literal_index()), | 6005 Handle<Object> literals_cell(literals->get(expr->literal_index()), |
6002 isolate()); | 6006 isolate()); |
6003 | 6007 Handle<Object> raw_boilerplate; |
6004 if (raw_boilerplate->IsUndefined()) { | 6008 if (literals_cell->IsUndefined()) { |
6005 raw_boilerplate = Runtime::CreateArrayLiteralBoilerplate( | 6009 raw_boilerplate = Runtime::CreateArrayLiteralBoilerplate( |
6006 isolate(), literals, expr->constant_elements()); | 6010 isolate(), literals, expr->constant_elements()); |
6007 if (raw_boilerplate.is_null()) { | 6011 if (raw_boilerplate.is_null()) { |
6008 return Bailout("array boilerplate creation failed"); | 6012 return Bailout("array boilerplate creation failed"); |
6009 } | 6013 } |
6010 literals->set(expr->literal_index(), *raw_boilerplate); | 6014 |
6015 site = isolate()->factory()->NewAllocationSite(); | |
6016 | |
6017 // We'll want to copy any useful information (statistics?) in the | |
6018 // AllocationSite from the full code gen | |
Hannes Payer (out of office)
2013/06/25 16:35:07
why can't you reuse the allocation site generated
mvstanton
2013/07/02 13:55:11
The reason is that we don't create the AllocationS
| |
6019 /* | |
6020 Handle<FixedArray> fullcode_literals(info()->closure()->literals(), isolate( )); | |
6021 Handle<Object> fullcode_literals_cell(fullcode_literals->get(expr->literal_i ndex()), | |
6022 isolate()); | |
6023 if (!fullcode_literals_cell->IsUndefined()) { | |
6024 Handle<AllocationSite> old_site = Handle<AllocationSite>::cast(fullcode_li terals_cell); | |
6025 // Extract info... | |
6026 } | |
6027 */ | |
6028 | |
6029 site->set_payload(*raw_boilerplate); | |
6030 literals->set(expr->literal_index(), *site); | |
6031 | |
6011 if (JSObject::cast(*raw_boilerplate)->elements()->map() == | 6032 if (JSObject::cast(*raw_boilerplate)->elements()->map() == |
6012 isolate()->heap()->fixed_cow_array_map()) { | 6033 isolate()->heap()->fixed_cow_array_map()) { |
6013 isolate()->counters()->cow_arrays_created_runtime()->Increment(); | 6034 isolate()->counters()->cow_arrays_created_runtime()->Increment(); |
6014 } | 6035 } |
6036 } else { | |
6037 ASSERT(literals_cell->IsAllocationSite()); | |
6038 site = Handle<AllocationSite>::cast(literals_cell); | |
6039 raw_boilerplate = Handle<Object>(site->payload(), isolate()); | |
6015 } | 6040 } |
6016 | 6041 |
6042 ASSERT(!raw_boilerplate.is_null()); | |
6043 ASSERT(site->IsLiteralSite()); | |
6044 | |
6017 Handle<JSObject> original_boilerplate_object = | 6045 Handle<JSObject> original_boilerplate_object = |
6018 Handle<JSObject>::cast(raw_boilerplate); | 6046 Handle<JSObject>::cast(raw_boilerplate); |
6019 ElementsKind boilerplate_elements_kind = | 6047 ElementsKind boilerplate_elements_kind = |
6020 Handle<JSObject>::cast(original_boilerplate_object)->GetElementsKind(); | 6048 Handle<JSObject>::cast(original_boilerplate_object)->GetElementsKind(); |
6021 | 6049 |
6022 // TODO(mvstanton): This heuristic is only a temporary solution. In the | 6050 // TODO(mvstanton): This heuristic is only a temporary solution. In the |
6023 // end, we want to quit creating allocation site info after a certain number | 6051 // end, we want to quit creating allocation site info after a certain number |
6024 // of GCs for a call site. | 6052 // of GCs for a call site. |
6025 AllocationSiteMode mode = AllocationSiteInfo::GetMode( | 6053 AllocationSiteMode mode = AllocationSite::GetMode( |
6026 boilerplate_elements_kind); | 6054 boilerplate_elements_kind); |
6027 | 6055 |
6028 // Check whether to use fast or slow deep-copying for boilerplate. | 6056 // Check whether to use fast or slow deep-copying for boilerplate. |
6029 int data_size = 0; | 6057 int data_size = 0; |
6030 int pointer_size = 0; | 6058 int pointer_size = 0; |
6031 int max_properties = kMaxFastLiteralProperties; | 6059 int max_properties = kMaxFastLiteralProperties; |
6032 if (IsFastLiteral(original_boilerplate_object, | 6060 if (IsFastLiteral(original_boilerplate_object, |
6033 kMaxFastLiteralDepth, | 6061 kMaxFastLiteralDepth, |
6034 &max_properties, | 6062 &max_properties, |
6035 &data_size, | 6063 &data_size, |
6036 &pointer_size)) { | 6064 &pointer_size)) { |
6037 if (mode == TRACK_ALLOCATION_SITE) { | 6065 if (mode == TRACK_ALLOCATION_SITE) { |
6038 pointer_size += AllocationSiteInfo::kSize; | 6066 pointer_size += AllocationSiteInfo::kSize; |
6039 } | 6067 } |
6040 | 6068 |
6041 Handle<JSObject> boilerplate_object = DeepCopy(original_boilerplate_object); | 6069 Handle<JSObject> boilerplate_object = DeepCopy(original_boilerplate_object); |
6042 literal = BuildFastLiteral(context, | 6070 literal = BuildFastLiteral(context, |
6043 boilerplate_object, | 6071 boilerplate_object, |
6044 original_boilerplate_object, | 6072 original_boilerplate_object, |
6073 site, | |
6045 data_size, | 6074 data_size, |
6046 pointer_size, | 6075 pointer_size, |
6047 mode); | 6076 mode); |
6048 } else { | 6077 } else { |
6049 NoObservableSideEffectsScope no_effects(this); | 6078 NoObservableSideEffectsScope no_effects(this); |
6050 // Boilerplate already exists and constant elements are never accessed, | 6079 // Boilerplate already exists and constant elements are never accessed, |
6051 // pass an empty fixed array to the runtime function instead. | 6080 // pass an empty fixed array to the runtime function instead. |
6052 Handle<FixedArray> constants = isolate()->factory()->empty_fixed_array(); | 6081 Handle<FixedArray> constants = isolate()->factory()->empty_fixed_array(); |
6053 int literal_index = expr->literal_index(); | 6082 int literal_index = expr->literal_index(); |
6054 | 6083 |
(...skipping 3892 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
9947 } else { | 9976 } else { |
9948 return new(zone()) HThisFunction; | 9977 return new(zone()) HThisFunction; |
9949 } | 9978 } |
9950 } | 9979 } |
9951 | 9980 |
9952 | 9981 |
9953 HInstruction* HOptimizedGraphBuilder::BuildFastLiteral( | 9982 HInstruction* HOptimizedGraphBuilder::BuildFastLiteral( |
9954 HValue* context, | 9983 HValue* context, |
9955 Handle<JSObject> boilerplate_object, | 9984 Handle<JSObject> boilerplate_object, |
9956 Handle<JSObject> original_boilerplate_object, | 9985 Handle<JSObject> original_boilerplate_object, |
9986 Handle<Object> allocation_site, | |
9957 int data_size, | 9987 int data_size, |
9958 int pointer_size, | 9988 int pointer_size, |
9959 AllocationSiteMode mode) { | 9989 AllocationSiteMode mode) { |
9960 Zone* zone = this->zone(); | 9990 Zone* zone = this->zone(); |
9961 int total_size = data_size + pointer_size; | 9991 int total_size = data_size + pointer_size; |
9962 | 9992 |
9963 NoObservableSideEffectsScope no_effects(this); | 9993 NoObservableSideEffectsScope no_effects(this); |
9964 | 9994 |
9965 HAllocate::Flags flags = HAllocate::CAN_ALLOCATE_IN_NEW_SPACE; | 9995 HAllocate::Flags flags = HAllocate::CAN_ALLOCATE_IN_NEW_SPACE; |
9966 // TODO(hpayer): add support for old data space | 9996 // TODO(hpayer): add support for old data space |
9967 if (isolate()->heap()->ShouldGloballyPretenure() && | 9997 if (isolate()->heap()->ShouldGloballyPretenure() && |
9968 data_size == 0) { | 9998 data_size == 0) { |
9969 flags = static_cast<HAllocate::Flags>( | 9999 flags = static_cast<HAllocate::Flags>( |
9970 flags | HAllocate::CAN_ALLOCATE_IN_OLD_POINTER_SPACE); | 10000 flags | HAllocate::CAN_ALLOCATE_IN_OLD_POINTER_SPACE); |
9971 } | 10001 } |
9972 | 10002 |
9973 HValue* size_in_bytes = | 10003 HValue* size_in_bytes = |
9974 AddInstruction(new(zone) HConstant(total_size, | 10004 AddInstruction(new(zone) HConstant(total_size, |
9975 Representation::Integer32())); | 10005 Representation::Integer32())); |
9976 HInstruction* result = | 10006 HInstruction* result = |
9977 AddInstruction(new(zone) HAllocate(context, | 10007 AddInstruction(new(zone) HAllocate(context, |
9978 size_in_bytes, | 10008 size_in_bytes, |
9979 HType::JSObject(), | 10009 HType::JSObject(), |
9980 flags)); | 10010 flags)); |
9981 int offset = 0; | 10011 int offset = 0; |
9982 BuildEmitDeepCopy(boilerplate_object, original_boilerplate_object, result, | 10012 BuildEmitDeepCopy(boilerplate_object, original_boilerplate_object, |
9983 &offset, mode); | 10013 allocation_site, result, &offset, mode); |
9984 return result; | 10014 return result; |
9985 } | 10015 } |
9986 | 10016 |
9987 | 10017 |
9988 void HOptimizedGraphBuilder::BuildEmitDeepCopy( | 10018 void HOptimizedGraphBuilder::BuildEmitDeepCopy( |
9989 Handle<JSObject> boilerplate_object, | 10019 Handle<JSObject> boilerplate_object, |
9990 Handle<JSObject> original_boilerplate_object, | 10020 Handle<JSObject> original_boilerplate_object, |
10021 Handle<Object> allocation_site_object, | |
9991 HInstruction* target, | 10022 HInstruction* target, |
9992 int* offset, | 10023 int* offset, |
9993 AllocationSiteMode mode) { | 10024 AllocationSiteMode mode) { |
9994 Zone* zone = this->zone(); | 10025 Zone* zone = this->zone(); |
9995 | 10026 |
10027 bool create_allocation_site_info = mode == TRACK_ALLOCATION_SITE && | |
10028 boilerplate_object->map()->CanTrackAllocationSite(); | |
10029 | |
10030 // If using allocation sites, then the payload on the site should already | |
10031 // be filled in as a valid (boilerplate) array. | |
10032 ASSERT(!create_allocation_site_info || | |
10033 AllocationSite::cast(*allocation_site_object)->IsLiteralSite()); | |
10034 | |
10035 HInstruction* allocation_site = NULL; | |
10036 | |
10037 if (create_allocation_site_info) { | |
10038 allocation_site = AddInstruction(new(zone) HConstant( | |
10039 allocation_site_object, Representation::Tagged())); | |
10040 } | |
10041 | |
10042 // Only elements backing stores for non-COW arrays need to be copied. | |
9996 Handle<FixedArrayBase> elements(boilerplate_object->elements()); | 10043 Handle<FixedArrayBase> elements(boilerplate_object->elements()); |
9997 Handle<FixedArrayBase> original_elements( | 10044 Handle<FixedArrayBase> original_elements( |
9998 original_boilerplate_object->elements()); | 10045 original_boilerplate_object->elements()); |
9999 ElementsKind kind = boilerplate_object->map()->elements_kind(); | 10046 ElementsKind kind = boilerplate_object->map()->elements_kind(); |
10000 | 10047 |
10001 // Increase the offset so that subsequent objects end up right after | 10048 // Increase the offset so that subsequent objects end up right after |
10002 // this object and its backing store. | 10049 // this object and its backing store. |
10003 int object_offset = *offset; | 10050 int object_offset = *offset; |
10004 int object_size = boilerplate_object->map()->instance_size(); | 10051 int object_size = boilerplate_object->map()->instance_size(); |
10005 int elements_size = (elements->length() > 0 && | 10052 int elements_size = (elements->length() > 0 && |
(...skipping 15 matching lines...) Expand all Loading... | |
10021 HValue* object_properties = | 10068 HValue* object_properties = |
10022 AddInstruction(new(zone) HInnerAllocatedObject(target, object_offset)); | 10069 AddInstruction(new(zone) HInnerAllocatedObject(target, object_offset)); |
10023 BuildEmitInObjectProperties(boilerplate_object, original_boilerplate_object, | 10070 BuildEmitInObjectProperties(boilerplate_object, original_boilerplate_object, |
10024 object_properties, target, offset); | 10071 object_properties, target, offset); |
10025 | 10072 |
10026 // Create allocation site info. | 10073 // Create allocation site info. |
10027 if (mode == TRACK_ALLOCATION_SITE && | 10074 if (mode == TRACK_ALLOCATION_SITE && |
10028 boilerplate_object->map()->CanTrackAllocationSite()) { | 10075 boilerplate_object->map()->CanTrackAllocationSite()) { |
10029 elements_offset += AllocationSiteInfo::kSize; | 10076 elements_offset += AllocationSiteInfo::kSize; |
10030 *offset += AllocationSiteInfo::kSize; | 10077 *offset += AllocationSiteInfo::kSize; |
10031 HInstruction* original_boilerplate = AddInstruction(new(zone) HConstant( | 10078 BuildCreateAllocationSiteInfo(target, JSArray::kSize, allocation_site); |
10032 original_boilerplate_object, Representation::Tagged())); | |
10033 BuildCreateAllocationSiteInfo(target, JSArray::kSize, original_boilerplate); | |
10034 } | 10079 } |
10035 } | 10080 } |
10036 | 10081 |
10037 | 10082 |
10038 HValue* HOptimizedGraphBuilder::BuildEmitObjectHeader( | 10083 HValue* HOptimizedGraphBuilder::BuildEmitObjectHeader( |
10039 Handle<JSObject> boilerplate_object, | 10084 Handle<JSObject> boilerplate_object, |
10040 HInstruction* target, | 10085 HInstruction* target, |
10041 int object_offset, | 10086 int object_offset, |
10042 int elements_offset, | 10087 int elements_offset, |
10043 int elements_size) { | 10088 int elements_size) { |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
10119 HObjectAccess::ForJSArrayOffset(property_offset) : | 10164 HObjectAccess::ForJSArrayOffset(property_offset) : |
10120 HObjectAccess::ForJSObjectOffset(property_offset); | 10165 HObjectAccess::ForJSObjectOffset(property_offset); |
10121 | 10166 |
10122 if (value->IsJSObject()) { | 10167 if (value->IsJSObject()) { |
10123 Handle<JSObject> value_object = Handle<JSObject>::cast(value); | 10168 Handle<JSObject> value_object = Handle<JSObject>::cast(value); |
10124 Handle<JSObject> original_value_object = Handle<JSObject>::cast( | 10169 Handle<JSObject> original_value_object = Handle<JSObject>::cast( |
10125 Handle<Object>(original_boilerplate_object->InObjectPropertyAt(index), | 10170 Handle<Object>(original_boilerplate_object->InObjectPropertyAt(index), |
10126 isolate())); | 10171 isolate())); |
10127 HInstruction* value_instruction = | 10172 HInstruction* value_instruction = |
10128 AddInstruction(new(zone) HInnerAllocatedObject(target, *offset)); | 10173 AddInstruction(new(zone) HInnerAllocatedObject(target, *offset)); |
10129 | |
10130 AddStore(object_properties, access, value_instruction); | 10174 AddStore(object_properties, access, value_instruction); |
10131 | 10175 BuildEmitDeepCopy(value_object, original_value_object, |
10132 BuildEmitDeepCopy(value_object, original_value_object, target, | 10176 Handle<Object>::null(), target, offset, |
10133 offset, DONT_TRACK_ALLOCATION_SITE); | 10177 DONT_TRACK_ALLOCATION_SITE); |
10134 } else { | 10178 } else { |
10135 Representation representation = details.representation(); | 10179 Representation representation = details.representation(); |
10136 HInstruction* value_instruction = AddInstruction(new(zone) HConstant( | 10180 HInstruction* value_instruction = AddInstruction(new(zone) HConstant( |
10137 value, Representation::Tagged())); | 10181 value, Representation::Tagged())); |
10138 | 10182 |
10139 if (representation.IsDouble()) { | 10183 if (representation.IsDouble()) { |
10140 // Allocate a HeapNumber box and store the value into it. | 10184 // Allocate a HeapNumber box and store the value into it. |
10141 HInstruction* double_box = | 10185 HInstruction* double_box = |
10142 AddInstruction(new(zone) HInnerAllocatedObject(target, *offset)); | 10186 AddInstruction(new(zone) HInnerAllocatedObject(target, *offset)); |
10143 AddStoreMapConstant(double_box, | 10187 AddStoreMapConstant(double_box, |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
10230 Handle<Object> value(fast_elements->get(i), isolate()); | 10274 Handle<Object> value(fast_elements->get(i), isolate()); |
10231 HValue* key_constant = AddInstruction(new(zone) HConstant(i)); | 10275 HValue* key_constant = AddInstruction(new(zone) HConstant(i)); |
10232 if (value->IsJSObject()) { | 10276 if (value->IsJSObject()) { |
10233 Handle<JSObject> value_object = Handle<JSObject>::cast(value); | 10277 Handle<JSObject> value_object = Handle<JSObject>::cast(value); |
10234 Handle<JSObject> original_value_object = Handle<JSObject>::cast( | 10278 Handle<JSObject> original_value_object = Handle<JSObject>::cast( |
10235 Handle<Object>(original_fast_elements->get(i), isolate())); | 10279 Handle<Object>(original_fast_elements->get(i), isolate())); |
10236 HInstruction* value_instruction = | 10280 HInstruction* value_instruction = |
10237 AddInstruction(new(zone) HInnerAllocatedObject(target, *offset)); | 10281 AddInstruction(new(zone) HInnerAllocatedObject(target, *offset)); |
10238 AddInstruction(new(zone) HStoreKeyed( | 10282 AddInstruction(new(zone) HStoreKeyed( |
10239 object_elements, key_constant, value_instruction, kind)); | 10283 object_elements, key_constant, value_instruction, kind)); |
10240 BuildEmitDeepCopy(value_object, original_value_object, target, | 10284 BuildEmitDeepCopy(value_object, original_value_object, |
10241 offset, DONT_TRACK_ALLOCATION_SITE); | 10285 Handle<Object>::null(), target, |
10286 offset, DONT_TRACK_ALLOCATION_SITE); | |
10242 } else { | 10287 } else { |
10243 HInstruction* value_instruction = | 10288 HInstruction* value_instruction = |
10244 AddInstruction(new(zone) HLoadKeyed( | 10289 AddInstruction(new(zone) HLoadKeyed( |
10245 boilerplate_elements, key_constant, NULL, kind, | 10290 boilerplate_elements, key_constant, NULL, kind, |
10246 ALLOW_RETURN_HOLE)); | 10291 ALLOW_RETURN_HOLE)); |
10247 AddInstruction(new(zone) HStoreKeyed( | 10292 AddInstruction(new(zone) HStoreKeyed( |
10248 object_elements, key_constant, value_instruction, kind)); | 10293 object_elements, key_constant, value_instruction, kind)); |
10249 } | 10294 } |
10250 } | 10295 } |
10251 } | 10296 } |
(...skipping 1346 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
11598 } | 11643 } |
11599 } | 11644 } |
11600 | 11645 |
11601 #ifdef DEBUG | 11646 #ifdef DEBUG |
11602 if (graph_ != NULL) graph_->Verify(false); // No full verify. | 11647 if (graph_ != NULL) graph_->Verify(false); // No full verify. |
11603 if (allocator_ != NULL) allocator_->Verify(); | 11648 if (allocator_ != NULL) allocator_->Verify(); |
11604 #endif | 11649 #endif |
11605 } | 11650 } |
11606 | 11651 |
11607 } } // namespace v8::internal | 11652 } } // namespace v8::internal |
OLD | NEW |