| Index: src/arm/stub-cache-arm.cc
|
| diff --git a/src/arm/stub-cache-arm.cc b/src/arm/stub-cache-arm.cc
|
| index b93d67ba2501cc35d8a770d31c07774387a7ed56..265265d591002ade05f68d778702faf41bc1b84f 100644
|
| --- a/src/arm/stub-cache-arm.cc
|
| +++ b/src/arm/stub-cache-arm.cc
|
| @@ -742,36 +742,6 @@ void StoreStubCompiler::GenerateRestoreName(MacroAssembler* masm,
|
| }
|
|
|
|
|
| -static void GenerateCallFunction(MacroAssembler* masm,
|
| - Handle<Object> object,
|
| - const ParameterCount& arguments,
|
| - Label* miss,
|
| - ExtraICState extra_ic_state) {
|
| - // ----------- S t a t e -------------
|
| - // -- r0: receiver
|
| - // -- r1: function to call
|
| - // -----------------------------------
|
| -
|
| - // Check that the function really is a function.
|
| - __ JumpIfSmi(r1, miss);
|
| - __ CompareObjectType(r1, r3, r3, JS_FUNCTION_TYPE);
|
| - __ b(ne, miss);
|
| -
|
| - if (object->IsGlobalObject()) {
|
| - const int argc = arguments.immediate();
|
| - const int receiver_offset = argc * kPointerSize;
|
| - __ ldr(r3, FieldMemOperand(r0, GlobalObject::kGlobalReceiverOffset));
|
| - __ str(r3, MemOperand(sp, receiver_offset));
|
| - }
|
| -
|
| - // Invoke the function.
|
| - CallKind call_kind = CallICBase::Contextual::decode(extra_ic_state)
|
| - ? CALL_AS_FUNCTION
|
| - : CALL_AS_METHOD;
|
| - __ InvokeFunction(r1, arguments, JUMP_FUNCTION, NullCallWrapper(), call_kind);
|
| -}
|
| -
|
| -
|
| static void PushInterceptorArguments(MacroAssembler* masm,
|
| Register receiver,
|
| Register holder,
|
| @@ -955,7 +925,7 @@ static void GenerateFastApiCall(MacroAssembler* masm,
|
|
|
| class CallInterceptorCompiler BASE_EMBEDDED {
|
| public:
|
| - CallInterceptorCompiler(StubCompiler* stub_compiler,
|
| + CallInterceptorCompiler(CallStubCompiler* stub_compiler,
|
| const ParameterCount& arguments,
|
| Register name,
|
| ExtraICState extra_ic_state)
|
| @@ -1067,13 +1037,8 @@ class CallInterceptorCompiler BASE_EMBEDDED {
|
| GenerateFastApiDirectCall(
|
| masm, optimization, arguments_.immediate(), false);
|
| } else {
|
| - CallKind call_kind = CallICBase::Contextual::decode(extra_ic_state_)
|
| - ? CALL_AS_FUNCTION
|
| - : CALL_AS_METHOD;
|
| Handle<JSFunction> function = optimization.constant_function();
|
| - ParameterCount expected(function);
|
| - __ InvokeFunction(function, expected, arguments_,
|
| - JUMP_FUNCTION, NullCallWrapper(), call_kind);
|
| + stub_compiler_->GenerateJumpFunctionIgnoreReceiver(function);
|
| }
|
|
|
| // Deferred code for fast API call case---clean preallocated space.
|
| @@ -1139,7 +1104,7 @@ class CallInterceptorCompiler BASE_EMBEDDED {
|
| __ b(ne, interceptor_succeeded);
|
| }
|
|
|
| - StubCompiler* stub_compiler_;
|
| + CallStubCompiler* stub_compiler_;
|
| const ParameterCount& arguments_;
|
| Register name_;
|
| ExtraICState extra_ic_state_;
|
| @@ -1541,6 +1506,15 @@ void CallStubCompiler::GenerateNameCheck(Handle<Name> name, Label* miss) {
|
| }
|
|
|
|
|
| +void CallStubCompiler::GenerateFunctionCheck(Register function,
|
| + Register scratch,
|
| + Label* miss) {
|
| + __ JumpIfSmi(function, miss);
|
| + __ CompareObjectType(function, scratch, scratch, JS_FUNCTION_TYPE);
|
| + __ b(ne, miss);
|
| +}
|
| +
|
| +
|
| void CallStubCompiler::GenerateLoadFunctionFromCell(
|
| Handle<Cell> cell,
|
| Handle<JSFunction> function,
|
| @@ -1556,9 +1530,7 @@ void CallStubCompiler::GenerateLoadFunctionFromCell(
|
| // the nice side effect that multiple closures based on the same
|
| // function can all use this call IC. Before we load through the
|
| // function, we have to verify that it still is a function.
|
| - __ JumpIfSmi(r1, miss);
|
| - __ CompareObjectType(r1, r3, r3, JS_FUNCTION_TYPE);
|
| - __ b(ne, miss);
|
| + GenerateFunctionCheck(r1, r3, miss);
|
|
|
| // Check the shared function info. Make sure it hasn't changed.
|
| __ Move(r3, Handle<SharedFunctionInfo>(function->shared()));
|
| @@ -1575,7 +1547,7 @@ void CallStubCompiler::GenerateMissBranch() {
|
| Handle<Code> code =
|
| isolate()->stub_cache()->ComputeCallMiss(arguments().immediate(),
|
| kind_,
|
| - extra_state_);
|
| + extra_state());
|
| __ Jump(code, RelocInfo::CODE_TARGET);
|
| }
|
|
|
| @@ -1590,8 +1562,7 @@ Handle<Code> CallStubCompiler::CompileCallField(Handle<JSObject> object,
|
| object, holder, name, RECEIVER_MAP_CHECK, &miss);
|
| GenerateFastPropertyLoad(masm(), r1, reg, index.is_inobject(holder),
|
| index.translate(holder), Representation::Tagged());
|
| -
|
| - GenerateCallFunction(masm(), object, arguments(), &miss, extra_state_);
|
| + GenerateJumpFunction(object, r1, &miss);
|
|
|
| HandlerFrontendFooter(&miss);
|
|
|
| @@ -1640,10 +1611,12 @@ Handle<Code> CallStubCompiler::CompileArrayPushCall(
|
| Handle<JSFunction> function,
|
| Handle<String> name,
|
| Code::StubType type) {
|
| - // If object is not an array or is observed, bail out to regular call.
|
| + // If object is not an array or is observed or sealed, bail out to regular
|
| + // call.
|
| if (!object->IsJSArray() ||
|
| !cell.is_null() ||
|
| - Handle<JSArray>::cast(object)->map()->is_observed()) {
|
| + Handle<JSArray>::cast(object)->map()->is_observed() ||
|
| + !Handle<JSArray>::cast(object)->map()->is_extensible()) {
|
| return Handle<Code>::null();
|
| }
|
|
|
| @@ -1883,10 +1856,12 @@ Handle<Code> CallStubCompiler::CompileArrayPopCall(
|
| Handle<JSFunction> function,
|
| Handle<String> name,
|
| Code::StubType type) {
|
| - // If object is not an array or is observed, bail out to regular call.
|
| + // If object is not an array or is observed or sealed, bail out to regular
|
| + // call.
|
| if (!object->IsJSArray() ||
|
| !cell.is_null() ||
|
| - Handle<JSArray>::cast(object)->map()->is_observed()) {
|
| + Handle<JSArray>::cast(object)->map()->is_observed() ||
|
| + !Handle<JSArray>::cast(object)->map()->is_extensible()) {
|
| return Handle<Code>::null();
|
| }
|
|
|
| @@ -1963,7 +1938,7 @@ Handle<Code> CallStubCompiler::CompileStringCharCodeAtCall(
|
| Label* index_out_of_range_label = &index_out_of_range;
|
|
|
| if (kind_ == Code::CALL_IC &&
|
| - (CallICBase::StringStubState::decode(extra_state_) ==
|
| + (CallICBase::StringStubState::decode(extra_state()) ==
|
| DEFAULT_STRING_STUB)) {
|
| index_out_of_range_label = &miss;
|
| }
|
| @@ -2006,8 +1981,7 @@ Handle<Code> CallStubCompiler::CompileStringCharCodeAtCall(
|
| __ bind(&miss);
|
| // Restore function name in r2.
|
| __ Move(r2, name);
|
| - __ bind(&name_miss);
|
| - GenerateMissBranch();
|
| + HandlerFrontendFooter(&name_miss);
|
|
|
| // Return the generated code.
|
| return GetCode(type, name);
|
| @@ -2030,7 +2004,7 @@ Handle<Code> CallStubCompiler::CompileStringCharAtCall(
|
| Label index_out_of_range;
|
| Label* index_out_of_range_label = &index_out_of_range;
|
| if (kind_ == Code::CALL_IC &&
|
| - (CallICBase::StringStubState::decode(extra_state_) ==
|
| + (CallICBase::StringStubState::decode(extra_state()) ==
|
| DEFAULT_STRING_STUB)) {
|
| index_out_of_range_label = &miss;
|
| }
|
| @@ -2073,8 +2047,7 @@ Handle<Code> CallStubCompiler::CompileStringCharAtCall(
|
| __ bind(&miss);
|
| // Restore function name in r2.
|
| __ Move(r2, name);
|
| - __ bind(&name_miss);
|
| - GenerateMissBranch();
|
| + HandlerFrontendFooter(&name_miss);
|
|
|
| // Return the generated code.
|
| return GetCode(type, name);
|
| @@ -2121,12 +2094,10 @@ Handle<Code> CallStubCompiler::CompileStringFromCharCodeCall(
|
| StubRuntimeCallHelper call_helper;
|
| generator.GenerateSlow(masm(), call_helper);
|
|
|
| - // Tail call the full function. We do not have to patch the receiver
|
| - // because the function makes no use of it.
|
| __ bind(&slow);
|
| - ParameterCount expected(function);
|
| - __ InvokeFunction(function, expected, arguments(),
|
| - JUMP_FUNCTION, NullCallWrapper(), CALL_AS_METHOD);
|
| + // We do not have to patch the receiver because the function makes no use of
|
| + // it.
|
| + GenerateJumpFunctionIgnoreReceiver(function);
|
|
|
| HandlerFrontendFooter(&miss);
|
|
|
| @@ -2214,11 +2185,9 @@ Handle<Code> CallStubCompiler::CompileMathFloorCall(
|
| __ Ret();
|
|
|
| __ bind(&slow);
|
| - // Tail call the full function. We do not have to patch the receiver
|
| - // because the function makes no use of it.
|
| - ParameterCount expected(function);
|
| - __ InvokeFunction(function, expected, arguments(),
|
| - JUMP_FUNCTION, NullCallWrapper(), CALL_AS_METHOD);
|
| + // We do not have to patch the receiver because the function makes no use of
|
| + // it.
|
| + GenerateJumpFunctionIgnoreReceiver(function);
|
|
|
| HandlerFrontendFooter(&miss);
|
|
|
| @@ -2296,12 +2265,10 @@ Handle<Code> CallStubCompiler::CompileMathAbsCall(
|
| __ Drop(argc + 1);
|
| __ Ret();
|
|
|
| - // Tail call the full function. We do not have to patch the receiver
|
| - // because the function makes no use of it.
|
| __ bind(&slow);
|
| - ParameterCount expected(function);
|
| - __ InvokeFunction(function, expected, arguments(),
|
| - JUMP_FUNCTION, NullCallWrapper(), CALL_AS_METHOD);
|
| + // We do not have to patch the receiver because the function makes no use of
|
| + // it.
|
| + GenerateJumpFunctionIgnoreReceiver(function);
|
|
|
| HandlerFrontendFooter(&miss);
|
|
|
| @@ -2354,8 +2321,7 @@ Handle<Code> CallStubCompiler::CompileFastApiCall(
|
| __ bind(&miss);
|
| FreeSpaceForFastApiCall(masm());
|
|
|
| - __ bind(&miss_before_stack_reserved);
|
| - GenerateMissBranch();
|
| + HandlerFrontendFooter(&miss_before_stack_reserved);
|
|
|
| // Return the generated code.
|
| return GetCode(function);
|
| @@ -2472,39 +2438,17 @@ Register CallStubCompiler::HandlerFrontendHeader(Handle<Object> object,
|
| }
|
|
|
|
|
| -void CallStubCompiler::CompileHandlerBackend(Handle<JSFunction> function) {
|
| - CallKind call_kind = CallICBase::Contextual::decode(extra_state_)
|
| - ? CALL_AS_FUNCTION
|
| - : CALL_AS_METHOD;
|
| - ParameterCount expected(function);
|
| - __ InvokeFunction(function, expected, arguments(),
|
| - JUMP_FUNCTION, NullCallWrapper(), call_kind);
|
| -}
|
| -
|
| -
|
| -Handle<Code> CallStubCompiler::CompileCallConstant(
|
| - Handle<Object> object,
|
| - Handle<JSObject> holder,
|
| - Handle<Name> name,
|
| - CheckType check,
|
| - Handle<JSFunction> function) {
|
| - if (HasCustomCallGenerator(function)) {
|
| - Handle<Code> code = CompileCustomCall(object, holder,
|
| - Handle<Cell>::null(),
|
| - function, Handle<String>::cast(name),
|
| - Code::FAST);
|
| - // A null handle means bail out to the regular compiler code below.
|
| - if (!code.is_null()) return code;
|
| - }
|
| -
|
| - Label miss;
|
| - HandlerFrontendHeader(object, holder, name, check, &miss);
|
| +void CallStubCompiler::GenerateJumpFunction(Handle<Object> object,
|
| + Register function,
|
| + Label* miss) {
|
| + ASSERT(function.is(r1));
|
| + // Check that the function really is a function.
|
| + GenerateFunctionCheck(function, r3, miss);
|
| PatchGlobalProxy(object);
|
| - CompileHandlerBackend(function);
|
| - HandlerFrontendFooter(&miss);
|
|
|
| - // Return the generated code.
|
| - return GetCode(function);
|
| + // Invoke the function.
|
| + __ InvokeFunction(r1, arguments(), JUMP_FUNCTION,
|
| + NullCallWrapper(), call_kind());
|
| }
|
|
|
|
|
| @@ -2522,7 +2466,7 @@ Handle<Code> CallStubCompiler::CompileCallInterceptor(Handle<JSObject> object,
|
| // Get the receiver from the stack.
|
| __ ldr(r1, MemOperand(sp, argc * kPointerSize));
|
|
|
| - CallInterceptorCompiler compiler(this, arguments(), r2, extra_state_);
|
| + CallInterceptorCompiler compiler(this, arguments(), r2, extra_state());
|
| compiler.Compile(masm(), object, holder, name, &lookup, r1, r3, r4, r0,
|
| &miss);
|
|
|
| @@ -2531,11 +2475,9 @@ Handle<Code> CallStubCompiler::CompileCallInterceptor(Handle<JSObject> object,
|
| // Restore receiver.
|
| __ ldr(r0, MemOperand(sp, argc * kPointerSize));
|
|
|
| - GenerateCallFunction(masm(), object, arguments(), &miss, extra_state_);
|
| + GenerateJumpFunction(object, r1, &miss);
|
|
|
| - // Handle call cache miss.
|
| - __ bind(&miss);
|
| - GenerateMissBranch();
|
| + HandlerFrontendFooter(&miss);
|
|
|
| // Return the generated code.
|
| return GetCode(Code::FAST, name);
|
| @@ -2558,26 +2500,13 @@ Handle<Code> CallStubCompiler::CompileCallGlobal(
|
|
|
| Label miss;
|
| HandlerFrontendHeader(object, holder, name, RECEIVER_MAP_CHECK, &miss);
|
| + // Potentially loads a closure that matches the shared function info of the
|
| + // function, rather than function.
|
| GenerateLoadFunctionFromCell(cell, function, &miss);
|
| - PatchGlobalProxy(object);
|
|
|
| - // Set up the context (function already in r1).
|
| - __ ldr(cp, FieldMemOperand(r1, JSFunction::kContextOffset));
|
| -
|
| - // Jump to the cached code (tail call).
|
| Counters* counters = isolate()->counters();
|
| __ IncrementCounter(counters->call_global_inline(), 1, r3, r4);
|
| - ParameterCount expected(function->shared()->formal_parameter_count());
|
| - CallKind call_kind = CallICBase::Contextual::decode(extra_state_)
|
| - ? CALL_AS_FUNCTION
|
| - : CALL_AS_METHOD;
|
| - // We call indirectly through the code field in the function to
|
| - // allow recompilation to take effect without changing any of the
|
| - // call sites.
|
| - __ ldr(r3, FieldMemOperand(r1, JSFunction::kCodeEntryOffset));
|
| - __ InvokeCode(r3, expected, arguments(), JUMP_FUNCTION,
|
| - NullCallWrapper(), call_kind);
|
| -
|
| + GenerateJumpFunction(object, r1, function);
|
| HandlerFrontendFooter(&miss);
|
|
|
| // Return the generated code.
|
|
|