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 | 5 // modification, are permitted provided that the following conditions |
6 // are met: | 6 // are 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 619 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
630 // Label L; // unbound label | 630 // Label L; // unbound label |
631 // j(cc, &L); // forward branch to unbound label | 631 // j(cc, &L); // forward branch to unbound label |
632 // bind(&L); // bind label to the current pc | 632 // bind(&L); // bind label to the current pc |
633 // j(cc, &L); // backward branch to bound label | 633 // j(cc, &L); // backward branch to bound label |
634 // bind(&L); // illegal: a label may be bound only once | 634 // bind(&L); // illegal: a label may be bound only once |
635 // | 635 // |
636 // Note: The same Label can be used for forward and backward branches | 636 // Note: The same Label can be used for forward and backward branches |
637 // but it may be bound only once. | 637 // but it may be bound only once. |
638 | 638 |
639 void bind(Label* L); // binds an unbound label L to the current code position | 639 void bind(Label* L); // binds an unbound label L to the current code position |
| 640 |
| 641 // Links a label at the current pc_offset(). If already bound, returns the |
| 642 // bound position. If already linked, returns the position of the prior link. |
| 643 // Otherwise, returns the current pc_offset(). |
| 644 int link(Label* L); |
| 645 |
640 // Determines if Label is bound and near enough so that a single | 646 // Determines if Label is bound and near enough so that a single |
641 // branch instruction can be used to reach it. | 647 // branch instruction can be used to reach it. |
642 bool is_near(Label* L, Condition cond); | 648 bool is_near(Label* L, Condition cond); |
643 | 649 |
644 // Returns the branch offset to the given label from the current code position | 650 // Returns the branch offset to the given label from the current code position |
645 // Links the label to the current position if it is still unbound | 651 // Links the label to the current position if it is still unbound |
646 // Manages the jump elimination optimization if the second parameter is true. | 652 // Manages the jump elimination optimization if the second parameter is true. |
647 int branch_offset(Label* L, bool jump_elimination_allowed); | 653 int branch_offset(Label* L, bool jump_elimination_allowed) { |
| 654 int position = link(L); |
| 655 return position - pc_offset(); |
| 656 } |
648 | 657 |
649 // Puts a labels target address at the given position. | 658 // Puts a labels target address at the given position. |
650 // The high 8 bits are set to zero. | 659 // The high 8 bits are set to zero. |
651 void label_at_put(Label* L, int at_offset); | 660 void label_at_put(Label* L, int at_offset); |
652 | 661 |
653 #if V8_OOL_CONSTANT_POOL | 662 #if V8_OOL_CONSTANT_POOL |
654 INLINE(static bool IsConstantPoolLoadStart(Address pc)); | 663 INLINE(static bool IsConstantPoolLoadStart(Address pc)); |
655 INLINE(static bool IsConstantPoolLoadEnd(Address pc)); | 664 INLINE(static bool IsConstantPoolLoadEnd(Address pc)); |
656 INLINE(static int GetConstantPoolOffset(Address pc)); | 665 INLINE(static int GetConstantPoolOffset(Address pc)); |
657 INLINE(static void SetConstantPoolOffset(Address pc, int offset)); | 666 INLINE(static void SetConstantPoolOffset(Address pc, int offset)); |
(...skipping 411 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1069 void cntlzw_(Register dst, Register src, RCBit rc = LeaveRC); | 1078 void cntlzw_(Register dst, Register src, RCBit rc = LeaveRC); |
1070 | 1079 |
1071 void subi(Register dst, Register src1, const Operand& src2); | 1080 void subi(Register dst, Register src1, const Operand& src2); |
1072 | 1081 |
1073 void cmp(Register src1, Register src2, CRegister cr = cr7); | 1082 void cmp(Register src1, Register src2, CRegister cr = cr7); |
1074 void cmpl(Register src1, Register src2, CRegister cr = cr7); | 1083 void cmpl(Register src1, Register src2, CRegister cr = cr7); |
1075 void cmpw(Register src1, Register src2, CRegister cr = cr7); | 1084 void cmpw(Register src1, Register src2, CRegister cr = cr7); |
1076 void cmplw(Register src1, Register src2, CRegister cr = cr7); | 1085 void cmplw(Register src1, Register src2, CRegister cr = cr7); |
1077 | 1086 |
1078 void mov(Register dst, const Operand& src); | 1087 void mov(Register dst, const Operand& src); |
| 1088 void bitwise_mov(Register dst, intptr_t value); |
| 1089 void bitwise_mov32(Register dst, int32_t value); |
1079 | 1090 |
1080 // Load the position of the label relative to the generated code object | 1091 // Load the position of the label relative to the generated code object |
1081 // pointer in a register. | 1092 // pointer in a register. |
1082 void mov_label_offset(Register dst, Label* label); | 1093 void mov_label_offset(Register dst, Label* label); |
1083 | 1094 |
| 1095 // Load the address of the label in a register and associate with an |
| 1096 // internal reference relocation. |
| 1097 void mov_label_addr(Register dst, Label* label); |
| 1098 |
| 1099 // Emit the address of the label (i.e. a jump table entry) and associate with |
| 1100 // an internal reference relocation. |
| 1101 void emit_label_addr(Label* label); |
| 1102 |
1084 // Multiply instructions | 1103 // Multiply instructions |
1085 void mul(Register dst, Register src1, Register src2, OEBit s = LeaveOE, | 1104 void mul(Register dst, Register src1, Register src2, OEBit s = LeaveOE, |
1086 RCBit r = LeaveRC); | 1105 RCBit r = LeaveRC); |
1087 | 1106 |
1088 // Miscellaneous arithmetic instructions | 1107 // Miscellaneous arithmetic instructions |
1089 | 1108 |
1090 // Special register access | 1109 // Special register access |
1091 void crxor(int bt, int ba, int bb); | 1110 void crxor(int bt, int ba, int bb); |
1092 void crclr(int bt) { crxor(bt, bt, bt); } | 1111 void crclr(int bt) { crxor(bt, bt, bt); } |
1093 void creqv(int bt, int ba, int bb); | 1112 void creqv(int bt, int ba, int bb); |
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1282 void RecordComment(const char* msg); | 1301 void RecordComment(const char* msg); |
1283 | 1302 |
1284 // Record a deoptimization reason that can be used by a log or cpu profiler. | 1303 // Record a deoptimization reason that can be used by a log or cpu profiler. |
1285 // Use --trace-deopt to enable. | 1304 // Use --trace-deopt to enable. |
1286 void RecordDeoptReason(const int reason, const int raw_position); | 1305 void RecordDeoptReason(const int reason, const int raw_position); |
1287 | 1306 |
1288 // Writes a single byte or word of data in the code stream. Used | 1307 // Writes a single byte or word of data in the code stream. Used |
1289 // for inline tables, e.g., jump-tables. | 1308 // for inline tables, e.g., jump-tables. |
1290 void db(uint8_t data); | 1309 void db(uint8_t data); |
1291 void dd(uint32_t data); | 1310 void dd(uint32_t data); |
1292 void emit_ptr(uintptr_t data); | 1311 void emit_ptr(intptr_t data); |
1293 | 1312 |
1294 PositionsRecorder* positions_recorder() { return &positions_recorder_; } | 1313 PositionsRecorder* positions_recorder() { return &positions_recorder_; } |
1295 | 1314 |
1296 // Read/patch instructions | 1315 // Read/patch instructions |
1297 Instr instr_at(int pos) { return *reinterpret_cast<Instr*>(buffer_ + pos); } | 1316 Instr instr_at(int pos) { return *reinterpret_cast<Instr*>(buffer_ + pos); } |
1298 void instr_at_put(int pos, Instr instr) { | 1317 void instr_at_put(int pos, Instr instr) { |
1299 *reinterpret_cast<Instr*>(buffer_ + pos) = instr; | 1318 *reinterpret_cast<Instr*>(buffer_ + pos) = instr; |
1300 } | 1319 } |
1301 static Instr instr_at(byte* pc) { return *reinterpret_cast<Instr*>(pc); } | 1320 static Instr instr_at(byte* pc) { return *reinterpret_cast<Instr*>(pc); } |
1302 static void instr_at_put(byte* pc, Instr instr) { | 1321 static void instr_at_put(byte* pc, Instr instr) { |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1362 bool is_constant_pool_full() const { | 1381 bool is_constant_pool_full() const { |
1363 return constant_pool_builder_.is_full(); | 1382 return constant_pool_builder_.is_full(); |
1364 } | 1383 } |
1365 | 1384 |
1366 bool use_extended_constant_pool() const { | 1385 bool use_extended_constant_pool() const { |
1367 return constant_pool_builder_.current_section() == | 1386 return constant_pool_builder_.current_section() == |
1368 ConstantPoolArray::EXTENDED_SECTION; | 1387 ConstantPoolArray::EXTENDED_SECTION; |
1369 } | 1388 } |
1370 #endif | 1389 #endif |
1371 | 1390 |
1372 #if ABI_USES_FUNCTION_DESCRIPTORS || V8_OOL_CONSTANT_POOL | |
1373 static void RelocateInternalReference( | 1391 static void RelocateInternalReference( |
1374 Address pc, intptr_t delta, Address code_start, | 1392 Address pc, intptr_t delta, Address code_start, RelocInfo::Mode rmode, |
1375 ICacheFlushMode icache_flush_mode = FLUSH_ICACHE_IF_NEEDED); | 1393 ICacheFlushMode icache_flush_mode = FLUSH_ICACHE_IF_NEEDED); |
1376 static int DecodeInternalReference(Vector<char> buffer, Address pc); | 1394 |
1377 #endif | 1395 void AddBoundInternalReference(int position) { |
| 1396 internal_reference_positions_.push_back(position); |
| 1397 } |
| 1398 |
| 1399 void AddBoundInternalReferenceLoad(int position) { |
| 1400 internal_reference_load_positions_.push_back(position); |
| 1401 } |
1378 | 1402 |
1379 protected: | 1403 protected: |
1380 // Relocation for a type-recording IC has the AST id added to it. This | 1404 // Relocation for a type-recording IC has the AST id added to it. This |
1381 // member variable is a way to pass the information from the call site to | 1405 // member variable is a way to pass the information from the call site to |
1382 // the relocation info. | 1406 // the relocation info. |
1383 TypeFeedbackId recorded_ast_id_; | 1407 TypeFeedbackId recorded_ast_id_; |
1384 | 1408 |
1385 int buffer_space() const { return reloc_info_writer.pos() - pc_; } | 1409 int buffer_space() const { return reloc_info_writer.pos() - pc_; } |
1386 | 1410 |
1387 // Decode branch instruction at pos and return branch target pos | 1411 // Decode branch instruction at pos and return branch target pos |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1433 | 1457 |
1434 // Emission of the trampoline pool may be blocked in some code sequences. | 1458 // Emission of the trampoline pool may be blocked in some code sequences. |
1435 int trampoline_pool_blocked_nesting_; // Block emission if this is not zero. | 1459 int trampoline_pool_blocked_nesting_; // Block emission if this is not zero. |
1436 int no_trampoline_pool_before_; // Block emission before this pc offset. | 1460 int no_trampoline_pool_before_; // Block emission before this pc offset. |
1437 | 1461 |
1438 // Relocation info generation | 1462 // Relocation info generation |
1439 // Each relocation is encoded as a variable size value | 1463 // Each relocation is encoded as a variable size value |
1440 static const int kMaxRelocSize = RelocInfoWriter::kMaxSize; | 1464 static const int kMaxRelocSize = RelocInfoWriter::kMaxSize; |
1441 RelocInfoWriter reloc_info_writer; | 1465 RelocInfoWriter reloc_info_writer; |
1442 | 1466 |
| 1467 // Internal reference positions, required for (potential) patching in |
| 1468 // GrowBuffer(); contains only those internal references whose labels |
| 1469 // are already bound. |
| 1470 std::deque<int> internal_reference_positions_; |
| 1471 std::deque<int> internal_reference_load_positions_; |
| 1472 |
1443 // The bound position, before this we cannot do instruction elimination. | 1473 // The bound position, before this we cannot do instruction elimination. |
1444 int last_bound_pos_; | 1474 int last_bound_pos_; |
1445 | 1475 |
1446 #if V8_OOL_CONSTANT_POOL | 1476 #if V8_OOL_CONSTANT_POOL |
1447 ConstantPoolBuilder constant_pool_builder_; | 1477 ConstantPoolBuilder constant_pool_builder_; |
1448 #endif | 1478 #endif |
1449 | 1479 |
1450 // Code emission | 1480 // Code emission |
1451 inline void CheckBuffer(); | 1481 inline void CheckBuffer(); |
1452 void GrowBuffer(); | 1482 void GrowBuffer(); |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1530 | 1560 |
1531 | 1561 |
1532 class EnsureSpace BASE_EMBEDDED { | 1562 class EnsureSpace BASE_EMBEDDED { |
1533 public: | 1563 public: |
1534 explicit EnsureSpace(Assembler* assembler) { assembler->CheckBuffer(); } | 1564 explicit EnsureSpace(Assembler* assembler) { assembler->CheckBuffer(); } |
1535 }; | 1565 }; |
1536 } | 1566 } |
1537 } // namespace v8::internal | 1567 } // namespace v8::internal |
1538 | 1568 |
1539 #endif // V8_PPC_ASSEMBLER_PPC_H_ | 1569 #endif // V8_PPC_ASSEMBLER_PPC_H_ |
OLD | NEW |