From 50c6b031fd2a474e642865b37f4d5de3b4618ff8 Mon Sep 17 00:00:00 2001 From: mbrandy Date: Wed, 9 Sep 2015 07:27:20 -0700 Subject: [PATCH] PPC: [runtime] Replace many buggy uses of %_CallFunction with %_Call. Port db2ba190dba6983b94eae36e111b0feebb97587e Original commit message: The semantics of the %_CallFunction intrinsic seem to be very unclear, which resulted in a lot of bugs. Especially the combination with %IsSloppyModeFunction is always a bug, because the receiver would be wrapped in the wrong context. So the %IsSloppyModeFunction helper is gone now, and many of the buggy uses of %_CallFunction are also eliminated. If you ever need to call something with a different receiver, then %_Call is your friend now. It does what you want and implements the call sequence fully (and correct). R=bmeurer@chromium.org, joransiu@ca.ibm.com, jyan@ca.ibm.com, michael_dawson@ca.ibm.com, dstence@us.ibm.com BUG=v8:4413 LOG=n Review URL: https://codereview.chromium.org/1310303008 Cr-Commit-Position: refs/heads/master@{#30655} --- src/full-codegen/ppc/full-codegen-ppc.cc | 22 +++++++++++++++++++++- src/ppc/interface-descriptors-ppc.cc | 9 +++++++++ 2 files changed, 30 insertions(+), 1 deletion(-) diff --git a/src/full-codegen/ppc/full-codegen-ppc.cc b/src/full-codegen/ppc/full-codegen-ppc.cc index 0a25554..5e5417b 100644 --- a/src/full-codegen/ppc/full-codegen-ppc.cc +++ b/src/full-codegen/ppc/full-codegen-ppc.cc @@ -4056,6 +4056,26 @@ void FullCodeGenerator::EmitStringAdd(CallRuntime* expr) { } +void FullCodeGenerator::EmitCall(CallRuntime* expr) { + ZoneList* args = expr->arguments(); + DCHECK_LE(2, args->length()); + // Push target, receiver and arguments onto the stack. + for (Expression* const arg : *args) { + VisitForStackValue(arg); + } + // Move target to r4. + int const argc = args->length() - 2; + __ LoadP(r4, MemOperand(sp, (argc + 1) * kPointerSize)); + // Call the target. + __ mov(r3, Operand(argc)); + __ Call(isolate()->builtins()->Call(), RelocInfo::CODE_TARGET); + // Restore context register. + __ LoadP(cp, MemOperand(fp, StandardFrameConstants::kContextOffset)); + // Discard the function left on TOS. + context()->DropAndPlug(1, r3); +} + + void FullCodeGenerator::EmitCallFunction(CallRuntime* expr) { ZoneList* args = expr->arguments(); DCHECK(args->length() >= 2); @@ -4081,7 +4101,7 @@ void FullCodeGenerator::EmitCallFunction(CallRuntime* expr) { __ bind(&runtime); __ push(r3); - __ CallRuntime(Runtime::kCall, args->length()); + __ CallRuntime(Runtime::kCallFunction, args->length()); __ bind(&done); context()->Plug(r3); diff --git a/src/ppc/interface-descriptors-ppc.cc b/src/ppc/interface-descriptors-ppc.cc index 70dcb0f..5fda82f 100644 --- a/src/ppc/interface-descriptors-ppc.cc +++ b/src/ppc/interface-descriptors-ppc.cc @@ -190,6 +190,15 @@ void CallConstructDescriptor::InitializePlatformSpecific( } +void CallTrampolineDescriptor::InitializePlatformSpecific( + CallInterfaceDescriptorData* data) { + // r3 : number of arguments + // r4 : the target to call + Register registers[] = {r4, r3}; + data->InitializePlatformSpecific(arraysize(registers), registers); +} + + void RegExpConstructResultDescriptor::InitializePlatformSpecific( CallInterfaceDescriptorData* data) { Register registers[] = {r5, r4, r3}; -- 2.7.4