| 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 3392 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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( | 3407 __ InvokeFunction( |
| 3408 function, expected, count, CALL_FUNCTION, generator, call_kind); | 3408 function, expected, count, CALL_FUNCTION, generator, call_kind); |
| 3409 } | 3409 } |
| 3410 } | 3410 } |
| 3411 | 3411 |
| 3412 | 3412 |
| 3413 void LCodeGen::DoCallConstantFunction(LCallConstantFunction* instr) { | 3413 void LCodeGen::DoCallWithDescriptor(LCallWithDescriptor* instr) { |
| 3414 ASSERT(ToRegister(instr->result()).is(rax)); | 3414 ASSERT(ToRegister(instr->result()).is(rax)); |
| 3415 CallKnownFunction(instr->hydrogen()->function(), | 3415 |
| 3416 instr->hydrogen()->formal_parameter_count(), | 3416 LPointerMap* pointers = instr->pointer_map(); |
| 3417 instr->arity(), | 3417 SafepointGenerator generator(this, pointers, Safepoint::kLazyDeopt); |
| 3418 instr, | 3418 |
| 3419 CALL_AS_METHOD, | 3419 if (instr->target()->IsConstantOperand()) { |
| 3420 RDI_UNINITIALIZED); | 3420 LConstantOperand* target = LConstantOperand::cast(instr->target()); |
| 3421 Handle<Code> code = Handle<Code>::cast(ToHandle(target)); |
| 3422 generator.BeforeCall(__ CallSize(code)); |
| 3423 __ call(code, RelocInfo::CODE_TARGET); |
| 3424 } else { |
| 3425 ASSERT(instr->target()->IsRegister()); |
| 3426 Register target = ToRegister(instr->target()); |
| 3427 generator.BeforeCall(__ CallSize(target)); |
| 3428 __ addq(target, Immediate(Code::kHeaderSize - kHeapObjectTag)); |
| 3429 __ call(target); |
| 3430 } |
| 3431 generator.AfterCall(); |
| 3421 } | 3432 } |
| 3422 | 3433 |
| 3423 | 3434 |
| 3435 void LCodeGen::DoCallJSFunction(LCallJSFunction* instr) { |
| 3436 ASSERT(ToRegister(instr->function()).is(rdi)); |
| 3437 ASSERT(ToRegister(instr->call_kind()).is(rcx)); |
| 3438 ASSERT(ToRegister(instr->result()).is(rax)); |
| 3439 |
| 3440 if (instr->hydrogen()->pass_argument_count()) { |
| 3441 __ Set(rax, instr->arity()); |
| 3442 } |
| 3443 |
| 3444 // Change context. |
| 3445 __ movq(rsi, FieldOperand(rdi, JSFunction::kContextOffset)); |
| 3446 |
| 3447 LPointerMap* pointers = instr->pointer_map(); |
| 3448 SafepointGenerator generator(this, pointers, Safepoint::kLazyDeopt); |
| 3449 |
| 3450 bool is_self_call = false; |
| 3451 if (instr->hydrogen()->function()->IsConstant()) { |
| 3452 Handle<JSFunction> jsfun = Handle<JSFunction>::null(); |
| 3453 HConstant* fun_const = HConstant::cast(instr->hydrogen()->function()); |
| 3454 jsfun = Handle<JSFunction>::cast(fun_const->handle(isolate())); |
| 3455 is_self_call = jsfun.is_identical_to(info()->closure()); |
| 3456 } |
| 3457 |
| 3458 if (is_self_call) { |
| 3459 __ CallSelf(); |
| 3460 } else { |
| 3461 Operand target = FieldOperand(rdi, JSFunction::kCodeEntryOffset); |
| 3462 generator.BeforeCall(__ CallSize(target)); |
| 3463 __ call(target); |
| 3464 } |
| 3465 generator.AfterCall(); |
| 3466 } |
| 3467 |
| 3468 |
| 3424 void LCodeGen::DoDeferredMathAbsTaggedHeapNumber(LMathAbs* instr) { | 3469 void LCodeGen::DoDeferredMathAbsTaggedHeapNumber(LMathAbs* instr) { |
| 3425 Register input_reg = ToRegister(instr->value()); | 3470 Register input_reg = ToRegister(instr->value()); |
| 3426 __ CompareRoot(FieldOperand(input_reg, HeapObject::kMapOffset), | 3471 __ CompareRoot(FieldOperand(input_reg, HeapObject::kMapOffset), |
| 3427 Heap::kHeapNumberMapRootIndex); | 3472 Heap::kHeapNumberMapRootIndex); |
| 3428 DeoptimizeIf(not_equal, instr->environment()); | 3473 DeoptimizeIf(not_equal, instr->environment()); |
| 3429 | 3474 |
| 3430 Label slow, allocated, done; | 3475 Label slow, allocated, done; |
| 3431 Register tmp = input_reg.is(rax) ? rcx : rax; | 3476 Register tmp = input_reg.is(rax) ? rcx : rax; |
| 3432 Register tmp2 = tmp.is(rcx) ? rdx : input_reg.is(rcx) ? rdx : rcx; | 3477 Register tmp2 = tmp.is(rcx) ? rdx : input_reg.is(rcx) ? rdx : rcx; |
| 3433 | 3478 |
| (...skipping 346 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3780 CallKnownFunction(known_function, | 3825 CallKnownFunction(known_function, |
| 3781 instr->hydrogen()->formal_parameter_count(), | 3826 instr->hydrogen()->formal_parameter_count(), |
| 3782 instr->arity(), | 3827 instr->arity(), |
| 3783 instr, | 3828 instr, |
| 3784 CALL_AS_METHOD, | 3829 CALL_AS_METHOD, |
| 3785 RDI_CONTAINS_TARGET); | 3830 RDI_CONTAINS_TARGET); |
| 3786 } | 3831 } |
| 3787 } | 3832 } |
| 3788 | 3833 |
| 3789 | 3834 |
| 3790 void LCodeGen::DoCallKeyed(LCallKeyed* instr) { | |
| 3791 ASSERT(ToRegister(instr->context()).is(rsi)); | |
| 3792 ASSERT(ToRegister(instr->key()).is(rcx)); | |
| 3793 ASSERT(ToRegister(instr->result()).is(rax)); | |
| 3794 | |
| 3795 int arity = instr->arity(); | |
| 3796 Handle<Code> ic = | |
| 3797 isolate()->stub_cache()->ComputeKeyedCallInitialize(arity); | |
| 3798 CallCode(ic, RelocInfo::CODE_TARGET, instr); | |
| 3799 } | |
| 3800 | |
| 3801 | |
| 3802 void LCodeGen::DoCallNamed(LCallNamed* instr) { | |
| 3803 ASSERT(ToRegister(instr->context()).is(rsi)); | |
| 3804 ASSERT(ToRegister(instr->result()).is(rax)); | |
| 3805 | |
| 3806 int arity = instr->arity(); | |
| 3807 RelocInfo::Mode mode = RelocInfo::CODE_TARGET; | |
| 3808 Handle<Code> ic = | |
| 3809 isolate()->stub_cache()->ComputeCallInitialize(arity, mode); | |
| 3810 __ Move(rcx, instr->name()); | |
| 3811 CallCode(ic, mode, instr); | |
| 3812 } | |
| 3813 | |
| 3814 | |
| 3815 void LCodeGen::DoCallFunction(LCallFunction* instr) { | 3835 void LCodeGen::DoCallFunction(LCallFunction* instr) { |
| 3816 ASSERT(ToRegister(instr->context()).is(rsi)); | 3836 ASSERT(ToRegister(instr->context()).is(rsi)); |
| 3817 ASSERT(ToRegister(instr->function()).is(rdi)); | 3837 ASSERT(ToRegister(instr->function()).is(rdi)); |
| 3818 ASSERT(ToRegister(instr->result()).is(rax)); | 3838 ASSERT(ToRegister(instr->result()).is(rax)); |
| 3819 | 3839 |
| 3820 int arity = instr->arity(); | 3840 int arity = instr->arity(); |
| 3821 CallFunctionStub stub(arity, NO_CALL_FUNCTION_FLAGS); | 3841 CallFunctionStub stub(arity, NO_CALL_FUNCTION_FLAGS); |
| 3822 if (instr->hydrogen()->IsTailCall()) { | 3842 if (instr->hydrogen()->IsTailCall()) { |
| 3823 if (NeedsEagerFrame()) __ leave(); | 3843 if (NeedsEagerFrame()) __ leave(); |
| 3824 __ jmp(stub.GetCode(isolate()), RelocInfo::CODE_TARGET); | 3844 __ jmp(stub.GetCode(isolate()), RelocInfo::CODE_TARGET); |
| 3825 } else { | 3845 } else { |
| 3826 CallCode(stub.GetCode(isolate()), RelocInfo::CODE_TARGET, instr); | 3846 CallCode(stub.GetCode(isolate()), RelocInfo::CODE_TARGET, instr); |
| 3827 } | 3847 } |
| 3828 } | 3848 } |
| 3829 | 3849 |
| 3830 | 3850 |
| 3831 void LCodeGen::DoCallGlobal(LCallGlobal* instr) { | 3851 void LCodeGen::DoCallGlobal(LCallGlobal* instr) { |
| 3832 ASSERT(ToRegister(instr->context()).is(rsi)); | 3852 ASSERT(ToRegister(instr->context()).is(rsi)); |
| 3833 ASSERT(ToRegister(instr->result()).is(rax)); | 3853 ASSERT(ToRegister(instr->result()).is(rax)); |
| 3834 int arity = instr->arity(); | 3854 int arity = instr->arity(); |
| 3835 RelocInfo::Mode mode = RelocInfo::CODE_TARGET_CONTEXT; | 3855 RelocInfo::Mode mode = RelocInfo::CODE_TARGET_CONTEXT; |
| 3836 Handle<Code> ic = | 3856 Handle<Code> ic = |
| 3837 isolate()->stub_cache()->ComputeCallInitialize(arity, mode); | 3857 isolate()->stub_cache()->ComputeCallInitialize(arity, mode); |
| 3838 __ Move(rcx, instr->name()); | 3858 __ Move(rcx, instr->name()); |
| 3839 CallCode(ic, mode, instr); | 3859 CallCode(ic, mode, instr); |
| 3840 } | 3860 } |
| 3841 | 3861 |
| 3842 | 3862 |
| 3843 void LCodeGen::DoCallKnownGlobal(LCallKnownGlobal* instr) { | |
| 3844 ASSERT(ToRegister(instr->result()).is(rax)); | |
| 3845 CallKnownFunction(instr->hydrogen()->target(), | |
| 3846 instr->hydrogen()->formal_parameter_count(), | |
| 3847 instr->arity(), | |
| 3848 instr, | |
| 3849 CALL_AS_FUNCTION, | |
| 3850 RDI_UNINITIALIZED); | |
| 3851 } | |
| 3852 | |
| 3853 | |
| 3854 void LCodeGen::DoCallNew(LCallNew* instr) { | 3863 void LCodeGen::DoCallNew(LCallNew* instr) { |
| 3855 ASSERT(ToRegister(instr->context()).is(rsi)); | 3864 ASSERT(ToRegister(instr->context()).is(rsi)); |
| 3856 ASSERT(ToRegister(instr->constructor()).is(rdi)); | 3865 ASSERT(ToRegister(instr->constructor()).is(rdi)); |
| 3857 ASSERT(ToRegister(instr->result()).is(rax)); | 3866 ASSERT(ToRegister(instr->result()).is(rax)); |
| 3858 | 3867 |
| 3859 __ Set(rax, instr->arity()); | 3868 __ Set(rax, instr->arity()); |
| 3860 // No cell in ebx for construct type feedback in optimized code | 3869 // No cell in ebx for construct type feedback in optimized code |
| 3861 Handle<Object> undefined_value(isolate()->factory()->undefined_value()); | 3870 Handle<Object> undefined_value(isolate()->factory()->undefined_value()); |
| 3862 __ Move(rbx, undefined_value); | 3871 __ Move(rbx, undefined_value); |
| 3863 CallConstructStub stub(NO_CALL_FUNCTION_FLAGS); | 3872 CallConstructStub stub(NO_CALL_FUNCTION_FLAGS); |
| (...skipping 1770 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5634 FixedArray::kHeaderSize - kPointerSize)); | 5643 FixedArray::kHeaderSize - kPointerSize)); |
| 5635 __ bind(&done); | 5644 __ bind(&done); |
| 5636 } | 5645 } |
| 5637 | 5646 |
| 5638 | 5647 |
| 5639 #undef __ | 5648 #undef __ |
| 5640 | 5649 |
| 5641 } } // namespace v8::internal | 5650 } } // namespace v8::internal |
| 5642 | 5651 |
| 5643 #endif // V8_TARGET_ARCH_X64 | 5652 #endif // V8_TARGET_ARCH_X64 |
| OLD | NEW |