| Index: src/x64/code-stubs-x64.cc
|
| diff --git a/src/x64/code-stubs-x64.cc b/src/x64/code-stubs-x64.cc
|
| index 0e53eb390ed1bafc32a948c663c84e7b528f4650..af8d21beb571d267b8888d81076cccb875324c29 100644
|
| --- a/src/x64/code-stubs-x64.cc
|
| +++ b/src/x64/code-stubs-x64.cc
|
| @@ -2228,16 +2228,17 @@ static void EmitWrapCase(MacroAssembler* masm,
|
| }
|
|
|
|
|
| -void CallFunctionStub::Generate(MacroAssembler* masm) {
|
| +static void CallFunctionNoFeedback(MacroAssembler* masm,
|
| + int argc, bool needs_checks,
|
| + bool call_as_method) {
|
| // rdi : the function to call
|
|
|
| // wrap_and_call can only be true if we are compiling a monomorphic method.
|
| Isolate* isolate = masm->isolate();
|
| Label slow, non_function, wrap, cont;
|
| - int argc = argc_;
|
| StackArgumentsAccessor args(rsp, argc);
|
|
|
| - if (NeedsChecks()) {
|
| + if (needs_checks) {
|
| // Check that the function really is a JavaScript function.
|
| __ JumpIfSmi(rdi, &non_function);
|
|
|
| @@ -2249,15 +2250,15 @@ void CallFunctionStub::Generate(MacroAssembler* masm) {
|
| // Fast-case: Just invoke the function.
|
| ParameterCount actual(argc);
|
|
|
| - if (CallAsMethod()) {
|
| - if (NeedsChecks()) {
|
| + if (call_as_method) {
|
| + if (needs_checks) {
|
| EmitContinueIfStrictOrNative(masm, &cont);
|
| }
|
|
|
| // Load the receiver from the stack.
|
| __ movp(rax, args.GetReceiverOperand());
|
|
|
| - if (NeedsChecks()) {
|
| + if (needs_checks) {
|
| __ JumpIfSmi(rax, &wrap);
|
|
|
| __ CmpObjectType(rax, FIRST_SPEC_OBJECT_TYPE, rcx);
|
| @@ -2271,19 +2272,24 @@ void CallFunctionStub::Generate(MacroAssembler* masm) {
|
|
|
| __ InvokeFunction(rdi, actual, JUMP_FUNCTION, NullCallWrapper());
|
|
|
| - if (NeedsChecks()) {
|
| + if (needs_checks) {
|
| // Slow-case: Non-function called.
|
| __ bind(&slow);
|
| EmitSlowCase(isolate, masm, &args, argc, &non_function);
|
| }
|
|
|
| - if (CallAsMethod()) {
|
| + if (call_as_method) {
|
| __ bind(&wrap);
|
| EmitWrapCase(masm, &args, &cont);
|
| }
|
| }
|
|
|
|
|
| +void CallFunctionStub::Generate(MacroAssembler* masm) {
|
| + CallFunctionNoFeedback(masm, argc_, NeedsChecks(), CallAsMethod());
|
| +}
|
| +
|
| +
|
| void CallConstructStub::Generate(MacroAssembler* masm) {
|
| // rax : number of arguments
|
| // rbx : feedback vector
|
| @@ -2358,6 +2364,52 @@ static void EmitLoadTypeFeedbackVector(MacroAssembler* masm, Register vector) {
|
| }
|
|
|
|
|
| +void CallICStub::Generate_MonomorphicArray(MacroAssembler* masm, Label* miss) {
|
| + // rdi - function
|
| + // rbx - feedback vector
|
| + // rdx - slot id
|
| + __ LoadGlobalFunction(Context::ARRAY_FUNCTION_INDEX, rcx);
|
| + __ cmpq(rdi, rcx);
|
| + __ j(not_equal, miss);
|
| +
|
| + __ movq(rax, Immediate(arg_count()));
|
| + __ movp(rbx, FieldOperand(rbx, rdx, times_pointer_size,
|
| + FixedArray::kHeaderSize));
|
| +
|
| + // Verify that ecx contains an AllocationSite
|
| + __ AssertUndefinedOrAllocationSite(rbx);
|
| + ArrayConstructorStub stub(masm->isolate(), arg_count());
|
| + __ TailCallStub(&stub);
|
| +}
|
| +
|
| +
|
| +void CallICStub::Generate_CustomFeedbackCall(MacroAssembler* masm) {
|
| + // rdi - function
|
| + // rbx - feedback vector
|
| + // rdx - slot id
|
| + Label miss;
|
| +
|
| + if (state_.stub_type() == CallIC::MONOMORPHIC_ARRAY) {
|
| + Generate_MonomorphicArray(masm, &miss);
|
| + } else {
|
| + // So far there is only one customer for our custom feedback scheme.
|
| + UNREACHABLE();
|
| + }
|
| +
|
| + __ bind(&miss);
|
| + GenerateMiss(masm);
|
| +
|
| + // The slow case, we need this no matter what to complete a call after a miss.
|
| + CallFunctionNoFeedback(masm,
|
| + arg_count(),
|
| + true,
|
| + CallAsMethod());
|
| +
|
| + // Unreachable.
|
| + __ int3();
|
| +}
|
| +
|
| +
|
| void CallICStub::Generate(MacroAssembler* masm) {
|
| // rdi - function
|
| // rbx - vector
|
| @@ -2372,6 +2424,12 @@ void CallICStub::Generate(MacroAssembler* masm) {
|
|
|
| EmitLoadTypeFeedbackVector(masm, rbx);
|
|
|
| + // the MONOMORPHIC_ARRAY case is handled with a helper function.
|
| + if (state_.stub_type() != CallIC::DEFAULT) {
|
| + Generate_CustomFeedbackCall(masm);
|
| + return;
|
| + }
|
| +
|
| // The checks. First, does rdi match the recorded monomorphic target?
|
| __ SmiToInteger32(rdx, rdx);
|
| __ cmpq(rdi, FieldOperand(rbx, rdx, times_pointer_size,
|
|
|