Skip to content

Commit 68cdf48

Browse files
committed
update for new R model
1 parent ed83281 commit 68cdf48

File tree

2 files changed

+28
-56
lines changed

2 files changed

+28
-56
lines changed

visualvm/heapviewer.truffle/src/org/graalvm/visualvm/heapviewer/truffle/lang/r/RDetailsProvider.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ public RDetailsProvider() {
7070

7171
public String getDetailsString(String className, Instance instance, Heap heap) {
7272
if (RVECTOR_MASK.equals(className) || RABSTRACT_VECTOR_MASK.equals(className)) {
73-
Object rawData = instance.getValueOfField("data"); // NOI18N
73+
Object rawData = RObject.findDataField(instance);
7474

7575
if (rawData != null) {
7676
int size;

visualvm/heapviewer.truffle/src/org/graalvm/visualvm/heapviewer/truffle/lang/r/RObject.java

Lines changed: 27 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -129,22 +129,22 @@ public RObject(Instance instance) {
129129
public RObject(String type, Instance instance) {
130130
this.instance = instance;
131131
this.type = type;
132-
133-
Object[] values = HeapUtils.getValuesOfFields(instance, "data", "complete", "refCount", "attributes", "frameAccess"); // NOI18N
134-
135-
data = (Instance) values[0];
136-
137-
Object completeO = values[1];
132+
133+
data = findDataField(instance);
134+
135+
Object[] values = HeapUtils.getValuesOfFields(instance, "complete", "refCount", "attributes", "frameAccess"); // NOI18N
136+
137+
Object completeO = values[0];
138138
complete = completeO == null ? null : Boolean.parseBoolean(completeO.toString());
139139

140-
Object refCountO = values[2];
140+
Object refCountO = values[1];
141141
refCount = refCountO == null ? null : Integer.parseInt(refCountO.toString());
142142

143-
attributesInstance = (Instance) values[3];
143+
attributesInstance = (Instance) values[2];
144144
className = instance.getJavaClass().getName();
145145
dataType = data == null ? null : data.getJavaClass().getName().replace("[]", ""); // NOI18N
146146
fieldValues = new LazyFieldValues();
147-
Instance frameAccess = (Instance) values[4];
147+
Instance frameAccess = (Instance) values[3];
148148
if (frameAccess != null) {
149149
frameInstance = (Instance) frameAccess.getValueOfField("frame"); // NOI18N
150150
} else {
@@ -156,52 +156,6 @@ public RObject(String type, Instance instance) {
156156
if (data == null && isSubClassOf(instance, R_WRAPPER_FQN)) {
157157
data = getDataFromWrapper(instance);
158158
}
159-
160-
// Map values = HeapUtils.getValuesOfFields(instance, "data", "complete", "refCount", "attributes", "frameAccess", "frame");
161-
//
162-
// data = (Instance) values.get("data"); // NOI18N
163-
//
164-
// Object completeO = values.get("complete"); // NOI18N
165-
// complete = completeO == null ? null : Boolean.parseBoolean(completeO.toString());
166-
//
167-
// Object refCountO = values.get("refCount"); // NOI18N
168-
// refCount = refCountO == null ? null : Integer.parseInt(refCountO.toString());
169-
// attributesInstance = (Instance) values.get("attributes"); // NOI18N
170-
// className = instance.getJavaClass().getName();
171-
// dataType = data == null ? null : data.getJavaClass().getName().replace("[]", ""); // NOI18N
172-
// fieldValues = new LazyFieldValues();
173-
// Instance frameAccess = (Instance) values.get("frameAccess"); // NOI18N
174-
// if (frameAccess != null) {
175-
// frameInstance = (Instance) values.get("frame");
176-
// } else {
177-
// frameInstance = null;
178-
// }
179-
// if (data == null && RPAIR_LIST_FQN.equals(className)) {
180-
// data = new RPairList(instance);
181-
// }
182-
// if (data == null && isSubClassOf(instance, R_WRAPPER_FQN)) {
183-
// data = getDataFromWrapper(instance);
184-
// }
185-
186-
// data = (Instance) instance.getValueOfField("data"); // NOI18N
187-
// complete = (Boolean) instance.getValueOfField("complete"); // NOI18N
188-
// refCount = (Integer) instance.getValueOfField("refCount"); // NOI18N
189-
// attributesInstance = (Instance) instance.getValueOfField("attributes"); // NOI18N
190-
// className = instance.getJavaClass().getName();
191-
// dataType = data == null ? null : data.getJavaClass().getName().replace("[]", ""); // NOI18N
192-
// fieldValues = new LazyFieldValues();
193-
// Instance frameAccess = (Instance) instance.getValueOfField("frameAccess"); // NOI18N
194-
// if (frameAccess != null) {
195-
// frameInstance = (Instance) frameAccess.getValueOfField("frame");
196-
// } else {
197-
// frameInstance = null;
198-
// }
199-
// if (data == null && RPAIR_LIST_FQN.equals(className)) {
200-
// data = new RPairList(instance);
201-
// }
202-
// if (data == null && isSubClassOf(instance, R_WRAPPER_FQN)) {
203-
// data = getDataFromWrapper(instance);
204-
// }
205159
}
206160

207161

@@ -525,6 +479,24 @@ static Instance getDataFromWrapper(Instance instance) {
525479
return null;
526480
}
527481

482+
static Instance findDataField(Instance instance) {
483+
for (Object val : instance.getFieldValues()) {
484+
FieldValue fv = (FieldValue) val;
485+
486+
if (fv instanceof ObjectFieldValue && "data".equals(fv.getField().getName())) { // NOI18N
487+
Instance data = ((ObjectFieldValue)fv).getInstance();
488+
489+
if (data != null && !instance.equals(data)) {
490+
if (data.getJavaClass().isArray()) {
491+
return data;
492+
}
493+
return findDataField(data);
494+
}
495+
}
496+
}
497+
return null;
498+
}
499+
528500
private class RPairList implements ObjectArrayInstance {
529501

530502
private Instance pairListInstance;

0 commit comments

Comments
 (0)