OLD | NEW |
1 // Copyright 2009 the V8 project authors. All rights reserved. | 1 // Copyright 2009 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 6012 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6023 void CEntryStub::GenerateCore(MacroAssembler* masm, | 6023 void CEntryStub::GenerateCore(MacroAssembler* masm, |
6024 Label* throw_normal_exception, | 6024 Label* throw_normal_exception, |
6025 Label* throw_out_of_memory_exception, | 6025 Label* throw_out_of_memory_exception, |
6026 StackFrame::Type frame_type, | 6026 StackFrame::Type frame_type, |
6027 bool do_gc, | 6027 bool do_gc, |
6028 bool always_allocate_scope) { | 6028 bool always_allocate_scope) { |
6029 // rax: result parameter for PerformGC, if any. | 6029 // rax: result parameter for PerformGC, if any. |
6030 // rbx: pointer to C function (C callee-saved). | 6030 // rbx: pointer to C function (C callee-saved). |
6031 // rbp: frame pointer (restored after C call). | 6031 // rbp: frame pointer (restored after C call). |
6032 // rsp: stack pointer (restored after C call). | 6032 // rsp: stack pointer (restored after C call). |
6033 // rdi: number of arguments including receiver. | 6033 // r14: number of arguments including receiver (C callee-saved). |
6034 // r15: pointer to the first argument (C callee-saved). | 6034 // r15: pointer to the first argument (C callee-saved). |
6035 // This pointer is reused in LeaveExitFrame(), so it is stored in a | 6035 // This pointer is reused in LeaveExitFrame(), so it is stored in a |
6036 // callee-saved register. | 6036 // callee-saved register. |
6037 | 6037 |
6038 if (do_gc) { | 6038 if (do_gc) { |
6039 // Pass failure code returned from last attempt as first argument to GC. | 6039 // Pass failure code returned from last attempt as first argument to GC. |
6040 #ifdef __MSVC__ | 6040 #ifdef __MSVC__ |
6041 __ movq(rcx, rax); // argc. | 6041 __ movq(rcx, rax); // argc. |
6042 #else // ! defined(__MSVC__) | 6042 #else // ! defined(__MSVC__) |
6043 __ movq(rdi, rax); // argv. | 6043 __ movq(rdi, rax); // argv. |
6044 #endif | 6044 #endif |
6045 __ movq(kScratchRegister, | 6045 __ movq(kScratchRegister, |
6046 FUNCTION_ADDR(Runtime::PerformGC), | 6046 FUNCTION_ADDR(Runtime::PerformGC), |
6047 RelocInfo::RUNTIME_ENTRY); | 6047 RelocInfo::RUNTIME_ENTRY); |
6048 __ call(kScratchRegister); | 6048 __ call(kScratchRegister); |
6049 } | 6049 } |
6050 | 6050 |
6051 ExternalReference scope_depth = | 6051 ExternalReference scope_depth = |
6052 ExternalReference::heap_always_allocate_scope_depth(); | 6052 ExternalReference::heap_always_allocate_scope_depth(); |
6053 if (always_allocate_scope) { | 6053 if (always_allocate_scope) { |
6054 __ movq(kScratchRegister, scope_depth); | 6054 __ movq(kScratchRegister, scope_depth); |
6055 __ incl(Operand(kScratchRegister, 0)); | 6055 __ incl(Operand(kScratchRegister, 0)); |
6056 } | 6056 } |
6057 | 6057 |
6058 // Call C function. | 6058 // Call C function. |
6059 #ifdef __MSVC__ | 6059 #ifdef __MSVC__ |
6060 // MSVC passes arguments in rcx, rdx, r8, r9 | 6060 // MSVC passes arguments in rcx, rdx, r8, r9 |
6061 __ movq(rcx, rdi); // argc. | 6061 __ movq(rcx, r14); // argc. |
6062 __ movq(rdx, r15); // argv. | 6062 __ movq(rdx, r15); // argv. |
6063 #else // ! defined(__MSVC__) | 6063 #else // ! defined(__MSVC__) |
6064 // GCC passes arguments in rdi, rsi, rdx, rcx, r8, r9. | 6064 // GCC passes arguments in rdi, rsi, rdx, rcx, r8, r9. |
6065 // First argument is already in rdi. | 6065 __ movq(rdi, r14); // argc. |
6066 __ movq(rsi, r15); // argv. | 6066 __ movq(rsi, r15); // argv. |
6067 #endif | 6067 #endif |
6068 __ call(rbx); | 6068 __ call(rbx); |
6069 // Result is in rax - do not destroy this register! | 6069 // Result is in rax - do not destroy this register! |
6070 | 6070 |
6071 if (always_allocate_scope) { | 6071 if (always_allocate_scope) { |
6072 __ movq(kScratchRegister, scope_depth); | 6072 __ movq(kScratchRegister, scope_depth); |
6073 __ decl(Operand(kScratchRegister, 0)); | 6073 __ decl(Operand(kScratchRegister, 0)); |
6074 } | 6074 } |
6075 | 6075 |
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6197 __ Set(rbx, 0); | 6197 __ Set(rbx, 0); |
6198 __ GetBuiltinEntry(rdx, Builtins::CALL_NON_FUNCTION); | 6198 __ GetBuiltinEntry(rdx, Builtins::CALL_NON_FUNCTION); |
6199 Handle<Code> adaptor(Builtins::builtin(Builtins::ArgumentsAdaptorTrampoline)); | 6199 Handle<Code> adaptor(Builtins::builtin(Builtins::ArgumentsAdaptorTrampoline)); |
6200 __ Jump(adaptor, RelocInfo::CODE_TARGET); | 6200 __ Jump(adaptor, RelocInfo::CODE_TARGET); |
6201 } | 6201 } |
6202 | 6202 |
6203 | 6203 |
6204 void CEntryStub::GenerateBody(MacroAssembler* masm, bool is_debug_break) { | 6204 void CEntryStub::GenerateBody(MacroAssembler* masm, bool is_debug_break) { |
6205 // rax: number of arguments including receiver | 6205 // rax: number of arguments including receiver |
6206 // rbx: pointer to C function (C callee-saved) | 6206 // rbx: pointer to C function (C callee-saved) |
6207 // rbp: frame pointer (restored after C call) | 6207 // rbp: frame pointer of calling JS frame (restored after C call) |
6208 // rsp: stack pointer (restored after C call) | 6208 // rsp: stack pointer (restored after C call) |
6209 // rsi: current context (C callee-saved) | 6209 // rsi: current context (restored) |
6210 // rdi: caller's parameter pointer pp (C callee-saved) | |
6211 | 6210 |
6212 // NOTE: Invocations of builtins may return failure objects | 6211 // NOTE: Invocations of builtins may return failure objects |
6213 // instead of a proper result. The builtin entry handles | 6212 // instead of a proper result. The builtin entry handles |
6214 // this by performing a garbage collection and retrying the | 6213 // this by performing a garbage collection and retrying the |
6215 // builtin once. | 6214 // builtin once. |
6216 | 6215 |
6217 StackFrame::Type frame_type = is_debug_break ? | 6216 StackFrame::Type frame_type = is_debug_break ? |
6218 StackFrame::EXIT_DEBUG : | 6217 StackFrame::EXIT_DEBUG : |
6219 StackFrame::EXIT; | 6218 StackFrame::EXIT; |
6220 | 6219 |
6221 // Enter the exit frame that transitions from JavaScript to C++. | 6220 // Enter the exit frame that transitions from JavaScript to C++. |
6222 __ EnterExitFrame(frame_type); | 6221 __ EnterExitFrame(frame_type); |
6223 | 6222 |
6224 // rax: result parameter for PerformGC, if any (setup below). | 6223 // rax: Holds the context at this point, but should not be used. |
6225 // Holds the result of a previous call to GenerateCore that | 6224 // On entry to code generated by GenerateCore, it must hold |
6226 // returned a failure. On next call, it's used as parameter | 6225 // a failure result if the collect_garbage argument to GenerateCore |
6227 // to Runtime::PerformGC. | 6226 // is true. This failure result can be the result of code |
| 6227 // generated by a previous call to GenerateCore. The value |
| 6228 // of rax is then passed to Runtime::PerformGC. |
6228 // rbx: pointer to builtin function (C callee-saved). | 6229 // rbx: pointer to builtin function (C callee-saved). |
6229 // rbp: frame pointer (restored after C call). | 6230 // rbp: frame pointer of exit frame (restored after C call). |
6230 // rsp: stack pointer (restored after C call). | 6231 // rsp: stack pointer (restored after C call). |
6231 // rdi: number of arguments including receiver (destroyed by C call). | 6232 // r14: number of arguments including receiver (C callee-saved). |
6232 // The rdi register is not callee-save in Unix 64-bit ABI, so | |
6233 // we must treat it as volatile. | |
6234 // r15: argv pointer (C callee-saved). | 6233 // r15: argv pointer (C callee-saved). |
6235 | 6234 |
6236 Label throw_out_of_memory_exception; | 6235 Label throw_out_of_memory_exception; |
6237 Label throw_normal_exception; | 6236 Label throw_normal_exception; |
6238 | 6237 |
6239 // Call into the runtime system. Collect garbage before the call if | 6238 // Call into the runtime system. Collect garbage before the call if |
6240 // running with --gc-greedy set. | 6239 // running with --gc-greedy set. |
6241 if (FLAG_gc_greedy) { | 6240 if (FLAG_gc_greedy) { |
6242 Failure* failure = Failure::RetryAfterGC(0); | 6241 Failure* failure = Failure::RetryAfterGC(0); |
6243 __ movq(rax, failure, RelocInfo::NONE); | 6242 __ movq(rax, failure, RelocInfo::NONE); |
(...skipping 697 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6941 int CompareStub::MinorKey() { | 6940 int CompareStub::MinorKey() { |
6942 // Encode the two parameters in a unique 16 bit value. | 6941 // Encode the two parameters in a unique 16 bit value. |
6943 ASSERT(static_cast<unsigned>(cc_) < (1 << 15)); | 6942 ASSERT(static_cast<unsigned>(cc_) < (1 << 15)); |
6944 return (static_cast<unsigned>(cc_) << 1) | (strict_ ? 1 : 0); | 6943 return (static_cast<unsigned>(cc_) << 1) | (strict_ ? 1 : 0); |
6945 } | 6944 } |
6946 | 6945 |
6947 | 6946 |
6948 #undef __ | 6947 #undef __ |
6949 | 6948 |
6950 } } // namespace v8::internal | 6949 } } // namespace v8::internal |
OLD | NEW |