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 #include "src/v8.h" | 5 #include "src/v8.h" |
6 | 6 |
7 #if V8_TARGET_ARCH_X87 | 7 #if V8_TARGET_ARCH_X87 |
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 3675 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3686 void LCodeGen::DoDeclareGlobals(LDeclareGlobals* instr) { | 3686 void LCodeGen::DoDeclareGlobals(LDeclareGlobals* instr) { |
3687 DCHECK(ToRegister(instr->context()).is(esi)); | 3687 DCHECK(ToRegister(instr->context()).is(esi)); |
3688 __ push(esi); // The context is the first argument. | 3688 __ push(esi); // The context is the first argument. |
3689 __ push(Immediate(instr->hydrogen()->pairs())); | 3689 __ push(Immediate(instr->hydrogen()->pairs())); |
3690 __ push(Immediate(Smi::FromInt(instr->hydrogen()->flags()))); | 3690 __ push(Immediate(Smi::FromInt(instr->hydrogen()->flags()))); |
3691 CallRuntime(Runtime::kDeclareGlobals, 3, instr); | 3691 CallRuntime(Runtime::kDeclareGlobals, 3, instr); |
3692 } | 3692 } |
3693 | 3693 |
3694 | 3694 |
3695 void LCodeGen::CallKnownFunction(Handle<JSFunction> function, | 3695 void LCodeGen::CallKnownFunction(Handle<JSFunction> function, |
3696 int formal_parameter_count, | 3696 int formal_parameter_count, int arity, |
3697 int arity, | 3697 LInstruction* instr) { |
3698 LInstruction* instr, | |
3699 EDIState edi_state) { | |
3700 bool dont_adapt_arguments = | 3698 bool dont_adapt_arguments = |
3701 formal_parameter_count == SharedFunctionInfo::kDontAdaptArgumentsSentinel; | 3699 formal_parameter_count == SharedFunctionInfo::kDontAdaptArgumentsSentinel; |
3702 bool can_invoke_directly = | 3700 bool can_invoke_directly = |
3703 dont_adapt_arguments || formal_parameter_count == arity; | 3701 dont_adapt_arguments || formal_parameter_count == arity; |
3704 | 3702 |
| 3703 Register function_reg = edi; |
| 3704 |
3705 if (can_invoke_directly) { | 3705 if (can_invoke_directly) { |
3706 if (edi_state == EDI_UNINITIALIZED) { | |
3707 __ LoadHeapObject(edi, function); | |
3708 } | |
3709 | |
3710 // Change context. | 3706 // Change context. |
3711 __ mov(esi, FieldOperand(edi, JSFunction::kContextOffset)); | 3707 __ mov(esi, FieldOperand(function_reg, JSFunction::kContextOffset)); |
3712 | 3708 |
3713 // Set eax to arguments count if adaption is not needed. Assumes that eax | 3709 // Set eax to arguments count if adaption is not needed. Assumes that eax |
3714 // is available to write to at this point. | 3710 // is available to write to at this point. |
3715 if (dont_adapt_arguments) { | 3711 if (dont_adapt_arguments) { |
3716 __ mov(eax, arity); | 3712 __ mov(eax, arity); |
3717 } | 3713 } |
3718 | 3714 |
3719 // Invoke function directly. | 3715 // Invoke function directly. |
3720 if (function.is_identical_to(info()->closure())) { | 3716 if (function.is_identical_to(info()->closure())) { |
3721 __ CallSelf(); | 3717 __ CallSelf(); |
3722 } else { | 3718 } else { |
3723 __ call(FieldOperand(edi, JSFunction::kCodeEntryOffset)); | 3719 __ call(FieldOperand(function_reg, JSFunction::kCodeEntryOffset)); |
3724 } | 3720 } |
3725 RecordSafepointWithLazyDeopt(instr, RECORD_SIMPLE_SAFEPOINT); | 3721 RecordSafepointWithLazyDeopt(instr, RECORD_SIMPLE_SAFEPOINT); |
3726 } else { | 3722 } else { |
3727 // We need to adapt arguments. | 3723 // We need to adapt arguments. |
3728 LPointerMap* pointers = instr->pointer_map(); | 3724 LPointerMap* pointers = instr->pointer_map(); |
3729 SafepointGenerator generator( | 3725 SafepointGenerator generator( |
3730 this, pointers, Safepoint::kLazyDeopt); | 3726 this, pointers, Safepoint::kLazyDeopt); |
3731 ParameterCount count(arity); | 3727 ParameterCount count(arity); |
3732 ParameterCount expected(formal_parameter_count); | 3728 ParameterCount expected(formal_parameter_count); |
3733 __ InvokeFunction(function, expected, count, CALL_FUNCTION, generator); | 3729 __ InvokeFunction(function_reg, expected, count, CALL_FUNCTION, generator); |
3734 } | 3730 } |
3735 } | 3731 } |
3736 | 3732 |
3737 | 3733 |
3738 void LCodeGen::DoTailCallThroughMegamorphicCache( | 3734 void LCodeGen::DoTailCallThroughMegamorphicCache( |
3739 LTailCallThroughMegamorphicCache* instr) { | 3735 LTailCallThroughMegamorphicCache* instr) { |
3740 Register receiver = ToRegister(instr->receiver()); | 3736 Register receiver = ToRegister(instr->receiver()); |
3741 Register name = ToRegister(instr->name()); | 3737 Register name = ToRegister(instr->name()); |
3742 DCHECK(receiver.is(LoadDescriptor::ReceiverRegister())); | 3738 DCHECK(receiver.is(LoadDescriptor::ReceiverRegister())); |
3743 DCHECK(name.is(LoadDescriptor::NameRegister())); | 3739 DCHECK(name.is(LoadDescriptor::NameRegister())); |
(...skipping 604 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4348 Handle<JSFunction> known_function = instr->hydrogen()->known_function(); | 4344 Handle<JSFunction> known_function = instr->hydrogen()->known_function(); |
4349 if (known_function.is_null()) { | 4345 if (known_function.is_null()) { |
4350 LPointerMap* pointers = instr->pointer_map(); | 4346 LPointerMap* pointers = instr->pointer_map(); |
4351 SafepointGenerator generator( | 4347 SafepointGenerator generator( |
4352 this, pointers, Safepoint::kLazyDeopt); | 4348 this, pointers, Safepoint::kLazyDeopt); |
4353 ParameterCount count(instr->arity()); | 4349 ParameterCount count(instr->arity()); |
4354 __ InvokeFunction(edi, count, CALL_FUNCTION, generator); | 4350 __ InvokeFunction(edi, count, CALL_FUNCTION, generator); |
4355 } else { | 4351 } else { |
4356 CallKnownFunction(known_function, | 4352 CallKnownFunction(known_function, |
4357 instr->hydrogen()->formal_parameter_count(), | 4353 instr->hydrogen()->formal_parameter_count(), |
4358 instr->arity(), | 4354 instr->arity(), instr); |
4359 instr, | |
4360 EDI_CONTAINS_TARGET); | |
4361 } | 4355 } |
4362 } | 4356 } |
4363 | 4357 |
4364 | 4358 |
4365 void LCodeGen::DoCallFunction(LCallFunction* instr) { | 4359 void LCodeGen::DoCallFunction(LCallFunction* instr) { |
4366 DCHECK(ToRegister(instr->context()).is(esi)); | 4360 DCHECK(ToRegister(instr->context()).is(esi)); |
4367 DCHECK(ToRegister(instr->function()).is(edi)); | 4361 DCHECK(ToRegister(instr->function()).is(edi)); |
4368 DCHECK(ToRegister(instr->result()).is(eax)); | 4362 DCHECK(ToRegister(instr->result()).is(eax)); |
4369 | 4363 |
4370 int arity = instr->arity(); | 4364 int arity = instr->arity(); |
(...skipping 1965 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6336 CallRuntime(Runtime::kPushBlockContext, 2, instr); | 6330 CallRuntime(Runtime::kPushBlockContext, 2, instr); |
6337 RecordSafepoint(Safepoint::kNoLazyDeopt); | 6331 RecordSafepoint(Safepoint::kNoLazyDeopt); |
6338 } | 6332 } |
6339 | 6333 |
6340 | 6334 |
6341 #undef __ | 6335 #undef __ |
6342 | 6336 |
6343 } } // namespace v8::internal | 6337 } } // namespace v8::internal |
6344 | 6338 |
6345 #endif // V8_TARGET_ARCH_X87 | 6339 #endif // V8_TARGET_ARCH_X87 |
OLD | NEW |