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

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

Issue 39973003: Merge bleeding_edge. (Closed) Base URL: https://v8.googlecode.com/svn/branches/experimental/parser
Patch Set: again Created 7 years, 1 month 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 722 matching lines...) Expand 10 before | Expand all | Expand 10 after
733 cmpb(Operand(rax, 0), Immediate(0)); 733 cmpb(Operand(rax, 0), Immediate(0));
734 j(zero, &profiler_disabled); 734 j(zero, &profiler_disabled);
735 735
736 // Third parameter is the address of the actual getter function. 736 // Third parameter is the address of the actual getter function.
737 movq(thunk_last_arg, function_address, RelocInfo::EXTERNAL_REFERENCE); 737 movq(thunk_last_arg, function_address, RelocInfo::EXTERNAL_REFERENCE);
738 movq(rax, thunk_address, RelocInfo::EXTERNAL_REFERENCE); 738 movq(rax, thunk_address, RelocInfo::EXTERNAL_REFERENCE);
739 jmp(&end_profiler_check); 739 jmp(&end_profiler_check);
740 740
741 bind(&profiler_disabled); 741 bind(&profiler_disabled);
742 // Call the api function! 742 // Call the api function!
743 movq(rax, reinterpret_cast<int64_t>(function_address), 743 movq(rax, reinterpret_cast<Address>(function_address),
744 RelocInfo::EXTERNAL_REFERENCE); 744 RelocInfo::EXTERNAL_REFERENCE);
745 745
746 bind(&end_profiler_check); 746 bind(&end_profiler_check);
747 747
748 // Call the api function! 748 // Call the api function!
749 call(rax); 749 call(rax);
750 750
751 if (FLAG_log_timer_events) { 751 if (FLAG_log_timer_events) {
752 FrameScope frame(this, StackFrame::MANUAL); 752 FrameScope frame(this, StackFrame::MANUAL);
753 PushSafepointRegisters(); 753 PushSafepointRegisters();
(...skipping 1731 matching lines...) Expand 10 before | Expand all | Expand 10 after
2485 movq(dst, src); 2485 movq(dst, src);
2486 } 2486 }
2487 } 2487 }
2488 2488
2489 2489
2490 void MacroAssembler::Move(Register dst, Handle<Object> source) { 2490 void MacroAssembler::Move(Register dst, Handle<Object> source) {
2491 AllowDeferredHandleDereference smi_check; 2491 AllowDeferredHandleDereference smi_check;
2492 if (source->IsSmi()) { 2492 if (source->IsSmi()) {
2493 Move(dst, Smi::cast(*source)); 2493 Move(dst, Smi::cast(*source));
2494 } else { 2494 } else {
2495 ASSERT(source->IsHeapObject()); 2495 MoveHeapObject(dst, source);
2496 movq(dst, source, RelocInfo::EMBEDDED_OBJECT);
2497 } 2496 }
2498 } 2497 }
2499 2498
2500 2499
2501 void MacroAssembler::Move(const Operand& dst, Handle<Object> source) { 2500 void MacroAssembler::Move(const Operand& dst, Handle<Object> source) {
2502 AllowDeferredHandleDereference smi_check; 2501 AllowDeferredHandleDereference smi_check;
2503 if (source->IsSmi()) { 2502 if (source->IsSmi()) {
2504 Move(dst, Smi::cast(*source)); 2503 Move(dst, Smi::cast(*source));
2505 } else { 2504 } else {
2506 ASSERT(source->IsHeapObject()); 2505 MoveHeapObject(kScratchRegister, source);
2507 movq(kScratchRegister, source, RelocInfo::EMBEDDED_OBJECT);
2508 movq(dst, kScratchRegister); 2506 movq(dst, kScratchRegister);
2509 } 2507 }
2510 } 2508 }
2511 2509
2512 2510
2513 void MacroAssembler::Cmp(Register dst, Handle<Object> source) { 2511 void MacroAssembler::Cmp(Register dst, Handle<Object> source) {
2514 AllowDeferredHandleDereference smi_check; 2512 AllowDeferredHandleDereference smi_check;
2515 if (source->IsSmi()) { 2513 if (source->IsSmi()) {
2516 Cmp(dst, Smi::cast(*source)); 2514 Cmp(dst, Smi::cast(*source));
2517 } else { 2515 } else {
2518 ASSERT(source->IsHeapObject()); 2516 MoveHeapObject(kScratchRegister, source);
2519 movq(kScratchRegister, source, RelocInfo::EMBEDDED_OBJECT);
2520 cmpq(dst, kScratchRegister); 2517 cmpq(dst, kScratchRegister);
2521 } 2518 }
2522 } 2519 }
2523 2520
2524 2521
2525 void MacroAssembler::Cmp(const Operand& dst, Handle<Object> source) { 2522 void MacroAssembler::Cmp(const Operand& dst, Handle<Object> source) {
2526 AllowDeferredHandleDereference smi_check; 2523 AllowDeferredHandleDereference smi_check;
2527 if (source->IsSmi()) { 2524 if (source->IsSmi()) {
2528 Cmp(dst, Smi::cast(*source)); 2525 Cmp(dst, Smi::cast(*source));
2529 } else { 2526 } else {
2530 ASSERT(source->IsHeapObject()); 2527 MoveHeapObject(kScratchRegister, source);
2531 movq(kScratchRegister, source, RelocInfo::EMBEDDED_OBJECT);
2532 cmpq(dst, kScratchRegister); 2528 cmpq(dst, kScratchRegister);
2533 } 2529 }
2534 } 2530 }
2535 2531
2536 2532
2537 void MacroAssembler::Push(Handle<Object> source) { 2533 void MacroAssembler::Push(Handle<Object> source) {
2538 AllowDeferredHandleDereference smi_check; 2534 AllowDeferredHandleDereference smi_check;
2539 if (source->IsSmi()) { 2535 if (source->IsSmi()) {
2540 Push(Smi::cast(*source)); 2536 Push(Smi::cast(*source));
2541 } else { 2537 } else {
2542 ASSERT(source->IsHeapObject()); 2538 MoveHeapObject(kScratchRegister, source);
2543 movq(kScratchRegister, source, RelocInfo::EMBEDDED_OBJECT);
2544 push(kScratchRegister); 2539 push(kScratchRegister);
2545 } 2540 }
2546 } 2541 }
2547 2542
2548 2543
2549 void MacroAssembler::LoadHeapObject(Register result, 2544 void MacroAssembler::MoveHeapObject(Register result,
2550 Handle<HeapObject> object) { 2545 Handle<Object> object) {
2551 AllowDeferredHandleDereference using_raw_address; 2546 AllowDeferredHandleDereference using_raw_address;
2547 ASSERT(object->IsHeapObject());
2552 if (isolate()->heap()->InNewSpace(*object)) { 2548 if (isolate()->heap()->InNewSpace(*object)) {
2553 Handle<Cell> cell = isolate()->factory()->NewCell(object); 2549 Handle<Cell> cell = isolate()->factory()->NewCell(object);
2554 movq(result, cell, RelocInfo::CELL); 2550 movq(result, cell, RelocInfo::CELL);
2555 movq(result, Operand(result, 0)); 2551 movq(result, Operand(result, 0));
2556 } else { 2552 } else {
2557 Move(result, object); 2553 movq(result, object, RelocInfo::EMBEDDED_OBJECT);
2558 } 2554 }
2559 } 2555 }
2560 2556
2561
2562 void MacroAssembler::CmpHeapObject(Register reg, Handle<HeapObject> object) {
2563 AllowDeferredHandleDereference using_raw_address;
2564 if (isolate()->heap()->InNewSpace(*object)) {
2565 Handle<Cell> cell = isolate()->factory()->NewCell(object);
2566 movq(kScratchRegister, cell, RelocInfo::CELL);
2567 cmpq(reg, Operand(kScratchRegister, 0));
2568 } else {
2569 Cmp(reg, object);
2570 }
2571 }
2572
2573
2574 void MacroAssembler::PushHeapObject(Handle<HeapObject> object) {
2575 AllowDeferredHandleDereference using_raw_address;
2576 if (isolate()->heap()->InNewSpace(*object)) {
2577 Handle<Cell> cell = isolate()->factory()->NewCell(object);
2578 movq(kScratchRegister, cell, RelocInfo::CELL);
2579 movq(kScratchRegister, Operand(kScratchRegister, 0));
2580 push(kScratchRegister);
2581 } else {
2582 Push(object);
2583 }
2584 }
2585
2586 2557
2587 void MacroAssembler::LoadGlobalCell(Register dst, Handle<Cell> cell) { 2558 void MacroAssembler::LoadGlobalCell(Register dst, Handle<Cell> cell) {
2588 if (dst.is(rax)) { 2559 if (dst.is(rax)) {
2589 AllowDeferredHandleDereference embedding_raw_address; 2560 AllowDeferredHandleDereference embedding_raw_address;
2590 load_rax(cell.location(), RelocInfo::CELL); 2561 load_rax(cell.location(), RelocInfo::CELL);
2591 } else { 2562 } else {
2592 movq(dst, cell, RelocInfo::CELL); 2563 movq(dst, cell, RelocInfo::CELL);
2593 movq(dst, Operand(dst, 0)); 2564 movq(dst, Operand(dst, 0));
2594 } 2565 }
2595 } 2566 }
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
2657 #endif 2628 #endif
2658 } 2629 }
2659 2630
2660 2631
2661 void MacroAssembler::Call(Handle<Code> code_object, 2632 void MacroAssembler::Call(Handle<Code> code_object,
2662 RelocInfo::Mode rmode, 2633 RelocInfo::Mode rmode,
2663 TypeFeedbackId ast_id) { 2634 TypeFeedbackId ast_id) {
2664 #ifdef DEBUG 2635 #ifdef DEBUG
2665 int end_position = pc_offset() + CallSize(code_object); 2636 int end_position = pc_offset() + CallSize(code_object);
2666 #endif 2637 #endif
2667 ASSERT(RelocInfo::IsCodeTarget(rmode)); 2638 ASSERT(RelocInfo::IsCodeTarget(rmode) ||
2639 rmode == RelocInfo::CODE_AGE_SEQUENCE);
2668 call(code_object, rmode, ast_id); 2640 call(code_object, rmode, ast_id);
2669 #ifdef DEBUG 2641 #ifdef DEBUG
2670 CHECK_EQ(end_position, pc_offset()); 2642 CHECK_EQ(end_position, pc_offset());
2671 #endif 2643 #endif
2672 } 2644 }
2673 2645
2674 2646
2675 void MacroAssembler::Pushad() { 2647 void MacroAssembler::Pushad() {
2676 push(rax); 2648 push(rax);
2677 push(rcx); 2649 push(rcx);
(...skipping 906 matching lines...) Expand 10 before | Expand all | Expand 10 after
3584 void MacroAssembler::InvokeFunction(Handle<JSFunction> function, 3556 void MacroAssembler::InvokeFunction(Handle<JSFunction> function,
3585 const ParameterCount& expected, 3557 const ParameterCount& expected,
3586 const ParameterCount& actual, 3558 const ParameterCount& actual,
3587 InvokeFlag flag, 3559 InvokeFlag flag,
3588 const CallWrapper& call_wrapper, 3560 const CallWrapper& call_wrapper,
3589 CallKind call_kind) { 3561 CallKind call_kind) {
3590 // You can't call a function without a valid frame. 3562 // You can't call a function without a valid frame.
3591 ASSERT(flag == JUMP_FUNCTION || has_frame()); 3563 ASSERT(flag == JUMP_FUNCTION || has_frame());
3592 3564
3593 // Get the function and setup the context. 3565 // Get the function and setup the context.
3594 LoadHeapObject(rdi, function); 3566 Move(rdi, function);
3595 movq(rsi, FieldOperand(rdi, JSFunction::kContextOffset)); 3567 movq(rsi, FieldOperand(rdi, JSFunction::kContextOffset));
3596 3568
3597 // We call indirectly through the code field in the function to 3569 // We call indirectly through the code field in the function to
3598 // allow recompilation to take effect without changing any of the 3570 // allow recompilation to take effect without changing any of the
3599 // call sites. 3571 // call sites.
3600 movq(rdx, FieldOperand(rdi, JSFunction::kCodeEntryOffset)); 3572 movq(rdx, FieldOperand(rdi, JSFunction::kCodeEntryOffset));
3601 InvokeCode(rdx, expected, actual, flag, call_wrapper, call_kind); 3573 InvokeCode(rdx, expected, actual, flag, call_wrapper, call_kind);
3602 } 3574 }
3603 3575
3604 3576
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
3671 } 3643 }
3672 } else { 3644 } else {
3673 SetCallKind(rcx, call_kind); 3645 SetCallKind(rcx, call_kind);
3674 Jump(adaptor, RelocInfo::CODE_TARGET); 3646 Jump(adaptor, RelocInfo::CODE_TARGET);
3675 } 3647 }
3676 bind(&invoke); 3648 bind(&invoke);
3677 } 3649 }
3678 } 3650 }
3679 3651
3680 3652
3653 void MacroAssembler::Prologue(PrologueFrameMode frame_mode) {
3654 if (frame_mode == BUILD_STUB_FRAME) {
3655 push(rbp); // Caller's frame pointer.
3656 movq(rbp, rsp);
3657 push(rsi); // Callee's context.
3658 Push(Smi::FromInt(StackFrame::STUB));
3659 } else {
3660 PredictableCodeSizeScope predictible_code_size_scope(this,
3661 kNoCodeAgeSequenceLength);
3662 if (FLAG_optimize_for_size && FLAG_age_code) {
3663 // Pre-age the code.
3664 Call(isolate()->builtins()->MarkCodeAsExecutedOnce(),
3665 RelocInfo::CODE_AGE_SEQUENCE);
3666 Nop(kNoCodeAgeSequenceLength - Assembler::kShortCallInstructionLength);
3667 } else {
3668 push(rbp); // Caller's frame pointer.
3669 movq(rbp, rsp);
3670 push(rsi); // Callee's context.
3671 push(rdi); // Callee's JS function.
3672 }
3673 }
3674 }
3675
3676
3681 void MacroAssembler::EnterFrame(StackFrame::Type type) { 3677 void MacroAssembler::EnterFrame(StackFrame::Type type) {
3682 push(rbp); 3678 push(rbp);
3683 movq(rbp, rsp); 3679 movq(rbp, rsp);
3684 push(rsi); // Context. 3680 push(rsi); // Context.
3685 Push(Smi::FromInt(type)); 3681 Push(Smi::FromInt(type));
3686 movq(kScratchRegister, CodeObject(), RelocInfo::EMBEDDED_OBJECT); 3682 movq(kScratchRegister, CodeObject(), RelocInfo::EMBEDDED_OBJECT);
3687 push(kScratchRegister); 3683 push(kScratchRegister);
3688 if (emit_debug_code()) { 3684 if (emit_debug_code()) {
3689 movq(kScratchRegister, 3685 movq(kScratchRegister,
3690 isolate()->factory()->undefined_value(), 3686 isolate()->factory()->undefined_value(),
(...skipping 395 matching lines...) Expand 10 before | Expand all | Expand 10 after
4086 } 4082 }
4087 } 4083 }
4088 jmp(gc_required); 4084 jmp(gc_required);
4089 return; 4085 return;
4090 } 4086 }
4091 ASSERT(!result.is(result_end)); 4087 ASSERT(!result.is(result_end));
4092 4088
4093 // Load address of new object into result. 4089 // Load address of new object into result.
4094 LoadAllocationTopHelper(result, scratch, flags); 4090 LoadAllocationTopHelper(result, scratch, flags);
4095 4091
4092 if (isolate()->heap_profiler()->is_tracking_allocations()) {
4093 RecordObjectAllocation(isolate(), result, object_size);
4094 }
4095
4096 // Align the next allocation. Storing the filler map without checking top is 4096 // Align the next allocation. Storing the filler map without checking top is
4097 // safe in new-space because the limit of the heap is aligned there. 4097 // safe in new-space because the limit of the heap is aligned there.
4098 if (((flags & DOUBLE_ALIGNMENT) != 0) && FLAG_debug_code) { 4098 if (((flags & DOUBLE_ALIGNMENT) != 0) && FLAG_debug_code) {
4099 testq(result, Immediate(kDoubleAlignmentMask)); 4099 testq(result, Immediate(kDoubleAlignmentMask));
4100 Check(zero, kAllocationIsNotDoubleAligned); 4100 Check(zero, kAllocationIsNotDoubleAligned);
4101 } 4101 }
4102 4102
4103 // Calculate new top and bail out if new space is exhausted. 4103 // Calculate new top and bail out if new space is exhausted.
4104 ExternalReference allocation_limit = 4104 ExternalReference allocation_limit =
4105 AllocationUtils::GetAllocationLimitReference(isolate(), flags); 4105 AllocationUtils::GetAllocationLimitReference(isolate(), flags);
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
4165 // object_size is left unchanged by this function. 4165 // object_size is left unchanged by this function.
4166 } 4166 }
4167 jmp(gc_required); 4167 jmp(gc_required);
4168 return; 4168 return;
4169 } 4169 }
4170 ASSERT(!result.is(result_end)); 4170 ASSERT(!result.is(result_end));
4171 4171
4172 // Load address of new object into result. 4172 // Load address of new object into result.
4173 LoadAllocationTopHelper(result, scratch, flags); 4173 LoadAllocationTopHelper(result, scratch, flags);
4174 4174
4175 if (isolate()->heap_profiler()->is_tracking_allocations()) {
4176 RecordObjectAllocation(isolate(), result, object_size);
4177 }
4178
4175 // Align the next allocation. Storing the filler map without checking top is 4179 // Align the next allocation. Storing the filler map without checking top is
4176 // safe in new-space because the limit of the heap is aligned there. 4180 // safe in new-space because the limit of the heap is aligned there.
4177 if (((flags & DOUBLE_ALIGNMENT) != 0) && FLAG_debug_code) { 4181 if (((flags & DOUBLE_ALIGNMENT) != 0) && FLAG_debug_code) {
4178 testq(result, Immediate(kDoubleAlignmentMask)); 4182 testq(result, Immediate(kDoubleAlignmentMask));
4179 Check(zero, kAllocationIsNotDoubleAligned); 4183 Check(zero, kAllocationIsNotDoubleAligned);
4180 } 4184 }
4181 4185
4182 // Calculate new top and bail out if new space is exhausted. 4186 // Calculate new top and bail out if new space is exhausted.
4183 ExternalReference allocation_limit = 4187 ExternalReference allocation_limit =
4184 AllocationUtils::GetAllocationLimitReference(isolate(), flags); 4188 AllocationUtils::GetAllocationLimitReference(isolate(), flags);
(...skipping 721 matching lines...) Expand 10 before | Expand all | Expand 10 after
4906 FieldOperand(rcx, JSObject::kElementsOffset)); 4910 FieldOperand(rcx, JSObject::kElementsOffset));
4907 j(not_equal, call_runtime); 4911 j(not_equal, call_runtime);
4908 4912
4909 movq(rcx, FieldOperand(rbx, Map::kPrototypeOffset)); 4913 movq(rcx, FieldOperand(rbx, Map::kPrototypeOffset));
4910 cmpq(rcx, null_value); 4914 cmpq(rcx, null_value);
4911 j(not_equal, &next); 4915 j(not_equal, &next);
4912 } 4916 }
4913 4917
4914 void MacroAssembler::TestJSArrayForAllocationMemento( 4918 void MacroAssembler::TestJSArrayForAllocationMemento(
4915 Register receiver_reg, 4919 Register receiver_reg,
4916 Register scratch_reg) { 4920 Register scratch_reg,
4917 Label no_memento_available; 4921 Label* no_memento_found) {
4918 ExternalReference new_space_start = 4922 ExternalReference new_space_start =
4919 ExternalReference::new_space_start(isolate()); 4923 ExternalReference::new_space_start(isolate());
4920 ExternalReference new_space_allocation_top = 4924 ExternalReference new_space_allocation_top =
4921 ExternalReference::new_space_allocation_top_address(isolate()); 4925 ExternalReference::new_space_allocation_top_address(isolate());
4922 4926
4923 lea(scratch_reg, Operand(receiver_reg, 4927 lea(scratch_reg, Operand(receiver_reg,
4924 JSArray::kSize + AllocationMemento::kSize - kHeapObjectTag)); 4928 JSArray::kSize + AllocationMemento::kSize - kHeapObjectTag));
4925 movq(kScratchRegister, new_space_start); 4929 movq(kScratchRegister, new_space_start);
4926 cmpq(scratch_reg, kScratchRegister); 4930 cmpq(scratch_reg, kScratchRegister);
4927 j(less, &no_memento_available); 4931 j(less, no_memento_found);
4928 cmpq(scratch_reg, ExternalOperand(new_space_allocation_top)); 4932 cmpq(scratch_reg, ExternalOperand(new_space_allocation_top));
4929 j(greater, &no_memento_available); 4933 j(greater, no_memento_found);
4930 CompareRoot(MemOperand(scratch_reg, -AllocationMemento::kSize), 4934 CompareRoot(MemOperand(scratch_reg, -AllocationMemento::kSize),
4931 Heap::kAllocationMementoMapRootIndex); 4935 Heap::kAllocationMementoMapRootIndex);
4932 bind(&no_memento_available);
4933 } 4936 }
4934 4937
4935 4938
4939 void MacroAssembler::RecordObjectAllocation(Isolate* isolate,
4940 Register object,
4941 Register object_size) {
4942 FrameScope frame(this, StackFrame::EXIT);
4943 PushSafepointRegisters();
4944 PrepareCallCFunction(3);
4945 // In case object is rdx
4946 movq(kScratchRegister, object);
4947 movq(arg_reg_3, object_size);
4948 movq(arg_reg_2, kScratchRegister);
4949 movq(arg_reg_1, isolate, RelocInfo::EXTERNAL_REFERENCE);
4950 CallCFunction(
4951 ExternalReference::record_object_allocation_function(isolate), 3);
4952 PopSafepointRegisters();
4953 }
4954
4955
4956 void MacroAssembler::RecordObjectAllocation(Isolate* isolate,
4957 Register object,
4958 int object_size) {
4959 FrameScope frame(this, StackFrame::EXIT);
4960 PushSafepointRegisters();
4961 PrepareCallCFunction(3);
4962 movq(arg_reg_2, object);
4963 movq(arg_reg_3, Immediate(object_size));
4964 movq(arg_reg_1, isolate, RelocInfo::EXTERNAL_REFERENCE);
4965 CallCFunction(
4966 ExternalReference::record_object_allocation_function(isolate), 3);
4967 PopSafepointRegisters();
4968 }
4969
4970
4936 } } // namespace v8::internal 4971 } } // namespace v8::internal
4937 4972
4938 #endif // V8_TARGET_ARCH_X64 4973 #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