| 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 16 matching lines...) Expand all Loading... |
| 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/mips/constants-mips.h" |
| 37 #include "src/register-configuration.h" |
| 37 #include "src/simulator.h" | 38 #include "src/simulator.h" |
| 38 #include "test/cctest/cctest.h" | 39 #include "test/cctest/cctest.h" |
| 39 #include "test/cctest/test-code-stubs.h" | 40 #include "test/cctest/test-code-stubs.h" |
| 40 | 41 |
| 41 using namespace v8::internal; | 42 using namespace v8::internal; |
| 42 | 43 |
| 43 #define __ masm. | 44 #define __ masm. |
| 44 | 45 |
| 45 ConvertDToIFunc MakeConvertDToIFuncTrampoline(Isolate* isolate, | 46 ConvertDToIFunc MakeConvertDToIFuncTrampoline(Isolate* isolate, |
| 46 Register source_reg, | 47 Register source_reg, |
| (...skipping 25 matching lines...) Expand all Loading... |
| 72 __ Move(f12, a0, a1); | 73 __ Move(f12, a0, a1); |
| 73 } | 74 } |
| 74 // Push the double argument. | 75 // Push the double argument. |
| 75 __ Subu(sp, sp, Operand(kDoubleSize)); | 76 __ Subu(sp, sp, Operand(kDoubleSize)); |
| 76 __ sdc1(f12, MemOperand(sp)); | 77 __ sdc1(f12, MemOperand(sp)); |
| 77 __ Move(source_reg, sp); | 78 __ Move(source_reg, sp); |
| 78 | 79 |
| 79 // Save registers make sure they don't get clobbered. | 80 // Save registers make sure they don't get clobbered. |
| 80 int source_reg_offset = kDoubleSize; | 81 int source_reg_offset = kDoubleSize; |
| 81 int reg_num = 2; | 82 int reg_num = 2; |
| 82 for (; reg_num < Register::NumAllocatableRegisters(); ++reg_num) { | 83 for (; reg_num < Register::kNumRegisters; ++reg_num) { |
| 83 Register reg = Register::from_code(reg_num); | 84 Register reg = Register::from_code(reg_num); |
| 84 if (!reg.is(destination_reg)) { | 85 if (reg.IsAllocatable()) { |
| 85 __ push(reg); | 86 if (!reg.is(destination_reg)) { |
| 86 source_reg_offset += kPointerSize; | 87 __ push(reg); |
| 88 source_reg_offset += kPointerSize; |
| 89 } |
| 87 } | 90 } |
| 88 } | 91 } |
| 89 | 92 |
| 90 // Re-push the double argument. | 93 // Re-push the double argument. |
| 91 __ Subu(sp, sp, Operand(kDoubleSize)); | 94 __ Subu(sp, sp, Operand(kDoubleSize)); |
| 92 __ sdc1(f12, MemOperand(sp)); | 95 __ sdc1(f12, MemOperand(sp)); |
| 93 | 96 |
| 94 // Call through to the actual stub | 97 // Call through to the actual stub |
| 95 if (inline_fastpath) { | 98 if (inline_fastpath) { |
| 96 __ ldc1(f12, MemOperand(source_reg)); | 99 __ ldc1(f12, MemOperand(source_reg)); |
| 97 __ TryInlineTruncateDoubleToI(destination_reg, f12, &done); | 100 __ TryInlineTruncateDoubleToI(destination_reg, f12, &done); |
| 98 if (destination_reg.is(source_reg) && !source_reg.is(sp)) { | 101 if (destination_reg.is(source_reg) && !source_reg.is(sp)) { |
| 99 // Restore clobbered source_reg. | 102 // Restore clobbered source_reg. |
| 100 __ Addu(source_reg, sp, Operand(source_reg_offset)); | 103 __ Addu(source_reg, sp, Operand(source_reg_offset)); |
| 101 } | 104 } |
| 102 } | 105 } |
| 103 __ Call(start, RelocInfo::EXTERNAL_REFERENCE); | 106 __ Call(start, RelocInfo::EXTERNAL_REFERENCE); |
| 104 __ bind(&done); | 107 __ bind(&done); |
| 105 | 108 |
| 106 __ Addu(sp, sp, Operand(kDoubleSize)); | 109 __ Addu(sp, sp, Operand(kDoubleSize)); |
| 107 | 110 |
| 108 // Make sure no registers have been unexpectedly clobbered | 111 // Make sure no registers have been unexpectedly clobbered |
| 109 for (--reg_num; reg_num >= 2; --reg_num) { | 112 for (--reg_num; reg_num >= 2; --reg_num) { |
| 110 Register reg = Register::from_code(reg_num); | 113 Register reg = Register::from_code(reg_num); |
| 111 if (!reg.is(destination_reg)) { | 114 if (reg.IsAllocatable()) { |
| 112 __ lw(at, MemOperand(sp, 0)); | 115 if (!reg.is(destination_reg)) { |
| 113 __ Assert(eq, kRegisterWasClobbered, reg, Operand(at)); | 116 __ lw(at, MemOperand(sp, 0)); |
| 114 __ Addu(sp, sp, Operand(kPointerSize)); | 117 __ Assert(eq, kRegisterWasClobbered, reg, Operand(at)); |
| 118 __ Addu(sp, sp, Operand(kPointerSize)); |
| 119 } |
| 115 } | 120 } |
| 116 } | 121 } |
| 117 | 122 |
| 118 __ Addu(sp, sp, Operand(kDoubleSize)); | 123 __ Addu(sp, sp, Operand(kDoubleSize)); |
| 119 | 124 |
| 120 __ Move(v0, destination_reg); | 125 __ Move(v0, destination_reg); |
| 121 Label ok; | 126 Label ok; |
| 122 __ Branch(&ok, eq, v0, Operand(zero_reg)); | 127 __ Branch(&ok, eq, v0, Operand(zero_reg)); |
| 123 __ bind(&ok); | 128 __ bind(&ok); |
| 124 | 129 |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 187 false)); | 192 false)); |
| 188 RunAllTruncationTests( | 193 RunAllTruncationTests( |
| 189 RunGeneratedCodeCallWrapper, | 194 RunGeneratedCodeCallWrapper, |
| 190 MakeConvertDToIFuncTrampoline(isolate, | 195 MakeConvertDToIFuncTrampoline(isolate, |
| 191 source_registers[s], | 196 source_registers[s], |
| 192 dest_registers[d], | 197 dest_registers[d], |
| 193 true)); | 198 true)); |
| 194 } | 199 } |
| 195 } | 200 } |
| 196 } | 201 } |
| OLD | NEW |