Skip to content

Admit dynamic optional identifier calls to bytecode - #3046

Merged
rogeralsing merged 1 commit into
mainfrom
codex/unified-bytecode-loop-86-dynamic-optional-call
Jun 2, 2026
Merged

Admit dynamic optional identifier calls to bytecode#3046
rogeralsing merged 1 commit into
mainfrom
codex/unified-bytecode-loop-86-dynamic-optional-call

Conversation

@rogeralsing

Copy link
Copy Markdown
Contributor

Summary

  • add PrepareDynamicIdentifierOptionalCallTarget for captured/dynamic optional identifier calls
  • wire production eligibility, compiler emission, VM short-circuit execution, and call-environment requirements
  • document the admitted simple-return captured optional identifier call shape and keep complex arguments declined

Verification

  • rtk dotnet test tests/Asynkron.JsEngine.Tests --filter "FullyQualifiedNameUnifiedBytecodeProductionInvocationTests&FullyQualifiedNameCapturedOptionalIdentifierCallExpression"
  • rtk dotnet test tests/Asynkron.JsEngine.Tests --filter "FullyQualifiedNameUnifiedBytecodeProductionEligibilityTests&FullyQualifiedNameDynamicOptionalIdentifierCallTarget"
  • rtk dotnet test tests/Asynkron.JsEngine.Tests --filter "FullyQualifiedName~UnifiedBytecodeProductionEligibilityTests"
  • rtk dotnet test tests/Asynkron.JsEngine.Tests --filter "FullyQualifiedName~UnifiedBytecodeProductionInvocationTests"
  • rtk dotnet test tests/Asynkron.JsEngine.Tests --filter "FullyQualifiedName~UnifiedBytecodeProduction"
  • rtk dotnet test tests/Asynkron.JsEngine.Tests --filter "FullyQualifiedName~ActivationSemanticsProofPackTests"
  • rtk dotnet test tests/Asynkron.JsEngine.Tests --filter "FullyQualifiedNameExpressionProgramCoverageMapTests&FullyQualifiedNameUnifiedBytecodeExpansionContract_ListsRequiredHeadingsAndCurrentEnums"
  • rtk dotnet build -c Release
  • rtk rg "EvaluateExpression\(|ProfileEvaluateExpression\(" src/Asynkron.JsEngine/Ast/TypedAstEvaluator.ExecutionPlanRunner* (no matches)
  • rtk ./tools/profile forloop --memory (Total allocated 6.85 MB)
  • rtk git diff --check

Copilot AI review requested due to automatic review settings June 2, 2026 02:41
@rogeralsing
rogeralsing merged commit 5a695dd into main Jun 2, 2026
@rogeralsing
rogeralsing deleted the codex/unified-bytecode-loop-86-dynamic-optional-call branch June 2, 2026 02:42

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

This PR extends the unified bytecode production pipeline to admit callee-optional identifier calls (fn?.(args)) when the identifier must be resolved via the dynamic environment (e.g., captured/dynamic identifier), including eligibility checks, compiler emission, VM execution/short-circuiting, and activation-environment requirements.

Changes:

  • Add and wire a new opcode PrepareDynamicIdentifierOptionalCallTarget across the unified bytecode compiler, eligibility analysis, VM interpreter, and activation requirements.
  • Expand eligibility logic to accept optional identifier call targets via dynamic identifier operations (when allowed), while continuing to decline complex argument shapes.
  • Add tests for fast-path usage and nullish short-circuit behavior; update the unified-bytecode expansion contract documentation.

Reviewed changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
tests/Asynkron.JsEngine.Tests/UnifiedBytecodeProductionInvocationTests.cs Adds invocation-level tests asserting fast-path usage and correct undefined short-circuiting for captured optional identifier calls.
tests/Asynkron.JsEngine.Tests/UnifiedBytecodeProductionEligibilityTests.cs Adds eligibility tests verifying acceptance/decline behavior and opcode emission for dynamic optional identifier call targets.
src/Asynkron.JsEngine/Execution/UnifiedBytecode/UnifiedBytecodeVirtualMachine.cs Implements VM execution for PrepareDynamicIdentifierOptionalCallTarget, including nullish short-circuit jump behavior.
src/Asynkron.JsEngine/Execution/UnifiedBytecode/UnifiedBytecodeProgram.cs Introduces the new opcode in UnifiedBytecodeOpCode.
src/Asynkron.JsEngine/Execution/UnifiedBytecode/UnifiedBytecodeProductionEligibility.cs Updates first-boundary optional identifier call detection to account for admitted dynamic identifiers.
src/Asynkron.JsEngine/Execution/UnifiedBytecode/UnifiedBytecodeCompiler.cs Emits PrepareDynamicIdentifierOptionalCallTarget with packed operand (name index + jump target) when dynamic identifiers are allowed.
src/Asynkron.JsEngine/Ast/TypedAstEvaluator.SyncFunctionInvoker.cs Ensures unified bytecode invocation requests an environment when the new dynamic optional opcode is present.
docs/unified-bytecode-expansion-contract.md Documents the new opcode and the admitted optional identifier call shape.

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

Comment on lines 646 to 648
The optional preparation opcodes pack a call-target constant index (low 16
bits) and a nullish short-circuit jump target (high 16 bits) into a single
operand. The VM checks the receiver or callee for nullish before argument
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.

2 participants