Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(317)

Side by Side Diff: src/code-stub-assembler.cc

Issue 2324863002: [stubs] Factor CSA::GrowElementsCapacity() out of existing code. (Closed)
Patch Set: Addressing comments Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/code-stub-assembler.h ('k') | src/code-stubs.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 1672 matching lines...) Expand 10 before | Expand all | Expand 10 after
1683 IntPtrAdd(new_capacity, IntPtrOrSmiConstant(16, mode)); 1683 IntPtrAdd(new_capacity, IntPtrOrSmiConstant(16, mode));
1684 if (mode == INTEGER_PARAMETERS || mode == INTPTR_PARAMETERS) { 1684 if (mode == INTEGER_PARAMETERS || mode == INTPTR_PARAMETERS) {
1685 return unconditioned_result; 1685 return unconditioned_result;
1686 } else { 1686 } else {
1687 int const kSmiShiftBits = kSmiShiftSize + kSmiTagSize; 1687 int const kSmiShiftBits = kSmiShiftSize + kSmiTagSize;
1688 return WordAnd(unconditioned_result, 1688 return WordAnd(unconditioned_result,
1689 IntPtrConstant(static_cast<size_t>(-1) << kSmiShiftBits)); 1689 IntPtrConstant(static_cast<size_t>(-1) << kSmiShiftBits));
1690 } 1690 }
1691 } 1691 }
1692 1692
1693 Node* CodeStubAssembler::CheckAndGrowElementsCapacity(Node* context, 1693 Node* CodeStubAssembler::TryGrowElementsCapacity(Node* object, Node* elements,
1694 Node* elements, 1694 ElementsKind kind, Node* key,
1695 ElementsKind kind, 1695 Label* bailout) {
1696 Node* key, Label* fail) {
1697 Node* capacity = LoadFixedArrayBaseLength(elements); 1696 Node* capacity = LoadFixedArrayBaseLength(elements);
1698 1697
1699 ParameterMode mode = OptimalParameterMode(); 1698 ParameterMode mode = OptimalParameterMode();
1700 capacity = UntagParameter(capacity, mode); 1699 capacity = UntagParameter(capacity, mode);
1701 key = UntagParameter(key, mode); 1700 key = UntagParameter(key, mode);
1702 1701
1702 return TryGrowElementsCapacity(object, elements, kind, key, capacity, mode,
1703 bailout);
1704 }
1705
1706 Node* CodeStubAssembler::TryGrowElementsCapacity(Node* object, Node* elements,
1707 ElementsKind kind, Node* key,
1708 Node* capacity,
1709 ParameterMode mode,
1710 Label* bailout) {
1711 Comment("TryGrowElementsCapacity");
1712
1703 // If the gap growth is too big, fall back to the runtime. 1713 // If the gap growth is too big, fall back to the runtime.
1704 Node* max_gap = IntPtrOrSmiConstant(JSObject::kMaxGap, mode); 1714 Node* max_gap = IntPtrOrSmiConstant(JSObject::kMaxGap, mode);
1705 Node* max_capacity = IntPtrAdd(capacity, max_gap); 1715 Node* max_capacity = IntPtrAdd(capacity, max_gap);
1706 GotoIf(UintPtrGreaterThanOrEqual(key, max_capacity), fail); 1716 GotoIf(UintPtrGreaterThanOrEqual(key, max_capacity), bailout);
1707 1717
1708 // Calculate the capacity of the new backing tore 1718 // Calculate the capacity of the new backing store.
1709 Node* new_capacity = CalculateNewElementsCapacity( 1719 Node* new_capacity = CalculateNewElementsCapacity(
1710 IntPtrAdd(key, IntPtrOrSmiConstant(1, mode)), mode); 1720 IntPtrAdd(key, IntPtrOrSmiConstant(1, mode)), mode);
1721 return GrowElementsCapacity(object, elements, kind, kind, capacity,
1722 new_capacity, mode, bailout);
1723 }
1711 1724
1725 Node* CodeStubAssembler::GrowElementsCapacity(
1726 Node* object, Node* elements, ElementsKind from_kind, ElementsKind to_kind,
1727 Node* capacity, Node* new_capacity, ParameterMode mode, Label* bailout) {
1728 Comment("[ GrowElementsCapacity");
1712 // If size of the allocation for the new capacity doesn't fit in a page 1729 // If size of the allocation for the new capacity doesn't fit in a page
1713 // that we can bump-pointer allocate from, fall back to the runtime, 1730 // that we can bump-pointer allocate from, fall back to the runtime.
1714 int max_size = FixedArrayBase::GetMaxLengthForNewSpaceAllocation(kind); 1731 int max_size = FixedArrayBase::GetMaxLengthForNewSpaceAllocation(to_kind);
1715 GotoIf(UintPtrGreaterThanOrEqual(new_capacity, 1732 GotoIf(UintPtrGreaterThanOrEqual(new_capacity,
1716 IntPtrOrSmiConstant(max_size, mode)), 1733 IntPtrOrSmiConstant(max_size, mode)),
1717 fail); 1734 bailout);
1718 1735
1719 // Allocate the new backing store. 1736 // Allocate the new backing store.
1720 Node* new_elements = AllocateFixedArray(kind, new_capacity, mode); 1737 Node* new_elements = AllocateFixedArray(to_kind, new_capacity, mode);
1721 1738
1722 // Fill in the added capacity in the new store with holes. 1739 // Fill in the added capacity in the new store with holes.
1723 FillFixedArrayWithValue(kind, new_elements, capacity, new_capacity, 1740 FillFixedArrayWithValue(to_kind, new_elements, capacity, new_capacity,
1724 Heap::kTheHoleValueRootIndex, mode); 1741 Heap::kTheHoleValueRootIndex, mode);
1725 1742
1726 // Copy the elements from the old elements store to the new. 1743 // Copy the elements from the old elements store to the new.
1727 CopyFixedArrayElements(kind, elements, new_elements, capacity, 1744 // The size-check above guarantees that the |new_elements| is allocated
1728 SKIP_WRITE_BARRIER, mode); 1745 // in new space so we can skip the write barrier.
1746 CopyFixedArrayElements(from_kind, elements, to_kind, new_elements, capacity,
1747 new_capacity, SKIP_WRITE_BARRIER, mode);
1729 1748
1749 StoreObjectField(object, JSObject::kElementsOffset, new_elements);
1750 Comment("] GrowElementsCapacity");
1730 return new_elements; 1751 return new_elements;
1731 } 1752 }
1732 1753
1733 void CodeStubAssembler::InitializeAllocationMemento( 1754 void CodeStubAssembler::InitializeAllocationMemento(
1734 compiler::Node* base_allocation, int base_allocation_size, 1755 compiler::Node* base_allocation, int base_allocation_size,
1735 compiler::Node* allocation_site) { 1756 compiler::Node* allocation_site) {
1736 StoreObjectFieldNoWriteBarrier( 1757 StoreObjectFieldNoWriteBarrier(
1737 base_allocation, AllocationMemento::kMapOffset + base_allocation_size, 1758 base_allocation, AllocationMemento::kMapOffset + base_allocation_size,
1738 HeapConstant(Handle<Map>(isolate()->heap()->allocation_memento_map()))); 1759 HeapConstant(Handle<Map>(isolate()->heap()->allocation_memento_map())));
1739 StoreObjectFieldNoWriteBarrier( 1760 StoreObjectFieldNoWriteBarrier(
(...skipping 2581 matching lines...) Expand 10 before | Expand all | Expand 10 after
4321 Heap::kTheHoleValueRootIndex); 4342 Heap::kTheHoleValueRootIndex);
4322 4343
4323 // Store the WeakCell in the feedback vector. 4344 // Store the WeakCell in the feedback vector.
4324 StoreFixedArrayElement(feedback_vector, slot, cell, UPDATE_WRITE_BARRIER, 4345 StoreFixedArrayElement(feedback_vector, slot, cell, UPDATE_WRITE_BARRIER,
4325 CodeStubAssembler::SMI_PARAMETERS); 4346 CodeStubAssembler::SMI_PARAMETERS);
4326 return cell; 4347 return cell;
4327 } 4348 }
4328 4349
4329 } // namespace internal 4350 } // namespace internal
4330 } // namespace v8 4351 } // namespace v8
OLDNEW
« no previous file with comments | « src/code-stub-assembler.h ('k') | src/code-stubs.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698