OLD | NEW |
1 // Copyright 2013 the V8 project authors. All rights reserved. | 1 // Copyright 2013 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 2997 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3008 // Do space-specific GC and retry runtime call. | 3008 // Do space-specific GC and retry runtime call. |
3009 GenerateCore(masm, | 3009 GenerateCore(masm, |
3010 &throw_normal_exception, | 3010 &throw_normal_exception, |
3011 &throw_termination_exception, | 3011 &throw_termination_exception, |
3012 &throw_out_of_memory_exception, | 3012 &throw_out_of_memory_exception, |
3013 true, | 3013 true, |
3014 false); | 3014 false); |
3015 | 3015 |
3016 // Do full GC and retry runtime call one final time. | 3016 // Do full GC and retry runtime call one final time. |
3017 Failure* failure = Failure::InternalError(); | 3017 Failure* failure = Failure::InternalError(); |
3018 __ movq(rax, failure, RelocInfo::NONE64); | 3018 __ Move(rax, failure, RelocInfo::NONE64); |
3019 GenerateCore(masm, | 3019 GenerateCore(masm, |
3020 &throw_normal_exception, | 3020 &throw_normal_exception, |
3021 &throw_termination_exception, | 3021 &throw_termination_exception, |
3022 &throw_out_of_memory_exception, | 3022 &throw_out_of_memory_exception, |
3023 true, | 3023 true, |
3024 true); | 3024 true); |
3025 | 3025 |
3026 __ bind(&throw_out_of_memory_exception); | 3026 __ bind(&throw_out_of_memory_exception); |
3027 // Set external caught exception to false. | 3027 // Set external caught exception to false. |
3028 Isolate* isolate = masm->isolate(); | 3028 Isolate* isolate = masm->isolate(); |
3029 ExternalReference external_caught(Isolate::kExternalCaughtExceptionAddress, | 3029 ExternalReference external_caught(Isolate::kExternalCaughtExceptionAddress, |
3030 isolate); | 3030 isolate); |
3031 __ Set(rax, static_cast<int64_t>(false)); | 3031 __ Set(rax, static_cast<int64_t>(false)); |
3032 __ Store(external_caught, rax); | 3032 __ Store(external_caught, rax); |
3033 | 3033 |
3034 // Set pending exception and rax to out of memory exception. | 3034 // Set pending exception and rax to out of memory exception. |
3035 ExternalReference pending_exception(Isolate::kPendingExceptionAddress, | 3035 ExternalReference pending_exception(Isolate::kPendingExceptionAddress, |
3036 isolate); | 3036 isolate); |
3037 Label already_have_failure; | 3037 Label already_have_failure; |
3038 JumpIfOOM(masm, rax, kScratchRegister, &already_have_failure); | 3038 JumpIfOOM(masm, rax, kScratchRegister, &already_have_failure); |
3039 __ movq(rax, Failure::OutOfMemoryException(0x1), RelocInfo::NONE64); | 3039 __ Move(rax, Failure::OutOfMemoryException(0x1), RelocInfo::NONE64); |
3040 __ bind(&already_have_failure); | 3040 __ bind(&already_have_failure); |
3041 __ Store(pending_exception, rax); | 3041 __ Store(pending_exception, rax); |
3042 // Fall through to the next label. | 3042 // Fall through to the next label. |
3043 | 3043 |
3044 __ bind(&throw_termination_exception); | 3044 __ bind(&throw_termination_exception); |
3045 __ ThrowUncatchable(rax); | 3045 __ ThrowUncatchable(rax); |
3046 | 3046 |
3047 __ bind(&throw_normal_exception); | 3047 __ bind(&throw_normal_exception); |
3048 __ Throw(rax); | 3048 __ Throw(rax); |
3049 } | 3049 } |
3050 | 3050 |
3051 | 3051 |
3052 void JSEntryStub::GenerateBody(MacroAssembler* masm, bool is_construct) { | 3052 void JSEntryStub::GenerateBody(MacroAssembler* masm, bool is_construct) { |
3053 Label invoke, handler_entry, exit; | 3053 Label invoke, handler_entry, exit; |
3054 Label not_outermost_js, not_outermost_js_2; | 3054 Label not_outermost_js, not_outermost_js_2; |
3055 | 3055 |
3056 ProfileEntryHookStub::MaybeCallEntryHook(masm); | 3056 ProfileEntryHookStub::MaybeCallEntryHook(masm); |
3057 | 3057 |
3058 { // NOLINT. Scope block confuses linter. | 3058 { // NOLINT. Scope block confuses linter. |
3059 MacroAssembler::NoRootArrayScope uninitialized_root_register(masm); | 3059 MacroAssembler::NoRootArrayScope uninitialized_root_register(masm); |
3060 // Set up frame. | 3060 // Set up frame. |
3061 __ push(rbp); | 3061 __ push(rbp); |
3062 __ movq(rbp, rsp); | 3062 __ movq(rbp, rsp); |
3063 | 3063 |
3064 // Push the stack frame type marker twice. | 3064 // Push the stack frame type marker twice. |
3065 int marker = is_construct ? StackFrame::ENTRY_CONSTRUCT : StackFrame::ENTRY; | 3065 int marker = is_construct ? StackFrame::ENTRY_CONSTRUCT : StackFrame::ENTRY; |
3066 // Scratch register is neither callee-save, nor an argument register on any | 3066 // Scratch register is neither callee-save, nor an argument register on any |
3067 // platform. It's free to use at this point. | 3067 // platform. It's free to use at this point. |
3068 // Cannot use smi-register for loading yet. | 3068 // Cannot use smi-register for loading yet. |
3069 __ movq(kScratchRegister, Smi::FromInt(marker), RelocInfo::NONE64); | 3069 __ Move(kScratchRegister, Smi::FromInt(marker), RelocInfo::NONE64); |
3070 __ push(kScratchRegister); // context slot | 3070 __ push(kScratchRegister); // context slot |
3071 __ push(kScratchRegister); // function slot | 3071 __ push(kScratchRegister); // function slot |
3072 // Save callee-saved registers (X64/Win64 calling conventions). | 3072 // Save callee-saved registers (X64/Win64 calling conventions). |
3073 __ push(r12); | 3073 __ push(r12); |
3074 __ push(r13); | 3074 __ push(r13); |
3075 __ push(r14); | 3075 __ push(r14); |
3076 __ push(r15); | 3076 __ push(r15); |
3077 #ifdef _WIN64 | 3077 #ifdef _WIN64 |
3078 __ push(rdi); // Only callee save in Win64 ABI, argument in AMD64 ABI. | 3078 __ push(rdi); // Only callee save in Win64 ABI, argument in AMD64 ABI. |
3079 __ push(rsi); // Only callee save in Win64 ABI, argument in AMD64 ABI. | 3079 __ push(rsi); // Only callee save in Win64 ABI, argument in AMD64 ABI. |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3127 // Jump to a faked try block that does the invoke, with a faked catch | 3127 // Jump to a faked try block that does the invoke, with a faked catch |
3128 // block that sets the pending exception. | 3128 // block that sets the pending exception. |
3129 __ jmp(&invoke); | 3129 __ jmp(&invoke); |
3130 __ bind(&handler_entry); | 3130 __ bind(&handler_entry); |
3131 handler_offset_ = handler_entry.pos(); | 3131 handler_offset_ = handler_entry.pos(); |
3132 // Caught exception: Store result (exception) in the pending exception | 3132 // Caught exception: Store result (exception) in the pending exception |
3133 // field in the JSEnv and return a failure sentinel. | 3133 // field in the JSEnv and return a failure sentinel. |
3134 ExternalReference pending_exception(Isolate::kPendingExceptionAddress, | 3134 ExternalReference pending_exception(Isolate::kPendingExceptionAddress, |
3135 isolate); | 3135 isolate); |
3136 __ Store(pending_exception, rax); | 3136 __ Store(pending_exception, rax); |
3137 __ movq(rax, Failure::Exception(), RelocInfo::NONE64); | 3137 __ Move(rax, Failure::Exception(), RelocInfo::NONE64); |
3138 __ jmp(&exit); | 3138 __ jmp(&exit); |
3139 | 3139 |
3140 // Invoke: Link this frame into the handler chain. There's only one | 3140 // Invoke: Link this frame into the handler chain. There's only one |
3141 // handler block in this code object, so its index is 0. | 3141 // handler block in this code object, so its index is 0. |
3142 __ bind(&invoke); | 3142 __ bind(&invoke); |
3143 __ PushTryHandler(StackHandler::JS_ENTRY, 0); | 3143 __ PushTryHandler(StackHandler::JS_ENTRY, 0); |
3144 | 3144 |
3145 // Clear any pending exceptions. | 3145 // Clear any pending exceptions. |
3146 __ LoadRoot(rax, Heap::kTheHoleValueRootIndex); | 3146 __ LoadRoot(rax, Heap::kTheHoleValueRootIndex); |
3147 __ Store(pending_exception, rax); | 3147 __ Store(pending_exception, rax); |
(...skipping 2276 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5424 __ lea(arg_reg_2, Operand(rsp, (kNumSavedRegisters + 1) * kPointerSize)); | 5424 __ lea(arg_reg_2, Operand(rsp, (kNumSavedRegisters + 1) * kPointerSize)); |
5425 | 5425 |
5426 // Calculate the function address to the first arg. | 5426 // Calculate the function address to the first arg. |
5427 __ movq(arg_reg_1, Operand(rsp, kNumSavedRegisters * kPointerSize)); | 5427 __ movq(arg_reg_1, Operand(rsp, kNumSavedRegisters * kPointerSize)); |
5428 __ subq(arg_reg_1, Immediate(Assembler::kShortCallInstructionLength)); | 5428 __ subq(arg_reg_1, Immediate(Assembler::kShortCallInstructionLength)); |
5429 | 5429 |
5430 // Save the remainder of the volatile registers. | 5430 // Save the remainder of the volatile registers. |
5431 masm->PushCallerSaved(kSaveFPRegs, arg_reg_1, arg_reg_2); | 5431 masm->PushCallerSaved(kSaveFPRegs, arg_reg_1, arg_reg_2); |
5432 | 5432 |
5433 // Call the entry hook function. | 5433 // Call the entry hook function. |
5434 __ movq(rax, FUNCTION_ADDR(masm->isolate()->function_entry_hook()), | 5434 __ Move(rax, FUNCTION_ADDR(masm->isolate()->function_entry_hook()), |
5435 RelocInfo::NONE64); | 5435 RelocInfo::NONE64); |
5436 | 5436 |
5437 AllowExternalCallThatCantCauseGC scope(masm); | 5437 AllowExternalCallThatCantCauseGC scope(masm); |
5438 | 5438 |
5439 const int kArgumentCount = 2; | 5439 const int kArgumentCount = 2; |
5440 __ PrepareCallCFunction(kArgumentCount); | 5440 __ PrepareCallCFunction(kArgumentCount); |
5441 __ CallCFunction(rax, kArgumentCount); | 5441 __ CallCFunction(rax, kArgumentCount); |
5442 | 5442 |
5443 // Restore volatile regs. | 5443 // Restore volatile regs. |
5444 masm->PopCallerSaved(kSaveFPRegs, arg_reg_1, arg_reg_2); | 5444 masm->PopCallerSaved(kSaveFPRegs, arg_reg_1, arg_reg_2); |
(...skipping 338 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5783 __ bind(&fast_elements_case); | 5783 __ bind(&fast_elements_case); |
5784 GenerateCase(masm, FAST_ELEMENTS); | 5784 GenerateCase(masm, FAST_ELEMENTS); |
5785 } | 5785 } |
5786 | 5786 |
5787 | 5787 |
5788 #undef __ | 5788 #undef __ |
5789 | 5789 |
5790 } } // namespace v8::internal | 5790 } } // namespace v8::internal |
5791 | 5791 |
5792 #endif // V8_TARGET_ARCH_X64 | 5792 #endif // V8_TARGET_ARCH_X64 |
OLD | NEW |