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 305 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
316 MacroAssembler assembler(isolate, nullptr, 0, | 316 MacroAssembler assembler(isolate, nullptr, 0, |
317 v8::internal::CodeObjectRequired::kYes); | 317 v8::internal::CodeObjectRequired::kYes); |
318 MacroAssembler* masm = &assembler; | 318 MacroAssembler* masm = &assembler; |
319 | 319 |
320 const int kNumCases = 512; | 320 const int kNumCases = 512; |
321 int values[kNumCases]; | 321 int values[kNumCases]; |
322 isolate->random_number_generator()->NextBytes(values, sizeof(values)); | 322 isolate->random_number_generator()->NextBytes(values, sizeof(values)); |
323 Label labels[kNumCases]; | 323 Label labels[kNumCases]; |
324 Label done; | 324 Label done; |
325 | 325 |
326 __ daddiu(sp, sp, -8); | 326 __ Push(ra); |
327 __ sd(ra, MemOperand(sp)); | |
328 | 327 |
329 __ Align(8); | 328 // Opposite of Align(8) as we have unaligned number of instructions in the |
329 // following block before the first dd(). | |
ivica.bogosavljevic
2016/01/25 11:40:03
Already made a remark
balazs.kilvady
2016/01/25 12:46:17
So do I :)
| |
330 if ((masm->pc_offset() & 7) == 0) { | |
331 __ nop(); | |
332 } | |
333 | |
330 { | 334 { |
331 __ BlockTrampolinePoolFor(kNumCases * 2 + 7 + 1); | 335 __ BlockTrampolinePoolFor(kNumCases * 2 + 6 + 1); |
332 PredictableCodeSizeScope predictable( | 336 PredictableCodeSizeScope predictable( |
333 masm, kNumCases * kPointerSize + ((7 + 1) * Assembler::kInstrSize)); | 337 masm, kNumCases * kPointerSize + ((6 + 1) * Assembler::kInstrSize)); |
334 Label here; | |
335 | 338 |
336 __ bal(&here); | 339 __ addiupc(at, 6 + 1); |
337 __ dsll(at, a0, 3); // In delay slot. | 340 __ dlsa(at, at, a0, 3); |
338 __ bind(&here); | 341 __ ld(at, MemOperand(at)); |
339 __ daddu(at, at, ra); | |
340 __ ld(at, MemOperand(at, 6 * Assembler::kInstrSize)); | |
341 __ jalr(at); | 342 __ jalr(at); |
342 __ nop(); // Branch delay slot nop. | 343 __ nop(); // Branch delay slot nop. |
343 __ bc(&done); | 344 __ bc(&done); |
344 // A nop instruction must be generated by the forbidden slot guard | 345 // A nop instruction must be generated by the forbidden slot guard |
345 // (Assembler::dd(Label*)) so the first label goes to an 8 bytes aligned | 346 // (Assembler::dd(Label*)) so the first label goes to an 8 bytes aligned |
346 // location. | 347 // location. |
347 for (int i = 0; i < kNumCases; ++i) { | 348 for (int i = 0; i < kNumCases; ++i) { |
348 __ dd(&labels[i]); | 349 __ dd(&labels[i]); |
349 } | 350 } |
350 } | 351 } |
351 | 352 |
352 for (int i = 0; i < kNumCases; ++i) { | 353 for (int i = 0; i < kNumCases; ++i) { |
353 __ bind(&labels[i]); | 354 __ bind(&labels[i]); |
354 __ lui(v0, (values[i] >> 16) & 0xffff); | 355 __ li(v0, values[i]); |
355 __ ori(v0, v0, values[i] & 0xffff); | |
356 __ jr(ra); | 356 __ jr(ra); |
357 __ nop(); | 357 __ nop(); |
358 } | 358 } |
359 | 359 |
360 __ bind(&done); | 360 __ bind(&done); |
361 __ ld(ra, MemOperand(sp)); | 361 __ Pop(ra); |
362 __ daddiu(sp, sp, 8); | |
363 __ jr(ra); | 362 __ jr(ra); |
364 __ nop(); | 363 __ nop(); |
365 | 364 |
366 CodeDesc desc; | 365 CodeDesc desc; |
367 masm->GetCode(&desc); | 366 masm->GetCode(&desc); |
368 Handle<Code> code = isolate->factory()->NewCode( | 367 Handle<Code> code = isolate->factory()->NewCode( |
369 desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); | 368 desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); |
370 #ifdef OBJECT_PRINT | 369 #ifdef OBJECT_PRINT |
371 code->Print(std::cout); | 370 code->Print(std::cout); |
372 #endif | 371 #endif |
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
538 for (size_t i = 0; i < nr_test_cases; ++i) { | 537 for (size_t i = 0; i < nr_test_cases; ++i) { |
539 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); |
540 PrintF("0x%" PRIx64 " =? 0x%" PRIx64 " == Dlsa(v0, %" PRIx64 ", %" PRIx64 | 539 PrintF("0x%" PRIx64 " =? 0x%" PRIx64 " == Dlsa(v0, %" PRIx64 ", %" PRIx64 |
541 ", %hhu)\n", | 540 ", %hhu)\n", |
542 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); |
543 CHECK_EQ(tc[i].expected_res, res); | 542 CHECK_EQ(tc[i].expected_res, res); |
544 } | 543 } |
545 } | 544 } |
546 | 545 |
547 #undef __ | 546 #undef __ |
OLD | NEW |