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 #include "src/code-stub-assembler.h" | 4 #include "src/code-stub-assembler.h" |
5 #include "src/code-factory.h" | 5 #include "src/code-factory.h" |
6 #include "src/frames-inl.h" | 6 #include "src/frames-inl.h" |
7 #include "src/frames.h" | 7 #include "src/frames.h" |
8 #include "src/ic/handler-configuration.h" | 8 #include "src/ic/handler-configuration.h" |
9 #include "src/ic/stub-cache.h" | 9 #include "src/ic/stub-cache.h" |
10 | 10 |
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
120 return IntPtrConstant(left_constant - right_constant); | 120 return IntPtrConstant(left_constant - right_constant); |
121 } | 121 } |
122 } else if (is_right_constant) { | 122 } else if (is_right_constant) { |
123 if (right_constant == 0) { | 123 if (right_constant == 0) { |
124 return left; | 124 return left; |
125 } | 125 } |
126 } | 126 } |
127 return IntPtrSub(left, right); | 127 return IntPtrSub(left, right); |
128 } | 128 } |
129 | 129 |
130 void CodeStubAssembler::BranchIfWordIsPowerOfTwo(Node* value, Label* if_true, | |
Igor Sheludko
2016/10/21 07:48:27
I think this can be written as predicate IsPowerOf
Camillo Bruni
2016/10/21 13:37:15
Ahhh that's what I've been looking for yesterday!
| |
131 Label* if_false) { | |
132 // value && !(value & (value - 1)) | |
133 GotoIf(WordEqual(value, IntPtrConstant(0)), if_false); | |
134 Branch( | |
135 WordEqual(WordAnd(value, IntPtrSubWithOverflow(value, IntPtrConstant(1))), | |
136 IntPtrConstant(0)), | |
137 if_true, if_false); | |
138 } | |
139 | |
130 Node* CodeStubAssembler::Float64Round(Node* x) { | 140 Node* CodeStubAssembler::Float64Round(Node* x) { |
131 Node* one = Float64Constant(1.0); | 141 Node* one = Float64Constant(1.0); |
132 Node* one_half = Float64Constant(0.5); | 142 Node* one_half = Float64Constant(0.5); |
133 | 143 |
134 Variable var_x(this, MachineRepresentation::kFloat64); | 144 Variable var_x(this, MachineRepresentation::kFloat64); |
135 Label return_x(this); | 145 Label return_x(this); |
136 | 146 |
137 // Round up {x} towards Infinity. | 147 // Round up {x} towards Infinity. |
138 var_x.Bind(Float64Ceil(x)); | 148 var_x.Bind(Float64Ceil(x)); |
139 | 149 |
(...skipping 1513 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1653 AllocateFixedArray(elements_kind, length_intptr, parameter_mode); | 1663 AllocateFixedArray(elements_kind, length_intptr, parameter_mode); |
1654 StoreObjectField(result, JSArray::kElementsOffset, elements); | 1664 StoreObjectField(result, JSArray::kElementsOffset, elements); |
1655 | 1665 |
1656 // Fill in the elements with undefined. | 1666 // Fill in the elements with undefined. |
1657 FillFixedArrayWithValue(elements_kind, elements, zero, length_intptr, | 1667 FillFixedArrayWithValue(elements_kind, elements, zero, length_intptr, |
1658 Heap::kUndefinedValueRootIndex, parameter_mode); | 1668 Heap::kUndefinedValueRootIndex, parameter_mode); |
1659 | 1669 |
1660 return result; | 1670 return result; |
1661 } | 1671 } |
1662 | 1672 |
1673 Node* CodeStubAssembler::AllocateNameDictionary(int capacity) { | |
1674 return AllocateNameDictionary(IntPtrConstant(capacity)); | |
1675 } | |
1676 | |
1677 Node* CodeStubAssembler::AllocateNameDictionary(Node* capacity) { | |
1678 CSA_ASSERT(UintPtrLessThanOrEqual( | |
1679 capacity, IntPtrConstant(NameDictionary::kMaxCapacity))); | |
1680 #if defined(DEBUG) | |
1681 Label ok(this), not_ok(this); | |
1682 BranchIfWordIsPowerOfTwo(capacity, &ok, ¬_ok); | |
Igor Sheludko
2016/10/21 07:48:27
... and them this will just be CSA_ASSERT(IsPowerO
Camillo Bruni
2016/10/21 13:37:15
done.
| |
1683 Bind(¬_ok); | |
1684 DebugBreak(); | |
1685 Goto(&ok); | |
1686 Bind(&ok); | |
1687 #endif | |
1688 Node* length = EntryToIndex<NameDictionary>(capacity); | |
1689 Node* store_size = | |
Igor Sheludko
2016/10/21 07:48:27
Please follow USE_DEFAULT_MINIMUM_CAPACITY way of
Camillo Bruni
2016/10/21 13:37:15
Implemented HashTableComputeCapacity.
| |
1690 IntPtrAddFoldConstants(WordShl(length, IntPtrConstant(kPointerSizeLog2)), | |
1691 IntPtrConstant(NameDictionary::kHeaderSize)); | |
1692 | |
1693 Node* result = Allocate(store_size); | |
1694 // Initialize FixedArray fields. | |
1695 StoreObjectFieldRoot(result, Internals::kHeapObjectMapOffset, | |
1696 Heap::kHashTableMapRootIndex); | |
1697 StoreObjectFieldNoWriteBarrier(result, FixedArray::kLengthOffset, | |
1698 SmiFromWord(length)); | |
1699 // Initialized HashTable fields. | |
1700 Node* zero = SmiConstant(0); | |
Igor Sheludko
2016/10/21 07:48:27
Smi::kZero
Camillo Bruni
2016/10/21 13:37:15
I added the SmiConstant(int) given the frequent us
| |
1701 StoreObjectFieldNoWriteBarrier(result, | |
1702 NameDictionary::kNumberOfElementsOffset, zero); | |
1703 StoreObjectFieldNoWriteBarrier( | |
1704 result, NameDictionary::kNumberOfDeletedElementsOffset, zero); | |
1705 StoreObjectFieldNoWriteBarrier(result, NameDictionary::kCapacityOffset, | |
1706 SmiFromWord(capacity)); | |
1707 // Initialize Dictionary fields. | |
1708 Node* filler = LoadRoot(Heap::kUndefinedValueRootIndex); | |
1709 StoreObjectFieldNoWriteBarrier(result, NameDictionary::kMaxNumberKeyOffset, | |
1710 filler); | |
1711 StoreObjectFieldNoWriteBarrier(result, | |
1712 NameDictionary::kNextEnumerationIndexOffset, | |
1713 SmiConstant(PropertyDetails::kInitialIndex)); | |
1714 // Initialize NameDictionary elements. | |
1715 Node* start_address = IntPtrAdd( | |
1716 result, | |
1717 IntPtrConstant(NameDictionary::kElementsStartOffset - kHeapObjectTag)); | |
1718 Node* end_address = IntPtrAdd( | |
1719 result, | |
1720 IntPtrSubFoldConstants(store_size, IntPtrConstant(kHeapObjectTag))); | |
1721 StoreFieldsNoWriteBarrier(start_address, end_address, filler); | |
1722 return result; | |
1723 } | |
1724 | |
1663 Node* CodeStubAssembler::AllocateJSObjectFromMap(Node* map, Node* properties, | 1725 Node* CodeStubAssembler::AllocateJSObjectFromMap(Node* map, Node* properties, |
1664 Node* elements) { | 1726 Node* elements) { |
1665 Node* size = | 1727 Node* size = |
1666 IntPtrMul(LoadMapInstanceSize(map), IntPtrConstant(kPointerSize)); | 1728 IntPtrMul(LoadMapInstanceSize(map), IntPtrConstant(kPointerSize)); |
1667 CSA_ASSERT(IsRegularHeapObjectSize(size)); | 1729 CSA_ASSERT(IsRegularHeapObjectSize(size)); |
1668 Node* object = Allocate(size); | 1730 Node* object = Allocate(size); |
1669 StoreMapNoWriteBarrier(object, map); | 1731 StoreMapNoWriteBarrier(object, map); |
1670 InitializeJSObjectFromMap(object, map, size, properties, elements); | 1732 InitializeJSObjectFromMap(object, map, size, properties, elements); |
1671 return object; | 1733 return object; |
1672 } | 1734 } |
(...skipping 6656 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
8329 Node* buffer_bit_field = LoadObjectField( | 8391 Node* buffer_bit_field = LoadObjectField( |
8330 buffer, JSArrayBuffer::kBitFieldOffset, MachineType::Uint32()); | 8392 buffer, JSArrayBuffer::kBitFieldOffset, MachineType::Uint32()); |
8331 Node* was_neutered_mask = Int32Constant(JSArrayBuffer::WasNeutered::kMask); | 8393 Node* was_neutered_mask = Int32Constant(JSArrayBuffer::WasNeutered::kMask); |
8332 | 8394 |
8333 return Word32NotEqual(Word32And(buffer_bit_field, was_neutered_mask), | 8395 return Word32NotEqual(Word32And(buffer_bit_field, was_neutered_mask), |
8334 Int32Constant(0)); | 8396 Int32Constant(0)); |
8335 } | 8397 } |
8336 | 8398 |
8337 } // namespace internal | 8399 } // namespace internal |
8338 } // namespace v8 | 8400 } // namespace v8 |
OLD | NEW |