Skip to content

Commit 3e78b95

Browse files
committed
[GR-33173] Migrate to new context reference API
PullRequest: graalpython/1941
2 parents c191a11 + 978cf37 commit 3e78b95

File tree

82 files changed

+307
-324
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

82 files changed

+307
-324
lines changed

ci.jsonnet

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
{ "overlay": "61fd7e543d7aec3ee0f034e1405fe587056ee001" }
1+
{ "overlay": "e385509fa2da9be1056c7c165f19023c06f7600e" }

graalpython/com.oracle.graal.python.benchmarks/java/com/oracle/graal/python/benchmarks/parser/Deserializing.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ public void setup() {
7676
public void execute(Blackhole bh) {
7777
for (int n = 0; n < parsingCycles; n++) {
7878
for (Item serialization : serializations) {
79-
bh.consume(parser.deserialize(serialization.data));
79+
bh.consume(parser.deserialize(core, serialization.data));
8080
}
8181
}
8282
}

graalpython/com.oracle.graal.python.benchmarks/java/com/oracle/graal/python/benchmarks/parser/ParserBenchRunner.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ public ParserBenchRunner() {
106106
context.initialize("python");
107107
context.enter();
108108

109-
this.pyContext = PythonLanguage.getContext();
109+
this.pyContext = PythonContext.get(null);
110110
this.parser = (PythonParserImpl) pyContext.getCore().getParser();
111111
this.core = pyContext.getCore();
112112
}
@@ -179,7 +179,7 @@ private List<Source> createSources() {
179179
}
180180
File file;
181181
PythonFileFilter filter = new PythonFileFilter(recursion, excludedPaths);
182-
PythonContext pyContext = PythonLanguage.getContext();
182+
PythonContext pyContext = PythonContext.get(null);
183183
for (String path : paths) {
184184
file = new File(path);
185185
if (file.isDirectory() || filter.accept(file)) {

graalpython/com.oracle.graal.python.test/src/com/oracle/graal/python/WithPythonContextRule.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,6 @@
4040
*/
4141
package com.oracle.graal.python;
4242

43-
import static com.oracle.graal.python.PythonLanguage.getContext;
44-
4543
import java.util.HashMap;
4644
import java.util.Map;
4745

@@ -95,7 +93,7 @@ public void evaluate() throws Throwable {
9593
RootCallTarget callTarget = Truffle.getRuntime().createCallTarget(new RootNode(null) {
9694
@Override
9795
public Object execute(VirtualFrame frame) {
98-
pythonContext = getContext();
96+
pythonContext = PythonContext.get(this);
9997
try {
10098
base.evaluate();
10199
} catch (Throwable e) {

graalpython/com.oracle.graal.python.test/src/com/oracle/graal/python/builtins/modules/ConversionNodeTests.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,8 @@ public class ConversionNodeTests {
6666
@Rule public ExpectedException expectedException = ExpectedException.none();
6767

6868
protected static Object call(Object arg, ArgumentCastNodeWithRaise castNode) {
69-
PythonLanguage language = PythonLanguage.getCurrent();
70-
final PythonContext pythonContext = PythonLanguage.getContext();
69+
PythonLanguage language = PythonLanguage.get(castNode);
70+
final PythonContext pythonContext = PythonContext.get(castNode);
7171

7272
RootCallTarget callTarget = Truffle.getRuntime().createCallTarget(new PRootNode(language) {
7373
@Child private CalleeContext calleeContext = CalleeContext.create();

graalpython/com.oracle.graal.python.test/src/com/oracle/graal/python/builtins/modules/DirFdConversionNodeTests.java

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

43-
import static com.oracle.graal.python.PythonLanguage.getContext;
4443
import static com.oracle.graal.python.runtime.PosixConstants.AT_FDCWD;
4544

4645
import java.math.BigInteger;
@@ -53,6 +52,7 @@
5352
import org.junit.Test;
5453

5554
import com.oracle.graal.python.builtins.objects.PNone;
55+
import com.oracle.graal.python.runtime.PythonContext;
5656
import com.oracle.graal.python.runtime.object.PythonObjectFactory;
5757
import com.oracle.graal.python.test.PythonTests;
5858

@@ -158,6 +158,6 @@ private static PythonObjectFactory factory() {
158158
}
159159

160160
private static Object evalValue(String source) {
161-
return getContext().getEnv().asGuestValue(Context.getCurrent().eval("python", source));
161+
return PythonContext.get(null).getEnv().asGuestValue(Context.getCurrent().eval("python", source));
162162
}
163163
}

graalpython/com.oracle.graal.python.test/src/com/oracle/graal/python/builtins/modules/FileDescriptorConversionNodeTests.java

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

43-
import static com.oracle.graal.python.PythonLanguage.getContext;
4443
import static com.oracle.graal.python.runtime.PosixConstants.AT_FDCWD;
4544

4645
import java.math.BigInteger;
@@ -53,6 +52,7 @@
5352
import org.junit.Test;
5453

5554
import com.oracle.graal.python.builtins.objects.PNone;
55+
import com.oracle.graal.python.runtime.PythonContext;
5656
import com.oracle.graal.python.runtime.object.PythonObjectFactory;
5757
import com.oracle.graal.python.test.PythonTests;
5858

@@ -166,6 +166,6 @@ private static PythonObjectFactory factory() {
166166
}
167167

168168
private static Object evalValue(String source) {
169-
return getContext().getEnv().asGuestValue(Context.getCurrent().eval("python", source));
169+
return PythonContext.get(null).getEnv().asGuestValue(Context.getCurrent().eval("python", source));
170170
}
171171
}

graalpython/com.oracle.graal.python.test/src/com/oracle/graal/python/builtins/modules/PathConversionNodeTests.java

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

43-
import static com.oracle.graal.python.PythonLanguage.getContext;
44-
4543
import java.math.BigInteger;
4644
import java.util.Collections;
4745

@@ -61,6 +59,7 @@
6159
import com.oracle.graal.python.builtins.objects.PNone;
6260
import com.oracle.graal.python.builtins.objects.tuple.PTuple;
6361
import com.oracle.graal.python.runtime.PosixSupportLibrary.Buffer;
62+
import com.oracle.graal.python.runtime.PythonContext;
6463
import com.oracle.graal.python.runtime.object.PythonObjectFactory;
6564
import com.oracle.graal.python.test.PythonTests;
6665
import com.oracle.graal.python.util.Function;
@@ -355,6 +354,6 @@ private static PythonObjectFactory factory() {
355354
}
356355

357356
private static Object evalValue(String source) {
358-
return getContext().getEnv().asGuestValue(Context.getCurrent().eval("python", source));
357+
return PythonContext.get(null).getEnv().asGuestValue(Context.getCurrent().eval("python", source));
359358
}
360359
}

graalpython/com.oracle.graal.python.test/src/com/oracle/graal/python/test/PythonTests.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -294,7 +294,7 @@ private static String getFileContent(File file) {
294294
public static RootNode getParseResult(com.oracle.truffle.api.source.Source source, PrintStream out, PrintStream err) {
295295
enterContext();
296296
try {
297-
PythonContext ctx = PythonLanguage.getContext();
297+
PythonContext ctx = PythonContext.get(null);
298298
ctx.setOut(out);
299299
ctx.setErr(err);
300300
return (RootNode) ctx.getCore().getParser().parse(ParserMode.File, 0, ctx.getCore(), source, null, null);

graalpython/com.oracle.graal.python.test/src/com/oracle/graal/python/test/datatype/PRangeTests.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,9 +64,10 @@ public void doInsert(Node child) {
6464
public void loopWithOnlyStop() throws UnexpectedResultException {
6565
PythonTests.enterContext();
6666
try {
67-
PRange range = PythonObjectFactory.getUncached().createIntRange(10);
67+
PythonObjectFactory factory = PythonObjectFactory.getUncached();
68+
PRange range = factory.createIntRange(10);
6869
int index = 0;
69-
TestRoot testRoot = new TestRoot(PythonLanguage.getCurrent());
70+
TestRoot testRoot = new TestRoot(PythonLanguage.get(factory));
7071
Object iter = PythonObjectLibrary.getUncached().getIterator(range);
7172
GetNextNode next = GetNextNode.create();
7273
testRoot.doInsert(next);
@@ -91,9 +92,10 @@ public void loopWithOnlyStop() throws UnexpectedResultException {
9192
public void loopWithStep() throws UnexpectedResultException {
9293
PythonTests.enterContext();
9394
try {
95+
PythonObjectFactory factory = PythonObjectFactory.getUncached();
9496
PRange range = PythonObjectFactory.getUncached().createIntRange(0, 10, 2, 5);
9597
int index = 0;
96-
TestRoot testRoot = new TestRoot(PythonLanguage.getCurrent());
98+
TestRoot testRoot = new TestRoot(PythonLanguage.get(factory));
9799
Object iter = PythonObjectLibrary.getUncached().getIterator(range);
98100
GetNextNode next = GetNextNode.create();
99101
testRoot.doInsert(next);

0 commit comments

Comments
 (0)