4646 */
4747public abstract class Hybrid {
4848
49- /**
50- * Hybrid objects cannot be directly represented in the Java language,
51- * so during bootstrapping that are represented as tuples plus an expansion.
52- *
53- * @author Bernd Mathiske
54- */
55- @ HOSTED_ONLY
56- private static class Expansion {
57- final Hybrid hybrid ;
58- final Word [] words ;
59- final int [] ints ;
60-
61- Expansion (Hybrid hybrid , int length ) {
62- this .hybrid = hybrid ;
63- this .words = new Word [length ];
64- this .ints = new int [(length * Word .size ()) / Ints .SIZE ];
65- }
66- }
67-
68- /**
69- * A map that stores the association between a hybrid and its expansion.
70- */
71- @ HOSTED_ONLY
72- private static final Map <Hybrid , Expansion > hybridToExpansion = Collections .synchronizedMap (new IdentityHashMap <Hybrid , Expansion >());
73-
7449 protected Hybrid () {
7550 }
7651
@@ -81,11 +56,6 @@ protected Hybrid() {
8156 * @return the expanded hybrid with array features
8257 */
8358 public final Hybrid expand (int length ) {
84- if (MaxineVM .isHosted ()) {
85- final Expansion oldValue = hybridToExpansion .put (this , new Expansion (this , length ));
86- assert oldValue == null ;
87- return this ;
88- }
8959 return Heap .expandHybrid (this , length );
9060 }
9161
@@ -101,9 +71,6 @@ public final Hybrid expand(int length) {
10171 */
10272 @ INLINE
10373 public final int length () {
104- if (MaxineVM .isHosted ()) {
105- return hybridToExpansion .get (this ).words .length ;
106- }
10774 return ArrayAccess .readArrayLength (this );
10875 }
10976
@@ -114,13 +81,7 @@ public final int length() {
11481 */
11582 @ INLINE
11683 public final void setWord (int wordIndex , Word value ) {
117- if (MaxineVM .isHosted ()) {
118- assert wordIndex >= firstWordIndex ();
119- final Expansion expansion = hybridToExpansion .get (this );
120- WordArray .set (expansion .words , wordIndex , value );
121- } else {
122- ArrayAccess .setWord (this , wordIndex , value );
123- }
84+ ArrayAccess .setWord (this , wordIndex , value );
12485 }
12586
12687 /**
@@ -130,11 +91,6 @@ public final void setWord(int wordIndex, Word value) {
13091 */
13192 @ INLINE
13293 public final Word getWord (int wordIndex ) {
133- if (MaxineVM .isHosted ()) {
134- assert wordIndex >= firstWordIndex ();
135- final Expansion expansion = hybridToExpansion .get (this );
136- return WordArray .get (expansion .words , wordIndex );
137- }
13894 return ArrayAccess .getWord (this , wordIndex );
13995 }
14096
@@ -145,13 +101,7 @@ public final Word getWord(int wordIndex) {
145101 */
146102 @ INLINE
147103 public final void setInt (int intIndex , int value ) {
148- if (MaxineVM .isHosted ()) {
149- assert intIndex >= firstIntIndex ();
150- final Expansion expansion = hybridToExpansion .get (this );
151- expansion .ints [intIndex ] = value ;
152- } else {
153- ArrayAccess .setInt (this , intIndex , value );
154- }
104+ ArrayAccess .setInt (this , intIndex , value );
155105 }
156106
157107 /**
@@ -161,11 +111,6 @@ public final void setInt(int intIndex, int value) {
161111 */
162112 @ INLINE
163113 public final int getInt (int intIndex ) {
164- if (MaxineVM .isHosted ()) {
165- assert intIndex >= firstIntIndex ();
166- final Expansion expansion = hybridToExpansion .get (this );
167- return expansion .ints [intIndex ];
168- }
169114 return ArrayAccess .getInt (this , intIndex );
170115 }
171116}
0 commit comments