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

Unified Diff: src/code-stub-assembler.cc

Issue 2304573004: Port FastCloneShallowArrayStub to Turbofan (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: cleanup mode a bit 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/code-stub-assembler.h ('k') | src/code-stubs.h » ('j') | src/code-stubs.h » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/code-stub-assembler.cc
diff --git a/src/code-stub-assembler.cc b/src/code-stub-assembler.cc
index 833b4b20ead9bf58d4b0a06ee172b0a7356875bd..f4284534e6883d175e70aaaead5bcf3f1927ecc6 100644
--- a/src/code-stub-assembler.cc
+++ b/src/code-stub-assembler.cc
@@ -46,6 +46,14 @@ Node* CodeStubAssembler::EmptyStringConstant() {
return LoadRoot(Heap::kempty_stringRootIndex);
}
+Node* CodeStubAssembler::FixedArrayMapConstant() {
+ return HeapConstant(isolate()->factory()->fixed_array_map());
+}
+
+Node* CodeStubAssembler::FixedCowArrayMapConstant() {
+ return HeapConstant(isolate()->factory()->fixed_cow_array_map());
+}
+
Node* CodeStubAssembler::HeapNumberMapConstant() {
return LoadRoot(Heap::kHeapNumberMapRootIndex);
}
@@ -1000,6 +1008,10 @@ Node* CodeStubAssembler::LoadElements(Node* object) {
return LoadObjectField(object, JSObject::kElementsOffset);
}
+Node* CodeStubAssembler::LoadJSArrayLength(compiler::Node* array) {
+ return LoadObjectField(array, JSArray::kLengthOffset);
+}
+
Node* CodeStubAssembler::LoadFixedArrayBaseLength(compiler::Node* array) {
return LoadObjectField(array, FixedArrayBase::kLengthOffset);
}
@@ -1366,49 +1378,78 @@ Node* CodeStubAssembler::AllocateSeqTwoByteString(Node* context, Node* length) {
return var_result.value();
}
-Node* CodeStubAssembler::AllocateJSArray(ElementsKind kind, Node* array_map,
- Node* capacity_node, Node* length_node,
- compiler::Node* allocation_site,
- ParameterMode mode) {
- bool is_double = IsFastDoubleElementsKind(kind);
- int base_size = JSArray::kSize + FixedArray::kHeaderSize;
- int elements_offset = JSArray::kSize;
-
+Node* CodeStubAssembler::AllocateEmptyJSArray(ElementsKind kind,
rmcilroy 2016/09/13 20:29:59 Maybe we should call this something like AllocateU
klaasb 2016/09/14 18:24:51 Done.
+ Node* array_map, Node* length,
+ Node* allocation_site,
+ ParameterMode mode,
+ Node* capacity) {
Comment("begin allocation of JSArray");
+ int base_size = JSArray::kSize;
+
if (allocation_site != nullptr) {
base_size += AllocationMemento::kSize;
- elements_offset += AllocationMemento::kSize;
}
- Node* total_size =
- ElementOffsetFromIndex(capacity_node, kind, mode, base_size);
+ int elements_offset = base_size;
+ Node* total_size;
+
+ // Compute space for elements if capacity is not null.
+ if (capacity != nullptr) {
+ base_size += FixedArray::kHeaderSize;
+ total_size = ElementOffsetFromIndex(capacity, kind, mode, base_size);
+ } else {
+ total_size = IntPtrConstant(base_size);
+ }
// Allocate both array and elements object, and initialize the JSArray.
- Heap* heap = isolate()->heap();
Node* array = Allocate(total_size);
+
StoreMapNoWriteBarrier(array, array_map);
- Node* empty_properties = LoadRoot(Heap::kEmptyFixedArrayRootIndex);
- StoreObjectFieldNoWriteBarrier(array, JSArray::kPropertiesOffset,
- empty_properties);
+
StoreObjectFieldNoWriteBarrier(array, JSArray::kLengthOffset,
- TagParameter(length_node, mode));
+ TagParameter(length, mode));
+
+ StoreObjectFieldRoot(array, JSArray::kPropertiesOffset,
+ Heap::kEmptyFixedArrayRootIndex);
+
+ if (capacity != nullptr) {
+ Node* elements = InnerAllocate(array, elements_offset);
+ StoreObjectField(array, JSObject::kElementsOffset, elements);
+ }
if (allocation_site != nullptr) {
InitializeAllocationMemento(array, JSArray::kSize, allocation_site);
}
- // Setup elements object.
+ return array;
+}
+
+Node* CodeStubAssembler::AllocateFilledJSArray(ElementsKind kind,
+ Node* array_map, Node* capacity,
+ Node* length,
+ Node* allocation_site,
+ ParameterMode mode) {
+ bool is_double = IsFastDoubleElementsKind(kind);
+ int elements_offset =
+ JSArray::kSize +
+ (allocation_site != nullptr ? AllocationMemento::kSize : 0);
+
+ // Allocate both array and elements object, and initialize the JSArray.
+ Node* array = AllocateEmptyJSArray(kind, array_map, length, allocation_site,
+ mode, capacity);
Node* elements = InnerAllocate(array, elements_offset);
rmcilroy 2016/09/13 20:29:58 Do you do this twice? There is an InnerAllocate fo
klaasb 2016/09/14 18:24:51 We still want to allocate space for the array and
- StoreObjectFieldNoWriteBarrier(array, JSArray::kElementsOffset, elements);
+
+ // Setup elements object.
+ Heap* heap = isolate()->heap();
Handle<Map> elements_map(is_double ? heap->fixed_double_array_map()
: heap->fixed_array_map());
StoreMapNoWriteBarrier(elements, HeapConstant(elements_map));
StoreObjectFieldNoWriteBarrier(elements, FixedArray::kLengthOffset,
- TagParameter(capacity_node, mode));
+ TagParameter(capacity, mode));
// Fill in the elements with holes.
- FillFixedArrayWithValue(kind, elements, IntPtrConstant(0), capacity_node,
+ FillFixedArrayWithValue(kind, elements, IntPtrConstant(0), capacity,
Heap::kTheHoleValueRootIndex, mode);
return array;
@@ -3860,7 +3901,7 @@ void CodeStubAssembler::EmitFastElementsBoundsCheck(Node* object,
}
Bind(&if_array);
{
- var_length.Bind(SmiUntag(LoadObjectField(object, JSArray::kLengthOffset)));
+ var_length.Bind(SmiUntag(LoadJSArrayLength(object)));
Goto(&length_loaded);
}
Bind(&length_loaded);
« no previous file with comments | « src/code-stub-assembler.h ('k') | src/code-stubs.h » ('j') | src/code-stubs.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698