| 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 379 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 390 // for a detailed comment on the layout (globals.h). | 390 // for a detailed comment on the layout (globals.h). |
| 391 // | 391 // |
| 392 // If the provided buffer is NULL, the assembler allocates and grows its own | 392 // If the provided buffer is NULL, the assembler allocates and grows its own |
| 393 // buffer, and buffer_size determines the initial buffer size. The buffer is | 393 // buffer, and buffer_size determines the initial buffer size. The buffer is |
| 394 // owned by the assembler and deallocated upon destruction of the assembler. | 394 // owned by the assembler and deallocated upon destruction of the assembler. |
| 395 // | 395 // |
| 396 // If the provided buffer is not NULL, the assembler uses the provided buffer | 396 // If the provided buffer is not NULL, the assembler uses the provided buffer |
| 397 // for code generation and assumes its size to be buffer_size. If the buffer | 397 // for code generation and assumes its size to be buffer_size. If the buffer |
| 398 // is too small, a fatal error occurs. No deallocation of the buffer is done | 398 // is too small, a fatal error occurs. No deallocation of the buffer is done |
| 399 // upon destruction of the assembler. | 399 // upon destruction of the assembler. |
| 400 Assembler(Isolate* isolate, void* buffer, int buffer_size); | 400 Assembler(Isolate* isolate, void* buffer, int buffer_size) |
| 401 : Assembler(IsolateData(isolate), buffer, buffer_size) {} |
| 402 Assembler(IsolateData isolate_data, void* buffer, int buffer_size); |
| 401 virtual ~Assembler() {} | 403 virtual ~Assembler() {} |
| 402 | 404 |
| 403 // GetCode emits any pending (non-emitted) code and fills the descriptor | 405 // GetCode emits any pending (non-emitted) code and fills the descriptor |
| 404 // desc. GetCode() is idempotent; it returns the same result if no other | 406 // desc. GetCode() is idempotent; it returns the same result if no other |
| 405 // Assembler functions are invoked in between GetCode() calls. | 407 // Assembler functions are invoked in between GetCode() calls. |
| 406 void GetCode(CodeDesc* desc); | 408 void GetCode(CodeDesc* desc); |
| 407 | 409 |
| 408 // Label operations & relative jumps (PPUM Appendix D) | 410 // Label operations & relative jumps (PPUM Appendix D) |
| 409 // | 411 // |
| 410 // Takes a branch opcode (cc) and a label (L) and generates | 412 // Takes a branch opcode (cc) and a label (L) and generates |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 455 int pc_offset, int offset, ConstantPoolEntry::Access access, | 457 int pc_offset, int offset, ConstantPoolEntry::Access access, |
| 456 ConstantPoolEntry::Type type)); | 458 ConstantPoolEntry::Type type)); |
| 457 | 459 |
| 458 // Return the address in the constant pool of the code target address used by | 460 // Return the address in the constant pool of the code target address used by |
| 459 // the branch/call instruction at pc, or the object in a mov. | 461 // the branch/call instruction at pc, or the object in a mov. |
| 460 INLINE(static Address target_constant_pool_address_at( | 462 INLINE(static Address target_constant_pool_address_at( |
| 461 Address pc, Address constant_pool, ConstantPoolEntry::Access access, | 463 Address pc, Address constant_pool, ConstantPoolEntry::Access access, |
| 462 ConstantPoolEntry::Type type)); | 464 ConstantPoolEntry::Type type)); |
| 463 | 465 |
| 464 // Read/Modify the code target address in the branch/call instruction at pc. | 466 // Read/Modify the code target address in the branch/call instruction at pc. |
| 467 // The isolate argument is unused (and may be nullptr) when skipping flushing. |
| 465 INLINE(static Address target_address_at(Address pc, Address constant_pool)); | 468 INLINE(static Address target_address_at(Address pc, Address constant_pool)); |
| 466 INLINE(static void set_target_address_at( | 469 INLINE(static void set_target_address_at( |
| 467 Isolate* isolate, Address pc, Address constant_pool, Address target, | 470 Isolate* isolate, Address pc, Address constant_pool, Address target, |
| 468 ICacheFlushMode icache_flush_mode = FLUSH_ICACHE_IF_NEEDED)); | 471 ICacheFlushMode icache_flush_mode = FLUSH_ICACHE_IF_NEEDED)); |
| 469 INLINE(static Address target_address_at(Address pc, Code* code)); | 472 INLINE(static Address target_address_at(Address pc, Code* code)); |
| 470 INLINE(static void set_target_address_at( | 473 INLINE(static void set_target_address_at( |
| 471 Isolate* isolate, Address pc, Code* code, Address target, | 474 Isolate* isolate, Address pc, Code* code, Address target, |
| 472 ICacheFlushMode icache_flush_mode = FLUSH_ICACHE_IF_NEEDED)); | 475 ICacheFlushMode icache_flush_mode = FLUSH_ICACHE_IF_NEEDED)); |
| 473 | 476 |
| 474 // Return the code target address at a call site from the return address | 477 // Return the code target address at a call site from the return address |
| (...skipping 887 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1362 constant_pool_entry_sharing_blocked_nesting_--; | 1365 constant_pool_entry_sharing_blocked_nesting_--; |
| 1363 } | 1366 } |
| 1364 bool is_constant_pool_entry_sharing_blocked() const { | 1367 bool is_constant_pool_entry_sharing_blocked() const { |
| 1365 return constant_pool_entry_sharing_blocked_nesting_ > 0; | 1368 return constant_pool_entry_sharing_blocked_nesting_ > 0; |
| 1366 } | 1369 } |
| 1367 | 1370 |
| 1368 bool has_exception() const { return internal_trampoline_exception_; } | 1371 bool has_exception() const { return internal_trampoline_exception_; } |
| 1369 | 1372 |
| 1370 bool is_trampoline_emitted() const { return trampoline_emitted_; } | 1373 bool is_trampoline_emitted() const { return trampoline_emitted_; } |
| 1371 | 1374 |
| 1372 private: | |
| 1373 // Code generation | 1375 // Code generation |
| 1374 // The relocation writer's position is at least kGap bytes below the end of | 1376 // The relocation writer's position is at least kGap bytes below the end of |
| 1375 // the generated instructions. This is so that multi-instruction sequences do | 1377 // the generated instructions. This is so that multi-instruction sequences do |
| 1376 // not have to check for overflow. The same is true for writes of large | 1378 // not have to check for overflow. The same is true for writes of large |
| 1377 // relocation info entries. | 1379 // relocation info entries. |
| 1378 static constexpr int kGap = 32; | 1380 static constexpr int kGap = 32; |
| 1379 | 1381 |
| 1382 RelocInfoWriter reloc_info_writer; |
| 1383 |
| 1384 private: |
| 1380 // Repeated checking whether the trampoline pool should be emitted is rather | 1385 // Repeated checking whether the trampoline pool should be emitted is rather |
| 1381 // expensive. By default we only check again once a number of instructions | 1386 // expensive. By default we only check again once a number of instructions |
| 1382 // has been generated. | 1387 // has been generated. |
| 1383 int next_trampoline_check_; // pc offset of next buffer check. | 1388 int next_trampoline_check_; // pc offset of next buffer check. |
| 1384 | 1389 |
| 1385 // Emission of the trampoline pool may be blocked in some code sequences. | 1390 // Emission of the trampoline pool may be blocked in some code sequences. |
| 1386 int trampoline_pool_blocked_nesting_; // Block emission if this is not zero. | 1391 int trampoline_pool_blocked_nesting_; // Block emission if this is not zero. |
| 1387 int no_trampoline_pool_before_; // Block emission before this pc offset. | 1392 int no_trampoline_pool_before_; // Block emission before this pc offset. |
| 1388 | 1393 |
| 1389 // Do not share constant pool entries. | 1394 // Do not share constant pool entries. |
| 1390 int constant_pool_entry_sharing_blocked_nesting_; | 1395 int constant_pool_entry_sharing_blocked_nesting_; |
| 1391 | 1396 |
| 1392 // Relocation info generation | 1397 // Relocation info generation |
| 1393 // Each relocation is encoded as a variable size value | 1398 // Each relocation is encoded as a variable size value |
| 1394 static constexpr int kMaxRelocSize = RelocInfoWriter::kMaxSize; | 1399 static constexpr int kMaxRelocSize = RelocInfoWriter::kMaxSize; |
| 1395 RelocInfoWriter reloc_info_writer; | |
| 1396 std::vector<DeferredRelocInfo> relocations_; | 1400 std::vector<DeferredRelocInfo> relocations_; |
| 1397 | 1401 |
| 1398 // The bound position, before this we cannot do instruction elimination. | 1402 // The bound position, before this we cannot do instruction elimination. |
| 1399 int last_bound_pos_; | 1403 int last_bound_pos_; |
| 1400 // Optimizable cmpi information. | 1404 // Optimizable cmpi information. |
| 1401 int optimizable_cmpi_pos_; | 1405 int optimizable_cmpi_pos_; |
| 1402 CRegister cmpi_cr_; | 1406 CRegister cmpi_cr_; |
| 1403 | 1407 |
| 1404 ConstantPoolBuilder constant_pool_builder_; | 1408 ConstantPoolBuilder constant_pool_builder_; |
| 1405 | 1409 |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1482 friend class CodePatcher; | 1486 friend class CodePatcher; |
| 1483 friend class BlockTrampolinePoolScope; | 1487 friend class BlockTrampolinePoolScope; |
| 1484 friend class EnsureSpace; | 1488 friend class EnsureSpace; |
| 1485 }; | 1489 }; |
| 1486 | 1490 |
| 1487 | 1491 |
| 1488 class EnsureSpace BASE_EMBEDDED { | 1492 class EnsureSpace BASE_EMBEDDED { |
| 1489 public: | 1493 public: |
| 1490 explicit EnsureSpace(Assembler* assembler) { assembler->CheckBuffer(); } | 1494 explicit EnsureSpace(Assembler* assembler) { assembler->CheckBuffer(); } |
| 1491 }; | 1495 }; |
| 1496 |
| 1497 class PatchingAssembler : public Assembler { |
| 1498 public: |
| 1499 PatchingAssembler(IsolateData isolate_data, byte* address, int instructions); |
| 1500 ~PatchingAssembler(); |
| 1501 |
| 1502 void FlushICache(Isolate* isolate); |
| 1503 }; |
| 1504 |
| 1492 } // namespace internal | 1505 } // namespace internal |
| 1493 } // namespace v8 | 1506 } // namespace v8 |
| 1494 | 1507 |
| 1495 #endif // V8_PPC_ASSEMBLER_PPC_H_ | 1508 #endif // V8_PPC_ASSEMBLER_PPC_H_ |
| OLD | NEW |