Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(346)

Side by Side Diff: src/x64/assembler-x64.h

Issue 11416133: Moved buffer handling to AssemblerBase. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Rebased Created 8 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/mips/assembler-mips.cc ('k') | src/x64/assembler-x64.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 538 matching lines...) Expand 10 before | Expand all | Expand 10 after
549 // 549 //
550 // If the provided buffer is NULL, the assembler allocates and grows its own 550 // If the provided buffer is NULL, the assembler allocates and grows its own
551 // buffer, and buffer_size determines the initial buffer size. The buffer is 551 // buffer, and buffer_size determines the initial buffer size. The buffer is
552 // owned by the assembler and deallocated upon destruction of the assembler. 552 // owned by the assembler and deallocated upon destruction of the assembler.
553 // 553 //
554 // If the provided buffer is not NULL, the assembler uses the provided buffer 554 // If the provided buffer is not NULL, the assembler uses the provided buffer
555 // for code generation and assumes its size to be buffer_size. If the buffer 555 // for code generation and assumes its size to be buffer_size. If the buffer
556 // is too small, a fatal error occurs. No deallocation of the buffer is done 556 // is too small, a fatal error occurs. No deallocation of the buffer is done
557 // upon destruction of the assembler. 557 // upon destruction of the assembler.
558 Assembler(Isolate* isolate, void* buffer, int buffer_size); 558 Assembler(Isolate* isolate, void* buffer, int buffer_size);
559 ~Assembler(); 559 virtual ~Assembler() { }
560 560
561 // GetCode emits any pending (non-emitted) code and fills the descriptor 561 // GetCode emits any pending (non-emitted) code and fills the descriptor
562 // desc. GetCode() is idempotent; it returns the same result if no other 562 // desc. GetCode() is idempotent; it returns the same result if no other
563 // Assembler functions are invoked in between GetCode() calls. 563 // Assembler functions are invoked in between GetCode() calls.
564 void GetCode(CodeDesc* desc); 564 void GetCode(CodeDesc* desc);
565 565
566 // Read/Modify the code target in the relative branch/call instruction at pc. 566 // Read/Modify the code target in the relative branch/call instruction at pc.
567 // On the x64 architecture, we use relative jumps with a 32-bit displacement 567 // On the x64 architecture, we use relative jumps with a 32-bit displacement
568 // to jump to other Code objects in the Code space in the heap. 568 // to jump to other Code objects in the Code space in the heap.
569 // Jumps to C functions are done indirectly through a 64-bit register holding 569 // Jumps to C functions are done indirectly through a 64-bit register holding
(...skipping 839 matching lines...) Expand 10 before | Expand all | Expand 10 after
1409 1409
1410 // Record a comment relocation entry that can be used by a disassembler. 1410 // Record a comment relocation entry that can be used by a disassembler.
1411 // Use --code-comments to enable. 1411 // Use --code-comments to enable.
1412 void RecordComment(const char* msg, bool force = false); 1412 void RecordComment(const char* msg, bool force = false);
1413 1413
1414 // Writes a single word of data in the code stream. 1414 // Writes a single word of data in the code stream.
1415 // Used for inline tables, e.g., jump-tables. 1415 // Used for inline tables, e.g., jump-tables.
1416 void db(uint8_t data); 1416 void db(uint8_t data);
1417 void dd(uint32_t data); 1417 void dd(uint32_t data);
1418 1418
1419 int pc_offset() const { return static_cast<int>(pc_ - buffer_); }
1420
1421 PositionsRecorder* positions_recorder() { return &positions_recorder_; } 1419 PositionsRecorder* positions_recorder() { return &positions_recorder_; }
1422 1420
1423 // Check if there is less than kGap bytes available in the buffer. 1421 // Check if there is less than kGap bytes available in the buffer.
1424 // If this is the case, we need to grow the buffer before emitting 1422 // If this is the case, we need to grow the buffer before emitting
1425 // an instruction or relocation information. 1423 // an instruction or relocation information.
1426 inline bool buffer_overflow() const { 1424 inline bool buffer_overflow() const {
1427 return pc_ >= reloc_info_writer.pos() - kGap; 1425 return pc_ >= reloc_info_writer.pos() - kGap;
1428 } 1426 }
1429 1427
1430 // Get the number of bytes available in the buffer. 1428 // Get the number of bytes available in the buffer.
1431 inline int available_space() const { 1429 inline int available_space() const {
1432 return static_cast<int>(reloc_info_writer.pos() - pc_); 1430 return static_cast<int>(reloc_info_writer.pos() - pc_);
1433 } 1431 }
1434 1432
1435 static bool IsNop(Address addr); 1433 static bool IsNop(Address addr);
1436 1434
1437 // Avoid overflows for displacements etc. 1435 // Avoid overflows for displacements etc.
1438 static const int kMaximalBufferSize = 512*MB; 1436 static const int kMaximalBufferSize = 512*MB;
1439 static const int kMinimalBufferSize = 4*KB;
1440 1437
1441 byte byte_at(int pos) { return buffer_[pos]; } 1438 byte byte_at(int pos) { return buffer_[pos]; }
1442 void set_byte_at(int pos, byte value) { buffer_[pos] = value; } 1439 void set_byte_at(int pos, byte value) { buffer_[pos] = value; }
1443 1440
1444 private: 1441 private:
1445 byte* addr_at(int pos) { return buffer_ + pos; } 1442 byte* addr_at(int pos) { return buffer_ + pos; }
1446 uint32_t long_at(int pos) { 1443 uint32_t long_at(int pos) {
1447 return *reinterpret_cast<uint32_t*>(addr_at(pos)); 1444 return *reinterpret_cast<uint32_t*>(addr_at(pos));
1448 } 1445 }
1449 void long_at_put(int pos, uint32_t x) { 1446 void long_at_put(int pos, uint32_t x) {
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after
1621 // void print(Label* L); 1618 // void print(Label* L);
1622 void bind_to(Label* L, int pos); 1619 void bind_to(Label* L, int pos);
1623 1620
1624 // record reloc info for current pc_ 1621 // record reloc info for current pc_
1625 void RecordRelocInfo(RelocInfo::Mode rmode, intptr_t data = 0); 1622 void RecordRelocInfo(RelocInfo::Mode rmode, intptr_t data = 0);
1626 1623
1627 friend class CodePatcher; 1624 friend class CodePatcher;
1628 friend class EnsureSpace; 1625 friend class EnsureSpace;
1629 friend class RegExpMacroAssemblerX64; 1626 friend class RegExpMacroAssemblerX64;
1630 1627
1631 // Code buffer:
1632 // The buffer into which code and relocation info are generated.
1633 byte* buffer_;
1634 int buffer_size_;
1635 // True if the assembler owns the buffer, false if buffer is external.
1636 bool own_buffer_;
1637
1638 // code generation 1628 // code generation
1639 byte* pc_; // the program counter; moves forward
1640 RelocInfoWriter reloc_info_writer; 1629 RelocInfoWriter reloc_info_writer;
1641 1630
1642 List< Handle<Code> > code_targets_; 1631 List< Handle<Code> > code_targets_;
1643 1632
1644 PositionsRecorder positions_recorder_; 1633 PositionsRecorder positions_recorder_;
1645 friend class PositionsRecorder; 1634 friend class PositionsRecorder;
1646 }; 1635 };
1647 1636
1648 1637
1649 // Helper class that ensures that there is enough space for generating 1638 // Helper class that ensures that there is enough space for generating
(...skipping 19 matching lines...) Expand all
1669 private: 1658 private:
1670 Assembler* assembler_; 1659 Assembler* assembler_;
1671 #ifdef DEBUG 1660 #ifdef DEBUG
1672 int space_before_; 1661 int space_before_;
1673 #endif 1662 #endif
1674 }; 1663 };
1675 1664
1676 } } // namespace v8::internal 1665 } } // namespace v8::internal
1677 1666
1678 #endif // V8_X64_ASSEMBLER_X64_H_ 1667 #endif // V8_X64_ASSEMBLER_X64_H_
OLDNEW
« no previous file with comments | « src/mips/assembler-mips.cc ('k') | src/x64/assembler-x64.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698