Handlify call cases for pre-monomorphic, normal, and miss.

These cases turn out to be easy.  There is a lingering raw pointer
implementation of TryCompileCallMiss because it's need by some of the
unconverted call stubs.

R=ulan@chromium.org
BUG=
TEST=

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

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@9749 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent f193d87e
......@@ -464,7 +464,7 @@ static void GenerateFunctionTailCall(MacroAssembler* masm,
}
static void GenerateCallNormal(MacroAssembler* masm, int argc) {
void CallICBase::GenerateNormal(MacroAssembler* masm, int argc) {
// ----------- S t a t e -------------
// -- r2 : name
// -- lr : return address
......@@ -568,17 +568,6 @@ void CallIC::GenerateMegamorphic(MacroAssembler* masm,
}
void CallIC::GenerateNormal(MacroAssembler* masm, int argc) {
// ----------- S t a t e -------------
// -- r2 : name
// -- lr : return address
// -----------------------------------
GenerateCallNormal(masm, argc);
GenerateMiss(masm, argc, Code::kNoExtraICState);
}
void KeyedCallIC::GenerateMegamorphic(MacroAssembler* masm, int argc) {
// ----------- S t a t e -------------
// -- r2 : name
......@@ -696,7 +685,7 @@ void KeyedCallIC::GenerateNormal(MacroAssembler* masm, int argc) {
__ JumpIfSmi(r2, &miss);
__ IsObjectJSStringType(r2, r0, &miss);
GenerateCallNormal(masm, argc);
CallICBase::GenerateNormal(masm, argc);
__ bind(&miss);
GenerateMiss(masm, argc);
}
......
......@@ -944,8 +944,9 @@ static void GenerateFunctionTailCall(MacroAssembler* masm,
NullCallWrapper(), CALL_AS_METHOD);
}
// The generated code falls through if the call should be handled by runtime.
static void GenerateCallNormal(MacroAssembler* masm, int argc) {
void CallICBase::GenerateNormal(MacroAssembler* masm, int argc) {
// ----------- S t a t e -------------
// -- ecx : name
// -- esp[0] : return address
......@@ -1060,20 +1061,6 @@ void CallIC::GenerateMegamorphic(MacroAssembler* masm,
}
void CallIC::GenerateNormal(MacroAssembler* masm, int argc) {
// ----------- S t a t e -------------
// -- ecx : name
// -- esp[0] : return address
// -- esp[(argc - n) * 4] : arg[n] (zero-based)
// -- ...
// -- esp[(argc + 1) * 4] : receiver
// -----------------------------------
GenerateCallNormal(masm, argc);
GenerateMiss(masm, argc, Code::kNoExtraICState);
}
void KeyedCallIC::GenerateMegamorphic(MacroAssembler* masm, int argc) {
// ----------- S t a t e -------------
// -- ecx : name
......@@ -1238,7 +1225,7 @@ void KeyedCallIC::GenerateNormal(MacroAssembler* masm, int argc) {
__ JumpIfSmi(ecx, &miss);
Condition cond = masm->IsObjectStringType(ecx, eax, eax);
__ j(NegateCondition(cond), &miss);
GenerateCallNormal(masm, argc);
CallICBase::GenerateNormal(masm, argc);
__ bind(&miss);
GenerateMiss(masm, argc);
}
......
......@@ -236,12 +236,15 @@ class CallICBase: public IC {
static void Clear(Address address, Code* target);
// Platform-specific generation of misses for call and keyed call.
// Platform-specific code generation functions used by both call and
// keyed call.
static void GenerateMiss(MacroAssembler* masm,
int argc,
IC::UtilityId id,
Code::ExtraICState extra_state);
static void GenerateNormal(MacroAssembler* masm, int argc);
Code::Kind kind_;
friend class IC;
......@@ -271,7 +274,10 @@ class CallIC: public CallICBase {
int argc,
Code::ExtraICState extra_ic_state);
static void GenerateNormal(MacroAssembler* masm, int argc);
static void GenerateNormal(MacroAssembler* masm, int argc) {
CallICBase::GenerateNormal(masm, argc);
GenerateMiss(masm, argc, Code::kNoExtraICState);
}
};
......
......@@ -463,7 +463,7 @@ static void GenerateFunctionTailCall(MacroAssembler* masm,
}
static void GenerateCallNormal(MacroAssembler* masm, int argc) {
void CallICBase::GenerateNormal(MacroAssembler* masm, int argc) {
// ----------- S t a t e -------------
// -- a2 : name
// -- ra : return address
......@@ -567,17 +567,6 @@ void CallIC::GenerateMegamorphic(MacroAssembler* masm,
}
void CallIC::GenerateNormal(MacroAssembler* masm, int argc) {
// ----------- S t a t e -------------
// -- a2 : name
// -- ra : return address
// -----------------------------------
GenerateCallNormal(masm, argc);
GenerateMiss(masm, argc, Code::kNoExtraICState);
}
void KeyedCallIC::GenerateMegamorphic(MacroAssembler* masm, int argc) {
// ----------- S t a t e -------------
// -- a2 : name
......@@ -694,7 +683,7 @@ void KeyedCallIC::GenerateNormal(MacroAssembler* masm, int argc) {
__ JumpIfSmi(a2, &miss);
__ IsObjectJSStringType(a2, a0, &miss);
GenerateCallNormal(masm, argc);
CallICBase::GenerateNormal(masm, argc);
__ bind(&miss);
GenerateMiss(masm, argc);
}
......
......@@ -1466,14 +1466,6 @@ Handle<Code> StubCompiler::CompileCallInitialize(Code::Flags flags) {
Handle<Code> StubCompiler::CompileCallPreMonomorphic(Code::Flags flags) {
CALL_HEAP_FUNCTION(isolate(),
(set_failure(NULL), TryCompileCallPreMonomorphic(flags)),
Code);
}
MaybeObject* StubCompiler::TryCompileCallPreMonomorphic(Code::Flags flags) {
HandleScope scope(isolate());
int argc = Code::ExtractArgumentsCountFromFlags(flags);
// The code of the PreMonomorphic stub is the same as the code
// of the Initialized stub. They just differ on the code object flags.
......@@ -1484,31 +1476,17 @@ MaybeObject* StubCompiler::TryCompileCallPreMonomorphic(Code::Flags flags) {
} else {
KeyedCallIC::GenerateInitialize(masm(), argc);
}
Object* result;
{ MaybeObject* maybe_result =
TryGetCodeWithFlags(flags, "CompileCallPreMonomorphic");
if (!maybe_result->ToObject(&result)) return maybe_result;
}
Handle<Code> code = GetCodeWithFlags(flags, "CompileCallPreMonomorphic");
isolate()->counters()->call_premonomorphic_stubs()->Increment();
Code* code = Code::cast(result);
USE(code);
PROFILE(isolate(),
CodeCreateEvent(CALL_LOGGER_TAG(kind, CALL_PRE_MONOMORPHIC_TAG),
code, code->arguments_count()));
GDBJIT(AddCode(GDBJITInterface::CALL_PRE_MONOMORPHIC, Code::cast(code)));
return result;
*code, code->arguments_count()));
GDBJIT(AddCode(GDBJITInterface::CALL_PRE_MONOMORPHIC, *code));
return code;
}
Handle<Code> StubCompiler::CompileCallNormal(Code::Flags flags) {
CALL_HEAP_FUNCTION(isolate(),
(set_failure(NULL), TryCompileCallNormal(flags)),
Code);
}
MaybeObject* StubCompiler::TryCompileCallNormal(Code::Flags flags) {
HandleScope scope(isolate());
int argc = Code::ExtractArgumentsCountFromFlags(flags);
Code::Kind kind = Code::ExtractKindFromFlags(flags);
if (kind == Code::CALL_IC) {
......@@ -1519,18 +1497,13 @@ MaybeObject* StubCompiler::TryCompileCallNormal(Code::Flags flags) {
} else {
KeyedCallIC::GenerateNormal(masm(), argc);
}
Object* result;
{ MaybeObject* maybe_result = TryGetCodeWithFlags(flags, "CompileCallNormal");
if (!maybe_result->ToObject(&result)) return maybe_result;
}
Handle<Code> code = GetCodeWithFlags(flags, "CompileCallNormal");
isolate()->counters()->call_normal_stubs()->Increment();
Code* code = Code::cast(result);
USE(code);
PROFILE(isolate(),
CodeCreateEvent(CALL_LOGGER_TAG(kind, CALL_NORMAL_TAG),
code, code->arguments_count()));
GDBJIT(AddCode(GDBJITInterface::CALL_NORMAL, Code::cast(code)));
return result;
*code, code->arguments_count()));
GDBJIT(AddCode(GDBJITInterface::CALL_NORMAL, *code));
return code;
}
......@@ -1595,12 +1568,26 @@ MaybeObject* StubCompiler::TryCompileCallArguments(Code::Flags flags) {
Handle<Code> StubCompiler::CompileCallMiss(Code::Flags flags) {
CALL_HEAP_FUNCTION(isolate(),
(set_failure(NULL), TryCompileCallMiss(flags)),
Code);
int argc = Code::ExtractArgumentsCountFromFlags(flags);
Code::Kind kind = Code::ExtractKindFromFlags(flags);
Code::ExtraICState extra_state = Code::ExtractExtraICStateFromFlags(flags);
if (kind == Code::CALL_IC) {
CallIC::GenerateMiss(masm(), argc, extra_state);
} else {
KeyedCallIC::GenerateMiss(masm(), argc);
}
Handle<Code> code = GetCodeWithFlags(flags, "CompileCallMiss");
isolate()->counters()->call_megamorphic_stubs()->Increment();
PROFILE(isolate(),
CodeCreateEvent(CALL_LOGGER_TAG(kind, CALL_MISS_TAG),
*code, code->arguments_count()));
GDBJIT(AddCode(GDBJITInterface::CALL_MISS, *code));
return code;
}
// TODO(kmillikin): This annoying raw pointer implementation should be
// eliminated when the stub compiler no longer needs it.
MaybeObject* StubCompiler::TryCompileCallMiss(Code::Flags flags) {
HandleScope scope(isolate());
int argc = Code::ExtractArgumentsCountFromFlags(flags);
......
......@@ -392,8 +392,6 @@ class StubCompiler BASE_EMBEDDED {
Handle<Code> CompileCallArguments(Code::Flags flags);
Handle<Code> CompileCallMiss(Code::Flags flags);
MUST_USE_RESULT MaybeObject* TryCompileCallPreMonomorphic(Code::Flags flags);
MUST_USE_RESULT MaybeObject* TryCompileCallNormal(Code::Flags flags);
MUST_USE_RESULT MaybeObject* TryCompileCallMegamorphic(Code::Flags flags);
MUST_USE_RESULT MaybeObject* TryCompileCallArguments(Code::Flags flags);
MUST_USE_RESULT MaybeObject* TryCompileCallMiss(Code::Flags flags);
......
......@@ -821,7 +821,7 @@ static void GenerateFunctionTailCall(MacroAssembler* masm,
// The generated code falls through if the call should be handled by runtime.
static void GenerateCallNormal(MacroAssembler* masm, int argc) {
void CallICBase::GenerateNormal(MacroAssembler* masm, int argc) {
// ----------- S t a t e -------------
// rcx : function name
// rsp[0] : return address
......@@ -941,22 +941,6 @@ void CallIC::GenerateMegamorphic(MacroAssembler* masm,
}
void CallIC::GenerateNormal(MacroAssembler* masm, int argc) {
// ----------- S t a t e -------------
// rcx : function name
// rsp[0] : return address
// rsp[8] : argument argc
// rsp[16] : argument argc - 1
// ...
// rsp[argc * 8] : argument 1
// rsp[(argc + 1) * 8] : argument 0 = receiver
// -----------------------------------
GenerateCallNormal(masm, argc);
GenerateMiss(masm, argc, Code::kNoExtraICState);
}
void KeyedCallIC::GenerateMegamorphic(MacroAssembler* masm, int argc) {
// ----------- S t a t e -------------
// rcx : function name
......@@ -1084,7 +1068,7 @@ void KeyedCallIC::GenerateNormal(MacroAssembler* masm, int argc) {
__ JumpIfSmi(rcx, &miss);
Condition cond = masm->IsObjectStringType(rcx, rax, rax);
__ j(NegateCondition(cond), &miss);
GenerateCallNormal(masm, argc);
CallICBase::GenerateNormal(masm, argc);
__ bind(&miss);
GenerateMiss(masm, argc);
}
......
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