| OLD | NEW |
| 1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 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> | 5 #include <limits.h> |
| 6 #include <stdarg.h> | 6 #include <stdarg.h> |
| 7 #include <stdlib.h> | 7 #include <stdlib.h> |
| 8 #include <cmath> | 8 #include <cmath> |
| 9 | 9 |
| 10 #if V8_TARGET_ARCH_MIPS64 | 10 #if V8_TARGET_ARCH_MIPS64 |
| (...skipping 1142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1153 DCHECK((fpureg >= 0) && (fpureg < kNumFPURegisters)); | 1153 DCHECK((fpureg >= 0) && (fpureg < kNumFPURegisters)); |
| 1154 return *bit_cast<double*>(&FPUregisters_[fpureg]); | 1154 return *bit_cast<double*>(&FPUregisters_[fpureg]); |
| 1155 } | 1155 } |
| 1156 | 1156 |
| 1157 | 1157 |
| 1158 // Runtime FP routines take up to two double arguments and zero | 1158 // Runtime FP routines take up to two double arguments and zero |
| 1159 // or one integer arguments. All are constructed here, | 1159 // or one integer arguments. All are constructed here, |
| 1160 // from a0-a3 or f12 and f13 (n64), or f14 (O32). | 1160 // from a0-a3 or f12 and f13 (n64), or f14 (O32). |
| 1161 void Simulator::GetFpArgs(double* x, double* y, int32_t* z) { | 1161 void Simulator::GetFpArgs(double* x, double* y, int32_t* z) { |
| 1162 if (!IsMipsSoftFloatABI) { | 1162 if (!IsMipsSoftFloatABI) { |
| 1163 const int fparg2 = (kMipsAbi == kN64) ? 13 : 14; | 1163 const int fparg2 = 13; |
| 1164 *x = get_fpu_register_double(12); | 1164 *x = get_fpu_register_double(12); |
| 1165 *y = get_fpu_register_double(fparg2); | 1165 *y = get_fpu_register_double(fparg2); |
| 1166 *z = static_cast<int32_t>(get_register(a2)); | 1166 *z = static_cast<int32_t>(get_register(a2)); |
| 1167 } else { | 1167 } else { |
| 1168 // TODO(plind): bad ABI stuff, refactor or remove. | 1168 // TODO(plind): bad ABI stuff, refactor or remove. |
| 1169 // We use a char buffer to get around the strict-aliasing rules which | 1169 // We use a char buffer to get around the strict-aliasing rules which |
| 1170 // otherwise allow the compiler to optimize away the copy. | 1170 // otherwise allow the compiler to optimize away the copy. |
| 1171 char buffer[sizeof(*x)]; | 1171 char buffer[sizeof(*x)]; |
| 1172 int32_t* reg_buffer = reinterpret_cast<int32_t*>(buffer); | 1172 int32_t* reg_buffer = reinterpret_cast<int32_t*>(buffer); |
| 1173 | 1173 |
| (...skipping 828 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2002 uint32_t code = (func == BREAK) ? instr->Bits(25, 6) : -1; | 2002 uint32_t code = (func == BREAK) ? instr->Bits(25, 6) : -1; |
| 2003 // We first check if we met a call_rt_redirected. | 2003 // We first check if we met a call_rt_redirected. |
| 2004 if (instr->InstructionBits() == rtCallRedirInstr) { | 2004 if (instr->InstructionBits() == rtCallRedirInstr) { |
| 2005 Redirection* redirection = Redirection::FromSwiInstruction(instr); | 2005 Redirection* redirection = Redirection::FromSwiInstruction(instr); |
| 2006 int64_t arg0 = get_register(a0); | 2006 int64_t arg0 = get_register(a0); |
| 2007 int64_t arg1 = get_register(a1); | 2007 int64_t arg1 = get_register(a1); |
| 2008 int64_t arg2 = get_register(a2); | 2008 int64_t arg2 = get_register(a2); |
| 2009 int64_t arg3 = get_register(a3); | 2009 int64_t arg3 = get_register(a3); |
| 2010 int64_t arg4, arg5; | 2010 int64_t arg4, arg5; |
| 2011 | 2011 |
| 2012 if (kMipsAbi == kN64) { | 2012 arg4 = get_register(a4); // Abi n64 register a4. |
| 2013 arg4 = get_register(a4); // Abi n64 register a4. | 2013 arg5 = get_register(a5); // Abi n64 register a5. |
| 2014 arg5 = get_register(a5); // Abi n64 register a5. | 2014 |
| 2015 } else { // Abi O32. | |
| 2016 int64_t* stack_pointer = reinterpret_cast<int64_t*>(get_register(sp)); | |
| 2017 // Args 4 and 5 are on the stack after the reserved space for args 0..3. | |
| 2018 arg4 = stack_pointer[4]; | |
| 2019 arg5 = stack_pointer[5]; | |
| 2020 } | |
| 2021 bool fp_call = | 2015 bool fp_call = |
| 2022 (redirection->type() == ExternalReference::BUILTIN_FP_FP_CALL) || | 2016 (redirection->type() == ExternalReference::BUILTIN_FP_FP_CALL) || |
| 2023 (redirection->type() == ExternalReference::BUILTIN_COMPARE_CALL) || | 2017 (redirection->type() == ExternalReference::BUILTIN_COMPARE_CALL) || |
| 2024 (redirection->type() == ExternalReference::BUILTIN_FP_CALL) || | 2018 (redirection->type() == ExternalReference::BUILTIN_FP_CALL) || |
| 2025 (redirection->type() == ExternalReference::BUILTIN_FP_INT_CALL); | 2019 (redirection->type() == ExternalReference::BUILTIN_FP_INT_CALL); |
| 2026 | 2020 |
| 2027 if (!IsMipsSoftFloatABI) { | 2021 if (!IsMipsSoftFloatABI) { |
| 2028 // With the hard floating point calling convention, double | 2022 // With the hard floating point calling convention, double |
| 2029 // arguments are passed in FPU registers. Fetch the arguments | 2023 // arguments are passed in FPU registers. Fetch the arguments |
| 2030 // from there and call the builtin using soft floating point | 2024 // from there and call the builtin using soft floating point |
| (...skipping 2761 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4792 set_register(s5, s5_val); | 4786 set_register(s5, s5_val); |
| 4793 set_register(s6, s6_val); | 4787 set_register(s6, s6_val); |
| 4794 set_register(s7, s7_val); | 4788 set_register(s7, s7_val); |
| 4795 set_register(gp, gp_val); | 4789 set_register(gp, gp_val); |
| 4796 set_register(sp, sp_val); | 4790 set_register(sp, sp_val); |
| 4797 set_register(fp, fp_val); | 4791 set_register(fp, fp_val); |
| 4798 } | 4792 } |
| 4799 | 4793 |
| 4800 | 4794 |
| 4801 int64_t Simulator::Call(byte* entry, int argument_count, ...) { | 4795 int64_t Simulator::Call(byte* entry, int argument_count, ...) { |
| 4802 const int kRegisterPassedArguments = (kMipsAbi == kN64) ? 8 : 4; | 4796 const int kRegisterPassedArguments = 8; |
| 4803 va_list parameters; | 4797 va_list parameters; |
| 4804 va_start(parameters, argument_count); | 4798 va_start(parameters, argument_count); |
| 4805 // Set up arguments. | 4799 // Set up arguments. |
| 4806 | 4800 |
| 4807 // First four arguments passed in registers in both ABI's. | 4801 // First four arguments passed in registers in both ABI's. |
| 4808 DCHECK(argument_count >= 4); | 4802 DCHECK(argument_count >= 4); |
| 4809 set_register(a0, va_arg(parameters, int64_t)); | 4803 set_register(a0, va_arg(parameters, int64_t)); |
| 4810 set_register(a1, va_arg(parameters, int64_t)); | 4804 set_register(a1, va_arg(parameters, int64_t)); |
| 4811 set_register(a2, va_arg(parameters, int64_t)); | 4805 set_register(a2, va_arg(parameters, int64_t)); |
| 4812 set_register(a3, va_arg(parameters, int64_t)); | 4806 set_register(a3, va_arg(parameters, int64_t)); |
| 4813 | 4807 |
| 4814 if (kMipsAbi == kN64) { | 4808 // Up to eight arguments passed in registers in N64 ABI. |
| 4815 // Up to eight arguments passed in registers in N64 ABI. | 4809 // TODO(plind): N64 ABI calls these regs a4 - a7. Clarify this. |
| 4816 // TODO(plind): N64 ABI calls these regs a4 - a7. Clarify this. | 4810 if (argument_count >= 5) set_register(a4, va_arg(parameters, int64_t)); |
| 4817 if (argument_count >= 5) set_register(a4, va_arg(parameters, int64_t)); | 4811 if (argument_count >= 6) set_register(a5, va_arg(parameters, int64_t)); |
| 4818 if (argument_count >= 6) set_register(a5, va_arg(parameters, int64_t)); | 4812 if (argument_count >= 7) set_register(a6, va_arg(parameters, int64_t)); |
| 4819 if (argument_count >= 7) set_register(a6, va_arg(parameters, int64_t)); | 4813 if (argument_count >= 8) set_register(a7, va_arg(parameters, int64_t)); |
| 4820 if (argument_count >= 8) set_register(a7, va_arg(parameters, int64_t)); | |
| 4821 } | |
| 4822 | 4814 |
| 4823 // Remaining arguments passed on stack. | 4815 // Remaining arguments passed on stack. |
| 4824 int64_t original_stack = get_register(sp); | 4816 int64_t original_stack = get_register(sp); |
| 4825 // Compute position of stack on entry to generated code. | 4817 // Compute position of stack on entry to generated code. |
| 4826 int stack_args_count = (argument_count > kRegisterPassedArguments) ? | 4818 int stack_args_count = (argument_count > kRegisterPassedArguments) ? |
| 4827 (argument_count - kRegisterPassedArguments) : 0; | 4819 (argument_count - kRegisterPassedArguments) : 0; |
| 4828 int stack_args_size = stack_args_count * sizeof(int64_t) + kCArgsSlotsSize; | 4820 int stack_args_size = stack_args_count * sizeof(int64_t) + kCArgsSlotsSize; |
| 4829 int64_t entry_stack = original_stack - stack_args_size; | 4821 int64_t entry_stack = original_stack - stack_args_size; |
| 4830 | 4822 |
| 4831 if (base::OS::ActivationFrameAlignment() != 0) { | 4823 if (base::OS::ActivationFrameAlignment() != 0) { |
| (...skipping 14 matching lines...) Expand all Loading... |
| 4846 CHECK_EQ(entry_stack, get_register(sp)); | 4838 CHECK_EQ(entry_stack, get_register(sp)); |
| 4847 set_register(sp, original_stack); | 4839 set_register(sp, original_stack); |
| 4848 | 4840 |
| 4849 int64_t result = get_register(v0); | 4841 int64_t result = get_register(v0); |
| 4850 return result; | 4842 return result; |
| 4851 } | 4843 } |
| 4852 | 4844 |
| 4853 | 4845 |
| 4854 double Simulator::CallFP(byte* entry, double d0, double d1) { | 4846 double Simulator::CallFP(byte* entry, double d0, double d1) { |
| 4855 if (!IsMipsSoftFloatABI) { | 4847 if (!IsMipsSoftFloatABI) { |
| 4856 const FPURegister fparg2 = (kMipsAbi == kN64) ? f13 : f14; | 4848 const FPURegister fparg2 = f13; |
| 4857 set_fpu_register_double(f12, d0); | 4849 set_fpu_register_double(f12, d0); |
| 4858 set_fpu_register_double(fparg2, d1); | 4850 set_fpu_register_double(fparg2, d1); |
| 4859 } else { | 4851 } else { |
| 4860 int buffer[2]; | 4852 int buffer[2]; |
| 4861 DCHECK(sizeof(buffer[0]) * 2 == sizeof(d0)); | 4853 DCHECK(sizeof(buffer[0]) * 2 == sizeof(d0)); |
| 4862 memcpy(buffer, &d0, sizeof(d0)); | 4854 memcpy(buffer, &d0, sizeof(d0)); |
| 4863 set_dw_register(a0, buffer); | 4855 set_dw_register(a0, buffer); |
| 4864 memcpy(buffer, &d1, sizeof(d1)); | 4856 memcpy(buffer, &d1, sizeof(d1)); |
| 4865 set_dw_register(a2, buffer); | 4857 set_dw_register(a2, buffer); |
| 4866 } | 4858 } |
| (...skipping 24 matching lines...) Expand all Loading... |
| 4891 } | 4883 } |
| 4892 | 4884 |
| 4893 | 4885 |
| 4894 #undef UNSUPPORTED | 4886 #undef UNSUPPORTED |
| 4895 } // namespace internal | 4887 } // namespace internal |
| 4896 } // namespace v8 | 4888 } // namespace v8 |
| 4897 | 4889 |
| 4898 #endif // USE_SIMULATOR | 4890 #endif // USE_SIMULATOR |
| 4899 | 4891 |
| 4900 #endif // V8_TARGET_ARCH_MIPS64 | 4892 #endif // V8_TARGET_ARCH_MIPS64 |
| OLD | NEW |