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

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

Issue 1628453002: MIPS: Use PC realitive instructions on r6. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Rebase Created 4 years, 10 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 210 matching lines...) Expand 10 before | Expand all | Expand 10 after
221 221
222 222
223 TEST(jump_tables4) { 223 TEST(jump_tables4) {
224 // Similar to test-assembler-mips jump_tables1, with extra test for branch 224 // Similar to test-assembler-mips jump_tables1, with extra test for branch
225 // trampoline required before emission of the dd table (where trampolines are 225 // trampoline required before emission of the dd table (where trampolines are
226 // blocked), and proper transition to long-branch mode. 226 // blocked), and proper transition to long-branch mode.
227 // Regression test for v8:4294. 227 // Regression test for v8:4294.
228 CcTest::InitializeVM(); 228 CcTest::InitializeVM();
229 Isolate* isolate = CcTest::i_isolate(); 229 Isolate* isolate = CcTest::i_isolate();
230 HandleScope scope(isolate); 230 HandleScope scope(isolate);
231 MacroAssembler assembler(isolate, NULL, 0, 231 MacroAssembler assembler(isolate, nullptr, 0,
232 v8::internal::CodeObjectRequired::kYes); 232 v8::internal::CodeObjectRequired::kYes);
233 MacroAssembler* masm = &assembler; 233 MacroAssembler* masm = &assembler;
234 234
235 const int kNumCases = 512; 235 const int kNumCases = 512;
236 int values[kNumCases]; 236 int values[kNumCases];
237 isolate->random_number_generator()->NextBytes(values, sizeof(values)); 237 isolate->random_number_generator()->NextBytes(values, sizeof(values));
238 Label labels[kNumCases]; 238 Label labels[kNumCases];
239 Label near_start, end; 239 Label near_start, end, done;
240 240
241 __ daddiu(sp, sp, -8); 241 __ Push(ra);
242 __ sd(ra, MemOperand(sp));
243
244 __ mov(v0, zero_reg); 242 __ mov(v0, zero_reg);
245 243
246 __ Branch(&end); 244 __ Branch(&end);
247 __ bind(&near_start); 245 __ bind(&near_start);
248 246
249 // Generate slightly less than 32K instructions, which will soon require 247 // Generate slightly less than 32K instructions, which will soon require
250 // trampoline for branch distance fixup. 248 // trampoline for branch distance fixup.
251 for (int i = 0; i < 32768 - 256; ++i) { 249 for (int i = 0; i < 32768 - 256; ++i) {
252 __ addiu(v0, v0, 1); 250 __ addiu(v0, v0, 1);
253 } 251 }
254 252
255 __ Align(8); 253 __ GenerateSwitchTable(a0, kNumCases,
256 Label done; 254 [&labels](size_t i) { return labels + i; });
257 {
258 __ BlockTrampolinePoolFor(kNumCases * 2 + 6);
259 PredictableCodeSizeScope predictable(
260 masm, (kNumCases * 2 + 6) * Assembler::kInstrSize);
261 Label here;
262
263 __ bal(&here);
264 __ dsll(at, a0, 3); // In delay slot.
265 __ bind(&here);
266 __ daddu(at, at, ra);
267 __ ld(at, MemOperand(at, 4 * Assembler::kInstrSize));
268 __ jr(at);
269 __ nop(); // Branch delay slot nop.
270 for (int i = 0; i < kNumCases; ++i) {
271 __ dd(&labels[i]);
272 }
273 }
274 255
275 for (int i = 0; i < kNumCases; ++i) { 256 for (int i = 0; i < kNumCases; ++i) {
276 __ bind(&labels[i]); 257 __ bind(&labels[i]);
277 __ lui(v0, (values[i] >> 16) & 0xffff); 258 __ li(v0, values[i]);
278 __ ori(v0, v0, values[i] & 0xffff);
279 __ Branch(&done); 259 __ Branch(&done);
280 } 260 }
281 261
282 __ bind(&done); 262 __ bind(&done);
283 __ ld(ra, MemOperand(sp)); 263 __ Pop(ra);
284 __ daddiu(sp, sp, 8);
285 __ jr(ra); 264 __ jr(ra);
286 __ nop(); 265 __ nop();
287 266
288 __ bind(&end); 267 __ bind(&end);
289 __ Branch(&near_start); 268 __ Branch(&near_start);
290 269
291 CodeDesc desc; 270 CodeDesc desc;
292 masm->GetCode(&desc); 271 masm->GetCode(&desc);
293 Handle<Code> code = isolate->factory()->NewCode( 272 Handle<Code> code = isolate->factory()->NewCode(
294 desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); 273 desc, Code::ComputeFlags(Code::STUB), Handle<Code>());
(...skipping 21 matching lines...) Expand all
316 MacroAssembler assembler(isolate, nullptr, 0, 295 MacroAssembler assembler(isolate, nullptr, 0,
317 v8::internal::CodeObjectRequired::kYes); 296 v8::internal::CodeObjectRequired::kYes);
318 MacroAssembler* masm = &assembler; 297 MacroAssembler* masm = &assembler;
319 298
320 const int kNumCases = 512; 299 const int kNumCases = 512;
321 int values[kNumCases]; 300 int values[kNumCases];
322 isolate->random_number_generator()->NextBytes(values, sizeof(values)); 301 isolate->random_number_generator()->NextBytes(values, sizeof(values));
323 Label labels[kNumCases]; 302 Label labels[kNumCases];
324 Label done; 303 Label done;
325 304
326 __ daddiu(sp, sp, -8); 305 __ Push(ra);
327 __ sd(ra, MemOperand(sp));
328 306
329 __ Align(8); 307 // Opposite of Align(8) as we have unaligned number of instructions in the
308 // following block before the first dd().
309 if ((masm->pc_offset() & 7) == 0) {
310 __ nop();
311 }
312
330 { 313 {
331 __ BlockTrampolinePoolFor(kNumCases * 2 + 7 + 1); 314 __ BlockTrampolinePoolFor(kNumCases * 2 + 6 + 1);
332 PredictableCodeSizeScope predictable( 315 PredictableCodeSizeScope predictable(
333 masm, kNumCases * kPointerSize + ((7 + 1) * Assembler::kInstrSize)); 316 masm, kNumCases * kPointerSize + ((6 + 1) * Assembler::kInstrSize));
334 Label here;
335 317
336 __ bal(&here); 318 __ addiupc(at, 6 + 1);
337 __ dsll(at, a0, 3); // In delay slot. 319 __ dlsa(at, at, a0, 3);
338 __ bind(&here); 320 __ ld(at, MemOperand(at));
339 __ daddu(at, at, ra);
340 __ ld(at, MemOperand(at, 6 * Assembler::kInstrSize));
341 __ jalr(at); 321 __ jalr(at);
342 __ nop(); // Branch delay slot nop. 322 __ nop(); // Branch delay slot nop.
343 __ bc(&done); 323 __ bc(&done);
344 // A nop instruction must be generated by the forbidden slot guard 324 // 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 325 // (Assembler::dd(Label*)) so the first label goes to an 8 bytes aligned
346 // location. 326 // location.
347 for (int i = 0; i < kNumCases; ++i) { 327 for (int i = 0; i < kNumCases; ++i) {
348 __ dd(&labels[i]); 328 __ dd(&labels[i]);
349 } 329 }
350 } 330 }
351 331
352 for (int i = 0; i < kNumCases; ++i) { 332 for (int i = 0; i < kNumCases; ++i) {
353 __ bind(&labels[i]); 333 __ bind(&labels[i]);
354 __ lui(v0, (values[i] >> 16) & 0xffff); 334 __ li(v0, values[i]);
355 __ ori(v0, v0, values[i] & 0xffff);
356 __ jr(ra); 335 __ jr(ra);
357 __ nop(); 336 __ nop();
358 } 337 }
359 338
360 __ bind(&done); 339 __ bind(&done);
361 __ ld(ra, MemOperand(sp)); 340 __ Pop(ra);
362 __ daddiu(sp, sp, 8);
363 __ jr(ra); 341 __ jr(ra);
364 __ nop(); 342 __ nop();
365 343
366 CodeDesc desc; 344 CodeDesc desc;
367 masm->GetCode(&desc); 345 masm->GetCode(&desc);
368 Handle<Code> code = isolate->factory()->NewCode( 346 Handle<Code> code = isolate->factory()->NewCode(
369 desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); 347 desc, Code::ComputeFlags(Code::STUB), Handle<Code>());
370 #ifdef OBJECT_PRINT 348 #ifdef OBJECT_PRINT
371 code->Print(std::cout); 349 code->Print(std::cout);
372 #endif 350 #endif
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after
538 for (size_t i = 0; i < nr_test_cases; ++i) { 516 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); 517 uint64_t res = run_dlsa(tc[i].rt, tc[i].rs, tc[i].sa);
540 PrintF("0x%" PRIx64 " =? 0x%" PRIx64 " == Dlsa(v0, %" PRIx64 ", %" PRIx64 518 PrintF("0x%" PRIx64 " =? 0x%" PRIx64 " == Dlsa(v0, %" PRIx64 ", %" PRIx64
541 ", %hhu)\n", 519 ", %hhu)\n",
542 tc[i].expected_res, res, tc[i].rt, tc[i].rs, tc[i].sa); 520 tc[i].expected_res, res, tc[i].rt, tc[i].rs, tc[i].sa);
543 CHECK_EQ(tc[i].expected_res, res); 521 CHECK_EQ(tc[i].expected_res, res);
544 } 522 }
545 } 523 }
546 524
547 #undef __ 525 #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