Commit dae36594 authored by sgjesse@chromium.org's avatar sgjesse@chromium.org

MIPS: port Fix a number of IC stubs to correctly set the call kind.

Ported r8109 (7ab86acc) to mips.

Original commit message:
Make the call kind and call wrapper arguments explicit to force
developers to make a choice. This would have avoided the bug in the
first case.

BUG=
TEST=

Review URL: http://codereview.chromium.org//7006021

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@8136 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent ad55fbc3
...@@ -942,10 +942,11 @@ static void Generate_JSConstructStubHelper(MacroAssembler* masm, ...@@ -942,10 +942,11 @@ static void Generate_JSConstructStubHelper(MacroAssembler* masm,
masm->isolate()->builtins()->HandleApiCallConstruct(); masm->isolate()->builtins()->HandleApiCallConstruct();
ParameterCount expected(0); ParameterCount expected(0);
__ InvokeCode(code, expected, expected, __ InvokeCode(code, expected, expected,
RelocInfo::CODE_TARGET, CALL_FUNCTION); RelocInfo::CODE_TARGET, CALL_FUNCTION, CALL_AS_METHOD);
} else { } else {
ParameterCount actual(a0); ParameterCount actual(a0);
__ InvokeFunction(a1, actual, CALL_FUNCTION); __ InvokeFunction(a1, actual, CALL_FUNCTION,
NullCallWrapper(), CALL_AS_METHOD);
} }
// Pop the function from the stack. // Pop the function from the stack.
...@@ -1078,7 +1079,8 @@ static void Generate_JSEntryTrampolineHelper(MacroAssembler* masm, ...@@ -1078,7 +1079,8 @@ static void Generate_JSEntryTrampolineHelper(MacroAssembler* masm,
RelocInfo::CODE_TARGET); RelocInfo::CODE_TARGET);
} else { } else {
ParameterCount actual(a0); ParameterCount actual(a0);
__ InvokeFunction(a1, actual, CALL_FUNCTION); __ InvokeFunction(a1, actual, CALL_FUNCTION,
NullCallWrapper(), CALL_AS_METHOD);
} }
__ LeaveInternalFrame(); __ LeaveInternalFrame();
...@@ -1338,7 +1340,8 @@ void Builtins::Generate_FunctionCall(MacroAssembler* masm) { ...@@ -1338,7 +1340,8 @@ void Builtins::Generate_FunctionCall(MacroAssembler* masm) {
RelocInfo::CODE_TARGET, ne, a2, Operand(a0)); RelocInfo::CODE_TARGET, ne, a2, Operand(a0));
ParameterCount expected(0); ParameterCount expected(0);
__ InvokeCode(a3, expected, expected, JUMP_FUNCTION); __ InvokeCode(a3, expected, expected, JUMP_FUNCTION,
NullCallWrapper(), CALL_AS_METHOD);
} }
...@@ -1471,7 +1474,8 @@ void Builtins::Generate_FunctionApply(MacroAssembler* masm) { ...@@ -1471,7 +1474,8 @@ void Builtins::Generate_FunctionApply(MacroAssembler* masm) {
ParameterCount actual(a0); ParameterCount actual(a0);
__ sra(a0, a0, kSmiTagSize); __ sra(a0, a0, kSmiTagSize);
__ lw(a1, MemOperand(fp, kFunctionOffset)); __ lw(a1, MemOperand(fp, kFunctionOffset));
__ InvokeFunction(a1, actual, CALL_FUNCTION); __ InvokeFunction(a1, actual, CALL_FUNCTION,
NullCallWrapper(), CALL_AS_METHOD);
// Tear down the internal frame and remove function, receiver and args. // Tear down the internal frame and remove function, receiver and args.
__ LeaveInternalFrame(); __ LeaveInternalFrame();
......
...@@ -4710,7 +4710,11 @@ void CallFunctionStub::Generate(MacroAssembler* masm) { ...@@ -4710,7 +4710,11 @@ void CallFunctionStub::Generate(MacroAssembler* masm) {
Label call_as_function; Label call_as_function;
__ LoadRoot(at, Heap::kTheHoleValueRootIndex); __ LoadRoot(at, Heap::kTheHoleValueRootIndex);
__ Branch(&call_as_function, eq, t0, Operand(at)); __ Branch(&call_as_function, eq, t0, Operand(at));
__ InvokeFunction(a1, actual, JUMP_FUNCTION); __ InvokeFunction(a1,
actual,
JUMP_FUNCTION,
NullCallWrapper(),
CALL_AS_METHOD);
__ bind(&call_as_function); __ bind(&call_as_function);
} }
__ InvokeFunction(a1, __ InvokeFunction(a1,
......
...@@ -3184,7 +3184,8 @@ void FullCodeGenerator::EmitCallFunction(ZoneList<Expression*>* args) { ...@@ -3184,7 +3184,8 @@ void FullCodeGenerator::EmitCallFunction(ZoneList<Expression*>* args) {
// InvokeFunction requires the function in a1. Move it in there. // InvokeFunction requires the function in a1. Move it in there.
__ mov(a1, result_register()); __ mov(a1, result_register());
ParameterCount count(arg_count); ParameterCount count(arg_count);
__ InvokeFunction(a1, count, CALL_FUNCTION); __ InvokeFunction(a1, count, CALL_FUNCTION,
NullCallWrapper(), CALL_AS_METHOD);
__ lw(cp, MemOperand(fp, StandardFrameConstants::kContextOffset)); __ lw(cp, MemOperand(fp, StandardFrameConstants::kContextOffset));
context()->Plug(v0); context()->Plug(v0);
} }
......
...@@ -567,7 +567,8 @@ static void GenerateFunctionTailCall(MacroAssembler* masm, ...@@ -567,7 +567,8 @@ static void GenerateFunctionTailCall(MacroAssembler* masm,
// Invoke the function. // Invoke the function.
ParameterCount actual(argc); ParameterCount actual(argc);
__ InvokeFunction(a1, actual, JUMP_FUNCTION); __ InvokeFunction(a1, actual, JUMP_FUNCTION,
NullCallWrapper(), CALL_AS_METHOD);
} }
......
...@@ -2898,7 +2898,8 @@ void MacroAssembler::InvokeFunction(Register function, ...@@ -2898,7 +2898,8 @@ void MacroAssembler::InvokeFunction(Register function,
void MacroAssembler::InvokeFunction(JSFunction* function, void MacroAssembler::InvokeFunction(JSFunction* function,
const ParameterCount& actual, const ParameterCount& actual,
InvokeFlag flag) { InvokeFlag flag,
CallKind call_kind) {
ASSERT(function->is_compiled()); ASSERT(function->is_compiled());
// Get the function and setup the context. // Get the function and setup the context.
...@@ -2911,7 +2912,7 @@ void MacroAssembler::InvokeFunction(JSFunction* function, ...@@ -2911,7 +2912,7 @@ void MacroAssembler::InvokeFunction(JSFunction* function,
if (V8::UseCrankshaft()) { if (V8::UseCrankshaft()) {
UNIMPLEMENTED_MIPS(); UNIMPLEMENTED_MIPS();
} else { } else {
InvokeCode(code, expected, actual, RelocInfo::CODE_TARGET, flag); InvokeCode(code, expected, actual, RelocInfo::CODE_TARGET, flag, call_kind);
} }
} }
...@@ -3393,10 +3394,12 @@ void MacroAssembler::InvokeBuiltin(Builtins::JavaScript id, ...@@ -3393,10 +3394,12 @@ void MacroAssembler::InvokeBuiltin(Builtins::JavaScript id,
GetBuiltinEntry(t9, id); GetBuiltinEntry(t9, id);
if (flag == CALL_FUNCTION) { if (flag == CALL_FUNCTION) {
call_wrapper.BeforeCall(CallSize(t9)); call_wrapper.BeforeCall(CallSize(t9));
SetCallKind(t1, CALL_AS_METHOD);
Call(t9); Call(t9);
call_wrapper.AfterCall(); call_wrapper.AfterCall();
} else { } else {
ASSERT(flag == JUMP_FUNCTION); ASSERT(flag == JUMP_FUNCTION);
SetCallKind(t1, CALL_AS_METHOD);
Jump(t9); Jump(t9);
} }
} }
......
...@@ -631,27 +631,28 @@ DECLARE_NOTARGET_PROTOTYPE(Ret) ...@@ -631,27 +631,28 @@ DECLARE_NOTARGET_PROTOTYPE(Ret)
const ParameterCount& expected, const ParameterCount& expected,
const ParameterCount& actual, const ParameterCount& actual,
InvokeFlag flag, InvokeFlag flag,
const CallWrapper& call_wrapper = NullCallWrapper(), const CallWrapper& call_wrapper,
CallKind call_kind = CALL_AS_METHOD); CallKind call_kind);
void InvokeCode(Handle<Code> code, void InvokeCode(Handle<Code> code,
const ParameterCount& expected, const ParameterCount& expected,
const ParameterCount& actual, const ParameterCount& actual,
RelocInfo::Mode rmode, RelocInfo::Mode rmode,
InvokeFlag flag, InvokeFlag flag,
CallKind call_kind = CALL_AS_METHOD); CallKind call_kind);
// Invoke the JavaScript function in the given register. Changes the // Invoke the JavaScript function in the given register. Changes the
// current context to the context in the function before invoking. // current context to the context in the function before invoking.
void InvokeFunction(Register function, void InvokeFunction(Register function,
const ParameterCount& actual, const ParameterCount& actual,
InvokeFlag flag, InvokeFlag flag,
const CallWrapper& call_wrapper = NullCallWrapper(), const CallWrapper& call_wrapper,
CallKind call_kind = CALL_AS_METHOD); CallKind call_kind);
void InvokeFunction(JSFunction* function, void InvokeFunction(JSFunction* function,
const ParameterCount& actual, const ParameterCount& actual,
InvokeFlag flag); InvokeFlag flag,
CallKind call_kind);
void IsObjectJSObjectType(Register heap_object, void IsObjectJSObjectType(Register heap_object,
...@@ -1113,8 +1114,8 @@ DECLARE_NOTARGET_PROTOTYPE(Ret) ...@@ -1113,8 +1114,8 @@ DECLARE_NOTARGET_PROTOTYPE(Ret)
Register code_reg, Register code_reg,
Label* done, Label* done,
InvokeFlag flag, InvokeFlag flag,
const CallWrapper& call_wrapper = NullCallWrapper(), const CallWrapper& call_wrapper,
CallKind call_kind = CALL_AS_METHOD); CallKind call_kind);
// Get the code for the given builtin. Returns if able to resolve // Get the code for the given builtin. Returns if able to resolve
// the function in the 'resolved' flag. // the function in the 'resolved' flag.
......
...@@ -472,7 +472,8 @@ void StubCompiler::GenerateLoadMiss(MacroAssembler* masm, Code::Kind kind) { ...@@ -472,7 +472,8 @@ void StubCompiler::GenerateLoadMiss(MacroAssembler* masm, Code::Kind kind) {
static void GenerateCallFunction(MacroAssembler* masm, static void GenerateCallFunction(MacroAssembler* masm,
Object* object, Object* object,
const ParameterCount& arguments, const ParameterCount& arguments,
Label* miss) { Label* miss,
Code::ExtraICState extra_ic_state) {
// ----------- S t a t e ------------- // ----------- S t a t e -------------
// -- a0: receiver // -- a0: receiver
// -- a1: function to call // -- a1: function to call
...@@ -490,7 +491,10 @@ static void GenerateCallFunction(MacroAssembler* masm, ...@@ -490,7 +491,10 @@ static void GenerateCallFunction(MacroAssembler* masm,
} }
// Invoke the function. // Invoke the function.
__ InvokeFunction(a1, arguments, JUMP_FUNCTION); CallKind call_kind = CallICBase::Contextual::decode(extra_ic_state)
? CALL_AS_FUNCTION
: CALL_AS_METHOD;
__ InvokeFunction(a1, arguments, JUMP_FUNCTION, NullCallWrapper(), call_kind);
} }
...@@ -629,10 +633,12 @@ class CallInterceptorCompiler BASE_EMBEDDED { ...@@ -629,10 +633,12 @@ class CallInterceptorCompiler BASE_EMBEDDED {
public: public:
CallInterceptorCompiler(StubCompiler* stub_compiler, CallInterceptorCompiler(StubCompiler* stub_compiler,
const ParameterCount& arguments, const ParameterCount& arguments,
Register name) Register name,
Code::ExtraICState extra_ic_state)
: stub_compiler_(stub_compiler), : stub_compiler_(stub_compiler),
arguments_(arguments), arguments_(arguments),
name_(name) {} name_(name),
extra_ic_state_(extra_ic_state) {}
MaybeObject* Compile(MacroAssembler* masm, MaybeObject* Compile(MacroAssembler* masm,
JSObject* object, JSObject* object,
...@@ -760,8 +766,11 @@ class CallInterceptorCompiler BASE_EMBEDDED { ...@@ -760,8 +766,11 @@ class CallInterceptorCompiler BASE_EMBEDDED {
arguments_.immediate()); arguments_.immediate());
if (result->IsFailure()) return result; if (result->IsFailure()) return result;
} else { } else {
CallKind call_kind = CallICBase::Contextual::decode(extra_ic_state_)
? CALL_AS_FUNCTION
: CALL_AS_METHOD;
__ InvokeFunction(optimization.constant_function(), arguments_, __ InvokeFunction(optimization.constant_function(), arguments_,
JUMP_FUNCTION); JUMP_FUNCTION, call_kind);
} }
// Deferred code for fast API call case---clean preallocated space. // Deferred code for fast API call case---clean preallocated space.
...@@ -844,6 +853,7 @@ class CallInterceptorCompiler BASE_EMBEDDED { ...@@ -844,6 +853,7 @@ class CallInterceptorCompiler BASE_EMBEDDED {
StubCompiler* stub_compiler_; StubCompiler* stub_compiler_;
const ParameterCount& arguments_; const ParameterCount& arguments_;
Register name_; Register name_;
Code::ExtraICState extra_ic_state_;
}; };
...@@ -1503,7 +1513,7 @@ MaybeObject* CallStubCompiler::CompileCallField(JSObject* object, ...@@ -1503,7 +1513,7 @@ MaybeObject* CallStubCompiler::CompileCallField(JSObject* object,
Register reg = CheckPrototypes(object, a0, holder, a1, a3, t0, name, &miss); Register reg = CheckPrototypes(object, a0, holder, a1, a3, t0, name, &miss);
GenerateFastPropertyLoad(masm(), a1, reg, holder, index); GenerateFastPropertyLoad(masm(), a1, reg, holder, index);
GenerateCallFunction(masm(), object, arguments(), &miss); GenerateCallFunction(masm(), object, arguments(), &miss, extra_ic_state_);
// Handle call cache miss. // Handle call cache miss.
__ bind(&miss); __ bind(&miss);
...@@ -2001,7 +2011,7 @@ MaybeObject* CallStubCompiler::CompileStringFromCharCodeCall( ...@@ -2001,7 +2011,7 @@ MaybeObject* CallStubCompiler::CompileStringFromCharCodeCall(
// Tail call the full function. We do not have to patch the receiver // Tail call the full function. We do not have to patch the receiver
// because the function makes no use of it. // because the function makes no use of it.
__ bind(&slow); __ bind(&slow);
__ InvokeFunction(function, arguments(), JUMP_FUNCTION); __ InvokeFunction(function, arguments(), JUMP_FUNCTION, CALL_AS_METHOD);
__ bind(&miss); __ bind(&miss);
// a2: function name. // a2: function name.
...@@ -2137,7 +2147,7 @@ MaybeObject* CallStubCompiler::CompileMathFloorCall(Object* object, ...@@ -2137,7 +2147,7 @@ MaybeObject* CallStubCompiler::CompileMathFloorCall(Object* object,
__ bind(&slow); __ bind(&slow);
// Tail call the full function. We do not have to patch the receiver // Tail call the full function. We do not have to patch the receiver
// because the function makes no use of it. // because the function makes no use of it.
__ InvokeFunction(function, arguments(), JUMP_FUNCTION); __ InvokeFunction(function, arguments(), JUMP_FUNCTION, CALL_AS_METHOD);
__ bind(&miss); __ bind(&miss);
// a2: function name. // a2: function name.
...@@ -2239,7 +2249,7 @@ MaybeObject* CallStubCompiler::CompileMathAbsCall(Object* object, ...@@ -2239,7 +2249,7 @@ MaybeObject* CallStubCompiler::CompileMathAbsCall(Object* object,
// Tail call the full function. We do not have to patch the receiver // Tail call the full function. We do not have to patch the receiver
// because the function makes no use of it. // because the function makes no use of it.
__ bind(&slow); __ bind(&slow);
__ InvokeFunction(function, arguments(), JUMP_FUNCTION); __ InvokeFunction(function, arguments(), JUMP_FUNCTION, CALL_AS_METHOD);
__ bind(&miss); __ bind(&miss);
// a2: function name. // a2: function name.
...@@ -2425,7 +2435,10 @@ MaybeObject* CallStubCompiler::CompileCallConstant(Object* object, ...@@ -2425,7 +2435,10 @@ MaybeObject* CallStubCompiler::CompileCallConstant(Object* object,
UNREACHABLE(); UNREACHABLE();
} }
__ InvokeFunction(function, arguments(), JUMP_FUNCTION); CallKind call_kind = CallICBase::Contextual::decode(extra_ic_state_)
? CALL_AS_FUNCTION
: CALL_AS_METHOD;
__ InvokeFunction(function, arguments(), JUMP_FUNCTION, call_kind);
// Handle call cache miss. // Handle call cache miss.
__ bind(&miss); __ bind(&miss);
...@@ -2459,7 +2472,7 @@ MaybeObject* CallStubCompiler::CompileCallInterceptor(JSObject* object, ...@@ -2459,7 +2472,7 @@ MaybeObject* CallStubCompiler::CompileCallInterceptor(JSObject* object,
// Get the receiver from the stack. // Get the receiver from the stack.
__ lw(a1, MemOperand(sp, argc * kPointerSize)); __ lw(a1, MemOperand(sp, argc * kPointerSize));
CallInterceptorCompiler compiler(this, arguments(), a2); CallInterceptorCompiler compiler(this, arguments(), a2, extra_ic_state_);
MaybeObject* result = compiler.Compile(masm(), MaybeObject* result = compiler.Compile(masm(),
object, object,
holder, holder,
...@@ -2479,7 +2492,7 @@ MaybeObject* CallStubCompiler::CompileCallInterceptor(JSObject* object, ...@@ -2479,7 +2492,7 @@ MaybeObject* CallStubCompiler::CompileCallInterceptor(JSObject* object,
// Restore receiver. // Restore receiver.
__ lw(a0, MemOperand(sp, argc * kPointerSize)); __ lw(a0, MemOperand(sp, argc * kPointerSize));
GenerateCallFunction(masm(), object, arguments(), &miss); GenerateCallFunction(masm(), object, arguments(), &miss, extra_ic_state_);
// Handle call cache miss. // Handle call cache miss.
__ bind(&miss); __ bind(&miss);
...@@ -2491,13 +2504,11 @@ MaybeObject* CallStubCompiler::CompileCallInterceptor(JSObject* object, ...@@ -2491,13 +2504,11 @@ MaybeObject* CallStubCompiler::CompileCallInterceptor(JSObject* object,
} }
MaybeObject* CallStubCompiler::CompileCallGlobal( MaybeObject* CallStubCompiler::CompileCallGlobal(JSObject* object,
JSObject* object,
GlobalObject* holder, GlobalObject* holder,
JSGlobalPropertyCell* cell, JSGlobalPropertyCell* cell,
JSFunction* function, JSFunction* function,
String* name, String* name) {
Code::ExtraICState extra_ic_state) {
// ----------- S t a t e ------------- // ----------- S t a t e -------------
// -- a2 : name // -- a2 : name
// -- ra : return address // -- ra : return address
...@@ -2538,7 +2549,7 @@ MaybeObject* CallStubCompiler::CompileCallGlobal( ...@@ -2538,7 +2549,7 @@ MaybeObject* CallStubCompiler::CompileCallGlobal(
ASSERT(function->is_compiled()); ASSERT(function->is_compiled());
Handle<Code> code(function->code()); Handle<Code> code(function->code());
ParameterCount expected(function->shared()->formal_parameter_count()); ParameterCount expected(function->shared()->formal_parameter_count());
CallKind call_kind = CallICBase::Contextual::decode(extra_ic_state) CallKind call_kind = CallICBase::Contextual::decode(extra_ic_state_)
? CALL_AS_FUNCTION ? CALL_AS_FUNCTION
: CALL_AS_METHOD; : CALL_AS_METHOD;
if (V8::UseCrankshaft()) { if (V8::UseCrankshaft()) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment