Commit 1a57cede authored by mbrandy's avatar mbrandy Committed by Commit bot

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

Port bc8041dc

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.

R=danno@chromium.org, dstence@us.ibm.com, michael_dawson@ca.ibm.com
BUG=

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

Cr-Commit-Position: refs/heads/master@{#29821}
parent f80e6869
...@@ -221,10 +221,9 @@ static void PushInterceptorArguments(MacroAssembler* masm, Register receiver, ...@@ -221,10 +221,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);
} }
...@@ -314,9 +313,7 @@ void NamedStoreHandlerCompiler::GenerateSlow(MacroAssembler* masm) { ...@@ -314,9 +313,7 @@ void NamedStoreHandlerCompiler::GenerateSlow(MacroAssembler* masm) {
// The slow case calls into the runtime to complete the store without causing // The slow case calls into the runtime to complete the store without causing
// an IC miss that would otherwise cause a transition to the generic stub. // an IC miss that would otherwise cause a transition to the generic stub.
ExternalReference ref = __ TailCallRuntime(Runtime::kStoreIC_Slow, 3, 1);
ExternalReference(IC_Utility(IC::kStoreIC_Slow), masm->isolate());
__ TailCallExternalReference(ref, 3, 1);
} }
...@@ -327,9 +324,7 @@ void ElementHandlerCompiler::GenerateStoreSlow(MacroAssembler* masm) { ...@@ -327,9 +324,7 @@ void ElementHandlerCompiler::GenerateStoreSlow(MacroAssembler* masm) {
// The slow case calls into the runtime to complete the store without causing // The slow case calls into the runtime to complete the store without causing
// an IC miss that would otherwise cause a transition to the generic stub. // an IC miss that would otherwise cause a transition to the generic stub.
ExternalReference ref = __ TailCallRuntime(Runtime::kKeyedStoreIC_Slow, 3, 1);
ExternalReference(IC_Utility(IC::kKeyedStoreIC_Slow), masm->isolate());
__ TailCallExternalReference(ref, 3, 1);
} }
...@@ -667,7 +662,7 @@ void NamedLoadHandlerCompiler::GenerateLoadInterceptorWithFollowup( ...@@ -667,7 +662,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.
...@@ -699,10 +694,8 @@ void NamedLoadHandlerCompiler::GenerateLoadInterceptor(Register holder_reg) { ...@@ -699,10 +694,8 @@ void NamedLoadHandlerCompiler::GenerateLoadInterceptor(Register holder_reg) {
PushInterceptorArguments(masm(), receiver(), holder_reg, this->name(), PushInterceptorArguments(masm(), receiver(), holder_reg, this->name(),
holder()); holder());
ExternalReference ref = ExternalReference( __ TailCallRuntime(Runtime::kLoadPropertyWithInterceptor,
IC_Utility(IC::kLoadPropertyWithInterceptor), isolate()); NamedLoadHandlerCompiler::kInterceptorArgsLength, 1);
__ TailCallExternalReference(
ref, NamedLoadHandlerCompiler::kInterceptorArgsLength, 1);
} }
...@@ -726,9 +719,7 @@ Handle<Code> NamedStoreHandlerCompiler::CompileStoreCallback( ...@@ -726,9 +719,7 @@ Handle<Code> NamedStoreHandlerCompiler::CompileStoreCallback(
__ Push(ip, value()); __ Push(ip, value());
// 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);
...@@ -740,9 +731,7 @@ Handle<Code> NamedStoreHandlerCompiler::CompileStoreInterceptor( ...@@ -740,9 +731,7 @@ Handle<Code> NamedStoreHandlerCompiler::CompileStoreInterceptor(
__ Push(receiver(), this->name(), value()); __ Push(receiver(), this->name(), value());
// 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);
......
...@@ -323,9 +323,8 @@ void LoadIC::GenerateMiss(MacroAssembler* masm) { ...@@ -323,9 +323,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), isolate);
int arg_count = 4; int arg_count = 4;
__ TailCallExternalReference(ref, arg_count, 1); __ TailCallRuntime(Runtime::kLoadIC_Miss, arg_count, 1);
} }
...@@ -354,10 +353,8 @@ void KeyedLoadIC::GenerateMiss(MacroAssembler* masm) { ...@@ -354,10 +353,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), isolate);
int arg_count = 4; int arg_count = 4;
__ TailCallExternalReference(ref, arg_count, 1); __ TailCallRuntime(Runtime::kKeyedLoadIC_Miss, arg_count, 1);
} }
...@@ -482,9 +479,7 @@ void KeyedStoreIC::GenerateMiss(MacroAssembler* masm) { ...@@ -482,9 +479,7 @@ void KeyedStoreIC::GenerateMiss(MacroAssembler* masm) {
__ Push(StoreDescriptor::ReceiverRegister(), StoreDescriptor::NameRegister(), __ Push(StoreDescriptor::ReceiverRegister(), StoreDescriptor::NameRegister(),
StoreDescriptor::ValueRegister()); StoreDescriptor::ValueRegister());
ExternalReference ref = __ TailCallRuntime(Runtime::kKeyedStoreIC_Miss, 3, 1);
ExternalReference(IC_Utility(kKeyedStoreIC_Miss), masm->isolate());
__ TailCallExternalReference(ref, 3, 1);
} }
...@@ -790,9 +785,7 @@ void StoreIC::GenerateMiss(MacroAssembler* masm) { ...@@ -790,9 +785,7 @@ void StoreIC::GenerateMiss(MacroAssembler* masm) {
StoreDescriptor::ValueRegister()); StoreDescriptor::ValueRegister());
// 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);
} }
......
...@@ -1973,10 +1973,7 @@ void LoadIndexedInterceptorStub::Generate(MacroAssembler* masm) { ...@@ -1973,10 +1973,7 @@ void LoadIndexedInterceptorStub::Generate(MacroAssembler* masm) {
__ Push(receiver, key); // Receiver, key. __ Push(receiver, key); // Receiver, key.
// Perform tail call to the entry. // Perform tail call to the entry.
__ TailCallExternalReference( __ TailCallRuntime(Runtime::kLoadElementWithInterceptor, 2, 1);
ExternalReference(IC_Utility(IC::kLoadElementWithInterceptor),
masm->isolate()),
2, 1);
__ bind(&slow); __ bind(&slow);
PropertyAccessCompiler::TailCallBuiltin( PropertyAccessCompiler::TailCallBuiltin(
...@@ -3087,11 +3084,10 @@ void CallICStub::GenerateMiss(MacroAssembler* masm) { ...@@ -3087,11 +3084,10 @@ void CallICStub::GenerateMiss(MacroAssembler* masm) {
__ Push(r4, r5, r6); __ Push(r4, r5, r6);
// 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 r4 and exit the internal frame. // Move result to r4 and exit the internal frame.
__ mr(r4, r3); __ mr(r4, r3);
...@@ -4046,15 +4042,12 @@ void CompareICStub::GenerateKnownObjects(MacroAssembler* masm) { ...@@ -4046,15 +4042,12 @@ 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());
FrameAndConstantPoolScope scope(masm, StackFrame::INTERNAL); FrameAndConstantPoolScope scope(masm, StackFrame::INTERNAL);
__ Push(r4, r3); __ Push(r4, r3);
__ Push(r4, r3); __ Push(r4, r3);
__ LoadSmiLiteral(r0, Smi::FromInt(op())); __ LoadSmiLiteral(r0, Smi::FromInt(op()));
__ push(r0); __ push(r0);
__ CallExternalReference(miss, 3); __ CallRuntime(Runtime::kCompareIC_Miss, 3);
// Compute the entry point of the rewritten stub. // Compute the entry point of the rewritten stub.
__ addi(r5, r3, Operand(Code::kHeaderSize - kHeapObjectTag)); __ addi(r5, r3, Operand(Code::kHeaderSize - kHeapObjectTag));
// Restore registers. // Restore registers.
......
...@@ -84,7 +84,9 @@ void DebugCodegen::GenerateDebugBreakStub(MacroAssembler* masm, ...@@ -84,7 +84,9 @@ void DebugCodegen::GenerateDebugBreakStub(MacroAssembler* masm,
if (mode == SAVE_RESULT_REGISTER) __ push(r3); if (mode == SAVE_RESULT_REGISTER) __ push(r3);
__ mov(r3, Operand::Zero()); // no arguments __ mov(r3, Operand::Zero()); // no arguments
__ mov(r4, Operand(ExternalReference::debug_break(masm->isolate()))); __ mov(r4,
Operand(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