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
13 changes: 13 additions & 0 deletions lib/JIT/IssetHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,19 @@ private static function hashtableFromObjectContainer(
return $context->type->object->splBackingHashtable($container);
}
if (null !== $container->objectPropertySlot) {
if (Variable::TYPE_HASHTABLE === $container->objectPropertyType) {
$htPtr = $context->builder->pointerCast(
$context->builder->load($container->objectPropertySlot),
$context->getTypeFromString('__hashtable__*')
);

return new Variable(
$context,
Variable::TYPE_HASHTABLE,
Variable::KIND_VALUE,
$htPtr
);
}
$valueType = $context->getTypeFromString('__value__');
$storage = $context->builder->alloca($valueType, 1, 'isset_obj_prop');
$valueMap = $context->structFieldMap['__value__'];
Expand Down
26 changes: 17 additions & 9 deletions lib/JIT/Variable.php
Original file line number Diff line number Diff line change
Expand Up @@ -433,6 +433,7 @@ public function free(): void {
? $this->value
: $this->context->helper->loadValue($this);
$this->context->refcount->delref($ptr);

return;
}
throw new \LogicException('Unknown free type: ' . $this->type);
Expand All @@ -453,6 +454,12 @@ public function initialize(): void {
$this->value
);
break;
case self::TYPE_HASHTABLE:
$this->context->builder->store(
$this->context->getTypeFromString('__hashtable__*')->constNull(),
$this->value
);
break;
case self::TYPE_VALUE:
case self::TYPE_NULL:
$map = $this->context->structFieldMap['__value__'];
Expand Down Expand Up @@ -489,10 +496,11 @@ public function dimFetch(self $dim, ?Type $expectedType = null, bool $forWrite =
case self::TYPE_HASHTABLE:
// Property slots own the hashtable; transient delref would free it (#58).
$propertyBacked = null !== $this->objectPropertySlot;
$container = HashTableHelper::asDetachedHashtable($this->context, $this);
if (
!$forWrite
&& null !== $this->superglobalName
&& '_FILES' !== $this->superglobalName
&& null !== $container->superglobalName
&& '_FILES' !== $container->superglobalName
&& self::TYPE_STRING === $dim->type
&& (null === $expectedType || Type::TYPE_ARRAY !== $expectedType->type)
) {
Expand All @@ -502,7 +510,7 @@ public function dimFetch(self $dim, ?Type $expectedType = null, bool $forWrite =
? null
: SuperglobalInit::compileTimeReadString(
$this->context,
$this->superglobalName,
$container->superglobalName,
$key
);
if (null !== $baked) {
Expand All @@ -513,7 +521,7 @@ public function dimFetch(self $dim, ?Type $expectedType = null, bool $forWrite =
$baked
);
}
$ht = $this->context->helper->loadValue($this);
$ht = $this->context->helper->loadValue($container);
$keyVal = $this->context->helper->loadValue($dim);

return HashTableHelper::readSuperglobalStringKeyToValueBox(
Expand All @@ -523,7 +531,7 @@ public function dimFetch(self $dim, ?Type $expectedType = null, bool $forWrite =
);
}
}
$ht = $this->context->helper->loadValue($this);
$ht = $this->context->helper->loadValue($container);
if (self::TYPE_VALUE === $dim->type || self::TYPE_OBJECT === $dim->type) {
$keyObj = self::TYPE_OBJECT === $dim->type
? $this->context->helper->loadValue($dim)
Expand All @@ -548,7 +556,7 @@ public function dimFetch(self $dim, ?Type $expectedType = null, bool $forWrite =

return HashTableHelper::writableStringKeyValueBox($this->context, $ht, $key);
}
if ('_FILES' === $this->superglobalName && !$forWrite) {
if ('_FILES' === $container->superglobalName && !$forWrite) {
$childHt = $this->context->builder->call(
$this->context->lookupFunction('__hashtable__readStringKeyHashtable'),
$ht,
Expand Down Expand Up @@ -608,7 +616,7 @@ public function dimFetch(self $dim, ?Type $expectedType = null, bool $forWrite =
$this->context->lookupFunction('__string__separate'),
$str
);
if (!$propertyBacked && null === $this->superglobalName) {
if (!$propertyBacked && null === $container->superglobalName) {
$this->context->refcount->delref($ht);
}

Expand All @@ -619,11 +627,11 @@ public function dimFetch(self $dim, ?Type $expectedType = null, bool $forWrite =
$owned
);
}
if (null === $this->superglobalName) {
if (!$propertyBacked && null === $container->superglobalName) {
$this->context->refcount->addref($ht);
}
$boxed = HashTableHelper::readIndexedToValueBox($this->context, $ht, $index);
if (null === $this->superglobalName) {
if (!$propertyBacked && null === $container->superglobalName) {
$this->context->refcount->delref($ht);
}

Expand Down