OLD | NEW |
1 // Copyright 2013 the V8 project authors. All rights reserved. | 1 // Copyright 2013 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 2106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2117 elements, isolate()->factory()->fixed_array_map(), top_info()); | 2117 elements, isolate()->factory()->fixed_array_map(), top_info()); |
2118 check_cow_map->ClearGVNFlag(kDependsOnElementsKind); | 2118 check_cow_map->ClearGVNFlag(kDependsOnElementsKind); |
2119 } | 2119 } |
2120 } | 2120 } |
2121 } | 2121 } |
2122 return AddElementAccess(elements, checked_key, val, checked_object, | 2122 return AddElementAccess(elements, checked_key, val, checked_object, |
2123 elements_kind, is_store, load_mode); | 2123 elements_kind, is_store, load_mode); |
2124 } | 2124 } |
2125 | 2125 |
2126 | 2126 |
2127 | |
2128 HValue* HGraphBuilder::BuildAllocateArrayFromLength( | 2127 HValue* HGraphBuilder::BuildAllocateArrayFromLength( |
2129 JSArrayBuilder* array_builder, | 2128 JSArrayBuilder* array_builder, |
2130 HValue* length_argument) { | 2129 HValue* length_argument) { |
2131 if (length_argument->IsConstant() && | 2130 if (length_argument->IsConstant() && |
2132 HConstant::cast(length_argument)->HasSmiValue()) { | 2131 HConstant::cast(length_argument)->HasSmiValue()) { |
2133 int array_length = HConstant::cast(length_argument)->Integer32Value(); | 2132 int array_length = HConstant::cast(length_argument)->Integer32Value(); |
2134 HValue* new_object = array_length == 0 | 2133 HValue* new_object = array_length == 0 |
2135 ? array_builder->AllocateEmptyArray() | 2134 ? array_builder->AllocateEmptyArray() |
2136 : array_builder->AllocateArray(length_argument, length_argument); | 2135 : array_builder->AllocateArray(length_argument, length_argument); |
2137 return new_object; | 2136 return new_object; |
(...skipping 22 matching lines...) Expand all Loading... |
2160 Push(checked_length); // length | 2159 Push(checked_length); // length |
2161 } | 2160 } |
2162 if_builder.End(); | 2161 if_builder.End(); |
2163 | 2162 |
2164 // Figure out total size | 2163 // Figure out total size |
2165 HValue* length = Pop(); | 2164 HValue* length = Pop(); |
2166 HValue* capacity = Pop(); | 2165 HValue* capacity = Pop(); |
2167 return array_builder->AllocateArray(capacity, length); | 2166 return array_builder->AllocateArray(capacity, length); |
2168 } | 2167 } |
2169 | 2168 |
2170 HValue* HGraphBuilder::BuildAllocateElements(ElementsKind kind, | 2169 HValue* HGraphBuilder::BuildCalculateElementsSize(ElementsKind kind, |
2171 HValue* capacity) { | 2170 HValue* capacity) { |
2172 int elements_size; | 2171 int elements_size = IsFastDoubleElementsKind(kind) |
2173 InstanceType instance_type; | 2172 ? kDoubleSize |
2174 | 2173 : kPointerSize; |
2175 if (IsFastDoubleElementsKind(kind)) { | |
2176 elements_size = kDoubleSize; | |
2177 instance_type = FIXED_DOUBLE_ARRAY_TYPE; | |
2178 } else { | |
2179 elements_size = kPointerSize; | |
2180 instance_type = FIXED_ARRAY_TYPE; | |
2181 } | |
2182 | 2174 |
2183 HConstant* elements_size_value = Add<HConstant>(elements_size); | 2175 HConstant* elements_size_value = Add<HConstant>(elements_size); |
2184 HValue* mul = AddUncasted<HMul>(capacity, elements_size_value); | 2176 HInstruction* mul = HMul::NewImul(zone(), context(), |
| 2177 capacity->ActualValue(), |
| 2178 elements_size_value); |
| 2179 AddInstruction(mul); |
2185 mul->ClearFlag(HValue::kCanOverflow); | 2180 mul->ClearFlag(HValue::kCanOverflow); |
2186 | 2181 |
| 2182 STATIC_ASSERT(FixedDoubleArray::kHeaderSize == FixedArray::kHeaderSize); |
| 2183 |
2187 HConstant* header_size = Add<HConstant>(FixedArray::kHeaderSize); | 2184 HConstant* header_size = Add<HConstant>(FixedArray::kHeaderSize); |
2188 HValue* total_size = AddUncasted<HAdd>(mul, header_size); | 2185 HValue* total_size = AddUncasted<HAdd>(mul, header_size); |
2189 total_size->ClearFlag(HValue::kCanOverflow); | 2186 total_size->ClearFlag(HValue::kCanOverflow); |
2190 | 2187 return total_size; |
2191 return Add<HAllocate>(total_size, HType::JSArray(), | |
2192 isolate()->heap()->GetPretenureMode(), instance_type); | |
2193 } | 2188 } |
2194 | 2189 |
2195 | 2190 |
| 2191 HConstant* HGraphBuilder::EstablishHeaderAllocationSize( |
| 2192 AllocationSiteMode mode) { |
| 2193 int base_size = JSArray::kSize; |
| 2194 if (mode == TRACK_ALLOCATION_SITE) { |
| 2195 base_size += AllocationMemento::kSize; |
| 2196 } |
| 2197 return Add<HConstant>(base_size); |
| 2198 } |
| 2199 |
| 2200 |
| 2201 HConstant* HGraphBuilder::EstablishElementsAllocationSize( |
| 2202 ElementsKind kind, |
| 2203 int capacity) { |
| 2204 int base_size = IsFastDoubleElementsKind(kind) |
| 2205 ? FixedDoubleArray::SizeFor(capacity) |
| 2206 : FixedArray::SizeFor(capacity); |
| 2207 |
| 2208 return Add<HConstant>(base_size); |
| 2209 } |
| 2210 |
| 2211 |
| 2212 HAllocate* HGraphBuilder::BuildAllocateElements(ElementsKind kind, |
| 2213 HValue* size_in_bytes, |
| 2214 PretenureFlag pretenure) { |
| 2215 InstanceType instance_type = IsFastDoubleElementsKind(kind) |
| 2216 ? FIXED_DOUBLE_ARRAY_TYPE |
| 2217 : FIXED_ARRAY_TYPE; |
| 2218 |
| 2219 return Add<HAllocate>(size_in_bytes, HType::JSArray(), |
| 2220 pretenure, instance_type); |
| 2221 } |
| 2222 |
| 2223 |
2196 void HGraphBuilder::BuildInitializeElementsHeader(HValue* elements, | 2224 void HGraphBuilder::BuildInitializeElementsHeader(HValue* elements, |
2197 ElementsKind kind, | 2225 ElementsKind kind, |
2198 HValue* capacity) { | 2226 HValue* capacity) { |
2199 Factory* factory = isolate()->factory(); | 2227 Factory* factory = isolate()->factory(); |
2200 Handle<Map> map = IsFastDoubleElementsKind(kind) | 2228 Handle<Map> map = IsFastDoubleElementsKind(kind) |
2201 ? factory->fixed_double_array_map() | 2229 ? factory->fixed_double_array_map() |
2202 : factory->fixed_array_map(); | 2230 : factory->fixed_array_map(); |
2203 | 2231 |
2204 AddStoreMapConstant(elements, map); | 2232 AddStoreMapConstant(elements, map); |
2205 Add<HStoreNamedField>(elements, HObjectAccess::ForFixedArrayLength(), | 2233 Add<HStoreNamedField>(elements, HObjectAccess::ForFixedArrayLength(), |
2206 capacity); | 2234 capacity); |
2207 } | 2235 } |
2208 | 2236 |
2209 | 2237 |
2210 HValue* HGraphBuilder::BuildAllocateElementsAndInitializeElementsHeader( | 2238 HValue* HGraphBuilder::BuildAllocateElementsAndInitializeElementsHeader( |
2211 ElementsKind kind, | 2239 ElementsKind kind, |
2212 HValue* capacity) { | 2240 HValue* capacity) { |
2213 // The HForceRepresentation is to prevent possible deopt on int-smi | 2241 // The HForceRepresentation is to prevent possible deopt on int-smi |
2214 // conversion after allocation but before the new object fields are set. | 2242 // conversion after allocation but before the new object fields are set. |
2215 capacity = AddUncasted<HForceRepresentation>(capacity, Representation::Smi()); | 2243 capacity = AddUncasted<HForceRepresentation>(capacity, Representation::Smi()); |
2216 HValue* new_elements = BuildAllocateElements(kind, capacity); | 2244 HValue* size_in_bytes = BuildCalculateElementsSize(kind, capacity); |
| 2245 HValue* new_elements = BuildAllocateElements( |
| 2246 kind, size_in_bytes, isolate()->heap()->GetPretenureMode()); |
2217 BuildInitializeElementsHeader(new_elements, kind, capacity); | 2247 BuildInitializeElementsHeader(new_elements, kind, capacity); |
2218 return new_elements; | 2248 return new_elements; |
2219 } | 2249 } |
2220 | 2250 |
2221 | 2251 |
2222 HInnerAllocatedObject* HGraphBuilder::BuildJSArrayHeader(HValue* array, | 2252 void HGraphBuilder::BuildJSArrayHeader(HValue* array, |
2223 HValue* array_map, | 2253 HValue* array_map, |
2224 AllocationSiteMode mode, | 2254 AllocationSiteMode mode, |
2225 ElementsKind elements_kind, | 2255 ElementsKind elements_kind, |
2226 HValue* allocation_site_payload, | 2256 HValue* allocation_site_payload, |
2227 HValue* length_field) { | 2257 HValue* length_field) { |
2228 | |
2229 Add<HStoreNamedField>(array, HObjectAccess::ForMap(), array_map); | 2258 Add<HStoreNamedField>(array, HObjectAccess::ForMap(), array_map); |
2230 | 2259 |
2231 HConstant* empty_fixed_array = | 2260 HConstant* empty_fixed_array = |
2232 Add<HConstant>(isolate()->factory()->empty_fixed_array()); | 2261 Add<HConstant>(isolate()->factory()->empty_fixed_array()); |
2233 | 2262 |
2234 HObjectAccess access = HObjectAccess::ForPropertiesPointer(); | 2263 Add<HStoreNamedField>( |
2235 Add<HStoreNamedField>(array, access, empty_fixed_array); | 2264 array, HObjectAccess::ForPropertiesPointer(), empty_fixed_array); |
2236 Add<HStoreNamedField>(array, HObjectAccess::ForArrayLength(elements_kind), | 2265 |
2237 length_field); | 2266 Add<HStoreNamedField>( |
| 2267 array, HObjectAccess::ForElementsPointer(), empty_fixed_array); |
| 2268 |
| 2269 Add<HStoreNamedField>( |
| 2270 array, HObjectAccess::ForArrayLength(elements_kind), length_field); |
2238 | 2271 |
2239 if (mode == TRACK_ALLOCATION_SITE) { | 2272 if (mode == TRACK_ALLOCATION_SITE) { |
2240 BuildCreateAllocationMemento(array, | 2273 BuildCreateAllocationMemento(array, |
2241 JSArray::kSize, | 2274 JSArray::kSize, |
2242 allocation_site_payload); | 2275 allocation_site_payload); |
2243 } | 2276 } |
2244 | |
2245 int elements_location = JSArray::kSize; | |
2246 if (mode == TRACK_ALLOCATION_SITE) { | |
2247 elements_location += AllocationMemento::kSize; | |
2248 } | |
2249 | |
2250 HValue* elements = Add<HInnerAllocatedObject>(array, elements_location); | |
2251 Add<HStoreNamedField>(array, HObjectAccess::ForElementsPointer(), elements); | |
2252 return static_cast<HInnerAllocatedObject*>(elements); | |
2253 } | 2277 } |
2254 | 2278 |
2255 | 2279 |
2256 HInstruction* HGraphBuilder::AddElementAccess( | 2280 HInstruction* HGraphBuilder::AddElementAccess( |
2257 HValue* elements, | 2281 HValue* elements, |
2258 HValue* checked_key, | 2282 HValue* checked_key, |
2259 HValue* val, | 2283 HValue* val, |
2260 HValue* dependency, | 2284 HValue* dependency, |
2261 ElementsKind elements_kind, | 2285 ElementsKind elements_kind, |
2262 bool is_store, | 2286 bool is_store, |
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2450 | 2474 |
2451 | 2475 |
2452 HValue* HGraphBuilder::BuildCloneShallowArray(HValue* boilerplate, | 2476 HValue* HGraphBuilder::BuildCloneShallowArray(HValue* boilerplate, |
2453 HValue* allocation_site, | 2477 HValue* allocation_site, |
2454 AllocationSiteMode mode, | 2478 AllocationSiteMode mode, |
2455 ElementsKind kind, | 2479 ElementsKind kind, |
2456 int length) { | 2480 int length) { |
2457 NoObservableSideEffectsScope no_effects(this); | 2481 NoObservableSideEffectsScope no_effects(this); |
2458 | 2482 |
2459 // All sizes here are multiples of kPointerSize. | 2483 // All sizes here are multiples of kPointerSize. |
2460 int size = JSArray::kSize; | 2484 HConstant* size_in_bytes = EstablishHeaderAllocationSize(mode); |
2461 if (mode == TRACK_ALLOCATION_SITE) { | |
2462 size += AllocationMemento::kSize; | |
2463 } | |
2464 | |
2465 HValue* size_in_bytes = Add<HConstant>(size); | |
2466 HInstruction* object = Add<HAllocate>(size_in_bytes, | 2485 HInstruction* object = Add<HAllocate>(size_in_bytes, |
2467 HType::JSObject(), | 2486 HType::JSObject(), |
2468 NOT_TENURED, | 2487 NOT_TENURED, |
2469 JS_OBJECT_TYPE); | 2488 JS_OBJECT_TYPE); |
2470 | 2489 |
2471 // Copy the JS array part. | 2490 // Copy the JS array part. |
2472 for (int i = 0; i < JSArray::kSize; i += kPointerSize) { | 2491 for (int i = 0; i < JSArray::kSize; i += kPointerSize) { |
2473 if ((i != JSArray::kElementsOffset) || (length == 0)) { | 2492 if ((i != JSArray::kElementsOffset) || (length == 0)) { |
2474 HObjectAccess access = HObjectAccess::ForJSArrayOffset(i); | 2493 HObjectAccess access = HObjectAccess::ForJSArrayOffset(i); |
2475 Add<HStoreNamedField>(object, access, | 2494 Add<HStoreNamedField>(object, access, |
2476 Add<HLoadNamedField>(boilerplate, access)); | 2495 Add<HLoadNamedField>(boilerplate, access)); |
2477 } | 2496 } |
2478 } | 2497 } |
2479 | 2498 |
2480 // Create an allocation site info if requested. | 2499 // Create an allocation site info if requested. |
2481 if (mode == TRACK_ALLOCATION_SITE) { | 2500 if (mode == TRACK_ALLOCATION_SITE) { |
2482 BuildCreateAllocationMemento(object, JSArray::kSize, allocation_site); | 2501 BuildCreateAllocationMemento(object, JSArray::kSize, allocation_site); |
2483 } | 2502 } |
2484 | 2503 |
2485 if (length > 0) { | 2504 if (length > 0) { |
2486 HValue* boilerplate_elements = AddLoadElements(boilerplate); | 2505 HValue* boilerplate_elements = AddLoadElements(boilerplate); |
2487 HValue* object_elements; | 2506 HConstant* elems_size = EstablishElementsAllocationSize(kind, length); |
2488 if (IsFastDoubleElementsKind(kind)) { | 2507 HValue* object_elements = |
2489 HValue* elems_size = Add<HConstant>(FixedDoubleArray::SizeFor(length)); | 2508 BuildAllocateElements(kind, elems_size, NOT_TENURED); |
2490 object_elements = Add<HAllocate>(elems_size, HType::JSArray(), | 2509 |
2491 NOT_TENURED, FIXED_DOUBLE_ARRAY_TYPE); | |
2492 } else { | |
2493 HValue* elems_size = Add<HConstant>(FixedArray::SizeFor(length)); | |
2494 object_elements = Add<HAllocate>(elems_size, HType::JSArray(), | |
2495 NOT_TENURED, FIXED_ARRAY_TYPE); | |
2496 } | |
2497 Add<HStoreNamedField>(object, HObjectAccess::ForElementsPointer(), | 2510 Add<HStoreNamedField>(object, HObjectAccess::ForElementsPointer(), |
2498 object_elements); | 2511 object_elements); |
2499 | 2512 |
2500 // Copy the elements array header. | 2513 // Copy the elements array header. |
2501 for (int i = 0; i < FixedArrayBase::kHeaderSize; i += kPointerSize) { | 2514 for (int i = 0; i < FixedArrayBase::kHeaderSize; i += kPointerSize) { |
2502 HObjectAccess access = HObjectAccess::ForFixedArrayHeader(i); | 2515 HObjectAccess access = HObjectAccess::ForFixedArrayHeader(i); |
2503 Add<HStoreNamedField>(object_elements, access, | 2516 Add<HStoreNamedField>(object_elements, access, |
2504 Add<HLoadNamedField>(boilerplate_elements, access)); | 2517 Add<HLoadNamedField>(boilerplate_elements, access)); |
2505 } | 2518 } |
2506 | 2519 |
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2660 } | 2673 } |
2661 | 2674 |
2662 | 2675 |
2663 HValue* HGraphBuilder::JSArrayBuilder::EmitInternalMapCode() { | 2676 HValue* HGraphBuilder::JSArrayBuilder::EmitInternalMapCode() { |
2664 // Find the map near the constructor function | 2677 // Find the map near the constructor function |
2665 HObjectAccess access = HObjectAccess::ForPrototypeOrInitialMap(); | 2678 HObjectAccess access = HObjectAccess::ForPrototypeOrInitialMap(); |
2666 return builder()->AddLoadNamedField(constructor_function_, access); | 2679 return builder()->AddLoadNamedField(constructor_function_, access); |
2667 } | 2680 } |
2668 | 2681 |
2669 | 2682 |
2670 HValue* HGraphBuilder::JSArrayBuilder::EstablishAllocationSize( | |
2671 HValue* length_node) { | |
2672 ASSERT(length_node != NULL); | |
2673 | |
2674 int base_size = JSArray::kSize; | |
2675 if (mode_ == TRACK_ALLOCATION_SITE) { | |
2676 base_size += AllocationMemento::kSize; | |
2677 } | |
2678 | |
2679 STATIC_ASSERT(FixedDoubleArray::kHeaderSize == FixedArray::kHeaderSize); | |
2680 base_size += FixedArray::kHeaderSize; | |
2681 | |
2682 HInstruction* elements_size_value = | |
2683 builder()->Add<HConstant>(elements_size()); | |
2684 HInstruction* mul = HMul::NewImul(builder()->zone(), builder()->context(), | |
2685 length_node, elements_size_value); | |
2686 builder()->AddInstruction(mul); | |
2687 HInstruction* base = builder()->Add<HConstant>(base_size); | |
2688 HInstruction* total_size = HAdd::New(builder()->zone(), builder()->context(), | |
2689 base, mul); | |
2690 total_size->ClearFlag(HValue::kCanOverflow); | |
2691 builder()->AddInstruction(total_size); | |
2692 return total_size; | |
2693 } | |
2694 | |
2695 | |
2696 HValue* HGraphBuilder::JSArrayBuilder::EstablishEmptyArrayAllocationSize() { | |
2697 int base_size = JSArray::kSize; | |
2698 if (mode_ == TRACK_ALLOCATION_SITE) { | |
2699 base_size += AllocationMemento::kSize; | |
2700 } | |
2701 | |
2702 base_size += IsFastDoubleElementsKind(kind_) | |
2703 ? FixedDoubleArray::SizeFor(initial_capacity()) | |
2704 : FixedArray::SizeFor(initial_capacity()); | |
2705 | |
2706 return builder()->Add<HConstant>(base_size); | |
2707 } | |
2708 | |
2709 | |
2710 HValue* HGraphBuilder::JSArrayBuilder::AllocateEmptyArray() { | 2683 HValue* HGraphBuilder::JSArrayBuilder::AllocateEmptyArray() { |
2711 HValue* size_in_bytes = EstablishEmptyArrayAllocationSize(); | |
2712 HConstant* capacity = builder()->Add<HConstant>(initial_capacity()); | 2684 HConstant* capacity = builder()->Add<HConstant>(initial_capacity()); |
2713 return AllocateArray(size_in_bytes, | 2685 return AllocateArray(capacity, |
2714 capacity, | |
2715 builder()->graph()->GetConstant0()); | 2686 builder()->graph()->GetConstant0()); |
2716 } | 2687 } |
2717 | 2688 |
2718 | 2689 |
2719 HValue* HGraphBuilder::JSArrayBuilder::AllocateArray(HValue* capacity, | 2690 HValue* HGraphBuilder::JSArrayBuilder::AllocateArray(HValue* capacity, |
2720 HValue* length_field, | 2691 HValue* length_field, |
2721 FillMode fill_mode) { | 2692 FillMode fill_mode) { |
2722 HValue* size_in_bytes = EstablishAllocationSize(capacity); | |
2723 return AllocateArray(size_in_bytes, capacity, length_field, fill_mode); | |
2724 } | |
2725 | |
2726 | |
2727 HValue* HGraphBuilder::JSArrayBuilder::AllocateArray(HValue* size_in_bytes, | |
2728 HValue* capacity, | |
2729 HValue* length_field, | |
2730 FillMode fill_mode) { | |
2731 // These HForceRepresentations are because we store these as fields in the | 2693 // These HForceRepresentations are because we store these as fields in the |
2732 // objects we construct, and an int32-to-smi HChange could deopt. Accept | 2694 // objects we construct, and an int32-to-smi HChange could deopt. Accept |
2733 // the deopt possibility now, before allocation occurs. | 2695 // the deopt possibility now, before allocation occurs. |
2734 capacity = | 2696 capacity = |
2735 builder()->AddUncasted<HForceRepresentation>(capacity, | 2697 builder()->AddUncasted<HForceRepresentation>(capacity, |
2736 Representation::Smi()); | 2698 Representation::Smi()); |
2737 length_field = | 2699 length_field = |
2738 builder()->AddUncasted<HForceRepresentation>(length_field, | 2700 builder()->AddUncasted<HForceRepresentation>(length_field, |
2739 Representation::Smi()); | 2701 Representation::Smi()); |
| 2702 |
| 2703 // Generate size calculation code here in order to make it dominate |
| 2704 // the JSArray allocation. |
| 2705 HValue* elms_size = builder()->BuildCalculateElementsSize(kind_, capacity); |
| 2706 |
2740 // Allocate (dealing with failure appropriately) | 2707 // Allocate (dealing with failure appropriately) |
2741 HAllocate* new_object = builder()->Add<HAllocate>(size_in_bytes, | 2708 HConstant* array_object_size = |
| 2709 builder()->EstablishHeaderAllocationSize(mode_); |
| 2710 HAllocate* array_object = builder()->Add<HAllocate>(array_object_size, |
2742 HType::JSArray(), NOT_TENURED, JS_ARRAY_TYPE); | 2711 HType::JSArray(), NOT_TENURED, JS_ARRAY_TYPE); |
2743 | 2712 |
2744 // Folded array allocation should be aligned if it has fast double elements. | |
2745 if (IsFastDoubleElementsKind(kind_)) { | |
2746 new_object->MakeDoubleAligned(); | |
2747 } | |
2748 | |
2749 // Fill in the fields: map, properties, length | 2713 // Fill in the fields: map, properties, length |
2750 HValue* map; | 2714 HValue* map; |
2751 if (allocation_site_payload_ == NULL) { | 2715 if (allocation_site_payload_ == NULL) { |
2752 map = EmitInternalMapCode(); | 2716 map = EmitInternalMapCode(); |
2753 } else { | 2717 } else { |
2754 map = EmitMapCode(); | 2718 map = EmitMapCode(); |
2755 } | 2719 } |
2756 elements_location_ = builder()->BuildJSArrayHeader(new_object, | |
2757 map, | |
2758 mode_, | |
2759 kind_, | |
2760 allocation_site_payload_, | |
2761 length_field); | |
2762 | 2720 |
2763 // Initialize the elements | 2721 builder()->BuildJSArrayHeader(array_object, |
| 2722 map, |
| 2723 mode_, |
| 2724 kind_, |
| 2725 allocation_site_payload_, |
| 2726 length_field); |
| 2727 |
| 2728 // Allocate and initialize the elements |
| 2729 elements_location_ = |
| 2730 builder()->BuildAllocateElements(kind_, elms_size, NOT_TENURED); |
| 2731 array_object->set_wired_allocate(elements_location_); |
| 2732 |
2764 builder()->BuildInitializeElementsHeader(elements_location_, kind_, capacity); | 2733 builder()->BuildInitializeElementsHeader(elements_location_, kind_, capacity); |
2765 | 2734 |
| 2735 // Set the elements |
| 2736 builder()->Add<HStoreNamedField>( |
| 2737 array_object, HObjectAccess::ForElementsPointer(), elements_location_); |
| 2738 |
2766 if (fill_mode == FILL_WITH_HOLE) { | 2739 if (fill_mode == FILL_WITH_HOLE) { |
2767 builder()->BuildFillElementsWithHole(elements_location_, kind_, | 2740 builder()->BuildFillElementsWithHole(elements_location_, kind_, |
2768 graph()->GetConstant0(), capacity); | 2741 graph()->GetConstant0(), capacity); |
2769 } | 2742 } |
2770 | 2743 |
2771 return new_object; | 2744 return array_object; |
2772 } | 2745 } |
2773 | 2746 |
2774 | 2747 |
2775 HStoreNamedField* HGraphBuilder::AddStoreMapConstant(HValue *object, | 2748 HStoreNamedField* HGraphBuilder::AddStoreMapConstant(HValue *object, |
2776 Handle<Map> map) { | 2749 Handle<Map> map) { |
2777 return Add<HStoreNamedField>(object, HObjectAccess::ForMap(), | 2750 return Add<HStoreNamedField>(object, HObjectAccess::ForMap(), |
2778 Add<HConstant>(map)); | 2751 Add<HConstant>(map)); |
2779 } | 2752 } |
2780 | 2753 |
2781 | 2754 |
(...skipping 8003 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
10785 if (ShouldProduceTraceOutput()) { | 10758 if (ShouldProduceTraceOutput()) { |
10786 isolate()->GetHTracer()->TraceHydrogen(name(), graph_); | 10759 isolate()->GetHTracer()->TraceHydrogen(name(), graph_); |
10787 } | 10760 } |
10788 | 10761 |
10789 #ifdef DEBUG | 10762 #ifdef DEBUG |
10790 graph_->Verify(false); // No full verify. | 10763 graph_->Verify(false); // No full verify. |
10791 #endif | 10764 #endif |
10792 } | 10765 } |
10793 | 10766 |
10794 } } // namespace v8::internal | 10767 } } // namespace v8::internal |
OLD | NEW |