annotate truffle/com.oracle.truffle.object.basic/src/com/oracle/truffle/object/basic/BasicAllocator.java @ 21951:9c8c0937da41

Moving all sources into truffle subdirectory
author Jaroslav Tulach <jaroslav.tulach@oracle.com>
date Wed, 17 Jun 2015 10:58:08 +0200
parents graal/com.oracle.truffle.object.basic/src/com/oracle/truffle/object/basic/BasicAllocator.java@2c3666f44855
children dc83cc1f94f2
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
18408
2c3666f44855 Truffle: initial commit of object API implementation
Andreas Woess <andreas.woess@jku.at>
parents:
diff changeset
1 /*
2c3666f44855 Truffle: initial commit of object API implementation
Andreas Woess <andreas.woess@jku.at>
parents:
diff changeset
2 * Copyright (c) 2012, 2014, Oracle and/or its affiliates. All rights reserved.
2c3666f44855 Truffle: initial commit of object API implementation
Andreas Woess <andreas.woess@jku.at>
parents:
diff changeset
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
2c3666f44855 Truffle: initial commit of object API implementation
Andreas Woess <andreas.woess@jku.at>
parents:
diff changeset
4 *
2c3666f44855 Truffle: initial commit of object API implementation
Andreas Woess <andreas.woess@jku.at>
parents:
diff changeset
5 * This code is free software; you can redistribute it and/or modify it
2c3666f44855 Truffle: initial commit of object API implementation
Andreas Woess <andreas.woess@jku.at>
parents:
diff changeset
6 * under the terms of the GNU General Public License version 2 only, as
2c3666f44855 Truffle: initial commit of object API implementation
Andreas Woess <andreas.woess@jku.at>
parents:
diff changeset
7 * published by the Free Software Foundation.
2c3666f44855 Truffle: initial commit of object API implementation
Andreas Woess <andreas.woess@jku.at>
parents:
diff changeset
8 *
2c3666f44855 Truffle: initial commit of object API implementation
Andreas Woess <andreas.woess@jku.at>
parents:
diff changeset
9 * This code is distributed in the hope that it will be useful, but WITHOUT
2c3666f44855 Truffle: initial commit of object API implementation
Andreas Woess <andreas.woess@jku.at>
parents:
diff changeset
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
2c3666f44855 Truffle: initial commit of object API implementation
Andreas Woess <andreas.woess@jku.at>
parents:
diff changeset
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
2c3666f44855 Truffle: initial commit of object API implementation
Andreas Woess <andreas.woess@jku.at>
parents:
diff changeset
12 * version 2 for more details (a copy is included in the LICENSE file that
2c3666f44855 Truffle: initial commit of object API implementation
Andreas Woess <andreas.woess@jku.at>
parents:
diff changeset
13 * accompanied this code).
2c3666f44855 Truffle: initial commit of object API implementation
Andreas Woess <andreas.woess@jku.at>
parents:
diff changeset
14 *
2c3666f44855 Truffle: initial commit of object API implementation
Andreas Woess <andreas.woess@jku.at>
parents:
diff changeset
15 * You should have received a copy of the GNU General Public License version
2c3666f44855 Truffle: initial commit of object API implementation
Andreas Woess <andreas.woess@jku.at>
parents:
diff changeset
16 * 2 along with this work; if not, write to the Free Software Foundation,
2c3666f44855 Truffle: initial commit of object API implementation
Andreas Woess <andreas.woess@jku.at>
parents:
diff changeset
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
2c3666f44855 Truffle: initial commit of object API implementation
Andreas Woess <andreas.woess@jku.at>
parents:
diff changeset
18 *
2c3666f44855 Truffle: initial commit of object API implementation
Andreas Woess <andreas.woess@jku.at>
parents:
diff changeset
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
2c3666f44855 Truffle: initial commit of object API implementation
Andreas Woess <andreas.woess@jku.at>
parents:
diff changeset
20 * or visit www.oracle.com if you need additional information or have any
2c3666f44855 Truffle: initial commit of object API implementation
Andreas Woess <andreas.woess@jku.at>
parents:
diff changeset
21 * questions.
2c3666f44855 Truffle: initial commit of object API implementation
Andreas Woess <andreas.woess@jku.at>
parents:
diff changeset
22 */
2c3666f44855 Truffle: initial commit of object API implementation
Andreas Woess <andreas.woess@jku.at>
parents:
diff changeset
23 package com.oracle.truffle.object.basic;
2c3666f44855 Truffle: initial commit of object API implementation
Andreas Woess <andreas.woess@jku.at>
parents:
diff changeset
24
2c3666f44855 Truffle: initial commit of object API implementation
Andreas Woess <andreas.woess@jku.at>
parents:
diff changeset
25 import static com.oracle.truffle.object.basic.BasicLocations.*;
2c3666f44855 Truffle: initial commit of object API implementation
Andreas Woess <andreas.woess@jku.at>
parents:
diff changeset
26
2c3666f44855 Truffle: initial commit of object API implementation
Andreas Woess <andreas.woess@jku.at>
parents:
diff changeset
27 import com.oracle.truffle.api.object.*;
2c3666f44855 Truffle: initial commit of object API implementation
Andreas Woess <andreas.woess@jku.at>
parents:
diff changeset
28 import com.oracle.truffle.object.*;
2c3666f44855 Truffle: initial commit of object API implementation
Andreas Woess <andreas.woess@jku.at>
parents:
diff changeset
29 import com.oracle.truffle.object.LocationImpl.InternalLongLocation;
2c3666f44855 Truffle: initial commit of object API implementation
Andreas Woess <andreas.woess@jku.at>
parents:
diff changeset
30 import com.oracle.truffle.object.Locations.ConstantLocation;
2c3666f44855 Truffle: initial commit of object API implementation
Andreas Woess <andreas.woess@jku.at>
parents:
diff changeset
31 import com.oracle.truffle.object.Locations.DeclaredDualLocation;
2c3666f44855 Truffle: initial commit of object API implementation
Andreas Woess <andreas.woess@jku.at>
parents:
diff changeset
32 import com.oracle.truffle.object.Locations.DualLocation;
2c3666f44855 Truffle: initial commit of object API implementation
Andreas Woess <andreas.woess@jku.at>
parents:
diff changeset
33 import com.oracle.truffle.object.Locations.ValueLocation;
2c3666f44855 Truffle: initial commit of object API implementation
Andreas Woess <andreas.woess@jku.at>
parents:
diff changeset
34 import com.oracle.truffle.object.basic.BasicLocations.BooleanLocationDecorator;
2c3666f44855 Truffle: initial commit of object API implementation
Andreas Woess <andreas.woess@jku.at>
parents:
diff changeset
35 import com.oracle.truffle.object.basic.BasicLocations.DoubleLocationDecorator;
2c3666f44855 Truffle: initial commit of object API implementation
Andreas Woess <andreas.woess@jku.at>
parents:
diff changeset
36 import com.oracle.truffle.object.basic.BasicLocations.IntLocationDecorator;
2c3666f44855 Truffle: initial commit of object API implementation
Andreas Woess <andreas.woess@jku.at>
parents:
diff changeset
37 import com.oracle.truffle.object.basic.BasicLocations.LongArrayLocation;
2c3666f44855 Truffle: initial commit of object API implementation
Andreas Woess <andreas.woess@jku.at>
parents:
diff changeset
38 import com.oracle.truffle.object.basic.BasicLocations.LongFieldLocation;
2c3666f44855 Truffle: initial commit of object API implementation
Andreas Woess <andreas.woess@jku.at>
parents:
diff changeset
39 import com.oracle.truffle.object.basic.BasicLocations.ObjectArrayLocation;
2c3666f44855 Truffle: initial commit of object API implementation
Andreas Woess <andreas.woess@jku.at>
parents:
diff changeset
40
2c3666f44855 Truffle: initial commit of object API implementation
Andreas Woess <andreas.woess@jku.at>
parents:
diff changeset
41 public abstract class BasicAllocator extends ShapeImpl.BaseAllocator {
2c3666f44855 Truffle: initial commit of object API implementation
Andreas Woess <andreas.woess@jku.at>
parents:
diff changeset
42
2c3666f44855 Truffle: initial commit of object API implementation
Andreas Woess <andreas.woess@jku.at>
parents:
diff changeset
43 public BasicAllocator(LayoutImpl layout) {
2c3666f44855 Truffle: initial commit of object API implementation
Andreas Woess <andreas.woess@jku.at>
parents:
diff changeset
44 super(layout);
2c3666f44855 Truffle: initial commit of object API implementation
Andreas Woess <andreas.woess@jku.at>
parents:
diff changeset
45 advance(((BasicLayout) layout).getPrimitiveArrayLocation());
2c3666f44855 Truffle: initial commit of object API implementation
Andreas Woess <andreas.woess@jku.at>
parents:
diff changeset
46 }
2c3666f44855 Truffle: initial commit of object API implementation
Andreas Woess <andreas.woess@jku.at>
parents:
diff changeset
47
2c3666f44855 Truffle: initial commit of object API implementation
Andreas Woess <andreas.woess@jku.at>
parents:
diff changeset
48 public BasicAllocator(ShapeImpl shape) {
2c3666f44855 Truffle: initial commit of object API implementation
Andreas Woess <andreas.woess@jku.at>
parents:
diff changeset
49 super(shape);
2c3666f44855 Truffle: initial commit of object API implementation
Andreas Woess <andreas.woess@jku.at>
parents:
diff changeset
50 }
2c3666f44855 Truffle: initial commit of object API implementation
Andreas Woess <andreas.woess@jku.at>
parents:
diff changeset
51
2c3666f44855 Truffle: initial commit of object API implementation
Andreas Woess <andreas.woess@jku.at>
parents:
diff changeset
52 private BasicLayout getLayout() {
2c3666f44855 Truffle: initial commit of object API implementation
Andreas Woess <andreas.woess@jku.at>
parents:
diff changeset
53 return (BasicLayout) layout;
2c3666f44855 Truffle: initial commit of object API implementation
Andreas Woess <andreas.woess@jku.at>
parents:
diff changeset
54 }
2c3666f44855 Truffle: initial commit of object API implementation
Andreas Woess <andreas.woess@jku.at>
parents:
diff changeset
55
2c3666f44855 Truffle: initial commit of object API implementation
Andreas Woess <andreas.woess@jku.at>
parents:
diff changeset
56 @Override
2c3666f44855 Truffle: initial commit of object API implementation
Andreas Woess <andreas.woess@jku.at>
parents:
diff changeset
57 protected Location moveLocation(Location oldLocation) {
2c3666f44855 Truffle: initial commit of object API implementation
Andreas Woess <andreas.woess@jku.at>
parents:
diff changeset
58 if (oldLocation instanceof DeclaredDualLocation) {
2c3666f44855 Truffle: initial commit of object API implementation
Andreas Woess <andreas.woess@jku.at>
parents:
diff changeset
59 return advance(newDeclaredDualLocation(((DeclaredDualLocation) oldLocation).get(null, false)));
2c3666f44855 Truffle: initial commit of object API implementation
Andreas Woess <andreas.woess@jku.at>
parents:
diff changeset
60 } else if (oldLocation instanceof DualLocation) {
2c3666f44855 Truffle: initial commit of object API implementation
Andreas Woess <andreas.woess@jku.at>
parents:
diff changeset
61 return advance(newDualLocation(((DualLocation) oldLocation).getType()));
2c3666f44855 Truffle: initial commit of object API implementation
Andreas Woess <andreas.woess@jku.at>
parents:
diff changeset
62 } else if (oldLocation instanceof LongLocation) {
2c3666f44855 Truffle: initial commit of object API implementation
Andreas Woess <andreas.woess@jku.at>
parents:
diff changeset
63 return newLongLocation(oldLocation.isFinal());
2c3666f44855 Truffle: initial commit of object API implementation
Andreas Woess <andreas.woess@jku.at>
parents:
diff changeset
64 } else if (oldLocation instanceof IntLocation) {
2c3666f44855 Truffle: initial commit of object API implementation
Andreas Woess <andreas.woess@jku.at>
parents:
diff changeset
65 return newIntLocation(oldLocation.isFinal());
2c3666f44855 Truffle: initial commit of object API implementation
Andreas Woess <andreas.woess@jku.at>
parents:
diff changeset
66 } else if (oldLocation instanceof DoubleLocation) {
2c3666f44855 Truffle: initial commit of object API implementation
Andreas Woess <andreas.woess@jku.at>
parents:
diff changeset
67 return newDoubleLocation(oldLocation.isFinal());
2c3666f44855 Truffle: initial commit of object API implementation
Andreas Woess <andreas.woess@jku.at>
parents:
diff changeset
68 } else if (oldLocation instanceof BooleanLocation) {
2c3666f44855 Truffle: initial commit of object API implementation
Andreas Woess <andreas.woess@jku.at>
parents:
diff changeset
69 return newBooleanLocation(oldLocation.isFinal());
2c3666f44855 Truffle: initial commit of object API implementation
Andreas Woess <andreas.woess@jku.at>
parents:
diff changeset
70 } else if (oldLocation instanceof ObjectLocation) {
2c3666f44855 Truffle: initial commit of object API implementation
Andreas Woess <andreas.woess@jku.at>
parents:
diff changeset
71 return newObjectLocation(oldLocation.isFinal(), ((ObjectLocation) oldLocation).isNonNull());
2c3666f44855 Truffle: initial commit of object API implementation
Andreas Woess <andreas.woess@jku.at>
parents:
diff changeset
72 } else {
2c3666f44855 Truffle: initial commit of object API implementation
Andreas Woess <andreas.woess@jku.at>
parents:
diff changeset
73 assert oldLocation instanceof ValueLocation;
2c3666f44855 Truffle: initial commit of object API implementation
Andreas Woess <andreas.woess@jku.at>
parents:
diff changeset
74 return advance(oldLocation);
2c3666f44855 Truffle: initial commit of object API implementation
Andreas Woess <andreas.woess@jku.at>
parents:
diff changeset
75 }
2c3666f44855 Truffle: initial commit of object API implementation
Andreas Woess <andreas.woess@jku.at>
parents:
diff changeset
76 }
2c3666f44855 Truffle: initial commit of object API implementation
Andreas Woess <andreas.woess@jku.at>
parents:
diff changeset
77
2c3666f44855 Truffle: initial commit of object API implementation
Andreas Woess <andreas.woess@jku.at>
parents:
diff changeset
78 @Override
2c3666f44855 Truffle: initial commit of object API implementation
Andreas Woess <andreas.woess@jku.at>
parents:
diff changeset
79 public Location newObjectLocation(boolean useFinal, boolean nonNull) {
2c3666f44855 Truffle: initial commit of object API implementation
Andreas Woess <andreas.woess@jku.at>
parents:
diff changeset
80 if (ObjectStorageOptions.InObjectFields) {
2c3666f44855 Truffle: initial commit of object API implementation
Andreas Woess <andreas.woess@jku.at>
parents:
diff changeset
81 int insertPos = objectFieldSize;
2c3666f44855 Truffle: initial commit of object API implementation
Andreas Woess <andreas.woess@jku.at>
parents:
diff changeset
82 while (insertPos + OBJECT_SIZE <= getLayout().getObjectFieldCount()) {
2c3666f44855 Truffle: initial commit of object API implementation
Andreas Woess <andreas.woess@jku.at>
parents:
diff changeset
83 return advance((Location) getLayout().getObjectFieldLocation(insertPos));
2c3666f44855 Truffle: initial commit of object API implementation
Andreas Woess <andreas.woess@jku.at>
parents:
diff changeset
84 }
2c3666f44855 Truffle: initial commit of object API implementation
Andreas Woess <andreas.woess@jku.at>
parents:
diff changeset
85 }
2c3666f44855 Truffle: initial commit of object API implementation
Andreas Woess <andreas.woess@jku.at>
parents:
diff changeset
86 return newObjectArrayLocation(useFinal, nonNull);
2c3666f44855 Truffle: initial commit of object API implementation
Andreas Woess <andreas.woess@jku.at>
parents:
diff changeset
87 }
2c3666f44855 Truffle: initial commit of object API implementation
Andreas Woess <andreas.woess@jku.at>
parents:
diff changeset
88
2c3666f44855 Truffle: initial commit of object API implementation
Andreas Woess <andreas.woess@jku.at>
parents:
diff changeset
89 @SuppressWarnings("unused")
2c3666f44855 Truffle: initial commit of object API implementation
Andreas Woess <andreas.woess@jku.at>
parents:
diff changeset
90 private Location newObjectArrayLocation(boolean useFinal, boolean nonNull) {
2c3666f44855 Truffle: initial commit of object API implementation
Andreas Woess <andreas.woess@jku.at>
parents:
diff changeset
91 return advance(new ObjectArrayLocation(objectArraySize, getLayout().getObjectArrayLocation()));
2c3666f44855 Truffle: initial commit of object API implementation
Andreas Woess <andreas.woess@jku.at>
parents:
diff changeset
92 }
2c3666f44855 Truffle: initial commit of object API implementation
Andreas Woess <andreas.woess@jku.at>
parents:
diff changeset
93
2c3666f44855 Truffle: initial commit of object API implementation
Andreas Woess <andreas.woess@jku.at>
parents:
diff changeset
94 @Override
2c3666f44855 Truffle: initial commit of object API implementation
Andreas Woess <andreas.woess@jku.at>
parents:
diff changeset
95 public Location newTypedObjectLocation(boolean useFinal, Class<?> type, boolean nonNull) {
2c3666f44855 Truffle: initial commit of object API implementation
Andreas Woess <andreas.woess@jku.at>
parents:
diff changeset
96 return newObjectLocation(useFinal, nonNull);
2c3666f44855 Truffle: initial commit of object API implementation
Andreas Woess <andreas.woess@jku.at>
parents:
diff changeset
97 }
2c3666f44855 Truffle: initial commit of object API implementation
Andreas Woess <andreas.woess@jku.at>
parents:
diff changeset
98
2c3666f44855 Truffle: initial commit of object API implementation
Andreas Woess <andreas.woess@jku.at>
parents:
diff changeset
99 @Override
2c3666f44855 Truffle: initial commit of object API implementation
Andreas Woess <andreas.woess@jku.at>
parents:
diff changeset
100 public Location newIntLocation(boolean useFinal) {
2c3666f44855 Truffle: initial commit of object API implementation
Andreas Woess <andreas.woess@jku.at>
parents:
diff changeset
101 if (ObjectStorageOptions.PrimitiveLocations && ObjectStorageOptions.IntegerLocations) {
2c3666f44855 Truffle: initial commit of object API implementation
Andreas Woess <andreas.woess@jku.at>
parents:
diff changeset
102 if (ObjectStorageOptions.InObjectFields && primitiveFieldSize + LONG_SIZE <= getLayout().getPrimitiveFieldCount()) {
2c3666f44855 Truffle: initial commit of object API implementation
Andreas Woess <andreas.woess@jku.at>
parents:
diff changeset
103 return advance(new IntLocationDecorator(getLayout().getPrimitiveFieldLocation(primitiveFieldSize)));
2c3666f44855 Truffle: initial commit of object API implementation
Andreas Woess <andreas.woess@jku.at>
parents:
diff changeset
104 } else if (getLayout().hasPrimitiveExtensionArray() && isPrimitiveExtensionArrayAvailable()) {
2c3666f44855 Truffle: initial commit of object API implementation
Andreas Woess <andreas.woess@jku.at>
parents:
diff changeset
105 return advance(new IntLocationDecorator(new LongArrayLocation(primitiveArraySize, getLayout().getPrimitiveArrayLocation())));
2c3666f44855 Truffle: initial commit of object API implementation
Andreas Woess <andreas.woess@jku.at>
parents:
diff changeset
106 }
2c3666f44855 Truffle: initial commit of object API implementation
Andreas Woess <andreas.woess@jku.at>
parents:
diff changeset
107 }
2c3666f44855 Truffle: initial commit of object API implementation
Andreas Woess <andreas.woess@jku.at>
parents:
diff changeset
108 return newObjectLocation(useFinal, true);
2c3666f44855 Truffle: initial commit of object API implementation
Andreas Woess <andreas.woess@jku.at>
parents:
diff changeset
109 }
2c3666f44855 Truffle: initial commit of object API implementation
Andreas Woess <andreas.woess@jku.at>
parents:
diff changeset
110
2c3666f44855 Truffle: initial commit of object API implementation
Andreas Woess <andreas.woess@jku.at>
parents:
diff changeset
111 @Override
2c3666f44855 Truffle: initial commit of object API implementation
Andreas Woess <andreas.woess@jku.at>
parents:
diff changeset
112 public Location newDoubleLocation(boolean useFinal) {
2c3666f44855 Truffle: initial commit of object API implementation
Andreas Woess <andreas.woess@jku.at>
parents:
diff changeset
113 if (ObjectStorageOptions.PrimitiveLocations && ObjectStorageOptions.DoubleLocations) {
2c3666f44855 Truffle: initial commit of object API implementation
Andreas Woess <andreas.woess@jku.at>
parents:
diff changeset
114 if (ObjectStorageOptions.InObjectFields && primitiveFieldSize + LONG_SIZE <= getLayout().getPrimitiveFieldCount()) {
2c3666f44855 Truffle: initial commit of object API implementation
Andreas Woess <andreas.woess@jku.at>
parents:
diff changeset
115 return advance(new DoubleLocationDecorator(getLayout().getPrimitiveFieldLocation(primitiveFieldSize), getLayout().isAllowedIntToDouble()));
2c3666f44855 Truffle: initial commit of object API implementation
Andreas Woess <andreas.woess@jku.at>
parents:
diff changeset
116 } else if (getLayout().hasPrimitiveExtensionArray() && isPrimitiveExtensionArrayAvailable()) {
2c3666f44855 Truffle: initial commit of object API implementation
Andreas Woess <andreas.woess@jku.at>
parents:
diff changeset
117 return advance(new DoubleLocationDecorator(new LongArrayLocation(primitiveArraySize, getLayout().getPrimitiveArrayLocation()), getLayout().isAllowedIntToDouble()));
2c3666f44855 Truffle: initial commit of object API implementation
Andreas Woess <andreas.woess@jku.at>
parents:
diff changeset
118 }
2c3666f44855 Truffle: initial commit of object API implementation
Andreas Woess <andreas.woess@jku.at>
parents:
diff changeset
119 }
2c3666f44855 Truffle: initial commit of object API implementation
Andreas Woess <andreas.woess@jku.at>
parents:
diff changeset
120 return newObjectLocation(useFinal, true);
2c3666f44855 Truffle: initial commit of object API implementation
Andreas Woess <andreas.woess@jku.at>
parents:
diff changeset
121 }
2c3666f44855 Truffle: initial commit of object API implementation
Andreas Woess <andreas.woess@jku.at>
parents:
diff changeset
122
2c3666f44855 Truffle: initial commit of object API implementation
Andreas Woess <andreas.woess@jku.at>
parents:
diff changeset
123 @Override
2c3666f44855 Truffle: initial commit of object API implementation
Andreas Woess <andreas.woess@jku.at>
parents:
diff changeset
124 public Location newLongLocation(boolean useFinal) {
2c3666f44855 Truffle: initial commit of object API implementation
Andreas Woess <andreas.woess@jku.at>
parents:
diff changeset
125 if (ObjectStorageOptions.PrimitiveLocations && ObjectStorageOptions.LongLocations) {
2c3666f44855 Truffle: initial commit of object API implementation
Andreas Woess <andreas.woess@jku.at>
parents:
diff changeset
126 if (ObjectStorageOptions.InObjectFields && primitiveFieldSize + LONG_SIZE <= getLayout().getPrimitiveFieldCount()) {
2c3666f44855 Truffle: initial commit of object API implementation
Andreas Woess <andreas.woess@jku.at>
parents:
diff changeset
127 return advance((Location) LongFieldLocation.create(getLayout().getPrimitiveFieldLocation(primitiveFieldSize), getLayout().isAllowedIntToLong()));
2c3666f44855 Truffle: initial commit of object API implementation
Andreas Woess <andreas.woess@jku.at>
parents:
diff changeset
128 } else if (getLayout().hasPrimitiveExtensionArray() && isPrimitiveExtensionArrayAvailable()) {
2c3666f44855 Truffle: initial commit of object API implementation
Andreas Woess <andreas.woess@jku.at>
parents:
diff changeset
129 return advance(new LongArrayLocation(primitiveArraySize, getLayout().getPrimitiveArrayLocation(), getLayout().isAllowedIntToLong()));
2c3666f44855 Truffle: initial commit of object API implementation
Andreas Woess <andreas.woess@jku.at>
parents:
diff changeset
130 }
2c3666f44855 Truffle: initial commit of object API implementation
Andreas Woess <andreas.woess@jku.at>
parents:
diff changeset
131 }
2c3666f44855 Truffle: initial commit of object API implementation
Andreas Woess <andreas.woess@jku.at>
parents:
diff changeset
132 return newObjectLocation(useFinal, true);
2c3666f44855 Truffle: initial commit of object API implementation
Andreas Woess <andreas.woess@jku.at>
parents:
diff changeset
133 }
2c3666f44855 Truffle: initial commit of object API implementation
Andreas Woess <andreas.woess@jku.at>
parents:
diff changeset
134
2c3666f44855 Truffle: initial commit of object API implementation
Andreas Woess <andreas.woess@jku.at>
parents:
diff changeset
135 @Override
2c3666f44855 Truffle: initial commit of object API implementation
Andreas Woess <andreas.woess@jku.at>
parents:
diff changeset
136 public Location newBooleanLocation(boolean useFinal) {
2c3666f44855 Truffle: initial commit of object API implementation
Andreas Woess <andreas.woess@jku.at>
parents:
diff changeset
137 if (ObjectStorageOptions.PrimitiveLocations && ObjectStorageOptions.BooleanLocations) {
2c3666f44855 Truffle: initial commit of object API implementation
Andreas Woess <andreas.woess@jku.at>
parents:
diff changeset
138 if (primitiveFieldSize + LONG_SIZE <= getLayout().getPrimitiveFieldCount()) {
2c3666f44855 Truffle: initial commit of object API implementation
Andreas Woess <andreas.woess@jku.at>
parents:
diff changeset
139 return advance(new BooleanLocationDecorator(getLayout().getPrimitiveFieldLocation(primitiveFieldSize)));
2c3666f44855 Truffle: initial commit of object API implementation
Andreas Woess <andreas.woess@jku.at>
parents:
diff changeset
140 }
2c3666f44855 Truffle: initial commit of object API implementation
Andreas Woess <andreas.woess@jku.at>
parents:
diff changeset
141 }
2c3666f44855 Truffle: initial commit of object API implementation
Andreas Woess <andreas.woess@jku.at>
parents:
diff changeset
142 return newObjectLocation(useFinal, true);
2c3666f44855 Truffle: initial commit of object API implementation
Andreas Woess <andreas.woess@jku.at>
parents:
diff changeset
143 }
2c3666f44855 Truffle: initial commit of object API implementation
Andreas Woess <andreas.woess@jku.at>
parents:
diff changeset
144
2c3666f44855 Truffle: initial commit of object API implementation
Andreas Woess <andreas.woess@jku.at>
parents:
diff changeset
145 private boolean isPrimitiveExtensionArrayAvailable() {
2c3666f44855 Truffle: initial commit of object API implementation
Andreas Woess <andreas.woess@jku.at>
parents:
diff changeset
146 return hasPrimitiveArray;
2c3666f44855 Truffle: initial commit of object API implementation
Andreas Woess <andreas.woess@jku.at>
parents:
diff changeset
147 }
2c3666f44855 Truffle: initial commit of object API implementation
Andreas Woess <andreas.woess@jku.at>
parents:
diff changeset
148
2c3666f44855 Truffle: initial commit of object API implementation
Andreas Woess <andreas.woess@jku.at>
parents:
diff changeset
149 @Override
2c3666f44855 Truffle: initial commit of object API implementation
Andreas Woess <andreas.woess@jku.at>
parents:
diff changeset
150 protected Location locationForValueUpcast(Object value, Location oldLocation) {
2c3666f44855 Truffle: initial commit of object API implementation
Andreas Woess <andreas.woess@jku.at>
parents:
diff changeset
151 assert !(value instanceof Class);
2c3666f44855 Truffle: initial commit of object API implementation
Andreas Woess <andreas.woess@jku.at>
parents:
diff changeset
152 if (oldLocation instanceof DualLocation) {
2c3666f44855 Truffle: initial commit of object API implementation
Andreas Woess <andreas.woess@jku.at>
parents:
diff changeset
153 DualLocation dualLocation = (DualLocation) oldLocation;
2c3666f44855 Truffle: initial commit of object API implementation
Andreas Woess <andreas.woess@jku.at>
parents:
diff changeset
154 if (dualLocation.getType() == null) {
2c3666f44855 Truffle: initial commit of object API implementation
Andreas Woess <andreas.woess@jku.at>
parents:
diff changeset
155 if (value instanceof Integer) {
2c3666f44855 Truffle: initial commit of object API implementation
Andreas Woess <andreas.woess@jku.at>
parents:
diff changeset
156 return dualLocation.changeType(int.class);
2c3666f44855 Truffle: initial commit of object API implementation
Andreas Woess <andreas.woess@jku.at>
parents:
diff changeset
157 } else if (value instanceof Double) {
2c3666f44855 Truffle: initial commit of object API implementation
Andreas Woess <andreas.woess@jku.at>
parents:
diff changeset
158 return dualLocation.changeType(double.class);
2c3666f44855 Truffle: initial commit of object API implementation
Andreas Woess <andreas.woess@jku.at>
parents:
diff changeset
159 } else if (value instanceof Long) {
2c3666f44855 Truffle: initial commit of object API implementation
Andreas Woess <andreas.woess@jku.at>
parents:
diff changeset
160 return dualLocation.changeType(long.class);
2c3666f44855 Truffle: initial commit of object API implementation
Andreas Woess <andreas.woess@jku.at>
parents:
diff changeset
161 } else if (value instanceof Boolean) {
2c3666f44855 Truffle: initial commit of object API implementation
Andreas Woess <andreas.woess@jku.at>
parents:
diff changeset
162 return dualLocation.changeType(boolean.class);
2c3666f44855 Truffle: initial commit of object API implementation
Andreas Woess <andreas.woess@jku.at>
parents:
diff changeset
163 } else {
2c3666f44855 Truffle: initial commit of object API implementation
Andreas Woess <andreas.woess@jku.at>
parents:
diff changeset
164 return dualLocation.changeType(Object.class);
2c3666f44855 Truffle: initial commit of object API implementation
Andreas Woess <andreas.woess@jku.at>
parents:
diff changeset
165 }
2c3666f44855 Truffle: initial commit of object API implementation
Andreas Woess <andreas.woess@jku.at>
parents:
diff changeset
166 } else if (dualLocation.getType().isPrimitive()) {
2c3666f44855 Truffle: initial commit of object API implementation
Andreas Woess <andreas.woess@jku.at>
parents:
diff changeset
167 return dualLocation.changeType(Object.class);
2c3666f44855 Truffle: initial commit of object API implementation
Andreas Woess <andreas.woess@jku.at>
parents:
diff changeset
168 } else {
2c3666f44855 Truffle: initial commit of object API implementation
Andreas Woess <andreas.woess@jku.at>
parents:
diff changeset
169 throw new UnsupportedOperationException();
2c3666f44855 Truffle: initial commit of object API implementation
Andreas Woess <andreas.woess@jku.at>
parents:
diff changeset
170 }
2c3666f44855 Truffle: initial commit of object API implementation
Andreas Woess <andreas.woess@jku.at>
parents:
diff changeset
171 } else if (oldLocation instanceof ConstantLocation) {
2c3666f44855 Truffle: initial commit of object API implementation
Andreas Woess <andreas.woess@jku.at>
parents:
diff changeset
172 return constantLocation(value);
2c3666f44855 Truffle: initial commit of object API implementation
Andreas Woess <andreas.woess@jku.at>
parents:
diff changeset
173 } else {
2c3666f44855 Truffle: initial commit of object API implementation
Andreas Woess <andreas.woess@jku.at>
parents:
diff changeset
174 throw new UnsupportedOperationException();
2c3666f44855 Truffle: initial commit of object API implementation
Andreas Woess <andreas.woess@jku.at>
parents:
diff changeset
175 }
2c3666f44855 Truffle: initial commit of object API implementation
Andreas Woess <andreas.woess@jku.at>
parents:
diff changeset
176 }
2c3666f44855 Truffle: initial commit of object API implementation
Andreas Woess <andreas.woess@jku.at>
parents:
diff changeset
177
2c3666f44855 Truffle: initial commit of object API implementation
Andreas Woess <andreas.woess@jku.at>
parents:
diff changeset
178 @Override
2c3666f44855 Truffle: initial commit of object API implementation
Andreas Woess <andreas.woess@jku.at>
parents:
diff changeset
179 protected DeclaredDualLocation newDeclaredDualLocation(Object value) {
2c3666f44855 Truffle: initial commit of object API implementation
Andreas Woess <andreas.woess@jku.at>
parents:
diff changeset
180 return new DeclaredDualLocation((InternalLongLocation) newLongLocation(false), (ObjectLocation) newObjectLocation(false, false), value, layout);
2c3666f44855 Truffle: initial commit of object API implementation
Andreas Woess <andreas.woess@jku.at>
parents:
diff changeset
181 }
2c3666f44855 Truffle: initial commit of object API implementation
Andreas Woess <andreas.woess@jku.at>
parents:
diff changeset
182 }