| OLD | NEW |
| 1 // Copyright 2013 the V8 project authors. All rights reserved. | 1 // Copyright 2013 the V8 project authors. All rights reserved. |
| 2 // Rrdistribution and use in source and binary forms, with or without | 2 // Rrdistribution 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 // * Rrdistributions of source code must retain the above copyright | 6 // * Rrdistributions 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 // * Rrdistributions in binary form must reproduce the above | 8 // * Rrdistributions 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 15 matching lines...) Expand all Loading... |
| 26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 27 | 27 |
| 28 #include <stdlib.h> | 28 #include <stdlib.h> |
| 29 | 29 |
| 30 #include "src/v8.h" | 30 #include "src/v8.h" |
| 31 | 31 |
| 32 #include "src/base/platform/platform.h" | 32 #include "src/base/platform/platform.h" |
| 33 #include "src/code-stubs.h" | 33 #include "src/code-stubs.h" |
| 34 #include "src/factory.h" | 34 #include "src/factory.h" |
| 35 #include "src/macro-assembler.h" | 35 #include "src/macro-assembler.h" |
| 36 #include "src/mips/constants-mips.h" | 36 #include "src/mips64/constants-mips64.h" |
| 37 #include "src/simulator.h" | 37 #include "src/simulator.h" |
| 38 #include "test/cctest/cctest.h" | 38 #include "test/cctest/cctest.h" |
| 39 #include "test/cctest/test-code-stubs.h" | 39 #include "test/cctest/test-code-stubs.h" |
| 40 | 40 |
| 41 using namespace v8::internal; | 41 using namespace v8::internal; |
| 42 | 42 |
| 43 #define __ masm. | 43 #define __ masm. |
| 44 | 44 |
| 45 ConvertDToIFunc MakeConvertDToIFuncTrampoline(Isolate* isolate, | 45 ConvertDToIFunc MakeConvertDToIFuncTrampoline(Isolate* isolate, |
| 46 Register source_reg, | 46 Register source_reg, |
| (...skipping 13 matching lines...) Expand all Loading... |
| 60 Label done; | 60 Label done; |
| 61 | 61 |
| 62 // Save callee save registers. | 62 // Save callee save registers. |
| 63 __ MultiPush(kCalleeSaved | ra.bit()); | 63 __ MultiPush(kCalleeSaved | ra.bit()); |
| 64 | 64 |
| 65 // For softfp, move the input value into f12. | 65 // For softfp, move the input value into f12. |
| 66 if (IsMipsSoftFloatABI) { | 66 if (IsMipsSoftFloatABI) { |
| 67 __ Move(f12, a0, a1); | 67 __ Move(f12, a0, a1); |
| 68 } | 68 } |
| 69 // Push the double argument. | 69 // Push the double argument. |
| 70 __ Subu(sp, sp, Operand(kDoubleSize)); | 70 __ Dsubu(sp, sp, Operand(kDoubleSize)); |
| 71 __ sdc1(f12, MemOperand(sp)); | 71 __ sdc1(f12, MemOperand(sp)); |
| 72 __ Move(source_reg, sp); | 72 __ Move(source_reg, sp); |
| 73 | 73 |
| 74 // Save registers make sure they don't get clobbered. | 74 // Save registers make sure they don't get clobbered. |
| 75 int source_reg_offset = kDoubleSize; | 75 int source_reg_offset = kDoubleSize; |
| 76 int reg_num = 2; | 76 int reg_num = 2; |
| 77 for (;reg_num < Register::NumAllocatableRegisters(); ++reg_num) { | 77 for (;reg_num < Register::NumAllocatableRegisters(); ++reg_num) { |
| 78 Register reg = Register::from_code(reg_num); | 78 Register reg = Register::from_code(reg_num); |
| 79 if (!reg.is(destination_reg)) { | 79 if (!reg.is(destination_reg)) { |
| 80 __ push(reg); | 80 __ push(reg); |
| 81 source_reg_offset += kPointerSize; | 81 source_reg_offset += kPointerSize; |
| 82 } | 82 } |
| 83 } | 83 } |
| 84 | 84 |
| 85 // Re-push the double argument. | 85 // Re-push the double argument. |
| 86 __ Subu(sp, sp, Operand(kDoubleSize)); | 86 __ Dsubu(sp, sp, Operand(kDoubleSize)); |
| 87 __ sdc1(f12, MemOperand(sp)); | 87 __ sdc1(f12, MemOperand(sp)); |
| 88 | 88 |
| 89 // Call through to the actual stub | 89 // Call through to the actual stub |
| 90 if (inline_fastpath) { | 90 if (inline_fastpath) { |
| 91 __ ldc1(f12, MemOperand(source_reg)); | 91 __ ldc1(f12, MemOperand(source_reg)); |
| 92 __ TryInlineTruncateDoubleToI(destination_reg, f12, &done); | 92 __ TryInlineTruncateDoubleToI(destination_reg, f12, &done); |
| 93 if (destination_reg.is(source_reg) && !source_reg.is(sp)) { | 93 if (destination_reg.is(source_reg) && !source_reg.is(sp)) { |
| 94 // Restore clobbered source_reg. | 94 // Restore clobbered source_reg. |
| 95 __ Addu(source_reg, sp, Operand(source_reg_offset)); | 95 __ Daddu(source_reg, sp, Operand(source_reg_offset)); |
| 96 } | 96 } |
| 97 } | 97 } |
| 98 __ Call(start, RelocInfo::EXTERNAL_REFERENCE); | 98 __ Call(start, RelocInfo::EXTERNAL_REFERENCE); |
| 99 __ bind(&done); | 99 __ bind(&done); |
| 100 | 100 |
| 101 __ Addu(sp, sp, Operand(kDoubleSize)); | 101 __ Daddu(sp, sp, Operand(kDoubleSize)); |
| 102 | 102 |
| 103 // Make sure no registers have been unexpectedly clobbered | 103 // Make sure no registers have been unexpectedly clobbered |
| 104 for (--reg_num; reg_num >= 2; --reg_num) { | 104 for (--reg_num; reg_num >= 2; --reg_num) { |
| 105 Register reg = Register::from_code(reg_num); | 105 Register reg = Register::from_code(reg_num); |
| 106 if (!reg.is(destination_reg)) { | 106 if (!reg.is(destination_reg)) { |
| 107 __ lw(at, MemOperand(sp, 0)); | 107 __ lw(at, MemOperand(sp, 0)); |
| 108 __ Assert(eq, kRegisterWasClobbered, reg, Operand(at)); | 108 __ Assert(eq, kRegisterWasClobbered, reg, Operand(at)); |
| 109 __ Addu(sp, sp, Operand(kPointerSize)); | 109 __ Daddu(sp, sp, Operand(kPointerSize)); |
| 110 } | 110 } |
| 111 } | 111 } |
| 112 | 112 |
| 113 __ Addu(sp, sp, Operand(kDoubleSize)); | 113 __ Daddu(sp, sp, Operand(kDoubleSize)); |
| 114 | 114 |
| 115 __ Move(v0, destination_reg); | 115 __ Move(v0, destination_reg); |
| 116 Label ok; | 116 Label ok; |
| 117 __ Branch(&ok, eq, v0, Operand(zero_reg)); | 117 __ Branch(&ok, eq, v0, Operand(zero_reg)); |
| 118 __ bind(&ok); | 118 __ bind(&ok); |
| 119 | 119 |
| 120 // Restore callee save registers. | 120 // Restore callee save registers. |
| 121 __ MultiPop(kCalleeSaved | ra.bit()); | 121 __ MultiPop(kCalleeSaved | ra.bit()); |
| 122 | 122 |
| 123 Label ok1; | 123 Label ok1; |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 158 HandleScope scope(isolate); | 158 HandleScope scope(isolate); |
| 159 | 159 |
| 160 #if DEBUG | 160 #if DEBUG |
| 161 // Verify that the tests actually work with the C version. In the release | 161 // Verify that the tests actually work with the C version. In the release |
| 162 // code, the compiler optimizes it away because it's all constant, but does it | 162 // code, the compiler optimizes it away because it's all constant, but does it |
| 163 // wrong, triggering an assert on gcc. | 163 // wrong, triggering an assert on gcc. |
| 164 RunAllTruncationTests(&ConvertDToICVersion); | 164 RunAllTruncationTests(&ConvertDToICVersion); |
| 165 #endif | 165 #endif |
| 166 | 166 |
| 167 Register source_registers[] = { | 167 Register source_registers[] = { |
| 168 sp, v0, v1, a0, a1, a2, a3, t0, t1, t2, t3, t4, t5}; | 168 sp, v0, v1, a0, a1, a2, a3, a4, a5, a6, a7, t0, t1}; |
| 169 Register dest_registers[] = { | 169 Register dest_registers[] = { |
| 170 v0, v1, a0, a1, a2, a3, t0, t1, t2, t3, t4, t5}; | 170 v0, v1, a0, a1, a2, a3, a4, a5, a6, a7, t0, t1}; |
| 171 | 171 |
| 172 for (size_t s = 0; s < sizeof(source_registers) / sizeof(Register); s++) { | 172 for (size_t s = 0; s < sizeof(source_registers) / sizeof(Register); s++) { |
| 173 for (size_t d = 0; d < sizeof(dest_registers) / sizeof(Register); d++) { | 173 for (size_t d = 0; d < sizeof(dest_registers) / sizeof(Register); d++) { |
| 174 RunAllTruncationTests( | 174 RunAllTruncationTests( |
| 175 RunGeneratedCodeCallWrapper, | 175 RunGeneratedCodeCallWrapper, |
| 176 MakeConvertDToIFuncTrampoline(isolate, | 176 MakeConvertDToIFuncTrampoline(isolate, |
| 177 source_registers[s], | 177 source_registers[s], |
| 178 dest_registers[d], | 178 dest_registers[d], |
| 179 false)); | 179 false)); |
| 180 RunAllTruncationTests( | 180 RunAllTruncationTests( |
| 181 RunGeneratedCodeCallWrapper, | 181 RunGeneratedCodeCallWrapper, |
| 182 MakeConvertDToIFuncTrampoline(isolate, | 182 MakeConvertDToIFuncTrampoline(isolate, |
| 183 source_registers[s], | 183 source_registers[s], |
| 184 dest_registers[d], | 184 dest_registers[d], |
| 185 true)); | 185 true)); |
| 186 } | 186 } |
| 187 } | 187 } |
| 188 } | 188 } |
| OLD | NEW |