OLD | NEW |
---|---|
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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 |
(...skipping 1186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1197 } | 1197 } |
1198 | 1198 |
1199 | 1199 |
1200 TEST(MIPS14) { | 1200 TEST(MIPS14) { |
1201 // Test round, floor, ceil, trunc, cvt. | 1201 // Test round, floor, ceil, trunc, cvt. |
1202 CcTest::InitializeVM(); | 1202 CcTest::InitializeVM(); |
1203 Isolate* isolate = CcTest::i_isolate(); | 1203 Isolate* isolate = CcTest::i_isolate(); |
1204 HandleScope scope(isolate); | 1204 HandleScope scope(isolate); |
1205 | 1205 |
1206 #define ROUND_STRUCT_ELEMENT(x) \ | 1206 #define ROUND_STRUCT_ELEMENT(x) \ |
1207 uint32_t x##_isNaN2008; \ | |
1207 int32_t x##_up_out; \ | 1208 int32_t x##_up_out; \ |
1208 int32_t x##_down_out; \ | 1209 int32_t x##_down_out; \ |
1209 int32_t neg_##x##_up_out; \ | 1210 int32_t neg_##x##_up_out; \ |
1210 int32_t neg_##x##_down_out; \ | 1211 int32_t neg_##x##_down_out; \ |
1211 uint32_t x##_err1_out; \ | 1212 uint32_t x##_err1_out; \ |
1212 uint32_t x##_err2_out; \ | 1213 uint32_t x##_err2_out; \ |
1213 uint32_t x##_err3_out; \ | 1214 uint32_t x##_err3_out; \ |
1214 uint32_t x##_err4_out; \ | 1215 uint32_t x##_err4_out; \ |
1215 int32_t x##_invalid_result; | 1216 int32_t x##_invalid_result; |
1216 | 1217 |
(...skipping 17 matching lines...) Expand all Loading... | |
1234 | 1235 |
1235 #undef ROUND_STRUCT_ELEMENT | 1236 #undef ROUND_STRUCT_ELEMENT |
1236 | 1237 |
1237 MacroAssembler assm(isolate, NULL, 0, v8::internal::CodeObjectRequired::kYes); | 1238 MacroAssembler assm(isolate, NULL, 0, v8::internal::CodeObjectRequired::kYes); |
1238 | 1239 |
1239 // Save FCSR. | 1240 // Save FCSR. |
1240 __ cfc1(a1, FCSR); | 1241 __ cfc1(a1, FCSR); |
1241 // Disable FPU exceptions. | 1242 // Disable FPU exceptions. |
1242 __ ctc1(zero_reg, FCSR); | 1243 __ ctc1(zero_reg, FCSR); |
1243 #define RUN_ROUND_TEST(x) \ | 1244 #define RUN_ROUND_TEST(x) \ |
1245 __ cfc1(t0, FCSR);\ | |
1246 __ sw(t0, MemOperand(a0, offsetof(T, x##_isNaN2008))); \ | |
1244 __ ldc1(f0, MemOperand(a0, offsetof(T, round_up_in))); \ | 1247 __ ldc1(f0, MemOperand(a0, offsetof(T, round_up_in))); \ |
1245 __ x##_w_d(f0, f0); \ | 1248 __ x##_w_d(f0, f0); \ |
1246 __ swc1(f0, MemOperand(a0, offsetof(T, x##_up_out))); \ | 1249 __ swc1(f0, MemOperand(a0, offsetof(T, x##_up_out))); \ |
1247 \ | 1250 \ |
1248 __ ldc1(f0, MemOperand(a0, offsetof(T, round_down_in))); \ | 1251 __ ldc1(f0, MemOperand(a0, offsetof(T, round_down_in))); \ |
1249 __ x##_w_d(f0, f0); \ | 1252 __ x##_w_d(f0, f0); \ |
1250 __ swc1(f0, MemOperand(a0, offsetof(T, x##_down_out))); \ | 1253 __ swc1(f0, MemOperand(a0, offsetof(T, x##_down_out))); \ |
1251 \ | 1254 \ |
1252 __ ldc1(f0, MemOperand(a0, offsetof(T, neg_round_up_in))); \ | 1255 __ ldc1(f0, MemOperand(a0, offsetof(T, neg_round_up_in))); \ |
1253 __ x##_w_d(f0, f0); \ | 1256 __ x##_w_d(f0, f0); \ |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1306 t.neg_round_down_in = -123.49; | 1309 t.neg_round_down_in = -123.49; |
1307 t.err1_in = 123.51; | 1310 t.err1_in = 123.51; |
1308 t.err2_in = 1; | 1311 t.err2_in = 1; |
1309 t.err3_in = static_cast<double>(1) + 0xFFFFFFFF; | 1312 t.err3_in = static_cast<double>(1) + 0xFFFFFFFF; |
1310 t.err4_in = NAN; | 1313 t.err4_in = NAN; |
1311 | 1314 |
1312 Object* dummy = CALL_GENERATED_CODE(isolate, f, &t, 0, 0, 0, 0); | 1315 Object* dummy = CALL_GENERATED_CODE(isolate, f, &t, 0, 0, 0, 0); |
1313 USE(dummy); | 1316 USE(dummy); |
1314 | 1317 |
1315 #define GET_FPU_ERR(x) (static_cast<int>(x & kFCSRFlagMask)) | 1318 #define GET_FPU_ERR(x) (static_cast<int>(x & kFCSRFlagMask)) |
1319 #define CHECK_NAN2008(x) (x & kFCSRNaN2008FlagMask) | |
1316 #define CHECK_ROUND_RESULT(type) \ | 1320 #define CHECK_ROUND_RESULT(type) \ |
1317 CHECK(GET_FPU_ERR(t.type##_err1_out) & kFCSRInexactFlagMask); \ | 1321 CHECK(GET_FPU_ERR(t.type##_err1_out) & kFCSRInexactFlagMask); \ |
1318 CHECK_EQ(0, GET_FPU_ERR(t.type##_err2_out)); \ | 1322 CHECK_EQ(0, GET_FPU_ERR(t.type##_err2_out)); \ |
1319 CHECK(GET_FPU_ERR(t.type##_err3_out) & kFCSRInvalidOpFlagMask); \ | 1323 CHECK(GET_FPU_ERR(t.type##_err3_out) & kFCSRInvalidOpFlagMask); \ |
1320 CHECK(GET_FPU_ERR(t.type##_err4_out) & kFCSRInvalidOpFlagMask); \ | 1324 CHECK(GET_FPU_ERR(t.type##_err4_out) & kFCSRInvalidOpFlagMask); \ |
1321 CHECK_EQ(kFPUInvalidResult, static_cast<uint>(t.type##_invalid_result)); | 1325 if (CHECK_NAN2008(t.type##_isNaN2008) && kArchVariant == kMips32r6) {\ |
1326 CHECK_EQ(static_cast<int32_t>(0), t.type##_invalid_result);\ | |
1327 } else {\ | |
1328 CHECK_EQ(static_cast<int32_t>(kFPUInvalidResult), t.type##_invalid_result);\ | |
1329 } | |
1330 | |
1322 | 1331 |
1323 CHECK_ROUND_RESULT(round); | 1332 CHECK_ROUND_RESULT(round); |
1324 CHECK_ROUND_RESULT(floor); | 1333 CHECK_ROUND_RESULT(floor); |
1325 CHECK_ROUND_RESULT(ceil); | 1334 CHECK_ROUND_RESULT(ceil); |
1326 CHECK_ROUND_RESULT(cvt); | 1335 CHECK_ROUND_RESULT(cvt); |
1327 } | 1336 } |
1328 | 1337 |
1329 | 1338 |
1330 TEST(MIPS15) { | 1339 TEST(MIPS15) { |
1331 // Test chaining of label usages within instructions (issue 1644). | 1340 // Test chaining of label usages within instructions (issue 1644). |
(...skipping 628 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1960 // ----------------------mips32r2 specific tests---------------------- | 1969 // ----------------------mips32r2 specific tests---------------------- |
1961 TEST(trunc_l) { | 1970 TEST(trunc_l) { |
1962 if (IsMipsArchVariant(kMips32r2) && IsFp64Mode()) { | 1971 if (IsMipsArchVariant(kMips32r2) && IsFp64Mode()) { |
1963 CcTest::InitializeVM(); | 1972 CcTest::InitializeVM(); |
1964 Isolate* isolate = CcTest::i_isolate(); | 1973 Isolate* isolate = CcTest::i_isolate(); |
1965 HandleScope scope(isolate); | 1974 HandleScope scope(isolate); |
1966 MacroAssembler assm(isolate, NULL, 0, | 1975 MacroAssembler assm(isolate, NULL, 0, |
1967 v8::internal::CodeObjectRequired::kYes); | 1976 v8::internal::CodeObjectRequired::kYes); |
1968 const double dFPU64InvalidResult = static_cast<double>(kFPU64InvalidResult); | 1977 const double dFPU64InvalidResult = static_cast<double>(kFPU64InvalidResult); |
1969 typedef struct test_float { | 1978 typedef struct test_float { |
1979 uint32_t isNaN2008; | |
1970 double a; | 1980 double a; |
1971 float b; | 1981 float b; |
1972 int64_t c; // a trunc result | 1982 int64_t c; // a trunc result |
1973 int64_t d; // b trunc result | 1983 int64_t d; // b trunc result |
1974 }Test; | 1984 }Test; |
1975 const int kTableLength = 15; | 1985 const int kTableLength = 15; |
1976 double inputs_D[kTableLength] = { | 1986 double inputs_D[kTableLength] = { |
1977 2.1, 2.6, 2.5, 3.1, 3.6, 3.5, | 1987 2.1, 2.6, 2.5, 3.1, 3.6, 3.5, |
1978 -2.1, -2.6, -2.5, -3.1, -3.6, -3.5, | 1988 -2.1, -2.6, -2.5, -3.1, -3.6, -3.5, |
1979 2147483648.0, | 1989 2147483648.0, |
1980 std::numeric_limits<double>::quiet_NaN(), | 1990 std::numeric_limits<double>::quiet_NaN(), |
1981 std::numeric_limits<double>::infinity() | 1991 std::numeric_limits<double>::infinity() |
1982 }; | 1992 }; |
1983 float inputs_S[kTableLength] = { | 1993 float inputs_S[kTableLength] = { |
1984 2.1, 2.6, 2.5, 3.1, 3.6, 3.5, | 1994 2.1, 2.6, 2.5, 3.1, 3.6, 3.5, |
1985 -2.1, -2.6, -2.5, -3.1, -3.6, -3.5, | 1995 -2.1, -2.6, -2.5, -3.1, -3.6, -3.5, |
1986 2147483648.0, | 1996 2147483648.0, |
1987 std::numeric_limits<float>::quiet_NaN(), | 1997 std::numeric_limits<float>::quiet_NaN(), |
1988 std::numeric_limits<float>::infinity() | 1998 std::numeric_limits<float>::infinity() |
1989 }; | 1999 }; |
1990 double outputs[kTableLength] = { | 2000 double outputs[kTableLength] = { |
1991 2.0, 2.0, 2.0, 3.0, 3.0, 3.0, | 2001 2.0, 2.0, 2.0, 3.0, 3.0, 3.0, |
1992 -2.0, -2.0, -2.0, -3.0, -3.0, -3.0, | 2002 -2.0, -2.0, -2.0, -3.0, -3.0, -3.0, |
1993 2147483648.0, dFPU64InvalidResult, | 2003 2147483648.0, dFPU64InvalidResult, |
1994 dFPU64InvalidResult}; | 2004 dFPU64InvalidResult}; |
2005 double outputsNaN2008[kTableLength] = { | |
2006 2.0, 2.0, 2.0, 3.0, 3.0, 3.0, | |
2007 -2.0, -2.0, -2.0, -3.0, -3.0, -3.0, | |
2008 2147483648.0, | |
2009 0, | |
2010 dFPU64InvalidResult}; | |
1995 | 2011 |
2012 __ cfc1(t1, FCSR); | |
2013 __ sw(t1, MemOperand(a0, offsetof(Test, isNaN2008))); | |
1996 __ ldc1(f4, MemOperand(a0, offsetof(Test, a)) ); | 2014 __ ldc1(f4, MemOperand(a0, offsetof(Test, a)) ); |
1997 __ lwc1(f6, MemOperand(a0, offsetof(Test, b)) ); | 2015 __ lwc1(f6, MemOperand(a0, offsetof(Test, b)) ); |
1998 __ trunc_l_d(f8, f4); | 2016 __ trunc_l_d(f8, f4); |
1999 __ trunc_l_s(f10, f6); | 2017 __ trunc_l_s(f10, f6); |
2000 __ sdc1(f8, MemOperand(a0, offsetof(Test, c)) ); | 2018 __ sdc1(f8, MemOperand(a0, offsetof(Test, c)) ); |
2001 __ sdc1(f10, MemOperand(a0, offsetof(Test, d)) ); | 2019 __ sdc1(f10, MemOperand(a0, offsetof(Test, d)) ); |
2002 __ jr(ra); | 2020 __ jr(ra); |
2003 __ nop(); | 2021 __ nop(); |
2004 Test test; | 2022 Test test; |
2005 CodeDesc desc; | 2023 CodeDesc desc; |
2006 assm.GetCode(&desc); | 2024 assm.GetCode(&desc); |
2007 Handle<Code> code = isolate->factory()->NewCode( | 2025 Handle<Code> code = isolate->factory()->NewCode( |
2008 desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); | 2026 desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); |
2009 F3 f = FUNCTION_CAST<F3>(code->entry()); | 2027 F3 f = FUNCTION_CAST<F3>(code->entry()); |
2010 for (int i = 0; i < kTableLength; i++) { | 2028 for (int i = 0; i < kTableLength; i++) { |
2011 test.a = inputs_D[i]; | 2029 test.a = inputs_D[i]; |
2012 test.b = inputs_S[i]; | 2030 test.b = inputs_S[i]; |
2013 (CALL_GENERATED_CODE(isolate, f, &test, 0, 0, 0, 0)); | 2031 (CALL_GENERATED_CODE(isolate, f, &test, 0, 0, 0, 0)); |
2014 CHECK_EQ(test.c, outputs[i]); | 2032 if ((test.isNaN2008 & kFCSRNaN2008FlagMask) && |
2033 kArchVariant == kMips32r6) { | |
2034 CHECK_EQ(test.c, outputsNaN2008[i]); | |
2035 } else { | |
2036 CHECK_EQ(test.c, outputs[i]); | |
2037 } | |
2015 CHECK_EQ(test.d, test.c); | 2038 CHECK_EQ(test.d, test.c); |
2016 } | 2039 } |
2017 } | 2040 } |
2018 } | 2041 } |
2019 | 2042 |
2020 | 2043 |
2021 TEST(movz_movn) { | 2044 TEST(movz_movn) { |
2022 if (IsMipsArchVariant(kMips32r2)) { | 2045 if (IsMipsArchVariant(kMips32r2)) { |
2023 const int kTableLength = 4; | 2046 const int kTableLength = 4; |
2024 CcTest::InitializeVM(); | 2047 CcTest::InitializeVM(); |
(...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2266 __ nop(); | 2289 __ nop(); |
2267 Test test; | 2290 Test test; |
2268 CodeDesc desc; | 2291 CodeDesc desc; |
2269 assm.GetCode(&desc); | 2292 assm.GetCode(&desc); |
2270 Handle<Code> code = isolate->factory()->NewCode( | 2293 Handle<Code> code = isolate->factory()->NewCode( |
2271 desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); | 2294 desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); |
2272 F3 f = FUNCTION_CAST<F3>(code->entry()); | 2295 F3 f = FUNCTION_CAST<F3>(code->entry()); |
2273 for (int j = 0; j < 4; j++) { | 2296 for (int j = 0; j < 4; j++) { |
2274 test.fcsr = fcsr_inputs[j]; | 2297 test.fcsr = fcsr_inputs[j]; |
2275 for (int i = 0; i < kTableLength; i++) { | 2298 for (int i = 0; i < kTableLength; i++) { |
2299 printf("Type = %d, i = %d\n", j, i); | |
Ilija.Pavlovic1
2015/12/02 09:12:16
Should be deleted/removed?
| |
2276 test.a = inputs[i]; | 2300 test.a = inputs[i]; |
2277 (CALL_GENERATED_CODE(isolate, f, &test, 0, 0, 0, 0)); | 2301 (CALL_GENERATED_CODE(isolate, f, &test, 0, 0, 0, 0)); |
2278 CHECK_EQ(test.b, outputs[j][i]); | 2302 CHECK_EQ(test.b, outputs[j][i]); |
2279 } | 2303 } |
2280 } | 2304 } |
2281 } | 2305 } |
2282 | 2306 |
2283 | 2307 |
2284 TEST(trunc_w) { | 2308 TEST(trunc_w) { |
2285 CcTest::InitializeVM(); | 2309 CcTest::InitializeVM(); |
2286 Isolate* isolate = CcTest::i_isolate(); | 2310 Isolate* isolate = CcTest::i_isolate(); |
2287 HandleScope scope(isolate); | 2311 HandleScope scope(isolate); |
2288 MacroAssembler assm(isolate, NULL, 0, v8::internal::CodeObjectRequired::kYes); | 2312 MacroAssembler assm(isolate, NULL, 0, v8::internal::CodeObjectRequired::kYes); |
2289 | 2313 |
2290 typedef struct test_float { | 2314 typedef struct test_float { |
2315 uint32_t isNaN2008; | |
2291 double a; | 2316 double a; |
2292 float b; | 2317 float b; |
2293 int32_t c; // a trunc result | 2318 int32_t c; // a trunc result |
2294 int32_t d; // b trunc result | 2319 int32_t d; // b trunc result |
2295 }Test; | 2320 }Test; |
2296 const int kTableLength = 15; | 2321 const int kTableLength = 15; |
2297 double inputs_D[kTableLength] = { | 2322 double inputs_D[kTableLength] = { |
2298 2.1, 2.6, 2.5, 3.1, 3.6, 3.5, | 2323 2.1, 2.6, 2.5, 3.1, 3.6, 3.5, |
2299 -2.1, -2.6, -2.5, -3.1, -3.6, -3.5, | 2324 -2.1, -2.6, -2.5, -3.1, -3.6, -3.5, |
2300 2147483648.0, | 2325 2147483648.0, |
2301 std::numeric_limits<double>::quiet_NaN(), | 2326 std::numeric_limits<double>::quiet_NaN(), |
2302 std::numeric_limits<double>::infinity() | 2327 std::numeric_limits<double>::infinity() |
2303 }; | 2328 }; |
2304 float inputs_S[kTableLength] = { | 2329 float inputs_S[kTableLength] = { |
2305 2.1, 2.6, 2.5, 3.1, 3.6, 3.5, | 2330 2.1, 2.6, 2.5, 3.1, 3.6, 3.5, |
2306 -2.1, -2.6, -2.5, -3.1, -3.6, -3.5, | 2331 -2.1, -2.6, -2.5, -3.1, -3.6, -3.5, |
2307 2147483648.0, | 2332 2147483648.0, |
2308 std::numeric_limits<float>::quiet_NaN(), | 2333 std::numeric_limits<float>::quiet_NaN(), |
2309 std::numeric_limits<float>::infinity() | 2334 std::numeric_limits<float>::infinity() |
2310 }; | 2335 }; |
2311 double outputs[kTableLength] = { | 2336 double outputs[kTableLength] = { |
2312 2.0, 2.0, 2.0, 3.0, 3.0, 3.0, | 2337 2.0, 2.0, 2.0, 3.0, 3.0, 3.0, |
2313 -2.0, -2.0, -2.0, -3.0, -3.0, -3.0, | 2338 -2.0, -2.0, -2.0, -3.0, -3.0, -3.0, |
2314 kFPUInvalidResult, kFPUInvalidResult, | 2339 kFPUInvalidResult, kFPUInvalidResult, |
2315 kFPUInvalidResult}; | 2340 kFPUInvalidResult}; |
2341 double outputsNaN2008[kTableLength] = { | |
2342 2.0, 2.0, 2.0, 3.0, 3.0, 3.0, | |
2343 -2.0, -2.0, -2.0, -3.0, -3.0, -3.0, | |
2344 kFPUInvalidResult, | |
2345 0, | |
2346 kFPUInvalidResult}; | |
2316 | 2347 |
2348 __ cfc1(t1, FCSR); | |
2349 __ sw(t1, MemOperand(a0, offsetof(Test, isNaN2008))); | |
2317 __ ldc1(f4, MemOperand(a0, offsetof(Test, a)) ); | 2350 __ ldc1(f4, MemOperand(a0, offsetof(Test, a)) ); |
2318 __ lwc1(f6, MemOperand(a0, offsetof(Test, b)) ); | 2351 __ lwc1(f6, MemOperand(a0, offsetof(Test, b)) ); |
2319 __ trunc_w_d(f8, f4); | 2352 __ trunc_w_d(f8, f4); |
2320 __ trunc_w_s(f10, f6); | 2353 __ trunc_w_s(f10, f6); |
2321 __ swc1(f8, MemOperand(a0, offsetof(Test, c)) ); | 2354 __ swc1(f8, MemOperand(a0, offsetof(Test, c)) ); |
2322 __ swc1(f10, MemOperand(a0, offsetof(Test, d)) ); | 2355 __ swc1(f10, MemOperand(a0, offsetof(Test, d)) ); |
2323 __ jr(ra); | 2356 __ jr(ra); |
2324 __ nop(); | 2357 __ nop(); |
2325 Test test; | 2358 Test test; |
2326 CodeDesc desc; | 2359 CodeDesc desc; |
2327 assm.GetCode(&desc); | 2360 assm.GetCode(&desc); |
2328 Handle<Code> code = isolate->factory()->NewCode( | 2361 Handle<Code> code = isolate->factory()->NewCode( |
2329 desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); | 2362 desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); |
2330 F3 f = FUNCTION_CAST<F3>(code->entry()); | 2363 F3 f = FUNCTION_CAST<F3>(code->entry()); |
2331 for (int i = 0; i < kTableLength; i++) { | 2364 for (int i = 0; i < kTableLength; i++) { |
2332 test.a = inputs_D[i]; | 2365 test.a = inputs_D[i]; |
2333 test.b = inputs_S[i]; | 2366 test.b = inputs_S[i]; |
2334 (CALL_GENERATED_CODE(isolate, f, &test, 0, 0, 0, 0)); | 2367 (CALL_GENERATED_CODE(isolate, f, &test, 0, 0, 0, 0)); |
2335 CHECK_EQ(test.c, outputs[i]); | 2368 if ((test.isNaN2008 & kFCSRNaN2008FlagMask) && kArchVariant == kMips32r6) { |
2369 CHECK_EQ(test.c, outputsNaN2008[i]); | |
2370 } else { | |
2371 CHECK_EQ(test.c, outputs[i]); | |
2372 } | |
2336 CHECK_EQ(test.d, test.c); | 2373 CHECK_EQ(test.d, test.c); |
2337 } | 2374 } |
2338 } | 2375 } |
2339 | 2376 |
2340 | 2377 |
2341 TEST(round_w) { | 2378 TEST(round_w) { |
2342 CcTest::InitializeVM(); | 2379 CcTest::InitializeVM(); |
2343 Isolate* isolate = CcTest::i_isolate(); | 2380 Isolate* isolate = CcTest::i_isolate(); |
2344 HandleScope scope(isolate); | 2381 HandleScope scope(isolate); |
2345 MacroAssembler assm(isolate, NULL, 0, v8::internal::CodeObjectRequired::kYes); | 2382 MacroAssembler assm(isolate, NULL, 0, v8::internal::CodeObjectRequired::kYes); |
2346 | 2383 |
2347 typedef struct test_float { | 2384 typedef struct test_float { |
2385 uint32_t isNaN2008; | |
2348 double a; | 2386 double a; |
2349 float b; | 2387 float b; |
2350 int32_t c; // a trunc result | 2388 int32_t c; // a trunc result |
2351 int32_t d; // b trunc result | 2389 int32_t d; // b trunc result |
2352 }Test; | 2390 }Test; |
2353 const int kTableLength = 15; | 2391 const int kTableLength = 15; |
2354 double inputs_D[kTableLength] = { | 2392 double inputs_D[kTableLength] = { |
2355 2.1, 2.6, 2.5, 3.1, 3.6, 3.5, | 2393 2.1, 2.6, 2.5, 3.1, 3.6, 3.5, |
2356 -2.1, -2.6, -2.5, -3.1, -3.6, -3.5, | 2394 -2.1, -2.6, -2.5, -3.1, -3.6, -3.5, |
2357 2147483648.0, | 2395 2147483648.0, |
2358 std::numeric_limits<double>::quiet_NaN(), | 2396 std::numeric_limits<double>::quiet_NaN(), |
2359 std::numeric_limits<double>::infinity() | 2397 std::numeric_limits<double>::infinity() |
2360 }; | 2398 }; |
2361 float inputs_S[kTableLength] = { | 2399 float inputs_S[kTableLength] = { |
2362 2.1, 2.6, 2.5, 3.1, 3.6, 3.5, | 2400 2.1, 2.6, 2.5, 3.1, 3.6, 3.5, |
2363 -2.1, -2.6, -2.5, -3.1, -3.6, -3.5, | 2401 -2.1, -2.6, -2.5, -3.1, -3.6, -3.5, |
2364 2147483648.0, | 2402 2147483648.0, |
2365 std::numeric_limits<float>::quiet_NaN(), | 2403 std::numeric_limits<float>::quiet_NaN(), |
2366 std::numeric_limits<float>::infinity() | 2404 std::numeric_limits<float>::infinity() |
2367 }; | 2405 }; |
2368 double outputs[kTableLength] = { | 2406 double outputs[kTableLength] = { |
2369 2.0, 3.0, 2.0, 3.0, 4.0, 4.0, | 2407 2.0, 3.0, 2.0, 3.0, 4.0, 4.0, |
2370 -2.0, -3.0, -2.0, -3.0, -4.0, -4.0, | 2408 -2.0, -3.0, -2.0, -3.0, -4.0, -4.0, |
2371 kFPUInvalidResult, kFPUInvalidResult, | 2409 kFPUInvalidResult, kFPUInvalidResult, |
2372 kFPUInvalidResult}; | 2410 kFPUInvalidResult}; |
2411 double outputsNaN2008[kTableLength] = { | |
2412 2.0, 3.0, 2.0, 3.0, 4.0, 4.0, | |
2413 -2.0, -3.0, -2.0, -3.0, -4.0, -4.0, | |
2414 kFPUInvalidResult, 0, | |
2415 kFPUInvalidResult}; | |
2373 | 2416 |
2417 __ cfc1(t1, FCSR); | |
2418 __ sw(t1, MemOperand(a0, offsetof(Test, isNaN2008))); | |
2374 __ ldc1(f4, MemOperand(a0, offsetof(Test, a)) ); | 2419 __ ldc1(f4, MemOperand(a0, offsetof(Test, a)) ); |
2375 __ lwc1(f6, MemOperand(a0, offsetof(Test, b)) ); | 2420 __ lwc1(f6, MemOperand(a0, offsetof(Test, b)) ); |
2376 __ round_w_d(f8, f4); | 2421 __ round_w_d(f8, f4); |
2377 __ round_w_s(f10, f6); | 2422 __ round_w_s(f10, f6); |
2378 __ swc1(f8, MemOperand(a0, offsetof(Test, c)) ); | 2423 __ swc1(f8, MemOperand(a0, offsetof(Test, c)) ); |
2379 __ swc1(f10, MemOperand(a0, offsetof(Test, d)) ); | 2424 __ swc1(f10, MemOperand(a0, offsetof(Test, d)) ); |
2380 __ jr(ra); | 2425 __ jr(ra); |
2381 __ nop(); | 2426 __ nop(); |
2382 Test test; | 2427 Test test; |
2383 CodeDesc desc; | 2428 CodeDesc desc; |
2384 assm.GetCode(&desc); | 2429 assm.GetCode(&desc); |
2385 Handle<Code> code = isolate->factory()->NewCode( | 2430 Handle<Code> code = isolate->factory()->NewCode( |
2386 desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); | 2431 desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); |
2387 F3 f = FUNCTION_CAST<F3>(code->entry()); | 2432 F3 f = FUNCTION_CAST<F3>(code->entry()); |
2388 for (int i = 0; i < kTableLength; i++) { | 2433 for (int i = 0; i < kTableLength; i++) { |
2389 test.a = inputs_D[i]; | 2434 test.a = inputs_D[i]; |
2390 test.b = inputs_S[i]; | 2435 test.b = inputs_S[i]; |
2391 (CALL_GENERATED_CODE(isolate, f, &test, 0, 0, 0, 0)); | 2436 (CALL_GENERATED_CODE(isolate, f, &test, 0, 0, 0, 0)); |
2392 CHECK_EQ(test.c, outputs[i]); | 2437 if ((test.isNaN2008 & kFCSRNaN2008FlagMask) && kArchVariant == kMips32r6) { |
2438 CHECK_EQ(test.c, outputsNaN2008[i]); | |
2439 } else { | |
2440 CHECK_EQ(test.c, outputs[i]); | |
2441 } | |
2393 CHECK_EQ(test.d, test.c); | 2442 CHECK_EQ(test.d, test.c); |
2394 } | 2443 } |
2395 } | 2444 } |
2396 | 2445 |
2397 | 2446 |
2398 TEST(round_l) { | 2447 TEST(round_l) { |
2399 if (IsFp64Mode()) { | 2448 if (IsFp64Mode()) { |
2400 CcTest::InitializeVM(); | 2449 CcTest::InitializeVM(); |
2401 Isolate* isolate = CcTest::i_isolate(); | 2450 Isolate* isolate = CcTest::i_isolate(); |
2402 HandleScope scope(isolate); | 2451 HandleScope scope(isolate); |
2403 MacroAssembler assm(isolate, NULL, 0, | 2452 MacroAssembler assm(isolate, NULL, 0, |
2404 v8::internal::CodeObjectRequired::kYes); | 2453 v8::internal::CodeObjectRequired::kYes); |
2405 const double dFPU64InvalidResult = static_cast<double>(kFPU64InvalidResult); | 2454 const double dFPU64InvalidResult = static_cast<double>(kFPU64InvalidResult); |
2406 typedef struct test_float { | 2455 typedef struct test_float { |
2456 uint32_t isNaN2008; | |
2407 double a; | 2457 double a; |
2408 float b; | 2458 float b; |
2409 int64_t c; | 2459 int64_t c; |
2410 int64_t d; | 2460 int64_t d; |
2411 }Test; | 2461 }Test; |
2412 const int kTableLength = 15; | 2462 const int kTableLength = 15; |
2413 double inputs_D[kTableLength] = { | 2463 double inputs_D[kTableLength] = { |
2414 2.1, 2.6, 2.5, 3.1, 3.6, 3.5, | 2464 2.1, 2.6, 2.5, 3.1, 3.6, 3.5, |
2415 -2.1, -2.6, -2.5, -3.1, -3.6, -3.5, | 2465 -2.1, -2.6, -2.5, -3.1, -3.6, -3.5, |
2416 2147483648.0, | 2466 2147483648.0, |
2417 std::numeric_limits<double>::quiet_NaN(), | 2467 std::numeric_limits<double>::quiet_NaN(), |
2418 std::numeric_limits<double>::infinity() | 2468 std::numeric_limits<double>::infinity() |
2419 }; | 2469 }; |
2420 float inputs_S[kTableLength] = { | 2470 float inputs_S[kTableLength] = { |
2421 2.1, 2.6, 2.5, 3.1, 3.6, 3.5, | 2471 2.1, 2.6, 2.5, 3.1, 3.6, 3.5, |
2422 -2.1, -2.6, -2.5, -3.1, -3.6, -3.5, | 2472 -2.1, -2.6, -2.5, -3.1, -3.6, -3.5, |
2423 2147483648.0, | 2473 2147483648.0, |
2424 std::numeric_limits<float>::quiet_NaN(), | 2474 std::numeric_limits<float>::quiet_NaN(), |
2425 std::numeric_limits<float>::infinity() | 2475 std::numeric_limits<float>::infinity() |
2426 }; | 2476 }; |
2427 double outputs[kTableLength] = { | 2477 double outputs[kTableLength] = { |
2428 2.0, 3.0, 2.0, 3.0, 4.0, 4.0, | 2478 2.0, 3.0, 2.0, 3.0, 4.0, 4.0, |
2429 -2.0, -3.0, -2.0, -3.0, -4.0, -4.0, | 2479 -2.0, -3.0, -2.0, -3.0, -4.0, -4.0, |
2430 2147483648.0, dFPU64InvalidResult, | 2480 2147483648.0, dFPU64InvalidResult, |
2431 dFPU64InvalidResult}; | 2481 dFPU64InvalidResult}; |
2482 double outputsNaN2008[kTableLength] = { | |
2483 2.0, 3.0, 2.0, 3.0, 4.0, 4.0, | |
2484 -2.0, -3.0, -2.0, -3.0, -4.0, -4.0, | |
2485 2147483648.0, | |
2486 0, | |
2487 dFPU64InvalidResult}; | |
2432 | 2488 |
2489 __ cfc1(t1, FCSR); | |
2490 __ sw(t1, MemOperand(a0, offsetof(Test, isNaN2008))); | |
2433 __ ldc1(f4, MemOperand(a0, offsetof(Test, a)) ); | 2491 __ ldc1(f4, MemOperand(a0, offsetof(Test, a)) ); |
2434 __ lwc1(f6, MemOperand(a0, offsetof(Test, b)) ); | 2492 __ lwc1(f6, MemOperand(a0, offsetof(Test, b)) ); |
2435 __ round_l_d(f8, f4); | 2493 __ round_l_d(f8, f4); |
2436 __ round_l_s(f10, f6); | 2494 __ round_l_s(f10, f6); |
2437 __ sdc1(f8, MemOperand(a0, offsetof(Test, c)) ); | 2495 __ sdc1(f8, MemOperand(a0, offsetof(Test, c)) ); |
2438 __ sdc1(f10, MemOperand(a0, offsetof(Test, d)) ); | 2496 __ sdc1(f10, MemOperand(a0, offsetof(Test, d)) ); |
2439 __ jr(ra); | 2497 __ jr(ra); |
2440 __ nop(); | 2498 __ nop(); |
2441 Test test; | 2499 Test test; |
2442 CodeDesc desc; | 2500 CodeDesc desc; |
2443 assm.GetCode(&desc); | 2501 assm.GetCode(&desc); |
2444 Handle<Code> code = isolate->factory()->NewCode( | 2502 Handle<Code> code = isolate->factory()->NewCode( |
2445 desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); | 2503 desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); |
2446 F3 f = FUNCTION_CAST<F3>(code->entry()); | 2504 F3 f = FUNCTION_CAST<F3>(code->entry()); |
2447 for (int i = 0; i < kTableLength; i++) { | 2505 for (int i = 0; i < kTableLength; i++) { |
2448 test.a = inputs_D[i]; | 2506 test.a = inputs_D[i]; |
2449 test.b = inputs_S[i]; | 2507 test.b = inputs_S[i]; |
2450 (CALL_GENERATED_CODE(isolate, f, &test, 0, 0, 0, 0)); | 2508 (CALL_GENERATED_CODE(isolate, f, &test, 0, 0, 0, 0)); |
2451 CHECK_EQ(test.c, outputs[i]); | 2509 if ((test.isNaN2008 & kFCSRNaN2008FlagMask) && |
2510 kArchVariant == kMips32r6) { | |
2511 CHECK_EQ(test.c, outputsNaN2008[i]); | |
2512 } else { | |
2513 CHECK_EQ(test.c, outputs[i]); | |
2514 } | |
2452 CHECK_EQ(test.d, test.c); | 2515 CHECK_EQ(test.d, test.c); |
2453 } | 2516 } |
2454 } | 2517 } |
2455 } | 2518 } |
2456 | 2519 |
2457 | 2520 |
2458 TEST(sub) { | 2521 TEST(sub) { |
2459 const int kTableLength = 12; | 2522 const int kTableLength = 12; |
2460 CcTest::InitializeVM(); | 2523 CcTest::InitializeVM(); |
2461 Isolate* isolate = CcTest::i_isolate(); | 2524 Isolate* isolate = CcTest::i_isolate(); |
(...skipping 333 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2795 } | 2858 } |
2796 | 2859 |
2797 | 2860 |
2798 TEST(floor_w) { | 2861 TEST(floor_w) { |
2799 CcTest::InitializeVM(); | 2862 CcTest::InitializeVM(); |
2800 Isolate* isolate = CcTest::i_isolate(); | 2863 Isolate* isolate = CcTest::i_isolate(); |
2801 HandleScope scope(isolate); | 2864 HandleScope scope(isolate); |
2802 MacroAssembler assm(isolate, NULL, 0, v8::internal::CodeObjectRequired::kYes); | 2865 MacroAssembler assm(isolate, NULL, 0, v8::internal::CodeObjectRequired::kYes); |
2803 | 2866 |
2804 typedef struct test_float { | 2867 typedef struct test_float { |
2868 uint32_t isNaN2008; | |
2805 double a; | 2869 double a; |
2806 float b; | 2870 float b; |
2807 int32_t c; // a floor result | 2871 int32_t c; // a floor result |
2808 int32_t d; // b floor result | 2872 int32_t d; // b floor result |
2809 }Test; | 2873 }Test; |
2810 const int kTableLength = 15; | 2874 const int kTableLength = 15; |
2811 double inputs_D[kTableLength] = { | 2875 double inputs_D[kTableLength] = { |
2812 2.1, 2.6, 2.5, 3.1, 3.6, 3.5, | 2876 2.1, 2.6, 2.5, 3.1, 3.6, 3.5, |
2813 -2.1, -2.6, -2.5, -3.1, -3.6, -3.5, | 2877 -2.1, -2.6, -2.5, -3.1, -3.6, -3.5, |
2814 2147483648.0, | 2878 2147483648.0, |
2815 std::numeric_limits<double>::quiet_NaN(), | 2879 std::numeric_limits<double>::quiet_NaN(), |
2816 std::numeric_limits<double>::infinity() | 2880 std::numeric_limits<double>::infinity() |
2817 }; | 2881 }; |
2818 float inputs_S[kTableLength] = { | 2882 float inputs_S[kTableLength] = { |
2819 2.1, 2.6, 2.5, 3.1, 3.6, 3.5, | 2883 2.1, 2.6, 2.5, 3.1, 3.6, 3.5, |
2820 -2.1, -2.6, -2.5, -3.1, -3.6, -3.5, | 2884 -2.1, -2.6, -2.5, -3.1, -3.6, -3.5, |
2821 2147483648.0, | 2885 2147483648.0, |
2822 std::numeric_limits<float>::quiet_NaN(), | 2886 std::numeric_limits<float>::quiet_NaN(), |
2823 std::numeric_limits<float>::infinity() | 2887 std::numeric_limits<float>::infinity() |
2824 }; | 2888 }; |
2825 double outputs[kTableLength] = { | 2889 double outputs[kTableLength] = { |
2826 2.0, 2.0, 2.0, 3.0, 3.0, 3.0, | 2890 2.0, 2.0, 2.0, 3.0, 3.0, 3.0, |
2827 -3.0, -3.0, -3.0, -4.0, -4.0, -4.0, | 2891 -3.0, -3.0, -3.0, -4.0, -4.0, -4.0, |
2828 kFPUInvalidResult, kFPUInvalidResult, | 2892 kFPUInvalidResult, kFPUInvalidResult, |
2829 kFPUInvalidResult}; | 2893 kFPUInvalidResult}; |
2894 double outputsNaN2008[kTableLength] = { | |
2895 2.0, 2.0, 2.0, 3.0, 3.0, 3.0, | |
2896 -3.0, -3.0, -3.0, -4.0, -4.0, -4.0, | |
2897 kFPUInvalidResult, | |
2898 0, | |
2899 kFPUInvalidResult}; | |
2830 | 2900 |
2901 __ cfc1(t1, FCSR); | |
2902 __ sw(t1, MemOperand(a0, offsetof(Test, isNaN2008))); | |
2831 __ ldc1(f4, MemOperand(a0, offsetof(Test, a)) ); | 2903 __ ldc1(f4, MemOperand(a0, offsetof(Test, a)) ); |
2832 __ lwc1(f6, MemOperand(a0, offsetof(Test, b)) ); | 2904 __ lwc1(f6, MemOperand(a0, offsetof(Test, b)) ); |
2833 __ floor_w_d(f8, f4); | 2905 __ floor_w_d(f8, f4); |
2834 __ floor_w_s(f10, f6); | 2906 __ floor_w_s(f10, f6); |
2835 __ swc1(f8, MemOperand(a0, offsetof(Test, c)) ); | 2907 __ swc1(f8, MemOperand(a0, offsetof(Test, c)) ); |
2836 __ swc1(f10, MemOperand(a0, offsetof(Test, d)) ); | 2908 __ swc1(f10, MemOperand(a0, offsetof(Test, d)) ); |
2837 __ jr(ra); | 2909 __ jr(ra); |
2838 __ nop(); | 2910 __ nop(); |
2839 Test test; | 2911 Test test; |
2840 CodeDesc desc; | 2912 CodeDesc desc; |
2841 assm.GetCode(&desc); | 2913 assm.GetCode(&desc); |
2842 Handle<Code> code = isolate->factory()->NewCode( | 2914 Handle<Code> code = isolate->factory()->NewCode( |
2843 desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); | 2915 desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); |
2844 F3 f = FUNCTION_CAST<F3>(code->entry()); | 2916 F3 f = FUNCTION_CAST<F3>(code->entry()); |
2845 for (int i = 0; i < kTableLength; i++) { | 2917 for (int i = 0; i < kTableLength; i++) { |
2846 test.a = inputs_D[i]; | 2918 test.a = inputs_D[i]; |
2847 test.b = inputs_S[i]; | 2919 test.b = inputs_S[i]; |
2848 (CALL_GENERATED_CODE(isolate, f, &test, 0, 0, 0, 0)); | 2920 (CALL_GENERATED_CODE(isolate, f, &test, 0, 0, 0, 0)); |
2849 CHECK_EQ(test.c, outputs[i]); | 2921 if ((test.isNaN2008 & kFCSRNaN2008FlagMask) && kArchVariant == kMips32r6) { |
2922 CHECK_EQ(test.c, outputsNaN2008[i]); | |
2923 } else { | |
2924 CHECK_EQ(test.c, outputs[i]); | |
2925 } | |
2850 CHECK_EQ(test.d, test.c); | 2926 CHECK_EQ(test.d, test.c); |
2851 } | 2927 } |
2852 } | 2928 } |
2853 | 2929 |
2854 | 2930 |
2855 TEST(floor_l) { | 2931 TEST(floor_l) { |
2856 if (IsFp64Mode()) { | 2932 if (IsFp64Mode()) { |
2857 CcTest::InitializeVM(); | 2933 CcTest::InitializeVM(); |
2858 Isolate* isolate = CcTest::i_isolate(); | 2934 Isolate* isolate = CcTest::i_isolate(); |
2859 HandleScope scope(isolate); | 2935 HandleScope scope(isolate); |
2860 MacroAssembler assm(isolate, NULL, 0, | 2936 MacroAssembler assm(isolate, NULL, 0, |
2861 v8::internal::CodeObjectRequired::kYes); | 2937 v8::internal::CodeObjectRequired::kYes); |
2862 const double dFPU64InvalidResult = static_cast<double>(kFPU64InvalidResult); | 2938 const double dFPU64InvalidResult = static_cast<double>(kFPU64InvalidResult); |
2863 typedef struct test_float { | 2939 typedef struct test_float { |
2940 uint32_t isNaN2008; | |
2864 double a; | 2941 double a; |
2865 float b; | 2942 float b; |
2866 int64_t c; | 2943 int64_t c; |
2867 int64_t d; | 2944 int64_t d; |
2868 }Test; | 2945 }Test; |
2869 const int kTableLength = 15; | 2946 const int kTableLength = 15; |
2870 double inputs_D[kTableLength] = { | 2947 double inputs_D[kTableLength] = { |
2871 2.1, 2.6, 2.5, 3.1, 3.6, 3.5, | 2948 2.1, 2.6, 2.5, 3.1, 3.6, 3.5, |
2872 -2.1, -2.6, -2.5, -3.1, -3.6, -3.5, | 2949 -2.1, -2.6, -2.5, -3.1, -3.6, -3.5, |
2873 2147483648.0, | 2950 2147483648.0, |
2874 std::numeric_limits<double>::quiet_NaN(), | 2951 std::numeric_limits<double>::quiet_NaN(), |
2875 std::numeric_limits<double>::infinity() | 2952 std::numeric_limits<double>::infinity() |
2876 }; | 2953 }; |
2877 float inputs_S[kTableLength] = { | 2954 float inputs_S[kTableLength] = { |
2878 2.1, 2.6, 2.5, 3.1, 3.6, 3.5, | 2955 2.1, 2.6, 2.5, 3.1, 3.6, 3.5, |
2879 -2.1, -2.6, -2.5, -3.1, -3.6, -3.5, | 2956 -2.1, -2.6, -2.5, -3.1, -3.6, -3.5, |
2880 2147483648.0, | 2957 2147483648.0, |
2881 std::numeric_limits<float>::quiet_NaN(), | 2958 std::numeric_limits<float>::quiet_NaN(), |
2882 std::numeric_limits<float>::infinity() | 2959 std::numeric_limits<float>::infinity() |
2883 }; | 2960 }; |
2884 double outputs[kTableLength] = { | 2961 double outputs[kTableLength] = { |
2885 2.0, 2.0, 2.0, 3.0, 3.0, 3.0, | 2962 2.0, 2.0, 2.0, 3.0, 3.0, 3.0, |
2886 -3.0, -3.0, -3.0, -4.0, -4.0, -4.0, | 2963 -3.0, -3.0, -3.0, -4.0, -4.0, -4.0, |
2887 2147483648.0, dFPU64InvalidResult, | 2964 2147483648.0, dFPU64InvalidResult, |
2888 dFPU64InvalidResult}; | 2965 dFPU64InvalidResult}; |
2966 double outputsNaN2008[kTableLength] = { | |
2967 2.0, 2.0, 2.0, 3.0, 3.0, 3.0, | |
2968 -3.0, -3.0, -3.0, -4.0, -4.0, -4.0, | |
2969 2147483648.0, | |
2970 0, | |
2971 dFPU64InvalidResult}; | |
2889 | 2972 |
2973 __ cfc1(t1, FCSR); | |
2974 __ sw(t1, MemOperand(a0, offsetof(Test, isNaN2008))); | |
2890 __ ldc1(f4, MemOperand(a0, offsetof(Test, a)) ); | 2975 __ ldc1(f4, MemOperand(a0, offsetof(Test, a)) ); |
2891 __ lwc1(f6, MemOperand(a0, offsetof(Test, b)) ); | 2976 __ lwc1(f6, MemOperand(a0, offsetof(Test, b)) ); |
2892 __ floor_l_d(f8, f4); | 2977 __ floor_l_d(f8, f4); |
2893 __ floor_l_s(f10, f6); | 2978 __ floor_l_s(f10, f6); |
2894 __ sdc1(f8, MemOperand(a0, offsetof(Test, c)) ); | 2979 __ sdc1(f8, MemOperand(a0, offsetof(Test, c)) ); |
2895 __ sdc1(f10, MemOperand(a0, offsetof(Test, d)) ); | 2980 __ sdc1(f10, MemOperand(a0, offsetof(Test, d)) ); |
2896 __ jr(ra); | 2981 __ jr(ra); |
2897 __ nop(); | 2982 __ nop(); |
2898 Test test; | 2983 Test test; |
2899 CodeDesc desc; | 2984 CodeDesc desc; |
2900 assm.GetCode(&desc); | 2985 assm.GetCode(&desc); |
2901 Handle<Code> code = isolate->factory()->NewCode( | 2986 Handle<Code> code = isolate->factory()->NewCode( |
2902 desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); | 2987 desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); |
2903 F3 f = FUNCTION_CAST<F3>(code->entry()); | 2988 F3 f = FUNCTION_CAST<F3>(code->entry()); |
2904 for (int i = 0; i < kTableLength; i++) { | 2989 for (int i = 0; i < kTableLength; i++) { |
2905 test.a = inputs_D[i]; | 2990 test.a = inputs_D[i]; |
2906 test.b = inputs_S[i]; | 2991 test.b = inputs_S[i]; |
2907 (CALL_GENERATED_CODE(isolate, f, &test, 0, 0, 0, 0)); | 2992 (CALL_GENERATED_CODE(isolate, f, &test, 0, 0, 0, 0)); |
2908 CHECK_EQ(test.c, outputs[i]); | 2993 if ((test.isNaN2008 & kFCSRNaN2008FlagMask) && |
2994 kArchVariant == kMips32r6) { | |
2995 CHECK_EQ(test.c, outputsNaN2008[i]); | |
2996 } else { | |
2997 CHECK_EQ(test.c, outputs[i]); | |
2998 } | |
2909 CHECK_EQ(test.d, test.c); | 2999 CHECK_EQ(test.d, test.c); |
2910 } | 3000 } |
2911 } | 3001 } |
2912 } | 3002 } |
2913 | 3003 |
2914 | 3004 |
2915 TEST(ceil_w) { | 3005 TEST(ceil_w) { |
2916 CcTest::InitializeVM(); | 3006 CcTest::InitializeVM(); |
2917 Isolate* isolate = CcTest::i_isolate(); | 3007 Isolate* isolate = CcTest::i_isolate(); |
2918 HandleScope scope(isolate); | 3008 HandleScope scope(isolate); |
2919 MacroAssembler assm(isolate, NULL, 0, v8::internal::CodeObjectRequired::kYes); | 3009 MacroAssembler assm(isolate, NULL, 0, v8::internal::CodeObjectRequired::kYes); |
2920 | 3010 |
2921 typedef struct test_float { | 3011 typedef struct test_float { |
3012 uint32_t isNaN2008; | |
2922 double a; | 3013 double a; |
2923 float b; | 3014 float b; |
2924 int32_t c; // a floor result | 3015 int32_t c; // a floor result |
2925 int32_t d; // b floor result | 3016 int32_t d; // b floor result |
2926 }Test; | 3017 }Test; |
2927 const int kTableLength = 15; | 3018 const int kTableLength = 15; |
2928 double inputs_D[kTableLength] = { | 3019 double inputs_D[kTableLength] = { |
2929 2.1, 2.6, 2.5, 3.1, 3.6, 3.5, | 3020 2.1, 2.6, 2.5, 3.1, 3.6, 3.5, |
2930 -2.1, -2.6, -2.5, -3.1, -3.6, -3.5, | 3021 -2.1, -2.6, -2.5, -3.1, -3.6, -3.5, |
2931 2147483648.0, | 3022 2147483648.0, |
2932 std::numeric_limits<double>::quiet_NaN(), | 3023 std::numeric_limits<double>::quiet_NaN(), |
2933 std::numeric_limits<double>::infinity() | 3024 std::numeric_limits<double>::infinity() |
2934 }; | 3025 }; |
2935 float inputs_S[kTableLength] = { | 3026 float inputs_S[kTableLength] = { |
2936 2.1, 2.6, 2.5, 3.1, 3.6, 3.5, | 3027 2.1, 2.6, 2.5, 3.1, 3.6, 3.5, |
2937 -2.1, -2.6, -2.5, -3.1, -3.6, -3.5, | 3028 -2.1, -2.6, -2.5, -3.1, -3.6, -3.5, |
2938 2147483648.0, | 3029 2147483648.0, |
2939 std::numeric_limits<float>::quiet_NaN(), | 3030 std::numeric_limits<float>::quiet_NaN(), |
2940 std::numeric_limits<float>::infinity() | 3031 std::numeric_limits<float>::infinity() |
2941 }; | 3032 }; |
2942 double outputs[kTableLength] = { | 3033 double outputs[kTableLength] = { |
2943 3.0, 3.0, 3.0, 4.0, 4.0, 4.0, | 3034 3.0, 3.0, 3.0, 4.0, 4.0, 4.0, |
2944 -2.0, -2.0, -2.0, -3.0, -3.0, -3.0, | 3035 -2.0, -2.0, -2.0, -3.0, -3.0, -3.0, |
2945 kFPUInvalidResult, kFPUInvalidResult, | 3036 kFPUInvalidResult, kFPUInvalidResult, |
2946 kFPUInvalidResult}; | 3037 kFPUInvalidResult}; |
3038 double outputsNaN2008[kTableLength] = { | |
3039 3.0, 3.0, 3.0, 4.0, 4.0, 4.0, | |
3040 -2.0, -2.0, -2.0, -3.0, -3.0, -3.0, | |
3041 kFPUInvalidResult, | |
3042 0, | |
3043 kFPUInvalidResult}; | |
2947 | 3044 |
3045 __ cfc1(t1, FCSR); | |
3046 __ sw(t1, MemOperand(a0, offsetof(Test, isNaN2008))); | |
2948 __ ldc1(f4, MemOperand(a0, offsetof(Test, a)) ); | 3047 __ ldc1(f4, MemOperand(a0, offsetof(Test, a)) ); |
2949 __ lwc1(f6, MemOperand(a0, offsetof(Test, b)) ); | 3048 __ lwc1(f6, MemOperand(a0, offsetof(Test, b)) ); |
2950 __ ceil_w_d(f8, f4); | 3049 __ ceil_w_d(f8, f4); |
2951 __ ceil_w_s(f10, f6); | 3050 __ ceil_w_s(f10, f6); |
2952 __ swc1(f8, MemOperand(a0, offsetof(Test, c)) ); | 3051 __ swc1(f8, MemOperand(a0, offsetof(Test, c)) ); |
2953 __ swc1(f10, MemOperand(a0, offsetof(Test, d)) ); | 3052 __ swc1(f10, MemOperand(a0, offsetof(Test, d)) ); |
2954 __ jr(ra); | 3053 __ jr(ra); |
2955 __ nop(); | 3054 __ nop(); |
2956 Test test; | 3055 Test test; |
2957 CodeDesc desc; | 3056 CodeDesc desc; |
2958 assm.GetCode(&desc); | 3057 assm.GetCode(&desc); |
2959 Handle<Code> code = isolate->factory()->NewCode( | 3058 Handle<Code> code = isolate->factory()->NewCode( |
2960 desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); | 3059 desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); |
2961 F3 f = FUNCTION_CAST<F3>(code->entry()); | 3060 F3 f = FUNCTION_CAST<F3>(code->entry()); |
2962 for (int i = 0; i < kTableLength; i++) { | 3061 for (int i = 0; i < kTableLength; i++) { |
2963 test.a = inputs_D[i]; | 3062 test.a = inputs_D[i]; |
2964 test.b = inputs_S[i]; | 3063 test.b = inputs_S[i]; |
2965 (CALL_GENERATED_CODE(isolate, f, &test, 0, 0, 0, 0)); | 3064 (CALL_GENERATED_CODE(isolate, f, &test, 0, 0, 0, 0)); |
2966 CHECK_EQ(test.c, outputs[i]); | 3065 if ((test.isNaN2008 & kFCSRNaN2008FlagMask) && kArchVariant == kMips32r6) { |
3066 CHECK_EQ(test.c, outputsNaN2008[i]); | |
3067 } else { | |
3068 CHECK_EQ(test.c, outputs[i]); | |
3069 } | |
2967 CHECK_EQ(test.d, test.c); | 3070 CHECK_EQ(test.d, test.c); |
2968 } | 3071 } |
2969 } | 3072 } |
2970 | 3073 |
2971 | 3074 |
2972 TEST(ceil_l) { | 3075 TEST(ceil_l) { |
2973 if (IsFp64Mode()) { | 3076 if (IsFp64Mode()) { |
2974 CcTest::InitializeVM(); | 3077 CcTest::InitializeVM(); |
2975 Isolate* isolate = CcTest::i_isolate(); | 3078 Isolate* isolate = CcTest::i_isolate(); |
2976 HandleScope scope(isolate); | 3079 HandleScope scope(isolate); |
2977 MacroAssembler assm(isolate, NULL, 0, | 3080 MacroAssembler assm(isolate, NULL, 0, |
2978 v8::internal::CodeObjectRequired::kYes); | 3081 v8::internal::CodeObjectRequired::kYes); |
2979 const double dFPU64InvalidResult = static_cast<double>(kFPU64InvalidResult); | 3082 const double dFPU64InvalidResult = static_cast<double>(kFPU64InvalidResult); |
2980 typedef struct test_float { | 3083 typedef struct test_float { |
3084 uint32_t isNaN2008; | |
2981 double a; | 3085 double a; |
2982 float b; | 3086 float b; |
2983 int64_t c; | 3087 int64_t c; |
2984 int64_t d; | 3088 int64_t d; |
2985 }Test; | 3089 }Test; |
2986 const int kTableLength = 15; | 3090 const int kTableLength = 15; |
2987 double inputs_D[kTableLength] = { | 3091 double inputs_D[kTableLength] = { |
2988 2.1, 2.6, 2.5, 3.1, 3.6, 3.5, | 3092 2.1, 2.6, 2.5, 3.1, 3.6, 3.5, |
2989 -2.1, -2.6, -2.5, -3.1, -3.6, -3.5, | 3093 -2.1, -2.6, -2.5, -3.1, -3.6, -3.5, |
2990 2147483648.0, | 3094 2147483648.0, |
2991 std::numeric_limits<double>::quiet_NaN(), | 3095 std::numeric_limits<double>::quiet_NaN(), |
2992 std::numeric_limits<double>::infinity() | 3096 std::numeric_limits<double>::infinity() |
2993 }; | 3097 }; |
2994 float inputs_S[kTableLength] = { | 3098 float inputs_S[kTableLength] = { |
2995 2.1, 2.6, 2.5, 3.1, 3.6, 3.5, | 3099 2.1, 2.6, 2.5, 3.1, 3.6, 3.5, |
2996 -2.1, -2.6, -2.5, -3.1, -3.6, -3.5, | 3100 -2.1, -2.6, -2.5, -3.1, -3.6, -3.5, |
2997 2147483648.0, | 3101 2147483648.0, |
2998 std::numeric_limits<float>::quiet_NaN(), | 3102 std::numeric_limits<float>::quiet_NaN(), |
2999 std::numeric_limits<float>::infinity() | 3103 std::numeric_limits<float>::infinity() |
3000 }; | 3104 }; |
3001 double outputs[kTableLength] = { | 3105 double outputs[kTableLength] = { |
3002 3.0, 3.0, 3.0, 4.0, 4.0, 4.0, | 3106 3.0, 3.0, 3.0, 4.0, 4.0, 4.0, |
3003 -2.0, -2.0, -2.0, -3.0, -3.0, -3.0, | 3107 -2.0, -2.0, -2.0, -3.0, -3.0, -3.0, |
3004 2147483648.0, dFPU64InvalidResult, | 3108 2147483648.0, dFPU64InvalidResult, |
3005 dFPU64InvalidResult}; | 3109 dFPU64InvalidResult}; |
3110 double outputsNaN2008[kTableLength] = { | |
3111 3.0, 3.0, 3.0, 4.0, 4.0, 4.0, | |
3112 -2.0, -2.0, -2.0, -3.0, -3.0, -3.0, | |
3113 2147483648.0, | |
3114 0, | |
3115 dFPU64InvalidResult}; | |
3006 | 3116 |
3117 __ cfc1(t1, FCSR); | |
3118 __ sw(t1, MemOperand(a0, offsetof(Test, isNaN2008))); | |
3007 __ ldc1(f4, MemOperand(a0, offsetof(Test, a)) ); | 3119 __ ldc1(f4, MemOperand(a0, offsetof(Test, a)) ); |
3008 __ lwc1(f6, MemOperand(a0, offsetof(Test, b)) ); | 3120 __ lwc1(f6, MemOperand(a0, offsetof(Test, b)) ); |
3009 __ ceil_l_d(f8, f4); | 3121 __ ceil_l_d(f8, f4); |
3010 __ ceil_l_s(f10, f6); | 3122 __ ceil_l_s(f10, f6); |
3011 __ sdc1(f8, MemOperand(a0, offsetof(Test, c)) ); | 3123 __ sdc1(f8, MemOperand(a0, offsetof(Test, c)) ); |
3012 __ sdc1(f10, MemOperand(a0, offsetof(Test, d)) ); | 3124 __ sdc1(f10, MemOperand(a0, offsetof(Test, d)) ); |
3013 __ jr(ra); | 3125 __ jr(ra); |
3014 __ nop(); | 3126 __ nop(); |
3015 Test test; | 3127 Test test; |
3016 CodeDesc desc; | 3128 CodeDesc desc; |
3017 assm.GetCode(&desc); | 3129 assm.GetCode(&desc); |
3018 Handle<Code> code = isolate->factory()->NewCode( | 3130 Handle<Code> code = isolate->factory()->NewCode( |
3019 desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); | 3131 desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); |
3020 F3 f = FUNCTION_CAST<F3>(code->entry()); | 3132 F3 f = FUNCTION_CAST<F3>(code->entry()); |
3021 for (int i = 0; i < kTableLength; i++) { | 3133 for (int i = 0; i < kTableLength; i++) { |
3022 test.a = inputs_D[i]; | 3134 test.a = inputs_D[i]; |
3023 test.b = inputs_S[i]; | 3135 test.b = inputs_S[i]; |
3024 (CALL_GENERATED_CODE(isolate, f, &test, 0, 0, 0, 0)); | 3136 (CALL_GENERATED_CODE(isolate, f, &test, 0, 0, 0, 0)); |
3025 CHECK_EQ(test.c, outputs[i]); | 3137 if ((test.isNaN2008 & kFCSRNaN2008FlagMask) && |
3138 kArchVariant == kMips32r6) { | |
3139 CHECK_EQ(test.c, outputsNaN2008[i]); | |
3140 } else { | |
3141 CHECK_EQ(test.c, outputs[i]); | |
3142 } | |
3026 CHECK_EQ(test.d, test.c); | 3143 CHECK_EQ(test.d, test.c); |
3027 } | 3144 } |
3028 } | 3145 } |
3029 } | 3146 } |
3030 | 3147 |
3031 | 3148 |
3032 TEST(jump_tables1) { | 3149 TEST(jump_tables1) { |
3033 // Test jump tables with forward jumps. | 3150 // Test jump tables with forward jumps. |
3034 CcTest::InitializeVM(); | 3151 CcTest::InitializeVM(); |
3035 Isolate* isolate = CcTest::i_isolate(); | 3152 Isolate* isolate = CcTest::i_isolate(); |
(...skipping 2232 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
5268 desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); | 5385 desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); |
5269 F2 f = FUNCTION_CAST<F2>(code->entry()); | 5386 F2 f = FUNCTION_CAST<F2>(code->entry()); |
5270 | 5387 |
5271 int32_t res = reinterpret_cast<int32_t>( | 5388 int32_t res = reinterpret_cast<int32_t>( |
5272 CALL_GENERATED_CODE(isolate, f, 42, 42, 0, 0, 0)); | 5389 CALL_GENERATED_CODE(isolate, f, 42, 42, 0, 0, 0)); |
5273 CHECK_EQ(res, 0); | 5390 CHECK_EQ(res, 0); |
5274 } | 5391 } |
5275 | 5392 |
5276 | 5393 |
5277 #undef __ | 5394 #undef __ |
OLD | NEW |