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

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

Issue 358363002: Move platform abstraction to base library (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: updates Created 6 years, 5 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
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "src/v8.h" 5 #include "src/v8.h"
6 6
7 #if V8_TARGET_ARCH_X64 7 #if V8_TARGET_ARCH_X64
8 8
9 #include "src/bootstrapper.h" 9 #include "src/bootstrapper.h"
10 #include "src/codegen.h" 10 #include "src/codegen.h"
(...skipping 524 matching lines...) Expand 10 before | Expand all | Expand 10 after
535 void MacroAssembler::Check(Condition cc, BailoutReason reason) { 535 void MacroAssembler::Check(Condition cc, BailoutReason reason) {
536 Label L; 536 Label L;
537 j(cc, &L, Label::kNear); 537 j(cc, &L, Label::kNear);
538 Abort(reason); 538 Abort(reason);
539 // Control will not return here. 539 // Control will not return here.
540 bind(&L); 540 bind(&L);
541 } 541 }
542 542
543 543
544 void MacroAssembler::CheckStackAlignment() { 544 void MacroAssembler::CheckStackAlignment() {
545 int frame_alignment = OS::ActivationFrameAlignment(); 545 int frame_alignment = base::OS::ActivationFrameAlignment();
546 int frame_alignment_mask = frame_alignment - 1; 546 int frame_alignment_mask = frame_alignment - 1;
547 if (frame_alignment > kPointerSize) { 547 if (frame_alignment > kPointerSize) {
548 ASSERT(IsPowerOf2(frame_alignment)); 548 ASSERT(IsPowerOf2(frame_alignment));
549 Label alignment_as_expected; 549 Label alignment_as_expected;
550 testp(rsp, Immediate(frame_alignment_mask)); 550 testp(rsp, Immediate(frame_alignment_mask));
551 j(zero, &alignment_as_expected, Label::kNear); 551 j(zero, &alignment_as_expected, Label::kNear);
552 // Abort if stack is not aligned. 552 // Abort if stack is not aligned.
553 int3(); 553 int3();
554 bind(&alignment_as_expected); 554 bind(&alignment_as_expected);
555 } 555 }
(...skipping 3534 matching lines...) Expand 10 before | Expand all | Expand 10 after
4090 int offset = -2 * kPointerSize; 4090 int offset = -2 * kPointerSize;
4091 for (int i = 0; i < XMMRegister::NumAllocatableRegisters(); i++) { 4091 for (int i = 0; i < XMMRegister::NumAllocatableRegisters(); i++) {
4092 XMMRegister reg = XMMRegister::FromAllocationIndex(i); 4092 XMMRegister reg = XMMRegister::FromAllocationIndex(i);
4093 movsd(Operand(rbp, offset - ((i + 1) * kDoubleSize)), reg); 4093 movsd(Operand(rbp, offset - ((i + 1) * kDoubleSize)), reg);
4094 } 4094 }
4095 } else if (arg_stack_space > 0) { 4095 } else if (arg_stack_space > 0) {
4096 subp(rsp, Immediate(arg_stack_space * kRegisterSize)); 4096 subp(rsp, Immediate(arg_stack_space * kRegisterSize));
4097 } 4097 }
4098 4098
4099 // Get the required frame alignment for the OS. 4099 // Get the required frame alignment for the OS.
4100 const int kFrameAlignment = OS::ActivationFrameAlignment(); 4100 const int kFrameAlignment = base::OS::ActivationFrameAlignment();
4101 if (kFrameAlignment > 0) { 4101 if (kFrameAlignment > 0) {
4102 ASSERT(IsPowerOf2(kFrameAlignment)); 4102 ASSERT(IsPowerOf2(kFrameAlignment));
4103 ASSERT(is_int8(kFrameAlignment)); 4103 ASSERT(is_int8(kFrameAlignment));
4104 andp(rsp, Immediate(-kFrameAlignment)); 4104 andp(rsp, Immediate(-kFrameAlignment));
4105 } 4105 }
4106 4106
4107 // Patch the saved entry sp. 4107 // Patch the saved entry sp.
4108 movp(Operand(rbp, ExitFrameConstants::kSPOffset), rsp); 4108 movp(Operand(rbp, ExitFrameConstants::kSPOffset), rsp);
4109 } 4109 }
4110 4110
(...skipping 859 matching lines...) Expand 10 before | Expand all | Expand 10 after
4970 4970
4971 SmiCompare(index, Smi::FromInt(0)); 4971 SmiCompare(index, Smi::FromInt(0));
4972 Check(greater_equal, kIndexIsNegative); 4972 Check(greater_equal, kIndexIsNegative);
4973 4973
4974 // Restore the index 4974 // Restore the index
4975 SmiToInteger32(index, index); 4975 SmiToInteger32(index, index);
4976 } 4976 }
4977 4977
4978 4978
4979 void MacroAssembler::PrepareCallCFunction(int num_arguments) { 4979 void MacroAssembler::PrepareCallCFunction(int num_arguments) {
4980 int frame_alignment = OS::ActivationFrameAlignment(); 4980 int frame_alignment = base::OS::ActivationFrameAlignment();
4981 ASSERT(frame_alignment != 0); 4981 ASSERT(frame_alignment != 0);
4982 ASSERT(num_arguments >= 0); 4982 ASSERT(num_arguments >= 0);
4983 4983
4984 // Make stack end at alignment and allocate space for arguments and old rsp. 4984 // Make stack end at alignment and allocate space for arguments and old rsp.
4985 movp(kScratchRegister, rsp); 4985 movp(kScratchRegister, rsp);
4986 ASSERT(IsPowerOf2(frame_alignment)); 4986 ASSERT(IsPowerOf2(frame_alignment));
4987 int argument_slots_on_stack = 4987 int argument_slots_on_stack =
4988 ArgumentStackSlotsForCFunctionCall(num_arguments); 4988 ArgumentStackSlotsForCFunctionCall(num_arguments);
4989 subp(rsp, Immediate((argument_slots_on_stack + 1) * kRegisterSize)); 4989 subp(rsp, Immediate((argument_slots_on_stack + 1) * kRegisterSize));
4990 andp(rsp, Immediate(-frame_alignment)); 4990 andp(rsp, Immediate(-frame_alignment));
4991 movp(Operand(rsp, argument_slots_on_stack * kRegisterSize), kScratchRegister); 4991 movp(Operand(rsp, argument_slots_on_stack * kRegisterSize), kScratchRegister);
4992 } 4992 }
4993 4993
4994 4994
4995 void MacroAssembler::CallCFunction(ExternalReference function, 4995 void MacroAssembler::CallCFunction(ExternalReference function,
4996 int num_arguments) { 4996 int num_arguments) {
4997 LoadAddress(rax, function); 4997 LoadAddress(rax, function);
4998 CallCFunction(rax, num_arguments); 4998 CallCFunction(rax, num_arguments);
4999 } 4999 }
5000 5000
5001 5001
5002 void MacroAssembler::CallCFunction(Register function, int num_arguments) { 5002 void MacroAssembler::CallCFunction(Register function, int num_arguments) {
5003 ASSERT(has_frame()); 5003 ASSERT(has_frame());
5004 // Check stack alignment. 5004 // Check stack alignment.
5005 if (emit_debug_code()) { 5005 if (emit_debug_code()) {
5006 CheckStackAlignment(); 5006 CheckStackAlignment();
5007 } 5007 }
5008 5008
5009 call(function); 5009 call(function);
5010 ASSERT(OS::ActivationFrameAlignment() != 0); 5010 ASSERT(base::OS::ActivationFrameAlignment() != 0);
5011 ASSERT(num_arguments >= 0); 5011 ASSERT(num_arguments >= 0);
5012 int argument_slots_on_stack = 5012 int argument_slots_on_stack =
5013 ArgumentStackSlotsForCFunctionCall(num_arguments); 5013 ArgumentStackSlotsForCFunctionCall(num_arguments);
5014 movp(rsp, Operand(rsp, argument_slots_on_stack * kRegisterSize)); 5014 movp(rsp, Operand(rsp, argument_slots_on_stack * kRegisterSize));
5015 } 5015 }
5016 5016
5017 5017
5018 bool AreAliased(Register r1, Register r2, Register r3, Register r4) { 5018 bool AreAliased(Register r1, Register r2, Register r3, Register r4) {
5019 if (r1.is(r2)) return true; 5019 if (r1.is(r2)) return true;
5020 if (r1.is(r3)) return true; 5020 if (r1.is(r3)) return true;
(...skipping 11 matching lines...) Expand all
5032 masm_(NULL, address, size + Assembler::kGap) { 5032 masm_(NULL, address, size + Assembler::kGap) {
5033 // Create a new macro assembler pointing to the address of the code to patch. 5033 // Create a new macro assembler pointing to the address of the code to patch.
5034 // The size is adjusted with kGap on order for the assembler to generate size 5034 // The size is adjusted with kGap on order for the assembler to generate size
5035 // bytes of instructions without failing with buffer size constraints. 5035 // bytes of instructions without failing with buffer size constraints.
5036 ASSERT(masm_.reloc_info_writer.pos() == address_ + size_ + Assembler::kGap); 5036 ASSERT(masm_.reloc_info_writer.pos() == address_ + size_ + Assembler::kGap);
5037 } 5037 }
5038 5038
5039 5039
5040 CodePatcher::~CodePatcher() { 5040 CodePatcher::~CodePatcher() {
5041 // Indicate that code has changed. 5041 // Indicate that code has changed.
5042 CPU::FlushICache(address_, size_); 5042 CpuFeatures::FlushICache(address_, size_);
5043 5043
5044 // Check that the code was patched as expected. 5044 // Check that the code was patched as expected.
5045 ASSERT(masm_.pc_ == address_ + size_); 5045 ASSERT(masm_.pc_ == address_ + size_);
5046 ASSERT(masm_.reloc_info_writer.pos() == address_ + size_ + Assembler::kGap); 5046 ASSERT(masm_.reloc_info_writer.pos() == address_ + size_ + Assembler::kGap);
5047 } 5047 }
5048 5048
5049 5049
5050 void MacroAssembler::CheckPageFlag( 5050 void MacroAssembler::CheckPageFlag(
5051 Register object, 5051 Register object,
5052 Register scratch, 5052 Register scratch,
(...skipping 297 matching lines...) Expand 10 before | Expand all | Expand 10 after
5350 if (ms.shift() > 0) sarl(rdx, Immediate(ms.shift())); 5350 if (ms.shift() > 0) sarl(rdx, Immediate(ms.shift()));
5351 movl(rax, dividend); 5351 movl(rax, dividend);
5352 shrl(rax, Immediate(31)); 5352 shrl(rax, Immediate(31));
5353 addl(rdx, rax); 5353 addl(rdx, rax);
5354 } 5354 }
5355 5355
5356 5356
5357 } } // namespace v8::internal 5357 } } // namespace v8::internal
5358 5358
5359 #endif // V8_TARGET_ARCH_X64 5359 #endif // V8_TARGET_ARCH_X64
OLDNEW
« src/base/macros.h ('K') | « src/x64/lithium-codegen-x64.h ('k') | src/x87/assembler-x87.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698