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

Side by Side Diff: src/arm/code-stubs-arm.cc

Issue 1311013008: [builtins] Unify the various versions of [[Call]] with a Call builtin. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: AssertFunction was wrong Created 5 years, 3 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/arm/builtins-arm.cc ('k') | src/arm/macro-assembler-arm.h » ('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_ARM 5 #if V8_TARGET_ARCH_ARM
6 6
7 #include "src/base/bits.h" 7 #include "src/base/bits.h"
8 #include "src/bootstrapper.h" 8 #include "src/bootstrapper.h"
9 #include "src/code-stubs.h" 9 #include "src/code-stubs.h"
10 #include "src/codegen.h" 10 #include "src/codegen.h"
(...skipping 2377 matching lines...) Expand 10 before | Expand all | Expand 10 after
2388 __ tst(r4, Operand(1 << (SharedFunctionInfo::kStrictModeFunction + 2388 __ tst(r4, Operand(1 << (SharedFunctionInfo::kStrictModeFunction +
2389 kSmiTagSize))); 2389 kSmiTagSize)));
2390 __ b(ne, cont); 2390 __ b(ne, cont);
2391 2391
2392 // Do not transform the receiver for native (Compilerhints already in r3). 2392 // Do not transform the receiver for native (Compilerhints already in r3).
2393 __ tst(r4, Operand(1 << (SharedFunctionInfo::kNative + kSmiTagSize))); 2393 __ tst(r4, Operand(1 << (SharedFunctionInfo::kNative + kSmiTagSize)));
2394 __ b(ne, cont); 2394 __ b(ne, cont);
2395 } 2395 }
2396 2396
2397 2397
2398 static void EmitSlowCase(MacroAssembler* masm, 2398 static void EmitSlowCase(MacroAssembler* masm, int argc) {
2399 int argc, 2399 __ mov(r0, Operand(argc));
2400 Label* non_function) { 2400 __ Jump(masm->isolate()->builtins()->Call(), RelocInfo::CODE_TARGET);
2401 // Check for function proxy.
2402 __ cmp(r4, Operand(JS_FUNCTION_PROXY_TYPE));
2403 __ b(ne, non_function);
2404 __ push(r1); // put proxy as additional argument
2405 __ mov(r0, Operand(argc + 1, RelocInfo::NONE32));
2406 __ mov(r2, Operand::Zero());
2407 __ GetBuiltinFunction(r1, Context::CALL_FUNCTION_PROXY_BUILTIN_INDEX);
2408 {
2409 Handle<Code> adaptor =
2410 masm->isolate()->builtins()->ArgumentsAdaptorTrampoline();
2411 __ Jump(adaptor, RelocInfo::CODE_TARGET);
2412 }
2413
2414 // CALL_NON_FUNCTION expects the non-function callee as receiver (instead
2415 // of the original receiver from the call site).
2416 __ bind(non_function);
2417 __ str(r1, MemOperand(sp, argc * kPointerSize));
2418 __ mov(r0, Operand(argc)); // Set up the number of arguments.
2419 __ mov(r2, Operand::Zero());
2420 __ GetBuiltinFunction(r1, Context::CALL_NON_FUNCTION_BUILTIN_INDEX);
2421 __ Jump(masm->isolate()->builtins()->ArgumentsAdaptorTrampoline(),
2422 RelocInfo::CODE_TARGET);
2423 } 2401 }
2424 2402
2425 2403
2426 static void EmitWrapCase(MacroAssembler* masm, int argc, Label* cont) { 2404 static void EmitWrapCase(MacroAssembler* masm, int argc, Label* cont) {
2427 // Wrap the receiver and patch it back onto the stack. 2405 // Wrap the receiver and patch it back onto the stack.
2428 { FrameAndConstantPoolScope frame_scope(masm, StackFrame::INTERNAL); 2406 { FrameAndConstantPoolScope frame_scope(masm, StackFrame::INTERNAL);
2429 __ push(r1); 2407 __ push(r1);
2430 __ mov(r0, r3); 2408 __ mov(r0, r3);
2431 ToObjectStub stub(masm->isolate()); 2409 ToObjectStub stub(masm->isolate());
2432 __ CallStub(&stub); 2410 __ CallStub(&stub);
2433 __ pop(r1); 2411 __ pop(r1);
2434 } 2412 }
2435 __ str(r0, MemOperand(sp, argc * kPointerSize)); 2413 __ str(r0, MemOperand(sp, argc * kPointerSize));
2436 __ jmp(cont); 2414 __ jmp(cont);
2437 } 2415 }
2438 2416
2439 2417
2440 static void CallFunctionNoFeedback(MacroAssembler* masm, 2418 static void CallFunctionNoFeedback(MacroAssembler* masm,
2441 int argc, bool needs_checks, 2419 int argc, bool needs_checks,
2442 bool call_as_method) { 2420 bool call_as_method) {
2443 // r1 : the function to call 2421 // r1 : the function to call
2444 Label slow, non_function, wrap, cont; 2422 Label slow, wrap, cont;
2445 2423
2446 if (needs_checks) { 2424 if (needs_checks) {
2447 // Check that the function is really a JavaScript function. 2425 // Check that the function is really a JavaScript function.
2448 // r1: pushed function (to be verified) 2426 // r1: pushed function (to be verified)
2449 __ JumpIfSmi(r1, &non_function); 2427 __ JumpIfSmi(r1, &slow);
2450 2428
2451 // Goto slow case if we do not have a function. 2429 // Goto slow case if we do not have a function.
2452 __ CompareObjectType(r1, r4, r4, JS_FUNCTION_TYPE); 2430 __ CompareObjectType(r1, r4, r4, JS_FUNCTION_TYPE);
2453 __ b(ne, &slow); 2431 __ b(ne, &slow);
2454 } 2432 }
2455 2433
2456 // Fast-case: Invoke the function now. 2434 // Fast-case: Invoke the function now.
2457 // r1: pushed function 2435 // r1: pushed function
2458 ParameterCount actual(argc); 2436 ParameterCount actual(argc);
2459 2437
(...skipping 14 matching lines...) Expand all
2474 } 2452 }
2475 2453
2476 __ bind(&cont); 2454 __ bind(&cont);
2477 } 2455 }
2478 2456
2479 __ InvokeFunction(r1, actual, JUMP_FUNCTION, NullCallWrapper()); 2457 __ InvokeFunction(r1, actual, JUMP_FUNCTION, NullCallWrapper());
2480 2458
2481 if (needs_checks) { 2459 if (needs_checks) {
2482 // Slow-case: Non-function called. 2460 // Slow-case: Non-function called.
2483 __ bind(&slow); 2461 __ bind(&slow);
2484 EmitSlowCase(masm, argc, &non_function); 2462 EmitSlowCase(masm, argc);
2485 } 2463 }
2486 2464
2487 if (call_as_method) { 2465 if (call_as_method) {
2488 __ bind(&wrap); 2466 __ bind(&wrap);
2489 EmitWrapCase(masm, argc, &cont); 2467 EmitWrapCase(masm, argc, &cont);
2490 } 2468 }
2491 } 2469 }
2492 2470
2493 2471
2494 void CallFunctionStub::Generate(MacroAssembler* masm) { 2472 void CallFunctionStub::Generate(MacroAssembler* masm) {
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
2608 2586
2609 __ mov(r2, r4); 2587 __ mov(r2, r4);
2610 __ mov(r3, r1); 2588 __ mov(r3, r1);
2611 ArrayConstructorStub stub(masm->isolate(), arg_count()); 2589 ArrayConstructorStub stub(masm->isolate(), arg_count());
2612 __ TailCallStub(&stub); 2590 __ TailCallStub(&stub);
2613 2591
2614 __ bind(&miss); 2592 __ bind(&miss);
2615 GenerateMiss(masm); 2593 GenerateMiss(masm);
2616 2594
2617 // The slow case, we need this no matter what to complete a call after a miss. 2595 // The slow case, we need this no matter what to complete a call after a miss.
2618 CallFunctionNoFeedback(masm, 2596 __ mov(r0, Operand(arg_count()));
2619 arg_count(), 2597 __ Jump(masm->isolate()->builtins()->Call(), RelocInfo::CODE_TARGET);
2620 true,
2621 CallAsMethod());
2622
2623 // Unreachable.
2624 __ stop("Unexpected code address");
2625 } 2598 }
2626 2599
2627 2600
2628 void CallICStub::Generate(MacroAssembler* masm) { 2601 void CallICStub::Generate(MacroAssembler* masm) {
2629 // r1 - function 2602 // r1 - function
2630 // r3 - slot id (Smi) 2603 // r3 - slot id (Smi)
2631 // r2 - vector 2604 // r2 - vector
2632 const int with_types_offset = 2605 const int with_types_offset =
2633 FixedArray::OffsetOfElementAt(TypeFeedbackVector::kWithTypesIndex); 2606 FixedArray::OffsetOfElementAt(TypeFeedbackVector::kWithTypesIndex);
2634 const int generic_offset = 2607 const int generic_offset =
2635 FixedArray::OffsetOfElementAt(TypeFeedbackVector::kGenericCountIndex); 2608 FixedArray::OffsetOfElementAt(TypeFeedbackVector::kGenericCountIndex);
2636 Label extra_checks_or_miss, slow_start; 2609 Label extra_checks_or_miss, slow_start;
2637 Label slow, non_function, wrap, cont; 2610 Label slow, wrap, cont;
2638 Label have_js_function; 2611 Label have_js_function;
2639 int argc = arg_count(); 2612 int argc = arg_count();
2640 ParameterCount actual(argc); 2613 ParameterCount actual(argc);
2641 2614
2642 // The checks. First, does r1 match the recorded monomorphic target? 2615 // The checks. First, does r1 match the recorded monomorphic target?
2643 __ add(r4, r2, Operand::PointerOffsetFromSmiKey(r3)); 2616 __ add(r4, r2, Operand::PointerOffsetFromSmiKey(r3));
2644 __ ldr(r4, FieldMemOperand(r4, FixedArray::kHeaderSize)); 2617 __ ldr(r4, FieldMemOperand(r4, FixedArray::kHeaderSize));
2645 2618
2646 // We don't know that we have a weak cell. We might have a private symbol 2619 // We don't know that we have a weak cell. We might have a private symbol
2647 // or an AllocationSite, but the memory is safe to examine. 2620 // or an AllocationSite, but the memory is safe to examine.
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
2681 __ JumpIfSmi(r3, &wrap); 2654 __ JumpIfSmi(r3, &wrap);
2682 __ CompareObjectType(r3, r4, r4, FIRST_SPEC_OBJECT_TYPE); 2655 __ CompareObjectType(r3, r4, r4, FIRST_SPEC_OBJECT_TYPE);
2683 __ b(lt, &wrap); 2656 __ b(lt, &wrap);
2684 2657
2685 __ bind(&cont); 2658 __ bind(&cont);
2686 } 2659 }
2687 2660
2688 __ InvokeFunction(r1, actual, JUMP_FUNCTION, NullCallWrapper()); 2661 __ InvokeFunction(r1, actual, JUMP_FUNCTION, NullCallWrapper());
2689 2662
2690 __ bind(&slow); 2663 __ bind(&slow);
2691 EmitSlowCase(masm, argc, &non_function); 2664 EmitSlowCase(masm, argc);
2692 2665
2693 if (CallAsMethod()) { 2666 if (CallAsMethod()) {
2694 __ bind(&wrap); 2667 __ bind(&wrap);
2695 EmitWrapCase(masm, argc, &cont); 2668 EmitWrapCase(masm, argc, &cont);
2696 } 2669 }
2697 2670
2698 __ bind(&extra_checks_or_miss); 2671 __ bind(&extra_checks_or_miss);
2699 Label uninitialized, miss; 2672 Label uninitialized, miss;
2700 2673
2701 __ CompareRoot(r4, Heap::kmegamorphic_symbolRootIndex); 2674 __ CompareRoot(r4, Heap::kmegamorphic_symbolRootIndex);
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
2768 2741
2769 // We are here because tracing is on or we encountered a MISS case we can't 2742 // We are here because tracing is on or we encountered a MISS case we can't
2770 // handle here. 2743 // handle here.
2771 __ bind(&miss); 2744 __ bind(&miss);
2772 GenerateMiss(masm); 2745 GenerateMiss(masm);
2773 2746
2774 // the slow case 2747 // the slow case
2775 __ bind(&slow_start); 2748 __ bind(&slow_start);
2776 // Check that the function is really a JavaScript function. 2749 // Check that the function is really a JavaScript function.
2777 // r1: pushed function (to be verified) 2750 // r1: pushed function (to be verified)
2778 __ JumpIfSmi(r1, &non_function); 2751 __ JumpIfSmi(r1, &slow);
2779 2752
2780 // Goto slow case if we do not have a function. 2753 // Goto slow case if we do not have a function.
2781 __ CompareObjectType(r1, r4, r4, JS_FUNCTION_TYPE); 2754 __ CompareObjectType(r1, r4, r4, JS_FUNCTION_TYPE);
2782 __ b(ne, &slow); 2755 __ b(ne, &slow);
2783 __ jmp(&have_js_function); 2756 __ jmp(&have_js_function);
2784 } 2757 }
2785 2758
2786 2759
2787 void CallICStub::GenerateMiss(MacroAssembler* masm) { 2760 void CallICStub::GenerateMiss(MacroAssembler* masm) {
2788 FrameAndConstantPoolScope scope(masm, StackFrame::INTERNAL); 2761 FrameAndConstantPoolScope scope(masm, StackFrame::INTERNAL);
(...skipping 2802 matching lines...) Expand 10 before | Expand all | Expand 10 after
5591 MemOperand(fp, 6 * kPointerSize), NULL); 5564 MemOperand(fp, 6 * kPointerSize), NULL);
5592 } 5565 }
5593 5566
5594 5567
5595 #undef __ 5568 #undef __
5596 5569
5597 } // namespace internal 5570 } // namespace internal
5598 } // namespace v8 5571 } // namespace v8
5599 5572
5600 #endif // V8_TARGET_ARCH_ARM 5573 #endif // V8_TARGET_ARCH_ARM
OLDNEW
« no previous file with comments | « src/arm/builtins-arm.cc ('k') | src/arm/macro-assembler-arm.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698