Skip to content

Commit 8019b11

Browse files
committed
Stub for _tracemalloc
1 parent 41c392a commit 8019b11

File tree

3 files changed

+98
-2
lines changed

3 files changed

+98
-2
lines changed

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/Python3Core.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@
5555
import java.util.ServiceLoader;
5656
import java.util.logging.Level;
5757

58+
import com.oracle.graal.python.builtins.modules.TracemallocModuleBuiltins;
5859
import org.graalvm.nativeimage.ImageInfo;
5960

6061
import com.oracle.graal.python.PythonLanguage;
@@ -575,7 +576,7 @@ private static PythonBuiltins[] initializeBuiltins(boolean nativeAccessAllowed)
575576
new PythonCextWarnBuiltins(),
576577
new WeakRefModuleBuiltins(),
577578
new ReferenceTypeBuiltins(),
578-
new WarningsModuleBuiltins(),
579+
new TracemallocModuleBuiltins(),
579580
new ContextVarBuiltins(),
580581
new ContextBuiltins(),
581582
new TokenBuiltins(),
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
/*
2+
* Copyright (c) 2023, 2023, Oracle and/or its affiliates. All rights reserved.
3+
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4+
*
5+
* The Universal Permissive License (UPL), Version 1.0
6+
*
7+
* Subject to the condition set forth below, permission is hereby granted to any
8+
* person obtaining a copy of this software, associated documentation and/or
9+
* data (collectively the "Software"), free of charge and under any and all
10+
* copyright rights in the Software, and any and all patent rights owned or
11+
* freely licensable by each licensor hereunder covering either (i) the
12+
* unmodified Software as contributed to or provided by such licensor, or (ii)
13+
* the Larger Works (as defined below), to deal in both
14+
*
15+
* (a) the Software, and
16+
*
17+
* (b) any piece of software and/or hardware listed in the lrgrwrks.txt file if
18+
* one is included with the Software each a "Larger Work" to which the Software
19+
* is contributed by such licensors),
20+
*
21+
* without restriction, including without limitation the rights to copy, create
22+
* derivative works of, display, perform, and distribute the Software and make,
23+
* use, sell, offer for sale, import, export, have made, and have sold the
24+
* Software and the Larger Work(s), and to sublicense the foregoing rights on
25+
* either these or other terms.
26+
*
27+
* This license is subject to the following condition:
28+
*
29+
* The above copyright notice and either this complete permission notice or at a
30+
* minimum a reference to the UPL must be included in all copies or substantial
31+
* portions of the Software.
32+
*
33+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
34+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
35+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
36+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
37+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
38+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
39+
* SOFTWARE.
40+
*/
41+
package com.oracle.graal.python.builtins.modules;
42+
43+
import static com.oracle.graal.python.nodes.BuiltinNames.J__TRACEMALLOC;
44+
45+
import java.util.List;
46+
47+
import com.oracle.graal.python.builtins.Builtin;
48+
import com.oracle.graal.python.builtins.CoreFunctions;
49+
import com.oracle.graal.python.builtins.Python3Core;
50+
import com.oracle.graal.python.builtins.PythonBuiltinClassType;
51+
import com.oracle.graal.python.builtins.PythonBuiltins;
52+
import com.oracle.graal.python.nodes.PRaiseNode;
53+
import com.oracle.graal.python.nodes.function.PythonBuiltinBaseNode;
54+
import com.oracle.graal.python.nodes.function.PythonBuiltinNode;
55+
import com.oracle.truffle.api.dsl.Cached;
56+
import com.oracle.truffle.api.dsl.GenerateNodeFactory;
57+
import com.oracle.truffle.api.dsl.NodeFactory;
58+
import com.oracle.truffle.api.dsl.Specialization;
59+
60+
@CoreFunctions(defineModule = J__TRACEMALLOC)
61+
public class TracemallocModuleBuiltins extends PythonBuiltins {
62+
63+
@Override
64+
protected List<? extends NodeFactory<? extends PythonBuiltinBaseNode>> getNodeFactories() {
65+
return TracemallocModuleBuiltinsFactory.getFactories();
66+
}
67+
68+
@Override
69+
public void initialize(Python3Core core) {
70+
super.initialize(core);
71+
}
72+
73+
@Builtin(name = "_get_object_traceback", minNumOfPositionalArgs = 1)
74+
@GenerateNodeFactory
75+
abstract static class GetObjectTracebackNode extends PythonBuiltinNode {
76+
@Specialization
77+
static Object getObjectTraceback(Object obj,
78+
@Cached PRaiseNode raiseNode) {
79+
throw raiseNode.raise(PythonBuiltinClassType.NotImplementedError);
80+
}
81+
}
82+
83+
@Builtin(name = "_get_traces")
84+
@GenerateNodeFactory
85+
abstract static class GetTracesNode extends PythonBuiltinNode {
86+
@Specialization
87+
static Object getTraces(
88+
@Cached PRaiseNode raiseNode) {
89+
throw raiseNode.raise(PythonBuiltinClassType.NotImplementedError);
90+
}
91+
}
92+
}

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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2018, 2022, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2018, 2023, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* The Universal Permissive License (UPL), Version 1.0
@@ -365,6 +365,9 @@ public abstract class BuiltinNames {
365365
public static final String J__WARNINGS = "_warnings";
366366
public static final TruffleString T__WARNINGS = tsLiteral(J__WARNINGS);
367367

368+
public static final String J__TRACEMALLOC = "_tracemalloc";
369+
public static final TruffleString T__TRACEMALLOC = tsLiteral(J__TRACEMALLOC);
370+
368371
public static final String J_POSIX = "posix";
369372
public static final TruffleString T_POSIX = tsLiteral(J_POSIX);
370373

0 commit comments

Comments
 (0)