Index: src/code-stub-assembler.cc |
diff --git a/src/code-stub-assembler.cc b/src/code-stub-assembler.cc |
index bc6477b005d77736f2536643d154504f8e2cca11..675d69ba9d85a6fd05e47a69cbf44164c2820a4b 100644 |
--- a/src/code-stub-assembler.cc |
+++ b/src/code-stub-assembler.cc |
@@ -127,6 +127,16 @@ Node* CodeStubAssembler::IntPtrSubFoldConstants(Node* left, Node* right) { |
return IntPtrSub(left, right); |
} |
+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!
|
+ Label* if_false) { |
+ // value && !(value & (value - 1)) |
+ GotoIf(WordEqual(value, IntPtrConstant(0)), if_false); |
+ Branch( |
+ WordEqual(WordAnd(value, IntPtrSubWithOverflow(value, IntPtrConstant(1))), |
+ IntPtrConstant(0)), |
+ if_true, if_false); |
+} |
+ |
Node* CodeStubAssembler::Float64Round(Node* x) { |
Node* one = Float64Constant(1.0); |
Node* one_half = Float64Constant(0.5); |
@@ -1660,6 +1670,58 @@ Node* CodeStubAssembler::AllocateRegExpResult(Node* context, Node* length, |
return result; |
} |
+Node* CodeStubAssembler::AllocateNameDictionary(int capacity) { |
+ return AllocateNameDictionary(IntPtrConstant(capacity)); |
+} |
+ |
+Node* CodeStubAssembler::AllocateNameDictionary(Node* capacity) { |
+ CSA_ASSERT(UintPtrLessThanOrEqual( |
+ capacity, IntPtrConstant(NameDictionary::kMaxCapacity))); |
+#if defined(DEBUG) |
+ Label ok(this), not_ok(this); |
+ 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.
|
+ Bind(¬_ok); |
+ DebugBreak(); |
+ Goto(&ok); |
+ Bind(&ok); |
+#endif |
+ Node* length = EntryToIndex<NameDictionary>(capacity); |
+ 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.
|
+ IntPtrAddFoldConstants(WordShl(length, IntPtrConstant(kPointerSizeLog2)), |
+ IntPtrConstant(NameDictionary::kHeaderSize)); |
+ |
+ Node* result = Allocate(store_size); |
+ // Initialize FixedArray fields. |
+ StoreObjectFieldRoot(result, Internals::kHeapObjectMapOffset, |
+ Heap::kHashTableMapRootIndex); |
+ StoreObjectFieldNoWriteBarrier(result, FixedArray::kLengthOffset, |
+ SmiFromWord(length)); |
+ // Initialized HashTable fields. |
+ 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
|
+ StoreObjectFieldNoWriteBarrier(result, |
+ NameDictionary::kNumberOfElementsOffset, zero); |
+ StoreObjectFieldNoWriteBarrier( |
+ result, NameDictionary::kNumberOfDeletedElementsOffset, zero); |
+ StoreObjectFieldNoWriteBarrier(result, NameDictionary::kCapacityOffset, |
+ SmiFromWord(capacity)); |
+ // Initialize Dictionary fields. |
+ Node* filler = LoadRoot(Heap::kUndefinedValueRootIndex); |
+ StoreObjectFieldNoWriteBarrier(result, NameDictionary::kMaxNumberKeyOffset, |
+ filler); |
+ StoreObjectFieldNoWriteBarrier(result, |
+ NameDictionary::kNextEnumerationIndexOffset, |
+ SmiConstant(PropertyDetails::kInitialIndex)); |
+ // Initialize NameDictionary elements. |
+ Node* start_address = IntPtrAdd( |
+ result, |
+ IntPtrConstant(NameDictionary::kElementsStartOffset - kHeapObjectTag)); |
+ Node* end_address = IntPtrAdd( |
+ result, |
+ IntPtrSubFoldConstants(store_size, IntPtrConstant(kHeapObjectTag))); |
+ StoreFieldsNoWriteBarrier(start_address, end_address, filler); |
+ return result; |
+} |
+ |
Node* CodeStubAssembler::AllocateJSObjectFromMap(Node* map, Node* properties, |
Node* elements) { |
Node* size = |