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

Unified Diff: src/code-stubs.cc

Issue 2100883003: [Code Stubs] Convert FastNewClosureStub to a TurboFanCodeStub. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 6 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
Index: src/code-stubs.cc
diff --git a/src/code-stubs.cc b/src/code-stubs.cc
index a4d91a9fa23b2de35911a4e3fa85754b5cdc957b..f3a8b73128b908019ac9662b12f5e16489e335e5 100644
--- a/src/code-stubs.cc
+++ b/src/code-stubs.cc
@@ -4189,14 +4189,10 @@ ElementsTransitionAndStoreStub::GetCallInterfaceDescriptor() const {
return VectorStoreTransitionDescriptor(isolate());
}
-void FastNewClosureStub::InitializeDescriptor(CodeStubDescriptor* descriptor) {}
-
void FastNewContextStub::InitializeDescriptor(CodeStubDescriptor* d) {}
-
void TypeofStub::InitializeDescriptor(CodeStubDescriptor* descriptor) {}
-
void NumberToStringStub::InitializeDescriptor(CodeStubDescriptor* descriptor) {
descriptor->Initialize(
Runtime::FunctionForId(Runtime::kNumberToString)->entry);
@@ -4425,6 +4421,70 @@ compiler::Node* HasPropertyStub::Generate(CodeStubAssembler* assembler,
return result.value();
}
+// static
+compiler::Node* FastNewClosureStub::Generate(CodeStubAssembler* assembler,
+ compiler::Node* shared_info,
+ compiler::Node* context,
+ compiler::Node* map_index) {
+ typedef compiler::Node Node;
+
+ Isolate* isolate = assembler->isolate();
+ Factory* factory = assembler->isolate()->factory();
+ assembler->IncrementCounter(isolate->counters()->fast_new_closure_total(), 1);
+
+ // Create a new closure from the given function info in new space
+ Node* result = assembler->Allocate(JSFunction::kSize);
+
+ // Get the function map in the current native context and set that
+ // as the map of the allocated object.
+ Node* native_context = assembler->LoadNativeContext(context);
+ Node* map_slot_value =
+ assembler->LoadFixedArrayElement(native_context, map_index);
+ assembler->StoreMapNoWriteBarrier(result, map_slot_value);
+
+ // Initialize the rest of the function.
+ Node* empty_fixed_array =
+ assembler->HeapConstant(factory->empty_fixed_array());
+ Node* empty_literals_array =
+ assembler->HeapConstant(factory->empty_literals_array());
+ assembler->StoreObjectFieldNoWriteBarrier(result, JSObject::kPropertiesOffset,
+ empty_fixed_array);
+ assembler->StoreObjectFieldNoWriteBarrier(result, JSObject::kElementsOffset,
+ empty_fixed_array);
+ assembler->StoreObjectFieldNoWriteBarrier(result, JSFunction::kLiteralsOffset,
+ empty_literals_array);
+ assembler->StoreObjectFieldNoWriteBarrier(
+ result, JSFunction::kPrototypeOrInitialMapOffset,
+ assembler->TheHoleConstant());
+ assembler->StoreObjectFieldNoWriteBarrier(
+ result, JSFunction::kSharedFunctionInfoOffset, shared_info);
+ assembler->StoreObjectFieldNoWriteBarrier(result, JSFunction::kContextOffset,
+ context);
+
+ // TODO(rmcilroy): Should we set the code entry from the SharedFunctionInfo
+ // instead? For eager compilation this would seem preferable.
+ Handle<Code> lazy_builtin_handle(
+ assembler->isolate()->builtins()->builtin(Builtins::kCompileLazy));
+ Node* lazy_builtin = assembler->HeapConstant(lazy_builtin_handle);
+ Node* lazy_builtin_entry = assembler->IntPtrAdd(
+ lazy_builtin,
+ assembler->IntPtrConstant(Code::kHeaderSize - kHeapObjectTag));
+ assembler->StoreObjectFieldNoWriteBarrier(
+ result, JSFunction::kCodeEntryOffset, lazy_builtin_entry);
+ assembler->StoreObjectFieldNoWriteBarrier(result,
+ JSFunction::kNextFunctionLinkOffset,
+ assembler->UndefinedConstant());
+
+ return result;
+}
+
+void FastNewClosureStub::GenerateAssembly(CodeStubAssembler* assembler) const {
+ int map_index = Context::FunctionMapIndex(language_mode(), kind());
+ assembler->Return(Generate(assembler, assembler->Parameter(0),
+ assembler->Parameter(1),
+ assembler->Int32Constant(map_index)));
+}
+
void CreateAllocationSiteStub::GenerateAheadOfTime(Isolate* isolate) {
CreateAllocationSiteStub stub(isolate);
stub.GetCode();
« src/code-stubs.h ('K') | « 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