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_IA32 | 5 #if V8_TARGET_ARCH_IA32 |
6 | 6 |
7 #include "src/base/bits.h" | 7 #include "src/base/bits.h" |
8 #include "src/base/division-by-constant.h" | 8 #include "src/base/division-by-constant.h" |
9 #include "src/bootstrapper.h" | 9 #include "src/bootstrapper.h" |
10 #include "src/codegen.h" | 10 #include "src/codegen.h" |
(...skipping 2068 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2079 } | 2079 } |
2080 | 2080 |
2081 | 2081 |
2082 void MacroAssembler::JumpToExternalReference(const ExternalReference& ext) { | 2082 void MacroAssembler::JumpToExternalReference(const ExternalReference& ext) { |
2083 // Set the entry point and jump to the C entry runtime stub. | 2083 // Set the entry point and jump to the C entry runtime stub. |
2084 mov(ebx, Immediate(ext)); | 2084 mov(ebx, Immediate(ext)); |
2085 CEntryStub ces(isolate(), 1); | 2085 CEntryStub ces(isolate(), 1); |
2086 jmp(ces.GetCode(), RelocInfo::CODE_TARGET); | 2086 jmp(ces.GetCode(), RelocInfo::CODE_TARGET); |
2087 } | 2087 } |
2088 | 2088 |
2089 void MacroAssembler::PrepareForTailCall(const ParameterCount& callee_args_count, | 2089 void MacroAssembler::PrepareForTailCall( |
2090 Register caller_args_count_reg, | 2090 const ParameterCount& callee_args_count, Register caller_args_count_reg, |
2091 Register scratch0, Register scratch1, | 2091 Register scratch0, Register scratch1, ReturnAddressState ra_state, |
2092 ReturnAddressState ra_state) { | 2092 int number_of_temp_values_after_return_address) { |
2093 #if DEBUG | 2093 #if DEBUG |
2094 if (callee_args_count.is_reg()) { | 2094 if (callee_args_count.is_reg()) { |
2095 DCHECK(!AreAliased(callee_args_count.reg(), caller_args_count_reg, scratch0, | 2095 DCHECK(!AreAliased(callee_args_count.reg(), caller_args_count_reg, scratch0, |
2096 scratch1)); | 2096 scratch1)); |
2097 } else { | 2097 } else { |
2098 DCHECK(!AreAliased(caller_args_count_reg, scratch0, scratch1)); | 2098 DCHECK(!AreAliased(caller_args_count_reg, scratch0, scratch1)); |
2099 } | 2099 } |
| 2100 DCHECK(ra_state != ReturnAddressState::kNotOnStack || |
| 2101 number_of_temp_values_after_return_address == 0); |
2100 #endif | 2102 #endif |
2101 | 2103 |
2102 // Calculate the destination address where we will put the return address | 2104 // Calculate the destination address where we will put the return address |
2103 // after we drop current frame. | 2105 // after we drop current frame. |
2104 Register new_sp_reg = scratch0; | 2106 Register new_sp_reg = scratch0; |
2105 if (callee_args_count.is_reg()) { | 2107 if (callee_args_count.is_reg()) { |
2106 sub(caller_args_count_reg, callee_args_count.reg()); | 2108 sub(caller_args_count_reg, callee_args_count.reg()); |
2107 lea(new_sp_reg, Operand(ebp, caller_args_count_reg, times_pointer_size, | 2109 lea(new_sp_reg, |
2108 StandardFrameConstants::kCallerPCOffset)); | 2110 Operand(ebp, caller_args_count_reg, times_pointer_size, |
| 2111 StandardFrameConstants::kCallerPCOffset - |
| 2112 number_of_temp_values_after_return_address * kPointerSize)); |
2109 } else { | 2113 } else { |
2110 lea(new_sp_reg, Operand(ebp, caller_args_count_reg, times_pointer_size, | 2114 lea(new_sp_reg, Operand(ebp, caller_args_count_reg, times_pointer_size, |
2111 StandardFrameConstants::kCallerPCOffset - | 2115 StandardFrameConstants::kCallerPCOffset - |
2112 callee_args_count.immediate() * kPointerSize)); | 2116 (callee_args_count.immediate() + |
| 2117 number_of_temp_values_after_return_address) * |
| 2118 kPointerSize)); |
2113 } | 2119 } |
2114 | 2120 |
2115 if (FLAG_debug_code) { | 2121 if (FLAG_debug_code) { |
2116 cmp(esp, new_sp_reg); | 2122 cmp(esp, new_sp_reg); |
2117 Check(below, kStackAccessBelowStackPointer); | 2123 Check(below, kStackAccessBelowStackPointer); |
2118 } | 2124 } |
2119 | 2125 |
2120 // Copy return address from caller's frame to current frame's return address | 2126 // Copy return address from caller's frame to current frame's return address |
2121 // to avoid its trashing and let the following loop copy it to the right | 2127 // to avoid its trashing and let the following loop copy it to the right |
2122 // place. | 2128 // place. |
2123 Register tmp_reg = scratch1; | 2129 Register tmp_reg = scratch1; |
2124 if (ra_state == ReturnAddressState::kOnStack) { | 2130 if (ra_state == ReturnAddressState::kOnStack) { |
2125 mov(tmp_reg, Operand(ebp, StandardFrameConstants::kCallerPCOffset)); | 2131 mov(tmp_reg, Operand(ebp, StandardFrameConstants::kCallerPCOffset)); |
2126 mov(Operand(esp, 0), tmp_reg); | 2132 mov(Operand(esp, number_of_temp_values_after_return_address * kPointerSize), |
| 2133 tmp_reg); |
2127 } else { | 2134 } else { |
2128 DCHECK(ReturnAddressState::kNotOnStack == ra_state); | 2135 DCHECK(ReturnAddressState::kNotOnStack == ra_state); |
| 2136 DCHECK_EQ(0, number_of_temp_values_after_return_address); |
2129 Push(Operand(ebp, StandardFrameConstants::kCallerPCOffset)); | 2137 Push(Operand(ebp, StandardFrameConstants::kCallerPCOffset)); |
2130 } | 2138 } |
2131 | 2139 |
2132 // Restore caller's frame pointer now as it could be overwritten by | 2140 // Restore caller's frame pointer now as it could be overwritten by |
2133 // the copying loop. | 2141 // the copying loop. |
2134 mov(ebp, Operand(ebp, StandardFrameConstants::kCallerFPOffset)); | 2142 mov(ebp, Operand(ebp, StandardFrameConstants::kCallerFPOffset)); |
2135 | 2143 |
2136 // +2 here is to copy both receiver and return address. | 2144 // +2 here is to copy both receiver and return address. |
2137 Register count_reg = caller_args_count_reg; | 2145 Register count_reg = caller_args_count_reg; |
2138 if (callee_args_count.is_reg()) { | 2146 if (callee_args_count.is_reg()) { |
2139 lea(count_reg, Operand(callee_args_count.reg(), 2)); | 2147 lea(count_reg, Operand(callee_args_count.reg(), |
| 2148 2 + number_of_temp_values_after_return_address)); |
2140 } else { | 2149 } else { |
2141 mov(count_reg, Immediate(callee_args_count.immediate() + 2)); | 2150 mov(count_reg, Immediate(callee_args_count.immediate() + 2 + |
| 2151 number_of_temp_values_after_return_address)); |
2142 // TODO(ishell): Unroll copying loop for small immediate values. | 2152 // TODO(ishell): Unroll copying loop for small immediate values. |
2143 } | 2153 } |
2144 | 2154 |
2145 // Now copy callee arguments to the caller frame going backwards to avoid | 2155 // Now copy callee arguments to the caller frame going backwards to avoid |
2146 // callee arguments corruption (source and destination areas could overlap). | 2156 // callee arguments corruption (source and destination areas could overlap). |
2147 Label loop, entry; | 2157 Label loop, entry; |
2148 jmp(&entry, Label::kNear); | 2158 jmp(&entry, Label::kNear); |
2149 bind(&loop); | 2159 bind(&loop); |
2150 dec(count_reg); | 2160 dec(count_reg); |
2151 mov(tmp_reg, Operand(esp, count_reg, times_pointer_size, 0)); | 2161 mov(tmp_reg, Operand(esp, count_reg, times_pointer_size, 0)); |
(...skipping 1149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3301 mov(eax, dividend); | 3311 mov(eax, dividend); |
3302 shr(eax, 31); | 3312 shr(eax, 31); |
3303 add(edx, eax); | 3313 add(edx, eax); |
3304 } | 3314 } |
3305 | 3315 |
3306 | 3316 |
3307 } // namespace internal | 3317 } // namespace internal |
3308 } // namespace v8 | 3318 } // namespace v8 |
3309 | 3319 |
3310 #endif // V8_TARGET_ARCH_IA32 | 3320 #endif // V8_TARGET_ARCH_IA32 |
OLD | NEW |