optimize string accumulation and devirtualize hot Silver runtime paths - #60
Conversation
📝 WalkthroughWalkthroughThis PR centralizes UTF-16 string length and metadata handling, relocates function debug data, adds compiler and VM support for templates and string builders, expands JIT fast paths and devirtualization guards, and adds broad regression tests. ChangesString runtime and metadata
Compiler and VM metadata
JIT specialization
Regression coverage
Estimated code review effort: 5 (Critical) | ~120 minutes Sequence Diagram(s)sequenceDiagram
participant JavaScriptCode
participant Compiler
participant JIT
participant Runtime
JavaScriptCode->>Compiler: compile templates, self-append, and member access
Compiler->>JIT: emit builder, global IC, and devirtualized call paths
JIT->>Runtime: invoke guarded fast paths or fallback helpers
Runtime-->>JIT: return values or errors
JIT-->>JavaScriptCode: preserve results and exception propagation
Possibly related PRs
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
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. Comment |
|
@macroscope-app review |
|
Manual reviews triggered for commit All prior checks · these links stay valid even if you push more commits. |
|
Review in progress. Results will be posted as check runs when complete. |
ApprovabilityVerdict: Needs human review Significant runtime optimization changes affecting string metadata caching, JIT devirtualization, template literal compilation, and global accessor handling. The scope and complexity of these core engine modifications warrant careful review despite comprehensive test coverage. You can customize Macroscope's approvability policy. Learn more. |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@include/silver/engine.h`:
- Around line 1072-1073: Prevent null dereferences of relocated debug metadata
by guarding every listed access with a debug-pointer check: in
include/silver/engine.h lines 1072-1073 and 1083, src/silver/engine.c lines 123,
136, 169, and 204, src/errors.c lines 376 and 418-428, and
src/silver/ops/objects.h lines 312-315. Preserve existing fallback behavior for
missing names, filenames, source data, and positions, and audit other
func->debug consumers, including js_set_error_site_from_bc calls in
src/silver/ops/property.h, applying the same guards where needed.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 36db738b-f174-4584-811b-1b783641506f
📒 Files selected for processing (42)
examples/spec/devirtualization.jsexamples/spec/strings.jsinclude/internal.hinclude/pool.hinclude/silver/engine.hinclude/silver/glue.hinclude/silver/opcode.hinclude/utf8.hsrc/ant.csrc/errors.csrc/modules/builtin.csrc/modules/io.csrc/modules/json.csrc/pool.csrc/silver/compiler.csrc/silver/engine.csrc/silver/glue.csrc/silver/ops/coercion.hsrc/silver/ops/globals.hsrc/silver/ops/objects.hsrc/silver/ops/property.hsrc/silver/swarm.csrc/utf8.ctests/harness/manifest.jstests/test_for_in_dense_array_fast.cjstests/test_for_of_dense_array_fast.cjstests/test_global_accessor_read.cjstests/test_jit_bigint_ops.cjstests/test_jit_cfunc_call_fast.cjstests/test_jit_delete_numeric_key.cjstests/test_jit_for_of.cjstests/test_jit_global_read_ic.cjstests/test_jit_inline_call_errors.cjstests/test_jit_put_elem_fast.cjstests/test_jit_put_field_ic.cjstests/test_jit_regexp_literal_intrinsics.cjstests/test_jit_string_builder_snapshot.cjstests/test_jit_typed_array_elem_fast.cjstests/test_jit_upvalue_self_reference.cjstests/test_number_simple_decimal_fast.cjstests/test_string_length_accumulation.cjstests/test_template_self_append.cjs
Summary by CodeRabbit