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 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
50 if (env.IsEmpty()) { | 50 if (env.IsEmpty()) { |
51 env = v8::Context::New(); | 51 env = v8::Context::New(); |
52 } | 52 } |
53 } | 53 } |
54 | 54 |
55 | 55 |
56 #define __ assm. | 56 #define __ assm. |
57 | 57 |
58 TEST(0) { | 58 TEST(0) { |
59 InitializeVM(); | 59 InitializeVM(); |
60 v8::HandleScope scope; | 60 Isolate* isolate = Isolate::Current(); |
| 61 HandleScope scope(isolate); |
61 | 62 |
62 Isolate* isolate = Isolate::Current(); | |
63 Assembler assm(isolate, NULL, 0); | 63 Assembler assm(isolate, NULL, 0); |
64 | 64 |
65 __ add(r0, r0, Operand(r1)); | 65 __ add(r0, r0, Operand(r1)); |
66 __ mov(pc, Operand(lr)); | 66 __ mov(pc, Operand(lr)); |
67 | 67 |
68 CodeDesc desc; | 68 CodeDesc desc; |
69 assm.GetCode(&desc); | 69 assm.GetCode(&desc); |
70 Object* code = isolate->heap()->CreateCode( | 70 Object* code = isolate->heap()->CreateCode( |
71 desc, | 71 desc, |
72 Code::ComputeFlags(Code::STUB), | 72 Code::ComputeFlags(Code::STUB), |
73 Handle<Code>())->ToObjectChecked(); | 73 Handle<Code>())->ToObjectChecked(); |
74 CHECK(code->IsCode()); | 74 CHECK(code->IsCode()); |
75 #ifdef DEBUG | 75 #ifdef DEBUG |
76 Code::cast(code)->Print(); | 76 Code::cast(code)->Print(); |
77 #endif | 77 #endif |
78 F2 f = FUNCTION_CAST<F2>(Code::cast(code)->entry()); | 78 F2 f = FUNCTION_CAST<F2>(Code::cast(code)->entry()); |
79 int res = reinterpret_cast<int>(CALL_GENERATED_CODE(f, 3, 4, 0, 0, 0)); | 79 int res = reinterpret_cast<int>(CALL_GENERATED_CODE(f, 3, 4, 0, 0, 0)); |
80 ::printf("f() = %d\n", res); | 80 ::printf("f() = %d\n", res); |
81 CHECK_EQ(7, res); | 81 CHECK_EQ(7, res); |
82 } | 82 } |
83 | 83 |
84 | 84 |
85 TEST(1) { | 85 TEST(1) { |
86 InitializeVM(); | 86 InitializeVM(); |
87 v8::HandleScope scope; | 87 Isolate* isolate = Isolate::Current(); |
| 88 HandleScope scope(isolate); |
88 | 89 |
89 Isolate* isolate = Isolate::Current(); | |
90 Assembler assm(isolate, NULL, 0); | 90 Assembler assm(isolate, NULL, 0); |
91 Label L, C; | 91 Label L, C; |
92 | 92 |
93 __ mov(r1, Operand(r0)); | 93 __ mov(r1, Operand(r0)); |
94 __ mov(r0, Operand::Zero()); | 94 __ mov(r0, Operand::Zero()); |
95 __ b(&C); | 95 __ b(&C); |
96 | 96 |
97 __ bind(&L); | 97 __ bind(&L); |
98 __ add(r0, r0, Operand(r1)); | 98 __ add(r0, r0, Operand(r1)); |
99 __ sub(r1, r1, Operand(1)); | 99 __ sub(r1, r1, Operand(1)); |
(...skipping 15 matching lines...) Expand all Loading... |
115 #endif | 115 #endif |
116 F1 f = FUNCTION_CAST<F1>(Code::cast(code)->entry()); | 116 F1 f = FUNCTION_CAST<F1>(Code::cast(code)->entry()); |
117 int res = reinterpret_cast<int>(CALL_GENERATED_CODE(f, 100, 0, 0, 0, 0)); | 117 int res = reinterpret_cast<int>(CALL_GENERATED_CODE(f, 100, 0, 0, 0, 0)); |
118 ::printf("f() = %d\n", res); | 118 ::printf("f() = %d\n", res); |
119 CHECK_EQ(5050, res); | 119 CHECK_EQ(5050, res); |
120 } | 120 } |
121 | 121 |
122 | 122 |
123 TEST(2) { | 123 TEST(2) { |
124 InitializeVM(); | 124 InitializeVM(); |
125 v8::HandleScope scope; | 125 Isolate* isolate = Isolate::Current(); |
| 126 HandleScope scope(isolate); |
126 | 127 |
127 Isolate* isolate = Isolate::Current(); | |
128 Assembler assm(isolate, NULL, 0); | 128 Assembler assm(isolate, NULL, 0); |
129 Label L, C; | 129 Label L, C; |
130 | 130 |
131 __ mov(r1, Operand(r0)); | 131 __ mov(r1, Operand(r0)); |
132 __ mov(r0, Operand(1)); | 132 __ mov(r0, Operand(1)); |
133 __ b(&C); | 133 __ b(&C); |
134 | 134 |
135 __ bind(&L); | 135 __ bind(&L); |
136 __ mul(r0, r1, r0); | 136 __ mul(r0, r1, r0); |
137 __ sub(r1, r1, Operand(1)); | 137 __ sub(r1, r1, Operand(1)); |
(...skipping 24 matching lines...) Expand all Loading... |
162 #endif | 162 #endif |
163 F1 f = FUNCTION_CAST<F1>(Code::cast(code)->entry()); | 163 F1 f = FUNCTION_CAST<F1>(Code::cast(code)->entry()); |
164 int res = reinterpret_cast<int>(CALL_GENERATED_CODE(f, 10, 0, 0, 0, 0)); | 164 int res = reinterpret_cast<int>(CALL_GENERATED_CODE(f, 10, 0, 0, 0, 0)); |
165 ::printf("f() = %d\n", res); | 165 ::printf("f() = %d\n", res); |
166 CHECK_EQ(3628800, res); | 166 CHECK_EQ(3628800, res); |
167 } | 167 } |
168 | 168 |
169 | 169 |
170 TEST(3) { | 170 TEST(3) { |
171 InitializeVM(); | 171 InitializeVM(); |
172 v8::HandleScope scope; | 172 Isolate* isolate = Isolate::Current(); |
| 173 HandleScope scope(isolate); |
173 | 174 |
174 typedef struct { | 175 typedef struct { |
175 int i; | 176 int i; |
176 char c; | 177 char c; |
177 int16_t s; | 178 int16_t s; |
178 } T; | 179 } T; |
179 T t; | 180 T t; |
180 | 181 |
181 Isolate* isolate = Isolate::Current(); | |
182 Assembler assm(isolate, NULL, 0); | 182 Assembler assm(isolate, NULL, 0); |
183 Label L, C; | 183 Label L, C; |
184 | 184 |
185 __ mov(ip, Operand(sp)); | 185 __ mov(ip, Operand(sp)); |
186 __ stm(db_w, sp, r4.bit() | fp.bit() | lr.bit()); | 186 __ stm(db_w, sp, r4.bit() | fp.bit() | lr.bit()); |
187 __ sub(fp, ip, Operand(4)); | 187 __ sub(fp, ip, Operand(4)); |
188 __ mov(r4, Operand(r0)); | 188 __ mov(r4, Operand(r0)); |
189 __ ldr(r0, MemOperand(r4, OFFSET_OF(T, i))); | 189 __ ldr(r0, MemOperand(r4, OFFSET_OF(T, i))); |
190 __ mov(r2, Operand(r0, ASR, 1)); | 190 __ mov(r2, Operand(r0, ASR, 1)); |
191 __ str(r2, MemOperand(r4, OFFSET_OF(T, i))); | 191 __ str(r2, MemOperand(r4, OFFSET_OF(T, i))); |
(...skipping 26 matching lines...) Expand all Loading... |
218 CHECK_EQ(101010, res); | 218 CHECK_EQ(101010, res); |
219 CHECK_EQ(100000/2, t.i); | 219 CHECK_EQ(100000/2, t.i); |
220 CHECK_EQ(10*4, t.c); | 220 CHECK_EQ(10*4, t.c); |
221 CHECK_EQ(1000/8, t.s); | 221 CHECK_EQ(1000/8, t.s); |
222 } | 222 } |
223 | 223 |
224 | 224 |
225 TEST(4) { | 225 TEST(4) { |
226 // Test the VFP floating point instructions. | 226 // Test the VFP floating point instructions. |
227 InitializeVM(); | 227 InitializeVM(); |
228 v8::HandleScope scope; | 228 Isolate* isolate = Isolate::Current(); |
| 229 HandleScope scope(isolate); |
229 | 230 |
230 typedef struct { | 231 typedef struct { |
231 double a; | 232 double a; |
232 double b; | 233 double b; |
233 double c; | 234 double c; |
234 double d; | 235 double d; |
235 double e; | 236 double e; |
236 double f; | 237 double f; |
237 double g; | 238 double g; |
238 double h; | 239 double h; |
239 int i; | 240 int i; |
240 double m; | 241 double m; |
241 double n; | 242 double n; |
242 float x; | 243 float x; |
243 float y; | 244 float y; |
244 } T; | 245 } T; |
245 T t; | 246 T t; |
246 | 247 |
247 // Create a function that accepts &t, and loads, manipulates, and stores | 248 // Create a function that accepts &t, and loads, manipulates, and stores |
248 // the doubles and floats. | 249 // the doubles and floats. |
249 Isolate* isolate = Isolate::Current(); | |
250 Assembler assm(isolate, NULL, 0); | 250 Assembler assm(isolate, NULL, 0); |
251 Label L, C; | 251 Label L, C; |
252 | 252 |
253 | 253 |
254 if (CpuFeatures::IsSupported(VFP3)) { | 254 if (CpuFeatures::IsSupported(VFP3)) { |
255 CpuFeatureScope scope(&assm, VFP3); | 255 CpuFeatureScope scope(&assm, VFP3); |
256 | 256 |
257 __ mov(ip, Operand(sp)); | 257 __ mov(ip, Operand(sp)); |
258 __ stm(db_w, sp, r4.bit() | fp.bit() | lr.bit()); | 258 __ stm(db_w, sp, r4.bit() | fp.bit() | lr.bit()); |
259 __ sub(fp, ip, Operand(4)); | 259 __ sub(fp, ip, Operand(4)); |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
357 CHECK_EQ(4.25, t.c); | 357 CHECK_EQ(4.25, t.c); |
358 CHECK_EQ(-4.1875, t.b); | 358 CHECK_EQ(-4.1875, t.b); |
359 CHECK_EQ(1.5, t.a); | 359 CHECK_EQ(1.5, t.a); |
360 } | 360 } |
361 } | 361 } |
362 | 362 |
363 | 363 |
364 TEST(5) { | 364 TEST(5) { |
365 // Test the ARMv7 bitfield instructions. | 365 // Test the ARMv7 bitfield instructions. |
366 InitializeVM(); | 366 InitializeVM(); |
367 v8::HandleScope scope; | 367 Isolate* isolate = Isolate::Current(); |
| 368 HandleScope scope(isolate); |
368 | 369 |
369 Isolate* isolate = Isolate::Current(); | |
370 Assembler assm(isolate, NULL, 0); | 370 Assembler assm(isolate, NULL, 0); |
371 | 371 |
372 if (CpuFeatures::IsSupported(ARMv7)) { | 372 if (CpuFeatures::IsSupported(ARMv7)) { |
373 CpuFeatureScope scope(&assm, ARMv7); | 373 CpuFeatureScope scope(&assm, ARMv7); |
374 // On entry, r0 = 0xAAAAAAAA = 0b10..10101010. | 374 // On entry, r0 = 0xAAAAAAAA = 0b10..10101010. |
375 __ ubfx(r0, r0, 1, 12); // 0b00..010101010101 = 0x555 | 375 __ ubfx(r0, r0, 1, 12); // 0b00..010101010101 = 0x555 |
376 __ sbfx(r0, r0, 0, 5); // 0b11..111111110101 = -11 | 376 __ sbfx(r0, r0, 0, 5); // 0b11..111111110101 = -11 |
377 __ bfc(r0, 1, 3); // 0b11..111111110001 = -15 | 377 __ bfc(r0, 1, 3); // 0b11..111111110001 = -15 |
378 __ mov(r1, Operand(7)); | 378 __ mov(r1, Operand(7)); |
379 __ bfi(r0, r1, 3, 3); // 0b11..111111111001 = -7 | 379 __ bfi(r0, r1, 3, 3); // 0b11..111111111001 = -7 |
(...skipping 14 matching lines...) Expand all Loading... |
394 CALL_GENERATED_CODE(f, 0xAAAAAAAA, 0, 0, 0, 0)); | 394 CALL_GENERATED_CODE(f, 0xAAAAAAAA, 0, 0, 0, 0)); |
395 ::printf("f() = %d\n", res); | 395 ::printf("f() = %d\n", res); |
396 CHECK_EQ(-7, res); | 396 CHECK_EQ(-7, res); |
397 } | 397 } |
398 } | 398 } |
399 | 399 |
400 | 400 |
401 TEST(6) { | 401 TEST(6) { |
402 // Test saturating instructions. | 402 // Test saturating instructions. |
403 InitializeVM(); | 403 InitializeVM(); |
404 v8::HandleScope scope; | 404 Isolate* isolate = Isolate::Current(); |
| 405 HandleScope scope(isolate); |
405 | 406 |
406 Isolate* isolate = Isolate::Current(); | |
407 Assembler assm(isolate, NULL, 0); | 407 Assembler assm(isolate, NULL, 0); |
408 | 408 |
409 if (CpuFeatures::IsSupported(ARMv7)) { | 409 if (CpuFeatures::IsSupported(ARMv7)) { |
410 CpuFeatureScope scope(&assm, ARMv7); | 410 CpuFeatureScope scope(&assm, ARMv7); |
411 __ usat(r1, 8, Operand(r0)); // Sat 0xFFFF to 0-255 = 0xFF. | 411 __ usat(r1, 8, Operand(r0)); // Sat 0xFFFF to 0-255 = 0xFF. |
412 __ usat(r2, 12, Operand(r0, ASR, 9)); // Sat (0xFFFF>>9) to 0-4095 = 0x7F. | 412 __ usat(r2, 12, Operand(r0, ASR, 9)); // Sat (0xFFFF>>9) to 0-4095 = 0x7F. |
413 __ usat(r3, 1, Operand(r0, LSL, 16)); // Sat (0xFFFF<<16) to 0-1 = 0x0. | 413 __ usat(r3, 1, Operand(r0, LSL, 16)); // Sat (0xFFFF<<16) to 0-1 = 0x0. |
414 __ add(r0, r1, Operand(r2)); | 414 __ add(r0, r1, Operand(r2)); |
415 __ add(r0, r0, Operand(r3)); | 415 __ add(r0, r0, Operand(r3)); |
416 __ mov(pc, Operand(lr)); | 416 __ mov(pc, Operand(lr)); |
(...skipping 21 matching lines...) Expand all Loading... |
438 s32_f64, | 438 s32_f64, |
439 u32_f64 | 439 u32_f64 |
440 }; | 440 }; |
441 | 441 |
442 static void TestRoundingMode(VCVTTypes types, | 442 static void TestRoundingMode(VCVTTypes types, |
443 VFPRoundingMode mode, | 443 VFPRoundingMode mode, |
444 double value, | 444 double value, |
445 int expected, | 445 int expected, |
446 bool expected_exception = false) { | 446 bool expected_exception = false) { |
447 InitializeVM(); | 447 InitializeVM(); |
448 v8::HandleScope scope; | 448 Isolate* isolate = Isolate::Current(); |
| 449 HandleScope scope(isolate); |
449 | 450 |
450 Isolate* isolate = Isolate::Current(); | |
451 Assembler assm(isolate, NULL, 0); | 451 Assembler assm(isolate, NULL, 0); |
452 | 452 |
453 if (CpuFeatures::IsSupported(VFP3)) { | 453 if (CpuFeatures::IsSupported(VFP3)) { |
454 CpuFeatureScope scope(&assm, VFP3); | 454 CpuFeatureScope scope(&assm, VFP3); |
455 | 455 |
456 Label wrong_exception; | 456 Label wrong_exception; |
457 | 457 |
458 __ vmrs(r1); | 458 __ vmrs(r1); |
459 // Set custom FPSCR. | 459 // Set custom FPSCR. |
460 __ bic(r2, r1, Operand(kVFPRoundingModeMask | kVFPExceptionMask)); | 460 __ bic(r2, r1, Operand(kVFPRoundingModeMask | kVFPExceptionMask)); |
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
616 TestRoundingMode(u32_f64, RN, (kMaxInt + 0.5), | 616 TestRoundingMode(u32_f64, RN, (kMaxInt + 0.5), |
617 static_cast<uint32_t>(kMaxInt) + 1); | 617 static_cast<uint32_t>(kMaxInt) + 1); |
618 TestRoundingMode(u32_f64, RN, (kMaxUInt + 0.49), kMaxUInt); | 618 TestRoundingMode(u32_f64, RN, (kMaxUInt + 0.49), kMaxUInt); |
619 TestRoundingMode(u32_f64, RN, (kMaxUInt + 0.5), kMaxUInt, true); | 619 TestRoundingMode(u32_f64, RN, (kMaxUInt + 0.5), kMaxUInt, true); |
620 TestRoundingMode(u32_f64, RN, (kMaxUInt + 1.0), kMaxUInt, true); | 620 TestRoundingMode(u32_f64, RN, (kMaxUInt + 1.0), kMaxUInt, true); |
621 } | 621 } |
622 | 622 |
623 TEST(8) { | 623 TEST(8) { |
624 // Test VFP multi load/store with ia_w. | 624 // Test VFP multi load/store with ia_w. |
625 InitializeVM(); | 625 InitializeVM(); |
626 v8::HandleScope scope; | 626 Isolate* isolate = Isolate::Current(); |
| 627 HandleScope scope(isolate); |
627 | 628 |
628 typedef struct { | 629 typedef struct { |
629 double a; | 630 double a; |
630 double b; | 631 double b; |
631 double c; | 632 double c; |
632 double d; | 633 double d; |
633 double e; | 634 double e; |
634 double f; | 635 double f; |
635 double g; | 636 double g; |
636 double h; | 637 double h; |
637 } D; | 638 } D; |
638 D d; | 639 D d; |
639 | 640 |
640 typedef struct { | 641 typedef struct { |
641 float a; | 642 float a; |
642 float b; | 643 float b; |
643 float c; | 644 float c; |
644 float d; | 645 float d; |
645 float e; | 646 float e; |
646 float f; | 647 float f; |
647 float g; | 648 float g; |
648 float h; | 649 float h; |
649 } F; | 650 } F; |
650 F f; | 651 F f; |
651 | 652 |
652 // Create a function that uses vldm/vstm to move some double and | 653 // Create a function that uses vldm/vstm to move some double and |
653 // single precision values around in memory. | 654 // single precision values around in memory. |
654 Isolate* isolate = Isolate::Current(); | |
655 Assembler assm(isolate, NULL, 0); | 655 Assembler assm(isolate, NULL, 0); |
656 | 656 |
657 if (CpuFeatures::IsSupported(VFP2)) { | 657 if (CpuFeatures::IsSupported(VFP2)) { |
658 CpuFeatureScope scope(&assm, VFP2); | 658 CpuFeatureScope scope(&assm, VFP2); |
659 | 659 |
660 __ mov(ip, Operand(sp)); | 660 __ mov(ip, Operand(sp)); |
661 __ stm(db_w, sp, r4.bit() | fp.bit() | lr.bit()); | 661 __ stm(db_w, sp, r4.bit() | fp.bit() | lr.bit()); |
662 __ sub(fp, ip, Operand(4)); | 662 __ sub(fp, ip, Operand(4)); |
663 | 663 |
664 __ add(r4, r0, Operand(OFFSET_OF(D, a))); | 664 __ add(r4, r0, Operand(OFFSET_OF(D, a))); |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
728 CHECK_EQ(4.0, f.f); | 728 CHECK_EQ(4.0, f.f); |
729 CHECK_EQ(5.0, f.g); | 729 CHECK_EQ(5.0, f.g); |
730 CHECK_EQ(6.0, f.h); | 730 CHECK_EQ(6.0, f.h); |
731 } | 731 } |
732 } | 732 } |
733 | 733 |
734 | 734 |
735 TEST(9) { | 735 TEST(9) { |
736 // Test VFP multi load/store with ia. | 736 // Test VFP multi load/store with ia. |
737 InitializeVM(); | 737 InitializeVM(); |
738 v8::HandleScope scope; | 738 Isolate* isolate = Isolate::Current(); |
| 739 HandleScope scope(isolate); |
739 | 740 |
740 typedef struct { | 741 typedef struct { |
741 double a; | 742 double a; |
742 double b; | 743 double b; |
743 double c; | 744 double c; |
744 double d; | 745 double d; |
745 double e; | 746 double e; |
746 double f; | 747 double f; |
747 double g; | 748 double g; |
748 double h; | 749 double h; |
749 } D; | 750 } D; |
750 D d; | 751 D d; |
751 | 752 |
752 typedef struct { | 753 typedef struct { |
753 float a; | 754 float a; |
754 float b; | 755 float b; |
755 float c; | 756 float c; |
756 float d; | 757 float d; |
757 float e; | 758 float e; |
758 float f; | 759 float f; |
759 float g; | 760 float g; |
760 float h; | 761 float h; |
761 } F; | 762 } F; |
762 F f; | 763 F f; |
763 | 764 |
764 // Create a function that uses vldm/vstm to move some double and | 765 // Create a function that uses vldm/vstm to move some double and |
765 // single precision values around in memory. | 766 // single precision values around in memory. |
766 Isolate* isolate = Isolate::Current(); | |
767 Assembler assm(isolate, NULL, 0); | 767 Assembler assm(isolate, NULL, 0); |
768 | 768 |
769 if (CpuFeatures::IsSupported(VFP2)) { | 769 if (CpuFeatures::IsSupported(VFP2)) { |
770 CpuFeatureScope scope(&assm, VFP2); | 770 CpuFeatureScope scope(&assm, VFP2); |
771 | 771 |
772 __ mov(ip, Operand(sp)); | 772 __ mov(ip, Operand(sp)); |
773 __ stm(db_w, sp, r4.bit() | fp.bit() | lr.bit()); | 773 __ stm(db_w, sp, r4.bit() | fp.bit() | lr.bit()); |
774 __ sub(fp, ip, Operand(4)); | 774 __ sub(fp, ip, Operand(4)); |
775 | 775 |
776 __ add(r4, r0, Operand(OFFSET_OF(D, a))); | 776 __ add(r4, r0, Operand(OFFSET_OF(D, a))); |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
844 CHECK_EQ(4.0, f.f); | 844 CHECK_EQ(4.0, f.f); |
845 CHECK_EQ(5.0, f.g); | 845 CHECK_EQ(5.0, f.g); |
846 CHECK_EQ(6.0, f.h); | 846 CHECK_EQ(6.0, f.h); |
847 } | 847 } |
848 } | 848 } |
849 | 849 |
850 | 850 |
851 TEST(10) { | 851 TEST(10) { |
852 // Test VFP multi load/store with db_w. | 852 // Test VFP multi load/store with db_w. |
853 InitializeVM(); | 853 InitializeVM(); |
854 v8::HandleScope scope; | 854 Isolate* isolate = Isolate::Current(); |
| 855 HandleScope scope(isolate); |
855 | 856 |
856 typedef struct { | 857 typedef struct { |
857 double a; | 858 double a; |
858 double b; | 859 double b; |
859 double c; | 860 double c; |
860 double d; | 861 double d; |
861 double e; | 862 double e; |
862 double f; | 863 double f; |
863 double g; | 864 double g; |
864 double h; | 865 double h; |
865 } D; | 866 } D; |
866 D d; | 867 D d; |
867 | 868 |
868 typedef struct { | 869 typedef struct { |
869 float a; | 870 float a; |
870 float b; | 871 float b; |
871 float c; | 872 float c; |
872 float d; | 873 float d; |
873 float e; | 874 float e; |
874 float f; | 875 float f; |
875 float g; | 876 float g; |
876 float h; | 877 float h; |
877 } F; | 878 } F; |
878 F f; | 879 F f; |
879 | 880 |
880 // Create a function that uses vldm/vstm to move some double and | 881 // Create a function that uses vldm/vstm to move some double and |
881 // single precision values around in memory. | 882 // single precision values around in memory. |
882 Isolate* isolate = Isolate::Current(); | |
883 Assembler assm(isolate, NULL, 0); | 883 Assembler assm(isolate, NULL, 0); |
884 | 884 |
885 if (CpuFeatures::IsSupported(VFP2)) { | 885 if (CpuFeatures::IsSupported(VFP2)) { |
886 CpuFeatureScope scope(&assm, VFP2); | 886 CpuFeatureScope scope(&assm, VFP2); |
887 | 887 |
888 __ mov(ip, Operand(sp)); | 888 __ mov(ip, Operand(sp)); |
889 __ stm(db_w, sp, r4.bit() | fp.bit() | lr.bit()); | 889 __ stm(db_w, sp, r4.bit() | fp.bit() | lr.bit()); |
890 __ sub(fp, ip, Operand(4)); | 890 __ sub(fp, ip, Operand(4)); |
891 | 891 |
892 __ add(r4, r0, Operand(OFFSET_OF(D, h) + 8)); | 892 __ add(r4, r0, Operand(OFFSET_OF(D, h) + 8)); |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
956 CHECK_EQ(4.0, f.f); | 956 CHECK_EQ(4.0, f.f); |
957 CHECK_EQ(5.0, f.g); | 957 CHECK_EQ(5.0, f.g); |
958 CHECK_EQ(6.0, f.h); | 958 CHECK_EQ(6.0, f.h); |
959 } | 959 } |
960 } | 960 } |
961 | 961 |
962 | 962 |
963 TEST(11) { | 963 TEST(11) { |
964 // Test instructions using the carry flag. | 964 // Test instructions using the carry flag. |
965 InitializeVM(); | 965 InitializeVM(); |
966 v8::HandleScope scope; | 966 Isolate* isolate = Isolate::Current(); |
| 967 HandleScope scope(isolate); |
967 | 968 |
968 typedef struct { | 969 typedef struct { |
969 int32_t a; | 970 int32_t a; |
970 int32_t b; | 971 int32_t b; |
971 int32_t c; | 972 int32_t c; |
972 int32_t d; | 973 int32_t d; |
973 } I; | 974 } I; |
974 I i; | 975 I i; |
975 | 976 |
976 i.a = 0xabcd0001; | 977 i.a = 0xabcd0001; |
977 i.b = 0xabcd0000; | 978 i.b = 0xabcd0000; |
978 | 979 |
979 Isolate* isolate = Isolate::Current(); | |
980 Assembler assm(isolate, NULL, 0); | 980 Assembler assm(isolate, NULL, 0); |
981 | 981 |
982 // Test HeapObject untagging. | 982 // Test HeapObject untagging. |
983 __ ldr(r1, MemOperand(r0, OFFSET_OF(I, a))); | 983 __ ldr(r1, MemOperand(r0, OFFSET_OF(I, a))); |
984 __ mov(r1, Operand(r1, ASR, 1), SetCC); | 984 __ mov(r1, Operand(r1, ASR, 1), SetCC); |
985 __ adc(r1, r1, Operand(r1), LeaveCC, cs); | 985 __ adc(r1, r1, Operand(r1), LeaveCC, cs); |
986 __ str(r1, MemOperand(r0, OFFSET_OF(I, a))); | 986 __ str(r1, MemOperand(r0, OFFSET_OF(I, a))); |
987 | 987 |
988 __ ldr(r2, MemOperand(r0, OFFSET_OF(I, b))); | 988 __ ldr(r2, MemOperand(r0, OFFSET_OF(I, b))); |
989 __ mov(r2, Operand(r2, ASR, 1), SetCC); | 989 __ mov(r2, Operand(r2, ASR, 1), SetCC); |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1022 CHECK_EQ(0xabcd0001, i.a); | 1022 CHECK_EQ(0xabcd0001, i.a); |
1023 CHECK_EQ(static_cast<int32_t>(0xabcd0000) >> 1, i.b); | 1023 CHECK_EQ(static_cast<int32_t>(0xabcd0000) >> 1, i.b); |
1024 CHECK_EQ(0x00000000, i.c); | 1024 CHECK_EQ(0x00000000, i.c); |
1025 CHECK_EQ(0xffffffff, i.d); | 1025 CHECK_EQ(0xffffffff, i.d); |
1026 } | 1026 } |
1027 | 1027 |
1028 | 1028 |
1029 TEST(12) { | 1029 TEST(12) { |
1030 // Test chaining of label usages within instructions (issue 1644). | 1030 // Test chaining of label usages within instructions (issue 1644). |
1031 InitializeVM(); | 1031 InitializeVM(); |
1032 v8::HandleScope scope; | 1032 Isolate* isolate = Isolate::Current(); |
1033 Assembler assm(Isolate::Current(), NULL, 0); | 1033 HandleScope scope(isolate); |
1034 | 1034 |
| 1035 Assembler assm(isolate, NULL, 0); |
1035 Label target; | 1036 Label target; |
1036 __ b(eq, &target); | 1037 __ b(eq, &target); |
1037 __ b(ne, &target); | 1038 __ b(ne, &target); |
1038 __ bind(&target); | 1039 __ bind(&target); |
1039 __ nop(); | 1040 __ nop(); |
1040 } | 1041 } |
1041 | 1042 |
1042 | 1043 |
1043 TEST(13) { | 1044 TEST(13) { |
1044 // Test VFP instructions using registers d16-d31. | 1045 // Test VFP instructions using registers d16-d31. |
1045 InitializeVM(); | 1046 InitializeVM(); |
1046 v8::HandleScope scope; | 1047 Isolate* isolate = Isolate::Current(); |
| 1048 HandleScope scope(isolate); |
1047 | 1049 |
1048 if (!CpuFeatures::IsSupported(VFP32DREGS)) { | 1050 if (!CpuFeatures::IsSupported(VFP32DREGS)) { |
1049 return; | 1051 return; |
1050 } | 1052 } |
1051 | 1053 |
1052 typedef struct { | 1054 typedef struct { |
1053 double a; | 1055 double a; |
1054 double b; | 1056 double b; |
1055 double c; | 1057 double c; |
1056 double x; | 1058 double x; |
1057 double y; | 1059 double y; |
1058 double z; | 1060 double z; |
1059 double i; | 1061 double i; |
1060 double j; | 1062 double j; |
1061 double k; | 1063 double k; |
1062 } T; | 1064 } T; |
1063 T t; | 1065 T t; |
1064 | 1066 |
1065 // Create a function that accepts &t, and loads, manipulates, and stores | 1067 // Create a function that accepts &t, and loads, manipulates, and stores |
1066 // the doubles and floats. | 1068 // the doubles and floats. |
1067 Isolate* isolate = Isolate::Current(); | |
1068 Assembler assm(isolate, NULL, 0); | 1069 Assembler assm(isolate, NULL, 0); |
1069 Label L, C; | 1070 Label L, C; |
1070 | 1071 |
1071 | 1072 |
1072 if (CpuFeatures::IsSupported(VFP3)) { | 1073 if (CpuFeatures::IsSupported(VFP3)) { |
1073 CpuFeatureScope scope(&assm, VFP3); | 1074 CpuFeatureScope scope(&assm, VFP3); |
1074 | 1075 |
1075 __ stm(db_w, sp, r4.bit() | lr.bit()); | 1076 __ stm(db_w, sp, r4.bit() | lr.bit()); |
1076 | 1077 |
1077 // Load a, b, c into d16, d17, d18. | 1078 // Load a, b, c into d16, d17, d18. |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1152 CHECK_EQ(2.75, t.x); | 1153 CHECK_EQ(2.75, t.x); |
1153 CHECK_EQ(1.5, t.y); | 1154 CHECK_EQ(1.5, t.y); |
1154 CHECK_EQ(17.0, t.z); | 1155 CHECK_EQ(17.0, t.z); |
1155 CHECK_EQ(14.7610017472335499, t.i); | 1156 CHECK_EQ(14.7610017472335499, t.i); |
1156 CHECK_EQ(16.0, t.j); | 1157 CHECK_EQ(16.0, t.j); |
1157 CHECK_EQ(73.8818412254460241, t.k); | 1158 CHECK_EQ(73.8818412254460241, t.k); |
1158 } | 1159 } |
1159 } | 1160 } |
1160 | 1161 |
1161 #undef __ | 1162 #undef __ |
OLD | NEW |