| OLD | NEW |
| 1 // Copyright 2010 the V8 project authors. All rights reserved. | 1 // Copyright 2010 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 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 51 } | 51 } |
| 52 } | 52 } |
| 53 | 53 |
| 54 | 54 |
| 55 #define __ assm. | 55 #define __ assm. |
| 56 | 56 |
| 57 TEST(0) { | 57 TEST(0) { |
| 58 InitializeVM(); | 58 InitializeVM(); |
| 59 v8::HandleScope scope; | 59 v8::HandleScope scope; |
| 60 | 60 |
| 61 Assembler assm(Isolate::Current(), NULL, 0); | 61 Assembler assm(NULL, 0); |
| 62 | 62 |
| 63 __ add(r0, r0, Operand(r1)); | 63 __ add(r0, r0, Operand(r1)); |
| 64 __ mov(pc, Operand(lr)); | 64 __ mov(pc, Operand(lr)); |
| 65 | 65 |
| 66 CodeDesc desc; | 66 CodeDesc desc; |
| 67 assm.GetCode(&desc); | 67 assm.GetCode(&desc); |
| 68 Object* code = HEAP->CreateCode( | 68 Object* code = HEAP->CreateCode( |
| 69 desc, | 69 desc, |
| 70 Code::ComputeFlags(Code::STUB), | 70 Code::ComputeFlags(Code::STUB), |
| 71 Handle<Object>(HEAP->undefined_value()))->ToObjectChecked(); | 71 Handle<Object>(HEAP->undefined_value()))->ToObjectChecked(); |
| 72 CHECK(code->IsCode()); | 72 CHECK(code->IsCode()); |
| 73 #ifdef DEBUG | 73 #ifdef DEBUG |
| 74 Code::cast(code)->Print(); | 74 Code::cast(code)->Print(); |
| 75 #endif | 75 #endif |
| 76 F2 f = FUNCTION_CAST<F2>(Code::cast(code)->entry()); | 76 F2 f = FUNCTION_CAST<F2>(Code::cast(code)->entry()); |
| 77 int res = reinterpret_cast<int>(CALL_GENERATED_CODE(f, 3, 4, 0, 0, 0)); | 77 int res = reinterpret_cast<int>(CALL_GENERATED_CODE(f, 3, 4, 0, 0, 0)); |
| 78 ::printf("f() = %d\n", res); | 78 ::printf("f() = %d\n", res); |
| 79 CHECK_EQ(7, res); | 79 CHECK_EQ(7, res); |
| 80 } | 80 } |
| 81 | 81 |
| 82 | 82 |
| 83 TEST(1) { | 83 TEST(1) { |
| 84 InitializeVM(); | 84 InitializeVM(); |
| 85 v8::HandleScope scope; | 85 v8::HandleScope scope; |
| 86 | 86 |
| 87 Assembler assm(Isolate::Current(), NULL, 0); | 87 Assembler assm(NULL, 0); |
| 88 Label L, C; | 88 Label L, C; |
| 89 | 89 |
| 90 __ mov(r1, Operand(r0)); | 90 __ mov(r1, Operand(r0)); |
| 91 __ mov(r0, Operand(0, RelocInfo::NONE)); | 91 __ mov(r0, Operand(0, RelocInfo::NONE)); |
| 92 __ b(&C); | 92 __ b(&C); |
| 93 | 93 |
| 94 __ bind(&L); | 94 __ bind(&L); |
| 95 __ add(r0, r0, Operand(r1)); | 95 __ add(r0, r0, Operand(r1)); |
| 96 __ sub(r1, r1, Operand(1)); | 96 __ sub(r1, r1, Operand(1)); |
| 97 | 97 |
| (...skipping 16 matching lines...) Expand all Loading... |
| 114 int res = reinterpret_cast<int>(CALL_GENERATED_CODE(f, 100, 0, 0, 0, 0)); | 114 int res = reinterpret_cast<int>(CALL_GENERATED_CODE(f, 100, 0, 0, 0, 0)); |
| 115 ::printf("f() = %d\n", res); | 115 ::printf("f() = %d\n", res); |
| 116 CHECK_EQ(5050, res); | 116 CHECK_EQ(5050, res); |
| 117 } | 117 } |
| 118 | 118 |
| 119 | 119 |
| 120 TEST(2) { | 120 TEST(2) { |
| 121 InitializeVM(); | 121 InitializeVM(); |
| 122 v8::HandleScope scope; | 122 v8::HandleScope scope; |
| 123 | 123 |
| 124 Assembler assm(Isolate::Current(), NULL, 0); | 124 Assembler assm(NULL, 0); |
| 125 Label L, C; | 125 Label L, C; |
| 126 | 126 |
| 127 __ mov(r1, Operand(r0)); | 127 __ mov(r1, Operand(r0)); |
| 128 __ mov(r0, Operand(1)); | 128 __ mov(r0, Operand(1)); |
| 129 __ b(&C); | 129 __ b(&C); |
| 130 | 130 |
| 131 __ bind(&L); | 131 __ bind(&L); |
| 132 __ mul(r0, r1, r0); | 132 __ mul(r0, r1, r0); |
| 133 __ sub(r1, r1, Operand(1)); | 133 __ sub(r1, r1, Operand(1)); |
| 134 | 134 |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 167 InitializeVM(); | 167 InitializeVM(); |
| 168 v8::HandleScope scope; | 168 v8::HandleScope scope; |
| 169 | 169 |
| 170 typedef struct { | 170 typedef struct { |
| 171 int i; | 171 int i; |
| 172 char c; | 172 char c; |
| 173 int16_t s; | 173 int16_t s; |
| 174 } T; | 174 } T; |
| 175 T t; | 175 T t; |
| 176 | 176 |
| 177 Assembler assm(Isolate::Current(), NULL, 0); | 177 Assembler assm(NULL, 0); |
| 178 Label L, C; | 178 Label L, C; |
| 179 | 179 |
| 180 __ mov(ip, Operand(sp)); | 180 __ mov(ip, Operand(sp)); |
| 181 __ stm(db_w, sp, r4.bit() | fp.bit() | lr.bit()); | 181 __ stm(db_w, sp, r4.bit() | fp.bit() | lr.bit()); |
| 182 __ sub(fp, ip, Operand(4)); | 182 __ sub(fp, ip, Operand(4)); |
| 183 __ mov(r4, Operand(r0)); | 183 __ mov(r4, Operand(r0)); |
| 184 __ ldr(r0, MemOperand(r4, OFFSET_OF(T, i))); | 184 __ ldr(r0, MemOperand(r4, OFFSET_OF(T, i))); |
| 185 __ mov(r2, Operand(r0, ASR, 1)); | 185 __ mov(r2, Operand(r0, ASR, 1)); |
| 186 __ str(r2, MemOperand(r4, OFFSET_OF(T, i))); | 186 __ str(r2, MemOperand(r4, OFFSET_OF(T, i))); |
| 187 __ ldrsb(r2, MemOperand(r4, OFFSET_OF(T, c))); | 187 __ ldrsb(r2, MemOperand(r4, OFFSET_OF(T, c))); |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 234 int i; | 234 int i; |
| 235 double m; | 235 double m; |
| 236 double n; | 236 double n; |
| 237 float x; | 237 float x; |
| 238 float y; | 238 float y; |
| 239 } T; | 239 } T; |
| 240 T t; | 240 T t; |
| 241 | 241 |
| 242 // Create a function that accepts &t, and loads, manipulates, and stores | 242 // Create a function that accepts &t, and loads, manipulates, and stores |
| 243 // the doubles and floats. | 243 // the doubles and floats. |
| 244 Assembler assm(Isolate::Current(), NULL, 0); | 244 Assembler assm(NULL, 0); |
| 245 Label L, C; | 245 Label L, C; |
| 246 | 246 |
| 247 | 247 |
| 248 if (CpuFeatures::IsSupported(VFP3)) { | 248 if (Isolate::Current()->cpu_features()->IsSupported(VFP3)) { |
| 249 CpuFeatures::Scope scope(VFP3); | 249 CpuFeatures::Scope scope(VFP3); |
| 250 | 250 |
| 251 __ mov(ip, Operand(sp)); | 251 __ mov(ip, Operand(sp)); |
| 252 __ stm(db_w, sp, r4.bit() | fp.bit() | lr.bit()); | 252 __ stm(db_w, sp, r4.bit() | fp.bit() | lr.bit()); |
| 253 __ sub(fp, ip, Operand(4)); | 253 __ sub(fp, ip, Operand(4)); |
| 254 | 254 |
| 255 __ mov(r4, Operand(r0)); | 255 __ mov(r4, Operand(r0)); |
| 256 __ vldr(d6, r4, OFFSET_OF(T, a)); | 256 __ vldr(d6, r4, OFFSET_OF(T, a)); |
| 257 __ vldr(d7, r4, OFFSET_OF(T, b)); | 257 __ vldr(d7, r4, OFFSET_OF(T, b)); |
| 258 __ vadd(d5, d6, d7); | 258 __ vadd(d5, d6, d7); |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 350 CHECK_EQ(1.5, t.a); | 350 CHECK_EQ(1.5, t.a); |
| 351 } | 351 } |
| 352 } | 352 } |
| 353 | 353 |
| 354 | 354 |
| 355 TEST(5) { | 355 TEST(5) { |
| 356 // Test the ARMv7 bitfield instructions. | 356 // Test the ARMv7 bitfield instructions. |
| 357 InitializeVM(); | 357 InitializeVM(); |
| 358 v8::HandleScope scope; | 358 v8::HandleScope scope; |
| 359 | 359 |
| 360 Assembler assm(Isolate::Current(), NULL, 0); | 360 Assembler assm(NULL, 0); |
| 361 | 361 |
| 362 if (CpuFeatures::IsSupported(ARMv7)) { | 362 if (Isolate::Current()->cpu_features()->IsSupported(ARMv7)) { |
| 363 CpuFeatures::Scope scope(ARMv7); | 363 CpuFeatures::Scope scope(ARMv7); |
| 364 // On entry, r0 = 0xAAAAAAAA = 0b10..10101010. | 364 // On entry, r0 = 0xAAAAAAAA = 0b10..10101010. |
| 365 __ ubfx(r0, r0, 1, 12); // 0b00..010101010101 = 0x555 | 365 __ ubfx(r0, r0, 1, 12); // 0b00..010101010101 = 0x555 |
| 366 __ sbfx(r0, r0, 0, 5); // 0b11..111111110101 = -11 | 366 __ sbfx(r0, r0, 0, 5); // 0b11..111111110101 = -11 |
| 367 __ bfc(r0, 1, 3); // 0b11..111111110001 = -15 | 367 __ bfc(r0, 1, 3); // 0b11..111111110001 = -15 |
| 368 __ mov(r1, Operand(7)); | 368 __ mov(r1, Operand(7)); |
| 369 __ bfi(r0, r1, 3, 3); // 0b11..111111111001 = -7 | 369 __ bfi(r0, r1, 3, 3); // 0b11..111111111001 = -7 |
| 370 __ mov(pc, Operand(lr)); | 370 __ mov(pc, Operand(lr)); |
| 371 | 371 |
| 372 CodeDesc desc; | 372 CodeDesc desc; |
| (...skipping 13 matching lines...) Expand all Loading... |
| 386 CHECK_EQ(-7, res); | 386 CHECK_EQ(-7, res); |
| 387 } | 387 } |
| 388 } | 388 } |
| 389 | 389 |
| 390 | 390 |
| 391 TEST(6) { | 391 TEST(6) { |
| 392 // Test saturating instructions. | 392 // Test saturating instructions. |
| 393 InitializeVM(); | 393 InitializeVM(); |
| 394 v8::HandleScope scope; | 394 v8::HandleScope scope; |
| 395 | 395 |
| 396 Assembler assm(Isolate::Current(), NULL, 0); | 396 Assembler assm(NULL, 0); |
| 397 | 397 |
| 398 if (CpuFeatures::IsSupported(ARMv7)) { | 398 if (Isolate::Current()->cpu_features()->IsSupported(ARMv7)) { |
| 399 CpuFeatures::Scope scope(ARMv7); | 399 CpuFeatures::Scope scope(ARMv7); |
| 400 __ usat(r1, 8, Operand(r0)); // Sat 0xFFFF to 0-255 = 0xFF. | 400 __ usat(r1, 8, Operand(r0)); // Sat 0xFFFF to 0-255 = 0xFF. |
| 401 __ usat(r2, 12, Operand(r0, ASR, 9)); // Sat (0xFFFF>>9) to 0-4095 = 0x7F. | 401 __ usat(r2, 12, Operand(r0, ASR, 9)); // Sat (0xFFFF>>9) to 0-4095 = 0x7F. |
| 402 __ usat(r3, 1, Operand(r0, LSL, 16)); // Sat (0xFFFF<<16) to 0-1 = 0x0. | 402 __ usat(r3, 1, Operand(r0, LSL, 16)); // Sat (0xFFFF<<16) to 0-1 = 0x0. |
| 403 __ add(r0, r1, Operand(r2)); | 403 __ add(r0, r1, Operand(r2)); |
| 404 __ add(r0, r0, Operand(r3)); | 404 __ add(r0, r0, Operand(r3)); |
| 405 __ mov(pc, Operand(lr)); | 405 __ mov(pc, Operand(lr)); |
| 406 | 406 |
| 407 CodeDesc desc; | 407 CodeDesc desc; |
| 408 assm.GetCode(&desc); | 408 assm.GetCode(&desc); |
| (...skipping 20 matching lines...) Expand all Loading... |
| 429 }; | 429 }; |
| 430 | 430 |
| 431 static void TestRoundingMode(VCVTTypes types, | 431 static void TestRoundingMode(VCVTTypes types, |
| 432 VFPRoundingMode mode, | 432 VFPRoundingMode mode, |
| 433 double value, | 433 double value, |
| 434 int expected, | 434 int expected, |
| 435 bool expected_exception = false) { | 435 bool expected_exception = false) { |
| 436 InitializeVM(); | 436 InitializeVM(); |
| 437 v8::HandleScope scope; | 437 v8::HandleScope scope; |
| 438 | 438 |
| 439 Assembler assm(Isolate::Current(), NULL, 0); | 439 Assembler assm(NULL, 0); |
| 440 | 440 |
| 441 if (CpuFeatures::IsSupported(VFP3)) { | 441 if (Isolate::Current()->cpu_features()->IsSupported(VFP3)) { |
| 442 CpuFeatures::Scope scope(VFP3); | 442 CpuFeatures::Scope scope(VFP3); |
| 443 | 443 |
| 444 Label wrong_exception; | 444 Label wrong_exception; |
| 445 | 445 |
| 446 __ vmrs(r1); | 446 __ vmrs(r1); |
| 447 // Set custom FPSCR. | 447 // Set custom FPSCR. |
| 448 __ bic(r2, r1, Operand(kVFPRoundingModeMask | kVFPExceptionMask)); | 448 __ bic(r2, r1, Operand(kVFPRoundingModeMask | kVFPExceptionMask)); |
| 449 __ orr(r2, r2, Operand(mode)); | 449 __ orr(r2, r2, Operand(mode)); |
| 450 __ vmsr(r2); | 450 __ vmsr(r2); |
| 451 | 451 |
| (...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 602 TestRoundingMode(u32_f64, RN, static_cast<double>(kMaxInt), kMaxInt); | 602 TestRoundingMode(u32_f64, RN, static_cast<double>(kMaxInt), kMaxInt); |
| 603 TestRoundingMode(u32_f64, RN, (kMaxInt + 0.49), kMaxInt); | 603 TestRoundingMode(u32_f64, RN, (kMaxInt + 0.49), kMaxInt); |
| 604 TestRoundingMode(u32_f64, RN, (kMaxInt + 0.5), | 604 TestRoundingMode(u32_f64, RN, (kMaxInt + 0.5), |
| 605 static_cast<uint32_t>(kMaxInt) + 1); | 605 static_cast<uint32_t>(kMaxInt) + 1); |
| 606 TestRoundingMode(u32_f64, RN, (kMaxUInt + 0.49), kMaxUInt); | 606 TestRoundingMode(u32_f64, RN, (kMaxUInt + 0.49), kMaxUInt); |
| 607 TestRoundingMode(u32_f64, RN, (kMaxUInt + 0.5), kMaxUInt, true); | 607 TestRoundingMode(u32_f64, RN, (kMaxUInt + 0.5), kMaxUInt, true); |
| 608 TestRoundingMode(u32_f64, RN, (kMaxUInt + 1.0), kMaxUInt, true); | 608 TestRoundingMode(u32_f64, RN, (kMaxUInt + 1.0), kMaxUInt, true); |
| 609 } | 609 } |
| 610 | 610 |
| 611 #undef __ | 611 #undef __ |
| OLD | NEW |