Skip to content

objects_finalized template#437

Open
lwaern-intel wants to merge 2 commits intointel:mainfrom
lwaern-intel:lw/objects_finalized
Open

objects_finalized template#437
lwaern-intel wants to merge 2 commits intointel:mainfrom
lwaern-intel:lw/objects_finalized

Conversation

@lwaern-intel
Copy link
Copy Markdown
Contributor

No description provided.

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Note

Copilot was unable to run its full agentic suite in this review.

Adds an objects_finalized lifecycle hook/template for DML 1.4 devices that runs after successful configuration, updates code generation to invoke it, and documents the behavior alongside immediate-after semantics.

Changes:

  • Introduce objects_finalized template in DML 1.4 builtins and wire it into the device template.
  • Update C backend generation to invoke _objects_finalized before executing immediate-after callbacks.
  • Add a DML+Python test plus documentation/release note updates describing the new hook.

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
test/1.4/lib/T_objects_finalized.py Adds a test that asserts objects_finalized() ran for device and subdevice instances.
test/1.4/lib/T_objects_finalized.dml Defines a test device/subdevice using the new objects_finalized template and verifies immediate-after ordering.
py/dml/c_backend.py Emits a call to _objects_finalized in the generated Simics objects_finalized hook (for non-1.2).
lib/1.4/dml-builtins.dml Adds the objects_finalized template and integrates it into the built-in device template.
doc/1.4/language.md Documents that immediate-after callbacks during configuration run during the Simics objects_finalized hook after objects_finalized() calls.
RELEASENOTES-1.4.md Notes the addition of the objects_finalized template/hook.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread test/1.4/lib/T_objects_finalized.py Outdated
Comment thread py/dml/c_backend.py
Comment thread lib/1.4/dml-builtins.dml Outdated
Comment thread lib/1.4/dml-builtins.dml Outdated
Comment thread RELEASENOTES-1.4.md
`init` and `post_init`, representing the stage after the device has been
created. Once Simics has successfully completed configuring the device and
all other objects created at the same time as it, `objects_finalized()` will
be called of every object that instantiates the `objects_finalized` template.
Copy link

Copilot AI Apr 22, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Grammar fix: 'called of every object' should be 'called on every object'.

Suggested change
be called of every object that instantiates the `objects_finalized` template.
be called on every object that instantiates the `objects_finalized` template.

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hm. No, I don't think I agree with that, each objects_finalized method called are of the object that instantiates the template. @mandolaerik your opinion?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In that case you should spell out the objects_finalized() method.

Maybe it's smoother to read if you avoid passive form (will be called) and instead write smth like Simics will call or Simics calls. Also consider "all other objects created at the same time as it" => "all other simultaneously created objects"

@lwaern-intel lwaern-intel force-pushed the lw/objects_finalized branch from 22a583f to a24eee2 Compare April 22, 2026 13:33
@syssimics
Copy link
Copy Markdown
Contributor

PR Verification: ✅ success

@syssimics
Copy link
Copy Markdown
Contributor

PR Verification: ✅ success

Comment thread doc/1.4/language.md
[`post_init()`](dml-builtins.html#post_init), or
[`set()`](dml-builtins.html#attribute-objects) of a configured or checkpointed
attribute), then the callback will be executed as part of the
`objects_finalized` hook of `SIM_create_class`, just after the automatic calls
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe replace hook with some other word: hook is a thing in DML, and it's not obvious to the reader that we did not define a DML hook for objects_finalized.

Something like "will be executed when SIM_create_class calls the objects_finalized function of class_info_t"?

Comment thread lib/1.4/dml-builtins.dml
Comment on lines +425 to +428
Provides an abstract method `objects_finalized`, which is called once both the
device and all other objects created at the same time as it have been
successfully configured, such that they are ready to be communicated with.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The sentence is correct but somewhat heavy, which is OK for a technical definition I guess. Maybe s/be communicated with/communicate [with other devices]/?

It would be good to also have a separate section somewhere that discusses the different instantiation primitives and how you partition code between them. Not part of this PR though.

Comment on lines +16 to +17
assert SIM_object_is_configured(dev.obj);
assert SIM_object_is_configured(partner.obj);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

move to s.objects_finalized(), which is called before?

subdevice s is objects_finalized {
saved bool objects_finalized_done;
method objects_finalized() {
objects_finalized_done = true;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe also assert dev.objects_finalized_done == false;? as a stability test that post-order traversal is used.

@mandolaerik
Copy link
Copy Markdown
Contributor

Looks good overall

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants