Skip to content

Commit 008d647

Browse files
ircmaxelldriusan
andcommitted
Reuse parent VM Context
There is no reason to use runtime->run to spawn a new VM when including a file, so instead push a frame onto the existing one. Co-Authored-By: driusan <driusan@gmail.com>
1 parent 785d523 commit 008d647

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

lib/VM.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -282,7 +282,10 @@ public function run(Block $block): int {
282282
case OpCode::TYPE_INCLUDE:
283283
$file = $frame->scope[$op->arg1]->toString();
284284
$parsed = $this->context->runtime->parseAndCompileFile($file);
285-
$this->context->runtime->run($parsed);
285+
$new = $parsed->getFrame($this->context);
286+
$this->context->push($frame);
287+
$frame = $new;
288+
goto restart;
286289
break;
287290
default:
288291
throw new \LogicException("VM OpCode Not Implemented: " . $op->getType());

0 commit comments

Comments
 (0)