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-stubs.cc

Issue 2607563002: [builtins] FastNewClosureStub becomes a builtin. (Closed)
Patch Set: Renames. Created 4 years 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/compiler/js-generic-lowering.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 2e03cf5ca076a56d47f762c53c887140c8ba4c19..bfa5294b04e2cf7375f4deff2225c97ab2d937ef 100644
--- a/src/code-stubs.cc
+++ b/src/code-stubs.cc
@@ -2330,161 +2330,6 @@ void GetPropertyStub::GenerateAssembly(
assembler.Return(var_result.value());
}
-// static
-compiler::Node* FastNewClosureStub::Generate(CodeStubAssembler* assembler,
- compiler::Node* shared_info,
- compiler::Node* context) {
- typedef compiler::Node Node;
- typedef compiler::CodeAssembler::Label Label;
- typedef compiler::CodeAssembler::Variable Variable;
-
- 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);
-
- // Calculate the index of the map we should install on the function based on
- // the FunctionKind and LanguageMode of the function.
- // Note: Must be kept in sync with Context::FunctionMapIndex
- Node* compiler_hints = assembler->LoadObjectField(
- shared_info, SharedFunctionInfo::kCompilerHintsOffset,
- MachineType::Uint32());
- Node* is_strict = assembler->Word32And(
- compiler_hints,
- assembler->Int32Constant(1 << SharedFunctionInfo::kStrictModeBit));
-
- Label if_normal(assembler), if_generator(assembler), if_async(assembler),
- if_class_constructor(assembler), if_function_without_prototype(assembler),
- load_map(assembler);
- Variable map_index(assembler, MachineType::PointerRepresentation());
-
- STATIC_ASSERT(FunctionKind::kNormalFunction == 0);
- Node* is_not_normal = assembler->Word32And(
- compiler_hints,
- assembler->Int32Constant(SharedFunctionInfo::kAllFunctionKindBitsMask));
- assembler->GotoUnless(is_not_normal, &if_normal);
-
- Node* is_generator = assembler->Word32And(
- compiler_hints,
- assembler->Int32Constant(FunctionKind::kGeneratorFunction
- << SharedFunctionInfo::kFunctionKindShift));
- assembler->GotoIf(is_generator, &if_generator);
-
- Node* is_async = assembler->Word32And(
- compiler_hints,
- assembler->Int32Constant(FunctionKind::kAsyncFunction
- << SharedFunctionInfo::kFunctionKindShift));
- assembler->GotoIf(is_async, &if_async);
-
- Node* is_class_constructor = assembler->Word32And(
- compiler_hints,
- assembler->Int32Constant(FunctionKind::kClassConstructor
- << SharedFunctionInfo::kFunctionKindShift));
- assembler->GotoIf(is_class_constructor, &if_class_constructor);
-
- if (FLAG_debug_code) {
- // Function must be a function without a prototype.
- CSA_ASSERT(assembler, assembler->Word32And(
- compiler_hints,
- assembler->Int32Constant(
- (FunctionKind::kAccessorFunction |
- FunctionKind::kArrowFunction |
- FunctionKind::kConciseMethod)
- << SharedFunctionInfo::kFunctionKindShift)));
- }
- assembler->Goto(&if_function_without_prototype);
-
- assembler->Bind(&if_normal);
- {
- map_index.Bind(assembler->SelectIntPtrConstant(
- is_strict, Context::STRICT_FUNCTION_MAP_INDEX,
- Context::SLOPPY_FUNCTION_MAP_INDEX));
- assembler->Goto(&load_map);
- }
-
- assembler->Bind(&if_generator);
- {
- map_index.Bind(assembler->SelectIntPtrConstant(
- is_strict, Context::STRICT_GENERATOR_FUNCTION_MAP_INDEX,
- Context::SLOPPY_GENERATOR_FUNCTION_MAP_INDEX));
- assembler->Goto(&load_map);
- }
-
- assembler->Bind(&if_async);
- {
- map_index.Bind(assembler->SelectIntPtrConstant(
- is_strict, Context::STRICT_ASYNC_FUNCTION_MAP_INDEX,
- Context::SLOPPY_ASYNC_FUNCTION_MAP_INDEX));
- assembler->Goto(&load_map);
- }
-
- assembler->Bind(&if_class_constructor);
- {
- map_index.Bind(
- assembler->IntPtrConstant(Context::CLASS_FUNCTION_MAP_INDEX));
- assembler->Goto(&load_map);
- }
-
- assembler->Bind(&if_function_without_prototype);
- {
- map_index.Bind(assembler->IntPtrConstant(
- Context::STRICT_FUNCTION_WITHOUT_PROTOTYPE_MAP_INDEX));
- assembler->Goto(&load_map);
- }
-
- assembler->Bind(&load_map);
-
- // 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.value());
- 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);
- 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(
- assembler->BitcastTaggedToWord(lazy_builtin),
- assembler->IntPtrConstant(Code::kHeaderSize - kHeapObjectTag));
- assembler->StoreObjectFieldNoWriteBarrier(
- result, JSFunction::kCodeEntryOffset, lazy_builtin_entry,
- MachineType::PointerRepresentation());
- assembler->StoreObjectFieldNoWriteBarrier(result,
- JSFunction::kNextFunctionLinkOffset,
- assembler->UndefinedConstant());
-
- return result;
-}
-
-void FastNewClosureStub::GenerateAssembly(
- compiler::CodeAssemblerState* state) const {
- typedef compiler::Node Node;
- CodeStubAssembler assembler(state);
- Node* shared = assembler.Parameter(Descriptor::kSharedFunctionInfo);
- Node* context = assembler.Parameter(Descriptor::kContext);
- assembler.Return(Generate(&assembler, shared, context));
-}
// static
int FastNewFunctionContextStub::MaximumSlots() {
« no previous file with comments | « src/code-stubs.h ('k') | src/compiler/js-generic-lowering.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698