OLD | NEW |
1 // Copyright 2013 the V8 project authors. All rights reserved. | 1 // Copyright 2013 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_X64 | 5 #if V8_TARGET_ARCH_X64 |
6 | 6 |
7 #include "src/base/bits.h" | 7 #include "src/base/bits.h" |
8 #include "src/code-factory.h" | 8 #include "src/code-factory.h" |
9 #include "src/code-stubs.h" | 9 #include "src/code-stubs.h" |
10 #include "src/cpu-profiler.h" | 10 #include "src/cpu-profiler.h" |
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
178 __ subp(rsp, Immediate(slots * kPointerSize)); | 178 __ subp(rsp, Immediate(slots * kPointerSize)); |
179 #ifdef _MSC_VER | 179 #ifdef _MSC_VER |
180 MakeSureStackPagesMapped(slots * kPointerSize); | 180 MakeSureStackPagesMapped(slots * kPointerSize); |
181 #endif | 181 #endif |
182 } | 182 } |
183 | 183 |
184 if (info()->saves_caller_doubles()) { | 184 if (info()->saves_caller_doubles()) { |
185 SaveCallerDoubles(); | 185 SaveCallerDoubles(); |
186 } | 186 } |
187 } | 187 } |
| 188 return !is_aborted(); |
| 189 } |
| 190 |
| 191 |
| 192 void LCodeGen::DoPrologue(LPrologue* instr) { |
| 193 Comment(";;; Prologue begin"); |
188 | 194 |
189 // Possibly allocate a local context. | 195 // Possibly allocate a local context. |
190 int heap_slots = info_->num_heap_slots() - Context::MIN_CONTEXT_SLOTS; | 196 if (info_->num_heap_slots() > 0) { |
191 if (heap_slots > 0) { | |
192 Comment(";;; Allocate local context"); | 197 Comment(";;; Allocate local context"); |
193 bool need_write_barrier = true; | 198 bool need_write_barrier = true; |
194 // Argument to NewContext is the function, which is still in rdi. | 199 // Argument to NewContext is the function, which is still in rdi. |
195 DCHECK(!info()->scope()->is_script_scope()); | 200 int slots = info_->num_heap_slots() - Context::MIN_CONTEXT_SLOTS; |
196 if (heap_slots <= FastNewContextStub::kMaximumSlots) { | 201 Safepoint::DeoptMode deopt_mode = Safepoint::kNoLazyDeopt; |
197 FastNewContextStub stub(isolate(), heap_slots); | 202 if (info()->scope()->is_script_scope()) { |
| 203 __ Push(rdi); |
| 204 __ Push(info()->scope()->GetScopeInfo(info()->isolate())); |
| 205 __ CallRuntime(Runtime::kNewScriptContext, 2); |
| 206 deopt_mode = Safepoint::kLazyDeopt; |
| 207 } else if (slots <= FastNewContextStub::kMaximumSlots) { |
| 208 FastNewContextStub stub(isolate(), slots); |
198 __ CallStub(&stub); | 209 __ CallStub(&stub); |
199 // Result of FastNewContextStub is always in new space. | 210 // Result of FastNewContextStub is always in new space. |
200 need_write_barrier = false; | 211 need_write_barrier = false; |
201 } else { | 212 } else { |
202 __ Push(rdi); | 213 __ Push(rdi); |
203 __ CallRuntime(Runtime::kNewFunctionContext, 1); | 214 __ CallRuntime(Runtime::kNewFunctionContext, 1); |
204 } | 215 } |
205 RecordSafepoint(Safepoint::kNoLazyDeopt); | 216 RecordSafepoint(deopt_mode); |
| 217 |
206 // Context is returned in rax. It replaces the context passed to us. | 218 // Context is returned in rax. It replaces the context passed to us. |
207 // It's saved in the stack and kept live in rsi. | 219 // It's saved in the stack and kept live in rsi. |
208 __ movp(rsi, rax); | 220 __ movp(rsi, rax); |
209 __ movp(Operand(rbp, StandardFrameConstants::kContextOffset), rax); | 221 __ movp(Operand(rbp, StandardFrameConstants::kContextOffset), rax); |
210 | 222 |
211 // Copy any necessary parameters into the context. | 223 // Copy any necessary parameters into the context. |
212 int num_parameters = scope()->num_parameters(); | 224 int num_parameters = scope()->num_parameters(); |
213 int first_parameter = scope()->has_this_declaration() ? -1 : 0; | 225 int first_parameter = scope()->has_this_declaration() ? -1 : 0; |
214 for (int i = first_parameter; i < num_parameters; i++) { | 226 for (int i = first_parameter; i < num_parameters; i++) { |
215 Variable* var = (i == -1) ? scope()->receiver() : scope()->parameter(i); | 227 Variable* var = (i == -1) ? scope()->receiver() : scope()->parameter(i); |
(...skipping 12 matching lines...) Expand all Loading... |
228 Label done; | 240 Label done; |
229 __ JumpIfInNewSpace(rsi, rax, &done, Label::kNear); | 241 __ JumpIfInNewSpace(rsi, rax, &done, Label::kNear); |
230 __ Abort(kExpectedNewSpaceObject); | 242 __ Abort(kExpectedNewSpaceObject); |
231 __ bind(&done); | 243 __ bind(&done); |
232 } | 244 } |
233 } | 245 } |
234 } | 246 } |
235 Comment(";;; End allocate local context"); | 247 Comment(";;; End allocate local context"); |
236 } | 248 } |
237 | 249 |
238 // Trace the call. | 250 Comment(";;; Prologue end"); |
239 if (FLAG_trace && info()->IsOptimizing()) { | |
240 __ CallRuntime(Runtime::kTraceEnter, 0); | |
241 } | |
242 return !is_aborted(); | |
243 } | 251 } |
244 | 252 |
245 | 253 |
246 void LCodeGen::GenerateOsrPrologue() { | 254 void LCodeGen::GenerateOsrPrologue() { |
247 // Generate the OSR entry prologue at the first unknown OSR value, or if there | 255 // Generate the OSR entry prologue at the first unknown OSR value, or if there |
248 // are none, at the OSR entrypoint instruction. | 256 // are none, at the OSR entrypoint instruction. |
249 if (osr_pc_offset_ >= 0) return; | 257 if (osr_pc_offset_ >= 0) return; |
250 | 258 |
251 osr_pc_offset_ = masm()->pc_offset(); | 259 osr_pc_offset_ = masm()->pc_offset(); |
252 | 260 |
(...skipping 5684 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5937 RecordSafepoint(Safepoint::kNoLazyDeopt); | 5945 RecordSafepoint(Safepoint::kNoLazyDeopt); |
5938 } | 5946 } |
5939 | 5947 |
5940 | 5948 |
5941 #undef __ | 5949 #undef __ |
5942 | 5950 |
5943 } // namespace internal | 5951 } // namespace internal |
5944 } // namespace v8 | 5952 } // namespace v8 |
5945 | 5953 |
5946 #endif // V8_TARGET_ARCH_X64 | 5954 #endif // V8_TARGET_ARCH_X64 |
OLD | NEW |