| 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 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 104 #ifdef _MSC_VER | 104 #ifdef _MSC_VER |
| 105 void LCodeGen::MakeSureStackPagesMapped(int offset) { | 105 void LCodeGen::MakeSureStackPagesMapped(int offset) { |
| 106 const int kPageSize = 4 * KB; | 106 const int kPageSize = 4 * KB; |
| 107 for (offset -= kPageSize; offset > 0; offset -= kPageSize) { | 107 for (offset -= kPageSize; offset > 0; offset -= kPageSize) { |
| 108 __ movq(Operand(rsp, offset), rax); | 108 __ movq(Operand(rsp, offset), rax); |
| 109 } | 109 } |
| 110 } | 110 } |
| 111 #endif | 111 #endif |
| 112 | 112 |
| 113 | 113 |
| 114 void LCodeGen::SaveCallerDoubles() { |
| 115 ASSERT(info()->saves_caller_doubles()); |
| 116 ASSERT(NeedsEagerFrame()); |
| 117 Comment(";;; Save clobbered callee double registers"); |
| 118 int count = 0; |
| 119 BitVector* doubles = chunk()->allocated_double_registers(); |
| 120 BitVector::Iterator save_iterator(doubles); |
| 121 while (!save_iterator.Done()) { |
| 122 __ movsd(MemOperand(rsp, count * kDoubleSize), |
| 123 XMMRegister::FromAllocationIndex(save_iterator.Current())); |
| 124 save_iterator.Advance(); |
| 125 count++; |
| 126 } |
| 127 } |
| 128 |
| 129 |
| 130 void LCodeGen::RestoreCallerDoubles() { |
| 131 ASSERT(info()->saves_caller_doubles()); |
| 132 ASSERT(NeedsEagerFrame()); |
| 133 Comment(";;; Restore clobbered callee double registers"); |
| 134 BitVector* doubles = chunk()->allocated_double_registers(); |
| 135 BitVector::Iterator save_iterator(doubles); |
| 136 int count = 0; |
| 137 while (!save_iterator.Done()) { |
| 138 __ movsd(XMMRegister::FromAllocationIndex(save_iterator.Current()), |
| 139 MemOperand(rsp, count * kDoubleSize)); |
| 140 save_iterator.Advance(); |
| 141 count++; |
| 142 } |
| 143 } |
| 144 |
| 145 |
| 114 bool LCodeGen::GeneratePrologue() { | 146 bool LCodeGen::GeneratePrologue() { |
| 115 ASSERT(is_generating()); | 147 ASSERT(is_generating()); |
| 116 | 148 |
| 117 if (info()->IsOptimizing()) { | 149 if (info()->IsOptimizing()) { |
| 118 ProfileEntryHookStub::MaybeCallEntryHook(masm_); | 150 ProfileEntryHookStub::MaybeCallEntryHook(masm_); |
| 119 | 151 |
| 120 #ifdef DEBUG | 152 #ifdef DEBUG |
| 121 if (strlen(FLAG_stop_at) > 0 && | 153 if (strlen(FLAG_stop_at) > 0 && |
| 122 info_->function()->name()->IsUtf8EqualTo(CStrVector(FLAG_stop_at))) { | 154 info_->function()->name()->IsUtf8EqualTo(CStrVector(FLAG_stop_at))) { |
| 123 __ int3(); | 155 __ int3(); |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 166 __ j(not_zero, &loop); | 198 __ j(not_zero, &loop); |
| 167 __ pop(rax); | 199 __ pop(rax); |
| 168 } else { | 200 } else { |
| 169 __ subq(rsp, Immediate(slots * kPointerSize)); | 201 __ subq(rsp, Immediate(slots * kPointerSize)); |
| 170 #ifdef _MSC_VER | 202 #ifdef _MSC_VER |
| 171 MakeSureStackPagesMapped(slots * kPointerSize); | 203 MakeSureStackPagesMapped(slots * kPointerSize); |
| 172 #endif | 204 #endif |
| 173 } | 205 } |
| 174 | 206 |
| 175 if (info()->saves_caller_doubles()) { | 207 if (info()->saves_caller_doubles()) { |
| 176 Comment(";;; Save clobbered callee double registers"); | 208 SaveCallerDoubles(); |
| 177 int count = 0; | |
| 178 BitVector* doubles = chunk()->allocated_double_registers(); | |
| 179 BitVector::Iterator save_iterator(doubles); | |
| 180 while (!save_iterator.Done()) { | |
| 181 __ movsd(MemOperand(rsp, count * kDoubleSize), | |
| 182 XMMRegister::FromAllocationIndex(save_iterator.Current())); | |
| 183 save_iterator.Advance(); | |
| 184 count++; | |
| 185 } | |
| 186 } | 209 } |
| 187 } | 210 } |
| 188 | 211 |
| 189 // Possibly allocate a local context. | 212 // Possibly allocate a local context. |
| 190 int heap_slots = info_->num_heap_slots() - Context::MIN_CONTEXT_SLOTS; | 213 int heap_slots = info_->num_heap_slots() - Context::MIN_CONTEXT_SLOTS; |
| 191 if (heap_slots > 0) { | 214 if (heap_slots > 0) { |
| 192 Comment(";;; Allocate local context"); | 215 Comment(";;; Allocate local context"); |
| 193 // Argument to NewContext is the function, which is still in rdi. | 216 // Argument to NewContext is the function, which is still in rdi. |
| 194 __ push(rdi); | 217 __ push(rdi); |
| 195 if (heap_slots <= FastNewContextStub::kMaximumSlots) { | 218 if (heap_slots <= FastNewContextStub::kMaximumSlots) { |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 254 __ bind(&jump_table_[i].label); | 277 __ bind(&jump_table_[i].label); |
| 255 Address entry = jump_table_[i].address; | 278 Address entry = jump_table_[i].address; |
| 256 Deoptimizer::BailoutType type = jump_table_[i].bailout_type; | 279 Deoptimizer::BailoutType type = jump_table_[i].bailout_type; |
| 257 int id = Deoptimizer::GetDeoptimizationId(isolate(), entry, type); | 280 int id = Deoptimizer::GetDeoptimizationId(isolate(), entry, type); |
| 258 if (id == Deoptimizer::kNotDeoptimizationEntry) { | 281 if (id == Deoptimizer::kNotDeoptimizationEntry) { |
| 259 Comment(";;; jump table entry %d.", i); | 282 Comment(";;; jump table entry %d.", i); |
| 260 } else { | 283 } else { |
| 261 Comment(";;; jump table entry %d: deoptimization bailout %d.", i, id); | 284 Comment(";;; jump table entry %d: deoptimization bailout %d.", i, id); |
| 262 } | 285 } |
| 263 if (jump_table_[i].needs_frame) { | 286 if (jump_table_[i].needs_frame) { |
| 287 ASSERT(!info()->saves_caller_doubles()); |
| 264 __ movq(kScratchRegister, ExternalReference::ForDeoptEntry(entry)); | 288 __ movq(kScratchRegister, ExternalReference::ForDeoptEntry(entry)); |
| 265 if (needs_frame.is_bound()) { | 289 if (needs_frame.is_bound()) { |
| 266 __ jmp(&needs_frame); | 290 __ jmp(&needs_frame); |
| 267 } else { | 291 } else { |
| 268 __ bind(&needs_frame); | 292 __ bind(&needs_frame); |
| 269 __ push(rbp); | 293 __ push(rbp); |
| 270 __ movq(rbp, rsp); | 294 __ movq(rbp, rsp); |
| 271 __ push(rsi); | 295 __ push(rsi); |
| 272 // This variant of deopt can only be used with stubs. Since we don't | 296 // This variant of deopt can only be used with stubs. Since we don't |
| 273 // have a function pointer to install in the stack frame that we're | 297 // have a function pointer to install in the stack frame that we're |
| 274 // building, install a special marker there instead. | 298 // building, install a special marker there instead. |
| 275 ASSERT(info()->IsStub()); | 299 ASSERT(info()->IsStub()); |
| 276 __ Move(rsi, Smi::FromInt(StackFrame::STUB)); | 300 __ Move(rsi, Smi::FromInt(StackFrame::STUB)); |
| 277 __ push(rsi); | 301 __ push(rsi); |
| 278 __ movq(rsi, MemOperand(rsp, kPointerSize)); | 302 __ movq(rsi, MemOperand(rsp, kPointerSize)); |
| 279 __ call(kScratchRegister); | 303 __ call(kScratchRegister); |
| 280 } | 304 } |
| 281 } else { | 305 } else { |
| 306 if (info()->saves_caller_doubles()) { |
| 307 ASSERT(info()->IsStub()); |
| 308 RestoreCallerDoubles(); |
| 309 } |
| 282 __ call(entry, RelocInfo::RUNTIME_ENTRY); | 310 __ call(entry, RelocInfo::RUNTIME_ENTRY); |
| 283 } | 311 } |
| 284 } | 312 } |
| 285 return !is_aborted(); | 313 return !is_aborted(); |
| 286 } | 314 } |
| 287 | 315 |
| 288 | 316 |
| 289 bool LCodeGen::GenerateDeferredCode() { | 317 bool LCodeGen::GenerateDeferredCode() { |
| 290 ASSERT(is_generating()); | 318 ASSERT(is_generating()); |
| 291 if (deferred_.length() > 0) { | 319 if (deferred_.length() > 0) { |
| (...skipping 362 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 654 if (info()->ShouldTrapOnDeopt()) { | 682 if (info()->ShouldTrapOnDeopt()) { |
| 655 Label done; | 683 Label done; |
| 656 if (cc != no_condition) { | 684 if (cc != no_condition) { |
| 657 __ j(NegateCondition(cc), &done, Label::kNear); | 685 __ j(NegateCondition(cc), &done, Label::kNear); |
| 658 } | 686 } |
| 659 __ int3(); | 687 __ int3(); |
| 660 __ bind(&done); | 688 __ bind(&done); |
| 661 } | 689 } |
| 662 | 690 |
| 663 ASSERT(info()->IsStub() || frame_is_built_); | 691 ASSERT(info()->IsStub() || frame_is_built_); |
| 664 if (cc == no_condition && frame_is_built_) { | 692 // Go through jump table if we need to handle condition, build frame, or |
| 693 // restore caller doubles. |
| 694 if (cc == no_condition && frame_is_built_ && |
| 695 !info()->saves_caller_doubles()) { |
| 665 __ call(entry, RelocInfo::RUNTIME_ENTRY); | 696 __ call(entry, RelocInfo::RUNTIME_ENTRY); |
| 666 } else { | 697 } else { |
| 667 // We often have several deopts to the same entry, reuse the last | 698 // We often have several deopts to the same entry, reuse the last |
| 668 // jump entry if this is the case. | 699 // jump entry if this is the case. |
| 669 if (jump_table_.is_empty() || | 700 if (jump_table_.is_empty() || |
| 670 jump_table_.last().address != entry || | 701 jump_table_.last().address != entry || |
| 671 jump_table_.last().needs_frame != !frame_is_built_ || | 702 jump_table_.last().needs_frame != !frame_is_built_ || |
| 672 jump_table_.last().bailout_type != bailout_type) { | 703 jump_table_.last().bailout_type != bailout_type) { |
| 673 Deoptimizer::JumpTableEntry table_entry(entry, | 704 Deoptimizer::JumpTableEntry table_entry(entry, |
| 674 bailout_type, | 705 bailout_type, |
| (...skipping 1869 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2544 | 2575 |
| 2545 | 2576 |
| 2546 void LCodeGen::DoReturn(LReturn* instr) { | 2577 void LCodeGen::DoReturn(LReturn* instr) { |
| 2547 if (FLAG_trace && info()->IsOptimizing()) { | 2578 if (FLAG_trace && info()->IsOptimizing()) { |
| 2548 // Preserve the return value on the stack and rely on the runtime | 2579 // Preserve the return value on the stack and rely on the runtime |
| 2549 // call to return the value in the same register. | 2580 // call to return the value in the same register. |
| 2550 __ push(rax); | 2581 __ push(rax); |
| 2551 __ CallRuntime(Runtime::kTraceExit, 1); | 2582 __ CallRuntime(Runtime::kTraceExit, 1); |
| 2552 } | 2583 } |
| 2553 if (info()->saves_caller_doubles()) { | 2584 if (info()->saves_caller_doubles()) { |
| 2554 ASSERT(NeedsEagerFrame()); | 2585 RestoreCallerDoubles(); |
| 2555 BitVector* doubles = chunk()->allocated_double_registers(); | |
| 2556 BitVector::Iterator save_iterator(doubles); | |
| 2557 int count = 0; | |
| 2558 while (!save_iterator.Done()) { | |
| 2559 __ movsd(XMMRegister::FromAllocationIndex(save_iterator.Current()), | |
| 2560 MemOperand(rsp, count * kDoubleSize)); | |
| 2561 save_iterator.Advance(); | |
| 2562 count++; | |
| 2563 } | |
| 2564 } | 2586 } |
| 2565 int no_frame_start = -1; | 2587 int no_frame_start = -1; |
| 2566 if (NeedsEagerFrame()) { | 2588 if (NeedsEagerFrame()) { |
| 2567 __ movq(rsp, rbp); | 2589 __ movq(rsp, rbp); |
| 2568 __ pop(rbp); | 2590 __ pop(rbp); |
| 2569 no_frame_start = masm_->pc_offset(); | 2591 no_frame_start = masm_->pc_offset(); |
| 2570 } | 2592 } |
| 2571 if (instr->has_constant_parameter_count()) { | 2593 if (instr->has_constant_parameter_count()) { |
| 2572 __ Ret((ToInteger32(instr->constant_parameter_count()) + 1) * kPointerSize, | 2594 __ Ret((ToInteger32(instr->constant_parameter_count()) + 1) * kPointerSize, |
| 2573 rcx); | 2595 rcx); |
| (...skipping 2902 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5476 FixedArray::kHeaderSize - kPointerSize)); | 5498 FixedArray::kHeaderSize - kPointerSize)); |
| 5477 __ bind(&done); | 5499 __ bind(&done); |
| 5478 } | 5500 } |
| 5479 | 5501 |
| 5480 | 5502 |
| 5481 #undef __ | 5503 #undef __ |
| 5482 | 5504 |
| 5483 } } // namespace v8::internal | 5505 } } // namespace v8::internal |
| 5484 | 5506 |
| 5485 #endif // V8_TARGET_ARCH_X64 | 5507 #endif // V8_TARGET_ARCH_X64 |
| OLD | NEW |