Commit b48f09d5 authored by mbrandy's avatar mbrandy Committed by Commit bot

PPC: [builtins] Sanitize receiver patching for API functions.

Port 12bcba15

Original commit message:
    The API functions are always in sloppy mode, so receiver is always a
    JSReceiver once the actual call trampoline runs, no need to check again
    in various places.

R=bmeurer@chromium.org, joransiu@ca.ibm.com, jyan@ca.ibm.com, michael_dawson@ca.ibm.com
BUG=

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

Cr-Commit-Position: refs/heads/master@{#33273}
parent 26a52ed4
......@@ -1301,9 +1301,6 @@ void CompatibleReceiverCheck(MacroAssembler* masm, Register receiver,
Register constructor = r9;
Register scratch = r10;
__ CompareObjectType(receiver, map, no_reg, FIRST_JS_OBJECT_TYPE);
__ blt(receiver_check_failed);
// If there is no signature, return the holder.
__ LoadP(signature, FieldMemOperand(function_template_info,
FunctionTemplateInfo::kSignatureOffset));
......@@ -1373,21 +1370,15 @@ void Builtins::Generate_HandleFastApiCall(MacroAssembler* masm) {
// -- sp[4 * argc] : receiver
// -----------------------------------
// Load the receiver.
__ ShiftLeftImm(r11, r3, Operand(kPointerSizeLog2));
__ LoadPX(r5, MemOperand(sp, r11));
// Update the receiver if this is a contextual call.
Label set_global_proxy, valid_receiver;
__ JumpIfRoot(r5, Heap::kUndefinedValueRootIndex, &set_global_proxy);
// Load the FunctionTemplateInfo.
__ bind(&valid_receiver);
__ LoadP(r6, FieldMemOperand(r4, JSFunction::kSharedFunctionInfoOffset));
__ LoadP(r6, FieldMemOperand(r6, SharedFunctionInfo::kFunctionDataOffset));
// Do the compatible receiver check.
Label receiver_check_failed;
__ ShiftLeftImm(r11, r3, Operand(kPointerSizeLog2));
__ LoadPX(r5, MemOperand(sp, r11));
CompatibleReceiverCheck(masm, r5, r6, &receiver_check_failed);
// Get the callback offset from the FunctionTemplateInfo, and jump to the
......@@ -1397,11 +1388,6 @@ void Builtins::Generate_HandleFastApiCall(MacroAssembler* masm) {
__ addi(ip, r7, Operand(Code::kHeaderSize - kHeapObjectTag));
__ JumpToJSEntry(ip);
__ bind(&set_global_proxy);
__ LoadGlobalProxy(r5);
__ StorePX(r5, MemOperand(sp, r11));
__ b(&valid_receiver);
// Compatible receiver check failed: throw an Illegal Invocation exception.
__ bind(&receiver_check_failed);
// Drop the arguments (including the receiver);
......
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