| Index: src/x64/code-stubs-x64.cc
|
| diff --git a/src/x64/code-stubs-x64.cc b/src/x64/code-stubs-x64.cc
|
| index 095113c40da56f397fbecbdc8f8b6d261ee38295..6f4d81d584db4fd54f6ddf86697c3bca10e89487 100644
|
| --- a/src/x64/code-stubs-x64.cc
|
| +++ b/src/x64/code-stubs-x64.cc
|
| @@ -62,6 +62,40 @@ void TransitionElementsKindStub::InitializeInterfaceDescriptor(
|
| }
|
|
|
|
|
| +static void InitializeArrayConstructorDescriptor(Isolate* isolate,
|
| + CodeStubInterfaceDescriptor* descriptor) {
|
| + static Register registers[] = { rdi, rbx };
|
| + descriptor->register_param_count_ = 2;
|
| + // stack param count needs (constructor pointer, and single argument)
|
| + descriptor->stack_parameter_count_ = &rax;
|
| + descriptor->register_params_ = registers;
|
| + descriptor->extra_expression_stack_count_ = 1;
|
| + descriptor->deoptimization_handler_ =
|
| + FUNCTION_ADDR(ArrayConstructor_StubFailure);
|
| +}
|
| +
|
| +
|
| +void ArrayNoArgumentConstructorStub::InitializeInterfaceDescriptor(
|
| + Isolate* isolate,
|
| + CodeStubInterfaceDescriptor* descriptor) {
|
| + InitializeArrayConstructorDescriptor(isolate, descriptor);
|
| +}
|
| +
|
| +
|
| +void ArraySingleArgumentConstructorStub::InitializeInterfaceDescriptor(
|
| + Isolate* isolate,
|
| + CodeStubInterfaceDescriptor* descriptor) {
|
| + InitializeArrayConstructorDescriptor(isolate, descriptor);
|
| +}
|
| +
|
| +
|
| +void ArrayNArgumentsConstructorStub::InitializeInterfaceDescriptor(
|
| + Isolate* isolate,
|
| + CodeStubInterfaceDescriptor* descriptor) {
|
| + InitializeArrayConstructorDescriptor(isolate, descriptor);
|
| +}
|
| +
|
| +
|
| #define __ ACCESS_MASM(masm)
|
|
|
| void ToNumberStub::Generate(MacroAssembler* masm) {
|
| @@ -3876,7 +3910,7 @@ static void GenerateRecordCallTarget(MacroAssembler* masm) {
|
| // rbx : cache cell for call target
|
| // rdi : the function to call
|
| Isolate* isolate = masm->isolate();
|
| - Label initialize, done;
|
| + Label initialize, done, miss, megamorphic, not_array_function;
|
|
|
| // Load the cache state into rcx.
|
| __ movq(rcx, FieldOperand(rbx, JSGlobalPropertyCell::kValueOffset));
|
| @@ -3884,22 +3918,66 @@ static void GenerateRecordCallTarget(MacroAssembler* masm) {
|
| // A monomorphic cache hit or an already megamorphic state: invoke the
|
| // function without changing the state.
|
| __ cmpq(rcx, rdi);
|
| - __ j(equal, &done, Label::kNear);
|
| + __ j(equal, &done, Label::kFar);
|
| __ Cmp(rcx, TypeFeedbackCells::MegamorphicSentinel(isolate));
|
| - __ j(equal, &done, Label::kNear);
|
| + __ j(equal, &done, Label::kFar);
|
| +
|
| + // Special handling of the Array() function, which caches not only the
|
| + // monomorphic Array function but the initial ElementsKind with special
|
| + // sentinels
|
| + Handle<Object> terminal_kind_sentinel =
|
| + TypeFeedbackCells::MonomorphicArraySentinel(LAST_FAST_ELEMENTS_KIND);
|
| + __ Cmp(rcx, terminal_kind_sentinel);
|
| + __ j(not_equal, &miss, Label::kFar);
|
| + // Load the global or builtins object from the current context
|
| + __ movq(rcx, Operand(rsi, Context::SlotOffset(Context::GLOBAL_OBJECT_INDEX)));
|
| + __ movq(rcx, FieldOperand(rcx, GlobalObject::kGlobalContextOffset));
|
| + __ movq(rcx,
|
| + Operand(rcx, Context::SlotOffset(Context::ARRAY_FUNCTION_INDEX)));
|
| + // Make sure the function is the Array() function
|
| + __ cmpq(rdi, rcx);
|
| + Label megamorphic_pre;
|
| + __ j(not_equal, &megamorphic_pre, Label::kFar);
|
| + __ jmp(&done);
|
| +
|
| + __ bind(&megamorphic_pre);
|
| + __ jmp(&megamorphic, Label::kFar);
|
| +
|
| + __ bind(&miss);
|
|
|
| // A monomorphic miss (i.e, here the cache is not uninitialized) goes
|
| // megamorphic.
|
| __ Cmp(rcx, TypeFeedbackCells::UninitializedSentinel(isolate));
|
| - __ j(equal, &initialize, Label::kNear);
|
| + __ j(equal, &initialize, Label::kFar);
|
| // MegamorphicSentinel is an immortal immovable object (undefined) so no
|
| // write-barrier is needed.
|
| + __ bind(&megamorphic);
|
| __ Move(FieldOperand(rbx, JSGlobalPropertyCell::kValueOffset),
|
| TypeFeedbackCells::MegamorphicSentinel(isolate));
|
| __ jmp(&done, Label::kNear);
|
|
|
| - // An uninitialized cache is patched with the function.
|
| + // An uninitialized cache is patched with the function or sentinel to
|
| + // indicate the ElementsKind if function is the Array constructor.
|
| __ bind(&initialize);
|
| + __ movq(rcx, Operand(rsi, Context::SlotOffset(Context::GLOBAL_OBJECT_INDEX)));
|
| + __ movq(rcx, FieldOperand(rcx, GlobalObject::kGlobalContextOffset));
|
| + __ movq(rcx,
|
| + Operand(rcx, Context::SlotOffset(Context::ARRAY_FUNCTION_INDEX)));
|
| + // Make sure the function is the Array() function
|
| + __ cmpq(rdi, rcx);
|
| + __ j(not_equal, ¬_array_function);
|
| +
|
| + // The target function is the Array constructor, install a sentinel value in
|
| + // the constructor's type info cell that will track the initial ElementsKind
|
| + // that should be used for the array when its constructed.
|
| + Handle<Object> initial_kind_sentinel =
|
| + TypeFeedbackCells::MonomorphicArraySentinel(
|
| + GetInitialFastElementsKind());
|
| + __ Move(FieldOperand(rbx, JSGlobalPropertyCell::kValueOffset),
|
| + initial_kind_sentinel);
|
| + __ jmp(&done);
|
| +
|
| + __ bind(¬_array_function);
|
| __ movq(FieldOperand(rbx, JSGlobalPropertyCell::kValueOffset), rdi);
|
| // No need for a write barrier here - cells are rescanned.
|
|
|
| @@ -4017,10 +4095,10 @@ void CallConstructStub::Generate(MacroAssembler* masm) {
|
| }
|
|
|
| // Jump to the function-specific construct stub.
|
| - __ movq(rbx, FieldOperand(rdi, JSFunction::kSharedFunctionInfoOffset));
|
| - __ movq(rbx, FieldOperand(rbx, SharedFunctionInfo::kConstructStubOffset));
|
| - __ lea(rbx, FieldOperand(rbx, Code::kHeaderSize));
|
| - __ jmp(rbx);
|
| + __ movq(rcx, FieldOperand(rdi, JSFunction::kSharedFunctionInfoOffset));
|
| + __ movq(rcx, FieldOperand(rcx, SharedFunctionInfo::kConstructStubOffset));
|
| + __ lea(rcx, FieldOperand(rcx, Code::kHeaderSize));
|
| + __ jmp(rcx);
|
|
|
| // rdi: called object
|
| // rax: number of arguments
|
|
|