|
161 | 161 | import com.oracle.graal.python.builtins.modules.io.TextIOWrapperNodes.TextIOWrapperInitNode; |
162 | 162 | import com.oracle.graal.python.builtins.modules.io.TextIOWrapperNodesFactory.TextIOWrapperInitNodeGen; |
163 | 163 | import com.oracle.graal.python.builtins.objects.PNone; |
| 164 | +import com.oracle.graal.python.builtins.objects.common.HashingStorageLibrary; |
164 | 165 | import com.oracle.graal.python.builtins.objects.common.SequenceStorageNodes; |
165 | 166 | import com.oracle.graal.python.builtins.objects.dict.PDict; |
166 | 167 | import com.oracle.graal.python.builtins.objects.exception.PBaseException; |
|
234 | 235 | import com.oracle.truffle.api.dsl.Specialization; |
235 | 236 | import com.oracle.truffle.api.frame.MaterializedFrame; |
236 | 237 | import com.oracle.truffle.api.frame.VirtualFrame; |
| 238 | +import com.oracle.truffle.api.library.CachedLibrary; |
237 | 239 | import com.oracle.truffle.api.nodes.Node; |
238 | 240 | import com.oracle.truffle.api.profiles.ConditionProfile; |
239 | 241 | import com.oracle.truffle.api.strings.TruffleString; |
@@ -789,6 +791,26 @@ private PException raiseCallStackDepth() { |
789 | 791 | } |
790 | 792 | } |
791 | 793 |
|
| 794 | + @Builtin(name = "_current_frames") |
| 795 | + @GenerateNodeFactory |
| 796 | + abstract static class CurrentFrames extends PythonBuiltinNode { |
| 797 | + @Specialization |
| 798 | + Object currentFrames(VirtualFrame frame, |
| 799 | + @Cached AuditNode auditNode, |
| 800 | + @Cached WarningsModuleBuiltins.WarnNode warnNode, |
| 801 | + @Cached ReadCallerFrameNode readCallerFrameNode, |
| 802 | + @CachedLibrary(limit = "1") HashingStorageLibrary hlib) { |
| 803 | + auditNode.audit("sys._current_frames"); |
| 804 | + if (!getLanguage().singleThreadedAssumption.isValid()) { |
| 805 | + warnNode.warn(frame, RuntimeWarning, ErrorMessages.WARN_CURRENT_FRAMES_MULTITHREADED); |
| 806 | + } |
| 807 | + PFrame currentFrame = readCallerFrameNode.executeWith(frame, 0); |
| 808 | + PDict result = factory().createDict(); |
| 809 | + result.setDictStorage(hlib.setItem(result.getDictStorage(), Thread.currentThread().getId(), currentFrame)); |
| 810 | + return result; |
| 811 | + } |
| 812 | + } |
| 813 | + |
792 | 814 | @Builtin(name = "getfilesystemencoding", minNumOfPositionalArgs = 0) |
793 | 815 | @GenerateNodeFactory |
794 | 816 | public abstract static class GetFileSystemEncodingNode extends PythonBuiltinNode { |
|
0 commit comments