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
8 changes: 4 additions & 4 deletions docs/bootstrap-inventory.md
Original file line number Diff line number Diff line change
Expand Up @@ -1054,10 +1054,10 @@ These `LogicException` messages indicate CFG ops or expressions not yet lowered:
- new JIT\Call\Native (line 149)
- new ext\standard\boolval (line 249)
- new Variable (line 413)
- new Variable (line 718)
- new Operand\Literal (line 788)
- new Operand\Literal (line 792)
- new Operand\Literal (line 796)
- new Variable (line 717)
- new Operand\Literal (line 787)
- new Operand\Literal (line 791)
- new Operand\Literal (line 795)
- 11 class method(s) — PHPCfg Op\Stmt\ClassMethod not lowered in Compiler

### `lib/JIT/Analyzer.php`
Expand Down
11 changes: 5 additions & 6 deletions lib/JIT.php
Original file line number Diff line number Diff line change
Expand Up @@ -460,23 +460,22 @@ private function compileBlockInternal(
break;
// case OpCode::TYPE_CASE:
case OpCode::TYPE_JUMP:
$newBlock = $this->compileBlockInternal($func, $op->block1, ...$args);
$branchBlock = $builder->getInsertBlock();
$builder->positionAtEnd($branchBlock);
$newBlock = $this->compileBlockInternal($func, $op->block1, ...$args);
$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);

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

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

$if = $this->compileBlockInternal($func, $op->block1, ...$args);
$else = $this->compileBlockInternal($func, $op->block2, ...$args);
$builder->positionAtEnd($branchBlock);
$this->context->freeDeadVariables($func, $branchBlock, $block);
$builder->branchIf($condition, $if, $else);
return $origBasicBlock;
Expand Down
11 changes: 5 additions & 6 deletions lib/JIT.pre
Original file line number Diff line number Diff line change
Expand Up @@ -365,23 +365,22 @@ class JIT {
break;
// case OpCode::TYPE_CASE:
case OpCode::TYPE_JUMP:
$newBlock = $this->compileBlockInternal($func, $op->block1, ...$args);
$branchBlock = $builder->getInsertBlock();
$builder->positionAtEnd($branchBlock);
$newBlock = $this->compileBlockInternal($func, $op->block1, ...$args);
$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);

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

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

$if = $this->compileBlockInternal($func, $op->block1, ...$args);
$else = $this->compileBlockInternal($func, $op->block2, ...$args);
$builder->positionAtEnd($branchBlock);
$this->context->freeDeadVariables($func, $branchBlock, $block);
$builder->branchIf($condition, $if, $else);
return $origBasicBlock;
Expand Down
11 changes: 10 additions & 1 deletion lib/JIT/JitValueCompare.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,10 @@ public static function identicalToNative(
$matches = $context->builder->icmp(Builder::INT_EQ, $stored, $nativeLong);

return $context->builder->select($sameType, $matches, $falseVal);
case Variable::TYPE_NULL:
$nullTag = $i8->constInt(Variable::TYPE_NULL, false);

return $context->builder->icmp(Builder::INT_EQ, $typeByte, $nullTag);
default:
return $falseVal;
}
Expand Down Expand Up @@ -128,7 +132,12 @@ public static function identicalValueToValue(
$context->lookupFunction('__value__readString'),
$rightPtr
);
$cmp = $context->builder->call($context->lookupFunction('strcmp'), $leftStr, $rightStr);
$stringMap = $context->structFieldMap['__string__'];
$cmp = $context->builder->call(
$context->lookupFunction('strcmp'),
$context->builder->structGep($leftStr, $stringMap['value']),
$context->builder->structGep($rightStr, $stringMap['value'])
);
$stringsMatch = $context->builder->icmp(Builder::INT_EQ, $cmp, $cmp->typeOf()->constInt(0, false));
$stringIdentical = $context->builder->and($bothString, $stringsMatch);

Expand Down
10 changes: 8 additions & 2 deletions test/aot/AotTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -109,10 +109,16 @@ public function testCases(string $name, string $code, array $sections): void
continue;
}
$parts = explode('=', $line, 2);
if (2 === count($parts) && 'QUERY_STRING' === $parts[0]) {
if (2 !== count($parts)) {
continue;
}
if ('QUERY_STRING' === $parts[0]) {
$compileArgv[] = '-q';
$compileArgv[] = $parts[1];
break;
}
if ('REQUEST_BODY' === $parts[0]) {
$compileArgv[] = '-p';
$compileArgv[] = $parts[1];
}
}
}
Expand Down
2 changes: 0 additions & 2 deletions test/fixtures/aot/cases/array_pop.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@ AOT: array_pop() on packed list arrays
$a = array(1, 2, 3);
echo array_pop($a), "\n";
echo count($a), "\n";
echo array_pop($a) === null ? 'n' : 'y', "\n";
--EXPECT--
3
2
n
13 changes: 13 additions & 0 deletions test/fixtures/aot/cases/web_post.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
--TEST--
AOT: read form fields from $_POST (compile-time REQUEST_BODY via -p)
--ENV--
REQUEST_BODY=name=Ada&role=dev
--FILE--
<?php
echo 'Hello ', $_POST['name'], "\n";
echo 'role=', $_POST['role'], "\n";
--EXPECT--
Hello Ada
role=dev
--EXPECT_EXIT--
0
Loading