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/crankshaft/ia32/lithium-codegen-ia32.h" | 7 #include "src/crankshaft/ia32/lithium-codegen-ia32.h" |
8 | 8 |
9 #include "src/base/bits.h" | 9 #include "src/base/bits.h" |
10 #include "src/code-factory.h" | 10 #include "src/code-factory.h" |
(...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
238 // Possibly allocate a local context. | 238 // Possibly allocate a local context. |
239 if (info_->num_heap_slots() > 0) { | 239 if (info_->num_heap_slots() > 0) { |
240 Comment(";;; Allocate local context"); | 240 Comment(";;; Allocate local context"); |
241 bool need_write_barrier = true; | 241 bool need_write_barrier = true; |
242 // Argument to NewContext is the function, which is still in edi. | 242 // Argument to NewContext is the function, which is still in edi. |
243 int slots = info_->num_heap_slots() - Context::MIN_CONTEXT_SLOTS; | 243 int slots = info_->num_heap_slots() - Context::MIN_CONTEXT_SLOTS; |
244 Safepoint::DeoptMode deopt_mode = Safepoint::kNoLazyDeopt; | 244 Safepoint::DeoptMode deopt_mode = Safepoint::kNoLazyDeopt; |
245 if (info()->scope()->is_script_scope()) { | 245 if (info()->scope()->is_script_scope()) { |
246 __ push(edi); | 246 __ push(edi); |
247 __ Push(info()->scope()->GetScopeInfo(info()->isolate())); | 247 __ Push(info()->scope()->GetScopeInfo(info()->isolate())); |
248 __ CallRuntime(Runtime::kNewScriptContext, 2); | 248 __ CallRuntime(Runtime::kNewScriptContext); |
249 deopt_mode = Safepoint::kLazyDeopt; | 249 deopt_mode = Safepoint::kLazyDeopt; |
250 } else if (slots <= FastNewContextStub::kMaximumSlots) { | 250 } else if (slots <= FastNewContextStub::kMaximumSlots) { |
251 FastNewContextStub stub(isolate(), slots); | 251 FastNewContextStub stub(isolate(), slots); |
252 __ CallStub(&stub); | 252 __ CallStub(&stub); |
253 // Result of FastNewContextStub is always in new space. | 253 // Result of FastNewContextStub is always in new space. |
254 need_write_barrier = false; | 254 need_write_barrier = false; |
255 } else { | 255 } else { |
256 __ push(edi); | 256 __ push(edi); |
257 __ CallRuntime(Runtime::kNewFunctionContext, 1); | 257 __ CallRuntime(Runtime::kNewFunctionContext); |
258 } | 258 } |
259 RecordSafepoint(deopt_mode); | 259 RecordSafepoint(deopt_mode); |
260 | 260 |
261 // Context is returned in eax. It replaces the context passed to us. | 261 // Context is returned in eax. It replaces the context passed to us. |
262 // It's saved in the stack and kept live in esi. | 262 // It's saved in the stack and kept live in esi. |
263 __ mov(esi, eax); | 263 __ mov(esi, eax); |
264 __ mov(Operand(ebp, StandardFrameConstants::kContextOffset), eax); | 264 __ mov(Operand(ebp, StandardFrameConstants::kContextOffset), eax); |
265 | 265 |
266 // Copy parameters into context if necessary. | 266 // Copy parameters into context if necessary. |
267 int num_parameters = scope()->num_parameters(); | 267 int num_parameters = scope()->num_parameters(); |
(...skipping 2335 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2603 | 2603 |
2604 | 2604 |
2605 void LCodeGen::DoReturn(LReturn* instr) { | 2605 void LCodeGen::DoReturn(LReturn* instr) { |
2606 if (FLAG_trace && info()->IsOptimizing()) { | 2606 if (FLAG_trace && info()->IsOptimizing()) { |
2607 // Preserve the return value on the stack and rely on the runtime call | 2607 // Preserve the return value on the stack and rely on the runtime call |
2608 // to return the value in the same register. We're leaving the code | 2608 // to return the value in the same register. We're leaving the code |
2609 // managed by the register allocator and tearing down the frame, it's | 2609 // managed by the register allocator and tearing down the frame, it's |
2610 // safe to write to the context register. | 2610 // safe to write to the context register. |
2611 __ push(eax); | 2611 __ push(eax); |
2612 __ mov(esi, Operand(ebp, StandardFrameConstants::kContextOffset)); | 2612 __ mov(esi, Operand(ebp, StandardFrameConstants::kContextOffset)); |
2613 __ CallRuntime(Runtime::kTraceExit, 1); | 2613 __ CallRuntime(Runtime::kTraceExit); |
2614 } | 2614 } |
2615 if (info()->saves_caller_doubles()) RestoreCallerDoubles(); | 2615 if (info()->saves_caller_doubles()) RestoreCallerDoubles(); |
2616 if (dynamic_frame_alignment_) { | 2616 if (dynamic_frame_alignment_) { |
2617 // Fetch the state of the dynamic frame alignment. | 2617 // Fetch the state of the dynamic frame alignment. |
2618 __ mov(edx, Operand(ebp, | 2618 __ mov(edx, Operand(ebp, |
2619 JavaScriptFrameConstants::kDynamicAlignmentStateOffset)); | 2619 JavaScriptFrameConstants::kDynamicAlignmentStateOffset)); |
2620 } | 2620 } |
2621 if (NeedsEagerFrame()) { | 2621 if (NeedsEagerFrame()) { |
2622 __ mov(esp, ebp); | 2622 __ mov(esp, ebp); |
2623 __ pop(ebp); | 2623 __ pop(ebp); |
(...skipping 578 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3202 // If there is no frame, the context must be in esi. | 3202 // If there is no frame, the context must be in esi. |
3203 DCHECK(result.is(esi)); | 3203 DCHECK(result.is(esi)); |
3204 } | 3204 } |
3205 } | 3205 } |
3206 | 3206 |
3207 | 3207 |
3208 void LCodeGen::DoDeclareGlobals(LDeclareGlobals* instr) { | 3208 void LCodeGen::DoDeclareGlobals(LDeclareGlobals* instr) { |
3209 DCHECK(ToRegister(instr->context()).is(esi)); | 3209 DCHECK(ToRegister(instr->context()).is(esi)); |
3210 __ push(Immediate(instr->hydrogen()->pairs())); | 3210 __ push(Immediate(instr->hydrogen()->pairs())); |
3211 __ push(Immediate(Smi::FromInt(instr->hydrogen()->flags()))); | 3211 __ push(Immediate(Smi::FromInt(instr->hydrogen()->flags()))); |
3212 CallRuntime(Runtime::kDeclareGlobals, 2, instr); | 3212 CallRuntime(Runtime::kDeclareGlobals, instr); |
3213 } | 3213 } |
3214 | 3214 |
3215 | 3215 |
3216 void LCodeGen::CallKnownFunction(Handle<JSFunction> function, | 3216 void LCodeGen::CallKnownFunction(Handle<JSFunction> function, |
3217 int formal_parameter_count, int arity, | 3217 int formal_parameter_count, int arity, |
3218 LInstruction* instr) { | 3218 LInstruction* instr) { |
3219 bool dont_adapt_arguments = | 3219 bool dont_adapt_arguments = |
3220 formal_parameter_count == SharedFunctionInfo::kDontAdaptArgumentsSentinel; | 3220 formal_parameter_count == SharedFunctionInfo::kDontAdaptArgumentsSentinel; |
3221 bool can_invoke_directly = | 3221 bool can_invoke_directly = |
3222 dont_adapt_arguments || formal_parameter_count == arity; | 3222 dont_adapt_arguments || formal_parameter_count == arity; |
(...skipping 2145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5368 | 5368 |
5369 Label use_cache, call_runtime; | 5369 Label use_cache, call_runtime; |
5370 __ CheckEnumCache(&call_runtime); | 5370 __ CheckEnumCache(&call_runtime); |
5371 | 5371 |
5372 __ mov(eax, FieldOperand(eax, HeapObject::kMapOffset)); | 5372 __ mov(eax, FieldOperand(eax, HeapObject::kMapOffset)); |
5373 __ jmp(&use_cache, Label::kNear); | 5373 __ jmp(&use_cache, Label::kNear); |
5374 | 5374 |
5375 // Get the set of properties to enumerate. | 5375 // Get the set of properties to enumerate. |
5376 __ bind(&call_runtime); | 5376 __ bind(&call_runtime); |
5377 __ push(eax); | 5377 __ push(eax); |
5378 CallRuntime(Runtime::kGetPropertyNamesFast, 1, instr); | 5378 CallRuntime(Runtime::kGetPropertyNamesFast, instr); |
5379 | 5379 |
5380 __ cmp(FieldOperand(eax, HeapObject::kMapOffset), | 5380 __ cmp(FieldOperand(eax, HeapObject::kMapOffset), |
5381 isolate()->factory()->meta_map()); | 5381 isolate()->factory()->meta_map()); |
5382 DeoptimizeIf(not_equal, instr, Deoptimizer::kWrongMap); | 5382 DeoptimizeIf(not_equal, instr, Deoptimizer::kWrongMap); |
5383 __ bind(&use_cache); | 5383 __ bind(&use_cache); |
5384 } | 5384 } |
5385 | 5385 |
5386 | 5386 |
5387 void LCodeGen::DoForInCacheArray(LForInCacheArray* instr) { | 5387 void LCodeGen::DoForInCacheArray(LForInCacheArray* instr) { |
5388 Register map = ToRegister(instr->map()); | 5388 Register map = ToRegister(instr->map()); |
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5488 void LCodeGen::DoStoreFrameContext(LStoreFrameContext* instr) { | 5488 void LCodeGen::DoStoreFrameContext(LStoreFrameContext* instr) { |
5489 Register context = ToRegister(instr->context()); | 5489 Register context = ToRegister(instr->context()); |
5490 __ mov(Operand(ebp, StandardFrameConstants::kContextOffset), context); | 5490 __ mov(Operand(ebp, StandardFrameConstants::kContextOffset), context); |
5491 } | 5491 } |
5492 | 5492 |
5493 | 5493 |
5494 void LCodeGen::DoAllocateBlockContext(LAllocateBlockContext* instr) { | 5494 void LCodeGen::DoAllocateBlockContext(LAllocateBlockContext* instr) { |
5495 Handle<ScopeInfo> scope_info = instr->scope_info(); | 5495 Handle<ScopeInfo> scope_info = instr->scope_info(); |
5496 __ Push(scope_info); | 5496 __ Push(scope_info); |
5497 __ push(ToRegister(instr->function())); | 5497 __ push(ToRegister(instr->function())); |
5498 CallRuntime(Runtime::kPushBlockContext, 2, instr); | 5498 CallRuntime(Runtime::kPushBlockContext, instr); |
5499 RecordSafepoint(Safepoint::kNoLazyDeopt); | 5499 RecordSafepoint(Safepoint::kNoLazyDeopt); |
5500 } | 5500 } |
5501 | 5501 |
5502 | 5502 |
5503 #undef __ | 5503 #undef __ |
5504 | 5504 |
5505 } // namespace internal | 5505 } // namespace internal |
5506 } // namespace v8 | 5506 } // namespace v8 |
5507 | 5507 |
5508 #endif // V8_TARGET_ARCH_IA32 | 5508 #endif // V8_TARGET_ARCH_IA32 |
OLD | NEW |