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

Unified Diff: src/code-stubs.cc

Issue 2207553002: [stubs] Turn FastCloneRegExpStub into a TurboFan code stub. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Fix indexing. Created 4 years, 4 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-stubs.h ('k') | src/code-stubs-hydrogen.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/code-stubs.cc
diff --git a/src/code-stubs.cc b/src/code-stubs.cc
index d53f6531bbc601ce9e1024943211d0f87c33f0f9..35156345022a8ee800b93ccd8e2f6eebadfc2bc7 100644
--- a/src/code-stubs.cc
+++ b/src/code-stubs.cc
@@ -4157,14 +4157,6 @@ void NumberToStringStub::InitializeDescriptor(CodeStubDescriptor* descriptor) {
}
-void FastCloneRegExpStub::InitializeDescriptor(CodeStubDescriptor* descriptor) {
- FastCloneRegExpDescriptor call_descriptor(isolate());
- descriptor->Initialize(
- Runtime::FunctionForId(Runtime::kCreateRegExpLiteral)->entry);
- descriptor->SetMissHandler(Runtime::kCreateRegExpLiteral);
-}
-
-
void FastCloneShallowArrayStub::InitializeDescriptor(
CodeStubDescriptor* descriptor) {
FastCloneShallowArrayDescriptor call_descriptor(isolate());
@@ -4622,6 +4614,45 @@ void FastNewFunctionContextStub::GenerateAssembly(
assembler->Return(function_context);
}
+void FastCloneRegExpStub::GenerateAssembly(CodeStubAssembler* assembler) const {
+ typedef CodeStubAssembler::Label Label;
+ typedef compiler::Node Node;
+
+ Label call_runtime(assembler, Label::kDeferred);
+
+ Node* closure = assembler->Parameter(Descriptor::kClosure);
+ Node* literal_index = assembler->Parameter(Descriptor::kLiteralIndex);
+
+ Node* undefined = assembler->UndefinedConstant();
+ Node* literals_array =
+ assembler->LoadObjectField(closure, JSFunction::kLiteralsOffset);
+ Node* boilerplate = assembler->LoadFixedArrayElement(
+ literals_array, literal_index,
+ LiteralsArray::kFirstLiteralIndex * kPointerSize,
+ CodeStubAssembler::SMI_PARAMETERS);
+ assembler->GotoIf(assembler->WordEqual(boilerplate, undefined),
+ &call_runtime);
+
+ {
+ int size = JSRegExp::kSize + JSRegExp::kInObjectFieldCount * kPointerSize;
+ Node* copy = assembler->Allocate(size);
+ for (int offset = 0; offset < size; offset += kPointerSize) {
+ Node* value = assembler->LoadObjectField(boilerplate, offset);
+ assembler->StoreObjectFieldNoWriteBarrier(copy, offset, value);
+ }
+ assembler->Return(copy);
+ }
+
+ assembler->Bind(&call_runtime);
+ {
+ Node* context = assembler->Parameter(Descriptor::kContext);
+ Node* pattern = assembler->Parameter(Descriptor::kPattern);
+ Node* flags = assembler->Parameter(Descriptor::kFlags);
+ assembler->TailCallRuntime(Runtime::kCreateRegExpLiteral, context, closure,
+ literal_index, pattern, flags);
+ }
+}
+
void CreateAllocationSiteStub::GenerateAheadOfTime(Isolate* isolate) {
CreateAllocationSiteStub stub(isolate);
stub.GetCode();
« no previous file with comments | « src/code-stubs.h ('k') | src/code-stubs-hydrogen.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698