Commit e101aa7f authored by zhengxing.li's avatar zhengxing.li Committed by Commit bot

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

  port 12bcba15 (r33258)

  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.

BUG=

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

Cr-Commit-Position: refs/heads/master@{#33278}
parent 92610888
......@@ -2254,10 +2254,6 @@ static void CompatibleReceiverCheck(MacroAssembler* masm, Register receiver,
Register function_template_info,
Register scratch0, Register scratch1,
Label* receiver_check_failed) {
// If receiver is not an object, jump to receiver_check_failed.
__ CmpObjectType(receiver, FIRST_JS_OBJECT_TYPE, scratch0);
__ j(below, receiver_check_failed);
// If there is no signature, return the holder.
__ CompareRoot(FieldOperand(function_template_info,
FunctionTemplateInfo::kSignatureOffset),
......@@ -2331,22 +2327,13 @@ void Builtins::Generate_HandleFastApiCall(MacroAssembler* masm) {
// -- esp[(eax + 1) * 4] : receiver
// -----------------------------------
// Load the receiver.
Operand receiver_operand(esp, eax, times_pointer_size, kPCOnStackSize);
__ mov(ecx, receiver_operand);
// Update the receiver if this is a contextual call.
Label set_global_proxy, valid_receiver;
__ CompareRoot(ecx, Heap::kUndefinedValueRootIndex);
__ j(equal, &set_global_proxy);
__ bind(&valid_receiver);
// Load the FunctionTemplateInfo.
__ mov(ebx, FieldOperand(edi, JSFunction::kSharedFunctionInfoOffset));
__ mov(ebx, FieldOperand(ebx, SharedFunctionInfo::kFunctionDataOffset));
// Do the compatible receiver check.
Label receiver_check_failed;
__ mov(ecx, Operand(esp, eax, times_pointer_size, kPCOnStackSize));
__ Push(eax);
CompatibleReceiverCheck(masm, ecx, ebx, edx, eax, &receiver_check_failed);
__ Pop(eax);
......@@ -2357,12 +2344,6 @@ void Builtins::Generate_HandleFastApiCall(MacroAssembler* masm) {
__ add(edx, Immediate(Code::kHeaderSize - kHeapObjectTag));
__ jmp(edx);
__ bind(&set_global_proxy);
__ mov(ecx, NativeContextOperand());
__ mov(ecx, ContextOperand(ecx, Context::GLOBAL_PROXY_INDEX));
__ mov(receiver_operand, ecx);
__ jmp(&valid_receiver, Label::kNear);
// Compatible receiver check failed: pop return address, arguments and
// receiver and throw an Illegal Invocation exception.
__ bind(&receiver_check_failed);
......
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