OLD | NEW |
1 // Copyright 2016 the V8 project authors. All rights reserved. | 1 // Copyright 2016 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/code-stub-assembler.h" | 5 #include "src/code-stub-assembler.h" |
6 #include "src/code-factory.h" | 6 #include "src/code-factory.h" |
7 #include "src/frames-inl.h" | 7 #include "src/frames-inl.h" |
8 #include "src/frames.h" | 8 #include "src/frames.h" |
9 #include "src/ic/handler-configuration.h" | 9 #include "src/ic/handler-configuration.h" |
10 #include "src/ic/stub-cache.h" | 10 #include "src/ic/stub-cache.h" |
(...skipping 1374 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1385 mode == SMI_PARAMETERS ? capacity_node : SmiTag(capacity_node)); | 1385 mode == SMI_PARAMETERS ? capacity_node : SmiTag(capacity_node)); |
1386 | 1386 |
1387 FillFixedArrayWithHole(kind, elements, IntPtrConstant(0), capacity_node, | 1387 FillFixedArrayWithHole(kind, elements, IntPtrConstant(0), capacity_node, |
1388 mode); | 1388 mode); |
1389 | 1389 |
1390 return array; | 1390 return array; |
1391 } | 1391 } |
1392 | 1392 |
1393 Node* CodeStubAssembler::AllocateFixedArray(ElementsKind kind, | 1393 Node* CodeStubAssembler::AllocateFixedArray(ElementsKind kind, |
1394 Node* capacity_node, | 1394 Node* capacity_node, |
1395 ParameterMode mode) { | 1395 ParameterMode mode, |
1396 Node* total_size = ElementOffsetFromIndex(capacity_node, kind, mode, | 1396 AllocationFlags flags) { |
1397 FixedArray::kHeaderSize); | 1397 Node* total_size = GetFixedAarrayAllocationSize(capacity_node, kind, mode); |
1398 | 1398 |
1399 // Allocate both array and elements object, and initialize the JSArray. | 1399 // Allocate both array and elements object, and initialize the JSArray. |
1400 Node* array = Allocate(total_size); | 1400 Node* array = Allocate(total_size, flags); |
1401 Heap* heap = isolate()->heap(); | 1401 Heap* heap = isolate()->heap(); |
1402 Handle<Map> map(IsFastDoubleElementsKind(kind) | 1402 Handle<Map> map(IsFastDoubleElementsKind(kind) |
1403 ? heap->fixed_double_array_map() | 1403 ? heap->fixed_double_array_map() |
1404 : heap->fixed_array_map()); | 1404 : heap->fixed_array_map()); |
1405 StoreMapNoWriteBarrier(array, HeapConstant(map)); | 1405 if (flags & kPretenured) { |
| 1406 StoreObjectField(array, JSObject::kMapOffset, HeapConstant(map)); |
| 1407 } else { |
| 1408 StoreMapNoWriteBarrier(array, HeapConstant(map)); |
| 1409 } |
1406 StoreObjectFieldNoWriteBarrier( | 1410 StoreObjectFieldNoWriteBarrier( |
1407 array, FixedArray::kLengthOffset, | 1411 array, FixedArray::kLengthOffset, |
1408 mode == INTEGER_PARAMETERS ? SmiTag(capacity_node) : capacity_node); | 1412 mode == INTEGER_PARAMETERS ? SmiTag(capacity_node) : capacity_node); |
1409 return array; | 1413 return array; |
1410 } | 1414 } |
1411 | 1415 |
1412 void CodeStubAssembler::FillFixedArrayWithHole(ElementsKind kind, | 1416 void CodeStubAssembler::FillFixedArrayWithHole(ElementsKind kind, |
1413 compiler::Node* array, | 1417 compiler::Node* array, |
1414 compiler::Node* from_node, | 1418 compiler::Node* from_node, |
1415 compiler::Node* to_node, | 1419 compiler::Node* to_node, |
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1586 Node* max_gap = IntPtrOrSmiConstant(JSObject::kMaxGap, mode); | 1590 Node* max_gap = IntPtrOrSmiConstant(JSObject::kMaxGap, mode); |
1587 Node* max_capacity = IntPtrAdd(capacity, max_gap); | 1591 Node* max_capacity = IntPtrAdd(capacity, max_gap); |
1588 GotoIf(UintPtrGreaterThanOrEqual(key, max_capacity), fail); | 1592 GotoIf(UintPtrGreaterThanOrEqual(key, max_capacity), fail); |
1589 | 1593 |
1590 // Calculate the capacity of the new backing tore | 1594 // Calculate the capacity of the new backing tore |
1591 Node* new_capacity = CalculateNewElementsCapacity( | 1595 Node* new_capacity = CalculateNewElementsCapacity( |
1592 IntPtrAdd(key, IntPtrOrSmiConstant(1, mode)), mode); | 1596 IntPtrAdd(key, IntPtrOrSmiConstant(1, mode)), mode); |
1593 | 1597 |
1594 // If size of the allocation for the new capacity doesn't fit in a page | 1598 // If size of the allocation for the new capacity doesn't fit in a page |
1595 // that we can bump-pointer allocate from, fall back to the runtime, | 1599 // that we can bump-pointer allocate from, fall back to the runtime, |
1596 int max_size = ((Page::kMaxRegularHeapObjectSize - FixedArray::kHeaderSize) >> | 1600 int max_size = FixedArrayBase::GetMaxLengthForNewSpaceAllocation(kind); |
1597 ElementsKindToShiftSize(kind)); | |
1598 GotoIf(UintPtrGreaterThanOrEqual(new_capacity, | 1601 GotoIf(UintPtrGreaterThanOrEqual(new_capacity, |
1599 IntPtrOrSmiConstant(max_size, mode)), | 1602 IntPtrOrSmiConstant(max_size, mode)), |
1600 fail); | 1603 fail); |
1601 | 1604 |
1602 // Allocate the new backing store. | 1605 // Allocate the new backing store. |
1603 Node* new_elements = AllocateFixedArray(kind, new_capacity, mode); | 1606 Node* new_elements = AllocateFixedArray(kind, new_capacity, mode); |
1604 | 1607 |
1605 // Fill in the added capacity in the new store with holes. | 1608 // Fill in the added capacity in the new store with holes. |
1606 FillFixedArrayWithHole(kind, new_elements, capacity, new_capacity, mode); | 1609 FillFixedArrayWithHole(kind, new_elements, capacity, new_capacity, mode); |
1607 | 1610 |
(...skipping 2338 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3946 Heap::kTheHoleValueRootIndex); | 3949 Heap::kTheHoleValueRootIndex); |
3947 | 3950 |
3948 // Store the WeakCell in the feedback vector. | 3951 // Store the WeakCell in the feedback vector. |
3949 StoreFixedArrayElement(feedback_vector, slot, cell, UPDATE_WRITE_BARRIER, | 3952 StoreFixedArrayElement(feedback_vector, slot, cell, UPDATE_WRITE_BARRIER, |
3950 CodeStubAssembler::SMI_PARAMETERS); | 3953 CodeStubAssembler::SMI_PARAMETERS); |
3951 return cell; | 3954 return cell; |
3952 } | 3955 } |
3953 | 3956 |
3954 } // namespace internal | 3957 } // namespace internal |
3955 } // namespace v8 | 3958 } // namespace v8 |
OLD | NEW |