OLD | NEW |
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_X87 | 5 #if V8_TARGET_ARCH_X87 |
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 1997 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2008 // ebp: frame pointer (restored after C call) | 2008 // ebp: frame pointer (restored after C call) |
2009 // esp: stack pointer (restored after C call) | 2009 // esp: stack pointer (restored after C call) |
2010 // esi: current context (C callee-saved) | 2010 // esi: current context (C callee-saved) |
2011 // edi: JS function of the caller (C callee-saved) | 2011 // edi: JS function of the caller (C callee-saved) |
2012 // | 2012 // |
2013 // If argv_in_register(): | 2013 // If argv_in_register(): |
2014 // ecx: pointer to the first argument | 2014 // ecx: pointer to the first argument |
2015 | 2015 |
2016 ProfileEntryHookStub::MaybeCallEntryHook(masm); | 2016 ProfileEntryHookStub::MaybeCallEntryHook(masm); |
2017 | 2017 |
| 2018 // Reserve space on the stack for the three arguments passed to the call. If |
| 2019 // result size is greater than can be returned in registers, also reserve |
| 2020 // space for the hidden argument for the result location, and space for the |
| 2021 // result itself. |
| 2022 int arg_stack_space = result_size() < 3 ? 3 : 4 + result_size(); |
| 2023 |
2018 // Enter the exit frame that transitions from JavaScript to C++. | 2024 // Enter the exit frame that transitions from JavaScript to C++. |
2019 if (argv_in_register()) { | 2025 if (argv_in_register()) { |
2020 DCHECK(!save_doubles()); | 2026 DCHECK(!save_doubles()); |
2021 __ EnterApiExitFrame(3); | 2027 __ EnterApiExitFrame(arg_stack_space); |
2022 | 2028 |
2023 // Move argc and argv into the correct registers. | 2029 // Move argc and argv into the correct registers. |
2024 __ mov(esi, ecx); | 2030 __ mov(esi, ecx); |
2025 __ mov(edi, eax); | 2031 __ mov(edi, eax); |
2026 } else { | 2032 } else { |
2027 __ EnterExitFrame(save_doubles()); | 2033 __ EnterExitFrame(arg_stack_space, save_doubles()); |
2028 } | 2034 } |
2029 | 2035 |
2030 // ebx: pointer to C function (C callee-saved) | 2036 // ebx: pointer to C function (C callee-saved) |
2031 // ebp: frame pointer (restored after C call) | 2037 // ebp: frame pointer (restored after C call) |
2032 // esp: stack pointer (restored after C call) | 2038 // esp: stack pointer (restored after C call) |
2033 // edi: number of arguments including receiver (C callee-saved) | 2039 // edi: number of arguments including receiver (C callee-saved) |
2034 // esi: pointer to the first argument (C callee-saved) | 2040 // esi: pointer to the first argument (C callee-saved) |
2035 | 2041 |
2036 // Result returned in eax, or eax+edx if result size is 2. | 2042 // Result returned in eax, or eax+edx if result size is 2. |
2037 | 2043 |
2038 // Check stack alignment. | 2044 // Check stack alignment. |
2039 if (FLAG_debug_code) { | 2045 if (FLAG_debug_code) { |
2040 __ CheckStackAlignment(); | 2046 __ CheckStackAlignment(); |
2041 } | 2047 } |
| 2048 // Call C function. |
| 2049 if (result_size() <= 2) { |
| 2050 __ mov(Operand(esp, 0 * kPointerSize), edi); // argc. |
| 2051 __ mov(Operand(esp, 1 * kPointerSize), esi); // argv. |
| 2052 __ mov(Operand(esp, 2 * kPointerSize), |
| 2053 Immediate(ExternalReference::isolate_address(isolate()))); |
| 2054 } else { |
| 2055 DCHECK_EQ(3, result_size()); |
| 2056 // Pass a pointer to the result location as the first argument. |
| 2057 __ lea(eax, Operand(esp, 4 * kPointerSize)); |
| 2058 __ mov(Operand(esp, 0 * kPointerSize), eax); |
| 2059 __ mov(Operand(esp, 1 * kPointerSize), edi); // argc. |
| 2060 __ mov(Operand(esp, 2 * kPointerSize), esi); // argv. |
| 2061 __ mov(Operand(esp, 3 * kPointerSize), |
| 2062 Immediate(ExternalReference::isolate_address(isolate()))); |
| 2063 } |
| 2064 __ call(ebx); |
2042 | 2065 |
2043 // Call C function. | 2066 if (result_size() > 2) { |
2044 __ mov(Operand(esp, 0 * kPointerSize), edi); // argc. | 2067 DCHECK_EQ(3, result_size()); |
2045 __ mov(Operand(esp, 1 * kPointerSize), esi); // argv. | 2068 #ifndef _WIN32 |
2046 __ mov(Operand(esp, 2 * kPointerSize), | 2069 // Restore the "hidden" argument on the stack which was popped by caller. |
2047 Immediate(ExternalReference::isolate_address(isolate()))); | 2070 __ sub(esp, Immediate(kPointerSize)); |
2048 __ call(ebx); | 2071 #endif |
2049 // Result is in eax or edx:eax - do not destroy these registers! | 2072 // Read result values stored on stack. Result is stored above the arguments. |
| 2073 __ mov(kReturnRegister0, Operand(esp, 4 * kPointerSize)); |
| 2074 __ mov(kReturnRegister1, Operand(esp, 5 * kPointerSize)); |
| 2075 __ mov(kReturnRegister2, Operand(esp, 6 * kPointerSize)); |
| 2076 } |
| 2077 // Result is in eax, edx:eax or edi:edx:eax - do not destroy these registers! |
2050 | 2078 |
2051 // Check result for exception sentinel. | 2079 // Check result for exception sentinel. |
2052 Label exception_returned; | 2080 Label exception_returned; |
2053 __ cmp(eax, isolate()->factory()->exception()); | 2081 __ cmp(eax, isolate()->factory()->exception()); |
2054 __ j(equal, &exception_returned); | 2082 __ j(equal, &exception_returned); |
2055 | 2083 |
2056 // Check that there is no pending exception, otherwise we | 2084 // Check that there is no pending exception, otherwise we |
2057 // should have returned the exception sentinel. | 2085 // should have returned the exception sentinel. |
2058 if (FLAG_debug_code) { | 2086 if (FLAG_debug_code) { |
2059 __ push(edx); | 2087 __ push(edx); |
(...skipping 3290 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5350 Operand(ebp, 7 * kPointerSize), NULL); | 5378 Operand(ebp, 7 * kPointerSize), NULL); |
5351 } | 5379 } |
5352 | 5380 |
5353 | 5381 |
5354 #undef __ | 5382 #undef __ |
5355 | 5383 |
5356 } // namespace internal | 5384 } // namespace internal |
5357 } // namespace v8 | 5385 } // namespace v8 |
5358 | 5386 |
5359 #endif // V8_TARGET_ARCH_X87 | 5387 #endif // V8_TARGET_ARCH_X87 |
OLD | NEW |