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

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

Issue 2384473002: [regexp] Port RegExpConstructResultStub to TurboFan (Closed)
Patch Set: Adapt to new constant accessor style Created 4 years, 2 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') | no next file with comments »
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 5295189a8e7816bdc7947828b3486554c0596e31..d05e07bd08bd463771e1cdeab64ee115df017808 100644
--- a/src/code-stub-assembler.cc
+++ b/src/code-stub-assembler.cc
@@ -1318,6 +1318,50 @@ Node* CodeStubAssembler::AllocateSlicedTwoByteString(Node* length, Node* parent,
return result;
}
+Node* CodeStubAssembler::AllocateRegExpResult(Node* context, Node* length,
+ Node* index, Node* input) {
+ Node* const max_length =
+ SmiConstant(Smi::FromInt(JSArray::kInitialMaxFastElementArray));
+ Assert(SmiLessThanOrEqual(length, max_length));
+
+ // Allocate the JSRegExpResult.
+ // TODO(jgruber): Fold JSArray and FixedArray allocations, then remove
+ // unneeded store of elements.
+ Node* const result = Allocate(JSRegExpResult::kSize);
+
+ // TODO(jgruber): Store map as Heap constant?
+ Node* const native_context = LoadNativeContext(context);
+ Node* const map =
+ LoadContextElement(native_context, Context::REGEXP_RESULT_MAP_INDEX);
+ StoreMapNoWriteBarrier(result, map);
+
+ // Initialize the header before allocating the elements.
+ Node* const empty_array = EmptyFixedArrayConstant();
+ DCHECK(Heap::RootIsImmortalImmovable(Heap::kEmptyFixedArrayRootIndex));
+ StoreObjectFieldNoWriteBarrier(result, JSArray::kPropertiesOffset,
+ empty_array);
+ StoreObjectFieldNoWriteBarrier(result, JSArray::kElementsOffset, empty_array);
+ StoreObjectFieldNoWriteBarrier(result, JSArray::kLengthOffset, length);
+
+ StoreObjectFieldNoWriteBarrier(result, JSRegExpResult::kIndexOffset, index);
+ StoreObjectField(result, JSRegExpResult::kInputOffset, input);
+
+ Node* const zero = IntPtrConstant(0);
+ Node* const length_intptr = SmiUntag(length);
+ const ElementsKind elements_kind = FAST_ELEMENTS;
+ const ParameterMode parameter_mode = INTPTR_PARAMETERS;
+
+ Node* const elements =
+ AllocateFixedArray(elements_kind, length_intptr, parameter_mode);
+ StoreObjectField(result, JSArray::kElementsOffset, elements);
+
+ // Fill in the elements with undefined.
+ FillFixedArrayWithValue(elements_kind, elements, zero, length_intptr,
+ Heap::kUndefinedValueRootIndex, parameter_mode);
+
+ return result;
+}
+
Node* CodeStubAssembler::AllocateUninitializedJSArrayWithoutElements(
ElementsKind kind, Node* array_map, Node* length, Node* allocation_site) {
Comment("begin allocation of JSArray without elements");
@@ -1408,7 +1452,7 @@ Node* CodeStubAssembler::AllocateFixedArray(ElementsKind kind,
Node* capacity_node,
ParameterMode mode,
AllocationFlags flags) {
- Node* total_size = GetFixedAarrayAllocationSize(capacity_node, kind, mode);
+ Node* total_size = GetFixedArrayAllocationSize(capacity_node, kind, mode);
// Allocate both array and elements object, and initialize the JSArray.
Node* array = Allocate(total_size, flags);
« no previous file with comments | « src/code-stub-assembler.h ('k') | src/code-stubs.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698