|
171 | 171 | import com.oracle.truffle.api.nodes.RootNode;
|
172 | 172 | import com.oracle.truffle.api.nodes.UnexpectedResultException;
|
173 | 173 | import com.oracle.truffle.api.profiles.ConditionProfile;
|
| 174 | +import com.oracle.truffle.api.profiles.ValueProfile; |
174 | 175 | import com.oracle.truffle.api.source.Source;
|
175 | 176 |
|
176 | 177 | @CoreFunctions(defineModule = "builtins")
|
@@ -488,33 +489,37 @@ public Object eval(VirtualFrame frame, String expression, @SuppressWarnings("unu
|
488 | 489 | }
|
489 | 490 |
|
490 | 491 | @Specialization
|
491 |
| - public Object eval(VirtualFrame frame, PCode code, @SuppressWarnings("unused") PNone globals, @SuppressWarnings("unused") PNone locals) { |
| 492 | + public Object eval(VirtualFrame frame, PCode code, @SuppressWarnings("unused") PNone globals, @SuppressWarnings("unused") PNone locals, |
| 493 | + @Cached("createIdentityProfile()") ValueProfile constantCt) { |
492 | 494 | Frame callerFrame = readCallerFrameNode.executeWith(frame);
|
493 | 495 | PythonObject callerGlobals = PArguments.getGlobals(callerFrame);
|
494 | 496 | PCell[] callerClosure = PArguments.getClosure(callerFrame);
|
495 |
| - return evalExpression(code, callerGlobals, callerGlobals, callerClosure); |
| 497 | + return evalExpression(constantCt.profile(code.getRootCallTarget()), callerGlobals, callerGlobals, callerClosure); |
496 | 498 | }
|
497 | 499 |
|
498 | 500 | @Specialization
|
499 |
| - public Object eval(VirtualFrame frame, PCode code, PythonObject globals, @SuppressWarnings("unused") PNone locals) { |
| 501 | + public Object eval(VirtualFrame frame, PCode code, PythonObject globals, @SuppressWarnings("unused") PNone locals, |
| 502 | + @Cached("createIdentityProfile()") ValueProfile constantCt) { |
500 | 503 | Frame callerFrame = readCallerFrameNode.executeWith(frame);
|
501 | 504 | PCell[] callerClosure = PArguments.getClosure(callerFrame);
|
502 |
| - return evalExpression(code, globals, globals, callerClosure); |
| 505 | + return evalExpression(constantCt.profile(code.getRootCallTarget()), globals, globals, callerClosure); |
503 | 506 | }
|
504 | 507 |
|
505 | 508 | @Specialization
|
506 |
| - public Object eval(VirtualFrame frame, PCode code, PythonObject globals, PythonObject locals) { |
| 509 | + public Object eval(VirtualFrame frame, PCode code, PythonObject globals, PythonObject locals, |
| 510 | + @Cached("createIdentityProfile()") ValueProfile constantCt) { |
507 | 511 | Frame callerFrame = readCallerFrameNode.executeWith(frame);
|
508 | 512 | PCell[] callerClosure = PArguments.getClosure(callerFrame);
|
509 |
| - return evalExpression(code, globals, locals, callerClosure); |
| 513 | + return evalExpression(constantCt.profile(code.getRootCallTarget()), globals, locals, callerClosure); |
510 | 514 | }
|
511 | 515 |
|
512 | 516 | @Specialization
|
513 |
| - public Object eval(VirtualFrame frame, PCode code, @SuppressWarnings("unused") PNone globals, PythonObject locals) { |
| 517 | + public Object eval(VirtualFrame frame, PCode code, @SuppressWarnings("unused") PNone globals, PythonObject locals, |
| 518 | + @Cached("createIdentityProfile()") ValueProfile constantCt) { |
514 | 519 | Frame callerFrame = readCallerFrameNode.executeWith(frame);
|
515 | 520 | PythonObject callerGlobals = PArguments.getGlobals(callerFrame);
|
516 | 521 | PCell[] callerClosure = PArguments.getClosure(callerFrame);
|
517 |
| - return evalExpression(code, callerGlobals, locals, callerClosure); |
| 522 | + return evalExpression(constantCt.profile(code.getRootCallTarget()), callerGlobals, locals, callerClosure); |
518 | 523 | }
|
519 | 524 |
|
520 | 525 | @Specialization
|
@@ -551,8 +556,8 @@ private byte[] getByteArray(PIBytesLike pByteArray) {
|
551 | 556 | }
|
552 | 557 |
|
553 | 558 | @TruffleBoundary
|
554 |
| - private static Object evalExpression(PCode code, PythonObject globals, PythonObject locals, PCell[] closure) { |
555 |
| - return evalNode(code.getRootCallTarget(), globals, locals, closure); |
| 559 | + private static Object evalExpression(RootCallTarget ct, PythonObject globals, PythonObject locals, PCell[] closure) { |
| 560 | + return evalNode(ct, globals, locals, closure); |
556 | 561 | }
|
557 | 562 |
|
558 | 563 | @TruffleBoundary
|
|
0 commit comments