Skip to content

test(runtime): verify apply_active_realm_protos with all-None clears overrides#370

Merged
dowdiness merged 1 commit into
mainfrom
test/apply-active-realm-protos-clearing
Jun 16, 2026
Merged

test(runtime): verify apply_active_realm_protos with all-None clears overrides#370
dowdiness merged 1 commit into
mainfrom
test/apply-active-realm-protos-clearing

Conversation

@dowdiness

@dowdiness dowdiness commented Jun 16, 2026

Copy link
Copy Markdown
Owner

Summary

Follow-up to #369. Adds a test covering the clearing path of apply_active_realm_protos — identified as a gap during review.

The test:

  1. Sets an active map_proto override → verifies fast path is blocked and getter returns the override
  2. Calls apply_active_realm_protos(rs, FunctionRealmProtos()) (all-None) → verifies fast path is re-allowed and getter falls back to the base proto

This exercises the branch in apply_active_realm_protos where any_set is false → writes None to active_overrides.

Test plan

  • moon test interpreter/runtime: 92/92 pass
  • moon check --deny-warn clean

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Tests
    • Added test coverage for prototype override clearing behavior.

…overrides

Covers the clearing path: set an override, call apply_active_realm_protos
with FunctionRealmProtos() (all None), confirm fast path is re-allowed and
proto getter falls back to the base proto.

Follow-up to #369 — identified as a gap during review.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Jun 16, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 78613aae-60cd-4d66-a48e-6abc65d2b1b3

📥 Commits

Reviewing files that changed from the base of the PR and between 3717dea and 6f9f0d9.

📒 Files selected for processing (1)
  • interpreter/runtime/factories_wbtest.mbt

📝 Walkthrough

Walkthrough

A new whitebox test is added to interpreter/runtime/factories_wbtest.mbt. The test stamps a function, applies an active map prototype override, verifies fast-path blocking and get_map_proto behavior under the override, then calls apply_active_realm_protos with an all-None FunctionRealmProtos() and asserts fast-path re-enablement and fallback to the base map prototype.

Changes

Override Clearance Whitebox Test

Layer / File(s) Summary
Whitebox test: all-None proto clears map override and restores fast path
interpreter/runtime/factories_wbtest.mbt
Adds test apply_active_realm_protos with all-None clears an existing override that stamps a function, activates a map prototype override, asserts fast-path is blocked and get_map_proto returns the override, then calls apply_active_realm_protos with an all-None FunctionRealmProtos() and asserts fast-path is re-enabled and get_map_proto falls back to the base prototype.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~3 minutes

Possibly related PRs

  • dowdiness/js_engine#369: Directly related — implements the realm_state.has_active_override and fast-path logic inside apply_active_realm_protos that this new test exercises when overrides are cleared.

Poem

🐇 Hop, hop, the override falls away,
The fast path blooms again today!
A None for map, a None for all—
The base prototype answers the call.
With every test, the engine's right,
This rabbit approves with pure delight! ✨

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main change: adding a test for apply_active_realm_protos that verifies all-None values clear existing overrides.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch test/apply-active-realm-protos-clearing

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@github-actions

Copy link
Copy Markdown
Contributor

Benchmark Results

Run: https://github.com/dowdiness/js_engine/actions/runs/27630432811

startup/tiny_program is the PR #153 / issue #141 guardrail for built-in realm-stamping startup cost.

Stage summary

stage benchmarks total mean slowest benchmark slowest mean noisy rows
startup 3 2.433 ms startup/tiny_program 1.271 ms 0
frontend 7 0.866 ms pipeline/parse_heavy 0.493 ms 2
execution 25 14836.420 ms exec/fibonacci_30 13439.809 ms 3

Focused bytecode base-vs-head comparison

Base-vs-head deltas are reporting-only. Negative delta and PR/base < 1.00x mean the PR is faster; interpret high-CV or noisy rows cautiously.

