Skip to content

Commit 1c7e476

Browse files
committed
Revert last commit, since checkNotNull must be static
1 parent 8c4e12d commit 1c7e476

File tree

1 file changed

+34
-34
lines changed

1 file changed

+34
-34
lines changed

src/main/java/org/truffleruby/extra/ffi/PointerNodes.java

Lines changed: 34 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,8 @@ public static void checkNull(
6666

6767
private abstract static class PointerPrimitiveArrayArgumentsNode extends PrimitiveArrayArgumentsNode {
6868

69-
protected void checkNull(Pointer ptr, InlinedBranchProfile nullPointerProfile) {
70-
PointerNodes.checkNull(ptr, getContext(), this, nullPointerProfile);
69+
protected static void checkNull(Node node, Pointer ptr, InlinedBranchProfile nullPointerProfile) {
70+
PointerNodes.checkNull(ptr, getContext(node), node, nullPointerProfile);
7171
}
7272

7373
}
@@ -245,7 +245,7 @@ public abstract static class PointerCopyMemoryNode extends PointerPrimitiveArray
245245
protected Object copyMemory(long to, long from, long size,
246246
@Cached InlinedBranchProfile nullPointerProfile) {
247247
final Pointer ptr = new Pointer(getContext(), to);
248-
checkNull(ptr, nullPointerProfile);
248+
checkNull(this, ptr, nullPointerProfile);
249249
ptr.writeBytes(0, new Pointer(getContext(), from), 0, size);
250250
return nil;
251251
}
@@ -268,7 +268,7 @@ protected RubyString readStringToNull(long address, long limit,
268268
@CachedLibrary(limit = "1") @Shared InteropLibrary interop,
269269
@Cached @Shared InlinedBranchProfile nullPointerProfile) {
270270
final Pointer ptr = new Pointer(getContext(), address);
271-
checkNull(ptr, nullPointerProfile);
271+
checkNull(this, ptr, nullPointerProfile);
272272
final byte[] bytes = ptr.readZeroTerminatedByteArray(getContext(), interop, 0, limit);
273273
return createString(fromByteArrayNode, bytes, Encodings.BINARY);
274274
}
@@ -279,7 +279,7 @@ protected RubyString readStringToNull(long address, Nil limit,
279279
@Cached @Shared TruffleString.FromByteArrayNode fromByteArrayNode,
280280
@Cached @Shared InlinedBranchProfile nullPointerProfile) {
281281
final Pointer ptr = new Pointer(getContext(), address);
282-
checkNull(ptr, nullPointerProfile);
282+
checkNull(this, ptr, nullPointerProfile);
283283
final byte[] bytes = ptr.readZeroTerminatedByteArray(getContext(), interop, 0);
284284
return createString(fromByteArrayNode, bytes, Encodings.BINARY);
285285
}
@@ -298,7 +298,7 @@ protected Object readBytes(RubyByteArray array, int arrayOffset, long address, i
298298
// No need to check the pointer address if we read nothing
299299
return nil;
300300
} else {
301-
checkNull(ptr, nullPointerProfile);
301+
checkNull(this, ptr, nullPointerProfile);
302302
final byte[] bytes = array.bytes;
303303
ptr.readBytes(0, bytes, arrayOffset, length);
304304
return nil;
@@ -320,7 +320,7 @@ protected RubyString readBytes(long address, int length,
320320
// No need to check the pointer address if we read nothing
321321
return createString(TStringConstants.EMPTY_BINARY, Encodings.BINARY);
322322
} else {
323-
checkNull(ptr, nullPointerProfile);
323+
checkNull(this, ptr, nullPointerProfile);
324324
final byte[] bytes = new byte[length];
325325
ptr.readBytes(0, bytes, 0, length);
326326
return createString(fromByteArrayNode, bytes, Encodings.BINARY);
@@ -347,7 +347,7 @@ protected static Object writeBytes(long address, Object string, int index, int l
347347

348348
if (nonZeroProfile.profile(node, length != 0)) {
349349
// No need to check the pointer address if we write nothing
350-
checkNull(ptr, nullPointerProfile);
350+
checkNull(node, ptr, nullPointerProfile);
351351

352352
copyToNativeMemoryNode.execute(tstring, index, ptr, 0, length, encoding);
353353
}
@@ -366,7 +366,7 @@ public abstract static class PointerReadCharNode extends PointerPrimitiveArrayAr
366366
protected int readCharSigned(long address,
367367
@Cached InlinedBranchProfile nullPointerProfile) {
368368
final Pointer ptr = new Pointer(getContext(), address);
369-
checkNull(ptr, nullPointerProfile);
369+
checkNull(this, ptr, nullPointerProfile);
370370
return ptr.readByte(0);
371371
}
372372

@@ -379,7 +379,7 @@ public abstract static class PointerReadUCharNode extends PointerPrimitiveArrayA
379379
protected int readCharUnsigned(long address,
380380
@Cached InlinedBranchProfile nullPointerProfile) {
381381
final Pointer ptr = new Pointer(getContext(), address);
382-
checkNull(ptr, nullPointerProfile);
382+
checkNull(this, ptr, nullPointerProfile);
383383
return Byte.toUnsignedInt(ptr.readByte(0));
384384
}
385385

@@ -392,7 +392,7 @@ public abstract static class PointerReadShortNode extends PointerPrimitiveArrayA
392392
protected int readShortSigned(long address,
393393
@Cached InlinedBranchProfile nullPointerProfile) {
394394
final Pointer ptr = new Pointer(getContext(), address);
395-
checkNull(ptr, nullPointerProfile);
395+
checkNull(this, ptr, nullPointerProfile);
396396
return ptr.readShort(0);
397397
}
398398
}
@@ -404,7 +404,7 @@ public abstract static class PointerReadUShortNode extends PointerPrimitiveArray
404404
protected int readShortUnsigned(long address,
405405
@Cached InlinedBranchProfile nullPointerProfile) {
406406
final Pointer ptr = new Pointer(getContext(), address);
407-
checkNull(ptr, nullPointerProfile);
407+
checkNull(this, ptr, nullPointerProfile);
408408
return Short.toUnsignedInt(ptr.readShort(0));
409409
}
410410

@@ -417,7 +417,7 @@ public abstract static class PointerReadIntNode extends PointerPrimitiveArrayArg
417417
protected int readIntSigned(long address,
418418
@Cached InlinedBranchProfile nullPointerProfile) {
419419
final Pointer ptr = new Pointer(getContext(), address);
420-
checkNull(ptr, nullPointerProfile);
420+
checkNull(this, ptr, nullPointerProfile);
421421
return ptr.readInt(0);
422422
}
423423

@@ -430,7 +430,7 @@ public abstract static class PointerReadUIntNode extends PointerPrimitiveArrayAr
430430
protected long readIntUnsigned(long address,
431431
@Cached InlinedBranchProfile nullPointerProfile) {
432432
final Pointer ptr = new Pointer(getContext(), address);
433-
checkNull(ptr, nullPointerProfile);
433+
checkNull(this, ptr, nullPointerProfile);
434434
return Integer.toUnsignedLong(ptr.readInt(0));
435435
}
436436

@@ -443,7 +443,7 @@ public abstract static class PointerReadLongNode extends PointerPrimitiveArrayAr
443443
protected long readLongSigned(long address,
444444
@Cached InlinedBranchProfile nullPointerProfile) {
445445
final Pointer ptr = new Pointer(getContext(), address);
446-
checkNull(ptr, nullPointerProfile);
446+
checkNull(this, ptr, nullPointerProfile);
447447
return ptr.readLong(0);
448448
}
449449

@@ -456,7 +456,7 @@ public abstract static class PointerReadULongNode extends PointerPrimitiveArrayA
456456
protected Object readLongUnsigned(long address,
457457
@Cached InlinedBranchProfile nullPointerProfile) {
458458
final Pointer ptr = new Pointer(getContext(), address);
459-
checkNull(ptr, nullPointerProfile);
459+
checkNull(this, ptr, nullPointerProfile);
460460
return readUnsignedLong(ptr, 0);
461461
}
462462

@@ -475,7 +475,7 @@ public abstract static class PointerReadFloatNode extends PointerPrimitiveArrayA
475475
protected double readFloat(long address,
476476
@Cached InlinedBranchProfile nullPointerProfile) {
477477
final Pointer ptr = new Pointer(getContext(), address);
478-
checkNull(ptr, nullPointerProfile);
478+
checkNull(this, ptr, nullPointerProfile);
479479
return ptr.readFloat(0);
480480
}
481481

@@ -488,7 +488,7 @@ public abstract static class PointerReadDoubleNode extends PointerPrimitiveArray
488488
protected double readDouble(long address,
489489
@Cached InlinedBranchProfile nullPointerProfile) {
490490
final Pointer ptr = new Pointer(getContext(), address);
491-
checkNull(ptr, nullPointerProfile);
491+
checkNull(this, ptr, nullPointerProfile);
492492
return ptr.readDouble(0);
493493
}
494494

@@ -501,7 +501,7 @@ public abstract static class PointerReadPointerNode extends PointerPrimitiveArra
501501
protected RubyPointer readPointer(long address,
502502
@Cached InlinedBranchProfile nullPointerProfile) {
503503
final Pointer ptr = new Pointer(getContext(), address);
504-
checkNull(ptr, nullPointerProfile);
504+
checkNull(this, ptr, nullPointerProfile);
505505
final Pointer readPointer = ptr.readPointer(getContext(), 0);
506506
final RubyPointer instance = new RubyPointer(
507507
coreLibrary().truffleFFIPointerClass,
@@ -521,7 +521,7 @@ public abstract static class PointerWriteCharNode extends PointerPrimitiveArrayA
521521
protected Object writeChar(long address, int value,
522522
@Cached InlinedBranchProfile nullPointerProfile) {
523523
final Pointer ptr = new Pointer(getContext(), address);
524-
checkNull(ptr, nullPointerProfile);
524+
checkNull(this, ptr, nullPointerProfile);
525525
byte byteValue = (byte) value;
526526
ptr.writeByte(0, byteValue);
527527
return nil;
@@ -537,7 +537,7 @@ public abstract static class PointerWriteUCharNode extends PointerPrimitiveArray
537537
protected Object writeChar(long address, int value,
538538
@Cached @Shared InlinedBranchProfile nullPointerProfile) {
539539
final Pointer ptr = new Pointer(getContext(), address);
540-
checkNull(ptr, nullPointerProfile);
540+
checkNull(this, ptr, nullPointerProfile);
541541
byte byteValue = (byte) value;
542542
ptr.writeByte(0, byteValue);
543543
return nil;
@@ -547,7 +547,7 @@ protected Object writeChar(long address, int value,
547547
protected Object writeUnsignedChar(long address, int value,
548548
@Cached @Shared InlinedBranchProfile nullPointerProfile) {
549549
final Pointer ptr = new Pointer(getContext(), address);
550-
checkNull(ptr, nullPointerProfile);
550+
checkNull(this, ptr, nullPointerProfile);
551551
byte signed = (byte) value; // Same as value - 2^8
552552
ptr.writeByte(0, signed);
553553
return nil;
@@ -563,7 +563,7 @@ public abstract static class PointerWriteShortNode extends PointerPrimitiveArray
563563
protected Object writeShort(long address, int value,
564564
@Cached InlinedBranchProfile nullPointerProfile) {
565565
final Pointer ptr = new Pointer(getContext(), address);
566-
checkNull(ptr, nullPointerProfile);
566+
checkNull(this, ptr, nullPointerProfile);
567567
short shortValue = (short) value;
568568
ptr.writeShort(0, shortValue);
569569
return nil;
@@ -579,7 +579,7 @@ public abstract static class PointerWriteUShortNode extends PointerPrimitiveArra
579579
protected Object writeShort(long address, int value,
580580
@Cached @Shared InlinedBranchProfile nullPointerProfile) {
581581
final Pointer ptr = new Pointer(getContext(), address);
582-
checkNull(ptr, nullPointerProfile);
582+
checkNull(this, ptr, nullPointerProfile);
583583
short shortValue = (short) value;
584584
ptr.writeShort(0, shortValue);
585585
return nil;
@@ -589,7 +589,7 @@ protected Object writeShort(long address, int value,
589589
protected Object writeUnsignedSort(long address, int value,
590590
@Cached @Shared InlinedBranchProfile nullPointerProfile) {
591591
final Pointer ptr = new Pointer(getContext(), address);
592-
checkNull(ptr, nullPointerProfile);
592+
checkNull(this, ptr, nullPointerProfile);
593593
short signed = (short) value; // Same as value - 2^16
594594
ptr.writeShort(0, signed);
595595
return nil;
@@ -604,7 +604,7 @@ public abstract static class PointerWriteIntNode extends PointerPrimitiveArrayAr
604604
protected Object writeInt(long address, int value,
605605
@Cached InlinedBranchProfile nullPointerProfile) {
606606
final Pointer ptr = new Pointer(getContext(), address);
607-
checkNull(ptr, nullPointerProfile);
607+
checkNull(this, ptr, nullPointerProfile);
608608
ptr.writeInt(0, value);
609609
return nil;
610610
}
@@ -621,7 +621,7 @@ public abstract static class PointerWriteUIntNode extends PointerPrimitiveArrayA
621621
protected Object writeInt(long address, int value,
622622
@Cached @Shared InlinedBranchProfile nullPointerProfile) {
623623
final Pointer ptr = new Pointer(getContext(), address);
624-
checkNull(ptr, nullPointerProfile);
624+
checkNull(this, ptr, nullPointerProfile);
625625
ptr.writeInt(0, value);
626626
return nil;
627627
}
@@ -630,7 +630,7 @@ protected Object writeInt(long address, int value,
630630
protected Object writeUnsignedInt(long address, long value,
631631
@Cached @Shared InlinedBranchProfile nullPointerProfile) {
632632
final Pointer ptr = new Pointer(getContext(), address);
633-
checkNull(ptr, nullPointerProfile);
633+
checkNull(this, ptr, nullPointerProfile);
634634
int signed = (int) value; // Same as value - 2^32
635635
ptr.writeInt(0, signed);
636636
return nil;
@@ -645,7 +645,7 @@ public abstract static class PointerWriteLongNode extends PointerPrimitiveArrayA
645645
protected Object writeLong(long address, long value,
646646
@Cached InlinedBranchProfile nullPointerProfile) {
647647
final Pointer ptr = new Pointer(getContext(), address);
648-
checkNull(ptr, nullPointerProfile);
648+
checkNull(this, ptr, nullPointerProfile);
649649
ptr.writeLong(0, value);
650650
return nil;
651651
}
@@ -659,7 +659,7 @@ public abstract static class PointerWriteULongNode extends PointerPrimitiveArray
659659
protected Object writeLong(long address, long value,
660660
@Cached @Shared InlinedBranchProfile nullPointerProfile) {
661661
final Pointer ptr = new Pointer(getContext(), address);
662-
checkNull(ptr, nullPointerProfile);
662+
checkNull(this, ptr, nullPointerProfile);
663663
ptr.writeLong(0, value);
664664
return nil;
665665
}
@@ -668,7 +668,7 @@ protected Object writeLong(long address, long value,
668668
protected Object writeUnsignedLong(long address, RubyBignum value,
669669
@Cached @Shared InlinedBranchProfile nullPointerProfile) {
670670
final Pointer ptr = new Pointer(getContext(), address);
671-
checkNull(ptr, nullPointerProfile);
671+
checkNull(this, ptr, nullPointerProfile);
672672
writeUnsignedLong(ptr, 0, value);
673673
return nil;
674674
}
@@ -691,7 +691,7 @@ public abstract static class PointerWriteFloatNode extends PointerPrimitiveArray
691691
protected Object writeFloat(long address, double value,
692692
@Cached InlinedBranchProfile nullPointerProfile) {
693693
final Pointer ptr = new Pointer(getContext(), address);
694-
checkNull(ptr, nullPointerProfile);
694+
checkNull(this, ptr, nullPointerProfile);
695695
ptr.writeFloat(0, (float) value);
696696
return nil;
697697
}
@@ -705,7 +705,7 @@ public abstract static class PointerWriteDoubleNode extends PointerPrimitiveArra
705705
protected Object writeDouble(long address, double value,
706706
@Cached InlinedBranchProfile nullPointerProfile) {
707707
final Pointer ptr = new Pointer(getContext(), address);
708-
checkNull(ptr, nullPointerProfile);
708+
checkNull(this, ptr, nullPointerProfile);
709709
ptr.writeDouble(0, value);
710710
return nil;
711711
}
@@ -719,7 +719,7 @@ public abstract static class PointerWritePointerNode extends PointerPrimitiveArr
719719
protected Object writePointer(long address, long value,
720720
@Cached InlinedBranchProfile nullPointerProfile) {
721721
final Pointer ptr = new Pointer(getContext(), address);
722-
checkNull(ptr, nullPointerProfile);
722+
checkNull(this, ptr, nullPointerProfile);
723723
ptr.writePointer(0, value);
724724
return nil;
725725
}

0 commit comments

Comments
 (0)