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

Side by Side Diff: test/cctest/test-macro-assembler-mips.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-assembler-mips64.cc ('k') | test/cctest/test-macro-assembler-mips64.cc » ('j') | 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 243 matching lines...) Expand 10 before | Expand all | Expand 10 after
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;
266
267 // Similar to test-assembler-mips jump_tables1, with extra test for emitting a
268 // compact branch instruction before emission of the dd table.
269 CcTest::InitializeVM();
270 Isolate* isolate = CcTest::i_isolate();
271 HandleScope scope(isolate);
272 MacroAssembler assembler(isolate, nullptr, 0,
273 v8::internal::CodeObjectRequired::kYes);
274 MacroAssembler* masm = &assembler;
275
276 const int kNumCases = 512;
277 int values[kNumCases];
278 isolate->random_number_generator()->NextBytes(values, sizeof(values));
279 Label labels[kNumCases];
280 Label done;
281
282 __ addiu(sp, sp, -4);
283 __ sw(ra, MemOperand(sp));
284
285 {
286 __ BlockTrampolinePoolFor(kNumCases * 2 + 7 + 1);
287 PredictableCodeSizeScope predictable(
288 masm, kNumCases * kPointerSize + ((7 + 1) * Assembler::kInstrSize));
289 Label here;
290
291 __ bal(&here);
292 __ sll(at, a0, 3); // In delay slot.
293 __ bind(&here);
294 __ addu(at, at, ra);
295 __ lw(at, MemOperand(at, 6 * Assembler::kInstrSize));
296 __ jalr(at);
297 __ nop(); // Branch delay slot nop.
298 __ bc(&done);
299 for (int i = 0; i < kNumCases; ++i) {
300 __ dd(&labels[i]);
301 }
302 }
303
304 for (int i = 0; i < kNumCases; ++i) {
305 __ bind(&labels[i]);
306 __ lui(v0, (values[i] >> 16) & 0xffff);
307 __ ori(v0, v0, values[i] & 0xffff);
308 __ jr(ra);
309 __ nop();
310 }
311
312 __ bind(&done);
313 __ lw(ra, MemOperand(sp));
314 __ addiu(sp, sp, 4);
315 __ jr(ra);
316 __ nop();
317
318 CodeDesc desc;
319 masm->GetCode(&desc);
320 Handle<Code> code = isolate->factory()->NewCode(
321 desc, Code::ComputeFlags(Code::STUB), Handle<Code>());
322 #ifdef OBJECT_PRINT
323 code->Print(std::cout);
324 #endif
325 F1 f = FUNCTION_CAST<F1>(code->entry());
326 for (int i = 0; i < kNumCases; ++i) {
327 int64_t res = reinterpret_cast<int64_t>(
328 CALL_GENERATED_CODE(isolate, f, i, 0, 0, 0, 0));
329 ::printf("f(%d) = %" PRId64 "\n", i, res);
330 CHECK_EQ(values[i], res);
331 }
332 }
333
334
264 static uint32_t run_lsa(uint32_t rt, uint32_t rs, int8_t sa) { 335 static uint32_t run_lsa(uint32_t rt, uint32_t rs, int8_t sa) {
265 Isolate* isolate = CcTest::i_isolate(); 336 Isolate* isolate = CcTest::i_isolate();
266 HandleScope scope(isolate); 337 HandleScope scope(isolate);
267 MacroAssembler assembler(isolate, nullptr, 0, 338 MacroAssembler assembler(isolate, nullptr, 0,
268 v8::internal::CodeObjectRequired::kYes); 339 v8::internal::CodeObjectRequired::kYes);
269 MacroAssembler* masm = &assembler; 340 MacroAssembler* masm = &assembler;
270 341
271 __ Lsa(v0, a0, a1, sa); 342 __ Lsa(v0, a0, a1, sa);
272 __ jr(ra); 343 __ jr(ra);
273 __ nop(); 344 __ nop();
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
336 size_t nr_test_cases = sizeof(tc) / sizeof(TestCaseLsa); 407 size_t nr_test_cases = sizeof(tc) / sizeof(TestCaseLsa);
337 for (size_t i = 0; i < nr_test_cases; ++i) { 408 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); 409 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, 410 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); 411 tc[i].rt, tc[i].rs, tc[i].sa);
341 CHECK_EQ(tc[i].expected_res, res); 412 CHECK_EQ(tc[i].expected_res, res);
342 } 413 }
343 } 414 }
344 415
345 #undef __ 416 #undef __
OLDNEW
« no previous file with comments | « test/cctest/test-assembler-mips64.cc ('k') | test/cctest/test-macro-assembler-mips64.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698