Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(63)

Side by Side Diff: test/cctest/test-macro-assembler-mips64.cc

Issue 1573953002: MIPS: Fix dd() implementations for compact branches. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 287 matching lines...) Expand 10 before | Expand all | Expand 10 after
298 F1 f = FUNCTION_CAST<F1>(code->entry()); 298 F1 f = FUNCTION_CAST<F1>(code->entry());
299 for (int i = 0; i < kNumCases; ++i) { 299 for (int i = 0; i < kNumCases; ++i) {
300 int64_t res = reinterpret_cast<int64_t>( 300 int64_t res = reinterpret_cast<int64_t>(
301 CALL_GENERATED_CODE(isolate, f, i, 0, 0, 0, 0)); 301 CALL_GENERATED_CODE(isolate, f, i, 0, 0, 0, 0));
302 ::printf("f(%d) = %" PRId64 "\n", i, res); 302 ::printf("f(%d) = %" PRId64 "\n", i, res);
303 CHECK_EQ(values[i], res); 303 CHECK_EQ(values[i], res);
304 } 304 }
305 } 305 }
306 306
307 307
308 TEST(jump_tables5) {
309 if (kArchVariant != kMips64r6) return;
310
311 // Similar to test-assembler-mips jump_tables1, with extra test for branch
312 // trampoline required before emission of the dd table (where trampolines are
313 // blocked), and proper transition to long-branch mode.
314 // Regression test for v8:4294.
315 CcTest::InitializeVM();
316 Isolate* isolate = CcTest::i_isolate();
317 HandleScope scope(isolate);
318 MacroAssembler assembler(isolate, nullptr, 0,
319 v8::internal::CodeObjectRequired::kYes);
320 MacroAssembler* masm = &assembler;
321
322 const int kNumCases = 512;
323 int values[kNumCases];
324 isolate->random_number_generator()->NextBytes(values, sizeof(values));
325 Label labels[kNumCases];
326 Label done;
327
328 __ daddiu(sp, sp, -8);
329 __ sd(ra, MemOperand(sp));
330
331 __ Align(8);
332 {
333 __ BlockTrampolinePoolFor(kNumCases * 2 + 7 + 1);
334 PredictableCodeSizeScope predictable(
335 masm, kNumCases * kPointerSize + ((7 + 1) * Assembler::kInstrSize));
336 Label here;
337
338 __ bal(&here);
339 __ dsll(at, a0, 3); // In delay slot.
340 __ bind(&here);
341 __ daddu(at, at, ra);
342 __ ld(at, MemOperand(at, 6 * Assembler::kInstrSize));
343 __ jalr(at);
344 __ nop(); // Branch delay slot nop.
345 __ bc(&done);
346 for (int i = 0; i < kNumCases; ++i) {
347 __ dd(&labels[i]);
348 }
349 }
350
351 for (int i = 0; i < kNumCases; ++i) {
352 __ bind(&labels[i]);
353 __ lui(v0, (values[i] >> 16) & 0xffff);
354 __ ori(v0, v0, values[i] & 0xffff);
355 __ jr(ra);
356 __ nop();
357 }
358
359 __ bind(&done);
360 __ ld(ra, MemOperand(sp));
361 __ daddiu(sp, sp, 8);
362 __ jr(ra);
363 __ nop();
364
365 CodeDesc desc;
366 masm->GetCode(&desc);
367 Handle<Code> code = isolate->factory()->NewCode(
368 desc, Code::ComputeFlags(Code::STUB), Handle<Code>());
369 #ifdef OBJECT_PRINT
370 code->Print(std::cout);
371 #endif
372 F1 f = FUNCTION_CAST<F1>(code->entry());
373 for (int i = 0; i < kNumCases; ++i) {
374 int64_t res = reinterpret_cast<int64_t>(
375 CALL_GENERATED_CODE(isolate, f, i, 0, 0, 0, 0));
376 ::printf("f(%d) = %" PRId64 "\n", i, res);
377 CHECK_EQ(values[i], res);
378 }
379 }
380
381
308 static uint64_t run_lsa(uint32_t rt, uint32_t rs, int8_t sa) { 382 static uint64_t run_lsa(uint32_t rt, uint32_t rs, int8_t sa) {
309 Isolate* isolate = CcTest::i_isolate(); 383 Isolate* isolate = CcTest::i_isolate();
310 HandleScope scope(isolate); 384 HandleScope scope(isolate);
311 MacroAssembler assembler(isolate, nullptr, 0, 385 MacroAssembler assembler(isolate, nullptr, 0,
312 v8::internal::CodeObjectRequired::kYes); 386 v8::internal::CodeObjectRequired::kYes);
313 MacroAssembler* masm = &assembler; 387 MacroAssembler* masm = &assembler;
314 388
315 __ Lsa(v0, a0, a1, sa); 389 __ Lsa(v0, a0, a1, sa);
316 __ jr(ra); 390 __ jr(ra);
317 __ nop(); 391 __ nop();
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after
463 for (size_t i = 0; i < nr_test_cases; ++i) { 537 for (size_t i = 0; i < nr_test_cases; ++i) {
464 uint64_t res = run_dlsa(tc[i].rt, tc[i].rs, tc[i].sa); 538 uint64_t res = run_dlsa(tc[i].rt, tc[i].rs, tc[i].sa);
465 PrintF("0x%" PRIx64 " =? 0x%" PRIx64 " == Dlsa(v0, %" PRIx64 ", %" PRIx64 539 PrintF("0x%" PRIx64 " =? 0x%" PRIx64 " == Dlsa(v0, %" PRIx64 ", %" PRIx64
466 ", %hhu)\n", 540 ", %hhu)\n",
467 tc[i].expected_res, res, tc[i].rt, tc[i].rs, tc[i].sa); 541 tc[i].expected_res, res, tc[i].rt, tc[i].rs, tc[i].sa);
468 CHECK_EQ(tc[i].expected_res, res); 542 CHECK_EQ(tc[i].expected_res, res);
469 } 543 }
470 } 544 }
471 545
472 #undef __ 546 #undef __
OLDNEW
« test/cctest/test-macro-assembler-mips.cc ('K') | « test/cctest/test-macro-assembler-mips.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698