OLD | NEW |
1 // Copyright 2013 the V8 project authors. All rights reserved. | 1 // Copyright 2013 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 3391 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3402 // We need to adapt arguments. | 3402 // We need to adapt arguments. |
3403 SafepointGenerator generator( | 3403 SafepointGenerator generator( |
3404 this, pointers, Safepoint::kLazyDeopt); | 3404 this, pointers, Safepoint::kLazyDeopt); |
3405 ParameterCount count(arity); | 3405 ParameterCount count(arity); |
3406 ParameterCount expected(formal_parameter_count); | 3406 ParameterCount expected(formal_parameter_count); |
3407 __ InvokeFunction(function, expected, count, CALL_FUNCTION, generator); | 3407 __ InvokeFunction(function, expected, count, CALL_FUNCTION, generator); |
3408 } | 3408 } |
3409 } | 3409 } |
3410 | 3410 |
3411 | 3411 |
3412 void LCodeGen::DoCallConstantFunction(LCallConstantFunction* instr) { | 3412 void LCodeGen::DoCallWithDescriptor(LCallWithDescriptor* instr) { |
3413 ASSERT(ToRegister(instr->result()).is(rax)); | 3413 ASSERT(ToRegister(instr->result()).is(rax)); |
3414 CallKnownFunction(instr->hydrogen()->function(), | 3414 |
3415 instr->hydrogen()->formal_parameter_count(), | 3415 LPointerMap* pointers = instr->pointer_map(); |
3416 instr->arity(), | 3416 SafepointGenerator generator(this, pointers, Safepoint::kLazyDeopt); |
3417 instr, | 3417 |
3418 RDI_UNINITIALIZED); | 3418 if (instr->target()->IsConstantOperand()) { |
| 3419 LConstantOperand* target = LConstantOperand::cast(instr->target()); |
| 3420 Handle<Code> code = Handle<Code>::cast(ToHandle(target)); |
| 3421 generator.BeforeCall(__ CallSize(code)); |
| 3422 __ call(code, RelocInfo::CODE_TARGET); |
| 3423 } else { |
| 3424 ASSERT(instr->target()->IsRegister()); |
| 3425 Register target = ToRegister(instr->target()); |
| 3426 generator.BeforeCall(__ CallSize(target)); |
| 3427 __ addq(target, Immediate(Code::kHeaderSize - kHeapObjectTag)); |
| 3428 __ call(target); |
| 3429 } |
| 3430 generator.AfterCall(); |
3419 } | 3431 } |
3420 | 3432 |
3421 | 3433 |
| 3434 void LCodeGen::DoCallJSFunction(LCallJSFunction* instr) { |
| 3435 ASSERT(ToRegister(instr->function()).is(rdi)); |
| 3436 ASSERT(ToRegister(instr->result()).is(rax)); |
| 3437 |
| 3438 if (instr->hydrogen()->pass_argument_count()) { |
| 3439 __ Set(rax, instr->arity()); |
| 3440 } |
| 3441 |
| 3442 // Change context. |
| 3443 __ movq(rsi, FieldOperand(rdi, JSFunction::kContextOffset)); |
| 3444 |
| 3445 LPointerMap* pointers = instr->pointer_map(); |
| 3446 SafepointGenerator generator(this, pointers, Safepoint::kLazyDeopt); |
| 3447 |
| 3448 bool is_self_call = false; |
| 3449 if (instr->hydrogen()->function()->IsConstant()) { |
| 3450 Handle<JSFunction> jsfun = Handle<JSFunction>::null(); |
| 3451 HConstant* fun_const = HConstant::cast(instr->hydrogen()->function()); |
| 3452 jsfun = Handle<JSFunction>::cast(fun_const->handle(isolate())); |
| 3453 is_self_call = jsfun.is_identical_to(info()->closure()); |
| 3454 } |
| 3455 |
| 3456 if (is_self_call) { |
| 3457 __ CallSelf(); |
| 3458 } else { |
| 3459 Operand target = FieldOperand(rdi, JSFunction::kCodeEntryOffset); |
| 3460 generator.BeforeCall(__ CallSize(target)); |
| 3461 __ call(target); |
| 3462 } |
| 3463 generator.AfterCall(); |
| 3464 } |
| 3465 |
| 3466 |
3422 void LCodeGen::DoDeferredMathAbsTaggedHeapNumber(LMathAbs* instr) { | 3467 void LCodeGen::DoDeferredMathAbsTaggedHeapNumber(LMathAbs* instr) { |
3423 Register input_reg = ToRegister(instr->value()); | 3468 Register input_reg = ToRegister(instr->value()); |
3424 __ CompareRoot(FieldOperand(input_reg, HeapObject::kMapOffset), | 3469 __ CompareRoot(FieldOperand(input_reg, HeapObject::kMapOffset), |
3425 Heap::kHeapNumberMapRootIndex); | 3470 Heap::kHeapNumberMapRootIndex); |
3426 DeoptimizeIf(not_equal, instr->environment()); | 3471 DeoptimizeIf(not_equal, instr->environment()); |
3427 | 3472 |
3428 Label slow, allocated, done; | 3473 Label slow, allocated, done; |
3429 Register tmp = input_reg.is(rax) ? rcx : rax; | 3474 Register tmp = input_reg.is(rax) ? rcx : rax; |
3430 Register tmp2 = tmp.is(rcx) ? rdx : input_reg.is(rcx) ? rdx : rcx; | 3475 Register tmp2 = tmp.is(rcx) ? rdx : input_reg.is(rcx) ? rdx : rcx; |
3431 | 3476 |
(...skipping 345 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3777 } else { | 3822 } else { |
3778 CallKnownFunction(known_function, | 3823 CallKnownFunction(known_function, |
3779 instr->hydrogen()->formal_parameter_count(), | 3824 instr->hydrogen()->formal_parameter_count(), |
3780 instr->arity(), | 3825 instr->arity(), |
3781 instr, | 3826 instr, |
3782 RDI_CONTAINS_TARGET); | 3827 RDI_CONTAINS_TARGET); |
3783 } | 3828 } |
3784 } | 3829 } |
3785 | 3830 |
3786 | 3831 |
3787 void LCodeGen::DoCallKeyed(LCallKeyed* instr) { | |
3788 ASSERT(ToRegister(instr->context()).is(rsi)); | |
3789 ASSERT(ToRegister(instr->key()).is(rcx)); | |
3790 ASSERT(ToRegister(instr->result()).is(rax)); | |
3791 | |
3792 int arity = instr->arity(); | |
3793 Handle<Code> ic = | |
3794 isolate()->stub_cache()->ComputeKeyedCallInitialize(arity); | |
3795 CallCode(ic, RelocInfo::CODE_TARGET, instr); | |
3796 } | |
3797 | |
3798 | |
3799 void LCodeGen::DoCallNamed(LCallNamed* instr) { | |
3800 ASSERT(ToRegister(instr->context()).is(rsi)); | |
3801 ASSERT(ToRegister(instr->result()).is(rax)); | |
3802 | |
3803 int arity = instr->arity(); | |
3804 Handle<Code> ic = isolate()->stub_cache()->ComputeCallInitialize(arity); | |
3805 __ Move(rcx, instr->name()); | |
3806 CallCode(ic, RelocInfo::CODE_TARGET, instr); | |
3807 } | |
3808 | |
3809 | |
3810 void LCodeGen::DoCallFunction(LCallFunction* instr) { | 3832 void LCodeGen::DoCallFunction(LCallFunction* instr) { |
3811 ASSERT(ToRegister(instr->context()).is(rsi)); | 3833 ASSERT(ToRegister(instr->context()).is(rsi)); |
3812 ASSERT(ToRegister(instr->function()).is(rdi)); | 3834 ASSERT(ToRegister(instr->function()).is(rdi)); |
3813 ASSERT(ToRegister(instr->result()).is(rax)); | 3835 ASSERT(ToRegister(instr->result()).is(rax)); |
3814 | 3836 |
3815 int arity = instr->arity(); | 3837 int arity = instr->arity(); |
3816 CallFunctionStub stub(arity, NO_CALL_FUNCTION_FLAGS); | 3838 CallFunctionStub stub(arity, NO_CALL_FUNCTION_FLAGS); |
3817 if (instr->hydrogen()->IsTailCall()) { | 3839 if (instr->hydrogen()->IsTailCall()) { |
3818 if (NeedsEagerFrame()) __ leave(); | 3840 if (NeedsEagerFrame()) __ leave(); |
3819 __ jmp(stub.GetCode(isolate()), RelocInfo::CODE_TARGET); | 3841 __ jmp(stub.GetCode(isolate()), RelocInfo::CODE_TARGET); |
3820 } else { | 3842 } else { |
3821 CallCode(stub.GetCode(isolate()), RelocInfo::CODE_TARGET, instr); | 3843 CallCode(stub.GetCode(isolate()), RelocInfo::CODE_TARGET, instr); |
3822 } | 3844 } |
3823 } | 3845 } |
3824 | 3846 |
3825 | 3847 |
3826 void LCodeGen::DoCallKnownGlobal(LCallKnownGlobal* instr) { | |
3827 ASSERT(ToRegister(instr->result()).is(rax)); | |
3828 CallKnownFunction(instr->hydrogen()->target(), | |
3829 instr->hydrogen()->formal_parameter_count(), | |
3830 instr->arity(), | |
3831 instr, | |
3832 RDI_UNINITIALIZED); | |
3833 } | |
3834 | |
3835 | |
3836 void LCodeGen::DoCallNew(LCallNew* instr) { | 3848 void LCodeGen::DoCallNew(LCallNew* instr) { |
3837 ASSERT(ToRegister(instr->context()).is(rsi)); | 3849 ASSERT(ToRegister(instr->context()).is(rsi)); |
3838 ASSERT(ToRegister(instr->constructor()).is(rdi)); | 3850 ASSERT(ToRegister(instr->constructor()).is(rdi)); |
3839 ASSERT(ToRegister(instr->result()).is(rax)); | 3851 ASSERT(ToRegister(instr->result()).is(rax)); |
3840 | 3852 |
3841 __ Set(rax, instr->arity()); | 3853 __ Set(rax, instr->arity()); |
3842 // No cell in ebx for construct type feedback in optimized code | 3854 // No cell in ebx for construct type feedback in optimized code |
3843 Handle<Object> undefined_value(isolate()->factory()->undefined_value()); | 3855 Handle<Object> undefined_value(isolate()->factory()->undefined_value()); |
3844 __ Move(rbx, undefined_value); | 3856 __ Move(rbx, undefined_value); |
3845 CallConstructStub stub(NO_CALL_FUNCTION_FLAGS); | 3857 CallConstructStub stub(NO_CALL_FUNCTION_FLAGS); |
(...skipping 1768 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5614 FixedArray::kHeaderSize - kPointerSize)); | 5626 FixedArray::kHeaderSize - kPointerSize)); |
5615 __ bind(&done); | 5627 __ bind(&done); |
5616 } | 5628 } |
5617 | 5629 |
5618 | 5630 |
5619 #undef __ | 5631 #undef __ |
5620 | 5632 |
5621 } } // namespace v8::internal | 5633 } } // namespace v8::internal |
5622 | 5634 |
5623 #endif // V8_TARGET_ARCH_X64 | 5635 #endif // V8_TARGET_ARCH_X64 |
OLD | NEW |