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

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

Issue 11312165: Refactoring: Make emit_debug_code flag handling architecture-independent. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 8 years, 1 month 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 540 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 ~Assembler();
560 560
561 // Overrides the default provided by FLAG_debug_code.
562 void set_emit_debug_code(bool value) { emit_debug_code_ = value; }
563
564 // GetCode emits any pending (non-emitted) code and fills the descriptor 561 // GetCode emits any pending (non-emitted) code and fills the descriptor
565 // 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
566 // Assembler functions are invoked in between GetCode() calls. 563 // Assembler functions are invoked in between GetCode() calls.
567 void GetCode(CodeDesc* desc); 564 void GetCode(CodeDesc* desc);
568 565
569 // 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.
570 // 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
571 // 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.
572 // 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
573 // the absolute address of the target. 570 // the absolute address of the target.
(...skipping 863 matching lines...) Expand 10 before | Expand all | Expand 10 after
1437 1434
1438 static bool IsNop(Address addr); 1435 static bool IsNop(Address addr);
1439 1436
1440 // Avoid overflows for displacements etc. 1437 // Avoid overflows for displacements etc.
1441 static const int kMaximalBufferSize = 512*MB; 1438 static const int kMaximalBufferSize = 512*MB;
1442 static const int kMinimalBufferSize = 4*KB; 1439 static const int kMinimalBufferSize = 4*KB;
1443 1440
1444 byte byte_at(int pos) { return buffer_[pos]; } 1441 byte byte_at(int pos) { return buffer_[pos]; }
1445 void set_byte_at(int pos, byte value) { buffer_[pos] = value; } 1442 void set_byte_at(int pos, byte value) { buffer_[pos] = value; }
1446 1443
1447 protected:
1448 bool emit_debug_code() const { return emit_debug_code_; }
1449
1450 private: 1444 private:
1451 byte* addr_at(int pos) { return buffer_ + pos; } 1445 byte* addr_at(int pos) { return buffer_ + pos; }
1452 uint32_t long_at(int pos) { 1446 uint32_t long_at(int pos) {
1453 return *reinterpret_cast<uint32_t*>(addr_at(pos)); 1447 return *reinterpret_cast<uint32_t*>(addr_at(pos));
1454 } 1448 }
1455 void long_at_put(int pos, uint32_t x) { 1449 void long_at_put(int pos, uint32_t x) {
1456 *reinterpret_cast<uint32_t*>(addr_at(pos)) = x; 1450 *reinterpret_cast<uint32_t*>(addr_at(pos)) = x;
1457 } 1451 }
1458 1452
1459 // code emission 1453 // code emission
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after
1641 // True if the assembler owns the buffer, false if buffer is external. 1635 // True if the assembler owns the buffer, false if buffer is external.
1642 bool own_buffer_; 1636 bool own_buffer_;
1643 1637
1644 // code generation 1638 // code generation
1645 byte* pc_; // the program counter; moves forward 1639 byte* pc_; // the program counter; moves forward
1646 RelocInfoWriter reloc_info_writer; 1640 RelocInfoWriter reloc_info_writer;
1647 1641
1648 List< Handle<Code> > code_targets_; 1642 List< Handle<Code> > code_targets_;
1649 1643
1650 PositionsRecorder positions_recorder_; 1644 PositionsRecorder positions_recorder_;
1651
1652 bool emit_debug_code_;
1653
1654 friend class PositionsRecorder; 1645 friend class PositionsRecorder;
1655 }; 1646 };
1656 1647
1657 1648
1658 // Helper class that ensures that there is enough space for generating 1649 // Helper class that ensures that there is enough space for generating
1659 // instructions and relocation information. The constructor makes 1650 // instructions and relocation information. The constructor makes
1660 // sure that there is enough space and (in debug mode) the destructor 1651 // sure that there is enough space and (in debug mode) the destructor
1661 // checks that we did not generate too much. 1652 // checks that we did not generate too much.
1662 class EnsureSpace BASE_EMBEDDED { 1653 class EnsureSpace BASE_EMBEDDED {
1663 public: 1654 public:
(...skipping 14 matching lines...) Expand all
1678 private: 1669 private:
1679 Assembler* assembler_; 1670 Assembler* assembler_;
1680 #ifdef DEBUG 1671 #ifdef DEBUG
1681 int space_before_; 1672 int space_before_;
1682 #endif 1673 #endif
1683 }; 1674 };
1684 1675
1685 } } // namespace v8::internal 1676 } } // namespace v8::internal
1686 1677
1687 #endif // V8_X64_ASSEMBLER_X64_H_ 1678 #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