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

Side by Side Diff: src/mips/assembler-mips.cc

Issue 1237083003: MIPS: Improved checking target ranges for J and JAL instructions. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 5 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 | « no previous file | test/cctest/test-disasm-mips.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 (c) 1994-2006 Sun Microsystems Inc. 1 // Copyright (c) 1994-2006 Sun Microsystems Inc.
2 // All Rights Reserved. 2 // All Rights Reserved.
3 // 3 //
4 // Redistribution and use in source and binary forms, with or without 4 // Redistribution and use in source and binary forms, with or without
5 // modification, are permitted provided that the following conditions are 5 // modification, are permitted provided that the following conditions are
6 // met: 6 // met:
7 // 7 //
8 // - Redistributions of source code must retain the above copyright notice, 8 // - Redistributions of source code must retain the above copyright notice,
9 // this list of conditions and the following disclaimer. 9 // this list of conditions and the following disclaimer.
10 // 10 //
(...skipping 1388 matching lines...) Expand 10 before | Expand all | Expand 10 after
1399 DCHECK(!(rs.is(zero_reg))); 1399 DCHECK(!(rs.is(zero_reg)));
1400 Instr instr = POP76 | (rs.code() << kRsShift) | offset; 1400 Instr instr = POP76 | (rs.code() << kRsShift) | offset;
1401 emit(instr); 1401 emit(instr);
1402 } 1402 }
1403 1403
1404 1404
1405 void Assembler::j(int32_t target) { 1405 void Assembler::j(int32_t target) {
1406 #if DEBUG 1406 #if DEBUG
1407 // Get pc of delay slot. 1407 // Get pc of delay slot.
1408 uint32_t ipc = reinterpret_cast<uint32_t>(pc_ + 1 * kInstrSize); 1408 uint32_t ipc = reinterpret_cast<uint32_t>(pc_ + 1 * kInstrSize);
1409 bool in_range = (ipc ^ static_cast<uint32_t>(target) >> 1409 bool in_range = ((ipc ^ static_cast<uint32_t>(target)) >>
1410 (kImm26Bits + kImmFieldShift)) == 0; 1410 (kImm26Bits + kImmFieldShift)) == 0;
1411 DCHECK(in_range && ((target & 3) == 0)); 1411 DCHECK(in_range && ((target & 3) == 0));
1412 #endif 1412 #endif
1413 GenInstrJump(J, target >> 2); 1413 GenInstrJump(J, (target >> 2) & kImm26Mask);
1414 } 1414 }
1415 1415
1416 1416
1417 void Assembler::jr(Register rs) { 1417 void Assembler::jr(Register rs) {
1418 if (!IsMipsArchVariant(kMips32r6)) { 1418 if (!IsMipsArchVariant(kMips32r6)) {
1419 BlockTrampolinePoolScope block_trampoline_pool(this); 1419 BlockTrampolinePoolScope block_trampoline_pool(this);
1420 if (rs.is(ra)) { 1420 if (rs.is(ra)) {
1421 positions_recorder()->WriteRecordedPositions(); 1421 positions_recorder()->WriteRecordedPositions();
1422 } 1422 }
1423 GenInstrRegister(SPECIAL, rs, zero_reg, zero_reg, 0, JR); 1423 GenInstrRegister(SPECIAL, rs, zero_reg, zero_reg, 0, JR);
1424 BlockTrampolinePoolFor(1); // For associated delay slot. 1424 BlockTrampolinePoolFor(1); // For associated delay slot.
1425 } else { 1425 } else {
1426 jalr(rs, zero_reg); 1426 jalr(rs, zero_reg);
1427 } 1427 }
1428 } 1428 }
1429 1429
1430 1430
1431 void Assembler::jal(int32_t target) { 1431 void Assembler::jal(int32_t target) {
1432 #ifdef DEBUG 1432 #ifdef DEBUG
1433 // Get pc of delay slot. 1433 // Get pc of delay slot.
1434 uint32_t ipc = reinterpret_cast<uint32_t>(pc_ + 1 * kInstrSize); 1434 uint32_t ipc = reinterpret_cast<uint32_t>(pc_ + 1 * kInstrSize);
1435 bool in_range = (ipc ^ static_cast<uint32_t>(target) >> 1435 bool in_range = ((ipc ^ static_cast<uint32_t>(target)) >>
1436 (kImm26Bits + kImmFieldShift)) == 0; 1436 (kImm26Bits + kImmFieldShift)) == 0;
1437 DCHECK(in_range && ((target & 3) == 0)); 1437 DCHECK(in_range && ((target & 3) == 0));
1438 #endif 1438 #endif
1439 positions_recorder()->WriteRecordedPositions(); 1439 positions_recorder()->WriteRecordedPositions();
1440 GenInstrJump(JAL, target >> 2); 1440 GenInstrJump(JAL, (target >> 2) & kImm26Mask);
1441 } 1441 }
1442 1442
1443 1443
1444 void Assembler::jalr(Register rs, Register rd) { 1444 void Assembler::jalr(Register rs, Register rd) {
1445 DCHECK(rs.code() != rd.code()); 1445 DCHECK(rs.code() != rd.code());
1446 BlockTrampolinePoolScope block_trampoline_pool(this); 1446 BlockTrampolinePoolScope block_trampoline_pool(this);
1447 positions_recorder()->WriteRecordedPositions(); 1447 positions_recorder()->WriteRecordedPositions();
1448 GenInstrRegister(SPECIAL, rs, zero_reg, rd, 0, JALR); 1448 GenInstrRegister(SPECIAL, rs, zero_reg, rd, 0, JALR);
1449 BlockTrampolinePoolFor(1); // For associated delay slot. 1449 BlockTrampolinePoolFor(1); // For associated delay slot.
1450 } 1450 }
(...skipping 1644 matching lines...) Expand 10 before | Expand all | Expand 10 after
3095 if (patched) { 3095 if (patched) {
3096 CpuFeatures::FlushICache(pc + 2, sizeof(Address)); 3096 CpuFeatures::FlushICache(pc + 2, sizeof(Address));
3097 } 3097 }
3098 } 3098 }
3099 3099
3100 3100
3101 } // namespace internal 3101 } // namespace internal
3102 } // namespace v8 3102 } // namespace v8
3103 3103
3104 #endif // V8_TARGET_ARCH_MIPS 3104 #endif // V8_TARGET_ARCH_MIPS
OLDNEW
« no previous file with comments | « no previous file | test/cctest/test-disasm-mips.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698