Skip to content

Commit 3b34843

Browse files
committed
All wrappers of "empty data address" must be "external"
1 parent 9597603 commit 3b34843

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/data/NativeDataAccess.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -324,15 +324,16 @@ public void toNative(@Cached() ToNativeNode toNative) {
324324
toNative.execute(this);
325325
}
326326

327-
public long setExternalDataAddress(long address) {
327+
public void setExternalDataAddress(long address) {
328328
this.dataAddress = NativeMemory.wrapExternalNativeMemory(address, delegate);
329329
if (dataAddressToNativeMirrors != null) {
330330
addToAddressDebugMapping(address);
331331
}
332-
return address;
333332
}
334333

335334
long setDataAddress(long address) {
335+
// use setExternalDataAddress for empty data address
336+
assert address != getEmptyDataAddress();
336337
this.dataAddress = NativeMemory.wrapNativeMemory(address, delegate);
337338
if (dataAddressToNativeMirrors != null) {
338339
addToAddressDebugMapping(address);
@@ -378,7 +379,7 @@ void allocateNativeString(byte[] bytes) {
378379
@TruffleBoundary
379380
void allocateNative(CharSXPWrapper[] wrappers) {
380381
if (wrappers.length == 0) {
381-
setDataAddress(getEmptyDataAddress());
382+
setExternalDataAddress(getEmptyDataAddress());
382383
} else {
383384
long addr = setDataAddress(NativeMemory.allocate(wrappers.length * (long) Long.BYTES, "CharSXPWrapper"));
384385
for (int i = 0; i < wrappers.length; i++) {
@@ -390,7 +391,7 @@ void allocateNative(CharSXPWrapper[] wrappers) {
390391
@TruffleBoundary
391392
void allocateNative(Object[] elements) {
392393
if (elements.length == 0) {
393-
setDataAddress(getEmptyDataAddress());
394+
setExternalDataAddress(getEmptyDataAddress());
394395
} else {
395396
long addr = setDataAddress(NativeMemory.allocate(elements.length * (long) Long.BYTES, "SEXP array"));
396397
for (int i = 0; i < elements.length; i++) {

com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/ffi/util/NativeMemory.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -289,7 +289,8 @@ private static void logFreeStart(long address, Object debugInfo) {
289289
sb.append("Alloc stack trace:\n").append(shortStackTrace(origInfo.stackTrace)).append("\n-----\n");
290290
}
291291
}
292-
// printing everything at once, because this is run from the cleaner thread so otherwise the output may interleave with the main thread
292+
// printing everything at once, because this is run from the cleaner thread so otherwise the
293+
// output may interleave with the main thread
293294
System.out.println(sb.toString());
294295
}
295296

0 commit comments

Comments
 (0)