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

Side by Side Diff: src/mips/simulator-mips.cc

Issue 14241029: Update arm and mips simulator to also use cmath (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 7 years, 8 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
« no previous file with comments | « src/arm/simulator-arm.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2011 the V8 project authors. All rights reserved. 1 // Copyright 2011 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution 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 // * Redistributions of source code must retain the above copyright 6 // * Redistributions 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 // * Redistributions in binary form must reproduce the above 8 // * Redistributions 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
11 // with the distribution. 11 // with the distribution.
12 // * Neither the name of Google Inc. nor the names of its 12 // * Neither the name of Google Inc. nor the names of its
13 // contributors may be used to endorse or promote products derived 13 // contributors may be used to endorse or promote products derived
14 // from this software without specific prior written permission. 14 // from this software without specific prior written permission.
15 // 15 //
16 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 16 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 17 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 18 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 19 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
20 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 20 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 21 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
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 #include <math.h>
30 #include <limits.h> 29 #include <limits.h>
30 #include <cmath>
31 #include <cstdarg> 31 #include <cstdarg>
32 #include "v8.h" 32 #include "v8.h"
33 33
34 #if defined(V8_TARGET_ARCH_MIPS) 34 #if defined(V8_TARGET_ARCH_MIPS)
35 35
36 #include "cpu.h" 36 #include "cpu.h"
37 #include "disasm.h" 37 #include "disasm.h"
38 #include "assembler.h" 38 #include "assembler.h"
39 #include "globals.h" // Need the BitCast. 39 #include "globals.h" // Need the BitCast.
40 #include "mips/constants-mips.h" 40 #include "mips/constants-mips.h"
(...skipping 1107 matching lines...) Expand 10 before | Expand all | Expand 10 after
1148 bool Simulator::test_fcsr_bit(uint32_t cc) { 1148 bool Simulator::test_fcsr_bit(uint32_t cc) {
1149 return FCSR_ & (1 << cc); 1149 return FCSR_ & (1 << cc);
1150 } 1150 }
1151 1151
1152 1152
1153 // Sets the rounding error codes in FCSR based on the result of the rounding. 1153 // Sets the rounding error codes in FCSR based on the result of the rounding.
1154 // Returns true if the operation was invalid. 1154 // Returns true if the operation was invalid.
1155 bool Simulator::set_fcsr_round_error(double original, double rounded) { 1155 bool Simulator::set_fcsr_round_error(double original, double rounded) {
1156 bool ret = false; 1156 bool ret = false;
1157 1157
1158 if (!isfinite(original) || !isfinite(rounded)) { 1158 if (!std::isfinite(original) || !std::isfinite(rounded)) {
1159 set_fcsr_bit(kFCSRInvalidOpFlagBit, true); 1159 set_fcsr_bit(kFCSRInvalidOpFlagBit, true);
1160 ret = true; 1160 ret = true;
1161 } 1161 }
1162 1162
1163 if (original != rounded) { 1163 if (original != rounded) {
1164 set_fcsr_bit(kFCSRInexactFlagBit, true); 1164 set_fcsr_bit(kFCSRInexactFlagBit, true);
1165 } 1165 }
1166 1166
1167 if (rounded < DBL_MIN && rounded > -DBL_MIN && rounded != 0) { 1167 if (rounded < DBL_MIN && rounded > -DBL_MIN && rounded != 0) {
1168 set_fcsr_bit(kFCSRUnderflowFlagBit, true); 1168 set_fcsr_bit(kFCSRUnderflowFlagBit, true);
(...skipping 891 matching lines...) Expand 10 before | Expand all | Expand 10 after
2060 case MOV_D: 2060 case MOV_D:
2061 set_fpu_register_double(fd_reg, fs); 2061 set_fpu_register_double(fd_reg, fs);
2062 break; 2062 break;
2063 case NEG_D: 2063 case NEG_D:
2064 set_fpu_register_double(fd_reg, -fs); 2064 set_fpu_register_double(fd_reg, -fs);
2065 break; 2065 break;
2066 case SQRT_D: 2066 case SQRT_D:
2067 set_fpu_register_double(fd_reg, sqrt(fs)); 2067 set_fpu_register_double(fd_reg, sqrt(fs));
2068 break; 2068 break;
2069 case C_UN_D: 2069 case C_UN_D:
2070 set_fcsr_bit(fcsr_cc, isnan(fs) || isnan(ft)); 2070 set_fcsr_bit(fcsr_cc, std::isnan(fs) || std::isnan(ft));
2071 break; 2071 break;
2072 case C_EQ_D: 2072 case C_EQ_D:
2073 set_fcsr_bit(fcsr_cc, (fs == ft)); 2073 set_fcsr_bit(fcsr_cc, (fs == ft));
2074 break; 2074 break;
2075 case C_UEQ_D: 2075 case C_UEQ_D:
2076 set_fcsr_bit(fcsr_cc, (fs == ft) || (isnan(fs) || isnan(ft))); 2076 set_fcsr_bit(fcsr_cc,
2077 (fs == ft) || (std::isnan(fs) || std::isnan(ft)));
2077 break; 2078 break;
2078 case C_OLT_D: 2079 case C_OLT_D:
2079 set_fcsr_bit(fcsr_cc, (fs < ft)); 2080 set_fcsr_bit(fcsr_cc, (fs < ft));
2080 break; 2081 break;
2081 case C_ULT_D: 2082 case C_ULT_D:
2082 set_fcsr_bit(fcsr_cc, (fs < ft) || (isnan(fs) || isnan(ft))); 2083 set_fcsr_bit(fcsr_cc,
2084 (fs < ft) || (std::isnan(fs) || std::isnan(ft)));
2083 break; 2085 break;
2084 case C_OLE_D: 2086 case C_OLE_D:
2085 set_fcsr_bit(fcsr_cc, (fs <= ft)); 2087 set_fcsr_bit(fcsr_cc, (fs <= ft));
2086 break; 2088 break;
2087 case C_ULE_D: 2089 case C_ULE_D:
2088 set_fcsr_bit(fcsr_cc, (fs <= ft) || (isnan(fs) || isnan(ft))); 2090 set_fcsr_bit(fcsr_cc,
2091 (fs <= ft) || (std::isnan(fs) || std::isnan(ft)));
2089 break; 2092 break;
2090 case CVT_W_D: // Convert double to word. 2093 case CVT_W_D: // Convert double to word.
2091 // Rounding modes are not yet supported. 2094 // Rounding modes are not yet supported.
2092 ASSERT((FCSR_ & 3) == 0); 2095 ASSERT((FCSR_ & 3) == 0);
2093 // In rounding mode 0 it should behave like ROUND. 2096 // In rounding mode 0 it should behave like ROUND.
2094 case ROUND_W_D: // Round double to word (round half to even). 2097 case ROUND_W_D: // Round double to word (round half to even).
2095 { 2098 {
2096 double rounded = floor(fs + 0.5); 2099 double rounded = floor(fs + 0.5);
2097 int32_t result = static_cast<int32_t>(rounded); 2100 int32_t result = static_cast<int32_t>(rounded);
2098 if ((result & 1) != 0 && result - fs == 0.5) { 2101 if ((result & 1) != 0 && result - fs == 0.5) {
(...skipping 800 matching lines...) Expand 10 before | Expand all | Expand 10 after
2899 } 2902 }
2900 2903
2901 2904
2902 #undef UNSUPPORTED 2905 #undef UNSUPPORTED
2903 2906
2904 } } // namespace v8::internal 2907 } } // namespace v8::internal
2905 2908
2906 #endif // USE_SIMULATOR 2909 #endif // USE_SIMULATOR
2907 2910
2908 #endif // V8_TARGET_ARCH_MIPS 2911 #endif // V8_TARGET_ARCH_MIPS
OLDNEW
« no previous file with comments | « src/arm/simulator-arm.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698