75
76 // This class represents a stream of code and associated relocations.
77 // There are a few in each CodeBuffer.
78 // They are filled concurrently, and concatenated at the end.
79 class CodeSection VALUE_OBJ_CLASS_SPEC {
80 friend class CodeBuffer;
81 public:
82 typedef int csize_t; // code size type; would be size_t except for history
83
84 private:
85 address _start; // first byte of contents (instructions)
86 address _mark; // user mark, usually an instruction beginning
87 address _end; // current end address
88 address _limit; // last possible (allocated) end address
89 relocInfo* _locs_start; // first byte of relocation information
90 relocInfo* _locs_end; // first byte after relocation information
91 relocInfo* _locs_limit; // first byte after relocation information buf
92 address _locs_point; // last relocated position (grows upward)
93 bool _locs_own; // did I allocate the locs myself?
94 bool _frozen; // no more expansion of this section
95 char _index; // my section number (SECT_INST, etc.)
96 CodeBuffer* _outer; // enclosing CodeBuffer
97
98 // (Note: _locs_point used to be called _last_reloc_offset.)
99
100 CodeSection() {
101 _start = NULL;
102 _mark = NULL;
103 _end = NULL;
104 _limit = NULL;
105 _locs_start = NULL;
106 _locs_end = NULL;
107 _locs_limit = NULL;
108 _locs_point = NULL;
109 _locs_own = false;
110 _frozen = false;
111 debug_only(_index = (char)-1);
112 debug_only(_outer = (CodeBuffer*)badAddress);
113 }
114
115 void initialize_outer(CodeBuffer* outer, int index) {
116 _outer = outer;
117 _index = index;
118 }
119
120 void initialize(address start, csize_t size = 0) {
121 assert(_start == NULL, "only one init step, please");
122 _start = start;
123 _mark = NULL;
124 _end = start;
125
126 _limit = start + size;
127 _locs_point = start;
128 }
129
130 void initialize_locs(int locs_capacity);
148 csize_t size() const { return (csize_t)(_end - _start); }
149 csize_t mark_off() const { assert(_mark != NULL, "not an offset");
150 return (csize_t)(_mark - _start); }
151 csize_t capacity() const { return (csize_t)(_limit - _start); }
152 csize_t remaining() const { return (csize_t)(_limit - _end); }
153
154 relocInfo* locs_start() const { return _locs_start; }
155 relocInfo* locs_end() const { return _locs_end; }
156 int locs_count() const { return (int)(_locs_end - _locs_start); }
157 relocInfo* locs_limit() const { return _locs_limit; }
158 address locs_point() const { return _locs_point; }
159 csize_t locs_point_off() const{ return (csize_t)(_locs_point - _start); }
160 csize_t locs_capacity() const { return (csize_t)(_locs_limit - _locs_start); }
161 csize_t locs_remaining()const { return (csize_t)(_locs_limit - _locs_end); }
162
163 int index() const { return _index; }
164 bool is_allocated() const { return _start != NULL; }
165 bool is_empty() const { return _start == _end; }
166 bool is_frozen() const { return _frozen; }
167 bool has_locs() const { return _locs_end != NULL; }
168
169 CodeBuffer* outer() const { return _outer; }
170
171 // is a given address in this section? (2nd version is end-inclusive)
172 bool contains(address pc) const { return pc >= _start && pc < _end; }
173 bool contains2(address pc) const { return pc >= _start && pc <= _end; }
174 bool allocates(address pc) const { return pc >= _start && pc < _limit; }
175 bool allocates2(address pc) const { return pc >= _start && pc <= _limit; }
176
177 void set_end(address pc) { assert(allocates2(pc), "not in CodeBuffer memory: " INTPTR_FORMAT " <= " INTPTR_FORMAT " <= " INTPTR_FORMAT, p2i(_start), p2i(pc), p2i(_limit)); _end = pc; }
178 void set_mark(address pc) { assert(contains2(pc), "not in codeBuffer");
179 _mark = pc; }
180 void set_mark_off(int offset) { assert(contains2(offset+_start),"not in codeBuffer");
181 _mark = offset + _start; }
182 void set_mark() { _mark = _end; }
183 void clear_mark() { _mark = NULL; }
184
185 void set_locs_end(relocInfo* p) {
186 assert(p <= locs_limit(), "locs data fits in allocated buffer");
187 _locs_end = p;
|
75
76 // This class represents a stream of code and associated relocations.
77 // There are a few in each CodeBuffer.
78 // They are filled concurrently, and concatenated at the end.
79 class CodeSection VALUE_OBJ_CLASS_SPEC {
80 friend class CodeBuffer;
81 public:
82 typedef int csize_t; // code size type; would be size_t except for history
83
84 private:
85 address _start; // first byte of contents (instructions)
86 address _mark; // user mark, usually an instruction beginning
87 address _end; // current end address
88 address _limit; // last possible (allocated) end address
89 relocInfo* _locs_start; // first byte of relocation information
90 relocInfo* _locs_end; // first byte after relocation information
91 relocInfo* _locs_limit; // first byte after relocation information buf
92 address _locs_point; // last relocated position (grows upward)
93 bool _locs_own; // did I allocate the locs myself?
94 bool _frozen; // no more expansion of this section
95 bool _scratch_emit; // Buffer is used for scratch emit, don't relocate.
96 char _index; // my section number (SECT_INST, etc.)
97 CodeBuffer* _outer; // enclosing CodeBuffer
98
99 // (Note: _locs_point used to be called _last_reloc_offset.)
100
101 CodeSection() {
102 _start = NULL;
103 _mark = NULL;
104 _end = NULL;
105 _limit = NULL;
106 _locs_start = NULL;
107 _locs_end = NULL;
108 _locs_limit = NULL;
109 _locs_point = NULL;
110 _locs_own = false;
111 _frozen = false;
112 _scratch_emit = false;
113 debug_only(_index = (char)-1);
114 debug_only(_outer = (CodeBuffer*)badAddress);
115 }
116
117 void initialize_outer(CodeBuffer* outer, int index) {
118 _outer = outer;
119 _index = index;
120 }
121
122 void initialize(address start, csize_t size = 0) {
123 assert(_start == NULL, "only one init step, please");
124 _start = start;
125 _mark = NULL;
126 _end = start;
127
128 _limit = start + size;
129 _locs_point = start;
130 }
131
132 void initialize_locs(int locs_capacity);
150 csize_t size() const { return (csize_t)(_end - _start); }
151 csize_t mark_off() const { assert(_mark != NULL, "not an offset");
152 return (csize_t)(_mark - _start); }
153 csize_t capacity() const { return (csize_t)(_limit - _start); }
154 csize_t remaining() const { return (csize_t)(_limit - _end); }
155
156 relocInfo* locs_start() const { return _locs_start; }
157 relocInfo* locs_end() const { return _locs_end; }
158 int locs_count() const { return (int)(_locs_end - _locs_start); }
159 relocInfo* locs_limit() const { return _locs_limit; }
160 address locs_point() const { return _locs_point; }
161 csize_t locs_point_off() const{ return (csize_t)(_locs_point - _start); }
162 csize_t locs_capacity() const { return (csize_t)(_locs_limit - _locs_start); }
163 csize_t locs_remaining()const { return (csize_t)(_locs_limit - _locs_end); }
164
165 int index() const { return _index; }
166 bool is_allocated() const { return _start != NULL; }
167 bool is_empty() const { return _start == _end; }
168 bool is_frozen() const { return _frozen; }
169 bool has_locs() const { return _locs_end != NULL; }
170
171 // Mark scratch buffer.
172 void set_scratch_emit() { _scratch_emit = true; }
173 bool scratch_emit() { return _scratch_emit; }
174
175 CodeBuffer* outer() const { return _outer; }
176
177 // is a given address in this section? (2nd version is end-inclusive)
178 bool contains(address pc) const { return pc >= _start && pc < _end; }
179 bool contains2(address pc) const { return pc >= _start && pc <= _end; }
180 bool allocates(address pc) const { return pc >= _start && pc < _limit; }
181 bool allocates2(address pc) const { return pc >= _start && pc <= _limit; }
182
183 void set_end(address pc) { assert(allocates2(pc), "not in CodeBuffer memory: " INTPTR_FORMAT " <= " INTPTR_FORMAT " <= " INTPTR_FORMAT, p2i(_start), p2i(pc), p2i(_limit)); _end = pc; }
184 void set_mark(address pc) { assert(contains2(pc), "not in codeBuffer");
185 _mark = pc; }
186 void set_mark_off(int offset) { assert(contains2(offset+_start),"not in codeBuffer");
187 _mark = offset + _start; }
188 void set_mark() { _mark = _end; }
189 void clear_mark() { _mark = NULL; }
190
191 void set_locs_end(relocInfo* p) {
192 assert(p <= locs_limit(), "locs data fits in allocated buffer");
193 _locs_end = p;
|