Commit 2571c69d authored by chunyang.dai's avatar chunyang.dai Committed by Commit bot

X87: Unify "runtime-style" IC functions with Runtime intrinsics

port bc8041dc (r29811).

original commit message:

    Previous to this CL, ICs used a slightly different code idiom
    to get to C++ code from generated code than runtime intrinsics,
    using an IC_Utility class that in essence provided exactly
    the same functionality as Runtime::FunctionForId, but in its
    own quirky way.

    This CL unifies the two mechanisms, folding IC_Utility
    away by making all IC entry points in C++ code, e.g. IC
    miss handlers, full-fledged runtime intrinsics. This makes
    it possible to eliminate a bunch of ad-hoc declarations and
    adapters that the IC system had to needlessly re-invent.

    As a bonus and the original reason for this yak-shave:
    IC-related C++ runtime functions are now callable from
    TurboFan.

BUG=

Review URL: https://codereview.chromium.org/1252903002

Cr-Commit-Position: refs/heads/master@{#29837}
parent 1359017f
...@@ -294,10 +294,9 @@ static void PushInterceptorArguments(MacroAssembler* masm, Register receiver, ...@@ -294,10 +294,9 @@ static void PushInterceptorArguments(MacroAssembler* masm, Register receiver,
static void CompileCallLoadPropertyWithInterceptor( static void CompileCallLoadPropertyWithInterceptor(
MacroAssembler* masm, Register receiver, Register holder, Register name, MacroAssembler* masm, Register receiver, Register holder, Register name,
Handle<JSObject> holder_obj, IC::UtilityId id) { Handle<JSObject> holder_obj, Runtime::FunctionId id) {
PushInterceptorArguments(masm, receiver, holder, name, holder_obj); PushInterceptorArguments(masm, receiver, holder, name, holder_obj);
__ CallExternalReference(ExternalReference(IC_Utility(id), masm->isolate()), __ CallRuntime(id, NamedLoadHandlerCompiler::kInterceptorArgsLength);
NamedLoadHandlerCompiler::kInterceptorArgsLength);
} }
...@@ -321,8 +320,7 @@ void NamedStoreHandlerCompiler::GenerateSlow(MacroAssembler* masm) { ...@@ -321,8 +320,7 @@ void NamedStoreHandlerCompiler::GenerateSlow(MacroAssembler* masm) {
StoreIC_PushArgs(masm); StoreIC_PushArgs(masm);
// Do tail-call to runtime routine. // Do tail-call to runtime routine.
ExternalReference ref(IC_Utility(IC::kStoreIC_Slow), masm->isolate()); __ TailCallRuntime(Runtime::kStoreIC_Slow, 3, 1);
__ TailCallExternalReference(ref, 3, 1);
} }
...@@ -331,8 +329,7 @@ void ElementHandlerCompiler::GenerateStoreSlow(MacroAssembler* masm) { ...@@ -331,8 +329,7 @@ void ElementHandlerCompiler::GenerateStoreSlow(MacroAssembler* masm) {
StoreIC_PushArgs(masm); StoreIC_PushArgs(masm);
// Do tail-call to runtime routine. // Do tail-call to runtime routine.
ExternalReference ref(IC_Utility(IC::kKeyedStoreIC_Slow), masm->isolate()); __ TailCallRuntime(Runtime::kKeyedStoreIC_Slow, 3, 1);
__ TailCallExternalReference(ref, 3, 1);
} }
...@@ -678,7 +675,7 @@ void NamedLoadHandlerCompiler::GenerateLoadInterceptorWithFollowup( ...@@ -678,7 +675,7 @@ void NamedLoadHandlerCompiler::GenerateLoadInterceptorWithFollowup(
// of this method.) // of this method.)
CompileCallLoadPropertyWithInterceptor( CompileCallLoadPropertyWithInterceptor(
masm(), receiver(), holder_reg, this->name(), holder(), masm(), receiver(), holder_reg, this->name(), holder(),
IC::kLoadPropertyWithInterceptorOnly); Runtime::kLoadPropertyWithInterceptorOnly);
// Check if interceptor provided a value for property. If it's // Check if interceptor provided a value for property. If it's
// the case, return immediately. // the case, return immediately.
...@@ -719,10 +716,8 @@ void NamedLoadHandlerCompiler::GenerateLoadInterceptor(Register holder_reg) { ...@@ -719,10 +716,8 @@ void NamedLoadHandlerCompiler::GenerateLoadInterceptor(Register holder_reg) {
holder()); holder());
__ push(scratch2()); // restore old return address __ push(scratch2()); // restore old return address
ExternalReference ref = ExternalReference( __ TailCallRuntime(Runtime::kLoadPropertyWithInterceptor,
IC_Utility(IC::kLoadPropertyWithInterceptor), isolate()); NamedLoadHandlerCompiler::kInterceptorArgsLength, 1);
__ TailCallExternalReference(
ref, NamedLoadHandlerCompiler::kInterceptorArgsLength, 1);
} }
...@@ -747,9 +742,7 @@ Handle<Code> NamedStoreHandlerCompiler::CompileStoreCallback( ...@@ -747,9 +742,7 @@ Handle<Code> NamedStoreHandlerCompiler::CompileStoreCallback(
__ push(scratch1()); // restore return address __ push(scratch1()); // restore return address
// Do tail-call to the runtime system. // Do tail-call to the runtime system.
ExternalReference store_callback_property = __ TailCallRuntime(Runtime::kStoreCallbackProperty, 5, 1);
ExternalReference(IC_Utility(IC::kStoreCallbackProperty), isolate());
__ TailCallExternalReference(store_callback_property, 5, 1);
// Return the generated code. // Return the generated code.
return GetCode(kind(), Code::FAST, name); return GetCode(kind(), Code::FAST, name);
...@@ -765,9 +758,7 @@ Handle<Code> NamedStoreHandlerCompiler::CompileStoreInterceptor( ...@@ -765,9 +758,7 @@ Handle<Code> NamedStoreHandlerCompiler::CompileStoreInterceptor(
__ push(scratch1()); // restore return address __ push(scratch1()); // restore return address
// Do tail-call to the runtime system. // Do tail-call to the runtime system.
ExternalReference store_ic_property = ExternalReference( __ TailCallRuntime(Runtime::kStorePropertyWithInterceptor, 3, 1);
IC_Utility(IC::kStorePropertyWithInterceptor), isolate());
__ TailCallExternalReference(store_ic_property, 3, 1);
// Return the generated code. // Return the generated code.
return GetCode(kind(), Code::FAST, name); return GetCode(kind(), Code::FAST, name);
......
...@@ -678,10 +678,8 @@ void LoadIC::GenerateMiss(MacroAssembler* masm) { ...@@ -678,10 +678,8 @@ void LoadIC::GenerateMiss(MacroAssembler* masm) {
LoadIC_PushArgs(masm); LoadIC_PushArgs(masm);
// Perform tail call to the entry. // Perform tail call to the entry.
ExternalReference ref =
ExternalReference(IC_Utility(kLoadIC_Miss), masm->isolate());
int arg_count = 4; int arg_count = 4;
__ TailCallExternalReference(ref, arg_count, 1); __ TailCallRuntime(Runtime::kLoadIC_Miss, arg_count, 1);
} }
...@@ -711,10 +709,8 @@ void KeyedLoadIC::GenerateMiss(MacroAssembler* masm) { ...@@ -711,10 +709,8 @@ void KeyedLoadIC::GenerateMiss(MacroAssembler* masm) {
LoadIC_PushArgs(masm); LoadIC_PushArgs(masm);
// Perform tail call to the entry. // Perform tail call to the entry.
ExternalReference ref =
ExternalReference(IC_Utility(kKeyedLoadIC_Miss), masm->isolate());
int arg_count = 4; int arg_count = 4;
__ TailCallExternalReference(ref, arg_count, 1); __ TailCallRuntime(Runtime::kKeyedLoadIC_Miss, arg_count, 1);
} }
...@@ -770,9 +766,7 @@ void StoreIC::GenerateMiss(MacroAssembler* masm) { ...@@ -770,9 +766,7 @@ void StoreIC::GenerateMiss(MacroAssembler* masm) {
StoreIC_PushArgs(masm); StoreIC_PushArgs(masm);
// Perform tail call to the entry. // Perform tail call to the entry.
ExternalReference ref = __ TailCallRuntime(Runtime::kStoreIC_Miss, 3, 1);
ExternalReference(IC_Utility(kStoreIC_Miss), masm->isolate());
__ TailCallExternalReference(ref, 3, 1);
} }
...@@ -808,9 +802,7 @@ void KeyedStoreIC::GenerateMiss(MacroAssembler* masm) { ...@@ -808,9 +802,7 @@ void KeyedStoreIC::GenerateMiss(MacroAssembler* masm) {
StoreIC_PushArgs(masm); StoreIC_PushArgs(masm);
// Do tail-call to runtime routine. // Do tail-call to runtime routine.
ExternalReference ref = __ TailCallRuntime(Runtime::kKeyedStoreIC_Miss, 3, 1);
ExternalReference(IC_Utility(kKeyedStoreIC_Miss), masm->isolate());
__ TailCallExternalReference(ref, 3, 1);
} }
......
...@@ -368,9 +368,7 @@ void LoadIndexedInterceptorStub::Generate(MacroAssembler* masm) { ...@@ -368,9 +368,7 @@ void LoadIndexedInterceptorStub::Generate(MacroAssembler* masm) {
__ push(scratch); // return address __ push(scratch); // return address
// Perform tail call to the entry. // Perform tail call to the entry.
ExternalReference ref = ExternalReference( __ TailCallRuntime(Runtime::kLoadElementWithInterceptor, 2, 1);
IC_Utility(IC::kLoadElementWithInterceptor), masm->isolate());
__ TailCallExternalReference(ref, 2, 1);
__ bind(&slow); __ bind(&slow);
PropertyAccessCompiler::TailCallBuiltin( PropertyAccessCompiler::TailCallBuiltin(
...@@ -2152,11 +2150,10 @@ void CallICStub::GenerateMiss(MacroAssembler* masm) { ...@@ -2152,11 +2150,10 @@ void CallICStub::GenerateMiss(MacroAssembler* masm) {
__ push(edx); __ push(edx);
// Call the entry. // Call the entry.
IC::UtilityId id = GetICState() == DEFAULT ? IC::kCallIC_Miss Runtime::FunctionId id = GetICState() == DEFAULT
: IC::kCallIC_Customization_Miss; ? Runtime::kCallIC_Miss
: Runtime::kCallIC_Customization_Miss;
ExternalReference miss = ExternalReference(IC_Utility(id), masm->isolate()); __ CallRuntime(id, 3);
__ CallExternalReference(miss, 3);
// Move result to edi and exit the internal frame. // Move result to edi and exit the internal frame.
__ mov(edi, eax); __ mov(edi, eax);
...@@ -3586,15 +3583,13 @@ void CompareICStub::GenerateKnownObjects(MacroAssembler* masm) { ...@@ -3586,15 +3583,13 @@ void CompareICStub::GenerateKnownObjects(MacroAssembler* masm) {
void CompareICStub::GenerateMiss(MacroAssembler* masm) { void CompareICStub::GenerateMiss(MacroAssembler* masm) {
{ {
// Call the runtime system in a fresh internal frame. // Call the runtime system in a fresh internal frame.
ExternalReference miss = ExternalReference(IC_Utility(IC::kCompareIC_Miss),
isolate());
FrameScope scope(masm, StackFrame::INTERNAL); FrameScope scope(masm, StackFrame::INTERNAL);
__ push(edx); // Preserve edx and eax. __ push(edx); // Preserve edx and eax.
__ push(eax); __ push(eax);
__ push(edx); // And also use them as the arguments. __ push(edx); // And also use them as the arguments.
__ push(eax); __ push(eax);
__ push(Immediate(Smi::FromInt(op()))); __ push(Immediate(Smi::FromInt(op())));
__ CallExternalReference(miss, 3); __ CallRuntime(Runtime::kCompareIC_Miss, 3);
// Compute the entry point of the rewritten stub. // Compute the entry point of the rewritten stub.
__ lea(edi, FieldOperand(eax, Code::kHeaderSize)); __ lea(edi, FieldOperand(eax, Code::kHeaderSize));
__ pop(eax); __ pop(eax);
......
...@@ -70,7 +70,9 @@ void DebugCodegen::GenerateDebugBreakStub(MacroAssembler* masm, ...@@ -70,7 +70,9 @@ void DebugCodegen::GenerateDebugBreakStub(MacroAssembler* masm,
if (mode == SAVE_RESULT_REGISTER) __ push(eax); if (mode == SAVE_RESULT_REGISTER) __ push(eax);
__ Move(eax, Immediate(0)); // No arguments. __ Move(eax, Immediate(0)); // No arguments.
__ mov(ebx, Immediate(ExternalReference::debug_break(masm->isolate()))); __ mov(ebx,
Immediate(ExternalReference(
Runtime::FunctionForId(Runtime::kDebugBreak), masm->isolate())));
CEntryStub ceb(masm->isolate(), 1); CEntryStub ceb(masm->isolate(), 1);
__ CallStub(&ceb); __ CallStub(&ceb);
......
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