|
34 | 34 | import javax.net.ssl.SSLEngine;
|
35 | 35 |
|
36 | 36 | import com.oracle.graal.python.PythonLanguage;
|
| 37 | +import com.oracle.graal.python.builtins.Python3Core; |
37 | 38 | import com.oracle.graal.python.builtins.PythonBuiltinClassType;
|
38 | 39 | import com.oracle.graal.python.builtins.modules.PosixModuleBuiltins.PosixFileHandle;
|
39 | 40 | import com.oracle.graal.python.builtins.modules.bz2.BZ2Object;
|
|
197 | 198 | import com.oracle.truffle.api.object.HiddenKey;
|
198 | 199 | import com.oracle.truffle.api.object.Shape;
|
199 | 200 |
|
| 201 | +/** |
| 202 | + * Factory for Python objects that also reports to Truffle's {@link AllocationReporter}. The |
| 203 | + * reporting needs current context. There are several implementations of this abstract class. Use |
| 204 | + * this rule of thumb when choosing which one to use: |
| 205 | + * <ul> |
| 206 | + * <li>In partially evaluated code: use adopted (@Child/@Cached) {@link PythonObjectFactory} node |
| 207 | + * </li> |
| 208 | + * <li>Behind {@code TruffleBoundary}: |
| 209 | + * <ul> |
| 210 | + * <li>When the current context is already available, use {@link Python3Core#factory()}. This avoids |
| 211 | + * repeated context lookups inside the factory.</li> |
| 212 | + * <li>When the current context is not available, but multiple objects will be created: lookup the |
| 213 | + * context and use {@link Python3Core#factory()}. This executes only one context lookup. Note: first |
| 214 | + * check if the caller could pass the context to avoid looking it up behind {@code TruffleBoundary}.</li> |
| 215 | + * <li>When the current context is not available, and only one object is to be created: use |
| 216 | + * {@link PythonObjectFactory#getUncached()}.</li> |
| 217 | + * </ul> |
| 218 | + * </li> |
| 219 | + * </ul> |
| 220 | + */ |
200 | 221 | @GenerateUncached
|
201 | 222 | @ImportStatic(PythonOptions.class)
|
202 | 223 | public abstract class PythonObjectFactory extends Node {
|
|
0 commit comments