Skip to content

Commit 8bae74e

Browse files
committed
Fix: Do not share native pointers.
1 parent 7d5fb53 commit 8bae74e

File tree

2 files changed

+4
-34
lines changed

2 files changed

+4
-34
lines changed

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/CExtNodes.java

Lines changed: 4 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -364,12 +364,7 @@ static PrimitiveNativeWrapper doIntegerSmall(@SuppressWarnings("unused") CExtCon
364364
static PrimitiveNativeWrapper doInteger(@SuppressWarnings("unused") CExtContext cextContext, int i,
365365
@Shared("contextRef") @CachedContext(PythonLanguage.class) ContextReference<PythonContext> contextRef) {
366366
if (CApiGuards.isSmallInteger(i)) {
367-
if (CompilerDirectives.inInterpreter()) {
368-
return doIntegerSmall(cextContext, i, contextRef);
369-
} else {
370-
// for explanation: see method doc
371-
return doIntegerSmall(cextContext, i, contextRef).copy();
372-
}
367+
return doIntegerSmall(cextContext, i, contextRef);
373368
}
374369
return PrimitiveNativeWrapper.createInt(i);
375370
}
@@ -388,12 +383,7 @@ static PrimitiveNativeWrapper doLongSmall(@SuppressWarnings("unused") CExtContex
388383
static PrimitiveNativeWrapper doLong(@SuppressWarnings("unused") CExtContext cextContext, long l,
389384
@Shared("contextRef") @CachedContext(PythonLanguage.class) ContextReference<PythonContext> contextRef) {
390385
if (CApiGuards.isSmallLong(l)) {
391-
// for explanation of this construct: see 'ToSulongNode.doInteger'
392-
if (CompilerDirectives.inInterpreter()) {
393-
return doLongSmall(cextContext, l, contextRef);
394-
} else {
395-
return doLongSmall(cextContext, l, contextRef).copy();
396-
}
386+
return doLongSmall(cextContext, l, contextRef);
397387
}
398388
return PrimitiveNativeWrapper.createLong(l);
399389
}
@@ -622,12 +612,7 @@ static PrimitiveNativeWrapper doLongSmall(@SuppressWarnings("unused") CExtContex
622612
static PrimitiveNativeWrapper doInteger(CExtContext cextContext, int i,
623613
@Shared("contextRef") @CachedContext(PythonLanguage.class) ContextReference<PythonContext> contextRef) {
624614
if (CApiGuards.isSmallInteger(i)) {
625-
// for explanation of this construct: see 'ToSulongNode.doInteger'
626-
if (CompilerDirectives.inInterpreter()) {
627-
return doIntegerSmall(cextContext, i, contextRef);
628-
} else {
629-
return doIntegerSmall(cextContext, i, contextRef).copy();
630-
}
615+
return doIntegerSmall(cextContext, i, contextRef);
631616
}
632617
return PrimitiveNativeWrapper.createInt(i);
633618
}
@@ -636,12 +621,7 @@ static PrimitiveNativeWrapper doInteger(CExtContext cextContext, int i,
636621
static PrimitiveNativeWrapper doLong(CExtContext cextContext, long l,
637622
@Shared("contextRef") @CachedContext(PythonLanguage.class) ContextReference<PythonContext> contextRef) {
638623
if (CApiGuards.isSmallLong(l)) {
639-
// for explanation of this construct: see 'ToSulongNode.doInteger'
640-
if (CompilerDirectives.inInterpreter()) {
641-
return doLongSmall(cextContext, l, contextRef);
642-
} else {
643-
return doLongSmall(cextContext, l, contextRef).copy();
644-
}
624+
return doLongSmall(cextContext, l, contextRef);
645625
}
646626
return PrimitiveNativeWrapper.createLong(l);
647627
}

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/DynamicObjectNativeWrapper.java

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1475,12 +1475,6 @@ private PrimitiveNativeWrapper(double dvalue) {
14751475
this.dvalue = dvalue;
14761476
}
14771477

1478-
private PrimitiveNativeWrapper(byte state, long value, double dvalue) {
1479-
this.state = state;
1480-
this.value = value;
1481-
this.dvalue = dvalue;
1482-
}
1483-
14841478
public byte getState() {
14851479
return state;
14861480
}
@@ -1563,10 +1557,6 @@ public int hashCode() {
15631557
return (Long.hashCode(value) ^ Long.hashCode(Double.doubleToRawLongBits(dvalue)) ^ state);
15641558
}
15651559

1566-
PrimitiveNativeWrapper copy() {
1567-
return new PrimitiveNativeWrapper(state, value, dvalue);
1568-
}
1569-
15701560
@Override
15711561
public String toString() {
15721562
return "PrimitiveNativeWrapper(" + getTypeName() + "(" + value + ")" + ')';

0 commit comments

Comments
 (0)