[PR #915] [MERGED] Optimization: execute const object bodies and typechecks only once #801

Closed
opened 2025-12-30 01:26:52 +01:00 by adam · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/apple/pkl/pull/915
Author: @bioball
Created: 1/29/2025
Status: Merged
Merged: 1/29/2025
Merged by: @bioball

Base: mainHead: const-member-optimization


📝 Commits (1)

  • 5bd4ef5 Optimization: execute const object bodies and typechecks only once

📊 Changes

3 files changed (+37 additions, -0 deletions)

View changed files

📝 pkl-core/src/main/java/org/pkl/core/runtime/VmUtils.java (+12 -0)
pkl-core/src/test/files/LanguageSnippetTests/input/basic/constModifier5.pkl (+13 -0)
pkl-core/src/test/files/LanguageSnippetTests/output/basic/constModifier5.err (+12 -0)

📄 Description

Closes https://github.com/apple/pkl/issues/508

If the object member is const, it only needs to be executed once, and all children in the prototype chain can use its cached value.

There is a possible other optimization here, not included in this PR: we can avoid adding these values to the child object's cachedMembers.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/apple/pkl/pull/915 **Author:** [@bioball](https://github.com/bioball) **Created:** 1/29/2025 **Status:** ✅ Merged **Merged:** 1/29/2025 **Merged by:** [@bioball](https://github.com/bioball) **Base:** `main` ← **Head:** `const-member-optimization` --- ### 📝 Commits (1) - [`5bd4ef5`](https://github.com/apple/pkl/commit/5bd4ef5ad13815d58e947772d558c781843f2a92) Optimization: execute const object bodies and typechecks only once ### 📊 Changes **3 files changed** (+37 additions, -0 deletions) <details> <summary>View changed files</summary> 📝 `pkl-core/src/main/java/org/pkl/core/runtime/VmUtils.java` (+12 -0) ➕ `pkl-core/src/test/files/LanguageSnippetTests/input/basic/constModifier5.pkl` (+13 -0) ➕ `pkl-core/src/test/files/LanguageSnippetTests/output/basic/constModifier5.err` (+12 -0) </details> ### 📄 Description Closes https://github.com/apple/pkl/issues/508 If the object member is const, it only needs to be executed once, and all children in the prototype chain can use its cached value. There is a possible other optimization here, not included in this PR: we can avoid adding these values to the child object's `cachedMembers`. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
adam added the pull-request label 2025-12-30 01:26:52 +01:00
adam closed this issue 2025-12-30 01:26:52 +01:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/pkl#801