| OLD | NEW |
| 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 <limits.h> // For LONG_MIN, LONG_MAX. | 5 #include <limits.h> // For LONG_MIN, LONG_MAX. |
| 6 | 6 |
| 7 #include "src/v8.h" | 7 #include "src/v8.h" |
| 8 | 8 |
| 9 #if V8_TARGET_ARCH_MIPS | 9 #if V8_TARGET_ARCH_MIPS |
| 10 | 10 |
| 11 #include "src/base/bits.h" |
| 11 #include "src/bootstrapper.h" | 12 #include "src/bootstrapper.h" |
| 12 #include "src/codegen.h" | 13 #include "src/codegen.h" |
| 13 #include "src/cpu-profiler.h" | 14 #include "src/cpu-profiler.h" |
| 14 #include "src/debug.h" | 15 #include "src/debug.h" |
| 15 #include "src/isolate-inl.h" | 16 #include "src/isolate-inl.h" |
| 16 #include "src/runtime.h" | 17 #include "src/runtime.h" |
| 17 | 18 |
| 18 namespace v8 { | 19 namespace v8 { |
| 19 namespace internal { | 20 namespace internal { |
| 20 | 21 |
| (...skipping 4933 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4954 li(t8, Operand(ExternalReference(Isolate::kCEntryFPAddress, isolate()))); | 4955 li(t8, Operand(ExternalReference(Isolate::kCEntryFPAddress, isolate()))); |
| 4955 sw(fp, MemOperand(t8)); | 4956 sw(fp, MemOperand(t8)); |
| 4956 li(t8, Operand(ExternalReference(Isolate::kContextAddress, isolate()))); | 4957 li(t8, Operand(ExternalReference(Isolate::kContextAddress, isolate()))); |
| 4957 sw(cp, MemOperand(t8)); | 4958 sw(cp, MemOperand(t8)); |
| 4958 | 4959 |
| 4959 const int frame_alignment = MacroAssembler::ActivationFrameAlignment(); | 4960 const int frame_alignment = MacroAssembler::ActivationFrameAlignment(); |
| 4960 if (save_doubles) { | 4961 if (save_doubles) { |
| 4961 // The stack must be allign to 0 modulo 8 for stores with sdc1. | 4962 // The stack must be allign to 0 modulo 8 for stores with sdc1. |
| 4962 DCHECK(kDoubleSize == frame_alignment); | 4963 DCHECK(kDoubleSize == frame_alignment); |
| 4963 if (frame_alignment > 0) { | 4964 if (frame_alignment > 0) { |
| 4964 DCHECK(IsPowerOf2(frame_alignment)); | 4965 DCHECK(base::bits::IsPowerOfTwo32(frame_alignment)); |
| 4965 And(sp, sp, Operand(-frame_alignment)); // Align stack. | 4966 And(sp, sp, Operand(-frame_alignment)); // Align stack. |
| 4966 } | 4967 } |
| 4967 int space = FPURegister::kMaxNumRegisters * kDoubleSize; | 4968 int space = FPURegister::kMaxNumRegisters * kDoubleSize; |
| 4968 Subu(sp, sp, Operand(space)); | 4969 Subu(sp, sp, Operand(space)); |
| 4969 // Remember: we only need to save every 2nd double FPU value. | 4970 // Remember: we only need to save every 2nd double FPU value. |
| 4970 for (int i = 0; i < FPURegister::kMaxNumRegisters; i+=2) { | 4971 for (int i = 0; i < FPURegister::kMaxNumRegisters; i+=2) { |
| 4971 FPURegister reg = FPURegister::from_code(i); | 4972 FPURegister reg = FPURegister::from_code(i); |
| 4972 sdc1(reg, MemOperand(sp, i * kDoubleSize)); | 4973 sdc1(reg, MemOperand(sp, i * kDoubleSize)); |
| 4973 } | 4974 } |
| 4974 } | 4975 } |
| 4975 | 4976 |
| 4976 // Reserve place for the return address, stack space and an optional slot | 4977 // Reserve place for the return address, stack space and an optional slot |
| 4977 // (used by the DirectCEntryStub to hold the return value if a struct is | 4978 // (used by the DirectCEntryStub to hold the return value if a struct is |
| 4978 // returned) and align the frame preparing for calling the runtime function. | 4979 // returned) and align the frame preparing for calling the runtime function. |
| 4979 DCHECK(stack_space >= 0); | 4980 DCHECK(stack_space >= 0); |
| 4980 Subu(sp, sp, Operand((stack_space + 2) * kPointerSize)); | 4981 Subu(sp, sp, Operand((stack_space + 2) * kPointerSize)); |
| 4981 if (frame_alignment > 0) { | 4982 if (frame_alignment > 0) { |
| 4982 DCHECK(IsPowerOf2(frame_alignment)); | 4983 DCHECK(base::bits::IsPowerOfTwo32(frame_alignment)); |
| 4983 And(sp, sp, Operand(-frame_alignment)); // Align stack. | 4984 And(sp, sp, Operand(-frame_alignment)); // Align stack. |
| 4984 } | 4985 } |
| 4985 | 4986 |
| 4986 // Set the exit frame sp value to point just before the return address | 4987 // Set the exit frame sp value to point just before the return address |
| 4987 // location. | 4988 // location. |
| 4988 addiu(at, sp, kPointerSize); | 4989 addiu(at, sp, kPointerSize); |
| 4989 sw(at, MemOperand(fp, ExitFrameConstants::kSPOffset)); | 4990 sw(at, MemOperand(fp, ExitFrameConstants::kSPOffset)); |
| 4990 } | 4991 } |
| 4991 | 4992 |
| 4992 | 4993 |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5067 } | 5068 } |
| 5068 | 5069 |
| 5069 | 5070 |
| 5070 void MacroAssembler::AssertStackIsAligned() { | 5071 void MacroAssembler::AssertStackIsAligned() { |
| 5071 if (emit_debug_code()) { | 5072 if (emit_debug_code()) { |
| 5072 const int frame_alignment = ActivationFrameAlignment(); | 5073 const int frame_alignment = ActivationFrameAlignment(); |
| 5073 const int frame_alignment_mask = frame_alignment - 1; | 5074 const int frame_alignment_mask = frame_alignment - 1; |
| 5074 | 5075 |
| 5075 if (frame_alignment > kPointerSize) { | 5076 if (frame_alignment > kPointerSize) { |
| 5076 Label alignment_as_expected; | 5077 Label alignment_as_expected; |
| 5077 DCHECK(IsPowerOf2(frame_alignment)); | 5078 DCHECK(base::bits::IsPowerOfTwo32(frame_alignment)); |
| 5078 andi(at, sp, frame_alignment_mask); | 5079 andi(at, sp, frame_alignment_mask); |
| 5079 Branch(&alignment_as_expected, eq, at, Operand(zero_reg)); | 5080 Branch(&alignment_as_expected, eq, at, Operand(zero_reg)); |
| 5080 // Don't use Check here, as it will call Runtime_Abort re-entering here. | 5081 // Don't use Check here, as it will call Runtime_Abort re-entering here. |
| 5081 stop("Unexpected stack alignment"); | 5082 stop("Unexpected stack alignment"); |
| 5082 bind(&alignment_as_expected); | 5083 bind(&alignment_as_expected); |
| 5083 } | 5084 } |
| 5084 } | 5085 } |
| 5085 } | 5086 } |
| 5086 | 5087 |
| 5087 | 5088 |
| (...skipping 380 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5468 // mips, even though those argument slots are not normally used. | 5469 // mips, even though those argument slots are not normally used. |
| 5469 // Remaining arguments are pushed on the stack, above (higher address than) | 5470 // Remaining arguments are pushed on the stack, above (higher address than) |
| 5470 // the argument slots. | 5471 // the argument slots. |
| 5471 int stack_passed_arguments = CalculateStackPassedWords( | 5472 int stack_passed_arguments = CalculateStackPassedWords( |
| 5472 num_reg_arguments, num_double_arguments); | 5473 num_reg_arguments, num_double_arguments); |
| 5473 if (frame_alignment > kPointerSize) { | 5474 if (frame_alignment > kPointerSize) { |
| 5474 // Make stack end at alignment and make room for num_arguments - 4 words | 5475 // Make stack end at alignment and make room for num_arguments - 4 words |
| 5475 // and the original value of sp. | 5476 // and the original value of sp. |
| 5476 mov(scratch, sp); | 5477 mov(scratch, sp); |
| 5477 Subu(sp, sp, Operand((stack_passed_arguments + 1) * kPointerSize)); | 5478 Subu(sp, sp, Operand((stack_passed_arguments + 1) * kPointerSize)); |
| 5478 DCHECK(IsPowerOf2(frame_alignment)); | 5479 DCHECK(base::bits::IsPowerOfTwo32(frame_alignment)); |
| 5479 And(sp, sp, Operand(-frame_alignment)); | 5480 And(sp, sp, Operand(-frame_alignment)); |
| 5480 sw(scratch, MemOperand(sp, stack_passed_arguments * kPointerSize)); | 5481 sw(scratch, MemOperand(sp, stack_passed_arguments * kPointerSize)); |
| 5481 } else { | 5482 } else { |
| 5482 Subu(sp, sp, Operand(stack_passed_arguments * kPointerSize)); | 5483 Subu(sp, sp, Operand(stack_passed_arguments * kPointerSize)); |
| 5483 } | 5484 } |
| 5484 } | 5485 } |
| 5485 | 5486 |
| 5486 | 5487 |
| 5487 void MacroAssembler::PrepareCallCFunction(int num_reg_arguments, | 5488 void MacroAssembler::PrepareCallCFunction(int num_reg_arguments, |
| 5488 Register scratch) { | 5489 Register scratch) { |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5525 // running in the simulator. The simulator has its own alignment check which | 5526 // running in the simulator. The simulator has its own alignment check which |
| 5526 // provides more information. | 5527 // provides more information. |
| 5527 // The argument stots are presumed to have been set up by | 5528 // The argument stots are presumed to have been set up by |
| 5528 // PrepareCallCFunction. The C function must be called via t9, for mips ABI. | 5529 // PrepareCallCFunction. The C function must be called via t9, for mips ABI. |
| 5529 | 5530 |
| 5530 #if V8_HOST_ARCH_MIPS | 5531 #if V8_HOST_ARCH_MIPS |
| 5531 if (emit_debug_code()) { | 5532 if (emit_debug_code()) { |
| 5532 int frame_alignment = base::OS::ActivationFrameAlignment(); | 5533 int frame_alignment = base::OS::ActivationFrameAlignment(); |
| 5533 int frame_alignment_mask = frame_alignment - 1; | 5534 int frame_alignment_mask = frame_alignment - 1; |
| 5534 if (frame_alignment > kPointerSize) { | 5535 if (frame_alignment > kPointerSize) { |
| 5535 DCHECK(IsPowerOf2(frame_alignment)); | 5536 DCHECK(base::bits::IsPowerOfTwo32(frame_alignment)); |
| 5536 Label alignment_as_expected; | 5537 Label alignment_as_expected; |
| 5537 And(at, sp, Operand(frame_alignment_mask)); | 5538 And(at, sp, Operand(frame_alignment_mask)); |
| 5538 Branch(&alignment_as_expected, eq, at, Operand(zero_reg)); | 5539 Branch(&alignment_as_expected, eq, at, Operand(zero_reg)); |
| 5539 // Don't use Check here, as it will call Runtime_Abort possibly | 5540 // Don't use Check here, as it will call Runtime_Abort possibly |
| 5540 // re-entering here. | 5541 // re-entering here. |
| 5541 stop("Unexpected alignment in CallCFunction"); | 5542 stop("Unexpected alignment in CallCFunction"); |
| 5542 bind(&alignment_as_expected); | 5543 bind(&alignment_as_expected); |
| 5543 } | 5544 } |
| 5544 } | 5545 } |
| 5545 #endif // V8_HOST_ARCH_MIPS | 5546 #endif // V8_HOST_ARCH_MIPS |
| (...skipping 570 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6116 } | 6117 } |
| 6117 if (ms.shift() > 0) sra(result, result, ms.shift()); | 6118 if (ms.shift() > 0) sra(result, result, ms.shift()); |
| 6118 srl(at, dividend, 31); | 6119 srl(at, dividend, 31); |
| 6119 Addu(result, result, Operand(at)); | 6120 Addu(result, result, Operand(at)); |
| 6120 } | 6121 } |
| 6121 | 6122 |
| 6122 | 6123 |
| 6123 } } // namespace v8::internal | 6124 } } // namespace v8::internal |
| 6124 | 6125 |
| 6125 #endif // V8_TARGET_ARCH_MIPS | 6126 #endif // V8_TARGET_ARCH_MIPS |
| OLD | NEW |