001/*
002 *  This file is part of the Jikes RVM project (http://jikesrvm.org).
003 *
004 *  This file is licensed to You under the Eclipse Public License (EPL);
005 *  You may not use this file except in compliance with the License. You
006 *  may obtain a copy of the License at
007 *
008 *      http://www.opensource.org/licenses/eclipse-1.0.php
009 *
010 *  See the COPYRIGHT.txt file distributed with this work for information
011 *  regarding copyright ownership.
012 */
013package org.vmmagic.unboxed;
014
015import org.vmmagic.Unboxed;
016import org.vmmagic.pragma.RawStorage;
017
018/**
019 * <b>Stub</b> implementation of an Address type, intended only to
020 * allow the core of MMTk to be compiled.  This <b>must</b> be
021 * replaced with a concrete implementation appropriate to a specific
022 * VM.<p>
023 *
024 * The address type is used by the runtime system and collector to
025 * denote machine addresses.  We use a separate type instead of the
026 * Java int type for coding clarity,  machine-portability (it can map
027 * to 32 bit and 64 bit integral types), and access to unsigned
028 * operations (Java does not have unsigned int types).
029 */
030@Unboxed
031@RawStorage(lengthInWords = true, length = 1)
032public final class Address {
033
034  /****************************************************************************
035   *
036   * Special values
037   */
038
039  /**
040   * Return an <code>Address</code> instance that reflects the value
041   * zero.
042   *
043   * @return An address instance that reflects the value zero.
044   */
045  public static Address zero() {
046    return null;
047  }
048
049  /**
050   * Return <code>true</code> if this instance is zero.
051   *
052   * @return <code>true</code> if this instance is zero.
053   */
054  public boolean isZero() {
055    return false;
056  }
057
058  /**
059   * Return an <code>Address</code> instance that reflects the maximum
060   * allowable <code>Address</code> value.
061   *
062   * @return An <code>Address</code> instance that reflects the
063   * maximum allowable <code>Address</code> value.
064   */
065  public static Address max() {
066    return null;
067  }
068
069  /**
070   * Return <code>true</code> if this instance is the maximum
071   * allowable <code>Address</code> value.
072   *
073   * @return <code>true</code> if this instance is the maximum
074   * allowable <code>Address</code> valu.
075   */
076  public boolean isMax() {
077    return false;
078  }
079
080  /****************************************************************************
081   *
082   * Conversions
083   */
084
085  /**
086   * Fabricate an <code>Address</code> instance from an integer, after
087   * sign extending the integer.
088   *
089   * @param address the integer from which to create an <code>Address</code>
090   *          instance
091   * @return An address instance
092   */
093  public static Address fromIntSignExtend(int address) {
094    return null;
095  }
096
097  /**
098   * Fabricate an <code>Address</code> instance from an integer, after
099   * zero extending the integer.
100   *
101   * @param address the integer from which to create an <code>Address</code>
102   *          instance
103   * @return An address instance
104   */
105  public static Address fromIntZeroExtend(int address) {
106    return null;
107  }
108
109  /**
110   * Fabricate an <code>Address</code> instance from an integer
111   *
112   * @param address the integer from which to create an <code>Address</code>
113   *          instance
114   * @return An address instance
115   */
116  public static Address fromLong(long address) {
117    return null;
118  }
119
120  /**
121   * Fabricate an <code>ObjectReference</code> instance from an
122   * <code>Address</code> instance.  It is the user's responsibility
123   * to ensure that the <code>Address</code> is suitable (i.e. it
124   * points to the object header, or satisfies any other VM-specific
125   * requirement for such a conversion).
126   *
127   * @return An <code>ObjectReference</code> instance.
128   */
129  public ObjectReference toObjectReference() {
130    return null;
131  }
132
133  /**
134   * Return an integer that reflects the value of this
135   * <code>Address</code> instance.
136   *
137   * @return An integer that reflects the value of this
138   * <code>Address</code> instance.
139   */
140  public int toInt() {
141    return 0;
142  }
143
144  /**
145   * Return an long that reflects the value of this
146   * <code>Address</code> instance.
147   *
148   * @return An long that reflects the value of this
149   * <code>Address</code> instance.
150   */
151  public long toLong() {
152    return 0;
153  }
154
155  /**
156   * Return a <code>Word</code> instance that reflects the value of
157   * this <code>Address</code> instance.
158   *
159   * @return A <code>Word</code> instance that reflects the value of
160   * this <code>Address</code> instance.
161   */
162  public Word toWord() {
163    return null;
164  }
165
166  /****************************************************************************
167   *
168   * Arithemtic operators
169   */
170
171  /**
172   * Add an integer to this <code>Address</code>, and return the sum.
173   *
174   * @param  v the value to be added to this <code>Address</code>
175   * @return An <code>Address</code> instance that reflects the result
176   * of the addition.
177   */
178  public Address plus(int v) {
179    return null;
180  }
181
182  /**
183   * Add an <code>Offset</code> to this <code>Address</code>, and
184   * return the sum.
185   *
186   * @param offset the <code>Offset</code> to be added to the address
187   * @return An <code>Address</code> instance that reflects the result
188   * of the addition.
189   */
190  public Address plus(Offset offset) {
191    return null;
192  }
193
194  /**
195   * Add an <code>Extent</code> to this <code>Address</code>, and
196   * return the sum.
197   *
198   * @param extent the <code>Extent</code> to be added to this
199   * <code>Address</code>
200   * @return An <code>Address</code> instance that reflects the result
201   * of the addition.
202   */
203  public Address plus(Extent extent) {
204    return null;
205  }
206
207  /**
208   * Subtract an integer from this <code>Address</code>, and return
209   * the result.
210   *
211   * @param v the integer to be subtracted from this
212   * <code>Address</code>.
213   * @return An <code>Address</code> instance that reflects the result
214   * of the subtraction.
215   */
216  public Address minus(int v) {
217    return null;
218  }
219
220  /**
221   * Subtract an <code>Offset</code> from this <code>Address</code>, and
222   * return the result.
223   *
224   * @param offset the <code>Offset</code> to be subtracted from this
225   *          <code>Address</code>.
226   * @return An <code>Address</code> instance that reflects the result
227   * of the subtraction.
228   */
229  public Address minus(Offset offset) {
230    return null;
231  }
232
233  /**
234   * Subtract an <code>Extent</code> from this <code>Address</code>, and
235   * return the result.
236   *
237   * @param extent the <code>Extent</code> to be subtracted from this
238   *          <code>Address</code>.
239   * @return An <code>Address</code> instance that reflects the result
240   * of the subtraction.
241   */
242  public Address minus(Extent extent) {
243    return null;
244  }
245
246  /**
247   * Compute the difference between two <code>Address</code>es and
248   * return the result.
249   *
250   * @param addr2 the <code>Address</code> to be subtracted from this
251   *          <code>Address</code>.
252   * @return An <code>Offset</code> instance that reflects the result
253   * of the subtraction.
254   */
255  public Offset diff(Address addr2) {
256    return null;
257  }
258
259  /****************************************************************************
260   *
261   * Boolean operators
262   */
263
264  /**
265   * Return {@code true} if this <code>Address</code> instance is <i>less
266   * than</i> <code>addr2</code>.
267   *
268   * @param addr2 the <code>Address</code> to be compared to this
269   *          <code>Address</code>.
270   * @return {@code true} if this <code>Address</code> instance is <i>less
271   * than</i> <code>addr2</code>.
272   */
273  public boolean LT(Address addr2) {
274    return false;
275  }
276
277  /**
278   * Return {@code true} if this <code>Address</code> instance is <i>less
279   * than or equal to</i> <code>addr2</code>.
280   *
281   * @param addr2 the <code>Address</code> to be compared to this
282   *          <code>Address</code>.
283   * @return {@code true} if this <code>Address</code> instance is <i>less
284   * than or equal to</i> <code>addr2</code>.
285   */
286  public boolean LE(Address addr2) {
287    return false;
288  }
289
290  /**
291   * Return {@code true} if this <code>Address</code> instance is <i>greater
292   * than</i> <code>addr2</code>.
293   *
294   * @param addr2 the <code>Address</code> to be compared to this
295   *          <code>Address</code>.
296   * @return {@code true} if this <code>Address</code> instance is <i>greater
297   * than</i> <code>addr2</code>.
298   */
299  public boolean GT(Address addr2) {
300    return false;
301  }
302
303  /**
304   * Return {@code true} if this <code>Address</code> instance is <i>greater
305   * than or equal to</i> <code>addr2</code>.
306   *
307   * @param addr2 the <code>Address</code> to be compared to this
308   *          <code>Address</code>.
309   * @return {@code true} if this <code>Address</code> instance is <i>greater
310   * than or equal to</i> <code>addr2</code>.
311   */
312  public boolean GE(Address addr2) {
313    return false;
314  }
315
316  /**
317   * Return {@code true} if this <code>Address</code> instance is <i>equal
318   * to</i> <code>addr2</code>.
319   *
320   * @param addr2 the <code>Address</code> to be compared to this
321   *          <code>Address</code>.
322   * @return {@code true} if this <code>Address</code> instance is <i>equal
323   * to</i> <code>addr2</code>.
324   */
325  public boolean EQ(Address addr2) {
326    return false;
327  }
328
329  /**
330   * Return {@code true} if this <code>Address</code> instance is <i>not equal
331   * to</i> <code>addr2</code>.
332   *
333   * @param addr2 the <code>Address</code> to be compared to this
334   *          <code>Address</code>.
335   * @return {@code true} if this <code>Address</code> instance is <i>not
336   * equal to</i> <code>addr2</code>.
337   */
338  public boolean NE(Address addr2) {
339    return false;
340  }
341
342  /****************************************************************************
343   *
344   * Software prefetch operators etc
345   */
346
347  /**
348   * Prefetch a cache-line, architecture-independent
349   */
350  public void prefetch() {
351  }
352
353  /****************************************************************************
354   *
355   * Memory access operators
356   */
357
358  /**
359   * Loads a reference from the memory location pointed to by the
360   * current instance.
361   *
362   * @return the read value
363   */
364  public ObjectReference loadObjectReference() {
365    return null;
366  }
367
368  /**
369   * Loads a reference from the memory location pointed to by the
370   * current instance.
371   *
372   * @param offset the offset to the value.
373   * @return the read value
374   */
375  public ObjectReference loadObjectReference(Offset offset) {
376    return null;
377  }
378
379  /**
380   * Loads a byte from the memory location pointed to by the
381   * current instance.
382   *
383   * @return the read value
384   */
385  public byte loadByte() {
386    return (byte) 0;
387  }
388
389  /**
390   * Loads a byte from the memory location pointed to by the
391   * current instance.
392   *
393   * @param offset the offset to the value.
394   * @return the read value
395   */
396  public byte loadByte(Offset offset) {
397    return (byte) 0;
398  }
399
400  /**
401   * Loads a char from the memory location pointed to by the
402   * current instance.
403   *
404   * @return the read value
405   */
406  public char loadChar() {
407    return (char) 0;
408  }
409
410  /**
411   * Loads a char from the memory location pointed to by the
412   * current instance.
413   *
414   * @param offset the offset to the value.
415   * @return the read value
416   */
417  public char loadChar(Offset offset) {
418    return (char) 0;
419  }
420
421  /**
422   * Loads a short from the memory location pointed to by the
423   * current instance.
424   *
425   * @return the read value
426   */
427  public short loadShort() {
428    return (short) 0;
429  }
430
431  /**
432   * Loads a short from the memory location pointed to by the
433   * current instance.
434   *
435   * @param offset the offset to the value.
436   * @return the read value
437   */
438  public short loadShort(Offset offset) {
439    return (short) 0;
440  }
441
442  /**
443   * Loads a float from the memory location pointed to by the
444   * current instance.
445   *
446   * @return the read value
447   */
448  public float loadFloat() {
449    return 0;
450  }
451
452  /**
453   * Loads a float from the memory location pointed to by the
454   * current instance.
455   *
456   * @param offset the offset to the value.
457   * @return the read value
458   */
459  public float loadFloat(Offset offset) {
460    return 0;
461  }
462
463  /**
464   * Loads an int from the memory location pointed to by the
465   * current instance.
466   *
467   * @return the read value
468   */
469  public int loadInt() {
470    return 0;
471  }
472
473  /**
474   * Loads an int from the memory location pointed to by the
475   * current instance.
476   *
477   * @param offset the offset to the value.
478   * @return the read value
479   */
480  public int loadInt(Offset offset) {
481    return 0;
482  }
483
484
485  /**
486   * Loads a long from the memory location pointed to by the
487   * current instance.
488   *
489   * @return the read value
490   */
491  public long loadLong() {
492    return 0L;
493  }
494
495  /**
496   * Loads a long from the memory location pointed to by the
497   * current instance.
498   *
499   * @param offset the offset to the value.
500   * @return the read value
501   */
502  public long loadLong(Offset offset) {
503    return 0L;
504  }
505
506  /**
507   * Loads a double from the memory location pointed to by the
508   * current instance.
509   *
510   * @return the read value
511   */
512  public double loadDouble() {
513    return 0;
514  }
515
516  /**
517   * Loads a double from the memory location pointed to by the
518   * current instance.
519   *
520   * @param offset the offset to the value.
521   * @return the read value
522   */
523  public double loadDouble(Offset offset) {
524    return 0;
525  }
526
527
528  /**
529   * Loads an address value from the memory location pointed to by the
530   * current instance.
531   *
532   * @return the read address value.
533   */
534  public Address loadAddress() {
535    return null;
536  }
537
538  /**
539   * Loads an address value from the memory location pointed to by the
540   * current instance.
541   *
542   * @param offset the offset to the value.
543   * @return the read address value.
544   */
545  public Address loadAddress(Offset offset) {
546    return null;
547  }
548
549  /**
550   * Loads a word value from the memory location pointed to by the
551   * current instance.
552   *
553   * @return the read word value.
554   */
555  public Word loadWord() {
556    return null;
557  }
558
559  /**
560   * Loads a word value from the memory location pointed to by the
561   * current instance.
562   *
563   * @param offset the offset to the value.
564   * @return the read word value.
565   */
566  public Word loadWord(Offset offset) {
567    return null;
568  }
569
570  /**
571   * Stores the address value in the memory location pointed to by the
572   * current instance.
573   *
574   * @param value The address value to store.
575   */
576  public void store(ObjectReference value) {
577  }
578
579  /**
580   * Stores the object reference value in the memory location pointed
581   * to by the current instance.
582   *
583   * @param value The object reference value to store.
584   * @param offset the offset to the value.
585   */
586  public void store(ObjectReference value, Offset offset) {
587  }
588
589  /**
590   * Stores the address value in the memory location pointed to by the
591   * current instance.
592   *
593   * @param value The address value to store.
594   */
595  public void store(Address value) {
596  }
597
598  /**
599   * Stores the address value in the memory location pointed to by the
600   * current instance.
601   *
602   * @param value The address value to store.
603   * @param offset the offset to the value.
604   */
605  public void store(Address value, Offset offset) {
606  }
607
608  /**
609   * Stores the float value in the memory location pointed to by the
610   * current instance.
611   *
612   * @param value The float value to store.
613   */
614  public void store(float value) {
615  }
616
617  /**
618   * Stores the float value in the memory location pointed to by the
619   * current instance.
620   *
621   * @param value The float value to store.
622   * @param offset the offset to the value.
623   */
624  public void store(float value, Offset offset) {
625  }
626
627  /**
628   * Stores the word value in the memory location pointed to by the
629   * current instance.
630   *
631   * @param value The word value to store.
632   */
633  public void store(Word value) {
634  }
635
636  /**
637   * Stores the word value in the memory location pointed to by the
638   * current instance.
639   *
640   * @param value The word value to store.
641   * @param offset the offset to the value.
642   */
643  public void store(Word value, Offset offset) {
644  }
645
646  /**
647   * Stores the boolean value in the memory location pointed to by the
648   * current instance.
649   *
650   * @param value The boolean value to store.
651   */
652  public void store(boolean value) {
653  }
654
655  /**
656   * Stores the boolean value in the memory location pointed to by the
657   * current instance.
658   *
659   * @param value The boolean value to store.
660   * @param offset the offset to the value.
661   */
662  public void store(boolean value, Offset offset) {
663  }
664
665  /**
666   * Stores the byte value in the memory location pointed to by the
667   * current instance.
668   *
669   * @param value The byte value to store.
670   */
671  public void store(byte value) {
672  }
673
674  /**
675   * Stores the byte value in the memory location pointed to by the
676   * current instance.
677   *
678   * @param value The byte value to store.
679   * @param offset the offset to the value.
680   */
681  public void store(byte value, Offset offset) {
682  }
683
684  /**
685   * Stores an int value in memory location pointed to by the
686   * current instance.
687   *
688   * @param value The int value to store.
689   */
690  public void store(int value) {
691  }
692
693  /**
694   * Stores an int value in memory location pointed to by the
695   * current instance.
696   *
697   * @param value The int value to store.
698   * @param offset the offset to the value.
699   */
700  public void store(int value, Offset offset) {
701  }
702
703  /**
704   * Stores a double value in memory location pointed to by the
705   * current instance.
706   *
707   * @param value The double value to store.
708   */
709  public void store(double value) {
710  }
711
712  /**
713   * Stores a double value in memory location pointed to by the
714   * current instance.
715   *
716   * @param value The double value to store.
717   * @param offset the offset to the value.
718   */
719  public void store(double value, Offset offset) {
720  }
721
722
723  /**
724   * Stores a double value in memory location pointed to by the
725   * current instance.
726   *
727   * @param value The double value to store.
728   */
729  public void store(long value) {
730  }
731
732  /**
733   * Stores a double value in memory location pointed to by the
734   * current instance.
735   *
736   * @param value The double value to store.
737   * @param offset the offset to the value.
738   */
739  public void store(long value, Offset offset) {
740  }
741
742  /**
743   * Stores a char value in the memory location pointed to by the
744   * current instance.
745   *
746   * @param value the char value to store.
747   */
748  public void store(char value) {
749  }
750
751  /**
752   * Stores a char value in the memory location pointed to by the
753   * current instance.
754   *
755   * @param value the char value to store.
756   * @param offset the offset to the value.
757   */
758  public void store(char value, Offset offset) {
759  }
760
761  /**
762   * Stores a short value in the memory location pointed to by the
763   * current instance.
764   *
765   * @param value the short value to store.
766   */
767  public void store(short value) {
768  }
769
770  /**
771   * Stores a short value in the memory location pointed to by the
772   * current instance.
773   *
774   * @param value the short value to store.
775   * @param offset the offset to the value.
776   */
777  public void store(short value, Offset offset) {
778  }
779
780  /****************************************************************************
781   *
782   * Atomic memory access operators (compare and swap)
783   */
784
785  /**
786   * Prepare for an atomic store operation. This must be associated with
787   * a related call to attempt.
788   *
789   * @return the old value to be passed to an attempt call.
790   */
791  public Word prepareWord() {
792    return null;
793  }
794
795  /**
796   * Prepare for an atomic store operation. This must be associated with
797   * a related call to attempt.
798   *
799   * @param offset the offset to the value.
800   * @return the old value to be passed to an attempt call.
801   */
802  public Word prepareWord(Offset offset) {
803    return null;
804  }
805
806  /**
807   * Prepare for an atomic store operation. This must be associated with
808   * a related call to attempt.
809   *
810   * @return the old value to be passed to an attempt call.
811   */
812  public ObjectReference prepareObjectReference() {
813    return null;
814  }
815
816  /**
817   * Prepare for an atomic store operation. This must be associated with
818   * a related call to attempt.
819   *
820   * @param offset the offset to the value.
821   * @return the old value to be passed to an attempt call.
822   */
823  public ObjectReference prepareObjectReference(Offset offset) {
824    return null;
825  }
826
827  /**
828   * Prepare for an atomic store operation. This must be associated with
829   * a related call to attempt.
830   *
831   * @return the old value to be passed to an attempt call.
832   */
833  public Address prepareAddress() {
834    return null;
835  }
836
837  /**
838   * Prepare for an atomic store operation. This must be associated with
839   * a related call to attempt.
840   *
841   * @param offset the offset to the value.
842   * @return the old value to be passed to an attempt call.
843   */
844  public Address prepareAddress(Offset offset) {
845    return null;
846  }
847
848  /**
849   * Prepare for an atomic store operation. This must be associated with
850   * a related call to attempt.
851   *
852   * @return the old value to be passed to an attempt call.
853   */
854  public int prepareInt() {
855    return 0;
856  }
857
858  /**
859   * Prepare for an atomic store operation. This must be associated with
860   * a related call to attempt.
861   *
862   * @param offset the offset to the value.
863   * @return the old value to be passed to an attempt call.
864   */
865  public int prepareInt(Offset offset) {
866    return 0;
867  }
868
869  /**
870   * Attempt an atomic store operation. This must be associated with a
871   * related call to prepare.
872   *
873   * @param old the old value.
874   * @param value the new value.
875   * @return {@code true} if the attempt was successful.
876   */
877  public boolean attempt(int old, int value) {
878    return false;
879  }
880
881  /**
882   * Attempt an atomic store operation. This must be associated with a
883   * related call to prepare.
884   *
885   * @param old the old value.
886   * @param value the new value.
887   * @param offset the offset to the value.
888   * @return {@code true} if the attempt was successful.
889   */
890  public boolean attempt(int old, int value, Offset offset) {
891    return false;
892  }
893
894  /**
895   * Attempt an atomic store operation. This must be associated with a
896   * related call to prepare.
897   *
898   * @param old the old value.
899   * @param value the new value.
900   * @return {@code true} if the attempt was successful.
901   */
902  public boolean attempt(Word old, Word value) {
903    return false;
904  }
905
906  /**
907   * Attempt an atomic store operation. This must be associated with a
908   * related call to prepare.
909   *
910   * @param old the old value.
911   * @param value the new value.
912   * @param offset the offset to the value.
913   * @return {@code true} if the attempt was successful.
914   */
915  public boolean attempt(Word old, Word value, Offset offset) {
916    return false;
917  }
918
919  /**
920   * Attempt an atomic store operation. This must be associated with a
921   * related call to prepare.
922   *
923   * @param old the old value.
924   * @param value the new value.
925   * @return {@code true} if the attempt was successful.
926   */
927  public boolean attempt(ObjectReference old, ObjectReference value) {
928    return false;
929  }
930
931  /**
932   * Attempt an atomic store operation. This must be associated with a
933   * related call to prepare.
934   *
935   * @param old the old value.
936   * @param value the new value.
937   * @param offset the offset to the value.
938   * @return {@code true} if the attempt was successful.
939   */
940  public boolean attempt(ObjectReference old, ObjectReference value,
941      Offset offset) {
942    return false;
943  }
944
945  /**
946   * Attempt an atomic store operation. This must be associated with a
947   * related call to prepare.
948   *
949   * @param old the old value.
950   * @param value the new value.
951   * @return {@code true} if the attempt was successful.
952   */
953  public boolean attempt(Address old, Address value) {
954    return false;
955  }
956
957  /**
958   * Attempt an atomic store operation. This must be associated with a
959   * related call to prepare.
960   *
961   * @param old the old value.
962   * @param value the new value.
963   * @param offset the offset to the value.
964   * @return {@code true} if the attempt was successful.
965   */
966  public boolean attempt(Address old, Address value, Offset offset) {
967    return false;
968  }
969
970}