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 #include "v8.h" | 5 #include "v8.h" |
6 | 6 |
7 #if V8_TARGET_ARCH_IA32 | 7 #if V8_TARGET_ARCH_IA32 |
8 | 8 |
9 #include "codegen.h" | 9 #include "codegen.h" |
10 #include "deoptimizer.h" | 10 #include "deoptimizer.h" |
(...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
202 FrameDescription* output_frame, CodeStubInterfaceDescriptor* descriptor) { | 202 FrameDescription* output_frame, CodeStubInterfaceDescriptor* descriptor) { |
203 intptr_t handler = | 203 intptr_t handler = |
204 reinterpret_cast<intptr_t>(descriptor->deoptimization_handler_); | 204 reinterpret_cast<intptr_t>(descriptor->deoptimization_handler_); |
205 int params = descriptor->GetHandlerParameterCount(); | 205 int params = descriptor->GetHandlerParameterCount(); |
206 output_frame->SetRegister(eax.code(), params); | 206 output_frame->SetRegister(eax.code(), params); |
207 output_frame->SetRegister(ebx.code(), handler); | 207 output_frame->SetRegister(ebx.code(), handler); |
208 } | 208 } |
209 | 209 |
210 | 210 |
211 void Deoptimizer::CopyDoubleRegisters(FrameDescription* output_frame) { | 211 void Deoptimizer::CopyDoubleRegisters(FrameDescription* output_frame) { |
212 if (!CpuFeatures::IsSupported(SSE2)) return; | |
213 for (int i = 0; i < XMMRegister::kNumAllocatableRegisters; ++i) { | 212 for (int i = 0; i < XMMRegister::kNumAllocatableRegisters; ++i) { |
214 double double_value = input_->GetDoubleRegister(i); | 213 double double_value = input_->GetDoubleRegister(i); |
215 output_frame->SetDoubleRegister(i, double_value); | 214 output_frame->SetDoubleRegister(i, double_value); |
216 } | 215 } |
217 } | 216 } |
218 | 217 |
219 | 218 |
220 bool Deoptimizer::HasAlignmentPadding(JSFunction* function) { | 219 bool Deoptimizer::HasAlignmentPadding(JSFunction* function) { |
221 int parameter_count = function->shared()->formal_parameter_count() + 1; | 220 int parameter_count = function->shared()->formal_parameter_count() + 1; |
222 unsigned input_frame_size = input_->GetFrameSize(); | 221 unsigned input_frame_size = input_->GetFrameSize(); |
223 unsigned alignment_state_offset = | 222 unsigned alignment_state_offset = |
224 input_frame_size - parameter_count * kPointerSize - | 223 input_frame_size - parameter_count * kPointerSize - |
225 StandardFrameConstants::kFixedFrameSize - | 224 StandardFrameConstants::kFixedFrameSize - |
226 kPointerSize; | 225 kPointerSize; |
227 ASSERT(JavaScriptFrameConstants::kDynamicAlignmentStateOffset == | 226 ASSERT(JavaScriptFrameConstants::kDynamicAlignmentStateOffset == |
228 JavaScriptFrameConstants::kLocal0Offset); | 227 JavaScriptFrameConstants::kLocal0Offset); |
229 int32_t alignment_state = input_->GetFrameSlot(alignment_state_offset); | 228 int32_t alignment_state = input_->GetFrameSlot(alignment_state_offset); |
230 return (alignment_state == kAlignmentPaddingPushed); | 229 return (alignment_state == kAlignmentPaddingPushed); |
231 } | 230 } |
232 | 231 |
233 | 232 |
234 Code* Deoptimizer::NotifyStubFailureBuiltin() { | 233 Code* Deoptimizer::NotifyStubFailureBuiltin() { |
235 Builtins::Name name = CpuFeatures::IsSupported(SSE2) ? | 234 return isolate_->builtins()->builtin(Builtins::kNotifyStubFailureSaveDoubles); |
Sven Panne
2014/05/07 13:46:03
I think we always use kNotifyStubFailureSaveDouble
| |
236 Builtins::kNotifyStubFailureSaveDoubles : Builtins::kNotifyStubFailure; | |
237 return isolate_->builtins()->builtin(name); | |
238 } | 235 } |
239 | 236 |
240 | 237 |
241 #define __ masm()-> | 238 #define __ masm()-> |
242 | 239 |
243 void Deoptimizer::EntryGenerator::Generate() { | 240 void Deoptimizer::EntryGenerator::Generate() { |
244 GeneratePrologue(); | 241 GeneratePrologue(); |
245 | 242 |
246 // Save all general purpose registers before messing with them. | 243 // Save all general purpose registers before messing with them. |
247 const int kNumberOfRegisters = Register::kNumRegisters; | 244 const int kNumberOfRegisters = Register::kNumRegisters; |
248 | 245 |
249 const int kDoubleRegsSize = kDoubleSize * | 246 const int kDoubleRegsSize = kDoubleSize * |
250 XMMRegister::kNumAllocatableRegisters; | 247 XMMRegister::kNumAllocatableRegisters; |
251 __ sub(esp, Immediate(kDoubleRegsSize)); | 248 __ sub(esp, Immediate(kDoubleRegsSize)); |
252 if (CpuFeatures::IsSupported(SSE2)) { | 249 for (int i = 0; i < XMMRegister::kNumAllocatableRegisters; ++i) { |
253 CpuFeatureScope scope(masm(), SSE2); | 250 XMMRegister xmm_reg = XMMRegister::FromAllocationIndex(i); |
254 for (int i = 0; i < XMMRegister::kNumAllocatableRegisters; ++i) { | 251 int offset = i * kDoubleSize; |
255 XMMRegister xmm_reg = XMMRegister::FromAllocationIndex(i); | 252 __ movsd(Operand(esp, offset), xmm_reg); |
256 int offset = i * kDoubleSize; | |
257 __ movsd(Operand(esp, offset), xmm_reg); | |
258 } | |
259 } | 253 } |
260 | 254 |
261 __ pushad(); | 255 __ pushad(); |
262 | 256 |
263 const int kSavedRegistersAreaSize = kNumberOfRegisters * kPointerSize + | 257 const int kSavedRegistersAreaSize = kNumberOfRegisters * kPointerSize + |
264 kDoubleRegsSize; | 258 kDoubleRegsSize; |
265 | 259 |
266 // Get the bailout id from the stack. | 260 // Get the bailout id from the stack. |
267 __ mov(ebx, Operand(esp, kSavedRegistersAreaSize)); | 261 __ mov(ebx, Operand(esp, kSavedRegistersAreaSize)); |
268 | 262 |
(...skipping 24 matching lines...) Expand all Loading... | |
293 // frame descriptor pointer. | 287 // frame descriptor pointer. |
294 __ mov(ebx, Operand(eax, Deoptimizer::input_offset())); | 288 __ mov(ebx, Operand(eax, Deoptimizer::input_offset())); |
295 | 289 |
296 // Fill in the input registers. | 290 // Fill in the input registers. |
297 for (int i = kNumberOfRegisters - 1; i >= 0; i--) { | 291 for (int i = kNumberOfRegisters - 1; i >= 0; i--) { |
298 int offset = (i * kPointerSize) + FrameDescription::registers_offset(); | 292 int offset = (i * kPointerSize) + FrameDescription::registers_offset(); |
299 __ pop(Operand(ebx, offset)); | 293 __ pop(Operand(ebx, offset)); |
300 } | 294 } |
301 | 295 |
302 int double_regs_offset = FrameDescription::double_registers_offset(); | 296 int double_regs_offset = FrameDescription::double_registers_offset(); |
303 if (CpuFeatures::IsSupported(SSE2)) { | 297 // Fill in the double input registers. |
304 CpuFeatureScope scope(masm(), SSE2); | 298 for (int i = 0; i < XMMRegister::kNumAllocatableRegisters; ++i) { |
305 // Fill in the double input registers. | 299 int dst_offset = i * kDoubleSize + double_regs_offset; |
306 for (int i = 0; i < XMMRegister::kNumAllocatableRegisters; ++i) { | 300 int src_offset = i * kDoubleSize; |
307 int dst_offset = i * kDoubleSize + double_regs_offset; | 301 __ movsd(xmm0, Operand(esp, src_offset)); |
308 int src_offset = i * kDoubleSize; | 302 __ movsd(Operand(ebx, dst_offset), xmm0); |
309 __ movsd(xmm0, Operand(esp, src_offset)); | |
310 __ movsd(Operand(ebx, dst_offset), xmm0); | |
311 } | |
312 } | 303 } |
313 | 304 |
314 // Clear FPU all exceptions. | 305 // Clear FPU all exceptions. |
315 // TODO(ulan): Find out why the TOP register is not zero here in some cases, | 306 // TODO(ulan): Find out why the TOP register is not zero here in some cases, |
316 // and check that the generated code never deoptimizes with unbalanced stack. | 307 // and check that the generated code never deoptimizes with unbalanced stack. |
317 __ fnclex(); | 308 __ fnclex(); |
318 | 309 |
319 // Remove the bailout id, return address and the double registers. | 310 // Remove the bailout id, return address and the double registers. |
320 __ add(esp, Immediate(kDoubleRegsSize + 2 * kPointerSize)); | 311 __ add(esp, Immediate(kDoubleRegsSize + 2 * kPointerSize)); |
321 | 312 |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
380 __ push(Operand(ebx, ecx, times_1, FrameDescription::frame_content_offset())); | 371 __ push(Operand(ebx, ecx, times_1, FrameDescription::frame_content_offset())); |
381 __ bind(&inner_loop_header); | 372 __ bind(&inner_loop_header); |
382 __ test(ecx, ecx); | 373 __ test(ecx, ecx); |
383 __ j(not_zero, &inner_push_loop); | 374 __ j(not_zero, &inner_push_loop); |
384 __ add(eax, Immediate(kPointerSize)); | 375 __ add(eax, Immediate(kPointerSize)); |
385 __ bind(&outer_loop_header); | 376 __ bind(&outer_loop_header); |
386 __ cmp(eax, edx); | 377 __ cmp(eax, edx); |
387 __ j(below, &outer_push_loop); | 378 __ j(below, &outer_push_loop); |
388 | 379 |
389 // In case of a failed STUB, we have to restore the XMM registers. | 380 // In case of a failed STUB, we have to restore the XMM registers. |
390 if (CpuFeatures::IsSupported(SSE2)) { | 381 for (int i = 0; i < XMMRegister::kNumAllocatableRegisters; ++i) { |
391 CpuFeatureScope scope(masm(), SSE2); | 382 XMMRegister xmm_reg = XMMRegister::FromAllocationIndex(i); |
392 for (int i = 0; i < XMMRegister::kNumAllocatableRegisters; ++i) { | 383 int src_offset = i * kDoubleSize + double_regs_offset; |
393 XMMRegister xmm_reg = XMMRegister::FromAllocationIndex(i); | 384 __ movsd(xmm_reg, Operand(ebx, src_offset)); |
394 int src_offset = i * kDoubleSize + double_regs_offset; | |
395 __ movsd(xmm_reg, Operand(ebx, src_offset)); | |
396 } | |
397 } | 385 } |
398 | 386 |
399 // Push state, pc, and continuation from the last output frame. | 387 // Push state, pc, and continuation from the last output frame. |
400 __ push(Operand(ebx, FrameDescription::state_offset())); | 388 __ push(Operand(ebx, FrameDescription::state_offset())); |
401 __ push(Operand(ebx, FrameDescription::pc_offset())); | 389 __ push(Operand(ebx, FrameDescription::pc_offset())); |
402 __ push(Operand(ebx, FrameDescription::continuation_offset())); | 390 __ push(Operand(ebx, FrameDescription::continuation_offset())); |
403 | 391 |
404 | 392 |
405 // Push the registers from the last output frame. | 393 // Push the registers from the last output frame. |
406 for (int i = 0; i < kNumberOfRegisters; i++) { | 394 for (int i = 0; i < kNumberOfRegisters; i++) { |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
445 UNREACHABLE(); | 433 UNREACHABLE(); |
446 } | 434 } |
447 | 435 |
448 | 436 |
449 #undef __ | 437 #undef __ |
450 | 438 |
451 | 439 |
452 } } // namespace v8::internal | 440 } } // namespace v8::internal |
453 | 441 |
454 #endif // V8_TARGET_ARCH_IA32 | 442 #endif // V8_TARGET_ARCH_IA32 |
OLD | NEW |