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 19 matching lines...) Expand all Loading... |
30 | 30 |
31 // The original source code covered by the above license above has been | 31 // The original source code covered by the above license above has been |
32 // modified significantly by Google Inc. | 32 // modified significantly by Google Inc. |
33 // Copyright 2012 the V8 project authors. All rights reserved. | 33 // Copyright 2012 the V8 project authors. All rights reserved. |
34 | 34 |
35 | 35 |
36 #ifndef V8_MIPS_ASSEMBLER_MIPS_H_ | 36 #ifndef V8_MIPS_ASSEMBLER_MIPS_H_ |
37 #define V8_MIPS_ASSEMBLER_MIPS_H_ | 37 #define V8_MIPS_ASSEMBLER_MIPS_H_ |
38 | 38 |
39 #include <stdio.h> | 39 #include <stdio.h> |
| 40 |
| 41 #include <set> |
| 42 |
40 #include "src/assembler.h" | 43 #include "src/assembler.h" |
41 #include "src/mips64/constants-mips64.h" | 44 #include "src/mips64/constants-mips64.h" |
42 #include "src/serialize.h" | 45 #include "src/serialize.h" |
43 | 46 |
44 namespace v8 { | 47 namespace v8 { |
45 namespace internal { | 48 namespace internal { |
46 | 49 |
47 // CPU Registers. | 50 // CPU Registers. |
48 // | 51 // |
49 // 1) We would prefer to use an enum, but enum values are assignment- | 52 // 1) We would prefer to use an enum, but enum values are assignment- |
(...skipping 1002 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1052 void ClearRecordedAstId() { recorded_ast_id_ = TypeFeedbackId::None(); } | 1055 void ClearRecordedAstId() { recorded_ast_id_ = TypeFeedbackId::None(); } |
1053 | 1056 |
1054 // Record a comment relocation entry that can be used by a disassembler. | 1057 // Record a comment relocation entry that can be used by a disassembler. |
1055 // Use --code-comments to enable. | 1058 // Use --code-comments to enable. |
1056 void RecordComment(const char* msg); | 1059 void RecordComment(const char* msg); |
1057 | 1060 |
1058 // Record a deoptimization reason that can be used by a log or cpu profiler. | 1061 // Record a deoptimization reason that can be used by a log or cpu profiler. |
1059 // Use --trace-deopt to enable. | 1062 // Use --trace-deopt to enable. |
1060 void RecordDeoptReason(const int reason, const int raw_position); | 1063 void RecordDeoptReason(const int reason, const int raw_position); |
1061 | 1064 |
1062 static int RelocateInternalReference(byte* pc, intptr_t pc_delta); | 1065 static int RelocateInternalReference(RelocInfo::Mode rmode, byte* pc, |
| 1066 intptr_t pc_delta); |
1063 | 1067 |
1064 // Writes a single byte or word of data in the code stream. Used for | 1068 // Writes a single byte or word of data in the code stream. Used for |
1065 // inline tables, e.g., jump-tables. | 1069 // inline tables, e.g., jump-tables. |
1066 void db(uint8_t data); | 1070 void db(uint8_t data); |
1067 void dd(uint32_t data); | 1071 void dd(uint32_t data); |
| 1072 void dd(Label* label); |
1068 | 1073 |
1069 // Emits the address of the code stub's first instruction. | 1074 // Emits the address of the code stub's first instruction. |
1070 void emit_code_stub_address(Code* stub); | 1075 void emit_code_stub_address(Code* stub); |
1071 | 1076 |
1072 PositionsRecorder* positions_recorder() { return &positions_recorder_; } | 1077 PositionsRecorder* positions_recorder() { return &positions_recorder_; } |
1073 | 1078 |
1074 // Postpone the generation of the trampoline pool for the specified number of | 1079 // Postpone the generation of the trampoline pool for the specified number of |
1075 // instructions. | 1080 // instructions. |
1076 void BlockTrampolinePoolFor(int instructions); | 1081 void BlockTrampolinePoolFor(int instructions); |
1077 | 1082 |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1156 | 1161 |
1157 protected: | 1162 protected: |
1158 // Relocation for a type-recording IC has the AST id added to it. This | 1163 // Relocation for a type-recording IC has the AST id added to it. This |
1159 // member variable is a way to pass the information from the call site to | 1164 // member variable is a way to pass the information from the call site to |
1160 // the relocation info. | 1165 // the relocation info. |
1161 TypeFeedbackId recorded_ast_id_; | 1166 TypeFeedbackId recorded_ast_id_; |
1162 | 1167 |
1163 int64_t buffer_space() const { return reloc_info_writer.pos() - pc_; } | 1168 int64_t buffer_space() const { return reloc_info_writer.pos() - pc_; } |
1164 | 1169 |
1165 // Decode branch instruction at pos and return branch target pos. | 1170 // Decode branch instruction at pos and return branch target pos. |
1166 int64_t target_at(int64_t pos); | 1171 int64_t target_at(int64_t pos, bool is_internal); |
1167 | 1172 |
1168 // Patch branch instruction at pos to branch to given branch target pos. | 1173 // Patch branch instruction at pos to branch to given branch target pos. |
1169 void target_at_put(int64_t pos, int64_t target_pos); | 1174 void target_at_put(int64_t pos, int64_t target_pos, bool is_internal); |
1170 | 1175 |
1171 // Say if we need to relocate with this mode. | 1176 // Say if we need to relocate with this mode. |
1172 bool MustUseReg(RelocInfo::Mode rmode); | 1177 bool MustUseReg(RelocInfo::Mode rmode); |
1173 | 1178 |
1174 // Record reloc info for current pc_. | 1179 // Record reloc info for current pc_. |
1175 void RecordRelocInfo(RelocInfo::Mode rmode, intptr_t data = 0); | 1180 void RecordRelocInfo(RelocInfo::Mode rmode, intptr_t data = 0); |
1176 | 1181 |
1177 // Block the emission of the trampoline pool before pc_offset. | 1182 // Block the emission of the trampoline pool before pc_offset. |
1178 void BlockTrampolinePoolBefore(int pc_offset) { | 1183 void BlockTrampolinePoolBefore(int pc_offset) { |
1179 if (no_trampoline_pool_before_ < pc_offset) | 1184 if (no_trampoline_pool_before_ < pc_offset) |
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1329 | 1334 |
1330 void GenInstrJump(Opcode opcode, | 1335 void GenInstrJump(Opcode opcode, |
1331 uint32_t address); | 1336 uint32_t address); |
1332 | 1337 |
1333 // Helpers. | 1338 // Helpers. |
1334 void LoadRegPlusOffsetToAt(const MemOperand& src); | 1339 void LoadRegPlusOffsetToAt(const MemOperand& src); |
1335 | 1340 |
1336 // Labels. | 1341 // Labels. |
1337 void print(Label* L); | 1342 void print(Label* L); |
1338 void bind_to(Label* L, int pos); | 1343 void bind_to(Label* L, int pos); |
1339 void next(Label* L); | 1344 void next(Label* L, bool is_internal); |
1340 | 1345 |
1341 // One trampoline consists of: | 1346 // One trampoline consists of: |
1342 // - space for trampoline slots, | 1347 // - space for trampoline slots, |
1343 // - space for labels. | 1348 // - space for labels. |
1344 // | 1349 // |
1345 // Space for trampoline slots is equal to slot_count * 2 * kInstrSize. | 1350 // Space for trampoline slots is equal to slot_count * 2 * kInstrSize. |
1346 // Space for trampoline slots preceeds space for labels. Each label is of one | 1351 // Space for trampoline slots preceeds space for labels. Each label is of one |
1347 // instruction size, so total amount for labels is equal to | 1352 // instruction size, so total amount for labels is equal to |
1348 // label_count * kInstrSize. | 1353 // label_count * kInstrSize. |
1349 class Trampoline { | 1354 class Trampoline { |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1394 // If trampoline is emitted, generated code is becoming large. As this is | 1399 // If trampoline is emitted, generated code is becoming large. As this is |
1395 // already a slow case which can possibly break our code generation for the | 1400 // already a slow case which can possibly break our code generation for the |
1396 // extreme case, we use this information to trigger different mode of | 1401 // extreme case, we use this information to trigger different mode of |
1397 // branch instruction generation, where we use jump instructions rather | 1402 // branch instruction generation, where we use jump instructions rather |
1398 // than regular branch instructions. | 1403 // than regular branch instructions. |
1399 bool trampoline_emitted_; | 1404 bool trampoline_emitted_; |
1400 static const int kTrampolineSlotsSize = 6 * kInstrSize; | 1405 static const int kTrampolineSlotsSize = 6 * kInstrSize; |
1401 static const int kMaxBranchOffset = (1 << (18 - 1)) - 1; | 1406 static const int kMaxBranchOffset = (1 << (18 - 1)) - 1; |
1402 static const int kInvalidSlotPos = -1; | 1407 static const int kInvalidSlotPos = -1; |
1403 | 1408 |
| 1409 // Internal reference positions, required for unbounded internal reference |
| 1410 // labels. |
| 1411 std::set<int64_t> internal_reference_positions_; |
| 1412 |
1404 Trampoline trampoline_; | 1413 Trampoline trampoline_; |
1405 bool internal_trampoline_exception_; | 1414 bool internal_trampoline_exception_; |
1406 | 1415 |
1407 friend class RegExpMacroAssemblerMIPS; | 1416 friend class RegExpMacroAssemblerMIPS; |
1408 friend class RelocInfo; | 1417 friend class RelocInfo; |
1409 friend class CodePatcher; | 1418 friend class CodePatcher; |
1410 friend class BlockTrampolinePoolScope; | 1419 friend class BlockTrampolinePoolScope; |
1411 | 1420 |
1412 PositionsRecorder positions_recorder_; | 1421 PositionsRecorder positions_recorder_; |
1413 friend class PositionsRecorder; | 1422 friend class PositionsRecorder; |
1414 friend class EnsureSpace; | 1423 friend class EnsureSpace; |
1415 }; | 1424 }; |
1416 | 1425 |
1417 | 1426 |
1418 class EnsureSpace BASE_EMBEDDED { | 1427 class EnsureSpace BASE_EMBEDDED { |
1419 public: | 1428 public: |
1420 explicit EnsureSpace(Assembler* assembler) { | 1429 explicit EnsureSpace(Assembler* assembler) { |
1421 assembler->CheckBuffer(); | 1430 assembler->CheckBuffer(); |
1422 } | 1431 } |
1423 }; | 1432 }; |
1424 | 1433 |
1425 } } // namespace v8::internal | 1434 } } // namespace v8::internal |
1426 | 1435 |
1427 #endif // V8_ARM_ASSEMBLER_MIPS_H_ | 1436 #endif // V8_ARM_ASSEMBLER_MIPS_H_ |
OLD | NEW |