Skip to content

Commit 1923b4d

Browse files
committed
Merge branch 'tim/no-reuse' into tim/GR-10719/kmeans
2 parents 44b7f6f + 580ddd9 commit 1923b4d

28 files changed

+106
-155
lines changed

graalpython/com.oracle.graal.python.cext/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ HEADER_TARGETS=$(INCLUDE_FILES:${VPATH}/include/%.h=${VPATH}/../include/%.h)
5353
default: ${TARGET_LIB} ${MODULE_TARGETS} ${HEADER_TARGETS}
5454

5555

56-
CFLAGS=${LLVM_TARGET_FLAGS} -ggdb -emit-llvm
56+
CFLAGS=${LLVM_TARGET_FLAGS} -O1 -ggdb -emit-llvm
5757
OPT_FLAGS=-mem2reg -globalopt -simplifycfg -constprop -always-inline -instcombine -dse -loop-simplify -reassociate -licm -gvn
5858
WARNINGS=-Wno-int-to-pointer-cast -Wno-int-conversion -Wno-incompatible-pointer-types-discards-qualifiers -Wno-pointer-type-mismatch
5959
INCLUDES=-I${POLYGLOT_INC} -I${VPATH}/include

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.test/src/tests/cpyext/__init__.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
# SOFTWARE.
3939

4040
import sys
41+
from importlib import invalidate_caches
4142
from string import Formatter
4243
os = sys.modules.get("posix", sys.modules.get("nt", None))
4344
if os is None:
@@ -87,6 +88,11 @@ def ccompile(self, name):
8788
binary_file_llvm = '%s/%s.bc' % (__dir__, name)
8889
if GRAALPYTHON:
8990
file_not_empty(binary_file_llvm)
91+
# IMPORTANT:
92+
# Invalidate caches after creating the native module.
93+
# FileFinder caches directory contents, and the check for directory
94+
# changes has whole-second precision, so it can miss quick updates.
95+
invalidate_caches()
9096

9197

9298
def file_not_empty(path):

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/PythonLanguage.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@
7676
import com.oracle.truffle.api.source.Source;
7777
import com.oracle.truffle.api.source.Source.Builder;
7878

