Mercurial > hg > graal-jvmci-8
comparison graal/com.oracle.truffle.object/src/com/oracle/truffle/object/LocationImpl.java @ 18795:e9cbe1618733
Truffle: refactor size calculation in location allocator to visitor pattern
author | Andreas Woess <andreas.woess@jku.at> |
---|---|
date | Wed, 07 Jan 2015 15:11:38 +0100 |
parents | 2c3666f44855 |
children |
comparison
equal
deleted
inserted
replaced
18794:e688e42b41e3 | 18795:e9cbe1618733 |
---|---|
23 package com.oracle.truffle.object; | 23 package com.oracle.truffle.object; |
24 | 24 |
25 import com.oracle.truffle.api.object.*; | 25 import com.oracle.truffle.api.object.*; |
26 | 26 |
27 public abstract class LocationImpl extends Location { | 27 public abstract class LocationImpl extends Location { |
28 | |
29 public interface EffectivelyFinalLocation<T extends Location> { | |
30 T toNonFinalLocation(); | |
31 } | |
32 | |
33 public interface TypedObjectLocation<T extends Location & ObjectLocation> extends ObjectLocation { | |
34 T toUntypedLocation(); | |
35 } | |
36 | |
37 public interface InternalLongLocation extends LongLocation { | |
38 void setLongInternal(DynamicObject store, long value); | |
39 } | |
40 | |
41 public interface LocationVisitor { | |
42 void visitObjectField(int index, int count); | |
43 | |
44 void visitObjectArray(int index, int count); | |
45 | |
46 void visitPrimitiveField(int index, int count); | |
47 | |
48 void visitPrimitiveArray(int index, int count); | |
49 } | |
50 | |
28 @Override | 51 @Override |
29 public void set(DynamicObject store, Object value, Shape shape) throws IncompatibleLocationException, FinalLocationException { | 52 public void set(DynamicObject store, Object value, Shape shape) throws IncompatibleLocationException, FinalLocationException { |
30 setInternal(store, value); | 53 setInternal(store, value); |
31 } | 54 } |
32 | 55 |
49 } | 72 } |
50 | 73 |
51 @SuppressWarnings("unused") | 74 @SuppressWarnings("unused") |
52 protected boolean canStoreFinal(DynamicObject store, Object value) { | 75 protected boolean canStoreFinal(DynamicObject store, Object value) { |
53 return true; | 76 return true; |
54 } | |
55 | |
56 public interface EffectivelyFinalLocation<T extends Location> { | |
57 T toNonFinalLocation(); | |
58 } | |
59 | |
60 public interface TypedObjectLocation<T extends Location & ObjectLocation> extends ObjectLocation { | |
61 T toUntypedLocation(); | |
62 } | |
63 | |
64 public interface InternalLongLocation extends LongLocation { | |
65 void setLongInternal(DynamicObject store, long value); | |
66 } | 77 } |
67 | 78 |
68 @Override | 79 @Override |
69 public boolean isFinal() { | 80 public boolean isFinal() { |
70 return false; | 81 return false; |
140 public int primitiveArrayCount() { | 151 public int primitiveArrayCount() { |
141 return 0; | 152 return 0; |
142 } | 153 } |
143 | 154 |
144 /** | 155 /** |
156 * Accept a visitor for location allocation for this and every nested location. | |
157 * | |
158 * @param locationVisitor visitor to be notified of every allocated slot in use by this location | |
159 */ | |
160 public abstract void accept(LocationVisitor locationVisitor); | |
161 | |
162 /** | |
145 * Boxed values need to be compared by value not by reference. | 163 * Boxed values need to be compared by value not by reference. |
146 * | 164 * |
147 * The first parameter should be the one with the more precise type information. | 165 * The first parameter should be the one with the more precise type information. |
148 * | 166 * |
149 * For sets to final locations, otherValue.equals(thisValue) seems more beneficial, since we | 167 * For sets to final locations, otherValue.equals(thisValue) seems more beneficial, since we |