Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2013 the V8 project authors. All rights reserved. | 1 // Copyright 2013 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 243 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 254 F1 f = FUNCTION_CAST<F1>(code->entry()); | 254 F1 f = FUNCTION_CAST<F1>(code->entry()); |
| 255 for (int i = 0; i < kNumCases; ++i) { | 255 for (int i = 0; i < kNumCases; ++i) { |
| 256 int res = | 256 int res = |
| 257 reinterpret_cast<int>(CALL_GENERATED_CODE(isolate, f, i, 0, 0, 0, 0)); | 257 reinterpret_cast<int>(CALL_GENERATED_CODE(isolate, f, i, 0, 0, 0, 0)); |
| 258 ::printf("f(%d) = %d\n", i, res); | 258 ::printf("f(%d) = %d\n", i, res); |
| 259 CHECK_EQ(values[i], res); | 259 CHECK_EQ(values[i], res); |
| 260 } | 260 } |
| 261 } | 261 } |
| 262 | 262 |
| 263 | 263 |
| 264 TEST(jump_tables5) { | |
| 265 if (IsMipsArchVariant(kMips32r6)) return; | |
|
paul.l...
2016/01/12 01:13:40
I suspect this should be ! IsMipsArchVariant(kMips
balazs.kilvady
2016/01/12 16:32:11
Done.
| |
| 266 | |
| 267 // Similar to test-assembler-mips jump_tables1, with extra test for branch | |
| 268 // trampoline required before emission of the dd table (where trampolines are | |
| 269 // blocked), and proper transition to long-branch mode. | |
| 270 // Regression test for v8:4294. | |
|
paul.l...
2016/01/12 01:13:40
Is this still a regression for that issue? Or was
balazs.kilvady
2016/01/12 16:32:11
Done.
| |
| 271 CcTest::InitializeVM(); | |
| 272 Isolate* isolate = CcTest::i_isolate(); | |
| 273 HandleScope scope(isolate); | |
| 274 MacroAssembler assembler(isolate, nullptr, 0, | |
| 275 v8::internal::CodeObjectRequired::kYes); | |
| 276 MacroAssembler* masm = &assembler; | |
| 277 | |
| 278 const int kNumCases = 512; | |
| 279 int values[kNumCases]; | |
| 280 isolate->random_number_generator()->NextBytes(values, sizeof(values)); | |
| 281 Label labels[kNumCases]; | |
| 282 Label done; | |
| 283 | |
| 284 __ addiu(sp, sp, -4); | |
| 285 __ sw(ra, MemOperand(sp)); | |
| 286 | |
| 287 __ Align(8); | |
| 288 { | |
| 289 __ BlockTrampolinePoolFor(kNumCases * 2 + 7 + 1); | |
| 290 PredictableCodeSizeScope predictable( | |
| 291 masm, kNumCases * kPointerSize + ((7 + 1) * Assembler::kInstrSize)); | |
| 292 Label here; | |
| 293 | |
| 294 __ bal(&here); | |
| 295 __ sll(at, a0, 3); // In delay slot. | |
| 296 __ bind(&here); | |
| 297 __ addu(at, at, ra); | |
| 298 __ lw(at, MemOperand(at, 6 * Assembler::kInstrSize)); | |
| 299 __ jalr(at); | |
| 300 __ nop(); // Branch delay slot nop. | |
| 301 __ bc(&done); | |
| 302 for (int i = 0; i < kNumCases; ++i) { | |
| 303 __ dd(&labels[i]); | |
| 304 } | |
| 305 } | |
| 306 | |
| 307 for (int i = 0; i < kNumCases; ++i) { | |
| 308 __ bind(&labels[i]); | |
| 309 __ lui(v0, (values[i] >> 16) & 0xffff); | |
| 310 __ ori(v0, v0, values[i] & 0xffff); | |
| 311 __ jr(ra); | |
| 312 __ nop(); | |
| 313 } | |
| 314 | |
| 315 __ bind(&done); | |
| 316 __ lw(ra, MemOperand(sp)); | |
| 317 __ addiu(sp, sp, 4); | |
| 318 __ jr(ra); | |
| 319 __ nop(); | |
| 320 | |
| 321 CodeDesc desc; | |
| 322 masm->GetCode(&desc); | |
| 323 Handle<Code> code = isolate->factory()->NewCode( | |
| 324 desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); | |
| 325 #ifdef OBJECT_PRINT | |
| 326 code->Print(std::cout); | |
| 327 #endif | |
| 328 F1 f = FUNCTION_CAST<F1>(code->entry()); | |
| 329 for (int i = 0; i < kNumCases; ++i) { | |
| 330 int64_t res = reinterpret_cast<int64_t>( | |
| 331 CALL_GENERATED_CODE(isolate, f, i, 0, 0, 0, 0)); | |
| 332 ::printf("f(%d) = %" PRId64 "\n", i, res); | |
| 333 CHECK_EQ(values[i], res); | |
| 334 } | |
| 335 } | |
| 336 | |
| 337 | |
| 264 static uint32_t run_lsa(uint32_t rt, uint32_t rs, int8_t sa) { | 338 static uint32_t run_lsa(uint32_t rt, uint32_t rs, int8_t sa) { |
| 265 Isolate* isolate = CcTest::i_isolate(); | 339 Isolate* isolate = CcTest::i_isolate(); |
| 266 HandleScope scope(isolate); | 340 HandleScope scope(isolate); |
| 267 MacroAssembler assembler(isolate, nullptr, 0, | 341 MacroAssembler assembler(isolate, nullptr, 0, |
| 268 v8::internal::CodeObjectRequired::kYes); | 342 v8::internal::CodeObjectRequired::kYes); |
| 269 MacroAssembler* masm = &assembler; | 343 MacroAssembler* masm = &assembler; |
| 270 | 344 |
| 271 __ Lsa(v0, a0, a1, sa); | 345 __ Lsa(v0, a0, a1, sa); |
| 272 __ jr(ra); | 346 __ jr(ra); |
| 273 __ nop(); | 347 __ nop(); |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 336 size_t nr_test_cases = sizeof(tc) / sizeof(TestCaseLsa); | 410 size_t nr_test_cases = sizeof(tc) / sizeof(TestCaseLsa); |
| 337 for (size_t i = 0; i < nr_test_cases; ++i) { | 411 for (size_t i = 0; i < nr_test_cases; ++i) { |
| 338 uint32_t res = run_lsa(tc[i].rt, tc[i].rs, tc[i].sa); | 412 uint32_t res = run_lsa(tc[i].rt, tc[i].rs, tc[i].sa); |
| 339 PrintF("0x%x =? 0x%x == lsa(v0, %x, %x, %hhu)\n", tc[i].expected_res, res, | 413 PrintF("0x%x =? 0x%x == lsa(v0, %x, %x, %hhu)\n", tc[i].expected_res, res, |
| 340 tc[i].rt, tc[i].rs, tc[i].sa); | 414 tc[i].rt, tc[i].rs, tc[i].sa); |
| 341 CHECK_EQ(tc[i].expected_res, res); | 415 CHECK_EQ(tc[i].expected_res, res); |
| 342 } | 416 } |
| 343 } | 417 } |
| 344 | 418 |
| 345 #undef __ | 419 #undef __ |
| OLD | NEW |