Mercurial > hg > truffle
annotate truffle/com.oracle.truffle.object.basic/src/com/oracle/truffle/object/basic/DynamicObjectBasic.java @ 22157:dc83cc1f94f2
Using fully qualified imports
author | Jaroslav Tulach <jaroslav.tulach@oracle.com> |
---|---|
date | Wed, 16 Sep 2015 11:33:22 +0200 |
parents | af393429ae26 |
children |
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) 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 |
22157
dc83cc1f94f2
Using fully qualified imports
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22143
diff
changeset
|
25 import com.oracle.truffle.api.object.DynamicObject; |
dc83cc1f94f2
Using fully qualified imports
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22143
diff
changeset
|
26 import com.oracle.truffle.api.object.Shape; |
dc83cc1f94f2
Using fully qualified imports
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22143
diff
changeset
|
27 import com.oracle.truffle.object.DynamicObjectImpl; |
dc83cc1f94f2
Using fully qualified imports
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22143
diff
changeset
|
28 import com.oracle.truffle.object.ObjectStorageOptions; |
dc83cc1f94f2
Using fully qualified imports
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22143
diff
changeset
|
29 import com.oracle.truffle.object.ShapeImpl; |
21554
b1530a6cce8c
renamed com.oracle.graal.[debug|options|hotspotvmconfig]* modules to com.oracle.jvmci.[debug|options|hotspotvmconfig]* modules (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents:
18408
diff
changeset
|
30 import com.oracle.truffle.object.basic.BasicLocations.SimpleLongFieldLocation; |
b1530a6cce8c
renamed com.oracle.graal.[debug|options|hotspotvmconfig]* modules to com.oracle.jvmci.[debug|options|hotspotvmconfig]* modules (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents:
18408
diff
changeset
|
31 import com.oracle.truffle.object.basic.BasicLocations.SimpleObjectFieldLocation; |
22157
dc83cc1f94f2
Using fully qualified imports
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22143
diff
changeset
|
32 import java.lang.annotation.Retention; |
dc83cc1f94f2
Using fully qualified imports
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
22143
diff
changeset
|
33 import java.lang.annotation.RetentionPolicy; |
18408
2c3666f44855
Truffle: initial commit of object API implementation
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
34 |
2c3666f44855
Truffle: initial commit of object API implementation
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
35 public class DynamicObjectBasic extends DynamicObjectImpl { |
2c3666f44855
Truffle: initial commit of object API implementation
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
36 @Retention(RetentionPolicy.RUNTIME) |
2c3666f44855
Truffle: initial commit of object API implementation
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
37 protected @interface DynamicField { |
2c3666f44855
Truffle: initial commit of object API implementation
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
38 } |
2c3666f44855
Truffle: initial commit of object API implementation
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
39 |
2c3666f44855
Truffle: initial commit of object API implementation
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
40 @DynamicField private long primitive1; |
2c3666f44855
Truffle: initial commit of object API implementation
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
41 @DynamicField private long primitive2; |
2c3666f44855
Truffle: initial commit of object API implementation
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
42 @DynamicField private long primitive3; |
2c3666f44855
Truffle: initial commit of object API implementation
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
43 @DynamicField private Object object1; |
2c3666f44855
Truffle: initial commit of object API implementation
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
44 @DynamicField private Object object2; |
2c3666f44855
Truffle: initial commit of object API implementation
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
45 @DynamicField private Object object3; |
2c3666f44855
Truffle: initial commit of object API implementation
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
46 @DynamicField private Object object4; |
2c3666f44855
Truffle: initial commit of object API implementation
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
47 private Object[] objext; |
2c3666f44855
Truffle: initial commit of object API implementation
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
48 private long[] primext; |
2c3666f44855
Truffle: initial commit of object API implementation
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
49 |
2c3666f44855
Truffle: initial commit of object API implementation
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
50 public DynamicObjectBasic(Shape shape) { |
2c3666f44855
Truffle: initial commit of object API implementation
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
51 super(shape); |
2c3666f44855
Truffle: initial commit of object API implementation
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
52 } |
2c3666f44855
Truffle: initial commit of object API implementation
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
53 |
2c3666f44855
Truffle: initial commit of object API implementation
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
54 @Override |
2c3666f44855
Truffle: initial commit of object API implementation
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
55 protected final void initialize(Shape shape) { |
2c3666f44855
Truffle: initial commit of object API implementation
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
56 assert getObjectStore(shape) == null; |
2c3666f44855
Truffle: initial commit of object API implementation
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
57 int capacity = ((ShapeImpl) shape).getObjectArrayCapacity(); |
2c3666f44855
Truffle: initial commit of object API implementation
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
58 if (capacity != 0) { |
2c3666f44855
Truffle: initial commit of object API implementation
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
59 this.setObjectStore(new Object[capacity], shape); |
2c3666f44855
Truffle: initial commit of object API implementation
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
60 } |
2c3666f44855
Truffle: initial commit of object API implementation
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
61 if (((ShapeImpl) shape).getPrimitiveArrayCapacity() != 0) { |
2c3666f44855
Truffle: initial commit of object API implementation
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
62 this.setPrimitiveStore(new long[((ShapeImpl) shape).getPrimitiveArrayCapacity()], shape); |
2c3666f44855
Truffle: initial commit of object API implementation
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
63 } |
2c3666f44855
Truffle: initial commit of object API implementation
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
64 } |
2c3666f44855
Truffle: initial commit of object API implementation
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
65 |
2c3666f44855
Truffle: initial commit of object API implementation
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
66 /** |
2c3666f44855
Truffle: initial commit of object API implementation
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
67 * Simpler version of {@link #resizeObjectStore} when the object is only increasing in size. |
2c3666f44855
Truffle: initial commit of object API implementation
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
68 */ |
2c3666f44855
Truffle: initial commit of object API implementation
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
69 @Override |
2c3666f44855
Truffle: initial commit of object API implementation
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
70 protected final void growObjectStore(Shape oldShape, Shape newShape) { |
2c3666f44855
Truffle: initial commit of object API implementation
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
71 int oldObjectArrayCapacity = ((ShapeImpl) oldShape).getObjectArrayCapacity(); |
2c3666f44855
Truffle: initial commit of object API implementation
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
72 int newObjectArrayCapacity = ((ShapeImpl) newShape).getObjectArrayCapacity(); |
2c3666f44855
Truffle: initial commit of object API implementation
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
73 if (oldObjectArrayCapacity != newObjectArrayCapacity) { |
2c3666f44855
Truffle: initial commit of object API implementation
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
74 growObjectStoreIntl(oldObjectArrayCapacity, newObjectArrayCapacity, oldShape); |
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 private void growObjectStoreIntl(int oldObjectArrayCapacity, int newObjectArrayCapacity, Shape newShape) { |
2c3666f44855
Truffle: initial commit of object API implementation
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
79 Object[] newObjectStore = new Object[newObjectArrayCapacity]; |
2c3666f44855
Truffle: initial commit of object API implementation
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
80 if (oldObjectArrayCapacity != 0) { |
2c3666f44855
Truffle: initial commit of object API implementation
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
81 // monotonic growth assumption |
2c3666f44855
Truffle: initial commit of object API implementation
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
82 assert oldObjectArrayCapacity < newObjectArrayCapacity; |
2c3666f44855
Truffle: initial commit of object API implementation
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
83 Object[] oldObjectStore = this.getObjectStore(newShape); |
2c3666f44855
Truffle: initial commit of object API implementation
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
84 for (int i = 0; i < oldObjectArrayCapacity; ++i) { |
2c3666f44855
Truffle: initial commit of object API implementation
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
85 newObjectStore[i] = oldObjectStore[i]; |
2c3666f44855
Truffle: initial commit of object API implementation
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
86 } |
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 this.setObjectStore(newObjectStore, newShape); |
2c3666f44855
Truffle: initial commit of object API implementation
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
89 } |
2c3666f44855
Truffle: initial commit of object API implementation
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
90 |
2c3666f44855
Truffle: initial commit of object API implementation
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
91 /** |
2c3666f44855
Truffle: initial commit of object API implementation
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
92 * Simpler version of {@link #resizePrimitiveStore} when the object is only increasing in size. |
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 protected final void growPrimitiveStore(Shape oldShape, Shape newShape) { |
2c3666f44855
Truffle: initial commit of object API implementation
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
96 assert ((ShapeImpl) newShape).hasPrimitiveArray(); |
22143
af393429ae26
removed 7 Shape methods from the API
Andreas Woess <andreas.woess@oracle.com>
parents:
21951
diff
changeset
|
97 int oldPrimitiveCapacity = ((ShapeImpl) oldShape).getPrimitiveArrayCapacity(); |
af393429ae26
removed 7 Shape methods from the API
Andreas Woess <andreas.woess@oracle.com>
parents:
21951
diff
changeset
|
98 int newPrimitiveCapacity = ((ShapeImpl) newShape).getPrimitiveArrayCapacity(); |
18408
2c3666f44855
Truffle: initial commit of object API implementation
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
99 if (newPrimitiveCapacity == 0) { |
2c3666f44855
Truffle: initial commit of object API implementation
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
100 // due to obsolescence, we might have to reserve an empty primitive array slot |
2c3666f44855
Truffle: initial commit of object API implementation
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
101 this.setPrimitiveStore(null, newShape); |
2c3666f44855
Truffle: initial commit of object API implementation
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
102 } else if (oldPrimitiveCapacity != newPrimitiveCapacity) { |
2c3666f44855
Truffle: initial commit of object API implementation
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
103 growPrimitiveStoreIntl(oldPrimitiveCapacity, newPrimitiveCapacity, oldShape); |
2c3666f44855
Truffle: initial commit of object API implementation
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
104 } |
2c3666f44855
Truffle: initial commit of object API implementation
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
105 } |
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 private void growPrimitiveStoreIntl(int oldPrimitiveCapacity, int newPrimitiveCapacity, Shape newShape) { |
2c3666f44855
Truffle: initial commit of object API implementation
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
108 long[] newPrimitiveArray = new long[newPrimitiveCapacity]; |
2c3666f44855
Truffle: initial commit of object API implementation
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
109 if (oldPrimitiveCapacity != 0) { |
2c3666f44855
Truffle: initial commit of object API implementation
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
110 // primitive array can shrink due to type changes |
2c3666f44855
Truffle: initial commit of object API implementation
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
111 long[] oldPrimitiveArray = this.getPrimitiveStore(newShape); |
2c3666f44855
Truffle: initial commit of object API implementation
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
112 for (int i = 0; i < Math.min(oldPrimitiveCapacity, newPrimitiveCapacity); ++i) { |
2c3666f44855
Truffle: initial commit of object API implementation
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
113 newPrimitiveArray[i] = oldPrimitiveArray[i]; |
2c3666f44855
Truffle: initial commit of object API implementation
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
114 } |
2c3666f44855
Truffle: initial commit of object API implementation
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
115 } |
2c3666f44855
Truffle: initial commit of object API implementation
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
116 this.setPrimitiveStore(newPrimitiveArray, newShape); |
2c3666f44855
Truffle: initial commit of object API implementation
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
117 } |
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 @Override |
2c3666f44855
Truffle: initial commit of object API implementation
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
120 protected final void resizeObjectStore(Shape oldShape, Shape newShape) { |
2c3666f44855
Truffle: initial commit of object API implementation
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
121 Object[] newObjectStore = null; |
22143
af393429ae26
removed 7 Shape methods from the API
Andreas Woess <andreas.woess@oracle.com>
parents:
21951
diff
changeset
|
122 int destinationCapacity = ((ShapeImpl) newShape).getObjectArrayCapacity(); |
18408
2c3666f44855
Truffle: initial commit of object API implementation
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
123 if (destinationCapacity != 0) { |
2c3666f44855
Truffle: initial commit of object API implementation
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
124 newObjectStore = new Object[destinationCapacity]; |
22143
af393429ae26
removed 7 Shape methods from the API
Andreas Woess <andreas.woess@oracle.com>
parents:
21951
diff
changeset
|
125 int sourceCapacity = ((ShapeImpl) oldShape).getObjectArrayCapacity(); |
18408
2c3666f44855
Truffle: initial commit of object API implementation
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
126 if (sourceCapacity != 0) { |
2c3666f44855
Truffle: initial commit of object API implementation
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
127 Object[] oldObjectStore = getObjectStore(newShape); |
2c3666f44855
Truffle: initial commit of object API implementation
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
128 for (int i = 0; i < Math.min(sourceCapacity, destinationCapacity); ++i) { |
2c3666f44855
Truffle: initial commit of object API implementation
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
129 newObjectStore[i] = oldObjectStore[i]; |
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 } |
2c3666f44855
Truffle: initial commit of object API implementation
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
133 this.setObjectStore(newObjectStore, newShape); |
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 |
2c3666f44855
Truffle: initial commit of object API implementation
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
136 private Object[] getObjectStore(@SuppressWarnings("unused") Shape currentShape) { |
2c3666f44855
Truffle: initial commit of object API implementation
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
137 return objext; |
2c3666f44855
Truffle: initial commit of object API implementation
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
138 } |
2c3666f44855
Truffle: initial commit of object API implementation
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
139 |
2c3666f44855
Truffle: initial commit of object API implementation
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
140 private void setObjectStore(Object[] newArray, @SuppressWarnings("unused") Shape currentShape) { |
2c3666f44855
Truffle: initial commit of object API implementation
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
141 objext = newArray; |
2c3666f44855
Truffle: initial commit of object API implementation
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
142 } |
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 private long[] getPrimitiveStore(@SuppressWarnings("unused") Shape currentShape) { |
2c3666f44855
Truffle: initial commit of object API implementation
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
145 return primext; |
2c3666f44855
Truffle: initial commit of object API implementation
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
146 } |
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 private void setPrimitiveStore(long[] newArray, @SuppressWarnings("unused") Shape currentShape) { |
2c3666f44855
Truffle: initial commit of object API implementation
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
149 primext = newArray; |
2c3666f44855
Truffle: initial commit of object API implementation
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
150 } |
2c3666f44855
Truffle: initial commit of object API implementation
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
151 |
2c3666f44855
Truffle: initial commit of object API implementation
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
152 @Override |
2c3666f44855
Truffle: initial commit of object API implementation
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
153 protected final void resizePrimitiveStore(Shape oldShape, Shape newShape) { |
22143
af393429ae26
removed 7 Shape methods from the API
Andreas Woess <andreas.woess@oracle.com>
parents:
21951
diff
changeset
|
154 assert ((ShapeImpl) newShape).hasPrimitiveArray(); |
18408
2c3666f44855
Truffle: initial commit of object API implementation
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
155 long[] newPrimitiveArray = null; |
22143
af393429ae26
removed 7 Shape methods from the API
Andreas Woess <andreas.woess@oracle.com>
parents:
21951
diff
changeset
|
156 int destinationCapacity = ((ShapeImpl) newShape).getPrimitiveArrayCapacity(); |
18408
2c3666f44855
Truffle: initial commit of object API implementation
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
157 if (destinationCapacity != 0) { |
2c3666f44855
Truffle: initial commit of object API implementation
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
158 newPrimitiveArray = new long[destinationCapacity]; |
22143
af393429ae26
removed 7 Shape methods from the API
Andreas Woess <andreas.woess@oracle.com>
parents:
21951
diff
changeset
|
159 int sourceCapacity = ((ShapeImpl) oldShape).getPrimitiveArrayCapacity(); |
18408
2c3666f44855
Truffle: initial commit of object API implementation
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
160 if (sourceCapacity != 0) { |
2c3666f44855
Truffle: initial commit of object API implementation
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
161 long[] oldPrimitiveArray = this.getPrimitiveStore(newShape); |
2c3666f44855
Truffle: initial commit of object API implementation
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
162 for (int i = 0; i < Math.min(sourceCapacity, destinationCapacity); ++i) { |
2c3666f44855
Truffle: initial commit of object API implementation
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
163 newPrimitiveArray[i] = oldPrimitiveArray[i]; |
2c3666f44855
Truffle: initial commit of object API implementation
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
164 } |
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 } |
2c3666f44855
Truffle: initial commit of object API implementation
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
167 this.setPrimitiveStore(newPrimitiveArray, newShape); |
2c3666f44855
Truffle: initial commit of object API implementation
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
168 } |
2c3666f44855
Truffle: initial commit of object API implementation
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
169 |
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 * Check whether fast transition is valid. |
2c3666f44855
Truffle: initial commit of object API implementation
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
172 * |
2c3666f44855
Truffle: initial commit of object API implementation
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
173 * @see #setShapeAndGrow |
2c3666f44855
Truffle: initial commit of object API implementation
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
174 */ |
2c3666f44855
Truffle: initial commit of object API implementation
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
175 @SuppressWarnings("unused") |
2c3666f44855
Truffle: initial commit of object API implementation
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
176 private boolean checkSetShape(Shape oldShape, Shape newShape) { |
2c3666f44855
Truffle: initial commit of object API implementation
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
177 Shape currentShape = getShape(); |
2c3666f44855
Truffle: initial commit of object API implementation
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
178 assert oldShape != newShape : "Wrong old shape assumption?"; |
2c3666f44855
Truffle: initial commit of object API implementation
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
179 assert newShape != currentShape : "Redundant shape change? shape=" + currentShape; |
2c3666f44855
Truffle: initial commit of object API implementation
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
180 assert oldShape == currentShape || oldShape.getParent() == currentShape : "Out-of-order shape change?" + "\nparentShape=" + currentShape + "\noldShape=" + oldShape + "\nnewShape=" + newShape; |
2c3666f44855
Truffle: initial commit of object API implementation
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
181 return true; |
2c3666f44855
Truffle: initial commit of object API implementation
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
182 } |
2c3666f44855
Truffle: initial commit of object API implementation
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
183 |
2c3666f44855
Truffle: initial commit of object API implementation
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
184 /** |
2c3666f44855
Truffle: initial commit of object API implementation
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
185 * Check whether the extension arrays are in accordance with the description in the shape. |
2c3666f44855
Truffle: initial commit of object API implementation
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
186 */ |
2c3666f44855
Truffle: initial commit of object API implementation
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
187 @Override |
2c3666f44855
Truffle: initial commit of object API implementation
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
188 protected final boolean checkExtensionArrayInvariants(Shape newShape) { |
2c3666f44855
Truffle: initial commit of object API implementation
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
189 assert getShape() == newShape; |
22143
af393429ae26
removed 7 Shape methods from the API
Andreas Woess <andreas.woess@oracle.com>
parents:
21951
diff
changeset
|
190 assert (getObjectStore(newShape) == null && ((ShapeImpl) newShape).getObjectArrayCapacity() == 0) || |
af393429ae26
removed 7 Shape methods from the API
Andreas Woess <andreas.woess@oracle.com>
parents:
21951
diff
changeset
|
191 (getObjectStore(newShape) != null && getObjectStore(newShape).length == ((ShapeImpl) newShape).getObjectArrayCapacity()); |
af393429ae26
removed 7 Shape methods from the API
Andreas Woess <andreas.woess@oracle.com>
parents:
21951
diff
changeset
|
192 if (((ShapeImpl) newShape).hasPrimitiveArray()) { |
af393429ae26
removed 7 Shape methods from the API
Andreas Woess <andreas.woess@oracle.com>
parents:
21951
diff
changeset
|
193 assert (getPrimitiveStore(newShape) == null && ((ShapeImpl) newShape).getPrimitiveArrayCapacity() == 0) || |
af393429ae26
removed 7 Shape methods from the API
Andreas Woess <andreas.woess@oracle.com>
parents:
21951
diff
changeset
|
194 (getPrimitiveStore(newShape) != null && getPrimitiveStore(newShape).length == ((ShapeImpl) newShape).getPrimitiveArrayCapacity()); |
18408
2c3666f44855
Truffle: initial commit of object API implementation
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
195 } |
2c3666f44855
Truffle: initial commit of object API implementation
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
196 return true; |
2c3666f44855
Truffle: initial commit of object API implementation
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
197 } |
2c3666f44855
Truffle: initial commit of object API implementation
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
198 |
2c3666f44855
Truffle: initial commit of object API implementation
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
199 @Override |
2c3666f44855
Truffle: initial commit of object API implementation
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
200 protected final DynamicObject cloneWithShape(Shape currentShape) { |
2c3666f44855
Truffle: initial commit of object API implementation
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
201 assert this.getShape() == currentShape; |
2c3666f44855
Truffle: initial commit of object API implementation
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
202 final DynamicObjectBasic clone = (DynamicObjectBasic) super.clone(); |
2c3666f44855
Truffle: initial commit of object API implementation
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
203 if (this.getObjectStore(currentShape) != null) { |
2c3666f44855
Truffle: initial commit of object API implementation
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
204 clone.setObjectStore(this.getObjectStore(currentShape).clone(), currentShape); |
2c3666f44855
Truffle: initial commit of object API implementation
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
205 } |
22143
af393429ae26
removed 7 Shape methods from the API
Andreas Woess <andreas.woess@oracle.com>
parents:
21951
diff
changeset
|
206 if (((ShapeImpl) currentShape).hasPrimitiveArray() && this.getPrimitiveStore(currentShape) != null) { |
18408
2c3666f44855
Truffle: initial commit of object API implementation
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
207 clone.setPrimitiveStore(this.getPrimitiveStore(currentShape).clone(), currentShape); |
2c3666f44855
Truffle: initial commit of object API implementation
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
208 } |
2c3666f44855
Truffle: initial commit of object API implementation
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
209 return clone; |
2c3666f44855
Truffle: initial commit of object API implementation
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
210 } |
2c3666f44855
Truffle: initial commit of object API implementation
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
211 |
2c3666f44855
Truffle: initial commit of object API implementation
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
212 protected final void reshape(ShapeImpl newShape) { |
2c3666f44855
Truffle: initial commit of object API implementation
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
213 reshapeCount.inc(); |
2c3666f44855
Truffle: initial commit of object API implementation
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
214 |
2c3666f44855
Truffle: initial commit of object API implementation
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
215 ShapeImpl oldShape = getShape(); |
2c3666f44855
Truffle: initial commit of object API implementation
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
216 ShapeImpl commonAncestor = ShapeImpl.findCommonAncestor(oldShape, newShape); |
2c3666f44855
Truffle: initial commit of object API implementation
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
217 if (ObjectStorageOptions.TraceReshape) { |
2c3666f44855
Truffle: initial commit of object API implementation
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
218 int limit = 150; |
2c3666f44855
Truffle: initial commit of object API implementation
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
219 System.out.printf("RESHAPE\nOLD %s\nNEW %s\nLCA %s\nDIFF %s\n---\n", oldShape.toStringLimit(limit), newShape.toStringLimit(limit), commonAncestor.toStringLimit(limit), |
2c3666f44855
Truffle: initial commit of object API implementation
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
220 ShapeImpl.diff(oldShape, newShape)); |
2c3666f44855
Truffle: initial commit of object API implementation
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
221 } |
2c3666f44855
Truffle: initial commit of object API implementation
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
222 |
2c3666f44855
Truffle: initial commit of object API implementation
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
223 DynamicObject original = this.cloneWithShape(oldShape); |
2c3666f44855
Truffle: initial commit of object API implementation
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
224 setShapeAndGrow(oldShape, newShape); |
2c3666f44855
Truffle: initial commit of object API implementation
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
225 assert !((newShape.hasPrimitiveArray() && newShape.getPrimitiveArrayCapacity() == 0)) || getPrimitiveStore(newShape) == null; |
2c3666f44855
Truffle: initial commit of object API implementation
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
226 copyProperties(original, commonAncestor); |
2c3666f44855
Truffle: initial commit of object API implementation
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
227 assert checkExtensionArrayInvariants(newShape); |
2c3666f44855
Truffle: initial commit of object API implementation
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
228 } |
2c3666f44855
Truffle: initial commit of object API implementation
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
229 |
2c3666f44855
Truffle: initial commit of object API implementation
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
230 static final SimpleObjectFieldLocation[] OBJECT_FIELD_LOCATIONS; |
2c3666f44855
Truffle: initial commit of object API implementation
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
231 static final SimpleLongFieldLocation[] PRIMITIVE_FIELD_LOCATIONS; |
2c3666f44855
Truffle: initial commit of object API implementation
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
232 |
2c3666f44855
Truffle: initial commit of object API implementation
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
233 static final SimpleObjectFieldLocation OBJECT_ARRAY_LOCATION; |
2c3666f44855
Truffle: initial commit of object API implementation
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
234 static final SimpleObjectFieldLocation PRIMITIVE_ARRAY_LOCATION; |
2c3666f44855
Truffle: initial commit of object API implementation
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
235 |
2c3666f44855
Truffle: initial commit of object API implementation
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
236 static { |
2c3666f44855
Truffle: initial commit of object API implementation
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
237 int index; |
2c3666f44855
Truffle: initial commit of object API implementation
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
238 |
2c3666f44855
Truffle: initial commit of object API implementation
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
239 index = 0; |
2c3666f44855
Truffle: initial commit of object API implementation
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
240 PRIMITIVE_FIELD_LOCATIONS = new SimpleLongFieldLocation[]{new SimpleLongFieldLocation(index++) { |
2c3666f44855
Truffle: initial commit of object API implementation
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
241 @Override |
2c3666f44855
Truffle: initial commit of object API implementation
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
242 public long getLong(DynamicObject store, boolean condition) { |
2c3666f44855
Truffle: initial commit of object API implementation
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
243 return ((DynamicObjectBasic) store).primitive1; |
2c3666f44855
Truffle: initial commit of object API implementation
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
244 } |
2c3666f44855
Truffle: initial commit of object API implementation
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
245 |
2c3666f44855
Truffle: initial commit of object API implementation
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
246 @Override |
2c3666f44855
Truffle: initial commit of object API implementation
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
247 public void setLongInternal(DynamicObject store, long value) { |
2c3666f44855
Truffle: initial commit of object API implementation
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
248 ((DynamicObjectBasic) store).primitive1 = value; |
2c3666f44855
Truffle: initial commit of object API implementation
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
249 } |
2c3666f44855
Truffle: initial commit of object API implementation
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
250 }, new SimpleLongFieldLocation(index++) { |
2c3666f44855
Truffle: initial commit of object API implementation
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
251 @Override |
2c3666f44855
Truffle: initial commit of object API implementation
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
252 public long getLong(DynamicObject store, boolean condition) { |
2c3666f44855
Truffle: initial commit of object API implementation
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
253 return ((DynamicObjectBasic) store).primitive2; |
2c3666f44855
Truffle: initial commit of object API implementation
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
254 } |
2c3666f44855
Truffle: initial commit of object API implementation
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
255 |
2c3666f44855
Truffle: initial commit of object API implementation
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
256 @Override |
2c3666f44855
Truffle: initial commit of object API implementation
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
257 public void setLongInternal(DynamicObject store, long value) { |
2c3666f44855
Truffle: initial commit of object API implementation
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
258 ((DynamicObjectBasic) store).primitive2 = value; |
2c3666f44855
Truffle: initial commit of object API implementation
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
259 } |
2c3666f44855
Truffle: initial commit of object API implementation
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
260 }, new SimpleLongFieldLocation(index++) { |
2c3666f44855
Truffle: initial commit of object API implementation
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
261 @Override |
2c3666f44855
Truffle: initial commit of object API implementation
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
262 public long getLong(DynamicObject store, boolean condition) { |
2c3666f44855
Truffle: initial commit of object API implementation
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
263 return ((DynamicObjectBasic) store).primitive3; |
2c3666f44855
Truffle: initial commit of object API implementation
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
264 } |
2c3666f44855
Truffle: initial commit of object API implementation
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
265 |
2c3666f44855
Truffle: initial commit of object API implementation
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
266 @Override |
2c3666f44855
Truffle: initial commit of object API implementation
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
267 public void setLongInternal(DynamicObject store, long value) { |
2c3666f44855
Truffle: initial commit of object API implementation
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
268 ((DynamicObjectBasic) store).primitive3 = value; |
2c3666f44855
Truffle: initial commit of object API implementation
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
269 } |
2c3666f44855
Truffle: initial commit of object API implementation
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
270 }}; |
2c3666f44855
Truffle: initial commit of object API implementation
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
271 |
2c3666f44855
Truffle: initial commit of object API implementation
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
272 index = 0; |
2c3666f44855
Truffle: initial commit of object API implementation
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
273 OBJECT_FIELD_LOCATIONS = new SimpleObjectFieldLocation[]{new SimpleObjectFieldLocation(index++) { |
2c3666f44855
Truffle: initial commit of object API implementation
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
274 @Override |
2c3666f44855
Truffle: initial commit of object API implementation
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
275 public Object get(DynamicObject store, boolean condition) { |
2c3666f44855
Truffle: initial commit of object API implementation
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
276 return ((DynamicObjectBasic) store).object1; |
2c3666f44855
Truffle: initial commit of object API implementation
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
277 } |
2c3666f44855
Truffle: initial commit of object API implementation
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
278 |
2c3666f44855
Truffle: initial commit of object API implementation
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
279 @Override |
2c3666f44855
Truffle: initial commit of object API implementation
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
280 public void setInternal(DynamicObject store, Object value) { |
2c3666f44855
Truffle: initial commit of object API implementation
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
281 ((DynamicObjectBasic) store).object1 = value; |
2c3666f44855
Truffle: initial commit of object API implementation
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
282 } |
2c3666f44855
Truffle: initial commit of object API implementation
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
283 }, new SimpleObjectFieldLocation(index++) { |
2c3666f44855
Truffle: initial commit of object API implementation
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
284 @Override |
2c3666f44855
Truffle: initial commit of object API implementation
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
285 public Object get(DynamicObject store, boolean condition) { |
2c3666f44855
Truffle: initial commit of object API implementation
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
286 return ((DynamicObjectBasic) store).object2; |
2c3666f44855
Truffle: initial commit of object API implementation
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
287 } |
2c3666f44855
Truffle: initial commit of object API implementation
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
288 |
2c3666f44855
Truffle: initial commit of object API implementation
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
289 @Override |
2c3666f44855
Truffle: initial commit of object API implementation
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
290 public void setInternal(DynamicObject store, Object value) { |
2c3666f44855
Truffle: initial commit of object API implementation
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
291 ((DynamicObjectBasic) store).object2 = value; |
2c3666f44855
Truffle: initial commit of object API implementation
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
292 } |
2c3666f44855
Truffle: initial commit of object API implementation
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
293 }, new SimpleObjectFieldLocation(index++) { |
2c3666f44855
Truffle: initial commit of object API implementation
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
294 @Override |
2c3666f44855
Truffle: initial commit of object API implementation
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
295 public Object get(DynamicObject store, boolean condition) { |
2c3666f44855
Truffle: initial commit of object API implementation
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
296 return ((DynamicObjectBasic) store).object3; |
2c3666f44855
Truffle: initial commit of object API implementation
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
297 } |
2c3666f44855
Truffle: initial commit of object API implementation
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
298 |
2c3666f44855
Truffle: initial commit of object API implementation
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
299 @Override |
2c3666f44855
Truffle: initial commit of object API implementation
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
300 public void setInternal(DynamicObject store, Object value) { |
2c3666f44855
Truffle: initial commit of object API implementation
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
301 ((DynamicObjectBasic) store).object3 = value; |
2c3666f44855
Truffle: initial commit of object API implementation
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
302 } |
2c3666f44855
Truffle: initial commit of object API implementation
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
303 }, new SimpleObjectFieldLocation(index++) { |
2c3666f44855
Truffle: initial commit of object API implementation
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
304 @Override |
2c3666f44855
Truffle: initial commit of object API implementation
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
305 public Object get(DynamicObject store, boolean condition) { |
2c3666f44855
Truffle: initial commit of object API implementation
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
306 return ((DynamicObjectBasic) store).object4; |
2c3666f44855
Truffle: initial commit of object API implementation
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
307 } |
2c3666f44855
Truffle: initial commit of object API implementation
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
308 |
2c3666f44855
Truffle: initial commit of object API implementation
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
309 @Override |
2c3666f44855
Truffle: initial commit of object API implementation
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
310 public void setInternal(DynamicObject store, Object value) { |
2c3666f44855
Truffle: initial commit of object API implementation
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
311 ((DynamicObjectBasic) store).object4 = value; |
2c3666f44855
Truffle: initial commit of object API implementation
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
312 } |
2c3666f44855
Truffle: initial commit of object API implementation
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
313 }}; |
2c3666f44855
Truffle: initial commit of object API implementation
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
314 |
2c3666f44855
Truffle: initial commit of object API implementation
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
315 OBJECT_ARRAY_LOCATION = new SimpleObjectFieldLocation(index++) { |
2c3666f44855
Truffle: initial commit of object API implementation
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
316 @Override |
2c3666f44855
Truffle: initial commit of object API implementation
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
317 public Object[] get(DynamicObject store, boolean condition) { |
2c3666f44855
Truffle: initial commit of object API implementation
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
318 return ((DynamicObjectBasic) store).objext; |
2c3666f44855
Truffle: initial commit of object API implementation
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
319 } |
2c3666f44855
Truffle: initial commit of object API implementation
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
320 |
2c3666f44855
Truffle: initial commit of object API implementation
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
321 @Override |
2c3666f44855
Truffle: initial commit of object API implementation
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
322 public void setInternal(DynamicObject store, Object value) { |
2c3666f44855
Truffle: initial commit of object API implementation
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
323 ((DynamicObjectBasic) store).objext = (Object[]) value; |
2c3666f44855
Truffle: initial commit of object API implementation
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
324 } |
2c3666f44855
Truffle: initial commit of object API implementation
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
325 }; |
2c3666f44855
Truffle: initial commit of object API implementation
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
326 |
2c3666f44855
Truffle: initial commit of object API implementation
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
327 PRIMITIVE_ARRAY_LOCATION = new SimpleObjectFieldLocation(index++) { |
2c3666f44855
Truffle: initial commit of object API implementation
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
328 @Override |
2c3666f44855
Truffle: initial commit of object API implementation
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
329 public long[] get(DynamicObject store, boolean condition) { |
2c3666f44855
Truffle: initial commit of object API implementation
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
330 return ((DynamicObjectBasic) store).primext; |
2c3666f44855
Truffle: initial commit of object API implementation
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
331 } |
2c3666f44855
Truffle: initial commit of object API implementation
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
332 |
2c3666f44855
Truffle: initial commit of object API implementation
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
333 @Override |
2c3666f44855
Truffle: initial commit of object API implementation
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
334 public void setInternal(DynamicObject store, Object value) { |
2c3666f44855
Truffle: initial commit of object API implementation
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
335 ((DynamicObjectBasic) store).primext = (long[]) value; |
2c3666f44855
Truffle: initial commit of object API implementation
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
336 } |
2c3666f44855
Truffle: initial commit of object API implementation
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
337 }; |
2c3666f44855
Truffle: initial commit of object API implementation
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
338 } |
2c3666f44855
Truffle: initial commit of object API implementation
Andreas Woess <andreas.woess@jku.at>
parents:
diff
changeset
|
339 } |