1/*
2 * Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation.
8 *
9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 */
23package org.graalvm.compiler.hotspot.word;
24
25import static org.graalvm.compiler.hotspot.word.HotSpotOperation.HotspotOpcode.FROM_POINTER;
26import static org.graalvm.compiler.hotspot.word.HotSpotOperation.HotspotOpcode.IS_NULL;
27
28import org.graalvm.compiler.nodes.memory.HeapAccess.BarrierType;
29import org.graalvm.compiler.word.Word;
30import org.graalvm.compiler.word.Word.Opcode;
31import org.graalvm.compiler.word.Word.Operation;
32import org.graalvm.word.LocationIdentity;
33import org.graalvm.word.Pointer;
34import org.graalvm.word.SignedWord;
35import org.graalvm.word.UnsignedWord;
36import org.graalvm.word.WordBase;
37
38/**
39 * Marker type for a metaspace pointer.
40 */
41public abstract class MetaspacePointer {
42
43    @HotSpotOperation(opcode = IS_NULL)
44    public abstract boolean isNull();
45
46    @HotSpotOperation(opcode = FROM_POINTER)
47    public abstract Pointer asWord();
48
49    /**
50     * Reads the memory at address {@code (this + offset)}. Both the base address and offset are in
51     * bytes.
52     * <p>
53     * The offset is always treated as a {@link SignedWord} value. However, the static type is
54     * {@link WordBase} to avoid the frequent casts of {@link UnsignedWord} values (where the caller
55     * knows that the highest-order bit of the unsigned value is never used).
56     *
57     * @param offset the signed offset for the memory access
58     * @param locationIdentity the identity of the read
59     * @return the result of the memory access
60     */
61    @Operation(opcode = Opcode.READ_POINTER)
62    public abstract byte readByte(WordBase offset, LocationIdentity locationIdentity);
63
64    /**
65     * Reads the memory at address {@code (this + offset)}. Both the base address and offset are in
66     * bytes.
67     * <p>
68     * The offset is always treated as a {@link SignedWord} value. However, the static type is
69     * {@link WordBase} to avoid the frequent casts of {@link UnsignedWord} values (where the caller
70     * knows that the highest-order bit of the unsigned value is never used).
71     *
72     * @param offset the signed offset for the memory access
73     * @param locationIdentity the identity of the read
74     * @return the result of the memory access
75     */
76    @Operation(opcode = Opcode.READ_POINTER)
77    public abstract char readChar(WordBase offset, LocationIdentity locationIdentity);
78
79    /**
80     * Reads the memory at address {@code (this + offset)}. Both the base address and offset are in
81     * bytes.
82     * <p>
83     * The offset is always treated as a {@link SignedWord} value. However, the static type is
84     * {@link WordBase} to avoid the frequent casts of {@link UnsignedWord} values (where the caller
85     * knows that the highest-order bit of the unsigned value is never used).
86     *
87     * @param offset the signed offset for the memory access
88     * @param locationIdentity the identity of the read
89     * @return the result of the memory access
90     */
91    @Operation(opcode = Opcode.READ_POINTER)
92    public abstract short readShort(WordBase offset, LocationIdentity locationIdentity);
93
94    /**
95     * Reads the memory at address {@code (this + offset)}. Both the base address and offset are in
96     * bytes.
97     * <p>
98     * The offset is always treated as a {@link SignedWord} value. However, the static type is
99     * {@link WordBase} to avoid the frequent casts of {@link UnsignedWord} values (where the caller
100     * knows that the highest-order bit of the unsigned value is never used).
101     *
102     * @param offset the signed offset for the memory access
103     * @param locationIdentity the identity of the read
104     * @return the result of the memory access
105     */
106    @Operation(opcode = Opcode.READ_POINTER)
107    public abstract int readInt(WordBase offset, LocationIdentity locationIdentity);
108
109    /**
110     * Reads the memory at address {@code (this + offset)}. Both the base address and offset are in
111     * bytes.
112     * <p>
113     * The offset is always treated as a {@link SignedWord} value. However, the static type is
114     * {@link WordBase} to avoid the frequent casts of {@link UnsignedWord} values (where the caller
115     * knows that the highest-order bit of the unsigned value is never used).
116     *
117     * @param offset the signed offset for the memory access
118     * @param locationIdentity the identity of the read
119     * @return the result of the memory access
120     */
121    @Operation(opcode = Opcode.READ_POINTER)
122    public abstract long readLong(WordBase offset, LocationIdentity locationIdentity);
123
124    /**
125     * Reads the memory at address {@code (this + offset)}. Both the base address and offset are in
126     * bytes.
127     * <p>
128     * The offset is always treated as a {@link SignedWord} value. However, the static type is
129     * {@link WordBase} to avoid the frequent casts of {@link UnsignedWord} values (where the caller
130     * knows that the highest-order bit of the unsigned value is never used).
131     *
132     * @param offset the signed offset for the memory access
133     * @param locationIdentity the identity of the read
134     * @return the result of the memory access
135     */
136    @Operation(opcode = Opcode.READ_POINTER)
137    public abstract float readFloat(WordBase offset, LocationIdentity locationIdentity);
138
139    /**
140     * Reads the memory at address {@code (this + offset)}. Both the base address and offset are in
141     * bytes.
142     * <p>
143     * The offset is always treated as a {@link SignedWord} value. However, the static type is
144     * {@link WordBase} to avoid the frequent casts of {@link UnsignedWord} values (where the caller
145     * knows that the highest-order bit of the unsigned value is never used).
146     *
147     * @param offset the signed offset for the memory access
148     * @param locationIdentity the identity of the read
149     * @return the result of the memory access
150     */
151    @Operation(opcode = Opcode.READ_POINTER)
152    public abstract double readDouble(WordBase offset, LocationIdentity locationIdentity);
153
154    /**
155     * Reads the memory at address {@code (this + offset)}. Both the base address and offset are in
156     * bytes.
157     * <p>
158     * The offset is always treated as a {@link SignedWord} value. However, the static type is
159     * {@link WordBase} to avoid the frequent casts of {@link UnsignedWord} values (where the caller
160     * knows that the highest-order bit of the unsigned value is never used).
161     *
162     * @param offset the signed offset for the memory access
163     * @param locationIdentity the identity of the read
164     * @return the result of the memory access
165     */
166    @Operation(opcode = Opcode.READ_POINTER)
167    public abstract Word readWord(WordBase offset, LocationIdentity locationIdentity);
168
169    /**
170     * Reads the memory at address {@code (this + offset)}. Both the base address and offset are in
171     * bytes.
172     * <p>
173     * The offset is always treated as a {@link SignedWord} value. However, the static type is
174     * {@link WordBase} to avoid the frequent casts of {@link UnsignedWord} values (where the caller
175     * knows that the highest-order bit of the unsigned value is never used).
176     *
177     * @param offset the signed offset for the memory access
178     * @param locationIdentity the identity of the read
179     * @return the result of the memory access
180     */
181    @Operation(opcode = Opcode.READ_POINTER)
182    public abstract Object readObject(WordBase offset, LocationIdentity locationIdentity);
183
184    /**
185     * Reads the memory at address {@code (this + offset)}. Both the base address and offset are in
186     * bytes.
187     *
188     * @param offset the signed offset for the memory access
189     * @param locationIdentity the identity of the read
190     * @return the result of the memory access
191     */
192    @Operation(opcode = Opcode.READ_POINTER)
193    public abstract byte readByte(int offset, LocationIdentity locationIdentity);
194
195    /**
196     * Reads the memory at address {@code (this + offset)}. Both the base address and offset are in
197     * bytes.
198     *
199     * @param offset the signed offset for the memory access
200     * @param locationIdentity the identity of the read
201     * @return the result of the memory access
202     */
203    @Operation(opcode = Opcode.READ_POINTER)
204    public abstract char readChar(int offset, LocationIdentity locationIdentity);
205
206    /**
207     * Reads the memory at address {@code (this + offset)}. Both the base address and offset are in
208     * bytes.
209     *
210     * @param offset the signed offset for the memory access
211     * @param locationIdentity the identity of the read
212     * @return the result of the memory access
213     */
214    @Operation(opcode = Opcode.READ_POINTER)
215    public abstract short readShort(int offset, LocationIdentity locationIdentity);
216
217    /**
218     * Reads the memory at address {@code (this + offset)}. Both the base address and offset are in
219     * bytes.
220     *
221     * @param offset the signed offset for the memory access
222     * @param locationIdentity the identity of the read
223     * @return the result of the memory access
224     */
225    @Operation(opcode = Opcode.READ_POINTER)
226    public abstract int readInt(int offset, LocationIdentity locationIdentity);
227
228    /**
229     * Reads the memory at address {@code (this + offset)}. Both the base address and offset are in
230     * bytes.
231     *
232     * @param offset the signed offset for the memory access
233     * @param locationIdentity the identity of the read
234     * @return the result of the memory access
235     */
236    @Operation(opcode = Opcode.READ_POINTER)
237    public abstract long readLong(int offset, LocationIdentity locationIdentity);
238
239    /**
240     * Reads the memory at address {@code (this + offset)}. Both the base address and offset are in
241     * bytes.
242     *
243     * @param offset the signed offset for the memory access
244     * @param locationIdentity the identity of the read
245     * @return the result of the memory access
246     */
247    @Operation(opcode = Opcode.READ_POINTER)
248    public abstract float readFloat(int offset, LocationIdentity locationIdentity);
249
250    /**
251     * Reads the memory at address {@code (this + offset)}. Both the base address and offset are in
252     * bytes.
253     *
254     * @param offset the signed offset for the memory access
255     * @param locationIdentity the identity of the read
256     * @return the result of the memory access
257     */
258    @Operation(opcode = Opcode.READ_POINTER)
259    public abstract double readDouble(int offset, LocationIdentity locationIdentity);
260
261    /**
262     * Reads the memory at address {@code (this + offset)}. Both the base address and offset are in
263     * bytes.
264     *
265     * @param offset the signed offset for the memory access
266     * @param locationIdentity the identity of the read
267     * @return the result of the memory access
268     */
269    @Operation(opcode = Opcode.READ_POINTER)
270    public abstract Word readWord(int offset, LocationIdentity locationIdentity);
271
272    /**
273     * Reads the memory at address {@code (this + offset)}. Both the base address and offset are in
274     * bytes.
275     *
276     * @param offset the signed offset for the memory access
277     * @param locationIdentity the identity of the read
278     * @return the result of the memory access
279     */
280    @Operation(opcode = Opcode.READ_POINTER)
281    public abstract Object readObject(int offset, LocationIdentity locationIdentity);
282
283    /**
284     * Writes the memory at address {@code (this + offset)}. Both the base address and offset are in
285     * bytes.
286     * <p>
287     * The offset is always treated as a {@link SignedWord} value. However, the static type is
288     * {@link WordBase} to avoid the frequent casts of {@link UnsignedWord} values (where the caller
289     * knows that the highest-order bit of the unsigned value is never used).
290     *
291     * @param offset the signed offset for the memory access
292     * @param locationIdentity the identity of the write
293     * @param val the value to be written to memory
294     */
295    @Operation(opcode = Opcode.WRITE_POINTER)
296    public abstract void writeByte(WordBase offset, byte val, LocationIdentity locationIdentity);
297
298    /**
299     * Writes the memory at address {@code (this + offset)}. Both the base address and offset are in
300     * bytes.
301     * <p>
302     * The offset is always treated as a {@link SignedWord} value. However, the static type is
303     * {@link WordBase} to avoid the frequent casts of {@link UnsignedWord} values (where the caller
304     * knows that the highest-order bit of the unsigned value is never used).
305     *
306     * @param offset the signed offset for the memory access
307     * @param locationIdentity the identity of the write
308     * @param val the value to be written to memory
309     */
310    @Operation(opcode = Opcode.WRITE_POINTER)
311    public abstract void writeChar(WordBase offset, char val, LocationIdentity locationIdentity);
312
313    /**
314     * Writes the memory at address {@code (this + offset)}. Both the base address and offset are in
315     * bytes.
316     * <p>
317     * The offset is always treated as a {@link SignedWord} value. However, the static type is
318     * {@link WordBase} to avoid the frequent casts of {@link UnsignedWord} values (where the caller
319     * knows that the highest-order bit of the unsigned value is never used).
320     *
321     * @param offset the signed offset for the memory access
322     * @param locationIdentity the identity of the write
323     * @param val the value to be written to memory
324     */
325    @Operation(opcode = Opcode.WRITE_POINTER)
326    public abstract void writeShort(WordBase offset, short val, LocationIdentity locationIdentity);
327
328    /**
329     * Writes the memory at address {@code (this + offset)}. Both the base address and offset are in
330     * bytes.
331     * <p>
332     * The offset is always treated as a {@link SignedWord} value. However, the static type is
333     * {@link WordBase} to avoid the frequent casts of {@link UnsignedWord} values (where the caller
334     * knows that the highest-order bit of the unsigned value is never used).
335     *
336     * @param offset the signed offset for the memory access
337     * @param locationIdentity the identity of the write
338     * @param val the value to be written to memory
339     */
340    @Operation(opcode = Opcode.WRITE_POINTER)
341    public abstract void writeInt(WordBase offset, int val, LocationIdentity locationIdentity);
342
343    /**
344     * Writes the memory at address {@code (this + offset)}. Both the base address and offset are in
345     * bytes.
346     * <p>
347     * The offset is always treated as a {@link SignedWord} value. However, the static type is
348     * {@link WordBase} to avoid the frequent casts of {@link UnsignedWord} values (where the caller
349     * knows that the highest-order bit of the unsigned value is never used).
350     *
351     * @param offset the signed offset for the memory access
352     * @param locationIdentity the identity of the write
353     * @param val the value to be written to memory
354     */
355    @Operation(opcode = Opcode.WRITE_POINTER)
356    public abstract void writeLong(WordBase offset, long val, LocationIdentity locationIdentity);
357
358    /**
359     * Writes the memory at address {@code (this + offset)}. Both the base address and offset are in
360     * bytes.
361     * <p>
362     * The offset is always treated as a {@link SignedWord} value. However, the static type is
363     * {@link WordBase} to avoid the frequent casts of {@link UnsignedWord} values (where the caller
364     * knows that the highest-order bit of the unsigned value is never used).
365     *
366     * @param offset the signed offset for the memory access
367     * @param locationIdentity the identity of the write
368     * @param val the value to be written to memory
369     */
370    @Operation(opcode = Opcode.WRITE_POINTER)
371    public abstract void writeFloat(WordBase offset, float val, LocationIdentity locationIdentity);
372
373    /**
374     * Writes the memory at address {@code (this + offset)}. Both the base address and offset are in
375     * bytes.
376     * <p>
377     * The offset is always treated as a {@link SignedWord} value. However, the static type is
378     * {@link WordBase} to avoid the frequent casts of {@link UnsignedWord} values (where the caller
379     * knows that the highest-order bit of the unsigned value is never used).
380     *
381     * @param offset the signed offset for the memory access
382     * @param locationIdentity the identity of the write
383     * @param val the value to be written to memory
384     */
385    @Operation(opcode = Opcode.WRITE_POINTER)
386    public abstract void writeDouble(WordBase offset, double val, LocationIdentity locationIdentity);
387
388    /**
389     * Writes the memory at address {@code (this + offset)}. Both the base address and offset are in
390     * bytes.
391     * <p>
392     * The offset is always treated as a {@link SignedWord} value. However, the static type is
393     * {@link WordBase} to avoid the frequent casts of {@link UnsignedWord} values (where the caller
394     * knows that the highest-order bit of the unsigned value is never used).
395     *
396     * @param offset the signed offset for the memory access
397     * @param locationIdentity the identity of the write
398     * @param val the value to be written to memory
399     */
400    @Operation(opcode = Opcode.WRITE_POINTER)
401    public abstract void writeWord(WordBase offset, WordBase val, LocationIdentity locationIdentity);
402
403    /**
404     * Initializes the memory at address {@code (this + offset)}. Both the base address and offset
405     * are in bytes. The memory must be uninitialized or zero prior to this operation.
406     * <p>
407     * The offset is always treated as a {@link SignedWord} value. However, the static type is
408     * {@link WordBase} to avoid the frequent casts of {@link UnsignedWord} values (where the caller
409     * knows that the highest-order bit of the unsigned value is never used).
410     *
411     * @param offset the signed offset for the memory access
412     * @param locationIdentity the identity of the write
413     * @param val the value to be written to memory
414     */
415    @Operation(opcode = Opcode.INITIALIZE)
416    public abstract void initializeLong(WordBase offset, long val, LocationIdentity locationIdentity);
417
418    /**
419     * Writes the memory at address {@code (this + offset)}. Both the base address and offset are in
420     * bytes.
421     * <p>
422     * The offset is always treated as a {@link SignedWord} value. However, the static type is
423     * {@link WordBase} to avoid the frequent casts of {@link UnsignedWord} values (where the caller
424     * knows that the highest-order bit of the unsigned value is never used).
425     *
426     * @param offset the signed offset for the memory access
427     * @param locationIdentity the identity of the write
428     * @param val the value to be written to memory
429     */
430    @Operation(opcode = Opcode.WRITE_POINTER)
431    public abstract void writeObject(WordBase offset, Object val, LocationIdentity locationIdentity);
432
433    /**
434     * Writes the memory at address {@code (this + offset)}. Both the base address and offset are in
435     * bytes.
436     *
437     * @param offset the signed offset for the memory access
438     * @param locationIdentity the identity of the write
439     * @param val the value to be written to memory
440     */
441    @Operation(opcode = Opcode.WRITE_POINTER)
442    public abstract void writeByte(int offset, byte val, LocationIdentity locationIdentity);
443
444    /**
445     * Writes the memory at address {@code (this + offset)}. Both the base address and offset are in
446     * bytes.
447     *
448     * @param offset the signed offset for the memory access
449     * @param locationIdentity the identity of the write
450     * @param val the value to be written to memory
451     */
452    @Operation(opcode = Opcode.WRITE_POINTER)
453    public abstract void writeChar(int offset, char val, LocationIdentity locationIdentity);
454
455    /**
456     * Writes the memory at address {@code (this + offset)}. Both the base address and offset are in
457     * bytes.
458     *
459     * @param offset the signed offset for the memory access
460     * @param locationIdentity the identity of the write
461     * @param val the value to be written to memory
462     */
463    @Operation(opcode = Opcode.WRITE_POINTER)
464    public abstract void writeShort(int offset, short val, LocationIdentity locationIdentity);
465
466    /**
467     * Writes the memory at address {@code (this + offset)}. Both the base address and offset are in
468     * bytes.
469     *
470     * @param offset the signed offset for the memory access
471     * @param locationIdentity the identity of the write
472     * @param val the value to be written to memory
473     */
474    @Operation(opcode = Opcode.WRITE_POINTER)
475    public abstract void writeInt(int offset, int val, LocationIdentity locationIdentity);
476
477    /**
478     * Writes the memory at address {@code (this + offset)}. Both the base address and offset are in
479     * bytes.
480     *
481     * @param offset the signed offset for the memory access
482     * @param locationIdentity the identity of the write
483     * @param val the value to be written to memory
484     */
485    @Operation(opcode = Opcode.WRITE_POINTER)
486    public abstract void writeLong(int offset, long val, LocationIdentity locationIdentity);
487
488    /**
489     * Writes the memory at address {@code (this + offset)}. Both the base address and offset are in
490     * bytes.
491     *
492     * @param offset the signed offset for the memory access
493     * @param locationIdentity the identity of the write
494     * @param val the value to be written to memory
495     */
496    @Operation(opcode = Opcode.WRITE_POINTER)
497    public abstract void writeFloat(int offset, float val, LocationIdentity locationIdentity);
498
499    /**
500     * Writes the memory at address {@code (this + offset)}. Both the base address and offset are in
501     * bytes.
502     *
503     * @param offset the signed offset for the memory access
504     * @param locationIdentity the identity of the write
505     * @param val the value to be written to memory
506     */
507    @Operation(opcode = Opcode.WRITE_POINTER)
508    public abstract void writeDouble(int offset, double val, LocationIdentity locationIdentity);
509
510    /**
511     * Writes the memory at address {@code (this + offset)}. Both the base address and offset are in
512     * bytes.
513     *
514     * @param offset the signed offset for the memory access
515     * @param locationIdentity the identity of the write
516     * @param val the value to be written to memory
517     */
518    @Operation(opcode = Opcode.WRITE_POINTER)
519    public abstract void writeWord(int offset, WordBase val, LocationIdentity locationIdentity);
520
521    /**
522     * Writes the memory at address {@code (this + offset)}. Both the base address and offset are in
523     * bytes.
524     *
525     * @param offset the signed offset for the memory access
526     * @param locationIdentity the identity of the write
527     * @param val the value to be written to memory
528     */
529    @Operation(opcode = Opcode.WRITE_POINTER)
530    public abstract void writeObject(int offset, Object val, LocationIdentity locationIdentity);
531
532    /**
533     * Reads the memory at address {@code (this + offset)}. Both the base address and offset are in
534     * bytes.
535     * <p>
536     * The offset is always treated as a {@link SignedWord} value. However, the static type is
537     * {@link WordBase} to avoid the frequent casts of {@link UnsignedWord} values (where the caller
538     * knows that the highest-order bit of the unsigned value is never used).
539     *
540     * @param offset the signed offset for the memory access
541     * @return the result of the memory access
542     */
543    @Operation(opcode = Opcode.READ_POINTER)
544    public abstract byte readByte(WordBase offset);
545
546    /**
547     * Reads the memory at address {@code (this + offset)}. Both the base address and offset are in
548     * bytes.
549     * <p>
550     * The offset is always treated as a {@link SignedWord} value. However, the static type is
551     * {@link WordBase} to avoid the frequent casts of {@link UnsignedWord} values (where the caller
552     * knows that the highest-order bit of the unsigned value is never used).
553     *
554     * @param offset the signed offset for the memory access
555     * @return the result of the memory access
556     */
557    @Operation(opcode = Opcode.READ_POINTER)
558    public abstract char readChar(WordBase offset);
559
560    /**
561     * Reads the memory at address {@code (this + offset)}. Both the base address and offset are in
562     * bytes.
563     * <p>
564     * The offset is always treated as a {@link SignedWord} value. However, the static type is
565     * {@link WordBase} to avoid the frequent casts of {@link UnsignedWord} values (where the caller
566     * knows that the highest-order bit of the unsigned value is never used).
567     *
568     * @param offset the signed offset for the memory access
569     * @return the result of the memory access
570     */
571    @Operation(opcode = Opcode.READ_POINTER)
572    public abstract short readShort(WordBase offset);
573
574    /**
575     * Reads the memory at address {@code (this + offset)}. Both the base address and offset are in
576     * bytes.
577     * <p>
578     * The offset is always treated as a {@link SignedWord} value. However, the static type is
579     * {@link WordBase} to avoid the frequent casts of {@link UnsignedWord} values (where the caller
580     * knows that the highest-order bit of the unsigned value is never used).
581     *
582     * @param offset the signed offset for the memory access
583     * @return the result of the memory access
584     */
585    @Operation(opcode = Opcode.READ_POINTER)
586    public abstract int readInt(WordBase offset);
587
588    /**
589     * Reads the memory at address {@code (this + offset)}. Both the base address and offset are in
590     * bytes.
591     * <p>
592     * The offset is always treated as a {@link SignedWord} value. However, the static type is
593     * {@link WordBase} to avoid the frequent casts of {@link UnsignedWord} values (where the caller
594     * knows that the highest-order bit of the unsigned value is never used).
595     *
596     * @param offset the signed offset for the memory access
597     * @return the result of the memory access
598     */
599    @Operation(opcode = Opcode.READ_POINTER)
600    public abstract long readLong(WordBase offset);
601
602    /**
603     * Reads the memory at address {@code (this + offset)}. Both the base address and offset are in
604     * bytes.
605     * <p>
606     * The offset is always treated as a {@link SignedWord} value. However, the static type is
607     * {@link WordBase} to avoid the frequent casts of {@link UnsignedWord} values (where the caller
608     * knows that the highest-order bit of the unsigned value is never used).
609     *
610     * @param offset the signed offset for the memory access
611     * @return the result of the memory access
612     */
613    @Operation(opcode = Opcode.READ_POINTER)
614    public abstract float readFloat(WordBase offset);
615
616    /**
617     * Reads the memory at address {@code (this + offset)}. Both the base address and offset are in
618     * bytes.
619     * <p>
620     * The offset is always treated as a {@link SignedWord} value. However, the static type is
621     * {@link WordBase} to avoid the frequent casts of {@link UnsignedWord} values (where the caller
622     * knows that the highest-order bit of the unsigned value is never used).
623     *
624     * @param offset the signed offset for the memory access
625     * @return the result of the memory access
626     */
627    @Operation(opcode = Opcode.READ_POINTER)
628    public abstract double readDouble(WordBase offset);
629
630    /**
631     * Reads the memory at address {@code (this + offset)}. Both the base address and offset are in
632     * bytes.
633     * <p>
634     * The offset is always treated as a {@link SignedWord} value. However, the static type is
635     * {@link WordBase} to avoid the frequent casts of {@link UnsignedWord} values (where the caller
636     * knows that the highest-order bit of the unsigned value is never used).
637     *
638     * @param offset the signed offset for the memory access
639     * @return the result of the memory access
640     */
641    @Operation(opcode = Opcode.READ_POINTER)
642    public abstract Word readWord(WordBase offset);
643
644    /**
645     * Reads the memory at address {@code (this + offset)}. Both the base address and offset are in
646     * bytes.
647     * <p>
648     * The offset is always treated as a {@link SignedWord} value. However, the static type is
649     * {@link WordBase} to avoid the frequent casts of {@link UnsignedWord} values (where the caller
650     * knows that the highest-order bit of the unsigned value is never used).
651     *
652     * @param offset the signed offset for the memory access
653     * @return the result of the memory access
654     */
655    @Operation(opcode = Opcode.READ_POINTER)
656    public abstract Object readObject(WordBase offset);
657
658    /**
659     * Reads the memory at address {@code (this + offset)}. This access will decompress the oop if
660     * the VM uses compressed oops, and it can be parameterized to allow read barriers (G1 referent
661     * field).
662     * <p>
663     * The offset is always treated as a {@link SignedWord} value. However, the static type is
664     * {@link WordBase} to avoid the frequent casts of {@link UnsignedWord} values (where the caller
665     * knows that the highest-order bit of the unsigned value is never used).
666     *
667     * @param offset the signed offset for the memory access
668     * @param barrierType the type of the read barrier to be added
669     * @return the result of the memory access
670     */
671    @Operation(opcode = Opcode.READ_POINTER)
672    public abstract Object readObject(WordBase offset, BarrierType barrierType);
673
674    /**
675     * Reads the memory at address {@code (this + offset)}. Both the base address and offset are in
676     * bytes.
677     *
678     * @param offset the signed offset for the memory access
679     * @return the result of the memory access
680     */
681    @Operation(opcode = Opcode.READ_POINTER)
682    public abstract byte readByte(int offset);
683
684    /**
685     * Reads the memory at address {@code (this + offset)}. Both the base address and offset are in
686     * bytes.
687     *
688     * @param offset the signed offset for the memory access
689     * @return the result of the memory access
690     */
691    @Operation(opcode = Opcode.READ_POINTER)
692    public abstract char readChar(int offset);
693
694    /**
695     * Reads the memory at address {@code (this + offset)}. Both the base address and offset are in
696     * bytes.
697     *
698     * @param offset the signed offset for the memory access
699     * @return the result of the memory access
700     */
701    @Operation(opcode = Opcode.READ_POINTER)
702    public abstract short readShort(int offset);
703
704    /**
705     * Reads the memory at address {@code (this + offset)}. Both the base address and offset are in
706     * bytes.
707     *
708     * @param offset the signed offset for the memory access
709     * @return the result of the memory access
710     */
711    @Operation(opcode = Opcode.READ_POINTER)
712    public abstract int readInt(int offset);
713
714    /**
715     * Reads the memory at address {@code (this + offset)}. Both the base address and offset are in
716     * bytes.
717     *
718     * @param offset the signed offset for the memory access
719     * @return the result of the memory access
720     */
721    @Operation(opcode = Opcode.READ_POINTER)
722    public abstract long readLong(int offset);
723
724    /**
725     * Reads the memory at address {@code (this + offset)}. Both the base address and offset are in
726     * bytes.
727     *
728     * @param offset the signed offset for the memory access
729     * @return the result of the memory access
730     */
731    @Operation(opcode = Opcode.READ_POINTER)
732    public abstract float readFloat(int offset);
733
734    /**
735     * Reads the memory at address {@code (this + offset)}. Both the base address and offset are in
736     * bytes.
737     *
738     * @param offset the signed offset for the memory access
739     * @return the result of the memory access
740     */
741    @Operation(opcode = Opcode.READ_POINTER)
742    public abstract double readDouble(int offset);
743
744    /**
745     * Reads the memory at address {@code (this + offset)}. Both the base address and offset are in
746     * bytes.
747     *
748     * @param offset the signed offset for the memory access
749     * @return the result of the memory access
750     */
751    @Operation(opcode = Opcode.READ_POINTER)
752    public abstract Word readWord(int offset);
753
754    /**
755     * Reads the memory at address {@code (this + offset)}. Both the base address and offset are in
756     * bytes.
757     *
758     * @param offset the signed offset for the memory access
759     * @return the result of the memory access
760     */
761    @Operation(opcode = Opcode.READ_POINTER)
762    public abstract Object readObject(int offset);
763
764    /**
765     * Reads the memory at address {@code (this + offset)}. This access will decompress the oop if
766     * the VM uses compressed oops, and it can be parameterized to allow read barriers (G1 referent
767     * field).
768     *
769     * @param offset the signed offset for the memory access
770     * @param barrierType the type of the read barrier to be added
771     * @return the result of the memory access
772     */
773    @Operation(opcode = Opcode.READ_POINTER)
774    public abstract Object readObject(int offset, BarrierType barrierType);
775
776    /**
777     * Writes the memory at address {@code (this + offset)}. Both the base address and offset are in
778     * bytes.
779     * <p>
780     * The offset is always treated as a {@link SignedWord} value. However, the static type is
781     * {@link WordBase} to avoid the frequent casts of {@link UnsignedWord} values (where the caller
782     * knows that the highest-order bit of the unsigned value is never used).
783     *
784     * @param offset the signed offset for the memory access
785     * @param val the value to be written to memory
786     */
787    @Operation(opcode = Opcode.WRITE_POINTER)
788    public abstract void writeByte(WordBase offset, byte val);
789
790    /**
791     * Writes the memory at address {@code (this + offset)}. Both the base address and offset are in
792     * bytes.
793     * <p>
794     * The offset is always treated as a {@link SignedWord} value. However, the static type is
795     * {@link WordBase} to avoid the frequent casts of {@link UnsignedWord} values (where the caller
796     * knows that the highest-order bit of the unsigned value is never used).
797     *
798     * @param offset the signed offset for the memory access
799     * @param val the value to be written to memory
800     */
801    @Operation(opcode = Opcode.WRITE_POINTER)
802    public abstract void writeChar(WordBase offset, char val);
803
804    /**
805     * Writes the memory at address {@code (this + offset)}. Both the base address and offset are in
806     * bytes.
807     * <p>
808     * The offset is always treated as a {@link SignedWord} value. However, the static type is
809     * {@link WordBase} to avoid the frequent casts of {@link UnsignedWord} values (where the caller
810     * knows that the highest-order bit of the unsigned value is never used).
811     *
812     * @param offset the signed offset for the memory access
813     * @param val the value to be written to memory
814     */
815    @Operation(opcode = Opcode.WRITE_POINTER)
816    public abstract void writeShort(WordBase offset, short val);
817
818    /**
819     * Writes the memory at address {@code (this + offset)}. Both the base address and offset are in
820     * bytes.
821     * <p>
822     * The offset is always treated as a {@link SignedWord} value. However, the static type is
823     * {@link WordBase} to avoid the frequent casts of {@link UnsignedWord} values (where the caller
824     * knows that the highest-order bit of the unsigned value is never used).
825     *
826     * @param offset the signed offset for the memory access
827     * @param val the value to be written to memory
828     */
829    @Operation(opcode = Opcode.WRITE_POINTER)
830    public abstract void writeInt(WordBase offset, int val);
831
832    /**
833     * Writes the memory at address {@code (this + offset)}. Both the base address and offset are in
834     * bytes.
835     * <p>
836     * The offset is always treated as a {@link SignedWord} value. However, the static type is
837     * {@link WordBase} to avoid the frequent casts of {@link UnsignedWord} values (where the caller
838     * knows that the highest-order bit of the unsigned value is never used).
839     *
840     * @param offset the signed offset for the memory access
841     * @param val the value to be written to memory
842     */
843    @Operation(opcode = Opcode.WRITE_POINTER)
844    public abstract void writeLong(WordBase offset, long val);
845
846    /**
847     * Writes the memory at address {@code (this + offset)}. Both the base address and offset are in
848     * bytes.
849     * <p>
850     * The offset is always treated as a {@link SignedWord} value. However, the static type is
851     * {@link WordBase} to avoid the frequent casts of {@link UnsignedWord} values (where the caller
852     * knows that the highest-order bit of the unsigned value is never used).
853     *
854     * @param offset the signed offset for the memory access
855     * @param val the value to be written to memory
856     */
857    @Operation(opcode = Opcode.WRITE_POINTER)
858    public abstract void writeFloat(WordBase offset, float val);
859
860    /**
861     * Writes the memory at address {@code (this + offset)}. Both the base address and offset are in
862     * bytes.
863     * <p>
864     * The offset is always treated as a {@link SignedWord} value. However, the static type is
865     * {@link WordBase} to avoid the frequent casts of {@link UnsignedWord} values (where the caller
866     * knows that the highest-order bit of the unsigned value is never used).
867     *
868     * @param offset the signed offset for the memory access
869     * @param val the value to be written to memory
870     */
871    @Operation(opcode = Opcode.WRITE_POINTER)
872    public abstract void writeDouble(WordBase offset, double val);
873
874    /**
875     * Writes the memory at address {@code (this + offset)}. Both the base address and offset are in
876     * bytes.
877     * <p>
878     * The offset is always treated as a {@link SignedWord} value. However, the static type is
879     * {@link WordBase} to avoid the frequent casts of {@link UnsignedWord} values (where the caller
880     * knows that the highest-order bit of the unsigned value is never used).
881     *
882     * @param offset the signed offset for the memory access
883     * @param val the value to be written to memory
884     */
885    @Operation(opcode = Opcode.WRITE_POINTER)
886    public abstract void writeWord(WordBase offset, WordBase val);
887
888    /**
889     * Writes the memory at address {@code (this + offset)}. Both the base address and offset are in
890     * bytes.
891     * <p>
892     * The offset is always treated as a {@link SignedWord} value. However, the static type is
893     * {@link WordBase} to avoid the frequent casts of {@link UnsignedWord} values (where the caller
894     * knows that the highest-order bit of the unsigned value is never used).
895     *
896     * @param offset the signed offset for the memory access
897     * @param val the value to be written to memory
898     */
899    @Operation(opcode = Opcode.WRITE_POINTER)
900    public abstract void writeObject(WordBase offset, Object val);
901
902    /**
903     * Writes the memory at address {@code (this + offset)}. Both the base address and offset are in
904     * bytes.
905     *
906     * @param offset the signed offset for the memory access
907     * @param val the value to be written to memory
908     */
909    @Operation(opcode = Opcode.WRITE_POINTER)
910    public abstract void writeByte(int offset, byte val);
911
912    /**
913     * Writes the memory at address {@code (this + offset)}. Both the base address and offset are in
914     * bytes.
915     *
916     * @param offset the signed offset for the memory access
917     * @param val the value to be written to memory
918     */
919    @Operation(opcode = Opcode.WRITE_POINTER)
920    public abstract void writeChar(int offset, char val);
921
922    /**
923     * Writes the memory at address {@code (this + offset)}. Both the base address and offset are in
924     * bytes.
925     *
926     * @param offset the signed offset for the memory access
927     * @param val the value to be written to memory
928     */
929    @Operation(opcode = Opcode.WRITE_POINTER)
930    public abstract void writeShort(int offset, short val);
931
932    /**
933     * Writes the memory at address {@code (this + offset)}. Both the base address and offset are in
934     * bytes.
935     *
936     * @param offset the signed offset for the memory access
937     * @param val the value to be written to memory
938     */
939    @Operation(opcode = Opcode.WRITE_POINTER)
940    public abstract void writeInt(int offset, int val);
941
942    /**
943     * Writes the memory at address {@code (this + offset)}. Both the base address and offset are in
944     * bytes.
945     *
946     * @param offset the signed offset for the memory access
947     * @param val the value to be written to memory
948     */
949    @Operation(opcode = Opcode.WRITE_POINTER)
950    public abstract void writeLong(int offset, long val);
951
952    /**
953     * Writes the memory at address {@code (this + offset)}. Both the base address and offset are in
954     * bytes.
955     *
956     * @param offset the signed offset for the memory access
957     * @param val the value to be written to memory
958     */
959    @Operation(opcode = Opcode.WRITE_POINTER)
960    public abstract void writeFloat(int offset, float val);
961
962    /**
963     * Writes the memory at address {@code (this + offset)}. Both the base address and offset are in
964     * bytes.
965     *
966     * @param offset the signed offset for the memory access
967     * @param val the value to be written to memory
968     */
969    @Operation(opcode = Opcode.WRITE_POINTER)
970    public abstract void writeDouble(int offset, double val);
971
972    /**
973     * Writes the memory at address {@code (this + offset)}. Both the base address and offset are in
974     * bytes.
975     *
976     * @param offset the signed offset for the memory access
977     * @param val the value to be written to memory
978     */
979    @Operation(opcode = Opcode.WRITE_POINTER)
980    public abstract void writeWord(int offset, WordBase val);
981
982    /**
983     * Writes the memory at address {@code (this + offset)}. Both the base address and offset are in
984     * bytes.
985     *
986     * @param offset the signed offset for the memory access
987     * @param val the value to be written to memory
988     */
989    @Operation(opcode = Opcode.WRITE_POINTER)
990    public abstract void writeObject(int offset, Object val);
991}
992