mirror of
https://github.com/apple/pkl.git
synced 2026-08-29 15:07:17 +02:00
Improve reading of const members (#1835)
The previous implementation can cause the JIT compiler to permanently bail out when reading const memebrs.
This commit is contained in:
@@ -353,9 +353,16 @@ public final class VmUtils {
|
|||||||
// can be re-used for all children in the amends chain.
|
// can be re-used for all children in the amends chain.
|
||||||
if (member.isConst() && owner != receiver) {
|
if (member.isConst() && owner != receiver) {
|
||||||
assert member.isProp();
|
assert member.isProp();
|
||||||
|
// `const` properties can possibly be declared on non-prototypes, but they must be also
|
||||||
|
// declared `local`; and that code path goes through `Read*LocalPropertyNode`.
|
||||||
|
// thus, this assertion is correct here.
|
||||||
assert owner.isPrototype();
|
assert owner.isPrototype();
|
||||||
var result = readMemberOrNull(owner, memberKey, checkType, callNode);
|
var cachedValue = owner.getCachedValue(memberKey);
|
||||||
assert result != null;
|
if (cachedValue != null) {
|
||||||
|
receiver.setCachedValue(memberKey, cachedValue);
|
||||||
|
return cachedValue;
|
||||||
|
}
|
||||||
|
var result = doReadMember(owner, owner, memberKey, member, checkType, callNode);
|
||||||
receiver.setCachedValue(memberKey, result);
|
receiver.setCachedValue(memberKey, result);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user