Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Docker/dev/ubuntu-22.04/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
git curl unzip ca-certificates \
php8.2-cli php8.2-mbstring php8.2-xml php8.2-ffi php8.2-posix php8.2-phar \
php8.2-tokenizer php8.2-dom php8.2-xmlwriter \
build-essential clang llvm-14-dev \
build-essential clang llvm-14-dev libjansson4 \
&& rm -rf /var/lib/apt/lists/* \
&& curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer

Expand Down
18 changes: 12 additions & 6 deletions lib/JIT.php
Original file line number Diff line number Diff line change
Expand Up @@ -461,33 +461,39 @@ private function compileBlockInternal(
// case OpCode::TYPE_CASE:
case OpCode::TYPE_JUMP:
$newBlock = $this->compileBlockInternal($func, $op->block1, ...$args);
$builder->positionAtEnd($basicBlock);
$this->context->freeDeadVariables($func, $basicBlock, $block);
$branchBlock = $builder->getInsertBlock();
$builder->positionAtEnd($branchBlock);
$this->context->freeDeadVariables($func, $branchBlock, $block);
$builder->branch($newBlock);
return $origBasicBlock;
case OpCode::TYPE_JUMPIF:
$if = $this->compileBlockInternal($func, $op->block1, ...$args);
$else = $this->compileBlockInternal($func, $op->block2, ...$args);

$builder->positionAtEnd($basicBlock);
$branchBlock = $builder->getInsertBlock();
$builder->positionAtEnd($branchBlock);

$condition = $this->context->castToBool(
$this->context->helper->loadValue($this->context->getVariableFromOp($block->getOperand($op->arg1)))
);

$this->context->freeDeadVariables($func, $basicBlock, $block);
$this->context->freeDeadVariables($func, $branchBlock, $block);
$builder->branchIf($condition, $if, $else);
return $origBasicBlock;
case OpCode::TYPE_RETURN_VOID:
$this->context->freeDeadVariables($func, $basicBlock, $block);
$returnBlock = $builder->getInsertBlock();
$builder->positionAtEnd($returnBlock);
$this->context->freeDeadVariables($func, $returnBlock, $block);
$this->context->builder->returnVoid();

return $origBasicBlock;
case OpCode::TYPE_RETURN:
$return = $this->context->getVariableFromOp($block->getOperand($op->arg1));
$return->addref();
$retval = $this->context->helper->loadValue($return);
$this->context->freeDeadVariables($func, $basicBlock, $block);
$returnBlock = $builder->getInsertBlock();
$builder->positionAtEnd($returnBlock);
$this->context->freeDeadVariables($func, $returnBlock, $block);
$this->context->builder->returnValue($retval);

return $origBasicBlock;
Expand Down
18 changes: 12 additions & 6 deletions lib/JIT.pre
Original file line number Diff line number Diff line change
Expand Up @@ -366,32 +366,38 @@ class JIT {
// case OpCode::TYPE_CASE:
case OpCode::TYPE_JUMP:
$newBlock = $this->compileBlockInternal($func, $op->block1, ...$args);
$builder->positionAtEnd($basicBlock);
$this->context->freeDeadVariables($func, $basicBlock, $block);
$branchBlock = $builder->getInsertBlock();
$builder->positionAtEnd($branchBlock);
$this->context->freeDeadVariables($func, $branchBlock, $block);
$builder->branch($newBlock);
return $origBasicBlock;
case OpCode::TYPE_JUMPIF:
$if = $this->compileBlockInternal($func, $op->block1, ...$args);
$else = $this->compileBlockInternal($func, $op->block2, ...$args);

$builder->positionAtEnd($basicBlock);
$branchBlock = $builder->getInsertBlock();
$builder->positionAtEnd($branchBlock);

$condition = $this->context->castToBool(
$this->context->helper->loadValue($this->context->getVariableFromOp($block->getOperand($op->arg1)))
);

$this->context->freeDeadVariables($func, $basicBlock, $block);
$this->context->freeDeadVariables($func, $branchBlock, $block);
$builder->branchIf($condition, $if, $else);
return $origBasicBlock;
case OpCode::TYPE_RETURN_VOID:
$this->context->freeDeadVariables($func, $basicBlock, $block);
$returnBlock = $builder->getInsertBlock();
$builder->positionAtEnd($returnBlock);
$this->context->freeDeadVariables($func, $returnBlock, $block);
compile { return; }
return $origBasicBlock;
case OpCode::TYPE_RETURN:
$return = $this->context->getVariableFromOp($block->getOperand($op->arg1));
$return->addref();
$retval = $this->context->helper->loadValue($return);
$this->context->freeDeadVariables($func, $basicBlock, $block);
$returnBlock = $builder->getInsertBlock();
$builder->positionAtEnd($returnBlock);
$this->context->freeDeadVariables($func, $returnBlock, $block);
compile { return $retval; }
return $origBasicBlock;
case OpCode::TYPE_FUNCDEF:
Expand Down
4 changes: 2 additions & 2 deletions script/docker-ci-local.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ if ! docker image inspect "$IMAGE" >/dev/null 2>&1; then
make docker-build-22
fi

if [[ -f vendor/bin/phpunit ]]; then
exec docker run --rm -v "$(pwd):/compiler" -w /compiler "$IMAGE" ./script/ci-local.sh "$@"
if [[ -f vendor/bin/phpunit ]] && docker run --rm -v "$(pwd):/compiler" -w /compiler "$IMAGE" test -f script/ci-local.sh 2>/dev/null; then
exec docker run --rm -v "$(pwd):/compiler" -w /compiler "$IMAGE" bash script/ci-local.sh "$@"
fi

echo "Bind-mount has no vendor/; copying repo into container via tar..."
Expand Down
12 changes: 12 additions & 0 deletions script/install-llvm9.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ need=0
[[ -f "$LLVM_DIR/gcc/9/crtbegin.o" ]] || need=1
[[ -f "$LLVM_DIR/libedit.so.2" ]] || need=1
[[ -f "$LLVM_DIR/libz3.so.4" ]] || need=1
[[ -f "$LLVM_DIR/libjansson.so.4" ]] || need=1
need_headers=0
[[ -f "$LLVM_DIR/sysroot/usr/include/stdio.h" ]] || need_headers=1
if [[ "$need" -eq 0 && "$need_headers" -eq 0 ]]; then
Expand Down Expand Up @@ -121,4 +122,15 @@ if [[ ! -f "$LLVM_DIR/libz3.so.4" ]]; then
install -m 644 "$dir/usr/lib/x86_64-linux-gnu/libz3.so.4" "$LLVM_DIR/libz3.so.4"
fi

# Bundled ld (binutils 2.40) needs libjansson at runtime on minimal images.
if [[ ! -f "$LLVM_DIR/libjansson.so.4" ]]; then
dir="$(fetch_deb "http://deb.debian.org/debian/pool/main/j/jansson/libjansson4_2.14-2_amd64.deb" libjansson4.deb)"
shopt -s nullglob
for lib in "$dir"/usr/lib/x86_64-linux-gnu/libjansson.so.4.*; do
install -m 644 "$lib" "$LLVM_DIR/$(basename "$lib")"
ln -sf "$(basename "$lib")" "$LLVM_DIR/libjansson.so.4"
done
shopt -u nullglob
fi

echo "LLVM 9 toolchain installed under $LLVM_DIR"
7 changes: 7 additions & 0 deletions test/fixtures/aot/cases/hello_world_example.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
--TEST--
AOT: examples/000-HelloWorld (echo string literal)
--FILE--
<?php
echo "Hello World\n";
--EXPECT--
Hello World
Loading