Commit 4d5ec5e6 authored by verwaest@chromium.org's avatar verwaest@chromium.org

Reupload CallIC changes.

Relands https://codereview.chromium.org/91963003/ with fix for the invalid receiver patching in case of the global object / interceptor.
BUG=
R=ishell@chromium.org

Review URL: https://chromiumcodereview.appspot.com/96763002

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@18161 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent 425f3fde
......@@ -1229,7 +1229,7 @@ void MacroAssembler::InvokeFunction(Register fun,
}
void MacroAssembler::InvokeFunction(Handle<JSFunction> function,
void MacroAssembler::InvokeFunction(Register function,
const ParameterCount& expected,
const ParameterCount& actual,
InvokeFlag flag,
......@@ -1238,8 +1238,10 @@ void MacroAssembler::InvokeFunction(Handle<JSFunction> function,
// You can't call a function without a valid frame.
ASSERT(flag == JUMP_FUNCTION || has_frame());
// Contract with called JS functions requires that function is passed in r1.
ASSERT(function.is(r1));
// Get the function and setup the context.
Move(r1, function);
ldr(cp, FieldMemOperand(r1, JSFunction::kContextOffset));
// We call indirectly through the code field in the function to
......@@ -1250,6 +1252,17 @@ void MacroAssembler::InvokeFunction(Handle<JSFunction> function,
}
void MacroAssembler::InvokeFunction(Handle<JSFunction> function,
const ParameterCount& expected,
const ParameterCount& actual,
InvokeFlag flag,
const CallWrapper& call_wrapper,
CallKind call_kind) {
Move(r1, function);
InvokeFunction(r1, expected, actual, flag, call_wrapper, call_kind);
}
void MacroAssembler::IsObjectJSObjectType(Register heap_object,
Register map,
Register scratch,
......
......@@ -613,6 +613,13 @@ class MacroAssembler: public Assembler {
const CallWrapper& call_wrapper,
CallKind call_kind);
void InvokeFunction(Register function,
const ParameterCount& expected,
const ParameterCount& actual,
InvokeFlag flag,
const CallWrapper& call_wrapper,
CallKind call_kind);
void InvokeFunction(Handle<JSFunction> function,
const ParameterCount& expected,
const ParameterCount& actual,
......
This diff is collapsed.
......@@ -2634,7 +2634,7 @@ void MacroAssembler::InvokeFunction(Register fun,
}
void MacroAssembler::InvokeFunction(Handle<JSFunction> function,
void MacroAssembler::InvokeFunction(Register fun,
const ParameterCount& expected,
const ParameterCount& actual,
InvokeFlag flag,
......@@ -2643,18 +2643,25 @@ void MacroAssembler::InvokeFunction(Handle<JSFunction> function,
// You can't call a function without a valid frame.
ASSERT(flag == JUMP_FUNCTION || has_frame());
// Get the function and setup the context.
LoadHeapObject(edi, function);
ASSERT(fun.is(edi));
mov(esi, FieldOperand(edi, JSFunction::kContextOffset));
// We call indirectly through the code field in the function to
// allow recompilation to take effect without changing any of the
// call sites.
InvokeCode(FieldOperand(edi, JSFunction::kCodeEntryOffset),
expected, actual, flag, call_wrapper, call_kind);
}
void MacroAssembler::InvokeFunction(Handle<JSFunction> function,
const ParameterCount& expected,
const ParameterCount& actual,
InvokeFlag flag,
const CallWrapper& call_wrapper,
CallKind call_kind) {
LoadHeapObject(edi, function);
InvokeFunction(edi, expected, actual, flag, call_wrapper, call_kind);
}
void MacroAssembler::InvokeBuiltin(Builtins::JavaScript id,
InvokeFlag flag,
const CallWrapper& call_wrapper) {
......
......@@ -349,6 +349,13 @@ class MacroAssembler: public Assembler {
const CallWrapper& call_wrapper,
CallKind call_kind);
void InvokeFunction(Register function,
const ParameterCount& expected,
const ParameterCount& actual,
InvokeFlag flag,
const CallWrapper& call_wrapper,
CallKind call_kind);
void InvokeFunction(Handle<JSFunction> function,
const ParameterCount& expected,
const ParameterCount& actual,
......
This diff is collapsed.
......@@ -3728,7 +3728,7 @@ void MacroAssembler::InvokeFunction(Register function,
}
void MacroAssembler::InvokeFunction(Handle<JSFunction> function,
void MacroAssembler::InvokeFunction(Register function,
const ParameterCount& expected,
const ParameterCount& actual,
InvokeFlag flag,
......@@ -3737,8 +3737,10 @@ void MacroAssembler::InvokeFunction(Handle<JSFunction> function,
// You can't call a function without a valid frame.
ASSERT(flag == JUMP_FUNCTION || has_frame());
// Contract with called JS functions requires that function is passed in a1.
ASSERT(function.is(a1));
// Get the function and setup the context.
li(a1, function);
lw(cp, FieldMemOperand(a1, JSFunction::kContextOffset));
// We call indirectly through the code field in the function to
......@@ -3749,6 +3751,17 @@ void MacroAssembler::InvokeFunction(Handle<JSFunction> function,
}
void MacroAssembler::InvokeFunction(Handle<JSFunction> function,
const ParameterCount& expected,
const ParameterCount& actual,
InvokeFlag flag,
const CallWrapper& call_wrapper,
CallKind call_kind) {
li(a1, function);
InvokeFunction(a1, expected, actual, flag, call_wrapper, call_kind);
}
void MacroAssembler::IsObjectJSObjectType(Register heap_object,
Register map,
Register scratch,
......
......@@ -917,6 +917,13 @@ class MacroAssembler: public Assembler {
const CallWrapper& call_wrapper,
CallKind call_kind);
void InvokeFunction(Register function,
const ParameterCount& expected,
const ParameterCount& actual,
InvokeFlag flag,
const CallWrapper& call_wrapper,
CallKind call_kind);
void InvokeFunction(Handle<JSFunction> function,
const ParameterCount& expected,
const ParameterCount& actual,
......
This diff is collapsed.
......@@ -1128,12 +1128,69 @@ void StubCompiler::LookupPostInterceptor(Handle<JSObject> holder,
#define __ ACCESS_MASM(masm())
CallKind CallStubCompiler::call_kind() {
return CallICBase::Contextual::decode(extra_state_)
? CALL_AS_FUNCTION
: CALL_AS_METHOD;
}
void CallStubCompiler::HandlerFrontendFooter(Label* miss) {
__ bind(miss);
GenerateMissBranch();
}
void CallStubCompiler::GenerateJumpFunctionIgnoreReceiver(
Handle<JSFunction> function) {
ParameterCount expected(function);
__ InvokeFunction(function, expected, arguments(),
JUMP_FUNCTION, NullCallWrapper(), call_kind());
}
void CallStubCompiler::GenerateJumpFunction(Handle<Object> object,
Handle<JSFunction> function) {
PatchGlobalProxy(object);
GenerateJumpFunctionIgnoreReceiver(function);
}
void CallStubCompiler::GenerateJumpFunction(Handle<Object> object,
Register actual_closure,
Handle<JSFunction> function) {
PatchGlobalProxy(object);
ParameterCount expected(function);
__ InvokeFunction(actual_closure, 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);
GenerateJumpFunction(object, function);
HandlerFrontendFooter(&miss);
// Return the generated code.
return GetCode(function);
}
Register LoadStubCompiler::HandlerFrontendHeader(
Handle<Type> type,
Register object_reg,
......
......@@ -919,7 +919,17 @@ class CallStubCompiler: public StubCompiler {
Label* miss);
void HandlerFrontendFooter(Label* miss);
void CompileHandlerBackend(Handle<JSFunction> function);
void GenerateJumpFunctionIgnoreReceiver(Handle<JSFunction> function);
void GenerateJumpFunction(Handle<Object> object,
Handle<JSFunction> function);
void GenerateJumpFunction(Handle<Object> object,
Register function,
Label* miss);
// Use to call |actual_closure|, a closure with the same shared function info
// as |function|.
void GenerateJumpFunction(Handle<Object> object,
Register actual_closure,
Handle<JSFunction> function);
Handle<Code> CompileCallConstant(Handle<Object> object,
Handle<JSObject> holder,
......@@ -968,6 +978,8 @@ class CallStubCompiler: public StubCompiler {
Handle<JSFunction> function,
Handle<String> name);
CallKind call_kind();
Handle<Code> GetCode(Code::StubType type, Handle<Name> name);
Handle<Code> GetCode(Handle<JSFunction> function);
......@@ -981,6 +993,8 @@ class CallStubCompiler: public StubCompiler {
Handle<JSFunction> function,
Label* miss);
void GenerateFunctionCheck(Register function, Register scratch, Label* miss);
// Generates a jump to CallIC miss stub.
void GenerateMissBranch();
......
......@@ -3601,7 +3601,7 @@ void MacroAssembler::InvokeFunction(Register function,
}
void MacroAssembler::InvokeFunction(Handle<JSFunction> function,
void MacroAssembler::InvokeFunction(Register function,
const ParameterCount& expected,
const ParameterCount& actual,
InvokeFlag flag,
......@@ -3610,18 +3610,27 @@ void MacroAssembler::InvokeFunction(Handle<JSFunction> function,
// You can't call a function without a valid frame.
ASSERT(flag == JUMP_FUNCTION || has_frame());
// Get the function and setup the context.
Move(rdi, function);
movq(rsi, FieldOperand(rdi, JSFunction::kContextOffset));
// We call indirectly through the code field in the function to
// allow recompilation to take effect without changing any of the
// call sites.
ASSERT(function.is(rdi));
movq(rsi, FieldOperand(function, JSFunction::kContextOffset));
// Advances rdx to the end of the Code object header, to the start of
// the executable code.
movq(rdx, FieldOperand(rdi, JSFunction::kCodeEntryOffset));
InvokeCode(rdx, expected, actual, flag, call_wrapper, call_kind);
}
void MacroAssembler::InvokeFunction(Handle<JSFunction> function,
const ParameterCount& expected,
const ParameterCount& actual,
InvokeFlag flag,
const CallWrapper& call_wrapper,
CallKind call_kind) {
Move(rdi, function);
InvokeFunction(rdi, expected, actual, flag, call_wrapper, call_kind);
}
void MacroAssembler::InvokePrologue(const ParameterCount& expected,
const ParameterCount& actual,
Handle<Code> code_constant,
......
......@@ -371,6 +371,13 @@ class MacroAssembler: public Assembler {
const CallWrapper& call_wrapper,
CallKind call_kind);
void InvokeFunction(Register function,
const ParameterCount& expected,
const ParameterCount& actual,
InvokeFlag flag,
const CallWrapper& call_wrapper,
CallKind call_kind);
void InvokeFunction(Handle<JSFunction> function,
const ParameterCount& expected,
const ParameterCount& actual,
......
This diff is collapsed.
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