| OLD | NEW |
| 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 |
| (...skipping 295 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 306 } | 306 } |
| 307 | 307 |
| 308 | 308 |
| 309 typedef int (*F7)(double x, double y); | 309 typedef int (*F7)(double x, double y); |
| 310 | 310 |
| 311 TEST(AssemblerIa329) { | 311 TEST(AssemblerIa329) { |
| 312 CcTest::InitializeVM(); | 312 CcTest::InitializeVM(); |
| 313 Isolate* isolate = reinterpret_cast<Isolate*>(CcTest::isolate()); | 313 Isolate* isolate = reinterpret_cast<Isolate*>(CcTest::isolate()); |
| 314 HandleScope scope(isolate); | 314 HandleScope scope(isolate); |
| 315 v8::internal::byte buffer[256]; | 315 v8::internal::byte buffer[256]; |
| 316 MacroAssembler assm(isolate, buffer, sizeof buffer); | 316 MacroAssembler assm(isolate, buffer, sizeof(buffer), true); |
| 317 enum { kEqual = 0, kGreater = 1, kLess = 2, kNaN = 3, kUndefined = 4 }; | 317 enum { kEqual = 0, kGreater = 1, kLess = 2, kNaN = 3, kUndefined = 4 }; |
| 318 Label equal_l, less_l, greater_l, nan_l; | 318 Label equal_l, less_l, greater_l, nan_l; |
| 319 __ fld_d(Operand(esp, 3 * kPointerSize)); | 319 __ fld_d(Operand(esp, 3 * kPointerSize)); |
| 320 __ fld_d(Operand(esp, 1 * kPointerSize)); | 320 __ fld_d(Operand(esp, 1 * kPointerSize)); |
| 321 __ FCmp(); | 321 __ FCmp(); |
| 322 __ j(parity_even, &nan_l); | 322 __ j(parity_even, &nan_l); |
| 323 __ j(equal, &equal_l); | 323 __ j(equal, &equal_l); |
| 324 __ j(below, &less_l); | 324 __ j(below, &less_l); |
| 325 __ j(above, &greater_l); | 325 __ j(above, &greater_l); |
| 326 | 326 |
| (...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 528 #endif // __GNUC__ | 528 #endif // __GNUC__ |
| 529 | 529 |
| 530 | 530 |
| 531 TEST(AssemblerIa32Extractps) { | 531 TEST(AssemblerIa32Extractps) { |
| 532 CcTest::InitializeVM(); | 532 CcTest::InitializeVM(); |
| 533 if (!CpuFeatures::IsSupported(SSE4_1)) return; | 533 if (!CpuFeatures::IsSupported(SSE4_1)) return; |
| 534 | 534 |
| 535 Isolate* isolate = reinterpret_cast<Isolate*>(CcTest::isolate()); | 535 Isolate* isolate = reinterpret_cast<Isolate*>(CcTest::isolate()); |
| 536 HandleScope scope(isolate); | 536 HandleScope scope(isolate); |
| 537 v8::internal::byte buffer[256]; | 537 v8::internal::byte buffer[256]; |
| 538 MacroAssembler assm(isolate, buffer, sizeof buffer); | 538 MacroAssembler assm(isolate, buffer, sizeof(buffer), true); |
| 539 { CpuFeatureScope fscope41(&assm, SSE4_1); | 539 { CpuFeatureScope fscope41(&assm, SSE4_1); |
| 540 __ movsd(xmm1, Operand(esp, 4)); | 540 __ movsd(xmm1, Operand(esp, 4)); |
| 541 __ extractps(eax, xmm1, 0x1); | 541 __ extractps(eax, xmm1, 0x1); |
| 542 __ ret(0); | 542 __ ret(0); |
| 543 } | 543 } |
| 544 | 544 |
| 545 CodeDesc desc; | 545 CodeDesc desc; |
| 546 assm.GetCode(&desc); | 546 assm.GetCode(&desc); |
| 547 Handle<Code> code = isolate->factory()->NewCode( | 547 Handle<Code> code = isolate->factory()->NewCode( |
| 548 desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); | 548 desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); |
| (...skipping 10 matching lines...) Expand all Loading... |
| 559 } | 559 } |
| 560 | 560 |
| 561 | 561 |
| 562 typedef int (*F8)(float x, float y); | 562 typedef int (*F8)(float x, float y); |
| 563 TEST(AssemblerIa32SSE) { | 563 TEST(AssemblerIa32SSE) { |
| 564 CcTest::InitializeVM(); | 564 CcTest::InitializeVM(); |
| 565 | 565 |
| 566 Isolate* isolate = reinterpret_cast<Isolate*>(CcTest::isolate()); | 566 Isolate* isolate = reinterpret_cast<Isolate*>(CcTest::isolate()); |
| 567 HandleScope scope(isolate); | 567 HandleScope scope(isolate); |
| 568 v8::internal::byte buffer[256]; | 568 v8::internal::byte buffer[256]; |
| 569 MacroAssembler assm(isolate, buffer, sizeof buffer); | 569 MacroAssembler assm(isolate, buffer, sizeof(buffer), true); |
| 570 { | 570 { |
| 571 __ movss(xmm0, Operand(esp, kPointerSize)); | 571 __ movss(xmm0, Operand(esp, kPointerSize)); |
| 572 __ movss(xmm1, Operand(esp, 2 * kPointerSize)); | 572 __ movss(xmm1, Operand(esp, 2 * kPointerSize)); |
| 573 __ shufps(xmm0, xmm0, 0x0); | 573 __ shufps(xmm0, xmm0, 0x0); |
| 574 __ shufps(xmm1, xmm1, 0x0); | 574 __ shufps(xmm1, xmm1, 0x0); |
| 575 __ movaps(xmm2, xmm1); | 575 __ movaps(xmm2, xmm1); |
| 576 __ addps(xmm2, xmm0); | 576 __ addps(xmm2, xmm0); |
| 577 __ mulps(xmm2, xmm1); | 577 __ mulps(xmm2, xmm1); |
| 578 __ subps(xmm2, xmm0); | 578 __ subps(xmm2, xmm0); |
| 579 __ divps(xmm2, xmm1); | 579 __ divps(xmm2, xmm1); |
| (...skipping 16 matching lines...) Expand all Loading... |
| 596 | 596 |
| 597 | 597 |
| 598 typedef int (*F9)(double x, double y, double z); | 598 typedef int (*F9)(double x, double y, double z); |
| 599 TEST(AssemblerX64FMA_sd) { | 599 TEST(AssemblerX64FMA_sd) { |
| 600 CcTest::InitializeVM(); | 600 CcTest::InitializeVM(); |
| 601 if (!CpuFeatures::IsSupported(FMA3)) return; | 601 if (!CpuFeatures::IsSupported(FMA3)) return; |
| 602 | 602 |
| 603 Isolate* isolate = reinterpret_cast<Isolate*>(CcTest::isolate()); | 603 Isolate* isolate = reinterpret_cast<Isolate*>(CcTest::isolate()); |
| 604 HandleScope scope(isolate); | 604 HandleScope scope(isolate); |
| 605 v8::internal::byte buffer[1024]; | 605 v8::internal::byte buffer[1024]; |
| 606 MacroAssembler assm(isolate, buffer, sizeof buffer); | 606 MacroAssembler assm(isolate, buffer, sizeof(buffer), true); |
| 607 { | 607 { |
| 608 CpuFeatureScope fscope(&assm, FMA3); | 608 CpuFeatureScope fscope(&assm, FMA3); |
| 609 Label exit; | 609 Label exit; |
| 610 __ movsd(xmm0, Operand(esp, 1 * kPointerSize)); | 610 __ movsd(xmm0, Operand(esp, 1 * kPointerSize)); |
| 611 __ movsd(xmm1, Operand(esp, 3 * kPointerSize)); | 611 __ movsd(xmm1, Operand(esp, 3 * kPointerSize)); |
| 612 __ movsd(xmm2, Operand(esp, 5 * kPointerSize)); | 612 __ movsd(xmm2, Operand(esp, 5 * kPointerSize)); |
| 613 // argument in xmm0, xmm1 and xmm2 | 613 // argument in xmm0, xmm1 and xmm2 |
| 614 // xmm0 * xmm1 + xmm2 | 614 // xmm0 * xmm1 + xmm2 |
| 615 __ movaps(xmm3, xmm0); | 615 __ movaps(xmm3, xmm0); |
| 616 __ mulsd(xmm3, xmm1); | 616 __ mulsd(xmm3, xmm1); |
| (...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 824 | 824 |
| 825 | 825 |
| 826 typedef int (*F10)(float x, float y, float z); | 826 typedef int (*F10)(float x, float y, float z); |
| 827 TEST(AssemblerX64FMA_ss) { | 827 TEST(AssemblerX64FMA_ss) { |
| 828 CcTest::InitializeVM(); | 828 CcTest::InitializeVM(); |
| 829 if (!CpuFeatures::IsSupported(FMA3)) return; | 829 if (!CpuFeatures::IsSupported(FMA3)) return; |
| 830 | 830 |
| 831 Isolate* isolate = reinterpret_cast<Isolate*>(CcTest::isolate()); | 831 Isolate* isolate = reinterpret_cast<Isolate*>(CcTest::isolate()); |
| 832 HandleScope scope(isolate); | 832 HandleScope scope(isolate); |
| 833 v8::internal::byte buffer[1024]; | 833 v8::internal::byte buffer[1024]; |
| 834 MacroAssembler assm(isolate, buffer, sizeof buffer); | 834 MacroAssembler assm(isolate, buffer, sizeof(buffer), true); |
| 835 { | 835 { |
| 836 CpuFeatureScope fscope(&assm, FMA3); | 836 CpuFeatureScope fscope(&assm, FMA3); |
| 837 Label exit; | 837 Label exit; |
| 838 __ movss(xmm0, Operand(esp, 1 * kPointerSize)); | 838 __ movss(xmm0, Operand(esp, 1 * kPointerSize)); |
| 839 __ movss(xmm1, Operand(esp, 2 * kPointerSize)); | 839 __ movss(xmm1, Operand(esp, 2 * kPointerSize)); |
| 840 __ movss(xmm2, Operand(esp, 3 * kPointerSize)); | 840 __ movss(xmm2, Operand(esp, 3 * kPointerSize)); |
| 841 // arguments in xmm0, xmm1 and xmm2 | 841 // arguments in xmm0, xmm1 and xmm2 |
| 842 // xmm0 * xmm1 + xmm2 | 842 // xmm0 * xmm1 + xmm2 |
| 843 __ movaps(xmm3, xmm0); | 843 __ movaps(xmm3, xmm0); |
| 844 __ mulss(xmm3, xmm1); | 844 __ mulss(xmm3, xmm1); |
| (...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1051 } | 1051 } |
| 1052 | 1052 |
| 1053 | 1053 |
| 1054 TEST(AssemblerIa32BMI1) { | 1054 TEST(AssemblerIa32BMI1) { |
| 1055 CcTest::InitializeVM(); | 1055 CcTest::InitializeVM(); |
| 1056 if (!CpuFeatures::IsSupported(BMI1)) return; | 1056 if (!CpuFeatures::IsSupported(BMI1)) return; |
| 1057 | 1057 |
| 1058 Isolate* isolate = reinterpret_cast<Isolate*>(CcTest::isolate()); | 1058 Isolate* isolate = reinterpret_cast<Isolate*>(CcTest::isolate()); |
| 1059 HandleScope scope(isolate); | 1059 HandleScope scope(isolate); |
| 1060 v8::internal::byte buffer[1024]; | 1060 v8::internal::byte buffer[1024]; |
| 1061 MacroAssembler assm(isolate, buffer, sizeof buffer); | 1061 MacroAssembler assm(isolate, buffer, sizeof(buffer), true); |
| 1062 { | 1062 { |
| 1063 CpuFeatureScope fscope(&assm, BMI1); | 1063 CpuFeatureScope fscope(&assm, BMI1); |
| 1064 Label exit; | 1064 Label exit; |
| 1065 | 1065 |
| 1066 __ push(ebx); // save ebx | 1066 __ push(ebx); // save ebx |
| 1067 __ mov(ecx, Immediate(0x55667788u)); // source operand | 1067 __ mov(ecx, Immediate(0x55667788u)); // source operand |
| 1068 __ push(ecx); // For memory operand | 1068 __ push(ecx); // For memory operand |
| 1069 | 1069 |
| 1070 // andn | 1070 // andn |
| 1071 __ mov(edx, Immediate(0x20000000u)); | 1071 __ mov(edx, Immediate(0x20000000u)); |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1158 } | 1158 } |
| 1159 | 1159 |
| 1160 | 1160 |
| 1161 TEST(AssemblerIa32LZCNT) { | 1161 TEST(AssemblerIa32LZCNT) { |
| 1162 CcTest::InitializeVM(); | 1162 CcTest::InitializeVM(); |
| 1163 if (!CpuFeatures::IsSupported(LZCNT)) return; | 1163 if (!CpuFeatures::IsSupported(LZCNT)) return; |
| 1164 | 1164 |
| 1165 Isolate* isolate = reinterpret_cast<Isolate*>(CcTest::isolate()); | 1165 Isolate* isolate = reinterpret_cast<Isolate*>(CcTest::isolate()); |
| 1166 HandleScope scope(isolate); | 1166 HandleScope scope(isolate); |
| 1167 v8::internal::byte buffer[256]; | 1167 v8::internal::byte buffer[256]; |
| 1168 MacroAssembler assm(isolate, buffer, sizeof buffer); | 1168 MacroAssembler assm(isolate, buffer, sizeof(buffer), true); |
| 1169 { | 1169 { |
| 1170 CpuFeatureScope fscope(&assm, LZCNT); | 1170 CpuFeatureScope fscope(&assm, LZCNT); |
| 1171 Label exit; | 1171 Label exit; |
| 1172 | 1172 |
| 1173 __ push(ebx); // save ebx | 1173 __ push(ebx); // save ebx |
| 1174 __ mov(ecx, Immediate(0x55667788u)); // source operand | 1174 __ mov(ecx, Immediate(0x55667788u)); // source operand |
| 1175 __ push(ecx); // For memory operand | 1175 __ push(ecx); // For memory operand |
| 1176 | 1176 |
| 1177 __ mov(eax, Immediate(1)); // Test number | 1177 __ mov(eax, Immediate(1)); // Test number |
| 1178 __ lzcnt(ebx, ecx); | 1178 __ lzcnt(ebx, ecx); |
| (...skipping 26 matching lines...) Expand all Loading... |
| 1205 } | 1205 } |
| 1206 | 1206 |
| 1207 | 1207 |
| 1208 TEST(AssemblerIa32POPCNT) { | 1208 TEST(AssemblerIa32POPCNT) { |
| 1209 CcTest::InitializeVM(); | 1209 CcTest::InitializeVM(); |
| 1210 if (!CpuFeatures::IsSupported(POPCNT)) return; | 1210 if (!CpuFeatures::IsSupported(POPCNT)) return; |
| 1211 | 1211 |
| 1212 Isolate* isolate = reinterpret_cast<Isolate*>(CcTest::isolate()); | 1212 Isolate* isolate = reinterpret_cast<Isolate*>(CcTest::isolate()); |
| 1213 HandleScope scope(isolate); | 1213 HandleScope scope(isolate); |
| 1214 v8::internal::byte buffer[256]; | 1214 v8::internal::byte buffer[256]; |
| 1215 MacroAssembler assm(isolate, buffer, sizeof buffer); | 1215 MacroAssembler assm(isolate, buffer, sizeof(buffer), true); |
| 1216 { | 1216 { |
| 1217 CpuFeatureScope fscope(&assm, POPCNT); | 1217 CpuFeatureScope fscope(&assm, POPCNT); |
| 1218 Label exit; | 1218 Label exit; |
| 1219 | 1219 |
| 1220 __ push(ebx); // save ebx | 1220 __ push(ebx); // save ebx |
| 1221 __ mov(ecx, Immediate(0x11111100u)); // source operand | 1221 __ mov(ecx, Immediate(0x11111100u)); // source operand |
| 1222 __ push(ecx); // For memory operand | 1222 __ push(ecx); // For memory operand |
| 1223 | 1223 |
| 1224 __ mov(eax, Immediate(1)); // Test number | 1224 __ mov(eax, Immediate(1)); // Test number |
| 1225 __ popcnt(ebx, ecx); | 1225 __ popcnt(ebx, ecx); |
| (...skipping 26 matching lines...) Expand all Loading... |
| 1252 } | 1252 } |
| 1253 | 1253 |
| 1254 | 1254 |
| 1255 TEST(AssemblerIa32BMI2) { | 1255 TEST(AssemblerIa32BMI2) { |
| 1256 CcTest::InitializeVM(); | 1256 CcTest::InitializeVM(); |
| 1257 if (!CpuFeatures::IsSupported(BMI2)) return; | 1257 if (!CpuFeatures::IsSupported(BMI2)) return; |
| 1258 | 1258 |
| 1259 Isolate* isolate = reinterpret_cast<Isolate*>(CcTest::isolate()); | 1259 Isolate* isolate = reinterpret_cast<Isolate*>(CcTest::isolate()); |
| 1260 HandleScope scope(isolate); | 1260 HandleScope scope(isolate); |
| 1261 v8::internal::byte buffer[2048]; | 1261 v8::internal::byte buffer[2048]; |
| 1262 MacroAssembler assm(isolate, buffer, sizeof buffer); | 1262 MacroAssembler assm(isolate, buffer, sizeof(buffer), true); |
| 1263 { | 1263 { |
| 1264 CpuFeatureScope fscope(&assm, BMI2); | 1264 CpuFeatureScope fscope(&assm, BMI2); |
| 1265 Label exit; | 1265 Label exit; |
| 1266 | 1266 |
| 1267 __ push(ebx); // save ebx | 1267 __ push(ebx); // save ebx |
| 1268 __ push(esi); // save esi | 1268 __ push(esi); // save esi |
| 1269 __ mov(ecx, Immediate(0x55667788u)); // source operand | 1269 __ mov(ecx, Immediate(0x55667788u)); // source operand |
| 1270 __ push(ecx); // For memory operand | 1270 __ push(ecx); // For memory operand |
| 1271 | 1271 |
| 1272 // bzhi | 1272 // bzhi |
| (...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1485 #endif | 1485 #endif |
| 1486 F1 f = FUNCTION_CAST<F1>(code->entry()); | 1486 F1 f = FUNCTION_CAST<F1>(code->entry()); |
| 1487 for (int i = 0; i < kNumCases; ++i) { | 1487 for (int i = 0; i < kNumCases; ++i) { |
| 1488 int res = f(i); | 1488 int res = f(i); |
| 1489 ::printf("f(%d) = %d\n", i, res); | 1489 ::printf("f(%d) = %d\n", i, res); |
| 1490 CHECK_EQ(values[i], res); | 1490 CHECK_EQ(values[i], res); |
| 1491 } | 1491 } |
| 1492 } | 1492 } |
| 1493 | 1493 |
| 1494 #undef __ | 1494 #undef __ |
| OLD | NEW |