145 public final void emitString0(String x) {
146 codeBuffer.emitBytes(x.getBytes(), 0, x.length());
147 }
148
149 public void emitString(String s, int pos) {
150 codeBuffer.emitBytes(s.getBytes(), pos);
151 }
152
153 /**
154 * Closes this assembler. No extra data can be written to this assembler after this call.
155 *
156 * @param trimmedCopy if {@code true}, then a copy of the underlying byte array up to (but not
157 * including) {@code position()} is returned
158 * @return the data in this buffer or a trimmed copy if {@code trimmedCopy} is {@code true}
159 */
160 public byte[] close(boolean trimmedCopy) {
161 checkAndClearLabelsWithPatches();
162 return codeBuffer.close(trimmedCopy);
163 }
164
165 private void checkAndClearLabelsWithPatches() throws InternalError {
166 Label label = labelsWithPatches;
167 while (label != null) {
168 if (label.patchPositions != null) {
169 throw new GraalError("Label used by instructions at following offsets has not been bound: %s", label.patchPositions);
170 }
171 Label next = label.nextWithPatches;
172 label.nextWithPatches = null;
173 label = next;
174 }
175 labelsWithPatches = null;
176 }
177
178 public void bind(Label l) {
179 assert !l.isBound() : "can bind label only once";
180 l.bind(position(), this);
181 }
182
183 public abstract void align(int modulus);
184
|
145 public final void emitString0(String x) {
146 codeBuffer.emitBytes(x.getBytes(), 0, x.length());
147 }
148
149 public void emitString(String s, int pos) {
150 codeBuffer.emitBytes(s.getBytes(), pos);
151 }
152
153 /**
154 * Closes this assembler. No extra data can be written to this assembler after this call.
155 *
156 * @param trimmedCopy if {@code true}, then a copy of the underlying byte array up to (but not
157 * including) {@code position()} is returned
158 * @return the data in this buffer or a trimmed copy if {@code trimmedCopy} is {@code true}
159 */
160 public byte[] close(boolean trimmedCopy) {
161 checkAndClearLabelsWithPatches();
162 return codeBuffer.close(trimmedCopy);
163 }
164
165 public byte[] copy(int start, int end) {
166 return codeBuffer.copyData(start, end);
167 }
168
169 private void checkAndClearLabelsWithPatches() throws InternalError {
170 Label label = labelsWithPatches;
171 while (label != null) {
172 if (label.patchPositions != null) {
173 throw new GraalError("Label used by instructions at following offsets has not been bound: %s", label.patchPositions);
174 }
175 Label next = label.nextWithPatches;
176 label.nextWithPatches = null;
177 label = next;
178 }
179 labelsWithPatches = null;
180 }
181
182 public void bind(Label l) {
183 assert !l.isBound() : "can bind label only once";
184 l.bind(position(), this);
185 }
186
187 public abstract void align(int modulus);
188
|