benchmark stage base mean PR mean delta PR/base base CV PR CV noisy
baseline/bytecode/closure_factory execution 13.755 ms 14.305 ms +4.0% 1.04x 6.9% 6.2% no
pipeline/bytecode/evaluate execution 9.086 ms 8.812 ms -3.0% 0.97x 1.5% 1.9% no
isolate/bytecode/call_frame execution 8.199 ms 8.868 ms +8.2% 1.08x 1.1% 1.0% no
isolate/bytecode/runtime_helpers execution 12.104 ms 12.621 ms +4.3% 1.04x 2.2% 0.7% no
isolate/bytecode/local_access execution 37.532 ms 38.355 ms +2.2% 1.02x 1.8% 1.3% no
isolate/bytecode/env_access execution 37.954 ms 38.772 ms +2.2% 1.02x 3.1% 1.9% no
isolate/bytecode/captured_access execution 36.061 ms 35.887 ms -0.5% 1.00x 2.4% 1.9% no
isolate/bytecode/dispatch_stack execution 24.300 ms 22.656 ms -6.8% 0.93x 1.4% 0.5% no

Base-vs-head comparison

benchmark stage base mean PR mean delta PR/base base CV PR CV noisy
startup/tiny_program startup 1.143 ms 1.271 ms +11.2% 1.11x 5.1% 5.8% no
lexer/small frontend 0.030 ms 0.030 ms -1.0% 0.99x 26.4% 27.9% base, PR
lexer/large frontend 0.261 ms 0.264 ms +1.1% 1.01x 0.8% 1.0% no
exec/fibonacci_30 execution 13083.630 ms 13439.809 ms +2.7% 1.03x 1.3% 0.5% no
exec/property_chain execution 14.869 ms 14.840 ms -0.2% 1.00x 13.3% 8.9% no
startup/phase/parse_tiny frontend 0.002 ms 0.002 ms +1.4% 1.01x 0.9% 1.7% no
startup/phase/new_interpreter startup 1.120 ms 1.161 ms +3.7% 1.04x 13.2% 9.0% no
startup/phase/execute_preparsed_tiny execution 0.001 ms 0.000 ms -4.4% 0.96x 0.7% 0.8% no
startup/phase/event_loop_drain_empty startup 0.000 ms 0.000 ms +1.8% 1.02x 0.9% 1.3% no
startup/phase/result_stringify_output execution 0.000 ms 0.000 ms -0.1% 1.00x 0.5% 0.6% no
exec/array_map_filter execution 21.025 ms 20.223 ms -3.8% 0.96x 18.7% 20.8% base, PR
exec/closure_factory execution 29.343 ms 28.785 ms -1.9% 0.98x 6.3% 8.5% no
baseline/closure_legacy/closure_factory execution 28.537 ms 28.020 ms -1.8% 0.98x 8.0% 9.8% no
baseline/bytecode/closure_factory execution 13.755 ms 14.305 ms +4.0% 1.04x 6.9% 6.2% no
isolate/bytecode/dispatch_stack execution 24.300 ms 22.656 ms -6.8% 0.93x 1.4% 0.5% no
isolate/bytecode/local_access execution 37.532 ms 38.355 ms +2.2% 1.02x 1.8% 1.3% no
isolate/bytecode/env_access execution 37.954 ms 38.772 ms +2.2% 1.02x 3.1% 1.9% no
isolate/bytecode/captured_access execution 36.061 ms 35.887 ms -0.5% 1.00x 2.4% 1.9% no
isolate/bytecode/call_frame execution 8.199 ms 8.868 ms +8.2% 1.08x 1.1% 1.0% no
isolate/bytecode/runtime_helpers execution 12.104 ms 12.621 ms +4.3% 1.04x 2.2% 0.7% no
isolate/bytecode/property_get execution 45.093 ms 45.157 ms +0.1% 1.00x 1.8% 2.9% no
isolate/bytecode/property_set execution 41.783 ms 40.597 ms -2.8% 0.97x 0.6% 2.7% no
isolate/bytecode/method_call execution 9.382 ms 9.979 ms +6.4% 1.06x 0.6% 0.9% no
isolate/bytecode/object_literal execution 13.497 ms 13.600 ms +0.8% 1.01x 2.6% 1.4% no
isolate/bytecode/array_literal execution 14.982 ms 15.005 ms +0.2% 1.00x 1.5% 1.2% no
exec/arithmetic_loop execution 948.943 ms 934.861 ms -1.5% 0.99x 0.4% 0.5% no
exec/object_construction execution 7.619 ms 7.610 ms -0.1% 1.00x 11.1% 6.1% no
exec/string_ops execution 1.833 ms 1.987 ms +8.4% 1.08x 12.2% 18.6% PR
pipeline/exec/lex frontend 0.028 ms 0.028 ms +0.3% 1.00x 0.5% 0.8% no
pipeline/exec/parse frontend 0.027 ms 0.028 ms +1.9% 1.02x 2.8% 3.3% no
pipeline/exec/evaluate execution 25.785 ms 30.211 ms +17.2% 1.17x 5.0% 20.1% PR
pipeline/closure_legacy/evaluate execution 24.619 ms 25.462 ms +3.4% 1.03x 4.2% 6.8% no
pipeline/bytecode/compile frontend 0.023 ms 0.023 ms -0.7% 0.99x 32.1% 26.5% base, PR
pipeline/bytecode/evaluate execution 9.086 ms 8.812 ms -3.0% 0.97x 1.5% 1.9% no
pipeline/parse_heavy frontend 0.487 ms 0.493 ms +1.2% 1.01x 7.2% 5.0% no

