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 1065 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1076 // Check if an instruction is a branch of some kind. | 1076 // Check if an instruction is a branch of some kind. |
1077 static bool IsBranch(Instr instr); | 1077 static bool IsBranch(Instr instr); |
1078 static bool IsBc(Instr instr); | 1078 static bool IsBc(Instr instr); |
1079 static bool IsBzc(Instr instr); | 1079 static bool IsBzc(Instr instr); |
1080 static bool IsBeq(Instr instr); | 1080 static bool IsBeq(Instr instr); |
1081 static bool IsBne(Instr instr); | 1081 static bool IsBne(Instr instr); |
1082 static bool IsBeqzc(Instr instr); | 1082 static bool IsBeqzc(Instr instr); |
1083 static bool IsBnezc(Instr instr); | 1083 static bool IsBnezc(Instr instr); |
1084 static bool IsBeqc(Instr instr); | 1084 static bool IsBeqc(Instr instr); |
1085 static bool IsBnec(Instr instr); | 1085 static bool IsBnec(Instr instr); |
| 1086 static bool IsJicOrJialc(Instr instr); |
1086 | 1087 |
1087 static bool IsJump(Instr instr); | 1088 static bool IsJump(Instr instr); |
1088 static bool IsJ(Instr instr); | 1089 static bool IsJ(Instr instr); |
1089 static bool IsLui(Instr instr); | 1090 static bool IsLui(Instr instr); |
1090 static bool IsOri(Instr instr); | 1091 static bool IsOri(Instr instr); |
1091 | 1092 |
1092 static bool IsJal(Instr instr); | 1093 static bool IsJal(Instr instr); |
1093 static bool IsJr(Instr instr); | 1094 static bool IsJr(Instr instr); |
1094 static bool IsJalr(Instr instr); | 1095 static bool IsJalr(Instr instr); |
1095 | 1096 |
(...skipping 19 matching lines...) Expand all Loading... |
1115 static uint32_t GetSaField(Instr instr); | 1116 static uint32_t GetSaField(Instr instr); |
1116 static uint32_t GetOpcodeField(Instr instr); | 1117 static uint32_t GetOpcodeField(Instr instr); |
1117 static uint32_t GetFunction(Instr instr); | 1118 static uint32_t GetFunction(Instr instr); |
1118 static uint32_t GetFunctionField(Instr instr); | 1119 static uint32_t GetFunctionField(Instr instr); |
1119 static uint32_t GetImmediate16(Instr instr); | 1120 static uint32_t GetImmediate16(Instr instr); |
1120 static uint32_t GetLabelConst(Instr instr); | 1121 static uint32_t GetLabelConst(Instr instr); |
1121 | 1122 |
1122 static int32_t GetBranchOffset(Instr instr); | 1123 static int32_t GetBranchOffset(Instr instr); |
1123 static bool IsLw(Instr instr); | 1124 static bool IsLw(Instr instr); |
1124 static int16_t GetLwOffset(Instr instr); | 1125 static int16_t GetLwOffset(Instr instr); |
| 1126 static int16_t GetJicOrJialcOffset(Instr instr); |
| 1127 static int16_t GetLuiOffset(Instr instr); |
1125 static Instr SetLwOffset(Instr instr, int16_t offset); | 1128 static Instr SetLwOffset(Instr instr, int16_t offset); |
1126 | 1129 |
1127 static bool IsSw(Instr instr); | 1130 static bool IsSw(Instr instr); |
1128 static Instr SetSwOffset(Instr instr, int16_t offset); | 1131 static Instr SetSwOffset(Instr instr, int16_t offset); |
1129 static bool IsAddImmediate(Instr instr); | 1132 static bool IsAddImmediate(Instr instr); |
1130 static Instr SetAddImmediateOffset(Instr instr, int16_t offset); | 1133 static Instr SetAddImmediateOffset(Instr instr, int16_t offset); |
| 1134 static uint32_t CreateTargetAddress(Instr instr_lui, Instr instr_jic); |
| 1135 static void UnpackTargetAddress(uint32_t address, int16_t& lui_offset, |
| 1136 int16_t& jic_offset); |
| 1137 static void UnpackTargetAddressUnsigned(uint32_t address, |
| 1138 uint32_t& lui_offset, |
| 1139 uint32_t& jic_offset); |
1131 | 1140 |
1132 static bool IsAndImmediate(Instr instr); | 1141 static bool IsAndImmediate(Instr instr); |
1133 static bool IsEmittedConstant(Instr instr); | 1142 static bool IsEmittedConstant(Instr instr); |
1134 | 1143 |
1135 void CheckTrampolinePool(); | 1144 void CheckTrampolinePool(); |
1136 | 1145 |
1137 void PatchConstantPoolAccessInstruction(int pc_offset, int offset, | 1146 void PatchConstantPoolAccessInstruction(int pc_offset, int offset, |
1138 ConstantPoolEntry::Access access, | 1147 ConstantPoolEntry::Access access, |
1139 ConstantPoolEntry::Type type) { | 1148 ConstantPoolEntry::Type type) { |
1140 // No embedded constant pool support. | 1149 // No embedded constant pool support. |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1207 } | 1216 } |
1208 | 1217 |
1209 void EmitForbiddenSlotInstruction() { | 1218 void EmitForbiddenSlotInstruction() { |
1210 if (IsPrevInstrCompactBranch()) { | 1219 if (IsPrevInstrCompactBranch()) { |
1211 nop(); | 1220 nop(); |
1212 } | 1221 } |
1213 } | 1222 } |
1214 | 1223 |
1215 inline void CheckTrampolinePoolQuick(int extra_instructions = 0); | 1224 inline void CheckTrampolinePoolQuick(int extra_instructions = 0); |
1216 | 1225 |
| 1226 inline void CheckBuffer(); |
| 1227 |
1217 private: | 1228 private: |
1218 inline static void set_target_internal_reference_encoded_at(Address pc, | 1229 inline static void set_target_internal_reference_encoded_at(Address pc, |
1219 Address target); | 1230 Address target); |
1220 | 1231 |
1221 // Buffer size and constant pool distance are checked together at regular | 1232 // Buffer size and constant pool distance are checked together at regular |
1222 // intervals of kBufferCheckInterval emitted bytes. | 1233 // intervals of kBufferCheckInterval emitted bytes. |
1223 static const int kBufferCheckInterval = 1*KB/2; | 1234 static const int kBufferCheckInterval = 1*KB/2; |
1224 | 1235 |
1225 // Code generation. | 1236 // Code generation. |
1226 // The relocation writer's position is at least kGap bytes below the end of | 1237 // The relocation writer's position is at least kGap bytes below the end of |
(...skipping 26 matching lines...) Expand all Loading... |
1253 static const int kMaxRelocSize = RelocInfoWriter::kMaxSize; | 1264 static const int kMaxRelocSize = RelocInfoWriter::kMaxSize; |
1254 RelocInfoWriter reloc_info_writer; | 1265 RelocInfoWriter reloc_info_writer; |
1255 | 1266 |
1256 // The bound position, before this we cannot do instruction elimination. | 1267 // The bound position, before this we cannot do instruction elimination. |
1257 int last_bound_pos_; | 1268 int last_bound_pos_; |
1258 | 1269 |
1259 // Readable constants for compact branch handling in emit() | 1270 // Readable constants for compact branch handling in emit() |
1260 enum class CompactBranchType : bool { NO = false, COMPACT_BRANCH = true }; | 1271 enum class CompactBranchType : bool { NO = false, COMPACT_BRANCH = true }; |
1261 | 1272 |
1262 // Code emission. | 1273 // Code emission. |
1263 inline void CheckBuffer(); | |
1264 void GrowBuffer(); | 1274 void GrowBuffer(); |
1265 inline void emit(Instr x, | 1275 inline void emit(Instr x, |
1266 CompactBranchType is_compact_branch = CompactBranchType::NO); | 1276 CompactBranchType is_compact_branch = CompactBranchType::NO); |
1267 inline void emit(uint64_t x); | 1277 inline void emit(uint64_t x); |
1268 inline void CheckForEmitInForbiddenSlot(); | 1278 inline void CheckForEmitInForbiddenSlot(); |
1269 template <typename T> | 1279 template <typename T> |
1270 inline void EmitHelper(T x); | 1280 inline void EmitHelper(T x); |
1271 inline void EmitHelper(Instr x, CompactBranchType is_compact_branch); | 1281 inline void EmitHelper(Instr x, CompactBranchType is_compact_branch); |
1272 | 1282 |
1273 // Instruction generation. | 1283 // Instruction generation. |
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1400 }; | 1410 }; |
1401 | 1411 |
1402 int32_t get_trampoline_entry(int32_t pos); | 1412 int32_t get_trampoline_entry(int32_t pos); |
1403 int unbound_labels_count_; | 1413 int unbound_labels_count_; |
1404 // If trampoline is emitted, generated code is becoming large. As this is | 1414 // If trampoline is emitted, generated code is becoming large. As this is |
1405 // already a slow case which can possibly break our code generation for the | 1415 // already a slow case which can possibly break our code generation for the |
1406 // extreme case, we use this information to trigger different mode of | 1416 // extreme case, we use this information to trigger different mode of |
1407 // branch instruction generation, where we use jump instructions rather | 1417 // branch instruction generation, where we use jump instructions rather |
1408 // than regular branch instructions. | 1418 // than regular branch instructions. |
1409 bool trampoline_emitted_; | 1419 bool trampoline_emitted_; |
| 1420 #ifdef _MIPS_ARCH_MIPS32R6 |
| 1421 static const int kTrampolineSlotsSize = 2 * kInstrSize; |
| 1422 #else |
1410 static const int kTrampolineSlotsSize = 4 * kInstrSize; | 1423 static const int kTrampolineSlotsSize = 4 * kInstrSize; |
| 1424 #endif |
1411 static const int kMaxBranchOffset = (1 << (18 - 1)) - 1; | 1425 static const int kMaxBranchOffset = (1 << (18 - 1)) - 1; |
1412 static const int kMaxCompactBranchOffset = (1 << (28 - 1)) - 1; | 1426 static const int kMaxCompactBranchOffset = (1 << (28 - 1)) - 1; |
1413 static const int kInvalidSlotPos = -1; | 1427 static const int kInvalidSlotPos = -1; |
1414 | 1428 |
1415 // Internal reference positions, required for unbounded internal reference | 1429 // Internal reference positions, required for unbounded internal reference |
1416 // labels. | 1430 // labels. |
1417 std::set<int> internal_reference_positions_; | 1431 std::set<int> internal_reference_positions_; |
1418 | 1432 |
1419 void EmittedCompactBranchInstruction() { prev_instr_compact_branch_ = true; } | 1433 void EmittedCompactBranchInstruction() { prev_instr_compact_branch_ = true; } |
1420 void ClearCompactBranchState() { prev_instr_compact_branch_ = false; } | 1434 void ClearCompactBranchState() { prev_instr_compact_branch_ = false; } |
(...skipping 17 matching lines...) Expand all Loading... |
1438 public: | 1452 public: |
1439 explicit EnsureSpace(Assembler* assembler) { | 1453 explicit EnsureSpace(Assembler* assembler) { |
1440 assembler->CheckBuffer(); | 1454 assembler->CheckBuffer(); |
1441 } | 1455 } |
1442 }; | 1456 }; |
1443 | 1457 |
1444 } // namespace internal | 1458 } // namespace internal |
1445 } // namespace v8 | 1459 } // namespace v8 |
1446 | 1460 |
1447 #endif // V8_ARM_ASSEMBLER_MIPS_H_ | 1461 #endif // V8_ARM_ASSEMBLER_MIPS_H_ |
OLD | NEW |