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

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: Use Align(). 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
« no previous file with comments | « test/cctest/test-macro-assembler-mips.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 emitting a
312 // compact branch instruction before emission of the dd table.
313 CcTest::InitializeVM();
314 Isolate* isolate = CcTest::i_isolate();
315 HandleScope scope(isolate);
316 MacroAssembler assembler(isolate, nullptr, 0,
317 v8::internal::CodeObjectRequired::kYes);
318 MacroAssembler* masm = &assembler;
319
320 const int kNumCases = 512;
321 int values[kNumCases];
322 isolate->random_number_generator()->NextBytes(values, sizeof(values));
323 Label labels[kNumCases];
324 Label done;
325
326 __ daddiu(sp, sp, -8);
327 __ sd(ra, MemOperand(sp));
328
329 __ Align(8);
330 {
331 __ BlockTrampolinePoolFor(kNumCases * 2 + 7 + 1);
332 PredictableCodeSizeScope predictable(
333 masm, kNumCases * kPointerSize + ((7 + 1) * Assembler::kInstrSize));
334 Label here;
335
336 __ bal(&here);
337 __ dsll(at, a0, 3); // In delay slot.
338 __ bind(&here);
339 __ daddu(at, at, ra);
340 __ ld(at, MemOperand(at, 6 * Assembler::kInstrSize));
341 __ jalr(at);
342 __ nop(); // Branch delay slot nop.
343 __ bc(&done);
344 for (int i = 0; i < kNumCases; ++i) {
345 __ dd(&labels[i]);
346 }
347 }
348
349 for (int i = 0; i < kNumCases; ++i) {
350 __ bind(&labels[i]);
351 __ lui(v0, (values[i] >> 16) & 0xffff);
352 __ ori(v0, v0, values[i] & 0xffff);
353 __ jr(ra);
354 __ nop();
355 }
356
357 __ bind(&done);
358 __ ld(ra, MemOperand(sp));
359 __ daddiu(sp, sp, 8);
360 __ jr(ra);
361 __ nop();
362
363 CodeDesc desc;
364 masm->GetCode(&desc);
365 Handle<Code> code = isolate->factory()->NewCode(
366 desc, Code::ComputeFlags(Code::STUB), Handle<Code>());
367 #ifdef OBJECT_PRINT
368 code->Print(std::cout);
369 #endif
370 F1 f = FUNCTION_CAST<F1>(code->entry());
371 for (int i = 0; i < kNumCases; ++i) {
372 int64_t res = reinterpret_cast<int64_t>(
373 CALL_GENERATED_CODE(isolate, f, i, 0, 0, 0, 0));
374 ::printf("f(%d) = %" PRId64 "\n", i, res);
375 CHECK_EQ(values[i], res);
376 }
377 }
378
379
308 static uint64_t run_lsa(uint32_t rt, uint32_t rs, int8_t sa) { 380 static uint64_t run_lsa(uint32_t rt, uint32_t rs, int8_t sa) {
309 Isolate* isolate = CcTest::i_isolate(); 381 Isolate* isolate = CcTest::i_isolate();
310 HandleScope scope(isolate); 382 HandleScope scope(isolate);
311 MacroAssembler assembler(isolate, nullptr, 0, 383 MacroAssembler assembler(isolate, nullptr, 0,
312 v8::internal::CodeObjectRequired::kYes); 384 v8::internal::CodeObjectRequired::kYes);
313 MacroAssembler* masm = &assembler; 385 MacroAssembler* masm = &assembler;
314 386
315 __ Lsa(v0, a0, a1, sa); 387 __ Lsa(v0, a0, a1, sa);
316 __ jr(ra); 388 __ jr(ra);
317 __ nop(); 389 __ nop();
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after
463 for (size_t i = 0; i < nr_test_cases; ++i) { 535 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); 536 uint64_t res = run_dlsa(tc[i].rt, tc[i].rs, tc[i].sa);
465 PrintF("0x%" PRIx64 " =? 0x%" PRIx64 " == Dlsa(v0, %" PRIx64 ", %" PRIx64 537 PrintF("0x%" PRIx64 " =? 0x%" PRIx64 " == Dlsa(v0, %" PRIx64 ", %" PRIx64
466 ", %hhu)\n", 538 ", %hhu)\n",
467 tc[i].expected_res, res, tc[i].rt, tc[i].rs, tc[i].sa); 539 tc[i].expected_res, res, tc[i].rt, tc[i].rs, tc[i].sa);
468 CHECK_EQ(tc[i].expected_res, res); 540 CHECK_EQ(tc[i].expected_res, res);
469 } 541 }
470 } 542 }
471 543
472 #undef __ 544 #undef __
OLDNEW
« no previous file with comments | « 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