| OLD | NEW |
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 141 #ifdef _MSC_VER | 141 #ifdef _MSC_VER |
| 142 void LCodeGen::MakeSureStackPagesMapped(int offset) { | 142 void LCodeGen::MakeSureStackPagesMapped(int offset) { |
| 143 const int kPageSize = 4 * KB; | 143 const int kPageSize = 4 * KB; |
| 144 for (offset -= kPageSize; offset > 0; offset -= kPageSize) { | 144 for (offset -= kPageSize; offset > 0; offset -= kPageSize) { |
| 145 __ mov(Operand(esp, offset), eax); | 145 __ mov(Operand(esp, offset), eax); |
| 146 } | 146 } |
| 147 } | 147 } |
| 148 #endif | 148 #endif |
| 149 | 149 |
| 150 | 150 |
| 151 void LCodeGen::SaveCallerDoubles() { |
| 152 ASSERT(info()->saves_caller_doubles()); |
| 153 ASSERT(NeedsEagerFrame()); |
| 154 Comment(";;; Save clobbered callee double registers"); |
| 155 CpuFeatureScope scope(masm(), SSE2); |
| 156 int count = 0; |
| 157 BitVector* doubles = chunk()->allocated_double_registers(); |
| 158 BitVector::Iterator save_iterator(doubles); |
| 159 while (!save_iterator.Done()) { |
| 160 __ movdbl(MemOperand(esp, count * kDoubleSize), |
| 161 XMMRegister::FromAllocationIndex(save_iterator.Current())); |
| 162 save_iterator.Advance(); |
| 163 count++; |
| 164 } |
| 165 } |
| 166 |
| 167 |
| 168 void LCodeGen::RestoreCallerDoubles() { |
| 169 ASSERT(info()->saves_caller_doubles()); |
| 170 ASSERT(NeedsEagerFrame()); |
| 171 Comment(";;; Restore clobbered callee double registers"); |
| 172 CpuFeatureScope scope(masm(), SSE2); |
| 173 BitVector* doubles = chunk()->allocated_double_registers(); |
| 174 BitVector::Iterator save_iterator(doubles); |
| 175 int count = 0; |
| 176 while (!save_iterator.Done()) { |
| 177 __ movdbl(XMMRegister::FromAllocationIndex(save_iterator.Current()), |
| 178 MemOperand(esp, count * kDoubleSize)); |
| 179 save_iterator.Advance(); |
| 180 count++; |
| 181 } |
| 182 } |
| 183 |
| 184 |
| 151 bool LCodeGen::GeneratePrologue() { | 185 bool LCodeGen::GeneratePrologue() { |
| 152 ASSERT(is_generating()); | 186 ASSERT(is_generating()); |
| 153 | 187 |
| 154 if (info()->IsOptimizing()) { | 188 if (info()->IsOptimizing()) { |
| 155 ProfileEntryHookStub::MaybeCallEntryHook(masm_); | 189 ProfileEntryHookStub::MaybeCallEntryHook(masm_); |
| 156 | 190 |
| 157 #ifdef DEBUG | 191 #ifdef DEBUG |
| 158 if (strlen(FLAG_stop_at) > 0 && | 192 if (strlen(FLAG_stop_at) > 0 && |
| 159 info_->function()->name()->IsUtf8EqualTo(CStrVector(FLAG_stop_at))) { | 193 info_->function()->name()->IsUtf8EqualTo(CStrVector(FLAG_stop_at))) { |
| 160 __ int3(); | 194 __ int3(); |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 262 int offset = JavaScriptFrameConstants::kDynamicAlignmentStateOffset; | 296 int offset = JavaScriptFrameConstants::kDynamicAlignmentStateOffset; |
| 263 if (dynamic_frame_alignment_) { | 297 if (dynamic_frame_alignment_) { |
| 264 __ mov(Operand(ebp, offset), edx); | 298 __ mov(Operand(ebp, offset), edx); |
| 265 } else { | 299 } else { |
| 266 __ mov(Operand(ebp, offset), Immediate(kNoAlignmentPadding)); | 300 __ mov(Operand(ebp, offset), Immediate(kNoAlignmentPadding)); |
| 267 } | 301 } |
| 268 } | 302 } |
| 269 } | 303 } |
| 270 | 304 |
| 271 if (info()->saves_caller_doubles() && CpuFeatures::IsSupported(SSE2)) { | 305 if (info()->saves_caller_doubles() && CpuFeatures::IsSupported(SSE2)) { |
| 272 Comment(";;; Save clobbered callee double registers"); | 306 SaveCallerDoubles(); |
| 273 CpuFeatureScope scope(masm(), SSE2); | |
| 274 int count = 0; | |
| 275 BitVector* doubles = chunk()->allocated_double_registers(); | |
| 276 BitVector::Iterator save_iterator(doubles); | |
| 277 while (!save_iterator.Done()) { | |
| 278 __ movdbl(MemOperand(esp, count * kDoubleSize), | |
| 279 XMMRegister::FromAllocationIndex(save_iterator.Current())); | |
| 280 save_iterator.Advance(); | |
| 281 count++; | |
| 282 } | |
| 283 } | 307 } |
| 284 } | 308 } |
| 285 | 309 |
| 286 // Possibly allocate a local context. | 310 // Possibly allocate a local context. |
| 287 int heap_slots = info_->num_heap_slots() - Context::MIN_CONTEXT_SLOTS; | 311 int heap_slots = info_->num_heap_slots() - Context::MIN_CONTEXT_SLOTS; |
| 288 if (heap_slots > 0) { | 312 if (heap_slots > 0) { |
| 289 Comment(";;; Allocate local context"); | 313 Comment(";;; Allocate local context"); |
| 290 // Argument to NewContext is the function, which is still in edi. | 314 // Argument to NewContext is the function, which is still in edi. |
| 291 __ push(edi); | 315 __ push(edi); |
| 292 if (heap_slots <= FastNewContextStub::kMaximumSlots) { | 316 if (heap_slots <= FastNewContextStub::kMaximumSlots) { |
| (...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 405 __ bind(&jump_table_[i].label); | 429 __ bind(&jump_table_[i].label); |
| 406 Address entry = jump_table_[i].address; | 430 Address entry = jump_table_[i].address; |
| 407 Deoptimizer::BailoutType type = jump_table_[i].bailout_type; | 431 Deoptimizer::BailoutType type = jump_table_[i].bailout_type; |
| 408 int id = Deoptimizer::GetDeoptimizationId(isolate(), entry, type); | 432 int id = Deoptimizer::GetDeoptimizationId(isolate(), entry, type); |
| 409 if (id == Deoptimizer::kNotDeoptimizationEntry) { | 433 if (id == Deoptimizer::kNotDeoptimizationEntry) { |
| 410 Comment(";;; jump table entry %d.", i); | 434 Comment(";;; jump table entry %d.", i); |
| 411 } else { | 435 } else { |
| 412 Comment(";;; jump table entry %d: deoptimization bailout %d.", i, id); | 436 Comment(";;; jump table entry %d: deoptimization bailout %d.", i, id); |
| 413 } | 437 } |
| 414 if (jump_table_[i].needs_frame) { | 438 if (jump_table_[i].needs_frame) { |
| 439 ASSERT(!info()->saves_caller_doubles()); |
| 415 __ push(Immediate(ExternalReference::ForDeoptEntry(entry))); | 440 __ push(Immediate(ExternalReference::ForDeoptEntry(entry))); |
| 416 if (needs_frame.is_bound()) { | 441 if (needs_frame.is_bound()) { |
| 417 __ jmp(&needs_frame); | 442 __ jmp(&needs_frame); |
| 418 } else { | 443 } else { |
| 419 __ bind(&needs_frame); | 444 __ bind(&needs_frame); |
| 420 __ push(MemOperand(ebp, StandardFrameConstants::kContextOffset)); | 445 __ push(MemOperand(ebp, StandardFrameConstants::kContextOffset)); |
| 421 // This variant of deopt can only be used with stubs. Since we don't | 446 // This variant of deopt can only be used with stubs. Since we don't |
| 422 // have a function pointer to install in the stack frame that we're | 447 // have a function pointer to install in the stack frame that we're |
| 423 // building, install a special marker there instead. | 448 // building, install a special marker there instead. |
| 424 ASSERT(info()->IsStub()); | 449 ASSERT(info()->IsStub()); |
| 425 __ push(Immediate(Smi::FromInt(StackFrame::STUB))); | 450 __ push(Immediate(Smi::FromInt(StackFrame::STUB))); |
| 426 // Push a PC inside the function so that the deopt code can find where | 451 // Push a PC inside the function so that the deopt code can find where |
| 427 // the deopt comes from. It doesn't have to be the precise return | 452 // the deopt comes from. It doesn't have to be the precise return |
| 428 // address of a "calling" LAZY deopt, it only has to be somewhere | 453 // address of a "calling" LAZY deopt, it only has to be somewhere |
| 429 // inside the code body. | 454 // inside the code body. |
| 430 Label push_approx_pc; | 455 Label push_approx_pc; |
| 431 __ call(&push_approx_pc); | 456 __ call(&push_approx_pc); |
| 432 __ bind(&push_approx_pc); | 457 __ bind(&push_approx_pc); |
| 433 // Push the continuation which was stashed were the ebp should | 458 // Push the continuation which was stashed were the ebp should |
| 434 // be. Replace it with the saved ebp. | 459 // be. Replace it with the saved ebp. |
| 435 __ push(MemOperand(esp, 3 * kPointerSize)); | 460 __ push(MemOperand(esp, 3 * kPointerSize)); |
| 436 __ mov(MemOperand(esp, 4 * kPointerSize), ebp); | 461 __ mov(MemOperand(esp, 4 * kPointerSize), ebp); |
| 437 __ lea(ebp, MemOperand(esp, 4 * kPointerSize)); | 462 __ lea(ebp, MemOperand(esp, 4 * kPointerSize)); |
| 438 __ ret(0); // Call the continuation without clobbering registers. | 463 __ ret(0); // Call the continuation without clobbering registers. |
| 439 } | 464 } |
| 440 } else { | 465 } else { |
| 466 if (info()->saves_caller_doubles() && CpuFeatures::IsSupported(SSE2)) { |
| 467 RestoreCallerDoubles(); |
| 468 } |
| 441 __ call(entry, RelocInfo::RUNTIME_ENTRY); | 469 __ call(entry, RelocInfo::RUNTIME_ENTRY); |
| 442 } | 470 } |
| 443 } | 471 } |
| 444 return !is_aborted(); | 472 return !is_aborted(); |
| 445 } | 473 } |
| 446 | 474 |
| 447 | 475 |
| 448 bool LCodeGen::GenerateDeferredCode() { | 476 bool LCodeGen::GenerateDeferredCode() { |
| 449 ASSERT(is_generating()); | 477 ASSERT(is_generating()); |
| 450 if (deferred_.length() > 0) { | 478 if (deferred_.length() > 0) { |
| (...skipping 2632 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3083 if (FLAG_trace && info()->IsOptimizing()) { | 3111 if (FLAG_trace && info()->IsOptimizing()) { |
| 3084 // Preserve the return value on the stack and rely on the runtime call | 3112 // Preserve the return value on the stack and rely on the runtime call |
| 3085 // to return the value in the same register. We're leaving the code | 3113 // to return the value in the same register. We're leaving the code |
| 3086 // managed by the register allocator and tearing down the frame, it's | 3114 // managed by the register allocator and tearing down the frame, it's |
| 3087 // safe to write to the context register. | 3115 // safe to write to the context register. |
| 3088 __ push(eax); | 3116 __ push(eax); |
| 3089 __ mov(esi, Operand(ebp, StandardFrameConstants::kContextOffset)); | 3117 __ mov(esi, Operand(ebp, StandardFrameConstants::kContextOffset)); |
| 3090 __ CallRuntime(Runtime::kTraceExit, 1); | 3118 __ CallRuntime(Runtime::kTraceExit, 1); |
| 3091 } | 3119 } |
| 3092 if (info()->saves_caller_doubles() && CpuFeatures::IsSupported(SSE2)) { | 3120 if (info()->saves_caller_doubles() && CpuFeatures::IsSupported(SSE2)) { |
| 3093 ASSERT(NeedsEagerFrame()); | 3121 RestoreCallerDoubles(); |
| 3094 CpuFeatureScope scope(masm(), SSE2); | |
| 3095 BitVector* doubles = chunk()->allocated_double_registers(); | |
| 3096 BitVector::Iterator save_iterator(doubles); | |
| 3097 int count = 0; | |
| 3098 while (!save_iterator.Done()) { | |
| 3099 __ movdbl(XMMRegister::FromAllocationIndex(save_iterator.Current()), | |
| 3100 MemOperand(esp, count * kDoubleSize)); | |
| 3101 save_iterator.Advance(); | |
| 3102 count++; | |
| 3103 } | |
| 3104 } | 3122 } |
| 3105 if (dynamic_frame_alignment_) { | 3123 if (dynamic_frame_alignment_) { |
| 3106 // Fetch the state of the dynamic frame alignment. | 3124 // Fetch the state of the dynamic frame alignment. |
| 3107 __ mov(edx, Operand(ebp, | 3125 __ mov(edx, Operand(ebp, |
| 3108 JavaScriptFrameConstants::kDynamicAlignmentStateOffset)); | 3126 JavaScriptFrameConstants::kDynamicAlignmentStateOffset)); |
| 3109 } | 3127 } |
| 3110 int no_frame_start = -1; | 3128 int no_frame_start = -1; |
| 3111 if (NeedsEagerFrame()) { | 3129 if (NeedsEagerFrame()) { |
| 3112 __ mov(esp, ebp); | 3130 __ mov(esp, ebp); |
| 3113 __ pop(ebp); | 3131 __ pop(ebp); |
| (...skipping 3254 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6368 FixedArray::kHeaderSize - kPointerSize)); | 6386 FixedArray::kHeaderSize - kPointerSize)); |
| 6369 __ bind(&done); | 6387 __ bind(&done); |
| 6370 } | 6388 } |
| 6371 | 6389 |
| 6372 | 6390 |
| 6373 #undef __ | 6391 #undef __ |
| 6374 | 6392 |
| 6375 } } // namespace v8::internal | 6393 } } // namespace v8::internal |
| 6376 | 6394 |
| 6377 #endif // V8_TARGET_ARCH_IA32 | 6395 #endif // V8_TARGET_ARCH_IA32 |
| OLD | NEW |