OLD | NEW |
---|---|
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 505 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
516 // are split across two consecutive instructions and don't exist separately | 516 // are split across two consecutive instructions and don't exist separately |
517 // in the code, so the serializer should not step forwards in memory after | 517 // in the code, so the serializer should not step forwards in memory after |
518 // a target is resolved and written. | 518 // a target is resolved and written. |
519 static const int kSpecialTargetSize = 0; | 519 static const int kSpecialTargetSize = 0; |
520 | 520 |
521 // Number of consecutive instructions used to store 32bit constant. | 521 // Number of consecutive instructions used to store 32bit constant. |
522 // Before jump-optimizations, this constant was used in | 522 // Before jump-optimizations, this constant was used in |
523 // RelocInfo::target_address_address() function to tell serializer address of | 523 // RelocInfo::target_address_address() function to tell serializer address of |
524 // the instruction that follows LUI/ORI instruction pair. Now, with new jump | 524 // the instruction that follows LUI/ORI instruction pair. Now, with new jump |
525 // optimization, where jump-through-register instruction that usually | 525 // optimization, where jump-through-register instruction that usually |
526 // follows LUI/ORI pair is substituted with J/JAL, this constant equals | 526 // follows LUI/ORI pair is substituted with J/JAL, this constant equals |
paul.l...
2016/01/11 22:34:57
These comments about J/JAL should have been remove
miran.karic
2016/02/18 08:38:05
Done.
| |
527 // to 3 instructions (LUI+ORI+J/JAL/JR/JALR). | 527 // to 3 instructions (LUI+ORI+J/JAL/JR/JALR). On r6, 32bit constant is placed |
528 // in 2 instructions (LUI+JIC) | |
529 #ifdef _MIPS_ARCH_MIPS32R6 | |
530 static const int kInstructionsFor32BitConstant = 2; | |
531 #else | |
528 static const int kInstructionsFor32BitConstant = 3; | 532 static const int kInstructionsFor32BitConstant = 3; |
paul.l...
2016/01/11 22:34:57
I _think_ this case of 3 was only useful when we h
miran.karic
2016/02/18 08:38:05
Done. New CL created.
| |
533 #endif | |
529 | 534 |
530 // Distance between the instruction referring to the address of the call | 535 // Distance between the instruction referring to the address of the call |
531 // target and the return address. | 536 // target and the return address. |
532 static const int kCallTargetAddressOffset = 4 * kInstrSize; | 537 static const int kCallTargetAddressOffset = 4 * kInstrSize; |
533 | 538 |
534 // Distance between start of patched debug break slot and the emitted address | 539 // Distance between start of patched debug break slot and the emitted address |
535 // to jump to. | 540 // to jump to. |
536 static const int kPatchDebugBreakSlotAddressOffset = 4 * kInstrSize; | 541 static const int kPatchDebugBreakSlotAddressOffset = 4 * kInstrSize; |
537 | 542 |
538 // Difference between address of current opcode and value read from pc | 543 // Difference between address of current opcode and value read from pc |
(...skipping 540 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1079 // Check if an instruction is a branch of some kind. | 1084 // Check if an instruction is a branch of some kind. |
1080 static bool IsBranch(Instr instr); | 1085 static bool IsBranch(Instr instr); |
1081 static bool IsBc(Instr instr); | 1086 static bool IsBc(Instr instr); |
1082 static bool IsBzc(Instr instr); | 1087 static bool IsBzc(Instr instr); |
1083 static bool IsBeq(Instr instr); | 1088 static bool IsBeq(Instr instr); |
1084 static bool IsBne(Instr instr); | 1089 static bool IsBne(Instr instr); |
1085 static bool IsBeqzc(Instr instr); | 1090 static bool IsBeqzc(Instr instr); |
1086 static bool IsBnezc(Instr instr); | 1091 static bool IsBnezc(Instr instr); |
1087 static bool IsBeqc(Instr instr); | 1092 static bool IsBeqc(Instr instr); |
1088 static bool IsBnec(Instr instr); | 1093 static bool IsBnec(Instr instr); |
1094 static bool IsJicOrJialc(Instr instr); | |
1089 | 1095 |
1090 static bool IsJump(Instr instr); | 1096 static bool IsJump(Instr instr); |
1091 static bool IsJ(Instr instr); | 1097 static bool IsJ(Instr instr); |
1092 static bool IsLui(Instr instr); | 1098 static bool IsLui(Instr instr); |
1093 static bool IsOri(Instr instr); | 1099 static bool IsOri(Instr instr); |
1094 | 1100 |
1095 static bool IsJal(Instr instr); | 1101 static bool IsJal(Instr instr); |
1096 static bool IsJr(Instr instr); | 1102 static bool IsJr(Instr instr); |
1097 static bool IsJalr(Instr instr); | 1103 static bool IsJalr(Instr instr); |
1098 | 1104 |
(...skipping 19 matching lines...) Expand all Loading... | |
1118 static uint32_t GetSaField(Instr instr); | 1124 static uint32_t GetSaField(Instr instr); |
1119 static uint32_t GetOpcodeField(Instr instr); | 1125 static uint32_t GetOpcodeField(Instr instr); |
1120 static uint32_t GetFunction(Instr instr); | 1126 static uint32_t GetFunction(Instr instr); |
1121 static uint32_t GetFunctionField(Instr instr); | 1127 static uint32_t GetFunctionField(Instr instr); |
1122 static uint32_t GetImmediate16(Instr instr); | 1128 static uint32_t GetImmediate16(Instr instr); |
1123 static uint32_t GetLabelConst(Instr instr); | 1129 static uint32_t GetLabelConst(Instr instr); |
1124 | 1130 |
1125 static int32_t GetBranchOffset(Instr instr); | 1131 static int32_t GetBranchOffset(Instr instr); |
1126 static bool IsLw(Instr instr); | 1132 static bool IsLw(Instr instr); |
1127 static int16_t GetLwOffset(Instr instr); | 1133 static int16_t GetLwOffset(Instr instr); |
1134 static int16_t GetJicOrJialcOffset(Instr instr); | |
1135 static int16_t GetLuiOffset(Instr instr); | |
1128 static Instr SetLwOffset(Instr instr, int16_t offset); | 1136 static Instr SetLwOffset(Instr instr, int16_t offset); |
1129 | 1137 |
1130 static bool IsSw(Instr instr); | 1138 static bool IsSw(Instr instr); |
1131 static Instr SetSwOffset(Instr instr, int16_t offset); | 1139 static Instr SetSwOffset(Instr instr, int16_t offset); |
1132 static bool IsAddImmediate(Instr instr); | 1140 static bool IsAddImmediate(Instr instr); |
1133 static Instr SetAddImmediateOffset(Instr instr, int16_t offset); | 1141 static Instr SetAddImmediateOffset(Instr instr, int16_t offset); |
1142 static uint32_t createTargetAddress(Instr instr_lui, Instr instr_jic); | |
1143 static void unpackTargetAddress(uint32_t address, int16_t& lui_offset, | |
1144 int16_t& jic_offset); | |
1145 static void unpackTargetAddressUnsigned(uint32_t address, | |
1146 uint32_t& lui_offset, | |
1147 uint32_t& jic_offset); | |
1134 | 1148 |
1135 static bool IsAndImmediate(Instr instr); | 1149 static bool IsAndImmediate(Instr instr); |
1136 static bool IsEmittedConstant(Instr instr); | 1150 static bool IsEmittedConstant(Instr instr); |
1137 | 1151 |
1138 void CheckTrampolinePool(); | 1152 void CheckTrampolinePool(); |
1139 | 1153 |
1140 void PatchConstantPoolAccessInstruction(int pc_offset, int offset, | 1154 void PatchConstantPoolAccessInstruction(int pc_offset, int offset, |
1141 ConstantPoolEntry::Access access, | 1155 ConstantPoolEntry::Access access, |
1142 ConstantPoolEntry::Type type) { | 1156 ConstantPoolEntry::Type type) { |
1143 // No embedded constant pool support. | 1157 // No embedded constant pool support. |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1204 DCHECK(block_buffer_growth_); | 1218 DCHECK(block_buffer_growth_); |
1205 block_buffer_growth_ = false; | 1219 block_buffer_growth_ = false; |
1206 } | 1220 } |
1207 | 1221 |
1208 bool is_buffer_growth_blocked() const { | 1222 bool is_buffer_growth_blocked() const { |
1209 return block_buffer_growth_; | 1223 return block_buffer_growth_; |
1210 } | 1224 } |
1211 | 1225 |
1212 inline void CheckTrampolinePoolQuick(int extra_instructions = 0); | 1226 inline void CheckTrampolinePoolQuick(int extra_instructions = 0); |
1213 | 1227 |
1228 inline void CheckBuffer(); | |
1229 | |
1214 private: | 1230 private: |
1215 inline static void set_target_internal_reference_encoded_at(Address pc, | 1231 inline static void set_target_internal_reference_encoded_at(Address pc, |
1216 Address target); | 1232 Address target); |
1217 | 1233 |
1218 // Buffer size and constant pool distance are checked together at regular | 1234 // Buffer size and constant pool distance are checked together at regular |
1219 // intervals of kBufferCheckInterval emitted bytes. | 1235 // intervals of kBufferCheckInterval emitted bytes. |
1220 static const int kBufferCheckInterval = 1*KB/2; | 1236 static const int kBufferCheckInterval = 1*KB/2; |
1221 | 1237 |
1222 // Code generation. | 1238 // Code generation. |
1223 // The relocation writer's position is at least kGap bytes below the end of | 1239 // The relocation writer's position is at least kGap bytes below the end of |
(...skipping 26 matching lines...) Expand all Loading... | |
1250 static const int kMaxRelocSize = RelocInfoWriter::kMaxSize; | 1266 static const int kMaxRelocSize = RelocInfoWriter::kMaxSize; |
1251 RelocInfoWriter reloc_info_writer; | 1267 RelocInfoWriter reloc_info_writer; |
1252 | 1268 |
1253 // The bound position, before this we cannot do instruction elimination. | 1269 // The bound position, before this we cannot do instruction elimination. |
1254 int last_bound_pos_; | 1270 int last_bound_pos_; |
1255 | 1271 |
1256 // Readable constants for compact branch handling in emit() | 1272 // Readable constants for compact branch handling in emit() |
1257 enum class CompactBranchType : bool { NO = false, COMPACT_BRANCH = true }; | 1273 enum class CompactBranchType : bool { NO = false, COMPACT_BRANCH = true }; |
1258 | 1274 |
1259 // Code emission. | 1275 // Code emission. |
1260 inline void CheckBuffer(); | |
1261 void GrowBuffer(); | 1276 void GrowBuffer(); |
1262 inline void emit(Instr x, | 1277 inline void emit(Instr x, |
1263 CompactBranchType is_compact_branch = CompactBranchType::NO); | 1278 CompactBranchType is_compact_branch = CompactBranchType::NO); |
1264 | 1279 |
1265 // Instruction generation. | 1280 // Instruction generation. |
1266 // We have 3 different kind of encoding layout on MIPS. | 1281 // We have 3 different kind of encoding layout on MIPS. |
1267 // However due to many different types of objects encoded in the same fields | 1282 // However due to many different types of objects encoded in the same fields |
1268 // we have quite a few aliases for each mode. | 1283 // we have quite a few aliases for each mode. |
1269 // Using the same structure to refer to Register and FPURegister would spare a | 1284 // Using the same structure to refer to Register and FPURegister would spare a |
1270 // few aliases, but mixing both does not look clean to me. | 1285 // few aliases, but mixing both does not look clean to me. |
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1392 }; | 1407 }; |
1393 | 1408 |
1394 int32_t get_trampoline_entry(int32_t pos); | 1409 int32_t get_trampoline_entry(int32_t pos); |
1395 int unbound_labels_count_; | 1410 int unbound_labels_count_; |
1396 // If trampoline is emitted, generated code is becoming large. As this is | 1411 // If trampoline is emitted, generated code is becoming large. As this is |
1397 // already a slow case which can possibly break our code generation for the | 1412 // already a slow case which can possibly break our code generation for the |
1398 // extreme case, we use this information to trigger different mode of | 1413 // extreme case, we use this information to trigger different mode of |
1399 // branch instruction generation, where we use jump instructions rather | 1414 // branch instruction generation, where we use jump instructions rather |
1400 // than regular branch instructions. | 1415 // than regular branch instructions. |
1401 bool trampoline_emitted_; | 1416 bool trampoline_emitted_; |
1417 #ifdef _MIPS_ARCH_MIPS32R6 | |
1418 static const int kTrampolineSlotsSize = 2 * kInstrSize; | |
1419 #else | |
1402 static const int kTrampolineSlotsSize = 4 * kInstrSize; | 1420 static const int kTrampolineSlotsSize = 4 * kInstrSize; |
1421 #endif | |
1403 static const int kMaxBranchOffset = (1 << (18 - 1)) - 1; | 1422 static const int kMaxBranchOffset = (1 << (18 - 1)) - 1; |
1404 static const int kMaxCompactBranchOffset = (1 << (28 - 1)) - 1; | 1423 static const int kMaxCompactBranchOffset = (1 << (28 - 1)) - 1; |
1405 static const int kInvalidSlotPos = -1; | 1424 static const int kInvalidSlotPos = -1; |
1406 | 1425 |
1407 // Internal reference positions, required for unbounded internal reference | 1426 // Internal reference positions, required for unbounded internal reference |
1408 // labels. | 1427 // labels. |
1409 std::set<int> internal_reference_positions_; | 1428 std::set<int> internal_reference_positions_; |
1410 | 1429 |
1411 void EmittedCompactBranchInstruction() { prev_instr_compact_branch_ = true; } | 1430 void EmittedCompactBranchInstruction() { prev_instr_compact_branch_ = true; } |
1412 void ClearCompactBranchState() { prev_instr_compact_branch_ = false; } | 1431 void ClearCompactBranchState() { prev_instr_compact_branch_ = false; } |
(...skipping 17 matching lines...) Expand all Loading... | |
1430 public: | 1449 public: |
1431 explicit EnsureSpace(Assembler* assembler) { | 1450 explicit EnsureSpace(Assembler* assembler) { |
1432 assembler->CheckBuffer(); | 1451 assembler->CheckBuffer(); |
1433 } | 1452 } |
1434 }; | 1453 }; |
1435 | 1454 |
1436 } // namespace internal | 1455 } // namespace internal |
1437 } // namespace v8 | 1456 } // namespace v8 |
1438 | 1457 |
1439 #endif // V8_ARM_ASSEMBLER_MIPS_H_ | 1458 #endif // V8_ARM_ASSEMBLER_MIPS_H_ |
OLD | NEW |