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 1216 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1227 } | 1227 } |
1228 | 1228 |
1229 | 1229 |
1230 TEST(MIPS14) { | 1230 TEST(MIPS14) { |
1231 // Test round, floor, ceil, trunc, cvt. | 1231 // Test round, floor, ceil, trunc, cvt. |
1232 CcTest::InitializeVM(); | 1232 CcTest::InitializeVM(); |
1233 Isolate* isolate = CcTest::i_isolate(); | 1233 Isolate* isolate = CcTest::i_isolate(); |
1234 HandleScope scope(isolate); | 1234 HandleScope scope(isolate); |
1235 | 1235 |
1236 #define ROUND_STRUCT_ELEMENT(x) \ | 1236 #define ROUND_STRUCT_ELEMENT(x) \ |
| 1237 uint32_t x##_isNaN2008; \ |
1237 int32_t x##_up_out; \ | 1238 int32_t x##_up_out; \ |
1238 int32_t x##_down_out; \ | 1239 int32_t x##_down_out; \ |
1239 int32_t neg_##x##_up_out; \ | 1240 int32_t neg_##x##_up_out; \ |
1240 int32_t neg_##x##_down_out; \ | 1241 int32_t neg_##x##_down_out; \ |
1241 uint32_t x##_err1_out; \ | 1242 uint32_t x##_err1_out; \ |
1242 uint32_t x##_err2_out; \ | 1243 uint32_t x##_err2_out; \ |
1243 uint32_t x##_err3_out; \ | 1244 uint32_t x##_err3_out; \ |
1244 uint32_t x##_err4_out; \ | 1245 uint32_t x##_err4_out; \ |
1245 int32_t x##_invalid_result; | 1246 int32_t x##_invalid_result; |
1246 | 1247 |
(...skipping 17 matching lines...) Expand all Loading... |
1264 | 1265 |
1265 #undef ROUND_STRUCT_ELEMENT | 1266 #undef ROUND_STRUCT_ELEMENT |
1266 | 1267 |
1267 MacroAssembler assm(isolate, NULL, 0, v8::internal::CodeObjectRequired::kYes); | 1268 MacroAssembler assm(isolate, NULL, 0, v8::internal::CodeObjectRequired::kYes); |
1268 | 1269 |
1269 // Save FCSR. | 1270 // Save FCSR. |
1270 __ cfc1(a1, FCSR); | 1271 __ cfc1(a1, FCSR); |
1271 // Disable FPU exceptions. | 1272 // Disable FPU exceptions. |
1272 __ ctc1(zero_reg, FCSR); | 1273 __ ctc1(zero_reg, FCSR); |
1273 #define RUN_ROUND_TEST(x) \ | 1274 #define RUN_ROUND_TEST(x) \ |
| 1275 __ cfc1(t0, FCSR);\ |
| 1276 __ sw(t0, MemOperand(a0, offsetof(T, x##_isNaN2008))); \ |
1274 __ ldc1(f0, MemOperand(a0, offsetof(T, round_up_in))); \ | 1277 __ ldc1(f0, MemOperand(a0, offsetof(T, round_up_in))); \ |
1275 __ x##_w_d(f0, f0); \ | 1278 __ x##_w_d(f0, f0); \ |
1276 __ swc1(f0, MemOperand(a0, offsetof(T, x##_up_out))); \ | 1279 __ swc1(f0, MemOperand(a0, offsetof(T, x##_up_out))); \ |
1277 \ | 1280 \ |
1278 __ ldc1(f0, MemOperand(a0, offsetof(T, round_down_in))); \ | 1281 __ ldc1(f0, MemOperand(a0, offsetof(T, round_down_in))); \ |
1279 __ x##_w_d(f0, f0); \ | 1282 __ x##_w_d(f0, f0); \ |
1280 __ swc1(f0, MemOperand(a0, offsetof(T, x##_down_out))); \ | 1283 __ swc1(f0, MemOperand(a0, offsetof(T, x##_down_out))); \ |
1281 \ | 1284 \ |
1282 __ ldc1(f0, MemOperand(a0, offsetof(T, neg_round_up_in))); \ | 1285 __ ldc1(f0, MemOperand(a0, offsetof(T, neg_round_up_in))); \ |
1283 __ x##_w_d(f0, f0); \ | 1286 __ x##_w_d(f0, f0); \ |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1336 t.neg_round_down_in = -123.49; | 1339 t.neg_round_down_in = -123.49; |
1337 t.err1_in = 123.51; | 1340 t.err1_in = 123.51; |
1338 t.err2_in = 1; | 1341 t.err2_in = 1; |
1339 t.err3_in = static_cast<double>(1) + 0xFFFFFFFF; | 1342 t.err3_in = static_cast<double>(1) + 0xFFFFFFFF; |
1340 t.err4_in = NAN; | 1343 t.err4_in = NAN; |
1341 | 1344 |
1342 Object* dummy = CALL_GENERATED_CODE(isolate, f, &t, 0, 0, 0, 0); | 1345 Object* dummy = CALL_GENERATED_CODE(isolate, f, &t, 0, 0, 0, 0); |
1343 USE(dummy); | 1346 USE(dummy); |
1344 | 1347 |
1345 #define GET_FPU_ERR(x) (static_cast<int>(x & kFCSRFlagMask)) | 1348 #define GET_FPU_ERR(x) (static_cast<int>(x & kFCSRFlagMask)) |
| 1349 #define CHECK_NAN2008(x) (x & kFCSRNaN2008FlagMask) |
1346 #define CHECK_ROUND_RESULT(type) \ | 1350 #define CHECK_ROUND_RESULT(type) \ |
1347 CHECK(GET_FPU_ERR(t.type##_err1_out) & kFCSRInexactFlagMask); \ | 1351 CHECK(GET_FPU_ERR(t.type##_err1_out) & kFCSRInexactFlagMask); \ |
1348 CHECK_EQ(0, GET_FPU_ERR(t.type##_err2_out)); \ | 1352 CHECK_EQ(0, GET_FPU_ERR(t.type##_err2_out)); \ |
1349 CHECK(GET_FPU_ERR(t.type##_err3_out) & kFCSRInvalidOpFlagMask); \ | 1353 CHECK(GET_FPU_ERR(t.type##_err3_out) & kFCSRInvalidOpFlagMask); \ |
1350 CHECK(GET_FPU_ERR(t.type##_err4_out) & kFCSRInvalidOpFlagMask); \ | 1354 CHECK(GET_FPU_ERR(t.type##_err4_out) & kFCSRInvalidOpFlagMask); \ |
1351 CHECK_EQ(static_cast<int32_t>(kFPUInvalidResult), t.type##_invalid_result); | 1355 if (CHECK_NAN2008(t.type##_isNaN2008) && kArchVariant == kMips64r6) { \ |
| 1356 CHECK_EQ(static_cast<int32_t>(0), t.type##_invalid_result);\ |
| 1357 } else { \ |
| 1358 CHECK_EQ(static_cast<int32_t>(kFPUInvalidResult), t.type##_invalid_result);\ |
| 1359 } |
1352 | 1360 |
1353 CHECK_ROUND_RESULT(round); | 1361 CHECK_ROUND_RESULT(round); |
1354 CHECK_ROUND_RESULT(floor); | 1362 CHECK_ROUND_RESULT(floor); |
1355 CHECK_ROUND_RESULT(ceil); | 1363 CHECK_ROUND_RESULT(ceil); |
1356 CHECK_ROUND_RESULT(cvt); | 1364 CHECK_ROUND_RESULT(cvt); |
1357 } | 1365 } |
1358 | 1366 |
1359 | 1367 |
1360 TEST(MIPS15) { | 1368 TEST(MIPS15) { |
1361 // Test chaining of label usages within instructions (issue 1644). | 1369 // Test chaining of label usages within instructions (issue 1644). |
(...skipping 682 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2044 // ----------------------mips64r2 specific tests---------------------- | 2052 // ----------------------mips64r2 specific tests---------------------- |
2045 TEST(trunc_l) { | 2053 TEST(trunc_l) { |
2046 if (kArchVariant == kMips64r2) { | 2054 if (kArchVariant == kMips64r2) { |
2047 CcTest::InitializeVM(); | 2055 CcTest::InitializeVM(); |
2048 Isolate* isolate = CcTest::i_isolate(); | 2056 Isolate* isolate = CcTest::i_isolate(); |
2049 HandleScope scope(isolate); | 2057 HandleScope scope(isolate); |
2050 MacroAssembler assm(isolate, NULL, 0, | 2058 MacroAssembler assm(isolate, NULL, 0, |
2051 v8::internal::CodeObjectRequired::kYes); | 2059 v8::internal::CodeObjectRequired::kYes); |
2052 const double dFPU64InvalidResult = static_cast<double>(kFPU64InvalidResult); | 2060 const double dFPU64InvalidResult = static_cast<double>(kFPU64InvalidResult); |
2053 typedef struct test_float { | 2061 typedef struct test_float { |
| 2062 uint32_t isNaN2008; |
2054 double a; | 2063 double a; |
2055 float b; | 2064 float b; |
2056 int64_t c; // a trunc result | 2065 int64_t c; // a trunc result |
2057 int64_t d; // b trunc result | 2066 int64_t d; // b trunc result |
2058 }Test; | 2067 }Test; |
2059 const int kTableLength = 15; | 2068 const int kTableLength = 15; |
2060 double inputs_D[kTableLength] = { | 2069 double inputs_D[kTableLength] = { |
2061 2.1, 2.6, 2.5, 3.1, 3.6, 3.5, | 2070 2.1, 2.6, 2.5, 3.1, 3.6, 3.5, |
2062 -2.1, -2.6, -2.5, -3.1, -3.6, -3.5, | 2071 -2.1, -2.6, -2.5, -3.1, -3.6, -3.5, |
2063 2147483648.0, | 2072 2147483648.0, |
2064 std::numeric_limits<double>::quiet_NaN(), | 2073 std::numeric_limits<double>::quiet_NaN(), |
2065 std::numeric_limits<double>::infinity() | 2074 std::numeric_limits<double>::infinity() |
2066 }; | 2075 }; |
2067 float inputs_S[kTableLength] = { | 2076 float inputs_S[kTableLength] = { |
2068 2.1, 2.6, 2.5, 3.1, 3.6, 3.5, | 2077 2.1, 2.6, 2.5, 3.1, 3.6, 3.5, |
2069 -2.1, -2.6, -2.5, -3.1, -3.6, -3.5, | 2078 -2.1, -2.6, -2.5, -3.1, -3.6, -3.5, |
2070 2147483648.0, | 2079 2147483648.0, |
2071 std::numeric_limits<float>::quiet_NaN(), | 2080 std::numeric_limits<float>::quiet_NaN(), |
2072 std::numeric_limits<float>::infinity() | 2081 std::numeric_limits<float>::infinity() |
2073 }; | 2082 }; |
2074 double outputs[kTableLength] = { | 2083 double outputs[kTableLength] = { |
2075 2.0, 2.0, 2.0, 3.0, 3.0, 3.0, | 2084 2.0, 2.0, 2.0, 3.0, 3.0, 3.0, |
2076 -2.0, -2.0, -2.0, -3.0, -3.0, -3.0, | 2085 -2.0, -2.0, -2.0, -3.0, -3.0, -3.0, |
2077 2147483648.0, dFPU64InvalidResult, | 2086 2147483648.0, dFPU64InvalidResult, |
2078 dFPU64InvalidResult}; | 2087 dFPU64InvalidResult}; |
| 2088 double outputsNaN2008[kTableLength] = { |
| 2089 2.0, 2.0, 2.0, 3.0, 3.0, 3.0, |
| 2090 -2.0, -2.0, -2.0, -3.0, -3.0, -3.0, |
| 2091 2147483648.0, dFPU64InvalidResult, |
| 2092 dFPU64InvalidResult}; |
2079 | 2093 |
| 2094 __ cfc1(t1, FCSR); |
| 2095 __ sw(t1, MemOperand(a0, offsetof(Test, isNaN2008))); |
2080 __ ldc1(f4, MemOperand(a0, offsetof(Test, a)) ); | 2096 __ ldc1(f4, MemOperand(a0, offsetof(Test, a)) ); |
2081 __ lwc1(f6, MemOperand(a0, offsetof(Test, b)) ); | 2097 __ lwc1(f6, MemOperand(a0, offsetof(Test, b)) ); |
2082 __ trunc_l_d(f8, f4); | 2098 __ trunc_l_d(f8, f4); |
2083 __ trunc_l_s(f10, f6); | 2099 __ trunc_l_s(f10, f6); |
2084 __ sdc1(f8, MemOperand(a0, offsetof(Test, c)) ); | 2100 __ sdc1(f8, MemOperand(a0, offsetof(Test, c)) ); |
2085 __ sdc1(f10, MemOperand(a0, offsetof(Test, d)) ); | 2101 __ sdc1(f10, MemOperand(a0, offsetof(Test, d)) ); |
2086 __ jr(ra); | 2102 __ jr(ra); |
2087 __ nop(); | 2103 __ nop(); |
2088 Test test; | 2104 Test test; |
2089 CodeDesc desc; | 2105 CodeDesc desc; |
2090 assm.GetCode(&desc); | 2106 assm.GetCode(&desc); |
2091 Handle<Code> code = isolate->factory()->NewCode( | 2107 Handle<Code> code = isolate->factory()->NewCode( |
2092 desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); | 2108 desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); |
2093 F3 f = FUNCTION_CAST<F3>(code->entry()); | 2109 F3 f = FUNCTION_CAST<F3>(code->entry()); |
2094 for (int i = 0; i < kTableLength; i++) { | 2110 for (int i = 0; i < kTableLength; i++) { |
2095 test.a = inputs_D[i]; | 2111 test.a = inputs_D[i]; |
2096 test.b = inputs_S[i]; | 2112 test.b = inputs_S[i]; |
2097 (CALL_GENERATED_CODE(isolate, f, &test, 0, 0, 0, 0)); | 2113 (CALL_GENERATED_CODE(isolate, f, &test, 0, 0, 0, 0)); |
2098 CHECK_EQ(test.c, outputs[i]); | 2114 if ((test.isNaN2008 & kFCSRNaN2008FlagMask) && |
| 2115 kArchVariant == kMips64r6) { |
| 2116 CHECK_EQ(test.c, outputsNaN2008[i]); |
| 2117 } else { |
| 2118 CHECK_EQ(test.c, outputs[i]); |
| 2119 } |
2099 CHECK_EQ(test.d, test.c); | 2120 CHECK_EQ(test.d, test.c); |
2100 } | 2121 } |
2101 } | 2122 } |
2102 } | 2123 } |
2103 | 2124 |
2104 | 2125 |
2105 TEST(movz_movn) { | 2126 TEST(movz_movn) { |
2106 if (kArchVariant == kMips64r2) { | 2127 if (kArchVariant == kMips64r2) { |
2107 const int kTableLength = 4; | 2128 const int kTableLength = 4; |
2108 CcTest::InitializeVM(); | 2129 CcTest::InitializeVM(); |
(...skipping 256 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2365 } | 2386 } |
2366 | 2387 |
2367 | 2388 |
2368 TEST(trunc_w) { | 2389 TEST(trunc_w) { |
2369 CcTest::InitializeVM(); | 2390 CcTest::InitializeVM(); |
2370 Isolate* isolate = CcTest::i_isolate(); | 2391 Isolate* isolate = CcTest::i_isolate(); |
2371 HandleScope scope(isolate); | 2392 HandleScope scope(isolate); |
2372 MacroAssembler assm(isolate, NULL, 0, v8::internal::CodeObjectRequired::kYes); | 2393 MacroAssembler assm(isolate, NULL, 0, v8::internal::CodeObjectRequired::kYes); |
2373 | 2394 |
2374 typedef struct test_float { | 2395 typedef struct test_float { |
| 2396 uint32_t isNaN2008; |
2375 double a; | 2397 double a; |
2376 float b; | 2398 float b; |
2377 int32_t c; // a trunc result | 2399 int32_t c; // a trunc result |
2378 int32_t d; // b trunc result | 2400 int32_t d; // b trunc result |
2379 }Test; | 2401 }Test; |
2380 const int kTableLength = 15; | 2402 const int kTableLength = 15; |
2381 double inputs_D[kTableLength] = { | 2403 double inputs_D[kTableLength] = { |
2382 2.1, 2.6, 2.5, 3.1, 3.6, 3.5, | 2404 2.1, 2.6, 2.5, 3.1, 3.6, 3.5, |
2383 -2.1, -2.6, -2.5, -3.1, -3.6, -3.5, | 2405 -2.1, -2.6, -2.5, -3.1, -3.6, -3.5, |
2384 2147483648.0, | 2406 2147483648.0, |
2385 std::numeric_limits<double>::quiet_NaN(), | 2407 std::numeric_limits<double>::quiet_NaN(), |
2386 std::numeric_limits<double>::infinity() | 2408 std::numeric_limits<double>::infinity() |
2387 }; | 2409 }; |
2388 float inputs_S[kTableLength] = { | 2410 float inputs_S[kTableLength] = { |
2389 2.1, 2.6, 2.5, 3.1, 3.6, 3.5, | 2411 2.1, 2.6, 2.5, 3.1, 3.6, 3.5, |
2390 -2.1, -2.6, -2.5, -3.1, -3.6, -3.5, | 2412 -2.1, -2.6, -2.5, -3.1, -3.6, -3.5, |
2391 2147483648.0, | 2413 2147483648.0, |
2392 std::numeric_limits<float>::quiet_NaN(), | 2414 std::numeric_limits<float>::quiet_NaN(), |
2393 std::numeric_limits<float>::infinity() | 2415 std::numeric_limits<float>::infinity() |
2394 }; | 2416 }; |
2395 double outputs[kTableLength] = { | 2417 double outputs[kTableLength] = { |
2396 2.0, 2.0, 2.0, 3.0, 3.0, 3.0, | 2418 2.0, 2.0, 2.0, 3.0, 3.0, 3.0, |
2397 -2.0, -2.0, -2.0, -3.0, -3.0, -3.0, | 2419 -2.0, -2.0, -2.0, -3.0, -3.0, -3.0, |
2398 kFPUInvalidResult, kFPUInvalidResult, | 2420 kFPUInvalidResult, kFPUInvalidResult, |
2399 kFPUInvalidResult}; | 2421 kFPUInvalidResult}; |
| 2422 double outputsNaN2008[kTableLength] = { |
| 2423 2.0, 2.0, 2.0, 3.0, 3.0, 3.0, |
| 2424 -2.0, -2.0, -2.0, -3.0, -3.0, -3.0, |
| 2425 kFPUInvalidResult, |
| 2426 0, |
| 2427 kFPUInvalidResult}; |
2400 | 2428 |
| 2429 __ cfc1(t1, FCSR); |
| 2430 __ sw(t1, MemOperand(a0, offsetof(Test, isNaN2008))); |
2401 __ ldc1(f4, MemOperand(a0, offsetof(Test, a)) ); | 2431 __ ldc1(f4, MemOperand(a0, offsetof(Test, a)) ); |
2402 __ lwc1(f6, MemOperand(a0, offsetof(Test, b)) ); | 2432 __ lwc1(f6, MemOperand(a0, offsetof(Test, b)) ); |
2403 __ trunc_w_d(f8, f4); | 2433 __ trunc_w_d(f8, f4); |
2404 __ trunc_w_s(f10, f6); | 2434 __ trunc_w_s(f10, f6); |
2405 __ swc1(f8, MemOperand(a0, offsetof(Test, c)) ); | 2435 __ swc1(f8, MemOperand(a0, offsetof(Test, c)) ); |
2406 __ swc1(f10, MemOperand(a0, offsetof(Test, d)) ); | 2436 __ swc1(f10, MemOperand(a0, offsetof(Test, d)) ); |
2407 __ jr(ra); | 2437 __ jr(ra); |
2408 __ nop(); | 2438 __ nop(); |
2409 Test test; | 2439 Test test; |
2410 CodeDesc desc; | 2440 CodeDesc desc; |
2411 assm.GetCode(&desc); | 2441 assm.GetCode(&desc); |
2412 Handle<Code> code = isolate->factory()->NewCode( | 2442 Handle<Code> code = isolate->factory()->NewCode( |
2413 desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); | 2443 desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); |
2414 F3 f = FUNCTION_CAST<F3>(code->entry()); | 2444 F3 f = FUNCTION_CAST<F3>(code->entry()); |
2415 for (int i = 0; i < kTableLength; i++) { | 2445 for (int i = 0; i < kTableLength; i++) { |
2416 test.a = inputs_D[i]; | 2446 test.a = inputs_D[i]; |
2417 test.b = inputs_S[i]; | 2447 test.b = inputs_S[i]; |
2418 (CALL_GENERATED_CODE(isolate, f, &test, 0, 0, 0, 0)); | 2448 (CALL_GENERATED_CODE(isolate, f, &test, 0, 0, 0, 0)); |
2419 CHECK_EQ(test.c, outputs[i]); | 2449 if ((test.isNaN2008 & kFCSRNaN2008FlagMask) && kArchVariant == kMips64r6) { |
| 2450 CHECK_EQ(test.c, outputsNaN2008[i]); |
| 2451 } else { |
| 2452 CHECK_EQ(test.c, outputs[i]); |
| 2453 } |
2420 CHECK_EQ(test.d, test.c); | 2454 CHECK_EQ(test.d, test.c); |
2421 } | 2455 } |
2422 } | 2456 } |
2423 | 2457 |
2424 | 2458 |
2425 TEST(round_w) { | 2459 TEST(round_w) { |
2426 CcTest::InitializeVM(); | 2460 CcTest::InitializeVM(); |
2427 Isolate* isolate = CcTest::i_isolate(); | 2461 Isolate* isolate = CcTest::i_isolate(); |
2428 HandleScope scope(isolate); | 2462 HandleScope scope(isolate); |
2429 MacroAssembler assm(isolate, NULL, 0, v8::internal::CodeObjectRequired::kYes); | 2463 MacroAssembler assm(isolate, NULL, 0, v8::internal::CodeObjectRequired::kYes); |
2430 | 2464 |
2431 typedef struct test_float { | 2465 typedef struct test_float { |
| 2466 uint32_t isNaN2008; |
2432 double a; | 2467 double a; |
2433 float b; | 2468 float b; |
2434 int32_t c; // a trunc result | 2469 int32_t c; // a trunc result |
2435 int32_t d; // b trunc result | 2470 int32_t d; // b trunc result |
2436 }Test; | 2471 }Test; |
2437 const int kTableLength = 15; | 2472 const int kTableLength = 15; |
2438 double inputs_D[kTableLength] = { | 2473 double inputs_D[kTableLength] = { |
2439 2.1, 2.6, 2.5, 3.1, 3.6, 3.5, | 2474 2.1, 2.6, 2.5, 3.1, 3.6, 3.5, |
2440 -2.1, -2.6, -2.5, -3.1, -3.6, -3.5, | 2475 -2.1, -2.6, -2.5, -3.1, -3.6, -3.5, |
2441 2147483648.0, | 2476 2147483648.0, |
2442 std::numeric_limits<double>::quiet_NaN(), | 2477 std::numeric_limits<double>::quiet_NaN(), |
2443 std::numeric_limits<double>::infinity() | 2478 std::numeric_limits<double>::infinity() |
2444 }; | 2479 }; |
2445 float inputs_S[kTableLength] = { | 2480 float inputs_S[kTableLength] = { |
2446 2.1, 2.6, 2.5, 3.1, 3.6, 3.5, | 2481 2.1, 2.6, 2.5, 3.1, 3.6, 3.5, |
2447 -2.1, -2.6, -2.5, -3.1, -3.6, -3.5, | 2482 -2.1, -2.6, -2.5, -3.1, -3.6, -3.5, |
2448 2147483648.0, | 2483 2147483648.0, |
2449 std::numeric_limits<float>::quiet_NaN(), | 2484 std::numeric_limits<float>::quiet_NaN(), |
2450 std::numeric_limits<float>::infinity() | 2485 std::numeric_limits<float>::infinity() |
2451 }; | 2486 }; |
2452 double outputs[kTableLength] = { | 2487 double outputs[kTableLength] = { |
2453 2.0, 3.0, 2.0, 3.0, 4.0, 4.0, | 2488 2.0, 3.0, 2.0, 3.0, 4.0, 4.0, |
2454 -2.0, -3.0, -2.0, -3.0, -4.0, -4.0, | 2489 -2.0, -3.0, -2.0, -3.0, -4.0, -4.0, |
2455 kFPUInvalidResult, kFPUInvalidResult, | 2490 kFPUInvalidResult, kFPUInvalidResult, |
2456 kFPUInvalidResult}; | 2491 kFPUInvalidResult}; |
| 2492 double outputsNaN2008[kTableLength] = { |
| 2493 2.0, 3.0, 2.0, 3.0, 4.0, 4.0, |
| 2494 -2.0, -3.0, -2.0, -3.0, -4.0, -4.0, |
| 2495 kFPUInvalidResult, 0, |
| 2496 kFPUInvalidResult}; |
2457 | 2497 |
| 2498 __ cfc1(t1, FCSR); |
| 2499 __ sw(t1, MemOperand(a0, offsetof(Test, isNaN2008))); |
2458 __ ldc1(f4, MemOperand(a0, offsetof(Test, a)) ); | 2500 __ ldc1(f4, MemOperand(a0, offsetof(Test, a)) ); |
2459 __ lwc1(f6, MemOperand(a0, offsetof(Test, b)) ); | 2501 __ lwc1(f6, MemOperand(a0, offsetof(Test, b)) ); |
2460 __ round_w_d(f8, f4); | 2502 __ round_w_d(f8, f4); |
2461 __ round_w_s(f10, f6); | 2503 __ round_w_s(f10, f6); |
2462 __ swc1(f8, MemOperand(a0, offsetof(Test, c)) ); | 2504 __ swc1(f8, MemOperand(a0, offsetof(Test, c)) ); |
2463 __ swc1(f10, MemOperand(a0, offsetof(Test, d)) ); | 2505 __ swc1(f10, MemOperand(a0, offsetof(Test, d)) ); |
2464 __ jr(ra); | 2506 __ jr(ra); |
2465 __ nop(); | 2507 __ nop(); |
2466 Test test; | 2508 Test test; |
2467 CodeDesc desc; | 2509 CodeDesc desc; |
2468 assm.GetCode(&desc); | 2510 assm.GetCode(&desc); |
2469 Handle<Code> code = isolate->factory()->NewCode( | 2511 Handle<Code> code = isolate->factory()->NewCode( |
2470 desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); | 2512 desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); |
2471 F3 f = FUNCTION_CAST<F3>(code->entry()); | 2513 F3 f = FUNCTION_CAST<F3>(code->entry()); |
2472 for (int i = 0; i < kTableLength; i++) { | 2514 for (int i = 0; i < kTableLength; i++) { |
2473 test.a = inputs_D[i]; | 2515 test.a = inputs_D[i]; |
2474 test.b = inputs_S[i]; | 2516 test.b = inputs_S[i]; |
2475 (CALL_GENERATED_CODE(isolate, f, &test, 0, 0, 0, 0)); | 2517 (CALL_GENERATED_CODE(isolate, f, &test, 0, 0, 0, 0)); |
2476 CHECK_EQ(test.c, outputs[i]); | 2518 if ((test.isNaN2008 & kFCSRNaN2008FlagMask) && kArchVariant == kMips64r6) { |
| 2519 CHECK_EQ(test.c, outputsNaN2008[i]); |
| 2520 } else { |
| 2521 CHECK_EQ(test.c, outputs[i]); |
| 2522 } |
2477 CHECK_EQ(test.d, test.c); | 2523 CHECK_EQ(test.d, test.c); |
2478 } | 2524 } |
2479 } | 2525 } |
2480 | 2526 |
2481 | 2527 |
2482 TEST(round_l) { | 2528 TEST(round_l) { |
2483 CcTest::InitializeVM(); | 2529 CcTest::InitializeVM(); |
2484 Isolate* isolate = CcTest::i_isolate(); | 2530 Isolate* isolate = CcTest::i_isolate(); |
2485 HandleScope scope(isolate); | 2531 HandleScope scope(isolate); |
2486 MacroAssembler assm(isolate, NULL, 0, | 2532 MacroAssembler assm(isolate, NULL, 0, |
2487 v8::internal::CodeObjectRequired::kYes); | 2533 v8::internal::CodeObjectRequired::kYes); |
2488 const double dFPU64InvalidResult = static_cast<double>(kFPU64InvalidResult); | 2534 const double dFPU64InvalidResult = static_cast<double>(kFPU64InvalidResult); |
2489 typedef struct test_float { | 2535 typedef struct test_float { |
| 2536 uint32_t isNaN2008; |
2490 double a; | 2537 double a; |
2491 float b; | 2538 float b; |
2492 int64_t c; | 2539 int64_t c; |
2493 int64_t d; | 2540 int64_t d; |
2494 }Test; | 2541 }Test; |
2495 const int kTableLength = 15; | 2542 const int kTableLength = 15; |
2496 double inputs_D[kTableLength] = { | 2543 double inputs_D[kTableLength] = { |
2497 2.1, 2.6, 2.5, 3.1, 3.6, 3.5, | 2544 2.1, 2.6, 2.5, 3.1, 3.6, 3.5, |
2498 -2.1, -2.6, -2.5, -3.1, -3.6, -3.5, | 2545 -2.1, -2.6, -2.5, -3.1, -3.6, -3.5, |
2499 2147483648.0, | 2546 2147483648.0, |
2500 std::numeric_limits<double>::quiet_NaN(), | 2547 std::numeric_limits<double>::quiet_NaN(), |
2501 std::numeric_limits<double>::infinity() | 2548 std::numeric_limits<double>::infinity() |
2502 }; | 2549 }; |
2503 float inputs_S[kTableLength] = { | 2550 float inputs_S[kTableLength] = { |
2504 2.1, 2.6, 2.5, 3.1, 3.6, 3.5, | 2551 2.1, 2.6, 2.5, 3.1, 3.6, 3.5, |
2505 -2.1, -2.6, -2.5, -3.1, -3.6, -3.5, | 2552 -2.1, -2.6, -2.5, -3.1, -3.6, -3.5, |
2506 2147483648.0, | 2553 2147483648.0, |
2507 std::numeric_limits<float>::quiet_NaN(), | 2554 std::numeric_limits<float>::quiet_NaN(), |
2508 std::numeric_limits<float>::infinity() | 2555 std::numeric_limits<float>::infinity() |
2509 }; | 2556 }; |
2510 double outputs[kTableLength] = { | 2557 double outputs[kTableLength] = { |
2511 2.0, 3.0, 2.0, 3.0, 4.0, 4.0, | 2558 2.0, 3.0, 2.0, 3.0, 4.0, 4.0, |
2512 -2.0, -3.0, -2.0, -3.0, -4.0, -4.0, | 2559 -2.0, -3.0, -2.0, -3.0, -4.0, -4.0, |
2513 2147483648.0, dFPU64InvalidResult, | 2560 2147483648.0, dFPU64InvalidResult, |
2514 dFPU64InvalidResult}; | 2561 dFPU64InvalidResult}; |
| 2562 double outputsNaN2008[kTableLength] = { |
| 2563 2.0, 3.0, 2.0, 3.0, 4.0, 4.0, |
| 2564 -2.0, -3.0, -2.0, -3.0, -4.0, -4.0, |
| 2565 2147483648.0, |
| 2566 0, |
| 2567 dFPU64InvalidResult}; |
2515 | 2568 |
| 2569 __ cfc1(t1, FCSR); |
| 2570 __ sw(t1, MemOperand(a0, offsetof(Test, isNaN2008))); |
2516 __ ldc1(f4, MemOperand(a0, offsetof(Test, a)) ); | 2571 __ ldc1(f4, MemOperand(a0, offsetof(Test, a)) ); |
2517 __ lwc1(f6, MemOperand(a0, offsetof(Test, b)) ); | 2572 __ lwc1(f6, MemOperand(a0, offsetof(Test, b)) ); |
2518 __ round_l_d(f8, f4); | 2573 __ round_l_d(f8, f4); |
2519 __ round_l_s(f10, f6); | 2574 __ round_l_s(f10, f6); |
2520 __ sdc1(f8, MemOperand(a0, offsetof(Test, c)) ); | 2575 __ sdc1(f8, MemOperand(a0, offsetof(Test, c)) ); |
2521 __ sdc1(f10, MemOperand(a0, offsetof(Test, d)) ); | 2576 __ sdc1(f10, MemOperand(a0, offsetof(Test, d)) ); |
2522 __ jr(ra); | 2577 __ jr(ra); |
2523 __ nop(); | 2578 __ nop(); |
2524 Test test; | 2579 Test test; |
2525 CodeDesc desc; | 2580 CodeDesc desc; |
2526 assm.GetCode(&desc); | 2581 assm.GetCode(&desc); |
2527 Handle<Code> code = isolate->factory()->NewCode( | 2582 Handle<Code> code = isolate->factory()->NewCode( |
2528 desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); | 2583 desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); |
2529 F3 f = FUNCTION_CAST<F3>(code->entry()); | 2584 F3 f = FUNCTION_CAST<F3>(code->entry()); |
2530 for (int i = 0; i < kTableLength; i++) { | 2585 for (int i = 0; i < kTableLength; i++) { |
2531 test.a = inputs_D[i]; | 2586 test.a = inputs_D[i]; |
2532 test.b = inputs_S[i]; | 2587 test.b = inputs_S[i]; |
2533 std::cout<< i<< "\n"; | |
2534 (CALL_GENERATED_CODE(isolate, f, &test, 0, 0, 0, 0)); | 2588 (CALL_GENERATED_CODE(isolate, f, &test, 0, 0, 0, 0)); |
2535 CHECK_EQ(test.c, outputs[i]); | 2589 if ((test.isNaN2008 & kFCSRNaN2008FlagMask) && |
| 2590 kArchVariant == kMips64r6) { |
| 2591 CHECK_EQ(test.c, outputsNaN2008[i]); |
| 2592 } else { |
| 2593 CHECK_EQ(test.c, outputs[i]); |
| 2594 } |
2536 CHECK_EQ(test.d, test.c); | 2595 CHECK_EQ(test.d, test.c); |
2537 } | 2596 } |
2538 } | 2597 } |
2539 | 2598 |
2540 | 2599 |
2541 TEST(sub) { | 2600 TEST(sub) { |
2542 const int kTableLength = 12; | 2601 const int kTableLength = 12; |
2543 CcTest::InitializeVM(); | 2602 CcTest::InitializeVM(); |
2544 Isolate* isolate = CcTest::i_isolate(); | 2603 Isolate* isolate = CcTest::i_isolate(); |
2545 HandleScope scope(isolate); | 2604 HandleScope scope(isolate); |
(...skipping 324 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2870 } | 2929 } |
2871 | 2930 |
2872 | 2931 |
2873 TEST(floor_w) { | 2932 TEST(floor_w) { |
2874 CcTest::InitializeVM(); | 2933 CcTest::InitializeVM(); |
2875 Isolate* isolate = CcTest::i_isolate(); | 2934 Isolate* isolate = CcTest::i_isolate(); |
2876 HandleScope scope(isolate); | 2935 HandleScope scope(isolate); |
2877 MacroAssembler assm(isolate, NULL, 0, v8::internal::CodeObjectRequired::kYes); | 2936 MacroAssembler assm(isolate, NULL, 0, v8::internal::CodeObjectRequired::kYes); |
2878 | 2937 |
2879 typedef struct test_float { | 2938 typedef struct test_float { |
| 2939 uint32_t isNaN2008; |
2880 double a; | 2940 double a; |
2881 float b; | 2941 float b; |
2882 int32_t c; // a floor result | 2942 int32_t c; // a floor result |
2883 int32_t d; // b floor result | 2943 int32_t d; // b floor result |
2884 }Test; | 2944 }Test; |
2885 const int kTableLength = 15; | 2945 const int kTableLength = 15; |
2886 double inputs_D[kTableLength] = { | 2946 double inputs_D[kTableLength] = { |
2887 2.1, 2.6, 2.5, 3.1, 3.6, 3.5, | 2947 2.1, 2.6, 2.5, 3.1, 3.6, 3.5, |
2888 -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, |
2889 2147483648.0, | 2949 2147483648.0, |
2890 std::numeric_limits<double>::quiet_NaN(), | 2950 std::numeric_limits<double>::quiet_NaN(), |
2891 std::numeric_limits<double>::infinity() | 2951 std::numeric_limits<double>::infinity() |
2892 }; | 2952 }; |
2893 float inputs_S[kTableLength] = { | 2953 float inputs_S[kTableLength] = { |
2894 2.1, 2.6, 2.5, 3.1, 3.6, 3.5, | 2954 2.1, 2.6, 2.5, 3.1, 3.6, 3.5, |
2895 -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, |
2896 2147483648.0, | 2956 2147483648.0, |
2897 std::numeric_limits<float>::quiet_NaN(), | 2957 std::numeric_limits<float>::quiet_NaN(), |
2898 std::numeric_limits<float>::infinity() | 2958 std::numeric_limits<float>::infinity() |
2899 }; | 2959 }; |
2900 double outputs[kTableLength] = { | 2960 double outputs[kTableLength] = { |
2901 2.0, 2.0, 2.0, 3.0, 3.0, 3.0, | 2961 2.0, 2.0, 2.0, 3.0, 3.0, 3.0, |
2902 -3.0, -3.0, -3.0, -4.0, -4.0, -4.0, | 2962 -3.0, -3.0, -3.0, -4.0, -4.0, -4.0, |
2903 kFPUInvalidResult, kFPUInvalidResult, | 2963 kFPUInvalidResult, kFPUInvalidResult, |
2904 kFPUInvalidResult}; | 2964 kFPUInvalidResult}; |
| 2965 double outputsNaN2008[kTableLength] = { |
| 2966 2.0, 2.0, 2.0, 3.0, 3.0, 3.0, |
| 2967 -3.0, -3.0, -3.0, -4.0, -4.0, -4.0, |
| 2968 kFPUInvalidResult, |
| 2969 0, |
| 2970 kFPUInvalidResult}; |
2905 | 2971 |
| 2972 __ cfc1(t1, FCSR); |
| 2973 __ sw(t1, MemOperand(a0, offsetof(Test, isNaN2008))); |
2906 __ ldc1(f4, MemOperand(a0, offsetof(Test, a)) ); | 2974 __ ldc1(f4, MemOperand(a0, offsetof(Test, a)) ); |
2907 __ lwc1(f6, MemOperand(a0, offsetof(Test, b)) ); | 2975 __ lwc1(f6, MemOperand(a0, offsetof(Test, b)) ); |
2908 __ floor_w_d(f8, f4); | 2976 __ floor_w_d(f8, f4); |
2909 __ floor_w_s(f10, f6); | 2977 __ floor_w_s(f10, f6); |
2910 __ swc1(f8, MemOperand(a0, offsetof(Test, c)) ); | 2978 __ swc1(f8, MemOperand(a0, offsetof(Test, c)) ); |
2911 __ swc1(f10, MemOperand(a0, offsetof(Test, d)) ); | 2979 __ swc1(f10, MemOperand(a0, offsetof(Test, d)) ); |
2912 __ jr(ra); | 2980 __ jr(ra); |
2913 __ nop(); | 2981 __ nop(); |
2914 Test test; | 2982 Test test; |
2915 CodeDesc desc; | 2983 CodeDesc desc; |
2916 assm.GetCode(&desc); | 2984 assm.GetCode(&desc); |
2917 Handle<Code> code = isolate->factory()->NewCode( | 2985 Handle<Code> code = isolate->factory()->NewCode( |
2918 desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); | 2986 desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); |
2919 F3 f = FUNCTION_CAST<F3>(code->entry()); | 2987 F3 f = FUNCTION_CAST<F3>(code->entry()); |
2920 for (int i = 0; i < kTableLength; i++) { | 2988 for (int i = 0; i < kTableLength; i++) { |
2921 test.a = inputs_D[i]; | 2989 test.a = inputs_D[i]; |
2922 test.b = inputs_S[i]; | 2990 test.b = inputs_S[i]; |
2923 (CALL_GENERATED_CODE(isolate, f, &test, 0, 0, 0, 0)); | 2991 (CALL_GENERATED_CODE(isolate, f, &test, 0, 0, 0, 0)); |
2924 CHECK_EQ(test.c, outputs[i]); | 2992 if ((test.isNaN2008 & kFCSRNaN2008FlagMask) && kArchVariant == kMips64r6) { |
| 2993 CHECK_EQ(test.c, outputsNaN2008[i]); |
| 2994 } else { |
| 2995 CHECK_EQ(test.c, outputs[i]); |
| 2996 } |
2925 CHECK_EQ(test.d, test.c); | 2997 CHECK_EQ(test.d, test.c); |
2926 } | 2998 } |
2927 } | 2999 } |
2928 | 3000 |
2929 | 3001 |
2930 TEST(floor_l) { | 3002 TEST(floor_l) { |
2931 CcTest::InitializeVM(); | 3003 CcTest::InitializeVM(); |
2932 Isolate* isolate = CcTest::i_isolate(); | 3004 Isolate* isolate = CcTest::i_isolate(); |
2933 HandleScope scope(isolate); | 3005 HandleScope scope(isolate); |
2934 MacroAssembler assm(isolate, NULL, 0, | 3006 MacroAssembler assm(isolate, NULL, 0, |
2935 v8::internal::CodeObjectRequired::kYes); | 3007 v8::internal::CodeObjectRequired::kYes); |
2936 const double dFPU64InvalidResult = static_cast<double>(kFPU64InvalidResult); | 3008 const double dFPU64InvalidResult = static_cast<double>(kFPU64InvalidResult); |
2937 typedef struct test_float { | 3009 typedef struct test_float { |
| 3010 uint32_t isNaN2008; |
2938 double a; | 3011 double a; |
2939 float b; | 3012 float b; |
2940 int64_t c; | 3013 int64_t c; |
2941 int64_t d; | 3014 int64_t d; |
2942 }Test; | 3015 }Test; |
2943 const int kTableLength = 15; | 3016 const int kTableLength = 15; |
2944 double inputs_D[kTableLength] = { | 3017 double inputs_D[kTableLength] = { |
2945 2.1, 2.6, 2.5, 3.1, 3.6, 3.5, | 3018 2.1, 2.6, 2.5, 3.1, 3.6, 3.5, |
2946 -2.1, -2.6, -2.5, -3.1, -3.6, -3.5, | 3019 -2.1, -2.6, -2.5, -3.1, -3.6, -3.5, |
2947 2147483648.0, | 3020 2147483648.0, |
2948 std::numeric_limits<double>::quiet_NaN(), | 3021 std::numeric_limits<double>::quiet_NaN(), |
2949 std::numeric_limits<double>::infinity() | 3022 std::numeric_limits<double>::infinity() |
2950 }; | 3023 }; |
2951 float inputs_S[kTableLength] = { | 3024 float inputs_S[kTableLength] = { |
2952 2.1, 2.6, 2.5, 3.1, 3.6, 3.5, | 3025 2.1, 2.6, 2.5, 3.1, 3.6, 3.5, |
2953 -2.1, -2.6, -2.5, -3.1, -3.6, -3.5, | 3026 -2.1, -2.6, -2.5, -3.1, -3.6, -3.5, |
2954 2147483648.0, | 3027 2147483648.0, |
2955 std::numeric_limits<float>::quiet_NaN(), | 3028 std::numeric_limits<float>::quiet_NaN(), |
2956 std::numeric_limits<float>::infinity() | 3029 std::numeric_limits<float>::infinity() |
2957 }; | 3030 }; |
2958 double outputs[kTableLength] = { | 3031 double outputs[kTableLength] = { |
2959 2.0, 2.0, 2.0, 3.0, 3.0, 3.0, | 3032 2.0, 2.0, 2.0, 3.0, 3.0, 3.0, |
2960 -3.0, -3.0, -3.0, -4.0, -4.0, -4.0, | 3033 -3.0, -3.0, -3.0, -4.0, -4.0, -4.0, |
2961 2147483648.0, dFPU64InvalidResult, | 3034 2147483648.0, dFPU64InvalidResult, |
2962 dFPU64InvalidResult}; | 3035 dFPU64InvalidResult}; |
| 3036 double outputsNaN2008[kTableLength] = { |
| 3037 2.0, 2.0, 2.0, 3.0, 3.0, 3.0, |
| 3038 -3.0, -3.0, -3.0, -4.0, -4.0, -4.0, |
| 3039 2147483648.0, |
| 3040 0, |
| 3041 dFPU64InvalidResult}; |
2963 | 3042 |
| 3043 __ cfc1(t1, FCSR); |
| 3044 __ sw(t1, MemOperand(a0, offsetof(Test, isNaN2008))); |
2964 __ ldc1(f4, MemOperand(a0, offsetof(Test, a)) ); | 3045 __ ldc1(f4, MemOperand(a0, offsetof(Test, a)) ); |
2965 __ lwc1(f6, MemOperand(a0, offsetof(Test, b)) ); | 3046 __ lwc1(f6, MemOperand(a0, offsetof(Test, b)) ); |
2966 __ floor_l_d(f8, f4); | 3047 __ floor_l_d(f8, f4); |
2967 __ floor_l_s(f10, f6); | 3048 __ floor_l_s(f10, f6); |
2968 __ sdc1(f8, MemOperand(a0, offsetof(Test, c)) ); | 3049 __ sdc1(f8, MemOperand(a0, offsetof(Test, c)) ); |
2969 __ sdc1(f10, MemOperand(a0, offsetof(Test, d)) ); | 3050 __ sdc1(f10, MemOperand(a0, offsetof(Test, d)) ); |
2970 __ jr(ra); | 3051 __ jr(ra); |
2971 __ nop(); | 3052 __ nop(); |
2972 Test test; | 3053 Test test; |
2973 CodeDesc desc; | 3054 CodeDesc desc; |
2974 assm.GetCode(&desc); | 3055 assm.GetCode(&desc); |
2975 Handle<Code> code = isolate->factory()->NewCode( | 3056 Handle<Code> code = isolate->factory()->NewCode( |
2976 desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); | 3057 desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); |
2977 F3 f = FUNCTION_CAST<F3>(code->entry()); | 3058 F3 f = FUNCTION_CAST<F3>(code->entry()); |
2978 for (int i = 0; i < kTableLength; i++) { | 3059 for (int i = 0; i < kTableLength; i++) { |
2979 test.a = inputs_D[i]; | 3060 test.a = inputs_D[i]; |
2980 test.b = inputs_S[i]; | 3061 test.b = inputs_S[i]; |
2981 (CALL_GENERATED_CODE(isolate, f, &test, 0, 0, 0, 0)); | 3062 (CALL_GENERATED_CODE(isolate, f, &test, 0, 0, 0, 0)); |
2982 CHECK_EQ(test.c, outputs[i]); | 3063 if ((test.isNaN2008 & kFCSRNaN2008FlagMask) && |
| 3064 kArchVariant == kMips64r6) { |
| 3065 CHECK_EQ(test.c, outputsNaN2008[i]); |
| 3066 } else { |
| 3067 CHECK_EQ(test.c, outputs[i]); |
| 3068 } |
2983 CHECK_EQ(test.d, test.c); | 3069 CHECK_EQ(test.d, test.c); |
2984 } | 3070 } |
2985 } | 3071 } |
2986 | 3072 |
2987 | 3073 |
2988 TEST(ceil_w) { | 3074 TEST(ceil_w) { |
2989 CcTest::InitializeVM(); | 3075 CcTest::InitializeVM(); |
2990 Isolate* isolate = CcTest::i_isolate(); | 3076 Isolate* isolate = CcTest::i_isolate(); |
2991 HandleScope scope(isolate); | 3077 HandleScope scope(isolate); |
2992 MacroAssembler assm(isolate, NULL, 0, v8::internal::CodeObjectRequired::kYes); | 3078 MacroAssembler assm(isolate, NULL, 0, v8::internal::CodeObjectRequired::kYes); |
2993 | 3079 |
2994 typedef struct test_float { | 3080 typedef struct test_float { |
| 3081 uint32_t isNaN2008; |
2995 double a; | 3082 double a; |
2996 float b; | 3083 float b; |
2997 int32_t c; // a floor result | 3084 int32_t c; // a floor result |
2998 int32_t d; // b floor result | 3085 int32_t d; // b floor result |
2999 }Test; | 3086 }Test; |
3000 const int kTableLength = 15; | 3087 const int kTableLength = 15; |
3001 double inputs_D[kTableLength] = { | 3088 double inputs_D[kTableLength] = { |
3002 2.1, 2.6, 2.5, 3.1, 3.6, 3.5, | 3089 2.1, 2.6, 2.5, 3.1, 3.6, 3.5, |
3003 -2.1, -2.6, -2.5, -3.1, -3.6, -3.5, | 3090 -2.1, -2.6, -2.5, -3.1, -3.6, -3.5, |
3004 2147483648.0, | 3091 2147483648.0, |
3005 std::numeric_limits<double>::quiet_NaN(), | 3092 std::numeric_limits<double>::quiet_NaN(), |
3006 std::numeric_limits<double>::infinity() | 3093 std::numeric_limits<double>::infinity() |
3007 }; | 3094 }; |
3008 float inputs_S[kTableLength] = { | 3095 float inputs_S[kTableLength] = { |
3009 2.1, 2.6, 2.5, 3.1, 3.6, 3.5, | 3096 2.1, 2.6, 2.5, 3.1, 3.6, 3.5, |
3010 -2.1, -2.6, -2.5, -3.1, -3.6, -3.5, | 3097 -2.1, -2.6, -2.5, -3.1, -3.6, -3.5, |
3011 2147483648.0, | 3098 2147483648.0, |
3012 std::numeric_limits<float>::quiet_NaN(), | 3099 std::numeric_limits<float>::quiet_NaN(), |
3013 std::numeric_limits<float>::infinity() | 3100 std::numeric_limits<float>::infinity() |
3014 }; | 3101 }; |
3015 double outputs[kTableLength] = { | 3102 double outputs[kTableLength] = { |
3016 3.0, 3.0, 3.0, 4.0, 4.0, 4.0, | 3103 3.0, 3.0, 3.0, 4.0, 4.0, 4.0, |
3017 -2.0, -2.0, -2.0, -3.0, -3.0, -3.0, | 3104 -2.0, -2.0, -2.0, -3.0, -3.0, -3.0, |
3018 kFPUInvalidResult, kFPUInvalidResult, | 3105 kFPUInvalidResult, kFPUInvalidResult, |
3019 kFPUInvalidResult}; | 3106 kFPUInvalidResult}; |
| 3107 double outputsNaN2008[kTableLength] = { |
| 3108 3.0, 3.0, 3.0, 4.0, 4.0, 4.0, |
| 3109 -2.0, -2.0, -2.0, -3.0, -3.0, -3.0, |
| 3110 kFPUInvalidResult, |
| 3111 0, |
| 3112 kFPUInvalidResult}; |
3020 | 3113 |
| 3114 __ cfc1(t1, FCSR); |
| 3115 __ sw(t1, MemOperand(a0, offsetof(Test, isNaN2008))); |
3021 __ ldc1(f4, MemOperand(a0, offsetof(Test, a)) ); | 3116 __ ldc1(f4, MemOperand(a0, offsetof(Test, a)) ); |
3022 __ lwc1(f6, MemOperand(a0, offsetof(Test, b)) ); | 3117 __ lwc1(f6, MemOperand(a0, offsetof(Test, b)) ); |
3023 __ ceil_w_d(f8, f4); | 3118 __ ceil_w_d(f8, f4); |
3024 __ ceil_w_s(f10, f6); | 3119 __ ceil_w_s(f10, f6); |
3025 __ swc1(f8, MemOperand(a0, offsetof(Test, c)) ); | 3120 __ swc1(f8, MemOperand(a0, offsetof(Test, c)) ); |
3026 __ swc1(f10, MemOperand(a0, offsetof(Test, d)) ); | 3121 __ swc1(f10, MemOperand(a0, offsetof(Test, d)) ); |
3027 __ jr(ra); | 3122 __ jr(ra); |
3028 __ nop(); | 3123 __ nop(); |
3029 Test test; | 3124 Test test; |
3030 CodeDesc desc; | 3125 CodeDesc desc; |
3031 assm.GetCode(&desc); | 3126 assm.GetCode(&desc); |
3032 Handle<Code> code = isolate->factory()->NewCode( | 3127 Handle<Code> code = isolate->factory()->NewCode( |
3033 desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); | 3128 desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); |
3034 F3 f = FUNCTION_CAST<F3>(code->entry()); | 3129 F3 f = FUNCTION_CAST<F3>(code->entry()); |
3035 for (int i = 0; i < kTableLength; i++) { | 3130 for (int i = 0; i < kTableLength; i++) { |
3036 test.a = inputs_D[i]; | 3131 test.a = inputs_D[i]; |
3037 test.b = inputs_S[i]; | 3132 test.b = inputs_S[i]; |
3038 (CALL_GENERATED_CODE(isolate, f, &test, 0, 0, 0, 0)); | 3133 (CALL_GENERATED_CODE(isolate, f, &test, 0, 0, 0, 0)); |
3039 CHECK_EQ(test.c, outputs[i]); | 3134 if ((test.isNaN2008 & kFCSRNaN2008FlagMask) && kArchVariant == kMips64r6) { |
| 3135 CHECK_EQ(test.c, outputsNaN2008[i]); |
| 3136 } else { |
| 3137 CHECK_EQ(test.c, outputs[i]); |
| 3138 } |
3040 CHECK_EQ(test.d, test.c); | 3139 CHECK_EQ(test.d, test.c); |
3041 } | 3140 } |
3042 } | 3141 } |
3043 | 3142 |
3044 | 3143 |
3045 TEST(ceil_l) { | 3144 TEST(ceil_l) { |
3046 CcTest::InitializeVM(); | 3145 CcTest::InitializeVM(); |
3047 Isolate* isolate = CcTest::i_isolate(); | 3146 Isolate* isolate = CcTest::i_isolate(); |
3048 HandleScope scope(isolate); | 3147 HandleScope scope(isolate); |
3049 MacroAssembler assm(isolate, NULL, 0, | 3148 MacroAssembler assm(isolate, NULL, 0, |
3050 v8::internal::CodeObjectRequired::kYes); | 3149 v8::internal::CodeObjectRequired::kYes); |
3051 const double dFPU64InvalidResult = static_cast<double>(kFPU64InvalidResult); | 3150 const double dFPU64InvalidResult = static_cast<double>(kFPU64InvalidResult); |
3052 typedef struct test_float { | 3151 typedef struct test_float { |
| 3152 uint32_t isNaN2008; |
3053 double a; | 3153 double a; |
3054 float b; | 3154 float b; |
3055 int64_t c; | 3155 int64_t c; |
3056 int64_t d; | 3156 int64_t d; |
3057 }Test; | 3157 }Test; |
3058 const int kTableLength = 15; | 3158 const int kTableLength = 15; |
3059 double inputs_D[kTableLength] = { | 3159 double inputs_D[kTableLength] = { |
3060 2.1, 2.6, 2.5, 3.1, 3.6, 3.5, | 3160 2.1, 2.6, 2.5, 3.1, 3.6, 3.5, |
3061 -2.1, -2.6, -2.5, -3.1, -3.6, -3.5, | 3161 -2.1, -2.6, -2.5, -3.1, -3.6, -3.5, |
3062 2147483648.0, | 3162 2147483648.0, |
3063 std::numeric_limits<double>::quiet_NaN(), | 3163 std::numeric_limits<double>::quiet_NaN(), |
3064 std::numeric_limits<double>::infinity() | 3164 std::numeric_limits<double>::infinity() |
3065 }; | 3165 }; |
3066 float inputs_S[kTableLength] = { | 3166 float inputs_S[kTableLength] = { |
3067 2.1, 2.6, 2.5, 3.1, 3.6, 3.5, | 3167 2.1, 2.6, 2.5, 3.1, 3.6, 3.5, |
3068 -2.1, -2.6, -2.5, -3.1, -3.6, -3.5, | 3168 -2.1, -2.6, -2.5, -3.1, -3.6, -3.5, |
3069 2147483648.0, | 3169 2147483648.0, |
3070 std::numeric_limits<float>::quiet_NaN(), | 3170 std::numeric_limits<float>::quiet_NaN(), |
3071 std::numeric_limits<float>::infinity() | 3171 std::numeric_limits<float>::infinity() |
3072 }; | 3172 }; |
3073 double outputs[kTableLength] = { | 3173 double outputs[kTableLength] = { |
3074 3.0, 3.0, 3.0, 4.0, 4.0, 4.0, | 3174 3.0, 3.0, 3.0, 4.0, 4.0, 4.0, |
3075 -2.0, -2.0, -2.0, -3.0, -3.0, -3.0, | 3175 -2.0, -2.0, -2.0, -3.0, -3.0, -3.0, |
3076 2147483648.0, dFPU64InvalidResult, | 3176 2147483648.0, dFPU64InvalidResult, |
3077 dFPU64InvalidResult}; | 3177 dFPU64InvalidResult}; |
| 3178 double outputsNaN2008[kTableLength] = { |
| 3179 3.0, 3.0, 3.0, 4.0, 4.0, 4.0, |
| 3180 -2.0, -2.0, -2.0, -3.0, -3.0, -3.0, |
| 3181 2147483648.0, |
| 3182 0, |
| 3183 dFPU64InvalidResult}; |
3078 | 3184 |
| 3185 __ cfc1(t1, FCSR); |
| 3186 __ sw(t1, MemOperand(a0, offsetof(Test, isNaN2008))); |
3079 __ ldc1(f4, MemOperand(a0, offsetof(Test, a)) ); | 3187 __ ldc1(f4, MemOperand(a0, offsetof(Test, a)) ); |
3080 __ lwc1(f6, MemOperand(a0, offsetof(Test, b)) ); | 3188 __ lwc1(f6, MemOperand(a0, offsetof(Test, b)) ); |
3081 __ ceil_l_d(f8, f4); | 3189 __ ceil_l_d(f8, f4); |
3082 __ ceil_l_s(f10, f6); | 3190 __ ceil_l_s(f10, f6); |
3083 __ sdc1(f8, MemOperand(a0, offsetof(Test, c)) ); | 3191 __ sdc1(f8, MemOperand(a0, offsetof(Test, c)) ); |
3084 __ sdc1(f10, MemOperand(a0, offsetof(Test, d)) ); | 3192 __ sdc1(f10, MemOperand(a0, offsetof(Test, d)) ); |
3085 __ jr(ra); | 3193 __ jr(ra); |
3086 __ nop(); | 3194 __ nop(); |
3087 Test test; | 3195 Test test; |
3088 CodeDesc desc; | 3196 CodeDesc desc; |
3089 assm.GetCode(&desc); | 3197 assm.GetCode(&desc); |
3090 Handle<Code> code = isolate->factory()->NewCode( | 3198 Handle<Code> code = isolate->factory()->NewCode( |
3091 desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); | 3199 desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); |
3092 F3 f = FUNCTION_CAST<F3>(code->entry()); | 3200 F3 f = FUNCTION_CAST<F3>(code->entry()); |
3093 for (int i = 0; i < kTableLength; i++) { | 3201 for (int i = 0; i < kTableLength; i++) { |
3094 test.a = inputs_D[i]; | 3202 test.a = inputs_D[i]; |
3095 test.b = inputs_S[i]; | 3203 test.b = inputs_S[i]; |
3096 (CALL_GENERATED_CODE(isolate, f, &test, 0, 0, 0, 0)); | 3204 (CALL_GENERATED_CODE(isolate, f, &test, 0, 0, 0, 0)); |
3097 CHECK_EQ(test.c, outputs[i]); | 3205 if ((test.isNaN2008 & kFCSRNaN2008FlagMask) && |
| 3206 kArchVariant == kMips64r6) { |
| 3207 CHECK_EQ(test.c, outputsNaN2008[i]); |
| 3208 } else { |
| 3209 CHECK_EQ(test.c, outputs[i]); |
| 3210 } |
3098 CHECK_EQ(test.d, test.c); | 3211 CHECK_EQ(test.d, test.c); |
3099 } | 3212 } |
3100 } | 3213 } |
3101 | 3214 |
3102 | 3215 |
3103 TEST(jump_tables1) { | 3216 TEST(jump_tables1) { |
3104 // Test jump tables with forward jumps. | 3217 // Test jump tables with forward jumps. |
3105 CcTest::InitializeVM(); | 3218 CcTest::InitializeVM(); |
3106 Isolate* isolate = CcTest::i_isolate(); | 3219 Isolate* isolate = CcTest::i_isolate(); |
3107 HandleScope scope(isolate); | 3220 HandleScope scope(isolate); |
(...skipping 2607 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5715 desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); | 5828 desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); |
5716 F2 f = FUNCTION_CAST<F2>(code->entry()); | 5829 F2 f = FUNCTION_CAST<F2>(code->entry()); |
5717 | 5830 |
5718 int64_t res = reinterpret_cast<int64_t>( | 5831 int64_t res = reinterpret_cast<int64_t>( |
5719 CALL_GENERATED_CODE(isolate, f, 42, 42, 0, 0, 0)); | 5832 CALL_GENERATED_CODE(isolate, f, 42, 42, 0, 0, 0)); |
5720 CHECK_EQ(res, 0); | 5833 CHECK_EQ(res, 0); |
5721 } | 5834 } |
5722 | 5835 |
5723 | 5836 |
5724 #undef __ | 5837 #undef __ |
OLD | NEW |