Skip to content

Commit 312d87d

Browse files
committed
[GR-14937] Remove opaque filesystem
PullRequest: graalpython/481
2 parents 84df344 + 4c1c82d commit 312d87d

File tree

12 files changed

+31
-258
lines changed

12 files changed

+31
-258
lines changed

graalpython/com.oracle.graal.python.test/src/com/oracle/graal/python/test/interop/JavaInteropTest.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -528,7 +528,6 @@ public String toString() {
528528
@Parameters(name = "{0}")
529529
public static OptionsChecker[] input() {
530530
return new OptionsChecker[]{
531-
new OptionsChecker("OpaqueFilesystem", "import sys; sys.graal_python_opaque_filesystem", "true", "false"),
532531
new OptionsChecker("InspectFlag", "import sys; sys.flags.inspect", "true", "false"),
533532
new OptionsChecker("QuietFlag", "import sys; sys.flags.quiet", "true", "false"),
534533
new OptionsChecker("VerboseFlag", "import sys; sys.flags.verbose", "true", "false"),

graalpython/com.oracle.graal.python.test/src/tests/cpyext/__init__.py

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -71,12 +71,6 @@ def setUp(self):
7171

7272

7373
def ccompile(self, name):
74-
if getattr(sys, "graal_python_opaque_filesystem", False):
75-
# distutils won't fully work with an opaque filesystem,
76-
# because we cannot read bytes from files and manipulate
77-
# them. We hope the code was already compiled.
78-
return
79-
8074
from distutils.core import setup, Extension
8175
source_file = '%s/%s.c' % (__dir__, name)
8276
file_not_empty(source_file)

graalpython/com.oracle.graal.python.test/src/tests/cpyext/test_err.py

Lines changed: 28 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
1+
# Copyright (c) 2018, 2019, Oracle and/or its affiliates. All rights reserved.
22
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
33
#
44
# The Universal Permissive License (UPL), Version 1.0
@@ -152,24 +152,23 @@ def compile_module(self, name):
152152
cmpfunc=unhandled_error_compare
153153
)
154154

155-
if not getattr(sys, "graal_python_opaque_filesystem", False):
156-
test_PyErr_PrintEx = CPyExtFunction(
157-
lambda args: None,
158-
lambda: (
159-
(True,),
160-
),
161-
code="""PyObject* wrap_PyErr_PrintEx(int n) {
162-
PyErr_SetString(PyExc_KeyError, "unknown key whatsoever");
163-
PyErr_PrintEx(n);
164-
return Py_None;
165-
}
166-
""",
167-
resultspec="O",
168-
argspec='i',
169-
arguments=["int n"],
170-
callfunction="wrap_PyErr_PrintEx",
171-
cmpfunc=unhandled_error_compare
172-
)
155+
test_PyErr_PrintEx = CPyExtFunction(
156+
lambda args: None,
157+
lambda: (
158+
(True,),
159+
),
160+
code="""PyObject* wrap_PyErr_PrintEx(int n) {
161+
PyErr_SetString(PyExc_KeyError, "unknown key whatsoever");
162+
PyErr_PrintEx(n);
163+
return Py_None;
164+
}
165+
""",
166+
resultspec="O",
167+
argspec='i',
168+
arguments=["int n"],
169+
callfunction="wrap_PyErr_PrintEx",
170+
cmpfunc=unhandled_error_compare
171+
)
173172

174173
test_PyErr_GivenExceptionMatches = CPyExtFunction(
175174
_reference_givenexceptionmatches,
@@ -267,17 +266,16 @@ def compile_module(self, name):
267266
cmpfunc=unhandled_error_compare
268267
)
269268

270-
if not getattr(sys, "graal_python_opaque_filesystem", False):
271-
test_PyErr_WarnEx = CPyExtFunctionVoid(
272-
lambda args: warnings.warn(args[1], args[0], args[2]),
273-
lambda: (
274-
(UserWarning, "custom warning", 1),
275-
),
276-
resultspec="O",
277-
argspec='Osn',
278-
arguments=["PyObject* category", "char* msg", "Py_ssize_t level"],
279-
cmpfunc=unhandled_error_compare
280-
)
269+
test_PyErr_WarnEx = CPyExtFunctionVoid(
270+
lambda args: warnings.warn(args[1], args[0], args[2]),
271+
lambda: (
272+
(UserWarning, "custom warning", 1),
273+
),
274+
resultspec="O",
275+
argspec='Osn',
276+
arguments=["PyObject* category", "char* msg", "Py_ssize_t level"],
277+
cmpfunc=unhandled_error_compare
278+
)
281279

282280
test_PyErr_NoMemory = CPyExtFunctionVoid(
283281
_reference_nomemory,

graalpython/com.oracle.graal.python.test/src/tests/test_pyio.py

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
1+
# Copyright (c) 2018, 2019, Oracle and/or its affiliates. All rights reserved.
22
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
33
#
44
# The Universal Permissive License (UPL), Version 1.0
@@ -176,11 +176,3 @@ def test_builtin_open():
176176
unlink(file_name)
177177

178178
assert success
179-
180-
181-
import sys
182-
if getattr(sys, "graal_python_opaque_filesystem", False):
183-
# this cannot possibly work with opaque files
184-
for k in globals():
185-
if k.startswith("test_"):
186-
del globals()[k]

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

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,6 @@
9090
import com.oracle.graal.python.builtins.objects.PNone;
9191
import com.oracle.graal.python.builtins.objects.PNotImplemented;
9292
import com.oracle.graal.python.builtins.objects.bytes.BytesNodes;
93-
import com.oracle.graal.python.builtins.objects.bytes.OpaqueBytes;
9493
import com.oracle.graal.python.builtins.objects.bytes.PBytes;
9594
import com.oracle.graal.python.builtins.objects.code.PCode;
9695
import com.oracle.graal.python.builtins.objects.common.HashingCollectionNodes;
@@ -774,12 +773,6 @@ PCode compile(PBytes source, String filename, String mode, Object kwFlags, Objec
774773
return compile(new String(toBytesNode.execute(source)), filename, mode, kwFlags, kwDontInherit, kwOptimize);
775774
}
776775

777-
@Specialization
778-
@TruffleBoundary
779-
PCode compile(OpaqueBytes source, String filename, String mode, Object kwFlags, Object kwDontInherit, Object kwOptimize) {
780-
return compile(new String(source.getBytes()), filename, mode, kwFlags, kwDontInherit, kwOptimize);
781-
}
782-
783776
@SuppressWarnings("unused")
784777
@Specialization
785778
@TruffleBoundary

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

Lines changed: 1 addition & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,6 @@
101101
import com.oracle.graal.python.builtins.modules.PosixModuleBuiltinsFactory.StatNodeFactory;
102102
import com.oracle.graal.python.builtins.objects.PNone;
103103
import com.oracle.graal.python.builtins.objects.bytes.BytesNodes.ToBytesNode;
104-
import com.oracle.graal.python.builtins.objects.bytes.OpaqueBytes;
105104
import com.oracle.graal.python.builtins.objects.bytes.PByteArray;
106105
import com.oracle.graal.python.builtins.objects.bytes.PBytes;
107106
import com.oracle.graal.python.builtins.objects.bytes.PIBytesLike;
@@ -1118,19 +1117,7 @@ public abstract static class ReadNode extends PythonFileNode {
11181117

11191118
@CompilationFinal private BranchProfile tooLargeProfile = BranchProfile.create();
11201119

1121-
@Specialization(guards = "readOpaque(frame)")
1122-
Object readOpaque(@SuppressWarnings("unused") VirtualFrame frame, int fd, long requestedSize,
1123-
@Cached("createClassProfile()") ValueProfile channelClassProfile,
1124-
@Cached("create()") ReadFromChannelNode readNode) {
1125-
if (OpaqueBytes.isInOpaqueFilesystem(getResources().getFilePath(fd), getContext())) {
1126-
Channel channel = getResources().getFileChannel(fd, channelClassProfile);
1127-
ByteSequenceStorage bytes = readNode.execute(channel, ReadFromChannelNode.MAX_READ);
1128-
return new OpaqueBytes(Arrays.copyOf(bytes.getInternalByteArray(), bytes.length()));
1129-
}
1130-
return read(frame, fd, requestedSize, channelClassProfile, readNode);
1131-
}
1132-
1133-
@Specialization(guards = "!readOpaque(frame)")
1120+
@Specialization
11341121
Object read(@SuppressWarnings("unused") VirtualFrame frame, int fd, long requestedSize,
11351122
@Cached("createClassProfile()") ValueProfile channelClassProfile,
11361123
@Cached("create()") ReadFromChannelNode readNode) {
@@ -1145,13 +1132,6 @@ Object read(@SuppressWarnings("unused") VirtualFrame frame, int fd, long request
11451132
ByteSequenceStorage array = readNode.execute(channel, size);
11461133
return factory().createBytes(array);
11471134
}
1148-
1149-
/**
1150-
* @param frame - only used so the DSL sees this as a dynamic check
1151-
*/
1152-
protected boolean readOpaque(VirtualFrame frame) {
1153-
return OpaqueBytes.isEnabled(getContext());
1154-
}
11551135
}
11561136

11571137
@Builtin(name = "isatty", minNumOfPositionalArgs = 1)

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

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -180,8 +180,6 @@ public void postInitialize(PythonCore core) {
180180
sys.setAttribute("graal_python_home", context.getLanguage().getHome());
181181
sys.setAttribute("graal_python_core_home", PythonOptions.getOption(context, PythonOptions.CoreHome));
182182
sys.setAttribute("graal_python_stdlib_home", PythonOptions.getOption(context, PythonOptions.StdLibHome));
183-
sys.setAttribute("graal_python_opaque_filesystem", PythonOptions.getOption(context, PythonOptions.OpaqueFilesystem));
184-
sys.setAttribute("graal_python_opaque_filesystem_prefix", PythonOptions.getOption(context, PythonOptions.OpaqueFilesystemPrefixes));
185183
sys.setAttribute("__flags__", core.factory().createTuple(new Object[]{
186184
false, // bytes_warning
187185
!PythonOptions.getFlag(context, PythonOptions.PythonOptimizeFlag), // debug

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/bytes/BytesBuiltins.java

Lines changed: 1 addition & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,6 @@
5858
import com.oracle.graal.python.builtins.objects.common.IndexNodes.NormalizeIndexNode;
5959
import com.oracle.graal.python.builtins.objects.common.SequenceStorageNodes;
6060
import com.oracle.graal.python.builtins.objects.iterator.PSequenceIterator;
61-
import com.oracle.graal.python.builtins.objects.list.PList;
6261
import com.oracle.graal.python.builtins.objects.memoryview.PMemoryView;
6362
import com.oracle.graal.python.nodes.call.special.LookupAndCallUnaryNode;
6463
import com.oracle.graal.python.nodes.function.PythonBuiltinBaseNode;
@@ -325,33 +324,7 @@ public Object repr(PBytes self,
325324
@Builtin(name = "join", minNumOfPositionalArgs = 2)
326325
@GenerateNodeFactory
327326
public abstract static class JoinNode extends PythonBinaryBuiltinNode {
328-
/**
329-
* @param bytes - the parameter is used to force the DSL to make this a dynamic check
330-
*/
331-
protected boolean readOpaque(PBytes bytes) {
332-
return OpaqueBytes.isEnabled(getContext());
333-
}
334-
335-
@Specialization(guards = {"readOpaque(bytes)"})
336-
public Object join(PBytes bytes, PList iterable,
337-
@Cached("create()") SequenceStorageNodes.GetItemNode getItemNode,
338-
@Cached("create()") SequenceStorageNodes.LenNode lenNode,
339-
@Cached("create()") SequenceStorageNodes.ToByteArrayNode toByteArrayNode,
340-
@Cached("create()") BytesNodes.BytesJoinNode bytesJoinNode) {
341-
int len = lenNode.execute(iterable.getSequenceStorage());
342-
if (len == 1) {
343-
// branch profiles aren't really needed, because of the specialization
344-
// happening in the getItemNode on first execution and the assumption
345-
// in OpaqueBytes.isInstance
346-
Object firstItem = getItemNode.execute(iterable.getSequenceStorage(), 0);
347-
if (OpaqueBytes.isInstance(firstItem)) {
348-
return firstItem;
349-
}
350-
}
351-
return join(bytes, iterable, toByteArrayNode, bytesJoinNode);
352-
}
353-
354-
@Specialization(guards = {"!readOpaque(bytes)"})
327+
@Specialization
355328
public PBytes join(PBytes bytes, Object iterable,
356329
@Cached("create()") SequenceStorageNodes.ToByteArrayNode toByteArrayNode,
357330
@Cached("create()") BytesNodes.BytesJoinNode bytesJoinNode) {

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/bytes/OpaqueBytes.java

Lines changed: 0 additions & 140 deletions
This file was deleted.

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/runtime/PythonContext.java

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@
4141

4242
import com.oracle.graal.python.PythonLanguage;
4343
import com.oracle.graal.python.builtins.objects.PythonAbstractObject;
44-
import com.oracle.graal.python.builtins.objects.bytes.OpaqueBytes;
4544
import com.oracle.graal.python.builtins.objects.cext.PThreadState;
4645
import com.oracle.graal.python.builtins.objects.cext.PythonNativeClass;
4746
import com.oracle.graal.python.builtins.objects.common.HashingStorage;
@@ -257,8 +256,6 @@ private void setupRuntimeInformation() {
257256

258257
sysModules.setItem(__MAIN__, mainModule);
259258

260-
OpaqueBytes.initializeForNewContext(this);
261-
262259
currentException = null;
263260
isInitialized = true;
264261
}

0 commit comments

Comments
 (0)