| OLD | NEW |
| 1 // Copyright 2010 the V8 project authors. All rights reserved. | 1 // Copyright 2010 the V8 project authors. All rights reserved. |
| 2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
| 3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
| 4 // met: | 4 // met: |
| 5 // | 5 // |
| 6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
| 7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
| 8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
| 9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
| 10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
| (...skipping 2465 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2476 __ xor_(rsi, rsi); // tentatively set context pointer to NULL | 2476 __ xor_(rsi, rsi); // tentatively set context pointer to NULL |
| 2477 NearLabel skip; | 2477 NearLabel skip; |
| 2478 __ cmpq(rbp, Immediate(0)); | 2478 __ cmpq(rbp, Immediate(0)); |
| 2479 __ j(equal, &skip); | 2479 __ j(equal, &skip); |
| 2480 __ movq(rsi, Operand(rbp, StandardFrameConstants::kContextOffset)); | 2480 __ movq(rsi, Operand(rbp, StandardFrameConstants::kContextOffset)); |
| 2481 __ bind(&skip); | 2481 __ bind(&skip); |
| 2482 __ ret(0); | 2482 __ ret(0); |
| 2483 } | 2483 } |
| 2484 | 2484 |
| 2485 | 2485 |
| 2486 void ApiGetterEntryStub::Generate(MacroAssembler* masm) { | |
| 2487 __ PrepareCallApiFunction(kStackSpace); | |
| 2488 #ifdef _WIN64 | |
| 2489 // All the parameters should be set up by a caller. | |
| 2490 #else | |
| 2491 // Set 1st parameter register with property name. | |
| 2492 __ movq(rsi, rdx); | |
| 2493 // Second parameter register rdi should be set with pointer to AccessorInfo | |
| 2494 // by a caller. | |
| 2495 #endif | |
| 2496 __ CallApiFunctionAndReturn(fun()); | |
| 2497 } | |
| 2498 | |
| 2499 | |
| 2500 void CEntryStub::GenerateCore(MacroAssembler* masm, | 2486 void CEntryStub::GenerateCore(MacroAssembler* masm, |
| 2501 Label* throw_normal_exception, | 2487 Label* throw_normal_exception, |
| 2502 Label* throw_termination_exception, | 2488 Label* throw_termination_exception, |
| 2503 Label* throw_out_of_memory_exception, | 2489 Label* throw_out_of_memory_exception, |
| 2504 bool do_gc, | 2490 bool do_gc, |
| 2505 bool always_allocate_scope, | 2491 bool always_allocate_scope, |
| 2506 int /* alignment_skew */) { | 2492 int /* alignment_skew */) { |
| 2507 // rax: result parameter for PerformGC, if any. | 2493 // rax: result parameter for PerformGC, if any. |
| 2508 // rbx: pointer to C function (C callee-saved). | 2494 // rbx: pointer to C function (C callee-saved). |
| 2509 // rbp: frame pointer (restored after C call). | 2495 // rbp: frame pointer (restored after C call). |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2542 ExternalReference::heap_always_allocate_scope_depth(); | 2528 ExternalReference::heap_always_allocate_scope_depth(); |
| 2543 if (always_allocate_scope) { | 2529 if (always_allocate_scope) { |
| 2544 __ movq(kScratchRegister, scope_depth); | 2530 __ movq(kScratchRegister, scope_depth); |
| 2545 __ incl(Operand(kScratchRegister, 0)); | 2531 __ incl(Operand(kScratchRegister, 0)); |
| 2546 } | 2532 } |
| 2547 | 2533 |
| 2548 // Call C function. | 2534 // Call C function. |
| 2549 #ifdef _WIN64 | 2535 #ifdef _WIN64 |
| 2550 // Windows 64-bit ABI passes arguments in rcx, rdx, r8, r9 | 2536 // Windows 64-bit ABI passes arguments in rcx, rdx, r8, r9 |
| 2551 // Store Arguments object on stack, below the 4 WIN64 ABI parameter slots. | 2537 // Store Arguments object on stack, below the 4 WIN64 ABI parameter slots. |
| 2552 __ movq(Operand(rsp, 4 * kPointerSize), r14); // argc. | 2538 __ movq(StackSpaceOperand(0), r14); // argc. |
| 2553 __ movq(Operand(rsp, 5 * kPointerSize), r12); // argv. | 2539 __ movq(StackSpaceOperand(1), r12); // argv. |
| 2554 if (result_size_ < 2) { | 2540 if (result_size_ < 2) { |
| 2555 // Pass a pointer to the Arguments object as the first argument. | 2541 // Pass a pointer to the Arguments object as the first argument. |
| 2556 // Return result in single register (rax). | 2542 // Return result in single register (rax). |
| 2557 __ lea(rcx, Operand(rsp, 4 * kPointerSize)); | 2543 __ lea(rcx, StackSpaceOperand(0)); |
| 2558 } else { | 2544 } else { |
| 2559 ASSERT_EQ(2, result_size_); | 2545 ASSERT_EQ(2, result_size_); |
| 2560 // Pass a pointer to the result location as the first argument. | 2546 // Pass a pointer to the result location as the first argument. |
| 2561 __ lea(rcx, Operand(rsp, 6 * kPointerSize)); | 2547 __ lea(rcx, StackSpaceOperand(2)); |
| 2562 // Pass a pointer to the Arguments object as the second argument. | 2548 // Pass a pointer to the Arguments object as the second argument. |
| 2563 __ lea(rdx, Operand(rsp, 4 * kPointerSize)); | 2549 __ lea(rdx, StackSpaceOperand(0)); |
| 2564 } | 2550 } |
| 2565 | 2551 |
| 2566 #else // _WIN64 | 2552 #else // _WIN64 |
| 2567 // GCC passes arguments in rdi, rsi, rdx, rcx, r8, r9. | 2553 // GCC passes arguments in rdi, rsi, rdx, rcx, r8, r9. |
| 2568 __ movq(rdi, r14); // argc. | 2554 __ movq(rdi, r14); // argc. |
| 2569 __ movq(rsi, r12); // argv. | 2555 __ movq(rsi, r12); // argv. |
| 2570 #endif | 2556 #endif |
| 2571 __ call(rbx); | 2557 __ call(rbx); |
| 2572 // Result is in rax - do not destroy this register! | 2558 // Result is in rax - do not destroy this register! |
| 2573 | 2559 |
| (...skipping 15 matching lines...) Expand all Loading... |
| 2589 __ movq(rax, Operand(rsp, 6 * kPointerSize)); | 2575 __ movq(rax, Operand(rsp, 6 * kPointerSize)); |
| 2590 __ movq(rdx, Operand(rsp, 7 * kPointerSize)); | 2576 __ movq(rdx, Operand(rsp, 7 * kPointerSize)); |
| 2591 } | 2577 } |
| 2592 #endif | 2578 #endif |
| 2593 __ lea(rcx, Operand(rax, 1)); | 2579 __ lea(rcx, Operand(rax, 1)); |
| 2594 // Lower 2 bits of rcx are 0 iff rax has failure tag. | 2580 // Lower 2 bits of rcx are 0 iff rax has failure tag. |
| 2595 __ testl(rcx, Immediate(kFailureTagMask)); | 2581 __ testl(rcx, Immediate(kFailureTagMask)); |
| 2596 __ j(zero, &failure_returned); | 2582 __ j(zero, &failure_returned); |
| 2597 | 2583 |
| 2598 // Exit the JavaScript to C++ exit frame. | 2584 // Exit the JavaScript to C++ exit frame. |
| 2599 __ LeaveExitFrame(result_size_); | 2585 __ LeaveExitFrame(); |
| 2600 __ ret(0); | 2586 __ ret(0); |
| 2601 | 2587 |
| 2602 // Handling of failure. | 2588 // Handling of failure. |
| 2603 __ bind(&failure_returned); | 2589 __ bind(&failure_returned); |
| 2604 | 2590 |
| 2605 NearLabel retry; | 2591 NearLabel retry; |
| 2606 // If the returned exception is RETRY_AFTER_GC continue at retry label | 2592 // If the returned exception is RETRY_AFTER_GC continue at retry label |
| 2607 STATIC_ASSERT(Failure::RETRY_AFTER_GC == 0); | 2593 STATIC_ASSERT(Failure::RETRY_AFTER_GC == 0); |
| 2608 __ testl(rax, Immediate(((1 << kFailureTypeTagSize) - 1) << kFailureTagSize)); | 2594 __ testl(rax, Immediate(((1 << kFailureTypeTagSize) - 1) << kFailureTagSize)); |
| 2609 __ j(zero, &retry); | 2595 __ j(zero, &retry); |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2693 // rbp: frame pointer of calling JS frame (restored after C call) | 2679 // rbp: frame pointer of calling JS frame (restored after C call) |
| 2694 // rsp: stack pointer (restored after C call) | 2680 // rsp: stack pointer (restored after C call) |
| 2695 // rsi: current context (restored) | 2681 // rsi: current context (restored) |
| 2696 | 2682 |
| 2697 // NOTE: Invocations of builtins may return failure objects | 2683 // NOTE: Invocations of builtins may return failure objects |
| 2698 // instead of a proper result. The builtin entry handles | 2684 // instead of a proper result. The builtin entry handles |
| 2699 // this by performing a garbage collection and retrying the | 2685 // this by performing a garbage collection and retrying the |
| 2700 // builtin once. | 2686 // builtin once. |
| 2701 | 2687 |
| 2702 // Enter the exit frame that transitions from JavaScript to C++. | 2688 // Enter the exit frame that transitions from JavaScript to C++. |
| 2703 __ EnterExitFrame(result_size_); | 2689 #ifdef _WIN64 |
| 2690 int arg_stack_space = (result_size_ < 2 ? 2 : 4); |
| 2691 #else |
| 2692 int arg_stack_space = 0; |
| 2693 #endif |
| 2694 __ EnterExitFrame(arg_stack_space); |
| 2704 | 2695 |
| 2705 // rax: Holds the context at this point, but should not be used. | 2696 // rax: Holds the context at this point, but should not be used. |
| 2706 // On entry to code generated by GenerateCore, it must hold | 2697 // On entry to code generated by GenerateCore, it must hold |
| 2707 // a failure result if the collect_garbage argument to GenerateCore | 2698 // a failure result if the collect_garbage argument to GenerateCore |
| 2708 // is true. This failure result can be the result of code | 2699 // is true. This failure result can be the result of code |
| 2709 // generated by a previous call to GenerateCore. The value | 2700 // generated by a previous call to GenerateCore. The value |
| 2710 // of rax is then passed to Runtime::PerformGC. | 2701 // of rax is then passed to Runtime::PerformGC. |
| 2711 // rbx: pointer to builtin function (C callee-saved). | 2702 // rbx: pointer to builtin function (C callee-saved). |
| 2712 // rbp: frame pointer of exit frame (restored after C call). | 2703 // rbp: frame pointer of exit frame (restored after C call). |
| 2713 // rsp: stack pointer (restored after C call). | 2704 // rsp: stack pointer (restored after C call). |
| (...skipping 1278 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3992 // tagged as a small integer. | 3983 // tagged as a small integer. |
| 3993 __ bind(&runtime); | 3984 __ bind(&runtime); |
| 3994 __ TailCallRuntime(Runtime::kStringCompare, 2, 1); | 3985 __ TailCallRuntime(Runtime::kStringCompare, 2, 1); |
| 3995 } | 3986 } |
| 3996 | 3987 |
| 3997 #undef __ | 3988 #undef __ |
| 3998 | 3989 |
| 3999 } } // namespace v8::internal | 3990 } } // namespace v8::internal |
| 4000 | 3991 |
| 4001 #endif // V8_TARGET_ARCH_X64 | 3992 #endif // V8_TARGET_ARCH_X64 |
| OLD | NEW |