Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(209)

Side by Side Diff: src/x64/builtins-x64.cc

Issue 1576423003: Fix the receiver check in the HandleFastApiCall builtin. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Rebased. Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/ppc/builtins-ppc.cc ('k') | src/x87/builtins-x87.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #if V8_TARGET_ARCH_X64 5 #if V8_TARGET_ARCH_X64
6 6
7 #include "src/code-factory.h" 7 #include "src/code-factory.h"
8 #include "src/codegen.h" 8 #include "src/codegen.h"
9 #include "src/deoptimizer.h" 9 #include "src/deoptimizer.h"
10 #include "src/full-codegen/full-codegen.h" 10 #include "src/full-codegen/full-codegen.h"
(...skipping 2418 matching lines...) Expand 10 before | Expand all | Expand 10 after
2429 Register constructor = scratch2; 2429 Register constructor = scratch2;
2430 2430
2431 // If there is no signature, return the holder. 2431 // If there is no signature, return the holder.
2432 __ movp(signature, FieldOperand(function_template_info, 2432 __ movp(signature, FieldOperand(function_template_info,
2433 FunctionTemplateInfo::kSignatureOffset)); 2433 FunctionTemplateInfo::kSignatureOffset));
2434 __ CompareRoot(signature, Heap::kUndefinedValueRootIndex); 2434 __ CompareRoot(signature, Heap::kUndefinedValueRootIndex);
2435 Label receiver_check_passed; 2435 Label receiver_check_passed;
2436 __ j(equal, &receiver_check_passed, Label::kNear); 2436 __ j(equal, &receiver_check_passed, Label::kNear);
2437 2437
2438 // Walk the prototype chain. 2438 // Walk the prototype chain.
2439 __ movp(map, FieldOperand(receiver, HeapObject::kMapOffset));
2439 Label prototype_loop_start; 2440 Label prototype_loop_start;
2440 __ bind(&prototype_loop_start); 2441 __ bind(&prototype_loop_start);
2441 2442
2442 // End if the receiver is null or if it's a hidden prototype.
2443 __ CompareRoot(receiver, Heap::kNullValueRootIndex);
2444 __ j(equal, receiver_check_failed, Label::kNear);
2445 __ movp(map, FieldOperand(receiver, HeapObject::kMapOffset));
2446 __ testq(FieldOperand(map, Map::kBitField3Offset),
2447 Immediate(Map::IsHiddenPrototype::kMask));
2448 __ j(not_zero, receiver_check_failed, Label::kNear);
2449
2450 // Get the constructor, if any. 2443 // Get the constructor, if any.
2451 __ GetMapConstructor(constructor, map, kScratchRegister); 2444 __ GetMapConstructor(constructor, map, kScratchRegister);
2452 __ CmpInstanceType(kScratchRegister, JS_FUNCTION_TYPE); 2445 __ CmpInstanceType(kScratchRegister, JS_FUNCTION_TYPE);
2453 Label next_prototype; 2446 Label next_prototype;
2454 __ j(not_equal, &next_prototype, Label::kNear); 2447 __ j(not_equal, &next_prototype, Label::kNear);
2455 2448
2456 // Get the constructor's signature. 2449 // Get the constructor's signature.
2457 Register type = constructor; 2450 Register type = constructor;
2458 __ movp(type, 2451 __ movp(type,
2459 FieldOperand(constructor, JSFunction::kSharedFunctionInfoOffset)); 2452 FieldOperand(constructor, JSFunction::kSharedFunctionInfoOffset));
(...skipping 11 matching lines...) Expand all
2471 // in the chain. 2464 // in the chain.
2472 __ JumpIfSmi(type, &next_prototype, Label::kNear); 2465 __ JumpIfSmi(type, &next_prototype, Label::kNear);
2473 __ CmpObjectType(type, FUNCTION_TEMPLATE_INFO_TYPE, kScratchRegister); 2466 __ CmpObjectType(type, FUNCTION_TEMPLATE_INFO_TYPE, kScratchRegister);
2474 __ j(not_equal, &next_prototype, Label::kNear); 2467 __ j(not_equal, &next_prototype, Label::kNear);
2475 2468
2476 // Otherwise load the parent function template and iterate. 2469 // Otherwise load the parent function template and iterate.
2477 __ movp(type, 2470 __ movp(type,
2478 FieldOperand(type, FunctionTemplateInfo::kParentTemplateOffset)); 2471 FieldOperand(type, FunctionTemplateInfo::kParentTemplateOffset));
2479 __ jmp(&function_template_loop, Label::kNear); 2472 __ jmp(&function_template_loop, Label::kNear);
2480 2473
2481 // Load the next prototype and iterate. 2474 // Load the next prototype.
2482 __ bind(&next_prototype); 2475 __ bind(&next_prototype);
2483 __ movp(receiver, FieldOperand(map, Map::kPrototypeOffset)); 2476 __ movp(receiver, FieldOperand(map, Map::kPrototypeOffset));
2477 // End if the prototype is null or not hidden.
2478 __ CompareRoot(receiver, Heap::kNullValueRootIndex);
2479 __ j(equal, receiver_check_failed);
2480 __ movp(map, FieldOperand(receiver, HeapObject::kMapOffset));
2481 __ testq(FieldOperand(map, Map::kBitField3Offset),
2482 Immediate(Map::IsHiddenPrototype::kMask));
2483 __ j(zero, receiver_check_failed);
2484 // Iterate.
2484 __ jmp(&prototype_loop_start, Label::kNear); 2485 __ jmp(&prototype_loop_start, Label::kNear);
2485 2486
2486 __ bind(&receiver_check_passed); 2487 __ bind(&receiver_check_passed);
2487 } 2488 }
2488 2489
2489 2490
2490 void Builtins::Generate_HandleFastApiCall(MacroAssembler* masm) { 2491 void Builtins::Generate_HandleFastApiCall(MacroAssembler* masm) {
2491 // ----------- S t a t e ------------- 2492 // ----------- S t a t e -------------
2492 // -- rax : number of arguments (not including the receiver) 2493 // -- rax : number of arguments (not including the receiver)
2493 // -- rdi : callee 2494 // -- rdi : callee
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
2583 __ ret(0); 2584 __ ret(0);
2584 } 2585 }
2585 2586
2586 2587
2587 #undef __ 2588 #undef __
2588 2589
2589 } // namespace internal 2590 } // namespace internal
2590 } // namespace v8 2591 } // namespace v8
2591 2592
2592 #endif // V8_TARGET_ARCH_X64 2593 #endif // V8_TARGET_ARCH_X64
OLDNEW
« no previous file with comments | « src/ppc/builtins-ppc.cc ('k') | src/x87/builtins-x87.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698