Skip to content

Commit d75ba0f

Browse files
committed
[GR-11200] TruffleBoundary and some additions to cext
PullRequest: graalpython/147
2 parents d6cd2f0 + d197957 commit d75ba0f

File tree

4 files changed

+24
-4
lines changed

4 files changed

+24
-4
lines changed

graalpython/com.oracle.graal.python.cext/src/pystate.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,3 +49,12 @@ PyThreadState * PyThreadState_Get() {
4949
// TODO: (tfel) how much ThreadState will we actually support?
5050
return (PyThreadState*)PyThreadState_GetDict();
5151
}
52+
53+
PyGILState_STATE PyGILState_Ensure() {
54+
// ignore for the time being
55+
return NULL;
56+
}
57+
58+
void PyGILState_Release(PyGILState_STATE state) {
59+
// ignore for the time being
60+
}

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/ArrayModuleBuiltins.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,7 @@ PArray arrayWithSequenceInitializer(PythonClass cls, String typeCode, PSequence
163163
}
164164

165165
@Specialization
166+
@TruffleBoundary
166167
PArray arrayWithObjectInitializer(@SuppressWarnings("unused") PythonClass cls, @SuppressWarnings("unused") String typeCode, Object initializer) {
167168
throw new RuntimeException("Unsupported initializer " + initializer);
168169
}

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

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -477,12 +477,17 @@ Object doGeneric(Object object, String key) {
477477
if (object instanceof PythonAbstractObject) {
478478
PythonObjectNativeWrapper nativeWrapper = ((PythonAbstractObject) object).getNativeWrapper();
479479
assert nativeWrapper != null;
480-
PythonLanguage.getLogger().log(Level.FINE, "read of Python struct native member " + key);
480+
logGeneric(key);
481481
return getGetItemNode().execute(nativeWrapper.getNativeMemberStore(), key);
482482
}
483483
throw UnknownIdentifierException.raise(key);
484484
}
485485

486+
@TruffleBoundary(allowInlining = true)
487+
private static void logGeneric(String key) {
488+
PythonLanguage.getLogger().log(Level.FINE, "read of Python struct native member " + key);
489+
}
490+
486491
protected boolean eq(String expected, String actual) {
487492
return expected.equals(actual);
488493
}
@@ -643,13 +648,18 @@ Object doGeneric(Object object, String key, Object value) {
643648
if (object instanceof PythonAbstractObject) {
644649
PythonObjectNativeWrapper nativeWrapper = ((PythonAbstractObject) object).getNativeWrapper();
645650
assert nativeWrapper != null;
646-
PythonLanguage.getLogger().log(Level.FINE, "write of Python struct native member " + key);
651+
logGeneric(key);
647652
getSetItemNode().execute(nativeWrapper.createNativeMemberStore(), key, value);
648653
return value;
649654
}
650655
throw UnknownIdentifierException.raise(key);
651656
}
652657

658+
@TruffleBoundary(allowInlining = true)
659+
private static void logGeneric(String key) {
660+
PythonLanguage.getLogger().log(Level.FINE, "write of Python struct native member " + key);
661+
}
662+
653663
protected boolean eq(String expected, String actual) {
654664
return expected.equals(actual);
655665
}

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/PRootNode.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
*/
4141
package com.oracle.graal.python.nodes;
4242

43-
import com.oracle.truffle.api.CompilerDirectives;
43+
import com.oracle.truffle.api.CompilerAsserts;
4444
import com.oracle.truffle.api.CompilerDirectives.CompilationFinal;
4545
import com.oracle.truffle.api.TruffleLanguage;
4646
import com.oracle.truffle.api.frame.FrameDescriptor;
@@ -62,8 +62,8 @@ public boolean needsCallerFrame() {
6262
}
6363

6464
public void setNeedsCallerFrame() {
65+
CompilerAsserts.neverPartOfCompilation("this is usually called from behind a TruffleBoundary");
6566
if (!this.needsCallerFrame) {
66-
CompilerDirectives.transferToInterpreterAndInvalidate();
6767
this.needsCallerFrame = true;
6868
}
6969
}

0 commit comments

Comments
 (0)