Mean-time chart (log scale)

benchmark stage mean chart
startup/tiny_program startup 1.271 ms ##
lexer/small frontend 0.030 ms ⚠ #
lexer/large frontend 0.264 ms #
exec/fibonacci_30 execution 13439.809 ms ##############################
exec/property_chain execution 14.840 ms ########
startup/phase/parse_tiny frontend 0.002 ms #
startup/phase/new_interpreter startup 1.161 ms ##
startup/phase/execute_preparsed_tiny execution 0.000 ms #
startup/phase/event_loop_drain_empty startup 0.000 ms #
startup/phase/result_stringify_output execution 0.000 ms #
exec/array_map_filter execution 20.223 ms ⚠ #########
exec/closure_factory execution 28.785 ms ##########
baseline/closure_legacy/closure_factory execution 28.020 ms ##########
baseline/bytecode/closure_factory execution 14.305 ms ########
isolate/bytecode/dispatch_stack execution 22.656 ms #########
isolate/bytecode/local_access execution 38.355 ms ###########
isolate/bytecode/env_access execution 38.772 ms ###########
isolate/bytecode/captured_access execution 35.887 ms ###########
isolate/bytecode/call_frame execution 8.868 ms #######
isolate/bytecode/runtime_helpers execution 12.621 ms ########
isolate/bytecode/property_get execution 45.157 ms ############
isolate/bytecode/property_set execution 40.597 ms ###########
isolate/bytecode/method_call execution 9.979 ms #######
isolate/bytecode/object_literal execution 13.600 ms ########
isolate/bytecode/array_literal execution 15.005 ms ########
exec/arithmetic_loop execution 934.861 ms #####################
exec/object_construction execution 7.610 ms ######
exec/string_ops execution 1.987 ms ⚠ ###
pipeline/exec/lex frontend 0.028 ms #
pipeline/exec/parse frontend 0.028 ms #
pipeline/exec/evaluate execution 30.211 ms ⚠ ##########
pipeline/closure_legacy/evaluate execution 25.462 ms ##########
pipeline/bytecode/compile frontend 0.023 ms ⚠ #
pipeline/bytecode/evaluate execution 8.812 ms #######
pipeline/parse_heavy frontend 0.493 ms #

Closure-conversion comparison

  • unavailable

@dowdiness dowdiness merged commit c220f27 into main Jun 16, 2026
14 checks passed
@dowdiness dowdiness deleted the test/apply-active-realm-protos-clearing branch June 16, 2026 23:41
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.

1 participant