Chromium Code Reviews

Side by Side Diff: src/x64/lithium-codegen-x64.cc

Issue 104663004: Preview of a first step towards unification of hydrogen calls (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 7 years ago
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | | Annotate | Revision Log
OLDNEW
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 3374 matching lines...)
3385 SafepointGenerator generator( 3385 SafepointGenerator generator(
3386 this, pointers, Safepoint::kLazyDeopt); 3386 this, pointers, Safepoint::kLazyDeopt);
3387 ParameterCount count(arity); 3387 ParameterCount count(arity);
3388 ParameterCount expected(formal_parameter_count); 3388 ParameterCount expected(formal_parameter_count);
3389 __ InvokeFunction( 3389 __ InvokeFunction(
3390 function, expected, count, CALL_FUNCTION, generator, call_kind); 3390 function, expected, count, CALL_FUNCTION, generator, call_kind);
3391 } 3391 }
3392 } 3392 }
3393 3393
3394 3394
3395 void LCodeGen::DoCallConstantFunction(LCallConstantFunction* instr) { 3395 void LCodeGen::DoCallWithDescriptor(LCallWithDescriptor* instr) {
3396 ASSERT(ToRegister(instr->result()).is(rax)); 3396 ASSERT(ToRegister(instr->result()).is(rax));
3397 CallKnownFunction(instr->hydrogen()->function(), 3397
3398 instr->hydrogen()->formal_parameter_count(), 3398 LPointerMap* pointers = instr->pointer_map();
3399 instr->arity(), 3399 SafepointGenerator generator(this, pointers, Safepoint::kLazyDeopt);
3400 instr, 3400
3401 CALL_AS_METHOD, 3401 if (instr->target()->IsConstantOperand()) {
3402 RDI_UNINITIALIZED); 3402 LConstantOperand* target = LConstantOperand::cast(instr->target());
3403 Handle<Code> code = Handle<Code>::cast(ToHandle(target));
3404 generator.BeforeCall(__ CallSize(code));
3405 __ call(code, RelocInfo::CODE_TARGET);
3406 } else {
3407 ASSERT(instr->target()->IsRegister());
3408 Register target = ToRegister(instr->target());
3409 generator.BeforeCall(__ CallSize(target));
3410 __ addq(target, Immediate(Code::kHeaderSize - kHeapObjectTag));
3411 __ call(target);
3412 }
3413 generator.AfterCall();
3403 } 3414 }
3404 3415
3405 3416
3417 void LCodeGen::DoCallJSFunction(LCallJSFunction* instr) {
3418 ASSERT(ToRegister(instr->function()).is(rdi));
3419 ASSERT(ToRegister(instr->call_kind()).is(rcx));
3420 ASSERT(ToRegister(instr->result()).is(rax));
3421
3422 if (instr->hydrogen()->pass_argument_count()) {
3423 __ Set(rax, instr->arity());
3424 }
3425
3426 // Change context.
3427 __ movq(rsi, FieldOperand(rdi, JSFunction::kContextOffset));
3428
3429 LPointerMap* pointers = instr->pointer_map();
3430 SafepointGenerator generator(this, pointers, Safepoint::kLazyDeopt);
3431
3432 bool is_self_call = false;
3433 if (instr->hydrogen()->function()->IsConstant()) {
3434 Handle<JSFunction> jsfun = Handle<JSFunction>::null();
3435 HConstant* fun_const = HConstant::cast(instr->hydrogen()->function());
3436 jsfun = Handle<JSFunction>::cast(fun_const->handle(isolate()));
3437 is_self_call = jsfun.is_identical_to(info()->closure());
3438 }
3439
3440 if (is_self_call) {
3441 __ CallSelf();
3442 } else {
3443 Operand target = FieldOperand(rdi, JSFunction::kCodeEntryOffset);
3444 generator.BeforeCall(__ CallSize(target));
3445 __ call(target);
3446 }
3447 generator.AfterCall();
3448 }
3449
3450
3406 void LCodeGen::DoDeferredMathAbsTaggedHeapNumber(LMathAbs* instr) { 3451 void LCodeGen::DoDeferredMathAbsTaggedHeapNumber(LMathAbs* instr) {
3407 Register input_reg = ToRegister(instr->value()); 3452 Register input_reg = ToRegister(instr->value());
3408 __ CompareRoot(FieldOperand(input_reg, HeapObject::kMapOffset), 3453 __ CompareRoot(FieldOperand(input_reg, HeapObject::kMapOffset),
3409 Heap::kHeapNumberMapRootIndex); 3454 Heap::kHeapNumberMapRootIndex);
3410 DeoptimizeIf(not_equal, instr->environment()); 3455 DeoptimizeIf(not_equal, instr->environment());
3411 3456
3412 Label slow, allocated, done; 3457 Label slow, allocated, done;
3413 Register tmp = input_reg.is(rax) ? rcx : rax; 3458 Register tmp = input_reg.is(rax) ? rcx : rax;
3414 Register tmp2 = tmp.is(rcx) ? rdx : input_reg.is(rcx) ? rdx : rcx; 3459 Register tmp2 = tmp.is(rcx) ? rdx : input_reg.is(rcx) ? rdx : rcx;
3415 3460
(...skipping 346 matching lines...)
3762 CallKnownFunction(known_function, 3807 CallKnownFunction(known_function,
3763 instr->hydrogen()->formal_parameter_count(), 3808 instr->hydrogen()->formal_parameter_count(),
3764 instr->arity(), 3809 instr->arity(),
3765 instr, 3810 instr,
3766 CALL_AS_METHOD, 3811 CALL_AS_METHOD,
3767 RDI_CONTAINS_TARGET); 3812 RDI_CONTAINS_TARGET);
3768 } 3813 }
3769 } 3814 }
3770 3815
3771 3816
3772 void LCodeGen::DoCallKeyed(LCallKeyed* instr) {
3773 ASSERT(ToRegister(instr->context()).is(rsi));
3774 ASSERT(ToRegister(instr->key()).is(rcx));
3775 ASSERT(ToRegister(instr->result()).is(rax));
3776
3777 int arity = instr->arity();
3778 Handle<Code> ic =
3779 isolate()->stub_cache()->ComputeKeyedCallInitialize(arity);
3780 CallCode(ic, RelocInfo::CODE_TARGET, instr);
3781 }
3782
3783
3784 void LCodeGen::DoCallNamed(LCallNamed* instr) {
3785 ASSERT(ToRegister(instr->context()).is(rsi));
3786 ASSERT(ToRegister(instr->result()).is(rax));
3787
3788 int arity = instr->arity();
3789 RelocInfo::Mode mode = RelocInfo::CODE_TARGET;
3790 Handle<Code> ic =
3791 isolate()->stub_cache()->ComputeCallInitialize(arity, mode);
3792 __ Move(rcx, instr->name());
3793 CallCode(ic, mode, instr);
3794 }
3795
3796
3797 void LCodeGen::DoCallFunction(LCallFunction* instr) { 3817 void LCodeGen::DoCallFunction(LCallFunction* instr) {
3798 ASSERT(ToRegister(instr->context()).is(rsi)); 3818 ASSERT(ToRegister(instr->context()).is(rsi));
3799 ASSERT(ToRegister(instr->function()).is(rdi)); 3819 ASSERT(ToRegister(instr->function()).is(rdi));
3800 ASSERT(ToRegister(instr->result()).is(rax)); 3820 ASSERT(ToRegister(instr->result()).is(rax));
3801 3821
3802 int arity = instr->arity(); 3822 int arity = instr->arity();
3803 CallFunctionStub stub(arity, NO_CALL_FUNCTION_FLAGS); 3823 CallFunctionStub stub(arity, NO_CALL_FUNCTION_FLAGS);
3804 if (instr->hydrogen()->IsTailCall()) { 3824 if (instr->hydrogen()->IsTailCall()) {
3805 if (NeedsEagerFrame()) __ leave(); 3825 if (NeedsEagerFrame()) __ leave();
3806 __ jmp(stub.GetCode(isolate()), RelocInfo::CODE_TARGET); 3826 __ jmp(stub.GetCode(isolate()), RelocInfo::CODE_TARGET);
3807 } else { 3827 } else {
3808 CallCode(stub.GetCode(isolate()), RelocInfo::CODE_TARGET, instr); 3828 CallCode(stub.GetCode(isolate()), RelocInfo::CODE_TARGET, instr);
3809 } 3829 }
3810 } 3830 }
3811 3831
3812 3832
3813 void LCodeGen::DoCallGlobal(LCallGlobal* instr) { 3833 void LCodeGen::DoCallGlobal(LCallGlobal* instr) {
3814 ASSERT(ToRegister(instr->context()).is(rsi)); 3834 ASSERT(ToRegister(instr->context()).is(rsi));
3815 ASSERT(ToRegister(instr->result()).is(rax)); 3835 ASSERT(ToRegister(instr->result()).is(rax));
3816 int arity = instr->arity(); 3836 int arity = instr->arity();
3817 RelocInfo::Mode mode = RelocInfo::CODE_TARGET_CONTEXT; 3837 RelocInfo::Mode mode = RelocInfo::CODE_TARGET_CONTEXT;
3818 Handle<Code> ic = 3838 Handle<Code> ic =
3819 isolate()->stub_cache()->ComputeCallInitialize(arity, mode); 3839 isolate()->stub_cache()->ComputeCallInitialize(arity, mode);
3820 __ Move(rcx, instr->name()); 3840 __ Move(rcx, instr->name());
3821 CallCode(ic, mode, instr); 3841 CallCode(ic, mode, instr);
3822 } 3842 }
3823 3843
3824 3844
3825 void LCodeGen::DoCallKnownGlobal(LCallKnownGlobal* instr) {
3826 ASSERT(ToRegister(instr->result()).is(rax));
3827 CallKnownFunction(instr->hydrogen()->target(),
3828 instr->hydrogen()->formal_parameter_count(),
3829 instr->arity(),
3830 instr,
3831 CALL_AS_FUNCTION,
3832 RDI_UNINITIALIZED);
3833 }
3834
3835
3836 void LCodeGen::DoCallNew(LCallNew* instr) { 3845 void LCodeGen::DoCallNew(LCallNew* instr) {
3837 ASSERT(ToRegister(instr->context()).is(rsi)); 3846 ASSERT(ToRegister(instr->context()).is(rsi));
3838 ASSERT(ToRegister(instr->constructor()).is(rdi)); 3847 ASSERT(ToRegister(instr->constructor()).is(rdi));
3839 ASSERT(ToRegister(instr->result()).is(rax)); 3848 ASSERT(ToRegister(instr->result()).is(rax));
3840 3849
3841 __ Set(rax, instr->arity()); 3850 __ Set(rax, instr->arity());
3842 // No cell in ebx for construct type feedback in optimized code 3851 // No cell in ebx for construct type feedback in optimized code
3843 Handle<Object> undefined_value(isolate()->factory()->undefined_value()); 3852 Handle<Object> undefined_value(isolate()->factory()->undefined_value());
3844 __ Move(rbx, undefined_value); 3853 __ Move(rbx, undefined_value);
3845 CallConstructStub stub(NO_CALL_FUNCTION_FLAGS); 3854 CallConstructStub stub(NO_CALL_FUNCTION_FLAGS);
(...skipping 1736 matching lines...)
5582 FixedArray::kHeaderSize - kPointerSize)); 5591 FixedArray::kHeaderSize - kPointerSize));
5583 __ bind(&done); 5592 __ bind(&done);
5584 } 5593 }
5585 5594
5586 5595
5587 #undef __ 5596 #undef __
5588 5597
5589 } } // namespace v8::internal 5598 } } // namespace v8::internal
5590 5599
5591 #endif // V8_TARGET_ARCH_X64 5600 #endif // V8_TARGET_ARCH_X64
OLDNEW

Powered by Google App Engine