79-
@TruffleLanguage.Registration(id = PythonLanguage.ID, name = PythonLanguage.NAME, version = PythonLanguage.VERSION, mimeType = PythonLanguage.MIME_TYPE, interactive = true, internal = false, contextPolicy = TruffleLanguage.ContextPolicy.REUSE)
79+
@TruffleLanguage.Registration(id = PythonLanguage.ID, name = PythonLanguage.NAME, version = PythonLanguage.VERSION, mimeType = PythonLanguage.MIME_TYPE, interactive = true, internal = false, contextPolicy = TruffleLanguage.ContextPolicy.EXCLUSIVE)
8080
@ProvidedTags({StandardTags.CallTag.class, StandardTags.StatementTag.class, StandardTags.RootTag.class, StandardTags.TryBlockTag.class, DebuggerTags.AlwaysHalt.class})
8181
public final class PythonLanguage extends TruffleLanguage<PythonContext> {
8282
public static final String ID = "python";

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/modules/ImpModuleBuiltins.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ public abstract static class CreateDynamic extends PythonBuiltinNode {
150150
@Specialization
151151
@TruffleBoundary
152152
public Object run(PythonObject moduleSpec, @SuppressWarnings("unused") Object filename,
153-
@Cached("createExecute(0).createNode()") Node executeNode,
153+
@Cached("EXECUTE.createNode()") Node executeNode,
154154
@Cached("READ.createNode()") Node readNode) {
155155
String name = moduleSpec.getAttribute("name").toString();
156156
String path = moduleSpec.getAttribute("origin").toString();

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,7 @@ Object remove(TruffleObject receiver, Object key,
227227
public abstract static class executeNode extends PythonBuiltinNode {
228228
@Specialization
229229
Object remove(TruffleObject receiver, Object[] arguments,
230-
@Cached("createExecute(0).createNode()") Node executeNode) {
230+
@Cached("EXECUTE.createNode()") Node executeNode) {
231231
try {
232232
return ForeignAccess.sendExecute(executeNode, receiver, arguments);
233233
} catch (UnsupportedMessageException | UnsupportedTypeException | ArityException e) {
@@ -242,7 +242,7 @@ Object remove(TruffleObject receiver, Object[] arguments,
242242
public abstract static class newNode extends PythonBuiltinNode {
243243
@Specialization
244244
Object remove(TruffleObject receiver, Object[] arguments,
245-
@Cached("createNew(0).createNode()") Node executeNode) {
245+
@Cached("NEW.createNode()") Node executeNode) {
246246
try {
247247
return ForeignAccess.sendNew(executeNode, receiver, arguments);
248248
} catch (UnsupportedMessageException | UnsupportedTypeException | ArityException e) {
@@ -257,7 +257,7 @@ Object remove(TruffleObject receiver, Object[] arguments,
257257
public abstract static class invokeNode extends PythonBuiltinNode {
258258
@Specialization
259259
Object remove(TruffleObject receiver, String key, Object[] arguments,
260-
@Cached("createInvoke(0).createNode()") Node executeNode) {
260+
@Cached("INVOKE.createNode()") Node executeNode) {
261261
try {
262262
return ForeignAccess.sendInvoke(executeNode, receiver, key, arguments);
263263
} catch (UnsupportedMessageException | UnsupportedTypeException | ArityException | UnknownIdentifierException e) {

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -273,7 +273,7 @@ Object call(TruffleObject callable, Object[] arguments,
273273
}
274274

275275
protected static Node createExecute() {
276-
return Message.createExecute(0).createNode();
276+
return Message.EXECUTE.createNode();
277277
}
278278

279279
}

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

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -636,11 +636,7 @@ public ExternalFunctionNode(PythonLanguage lang, String name, TruffleObject cwra
636636
this.name = name;
637637
this.cwrapper = cwrapper;
638638
this.callable = callable;
639-
if (cwrapper != null) {
640-
this.executeNode = Message.createExecute(3).createNode();
641-
} else {
642-
this.executeNode = Message.createExecute(2).createNode();
643-
}
639+
this.executeNode = Message.EXECUTE.createNode();
644640
}
645641

646642
public TruffleObject getCallable() {

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

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ public abstract class CExtNodes {
8787
*/
8888
public static class SubtypeNew extends PBaseNode {
8989
private final TruffleObject subtypeFunc;
90-
@Child private Node executeNode = Message.createExecute(2).createNode();
90+
@Child private Node executeNode = Message.EXECUTE.createNode();
9191
@Child private ToSulongNode toSulongNode = ToSulongNode.create();
9292
@Child private ToJavaNode toJavaNode = ToJavaNode.create();
9393

@@ -134,7 +134,7 @@ private PythonBuiltinClass getExpectedClass() {
134134
private Node getExecNode() {
135135
if (executeNode == null) {
136136
CompilerDirectives.transferToInterpreterAndInvalidate();
137-
executeNode = insert(Message.createExecute(1).createNode());
137+
executeNode = insert(Message.EXECUTE.createNode());
138138
}
139139
return executeNode;
140140
}
@@ -367,7 +367,7 @@ Object doWrapper(PythonObjectNativeWrapper value) {
367367
Object doForeign(Object value) {
368368
if (callNativeNode == null) {
369369
CompilerDirectives.transferToInterpreterAndInvalidate();
370-
callNativeNode = insert(PCallNativeNode.create(1));
370+
callNativeNode = insert(PCallNativeNode.create());
371371
}
372372
if (callNativeNode == null) {
373373
CompilerDirectives.transferToInterpreterAndInvalidate();
@@ -393,13 +393,13 @@ public abstract static class AsCharPointer extends CExtBaseNode {
393393

394394
@Specialization
395395
Object doPString(PString str,
396-
@Cached("createExecute(1)") Node executeNode) {
396+
@Cached("createExecute()") Node executeNode) {
397397
return doString(str.getValue(), executeNode);
398398
}
399399

400400
@Specialization
401401
Object doString(String str,
402-
@Cached("createExecute(1)") Node executeNode) {
402+
@Cached("createExecute()") Node executeNode) {
403403
try {
404404
return ForeignAccess.sendExecute(executeNode, getTruffleStringToCstr(), str, str.length());
405405
} catch (UnsupportedTypeException | ArityException | UnsupportedMessageException e) {
@@ -409,7 +409,7 @@ Object doString(String str,
409409

410410
@Specialization
411411
Object doByteArray(byte[] arr,
412-
@Cached("createExecute(2)") Node executeNode) {
412+
@Cached("createExecute()") Node executeNode) {
413413
try {
414414
return ForeignAccess.sendExecute(executeNode, getTruffleByteArrayToNative(), getContext().getEnv().asGuestValue(arr), arr.length);
415415
} catch (UnsupportedTypeException | ArityException | UnsupportedMessageException e) {
@@ -433,8 +433,8 @@ TruffleObject getTruffleByteArrayToNative() {
433433
return truffle_byte_array_to_native;
434434
}
435435

436-
protected Node createExecute(int arity) {
437-
return Message.createExecute(arity).createNode();
436+
protected Node createExecute() {
437+
return Message.EXECUTE.createNode();
438438
}
439439

440440
public static AsCharPointer create() {
@@ -458,7 +458,7 @@ TruffleObject getTruffleStringToCstr() {
458458
private Node getExecuteNode() {
459459
if (executeNode == null) {
460460
CompilerDirectives.transferToInterpreterAndInvalidate();
461-
executeNode = insert(Message.createExecute(1).createNode());
461+
executeNode = insert(Message.EXECUTE.createNode());
462462
}
463463
return executeNode;
464464
}
@@ -500,7 +500,7 @@ private ToJavaNode getToJavaNode() {
500500
private PCallNativeNode getCallGetObTypeNode() {
501501
if (callGetObTypeNode == null) {
502502
CompilerDirectives.transferToInterpreterAndInvalidate();
503-
callGetObTypeNode = insert(PCallNativeNode.create(1));
503+
callGetObTypeNode = insert(PCallNativeNode.create());
504504
}
505505
return callGetObTypeNode;
506506
}
@@ -526,7 +526,7 @@ public long execute() {
526526
if (wcharSize < 0) {
527527
CompilerDirectives.transferToInterpreterAndInvalidate();
528528
try {
529-
wcharSize = (long) ForeignAccess.sendExecute(Message.createExecute(0).createNode(), getNativeFunction());
529+
wcharSize = (long) ForeignAccess.sendExecute(Message.EXECUTE.createNode(), getNativeFunction());
530530
assert wcharSize >= 0L;
531531
} catch (InteropException e) {
532532
throw e.raise();

0 commit comments

Comments
 (0)