OLD | NEW |
1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 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 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
156 const int kPageSize = 4 * KB; | 156 const int kPageSize = 4 * KB; |
157 for (int offset = slots * kPointerSize - kPageSize; | 157 for (int offset = slots * kPointerSize - kPageSize; |
158 offset > 0; | 158 offset > 0; |
159 offset -= kPageSize) { | 159 offset -= kPageSize) { |
160 __ movq(Operand(rsp, offset), rax); | 160 __ movq(Operand(rsp, offset), rax); |
161 } | 161 } |
162 #endif | 162 #endif |
163 } | 163 } |
164 } | 164 } |
165 | 165 |
| 166 // Possibly allocate a local context. |
| 167 int heap_slots = scope()->num_heap_slots() - Context::MIN_CONTEXT_SLOTS; |
| 168 if (heap_slots > 0) { |
| 169 Comment(";;; Allocate local context"); |
| 170 // Argument to NewContext is the function, which is still in rdi. |
| 171 __ push(rdi); |
| 172 if (heap_slots <= FastNewContextStub::kMaximumSlots) { |
| 173 FastNewContextStub stub(heap_slots); |
| 174 __ CallStub(&stub); |
| 175 } else { |
| 176 __ CallRuntime(Runtime::kNewContext, 1); |
| 177 } |
| 178 RecordSafepoint(Safepoint::kNoDeoptimizationIndex); |
| 179 // Context is returned in both rax and rsi. It replaces the context |
| 180 // passed to us. It's saved in the stack and kept live in rsi. |
| 181 __ movq(Operand(rbp, StandardFrameConstants::kContextOffset), rsi); |
| 182 |
| 183 // Copy any necessary parameters into the context. |
| 184 int num_parameters = scope()->num_parameters(); |
| 185 for (int i = 0; i < num_parameters; i++) { |
| 186 Slot* slot = scope()->parameter(i)->AsSlot(); |
| 187 if (slot != NULL && slot->type() == Slot::CONTEXT) { |
| 188 int parameter_offset = StandardFrameConstants::kCallerSPOffset + |
| 189 (num_parameters - 1 - i) * kPointerSize; |
| 190 // Load parameter from stack. |
| 191 __ movq(rax, Operand(rbp, parameter_offset)); |
| 192 // Store it in the context. |
| 193 int context_offset = Context::SlotOffset(slot->index()); |
| 194 __ movq(Operand(rsi, context_offset), rax); |
| 195 // Update the write barrier. This clobbers all involved |
| 196 // registers, so we have use a third register to avoid |
| 197 // clobbering rsi. |
| 198 __ movq(rcx, rsi); |
| 199 __ RecordWrite(rcx, context_offset, rax, rbx); |
| 200 } |
| 201 } |
| 202 Comment(";;; End allocate local context"); |
| 203 } |
| 204 |
166 // Trace the call. | 205 // Trace the call. |
167 if (FLAG_trace) { | 206 if (FLAG_trace) { |
168 __ CallRuntime(Runtime::kTraceEnter, 0); | 207 __ CallRuntime(Runtime::kTraceEnter, 0); |
169 } | 208 } |
170 return !is_aborted(); | 209 return !is_aborted(); |
171 } | 210 } |
172 | 211 |
173 | 212 |
174 bool LCodeGen::GenerateBody() { | 213 bool LCodeGen::GenerateBody() { |
175 ASSERT(is_generating()); | 214 ASSERT(is_generating()); |
(...skipping 387 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
563 } | 602 } |
564 } | 603 } |
565 | 604 |
566 | 605 |
567 void LCodeGen::RecordSafepoint(LPointerMap* pointers, | 606 void LCodeGen::RecordSafepoint(LPointerMap* pointers, |
568 int deoptimization_index) { | 607 int deoptimization_index) { |
569 RecordSafepoint(pointers, Safepoint::kSimple, 0, deoptimization_index); | 608 RecordSafepoint(pointers, Safepoint::kSimple, 0, deoptimization_index); |
570 } | 609 } |
571 | 610 |
572 | 611 |
| 612 void LCodeGen::RecordSafepoint(int deoptimization_index) { |
| 613 LPointerMap empty_pointers(RelocInfo::kNoPosition); |
| 614 RecordSafepoint(&empty_pointers, deoptimization_index); |
| 615 } |
| 616 |
| 617 |
573 void LCodeGen::RecordSafepointWithRegisters(LPointerMap* pointers, | 618 void LCodeGen::RecordSafepointWithRegisters(LPointerMap* pointers, |
574 int arguments, | 619 int arguments, |
575 int deoptimization_index) { | 620 int deoptimization_index) { |
576 RecordSafepoint(pointers, Safepoint::kWithRegisters, arguments, | 621 RecordSafepoint(pointers, Safepoint::kWithRegisters, arguments, |
577 deoptimization_index); | 622 deoptimization_index); |
578 } | 623 } |
579 | 624 |
580 | 625 |
581 void LCodeGen::RecordPosition(int position) { | 626 void LCodeGen::RecordPosition(int position) { |
582 if (!FLAG_debug_info || position == RelocInfo::kNoPosition) return; | 627 if (!FLAG_debug_info || position == RelocInfo::kNoPosition) return; |
(...skipping 2650 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3233 RegisterEnvironmentForDeoptimization(environment); | 3278 RegisterEnvironmentForDeoptimization(environment); |
3234 ASSERT(osr_pc_offset_ == -1); | 3279 ASSERT(osr_pc_offset_ == -1); |
3235 osr_pc_offset_ = masm()->pc_offset(); | 3280 osr_pc_offset_ = masm()->pc_offset(); |
3236 } | 3281 } |
3237 | 3282 |
3238 #undef __ | 3283 #undef __ |
3239 | 3284 |
3240 } } // namespace v8::internal | 3285 } } // namespace v8::internal |
3241 | 3286 |
3242 #endif // V8_TARGET_ARCH_X64 | 3287 #endif // V8_TARGET_ARCH_X64 |
OLD | NEW |