Chromium Code Reviews| 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 29 matching lines...) Expand all Loading... | |
| 40 | 40 |
| 41 | 41 |
| 42 using namespace v8::internal; | 42 using namespace v8::internal; |
| 43 | 43 |
| 44 | 44 |
| 45 // Define these function prototypes to match JSEntryFunction in execution.cc. | 45 // Define these function prototypes to match JSEntryFunction in execution.cc. |
| 46 typedef Object* (*F1)(int x, int p1, int p2, int p3, int p4); | 46 typedef Object* (*F1)(int x, int p1, int p2, int p3, int p4); |
| 47 typedef Object* (*F2)(int x, int y, int p2, int p3, int p4); | 47 typedef Object* (*F2)(int x, int y, int p2, int p3, int p4); |
| 48 typedef Object* (*F3)(void* p, int p1, int p2, int p3, int p4); | 48 typedef Object* (*F3)(void* p, int p1, int p2, int p3, int p4); |
| 49 | 49 |
| 50 // clang-format off | |
| 51 | |
| 52 | 50 |
| 53 #define __ assm. | 51 #define __ assm. |
| 54 | 52 |
| 55 TEST(MIPS0) { | 53 TEST(MIPS0) { |
| 56 CcTest::InitializeVM(); | 54 CcTest::InitializeVM(); |
| 57 Isolate* isolate = CcTest::i_isolate(); | 55 Isolate* isolate = CcTest::i_isolate(); |
| 58 HandleScope scope(isolate); | 56 HandleScope scope(isolate); |
| 59 | 57 |
| 60 MacroAssembler assm(isolate, NULL, 0, v8::internal::CodeObjectRequired::kYes); | 58 MacroAssembler assm(isolate, NULL, 0, v8::internal::CodeObjectRequired::kYes); |
| 61 | 59 |
| (...skipping 5284 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 5346 { 4, 1 }, | 5344 { 4, 1 }, |
| 5347 }; | 5345 }; |
| 5348 | 5346 |
| 5349 size_t nr_test_cases = sizeof(tc) / sizeof(TestCaseBal); | 5347 size_t nr_test_cases = sizeof(tc) / sizeof(TestCaseBal); |
| 5350 for (size_t i = 0; i < nr_test_cases; ++i) { | 5348 for (size_t i = 0; i < nr_test_cases; ++i) { |
| 5351 CHECK_EQ(tc[i].expected_res, run_bal(tc[i].offset)); | 5349 CHECK_EQ(tc[i].expected_res, run_bal(tc[i].offset)); |
| 5352 } | 5350 } |
| 5353 } | 5351 } |
| 5354 | 5352 |
| 5355 | 5353 |
| 5354 static uint32_t run_lsa(uint32_t rt, uint32_t rs, int8_t sa) { | |
| 5355 Isolate* isolate = CcTest::i_isolate(); | |
| 5356 HandleScope scope(isolate); | |
| 5357 MacroAssembler assm(isolate, nullptr, 0, | |
| 5358 v8::internal::CodeObjectRequired::kYes); | |
| 5359 | |
| 5360 __ lsa(v0, a0, a1, sa); | |
| 5361 __ jr(ra); | |
| 5362 __ nop(); | |
| 5363 | |
| 5364 CodeDesc desc; | |
| 5365 assm.GetCode(&desc); | |
| 5366 Handle<Code> code = isolate->factory()->NewCode( | |
| 5367 desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); | |
| 5368 | |
| 5369 F1 f = FUNCTION_CAST<F1>(code->entry()); | |
| 5370 | |
| 5371 uint32_t res = reinterpret_cast<uint32_t>( | |
| 5372 CALL_GENERATED_CODE(isolate, f, rt, rs, 0, 0, 0)); | |
| 5373 | |
| 5374 return res; | |
| 5375 } | |
| 5376 | |
| 5377 | |
| 5378 TEST(lsa) { | |
| 5379 if (!IsMipsArchVariant(kMips32r6)) return; | |
|
ivica.bogosavljevic
2015/12/24 09:54:05
Suggestion:
1) Instead of lsa, use Lsa macro-asse
balazs.kilvady
2015/12/25 13:30:29
I tought about this also but in that case the test
balazs.kilvady
2016/01/04 20:30:46
Done.
| |
| 5380 | |
| 5381 CcTest::InitializeVM(); | |
| 5382 struct TestCaseLsa { | |
| 5383 int32_t rt; | |
| 5384 int32_t rs; | |
| 5385 uint8_t sa; | |
| 5386 uint32_t expected_res; | |
| 5387 }; | |
| 5388 | |
| 5389 struct TestCaseLsa tc[] = { | |
| 5390 // rt, rs, sa, expected_res | |
| 5391 {0x4, 0x1, 1, 0x6}, | |
| 5392 {0x4, 0x1, 2, 0x8}, | |
| 5393 {0x4, 0x1, 3, 0xc}, | |
| 5394 {0x4, 0x1, 4, 0x14}, | |
| 5395 {0x0, 0x1, 1, 0x2}, | |
| 5396 {0x0, 0x1, 2, 0x4}, | |
| 5397 {0x0, 0x1, 3, 0x8}, | |
| 5398 {0x0, 0x1, 4, 0x10}, | |
| 5399 {0x4, 0x0, 1, 0x4}, | |
| 5400 {0x4, 0x0, 2, 0x4}, | |
| 5401 {0x4, 0x0, 3, 0x4}, | |
| 5402 {0x4, 0x0, 4, 0x4}, | |
| 5403 {0x4, INT32_MAX, 1, 0x2}, // Shift overflow. | |
| 5404 {0x4, INT32_MAX >> 1, 2, 0x0}, // Shift overflow. | |
| 5405 {0x4, INT32_MAX >> 2, 3, 0xfffffffc}, // Shift overflow. | |
| 5406 {0x4, INT32_MAX >> 3, 4, 0xfffffff4}, // Shift overflow. | |
| 5407 {INT32_MAX - 1, 0x1, 1, 0x80000000}, // Signed adition overflow. | |
| 5408 {INT32_MAX - 3, 0x1, 2, 0x80000000}, // Signed addition overflow. | |
| 5409 {INT32_MAX - 7, 0x1, 3, 0x80000000}, // Signed addition overflow. | |
| 5410 {INT32_MAX - 15, 0x1, 4, 0x80000000}, // Signed addition overflow. | |
| 5411 {-2, 0x1, 1, 0x0}, // Addition overflow. | |
| 5412 {-4, 0x1, 2, 0x0}, // Addition overflow. | |
| 5413 {-8, 0x1, 3, 0x0}, // Addition overflow. | |
| 5414 {-16, 0x1, 4, 0x0}}; // Addition overflow. | |
| 5415 | |
| 5416 size_t nr_test_cases = sizeof(tc) / sizeof(TestCaseLsa); | |
| 5417 for (size_t i = 0; i < nr_test_cases; ++i) { | |
| 5418 uint32_t res = run_lsa(tc[i].rt, tc[i].rs, tc[i].sa); | |
| 5419 PrintF("0x%x =? 0x%x == lsa(v0, %x, %x, %hhu)\n", tc[i].expected_res, res, | |
| 5420 tc[i].rt, tc[i].rs, tc[i].sa); | |
| 5421 CHECK_EQ(tc[i].expected_res, res); | |
| 5422 } | |
| 5423 } | |
| 5424 | |
| 5425 | |
| 5356 TEST(Trampoline) { | 5426 TEST(Trampoline) { |
| 5357 // Private member of Assembler class. | 5427 // Private member of Assembler class. |
| 5358 static const int kMaxBranchOffset = (1 << (18 - 1)) - 1; | 5428 static const int kMaxBranchOffset = (1 << (18 - 1)) - 1; |
| 5359 | 5429 |
| 5360 CcTest::InitializeVM(); | 5430 CcTest::InitializeVM(); |
| 5361 Isolate* isolate = CcTest::i_isolate(); | 5431 Isolate* isolate = CcTest::i_isolate(); |
| 5362 HandleScope scope(isolate); | 5432 HandleScope scope(isolate); |
| 5363 | 5433 |
| 5364 MacroAssembler assm(isolate, nullptr, 0, | 5434 MacroAssembler assm(isolate, nullptr, 0, |
| 5365 v8::internal::CodeObjectRequired::kYes); | 5435 v8::internal::CodeObjectRequired::kYes); |
| (...skipping 11 matching lines...) Expand all Loading... | |
| 5377 assm.GetCode(&desc); | 5447 assm.GetCode(&desc); |
| 5378 Handle<Code> code = isolate->factory()->NewCode( | 5448 Handle<Code> code = isolate->factory()->NewCode( |
| 5379 desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); | 5449 desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); |
| 5380 F2 f = FUNCTION_CAST<F2>(code->entry()); | 5450 F2 f = FUNCTION_CAST<F2>(code->entry()); |
| 5381 | 5451 |
| 5382 int32_t res = reinterpret_cast<int32_t>( | 5452 int32_t res = reinterpret_cast<int32_t>( |
| 5383 CALL_GENERATED_CODE(isolate, f, 42, 42, 0, 0, 0)); | 5453 CALL_GENERATED_CODE(isolate, f, 42, 42, 0, 0, 0)); |
| 5384 CHECK_EQ(res, 0); | 5454 CHECK_EQ(res, 0); |
| 5385 } | 5455 } |
| 5386 | 5456 |
| 5387 | |
| 5388 #undef __ | 5457 #undef __ |
| OLD | NEW |