Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(145)

Side by Side Diff: src/x64/macro-assembler-x64.cc

Issue 132623005: A64: Synchronize with r18642. (Closed) Base URL: https://v8.googlecode.com/svn/branches/experimental/a64
Patch Set: Created 6 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/x64/macro-assembler-x64.h ('k') | src/x64/stub-cache-x64.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 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 830 matching lines...) Expand 10 before | Expand all | Expand 10 after
841 InvokeFlag flag, 841 InvokeFlag flag,
842 const CallWrapper& call_wrapper) { 842 const CallWrapper& call_wrapper) {
843 // You can't call a builtin without a valid frame. 843 // You can't call a builtin without a valid frame.
844 ASSERT(flag == JUMP_FUNCTION || has_frame()); 844 ASSERT(flag == JUMP_FUNCTION || has_frame());
845 845
846 // Rely on the assertion to check that the number of provided 846 // Rely on the assertion to check that the number of provided
847 // arguments match the expected number of arguments. Fake a 847 // arguments match the expected number of arguments. Fake a
848 // parameter count to avoid emitting code to do the check. 848 // parameter count to avoid emitting code to do the check.
849 ParameterCount expected(0); 849 ParameterCount expected(0);
850 GetBuiltinEntry(rdx, id); 850 GetBuiltinEntry(rdx, id);
851 InvokeCode(rdx, expected, expected, flag, call_wrapper, CALL_AS_METHOD); 851 InvokeCode(rdx, expected, expected, flag, call_wrapper);
852 } 852 }
853 853
854 854
855 void MacroAssembler::GetBuiltinFunction(Register target, 855 void MacroAssembler::GetBuiltinFunction(Register target,
856 Builtins::JavaScript id) { 856 Builtins::JavaScript id) {
857 // Load the builtins object into target register. 857 // Load the builtins object into target register.
858 movq(target, Operand(rsi, Context::SlotOffset(Context::GLOBAL_OBJECT_INDEX))); 858 movq(target, Operand(rsi, Context::SlotOffset(Context::GLOBAL_OBJECT_INDEX)));
859 movq(target, FieldOperand(target, GlobalObject::kBuiltinsOffset)); 859 movq(target, FieldOperand(target, GlobalObject::kBuiltinsOffset));
860 movq(target, FieldOperand(target, 860 movq(target, FieldOperand(target,
861 JSBuiltinsObject::OffsetOfFunctionWithId(id))); 861 JSBuiltinsObject::OffsetOfFunctionWithId(id)));
(...skipping 2603 matching lines...) Expand 10 before | Expand all | Expand 10 after
3465 void MacroAssembler::DebugBreak() { 3465 void MacroAssembler::DebugBreak() {
3466 Set(rax, 0); // No arguments. 3466 Set(rax, 0); // No arguments.
3467 LoadAddress(rbx, ExternalReference(Runtime::kDebugBreak, isolate())); 3467 LoadAddress(rbx, ExternalReference(Runtime::kDebugBreak, isolate()));
3468 CEntryStub ces(1); 3468 CEntryStub ces(1);
3469 ASSERT(AllowThisStubCall(&ces)); 3469 ASSERT(AllowThisStubCall(&ces));
3470 Call(ces.GetCode(isolate()), RelocInfo::DEBUG_BREAK); 3470 Call(ces.GetCode(isolate()), RelocInfo::DEBUG_BREAK);
3471 } 3471 }
3472 #endif // ENABLE_DEBUGGER_SUPPORT 3472 #endif // ENABLE_DEBUGGER_SUPPORT
3473 3473
3474 3474
3475 void MacroAssembler::SetCallKind(Register dst, CallKind call_kind) {
3476 // This macro takes the dst register to make the code more readable
3477 // at the call sites. However, the dst register has to be rcx to
3478 // follow the calling convention which requires the call type to be
3479 // in rcx.
3480 ASSERT(dst.is(rcx));
3481 if (call_kind == CALL_AS_FUNCTION) {
3482 LoadSmiConstant(dst, Smi::FromInt(1));
3483 } else {
3484 LoadSmiConstant(dst, Smi::FromInt(0));
3485 }
3486 }
3487
3488
3489 void MacroAssembler::InvokeCode(Register code, 3475 void MacroAssembler::InvokeCode(Register code,
3490 const ParameterCount& expected, 3476 const ParameterCount& expected,
3491 const ParameterCount& actual, 3477 const ParameterCount& actual,
3492 InvokeFlag flag, 3478 InvokeFlag flag,
3493 const CallWrapper& call_wrapper, 3479 const CallWrapper& call_wrapper) {
3494 CallKind call_kind) {
3495 // You can't call a function without a valid frame. 3480 // You can't call a function without a valid frame.
3496 ASSERT(flag == JUMP_FUNCTION || has_frame()); 3481 ASSERT(flag == JUMP_FUNCTION || has_frame());
3497 3482
3498 Label done; 3483 Label done;
3499 bool definitely_mismatches = false; 3484 bool definitely_mismatches = false;
3500 InvokePrologue(expected, 3485 InvokePrologue(expected,
3501 actual, 3486 actual,
3502 Handle<Code>::null(), 3487 Handle<Code>::null(),
3503 code, 3488 code,
3504 &done, 3489 &done,
3505 &definitely_mismatches, 3490 &definitely_mismatches,
3506 flag, 3491 flag,
3507 Label::kNear, 3492 Label::kNear,
3508 call_wrapper, 3493 call_wrapper);
3509 call_kind);
3510 if (!definitely_mismatches) { 3494 if (!definitely_mismatches) {
3511 if (flag == CALL_FUNCTION) { 3495 if (flag == CALL_FUNCTION) {
3512 call_wrapper.BeforeCall(CallSize(code)); 3496 call_wrapper.BeforeCall(CallSize(code));
3513 SetCallKind(rcx, call_kind);
3514 call(code); 3497 call(code);
3515 call_wrapper.AfterCall(); 3498 call_wrapper.AfterCall();
3516 } else { 3499 } else {
3517 ASSERT(flag == JUMP_FUNCTION); 3500 ASSERT(flag == JUMP_FUNCTION);
3518 SetCallKind(rcx, call_kind);
3519 jmp(code); 3501 jmp(code);
3520 } 3502 }
3521 bind(&done); 3503 bind(&done);
3522 } 3504 }
3523 } 3505 }
3524 3506
3525 3507
3526 void MacroAssembler::InvokeCode(Handle<Code> code,
3527 const ParameterCount& expected,
3528 const ParameterCount& actual,
3529 RelocInfo::Mode rmode,
3530 InvokeFlag flag,
3531 const CallWrapper& call_wrapper,
3532 CallKind call_kind) {
3533 // You can't call a function without a valid frame.
3534 ASSERT(flag == JUMP_FUNCTION || has_frame());
3535
3536 Label done;
3537 bool definitely_mismatches = false;
3538 Register dummy = rax;
3539 InvokePrologue(expected,
3540 actual,
3541 code,
3542 dummy,
3543 &done,
3544 &definitely_mismatches,
3545 flag,
3546 Label::kNear,
3547 call_wrapper,
3548 call_kind);
3549 if (!definitely_mismatches) {
3550 if (flag == CALL_FUNCTION) {
3551 call_wrapper.BeforeCall(CallSize(code));
3552 SetCallKind(rcx, call_kind);
3553 Call(code, rmode);
3554 call_wrapper.AfterCall();
3555 } else {
3556 ASSERT(flag == JUMP_FUNCTION);
3557 SetCallKind(rcx, call_kind);
3558 Jump(code, rmode);
3559 }
3560 bind(&done);
3561 }
3562 }
3563
3564
3565 void MacroAssembler::InvokeFunction(Register function, 3508 void MacroAssembler::InvokeFunction(Register function,
3566 const ParameterCount& actual, 3509 const ParameterCount& actual,
3567 InvokeFlag flag, 3510 InvokeFlag flag,
3568 const CallWrapper& call_wrapper, 3511 const CallWrapper& call_wrapper) {
3569 CallKind call_kind) {
3570 // You can't call a function without a valid frame. 3512 // You can't call a function without a valid frame.
3571 ASSERT(flag == JUMP_FUNCTION || has_frame()); 3513 ASSERT(flag == JUMP_FUNCTION || has_frame());
3572 3514
3573 ASSERT(function.is(rdi)); 3515 ASSERT(function.is(rdi));
3574 movq(rdx, FieldOperand(function, JSFunction::kSharedFunctionInfoOffset)); 3516 movq(rdx, FieldOperand(function, JSFunction::kSharedFunctionInfoOffset));
3575 movq(rsi, FieldOperand(function, JSFunction::kContextOffset)); 3517 movq(rsi, FieldOperand(function, JSFunction::kContextOffset));
3576 movsxlq(rbx, 3518 movsxlq(rbx,
3577 FieldOperand(rdx, SharedFunctionInfo::kFormalParameterCountOffset)); 3519 FieldOperand(rdx, SharedFunctionInfo::kFormalParameterCountOffset));
3578 // Advances rdx to the end of the Code object header, to the start of 3520 // Advances rdx to the end of the Code object header, to the start of
3579 // the executable code. 3521 // the executable code.
3580 movq(rdx, FieldOperand(rdi, JSFunction::kCodeEntryOffset)); 3522 movq(rdx, FieldOperand(rdi, JSFunction::kCodeEntryOffset));
3581 3523
3582 ParameterCount expected(rbx); 3524 ParameterCount expected(rbx);
3583 InvokeCode(rdx, expected, actual, flag, call_wrapper, call_kind); 3525 InvokeCode(rdx, expected, actual, flag, call_wrapper);
3584 } 3526 }
3585 3527
3586 3528
3587 void MacroAssembler::InvokeFunction(Register function, 3529 void MacroAssembler::InvokeFunction(Register function,
3588 const ParameterCount& expected, 3530 const ParameterCount& expected,
3589 const ParameterCount& actual, 3531 const ParameterCount& actual,
3590 InvokeFlag flag, 3532 InvokeFlag flag,
3591 const CallWrapper& call_wrapper, 3533 const CallWrapper& call_wrapper) {
3592 CallKind call_kind) {
3593 // You can't call a function without a valid frame. 3534 // You can't call a function without a valid frame.
3594 ASSERT(flag == JUMP_FUNCTION || has_frame()); 3535 ASSERT(flag == JUMP_FUNCTION || has_frame());
3595 3536
3596 ASSERT(function.is(rdi)); 3537 ASSERT(function.is(rdi));
3597 movq(rsi, FieldOperand(function, JSFunction::kContextOffset)); 3538 movq(rsi, FieldOperand(function, JSFunction::kContextOffset));
3598 // Advances rdx to the end of the Code object header, to the start of 3539 // Advances rdx to the end of the Code object header, to the start of
3599 // the executable code. 3540 // the executable code.
3600 movq(rdx, FieldOperand(rdi, JSFunction::kCodeEntryOffset)); 3541 movq(rdx, FieldOperand(rdi, JSFunction::kCodeEntryOffset));
3601 3542
3602 InvokeCode(rdx, expected, actual, flag, call_wrapper, call_kind); 3543 InvokeCode(rdx, expected, actual, flag, call_wrapper);
3603 } 3544 }
3604 3545
3605 3546
3606 void MacroAssembler::InvokeFunction(Handle<JSFunction> function, 3547 void MacroAssembler::InvokeFunction(Handle<JSFunction> function,
3607 const ParameterCount& expected, 3548 const ParameterCount& expected,
3608 const ParameterCount& actual, 3549 const ParameterCount& actual,
3609 InvokeFlag flag, 3550 InvokeFlag flag,
3610 const CallWrapper& call_wrapper, 3551 const CallWrapper& call_wrapper) {
3611 CallKind call_kind) {
3612 Move(rdi, function); 3552 Move(rdi, function);
3613 InvokeFunction(rdi, expected, actual, flag, call_wrapper, call_kind); 3553 InvokeFunction(rdi, expected, actual, flag, call_wrapper);
3614 } 3554 }
3615 3555
3616 3556
3617 void MacroAssembler::InvokePrologue(const ParameterCount& expected, 3557 void MacroAssembler::InvokePrologue(const ParameterCount& expected,
3618 const ParameterCount& actual, 3558 const ParameterCount& actual,
3619 Handle<Code> code_constant, 3559 Handle<Code> code_constant,
3620 Register code_register, 3560 Register code_register,
3621 Label* done, 3561 Label* done,
3622 bool* definitely_mismatches, 3562 bool* definitely_mismatches,
3623 InvokeFlag flag, 3563 InvokeFlag flag,
3624 Label::Distance near_jump, 3564 Label::Distance near_jump,
3625 const CallWrapper& call_wrapper, 3565 const CallWrapper& call_wrapper) {
3626 CallKind call_kind) {
3627 bool definitely_matches = false; 3566 bool definitely_matches = false;
3628 *definitely_mismatches = false; 3567 *definitely_mismatches = false;
3629 Label invoke; 3568 Label invoke;
3630 if (expected.is_immediate()) { 3569 if (expected.is_immediate()) {
3631 ASSERT(actual.is_immediate()); 3570 ASSERT(actual.is_immediate());
3632 if (expected.immediate() == actual.immediate()) { 3571 if (expected.immediate() == actual.immediate()) {
3633 definitely_matches = true; 3572 definitely_matches = true;
3634 } else { 3573 } else {
3635 Set(rax, actual.immediate()); 3574 Set(rax, actual.immediate());
3636 if (expected.immediate() == 3575 if (expected.immediate() ==
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
3668 Handle<Code> adaptor = isolate()->builtins()->ArgumentsAdaptorTrampoline(); 3607 Handle<Code> adaptor = isolate()->builtins()->ArgumentsAdaptorTrampoline();
3669 if (!code_constant.is_null()) { 3608 if (!code_constant.is_null()) {
3670 Move(rdx, code_constant, RelocInfo::EMBEDDED_OBJECT); 3609 Move(rdx, code_constant, RelocInfo::EMBEDDED_OBJECT);
3671 addq(rdx, Immediate(Code::kHeaderSize - kHeapObjectTag)); 3610 addq(rdx, Immediate(Code::kHeaderSize - kHeapObjectTag));
3672 } else if (!code_register.is(rdx)) { 3611 } else if (!code_register.is(rdx)) {
3673 movq(rdx, code_register); 3612 movq(rdx, code_register);
3674 } 3613 }
3675 3614
3676 if (flag == CALL_FUNCTION) { 3615 if (flag == CALL_FUNCTION) {
3677 call_wrapper.BeforeCall(CallSize(adaptor)); 3616 call_wrapper.BeforeCall(CallSize(adaptor));
3678 SetCallKind(rcx, call_kind);
3679 Call(adaptor, RelocInfo::CODE_TARGET); 3617 Call(adaptor, RelocInfo::CODE_TARGET);
3680 call_wrapper.AfterCall(); 3618 call_wrapper.AfterCall();
3681 if (!*definitely_mismatches) { 3619 if (!*definitely_mismatches) {
3682 jmp(done, near_jump); 3620 jmp(done, near_jump);
3683 } 3621 }
3684 } else { 3622 } else {
3685 SetCallKind(rcx, call_kind);
3686 Jump(adaptor, RelocInfo::CODE_TARGET); 3623 Jump(adaptor, RelocInfo::CODE_TARGET);
3687 } 3624 }
3688 bind(&invoke); 3625 bind(&invoke);
3689 } 3626 }
3690 } 3627 }
3691 3628
3692 3629
3693 void MacroAssembler::Prologue(PrologueFrameMode frame_mode) { 3630 void MacroAssembler::Prologue(PrologueFrameMode frame_mode) {
3694 if (frame_mode == BUILD_STUB_FRAME) { 3631 if (frame_mode == BUILD_STUB_FRAME) {
3695 push(rbp); // Caller's frame pointer. 3632 push(rbp); // Caller's frame pointer.
(...skipping 1351 matching lines...) Expand 10 before | Expand all | Expand 10 after
5047 j(equal, found); 4984 j(equal, found);
5048 movq(current, FieldOperand(current, Map::kPrototypeOffset)); 4985 movq(current, FieldOperand(current, Map::kPrototypeOffset));
5049 CompareRoot(current, Heap::kNullValueRootIndex); 4986 CompareRoot(current, Heap::kNullValueRootIndex);
5050 j(not_equal, &loop_again); 4987 j(not_equal, &loop_again);
5051 } 4988 }
5052 4989
5053 4990
5054 } } // namespace v8::internal 4991 } } // namespace v8::internal
5055 4992
5056 #endif // V8_TARGET_ARCH_X64 4993 #endif // V8_TARGET_ARCH_X64
OLDNEW
« no previous file with comments | « src/x64/macro-assembler-x64.h ('k') | src/x64/stub-cache-x64.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698