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 #if V8_TARGET_ARCH_IA32 | 5 #if V8_TARGET_ARCH_IA32 |
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/codegen.h" | 10 #include "src/codegen.h" |
(...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
241 if (dynamic_frame_alignment_) { | 241 if (dynamic_frame_alignment_) { |
242 __ mov(Operand(ebp, offset), edx); | 242 __ mov(Operand(ebp, offset), edx); |
243 } else { | 243 } else { |
244 __ mov(Operand(ebp, offset), Immediate(kNoAlignmentPadding)); | 244 __ mov(Operand(ebp, offset), Immediate(kNoAlignmentPadding)); |
245 } | 245 } |
246 } | 246 } |
247 } | 247 } |
248 | 248 |
249 if (info()->saves_caller_doubles()) SaveCallerDoubles(); | 249 if (info()->saves_caller_doubles()) SaveCallerDoubles(); |
250 } | 250 } |
| 251 return !is_aborted(); |
| 252 } |
| 253 |
| 254 |
| 255 void LCodeGen::DoPrologue(LPrologue* instr) { |
| 256 Comment(";;; Prologue begin"); |
251 | 257 |
252 // Possibly allocate a local context. | 258 // Possibly allocate a local context. |
253 int heap_slots = info_->num_heap_slots() - Context::MIN_CONTEXT_SLOTS; | 259 if (info_->num_heap_slots() > 0) { |
254 if (heap_slots > 0) { | |
255 Comment(";;; Allocate local context"); | 260 Comment(";;; Allocate local context"); |
256 bool need_write_barrier = true; | 261 bool need_write_barrier = true; |
257 // Argument to NewContext is the function, which is still in edi. | 262 // Argument to NewContext is the function, which is still in edi. |
258 DCHECK(!info()->scope()->is_script_scope()); | 263 int slots = info_->num_heap_slots() - Context::MIN_CONTEXT_SLOTS; |
259 if (heap_slots <= FastNewContextStub::kMaximumSlots) { | 264 Safepoint::DeoptMode deopt_mode = Safepoint::kNoLazyDeopt; |
260 FastNewContextStub stub(isolate(), heap_slots); | 265 if (info()->scope()->is_script_scope()) { |
| 266 __ push(edi); |
| 267 __ Push(info()->scope()->GetScopeInfo(info()->isolate())); |
| 268 __ CallRuntime(Runtime::kNewScriptContext, 2); |
| 269 deopt_mode = Safepoint::kLazyDeopt; |
| 270 } else if (slots <= FastNewContextStub::kMaximumSlots) { |
| 271 FastNewContextStub stub(isolate(), slots); |
261 __ CallStub(&stub); | 272 __ CallStub(&stub); |
262 // Result of FastNewContextStub is always in new space. | 273 // Result of FastNewContextStub is always in new space. |
263 need_write_barrier = false; | 274 need_write_barrier = false; |
264 } else { | 275 } else { |
265 __ push(edi); | 276 __ push(edi); |
266 __ CallRuntime(Runtime::kNewFunctionContext, 1); | 277 __ CallRuntime(Runtime::kNewFunctionContext, 1); |
267 } | 278 } |
268 RecordSafepoint(Safepoint::kNoLazyDeopt); | 279 RecordSafepoint(deopt_mode); |
| 280 |
269 // Context is returned in eax. It replaces the context passed to us. | 281 // Context is returned in eax. It replaces the context passed to us. |
270 // It's saved in the stack and kept live in esi. | 282 // It's saved in the stack and kept live in esi. |
271 __ mov(esi, eax); | 283 __ mov(esi, eax); |
272 __ mov(Operand(ebp, StandardFrameConstants::kContextOffset), eax); | 284 __ mov(Operand(ebp, StandardFrameConstants::kContextOffset), eax); |
273 | 285 |
274 // Copy parameters into context if necessary. | 286 // Copy parameters into context if necessary. |
275 int num_parameters = scope()->num_parameters(); | 287 int num_parameters = scope()->num_parameters(); |
276 int first_parameter = scope()->has_this_declaration() ? -1 : 0; | 288 int first_parameter = scope()->has_this_declaration() ? -1 : 0; |
277 for (int i = first_parameter; i < num_parameters; i++) { | 289 for (int i = first_parameter; i < num_parameters; i++) { |
278 Variable* var = (i == -1) ? scope()->receiver() : scope()->parameter(i); | 290 Variable* var = (i == -1) ? scope()->receiver() : scope()->parameter(i); |
(...skipping 16 matching lines...) Expand all Loading... |
295 Label done; | 307 Label done; |
296 __ JumpIfInNewSpace(esi, eax, &done, Label::kNear); | 308 __ JumpIfInNewSpace(esi, eax, &done, Label::kNear); |
297 __ Abort(kExpectedNewSpaceObject); | 309 __ Abort(kExpectedNewSpaceObject); |
298 __ bind(&done); | 310 __ bind(&done); |
299 } | 311 } |
300 } | 312 } |
301 } | 313 } |
302 Comment(";;; End allocate local context"); | 314 Comment(";;; End allocate local context"); |
303 } | 315 } |
304 | 316 |
305 // Trace the call. | 317 Comment(";;; Prologue end"); |
306 if (FLAG_trace && info()->IsOptimizing()) { | |
307 // We have not executed any compiled code yet, so esi still holds the | |
308 // incoming context. | |
309 __ CallRuntime(Runtime::kTraceEnter, 0); | |
310 } | |
311 return !is_aborted(); | |
312 } | 318 } |
313 | 319 |
314 | 320 |
315 void LCodeGen::GenerateOsrPrologue() { | 321 void LCodeGen::GenerateOsrPrologue() { |
316 // Generate the OSR entry prologue at the first unknown OSR value, or if there | 322 // Generate the OSR entry prologue at the first unknown OSR value, or if there |
317 // are none, at the OSR entrypoint instruction. | 323 // are none, at the OSR entrypoint instruction. |
318 if (osr_pc_offset_ >= 0) return; | 324 if (osr_pc_offset_ >= 0) return; |
319 | 325 |
320 osr_pc_offset_ = masm()->pc_offset(); | 326 osr_pc_offset_ = masm()->pc_offset(); |
321 | 327 |
(...skipping 5426 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5748 RecordSafepoint(Safepoint::kNoLazyDeopt); | 5754 RecordSafepoint(Safepoint::kNoLazyDeopt); |
5749 } | 5755 } |
5750 | 5756 |
5751 | 5757 |
5752 #undef __ | 5758 #undef __ |
5753 | 5759 |
5754 } // namespace internal | 5760 } // namespace internal |
5755 } // namespace v8 | 5761 } // namespace v8 |
5756 | 5762 |
5757 #endif // V8_TARGET_ARCH_IA32 | 5763 #endif // V8_TARGET_ARCH_IA32 |
OLD | NEW |