Skip to content
  •  
  •  
  •  
2 changes: 1 addition & 1 deletion src/analytics/schema.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ use bun_core::Error;
// PORT NOTE: peechy's two error cases (`EOF`, `InvalidValue`) are folded into
// the crate-wide `bun_core::Error` so downstream `decode` signatures stay
// `Result<_, bun_core::Error>` without an extra `From` hop.
pub const EOF: Error = Error::TODO; // TODO(b2): Error::from_name("EOF") once name→code table lands
pub const EOF: Error = Error::TODO; // TODO(port): Error::from_name("EOF") once name→code table lands

/// Primitive integers encodable in the peechy wire format (native-endian raw
/// bytes). Zig handled this via `comptime T` + `std.mem.readIntSliceNative` /
Expand Down
9 changes: 2 additions & 7 deletions src/ast/ast_memory_allocator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,6 @@ use crate::stmt;
// stack-fallback would still avoid the heap entirely for small modules — left
// for a follow-up.)

// TODO(port): `Expr.Data.Store.memory_allocator` / `Stmt.Data.Store.memory_allocator` are
// `threadlocal var ?*ASTMemoryAllocator` in Zig, read/written directly. Phase B must expose
// `memory_allocator() -> *mut ASTMemoryAllocator`, `set_memory_allocator(*mut ASTMemoryAllocator)`,
// and `begin()` on the Rust `expr::data::Store` / `stmt::data::Store` (thread_local! + Cell).

// ── Thread-local arena pool ──────────────────────────────────────────────
//
// Zig's `ASTMemoryAllocator` was a `StackFallbackAllocator(8192, fallback)`:
Expand Down Expand Up @@ -114,7 +109,7 @@ impl ASTMemoryAllocator {
/// `a.enter(arena)` (passing the fallback `std.mem.Allocator`). In the
/// Rust port the SFA + fallback collapse to a single internal `Arena`, so
/// the passed arena is currently unused — kept for call-site shape compat.
// TODO(port): if Phase B routes the parser bump arena through here instead
// TODO(port): if the parser bump arena is ever routed through here instead
// of allocating a fresh one, thread `_fallback` into `self.arena`.
pub fn new(_fallback: &Arena) -> Self {
// PERF(port): was stack-fallback — profile
Expand Down Expand Up @@ -221,7 +216,7 @@ impl ASTMemoryAllocator {
}

/// Zig: `this.stack_allocator.get()` — the `std.mem.Allocator` vtable into
/// the stack-fallback buffer. In Phase A both `stack_allocator` and
/// the stack-fallback buffer. In the Rust port both `stack_allocator` and
/// `bump_allocator` collapse to the single `Arena`, so this returns it.
#[inline]
pub fn stack_allocator(&self) -> &Arena {
Expand Down
4 changes: 2 additions & 2 deletions src/ast/b.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ pub use crate::ArrayBinding;
/// ----------------
/// B.Object
// Zig: `union(Binding.Tag)` — tag enum lives on `Binding::Tag`.
// PORT NOTE: arena ptrs are raw `*mut` in Phase A (LIFETIMES.tsv: ARENA → raw);
// 'bump threaded crate-wide (`&'bump mut T`).
// PORT NOTE: arena values are referenced via `StoreRef<T>` (LIFETIMES.tsv: ARENA)
// rather than a threaded `&'bump mut T`.
#[derive(Copy, Clone, bun_core::EnumTag)]
#[enum_tag(existing = super::binding::Tag)]
pub enum B {
Expand Down
34 changes: 16 additions & 18 deletions src/ast/e.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,10 @@
}
}
}
// TODO(b2-ast-round-C): Array methods call `Vec::init_capacity(bump, n)`
// TODO(port): Array methods call `Vec::init_capacity(bump, n)`
// (signature mismatch: Vec takes only `n`; AST-crate variant with bump
// arena pending) and `Expr::Data::*` deep matches. Un-gate with parser round.
// Live subset of `Array` accessors needed by downstream crates (round-E unblock).

Check warning on line 69 in src/ast/e.rs

View check run for this annotation

Claude / Claude Code Review

round-B/C/D/E port-phase references survive in files this PR edits

🟡 The cleanup grep missed the bare `round-[A-E]` form in files this PR already edits — most visibly `src/ast/e.rs:69` ("round-E unblock", three lines below the `TODO(b2-ast-round-C)` → `TODO(port)` rewrite at :66) and `src/ast/expr.rs:2319` ("round-B verify gate", three lines below the same rewrite at :2316), plus e.rs:955/1490, expr.rs:179/781/1183/1490/3129, ParseTask.rs:603/714, and ~16 in `js_parser/p.rs`. Same straggler class as #3252525489 but a different lexical pattern (`round-X` vs `Pha
Comment thread
claude[bot] marked this conversation as resolved.
Outdated
impl Array {
pub const EMPTY: Array = Array {
items: bun_alloc::AstAlloc::vec(),
Expand All @@ -78,7 +78,7 @@
};

/// Zig: `pub fn push(this: *Array, arena, item) !void`.
/// Phase A `Vec::append` uses the global arena; `_bump` is kept
/// `Vec::append` uses the global arena; `_bump` is kept
/// for call-site shape parity and the eventual bump-arena Vec.
pub fn push(&mut self, _bump: &Bump, item: Expr) -> Result<(), AllocError> {
VecExt::append(&mut self.items, item);
Expand All @@ -98,7 +98,7 @@
estimated_count: usize,
) -> Result<ExprNodeList, AllocError> {
// This over-allocates a little but it's fine
// PERF(port): Zig allocated in arena; Phase-A Vec uses global arena.
// PERF(port): Zig allocated in arena; this Vec uses the global arena.
// `Expr.data` is an enum (validity invariant), so the Zig
// `expandToCapacity` + index-walk pattern would form `&mut [Expr]`
// over invalid bit patterns. Push into reserved capacity instead —
Expand Down Expand Up @@ -685,13 +685,12 @@
}
impl JSXSpecialProp {
// PERF(port): Zig used `ComptimeStringMap` (length-prefix lookup, all
// resolved at comptime). Phase A reached for `phf::Map`, which on every
// JSX prop name computes a full SipHash + index + slice compare even
// though the overwhelming majority of inputs (`className`, `onClick`,
// `style`, ...) miss. With only 4 keys at 3 distinct lengths, a
// length-gated `match` rejects almost every miss on a single `usize`
// compare and never hashes. See clap::find_param (12577e958d71) for the
// same pattern.
// resolved at comptime). A `phf::Map` here would compute a full SipHash +
// index + slice compare on every JSX prop name even though the
// overwhelming majority of inputs (`className`, `onClick`, `style`, ...)
// miss. With only 4 keys at 3 distinct lengths, a length-gated `match`
// rejects almost every miss on a single `usize` compare and never hashes.
// See clap::find_param (12577e958d71) for the same pattern.
#[inline]
pub fn from_bytes(s: &[u8]) -> Option<Self> {
match s.len() {
Expand All @@ -709,7 +708,7 @@

// `Missing` re-exported from `crate::E` above.
// TODO(port): `Missing::json_stringify` — Zig std.json protocol; orphan rules
// prevent an inherent impl here now that the type lives at T2. Phase B picks a
// prevent an inherent impl here now that the type lives at T2. Pick a
// serde strategy (extension trait or move the method down).

#[derive(Clone, Copy)]
Expand Down Expand Up @@ -895,7 +894,7 @@

/// used in TOML parser to merge properties.
///
/// Phase A keeps node types lifetime-free, so `next` is a raw `*mut Rope`
/// Node types are lifetime-free, so `next` is a raw `*mut Rope`
/// into the bump arena (Zig: `next: ?*Rope`). Segments are bulk-freed at
/// arena reset.
pub struct Rope {
Expand Down Expand Up @@ -1575,7 +1574,7 @@
}

/// Zig `string(arena)` — return UTF-8 bytes, transcoding if UTF-16.
/// Phase A: transcode allocates via global arena then copies into
/// The transcode allocates via the global arena then copies into
/// `bump` (Zig used the passed arena directly).
pub fn string<'b>(&self, bump: &'b Bump) -> Result<&'b [u8], AllocError> {
if self.is_utf8() {
Expand Down Expand Up @@ -1609,10 +1608,9 @@
}
}

// ── live EString surface (B-2 un-gate) ─────────────────────────────────────
// Ordering / equality / const-literal / rope-mutation helpers extracted from
// the round-C draft below. `string_z`/`to_zig_string` remain gated on
// `bun_core::ZStr` arena constructors.
// ── EString surface ────────────────────────────────────────────────────────
// Ordering / equality / const-literal / rope-mutation helpers.
// `string_z`/`to_zig_string` remain gated on `bun_core::ZStr` arena constructors.
impl EString {
pub const CLASS: EString = EString::from_static(b"class");
pub const EMPTY: EString = EString::from_static(b"");
Expand Down Expand Up @@ -1816,7 +1814,7 @@
}
}

// TODO(port): jsonStringify — Zig std.json protocol; Phase B picks a serde strategy.
// TODO(port): jsonStringify — Zig std.json protocol; pick a serde strategy.
pub fn json_stringify<W>(&self, writer: &mut W) -> Result<(), bun_core::Error> {
let _ = writer;
let mut buf = [0u8; 4096];
Expand Down
21 changes: 10 additions & 11 deletions src/ast/expr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ use core::fmt;
use crate::Loc;
use bun_alloc::{AllocError, Arena as Bump};
use bun_collections::{ArrayHashMap, VecExt};
use bun_core::ZStr;
use bun_core::{self};
use bun_core::{ZStr, strings};

use crate::{DebugOnlyDisabler, E, G, Op, Ref, S, Stmt};
use bun_alloc::ArenaVecExt as _;
Expand Down Expand Up @@ -255,7 +255,7 @@ impl Expr {
}
}

// TODO(b2-ast-round-C): gated on `EString::string_z` (E.rs:1666 block) which
// TODO(port): gated on `EString::string_z` (E.rs:1666 block) which
// needs `bun_core::ZStr` bump-arena constructors. Only caller
// (`get_string_cloned_z`) is likewise gated.

Expand Down Expand Up @@ -283,7 +283,7 @@ impl Expr {
}

// Expr — property/object/string accessor methods.
// TODO(b2-ast-round-C): these call into `E::Object::as_property` / `EString`
// TODO(port): these call into `E::Object::as_property` / `EString`
// methods that need `bun_core::utf16_eql_string`/`to_utf8_alloc` (track-A
// blocked_on) and `Vec::deep_clone`. Types are real; bodies un-gate with
// the parser round once those land.
Expand Down Expand Up @@ -708,12 +708,11 @@ impl ArrayIterator {
}
}

// TODO(b2-ast-round-C): same as above (string/array accessors).
// PORT NOTE: the Phase-A draft of `as_array`/`is_string`/`as_utf8_string_literal`/
// PORT NOTE: earlier drafts of `as_array`/`is_string`/`as_utf8_string_literal`/
// `as_string`/`as_string_cloned`/`as_bool`/`as_number` duplicated the live `&self`
// implementations above (lines ~231-315) with worse signatures (`expr: &Expr`,
// raw-ptr returns). Those drafts were dropped during un-gating; only the methods
// without a live counterpart remain.
// raw-ptr returns). Those drafts were dropped; only the methods without a live
// counterpart remain.
impl Expr {
#[inline]
pub fn as_string_literal<'b>(&self, bump: &'b Bump) -> Option<&'b [u8]> {
Expand Down Expand Up @@ -960,8 +959,8 @@ impl Expr {
}
}

// TODO(port): jsonStringify protocol — replace with serde or custom trait in
// Phase B. Kept gated; `Serializable` is its payload shape.
// TODO(refactor): jsonStringify protocol — replace with serde or a custom trait.
// `Serializable` is its payload shape.

impl Expr {
// PORT NOTE: Zig's `jsonStringify` fed `Serializable` to `std.json.stringify`.
Expand Down Expand Up @@ -2314,7 +2313,7 @@ impl Data {

// ───────────────────────────────────────────────────────────────────────────
// Data — heavy transform/analysis methods (clone/deep_clone/fold/etc).
// TODO(b2-ast-round-C): these reference `Vec::deep_clone`/`E::*::Clone`
// TODO(port): these reference `Vec::deep_clone`/`E::*::Clone`
// surfaces, `bun_core::write_any_to_hasher`, and parser-state types that land
// with `P.rs`/`Parser.rs`. The *types* (`Data`/`Expr`/`Tag`/`Store`) are real;
// only these method bodies wait. The round-B verify gate covers what's live.
Expand Down Expand Up @@ -3387,7 +3386,7 @@ pub mod data {
crate::thread_local_ast_store!(expr_store::Store, "Expr");
}

/// Compatibility shim: Phase-A draft callers in this file used `Store::method()`
/// Compatibility shim: callers in this file use `Store::method()`
/// (impl-on-struct namespace). Forward to the real `data::Store` module.
pub use data::Store;

Expand Down
2 changes: 1 addition & 1 deletion src/ast/g.rs
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@ pub enum PropertyKind {

impl PropertyKind {
// TODO(port): Zig `jsonStringify(self, writer: anytype) !void` — maps to a serde-like
// protocol writing @tagName(self). Phase B: decide on the json writer trait.
// protocol writing @tagName(self). Decide on a shared json writer trait.
pub fn json_stringify(self, writer: &mut impl core::fmt::Write) -> core::fmt::Result {
// Zig: `writer.write(@tagName(self))` on a std.json WriteStream — emits a
// *quoted* JSON string. Tag names are [a-z_] so no escaping needed.
Expand Down
4 changes: 2 additions & 2 deletions src/ast/import_record.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ pub use crate::{ImportKind, Index, Loader};
pub struct ImportRecord {
pub range: Range,
// TODO(port): lifetime — `bun_paths::fs::Path<'a>` borrows resolver-owned
// strings. Phase A uses 'static (PORTING.md: no struct lifetime params).
// strings. Uses 'static (PORTING.md: no struct lifetime params).
pub path: Path<'static>,
pub kind: ImportKind,
pub tag: Tag,
Expand All @@ -35,7 +35,7 @@ pub struct ImportRecord {
/// This is preserved before resolution overwrites `path` with the resolved path.
/// Used for metafile generation.
// TODO(port): lifetime — Zig `[]const u8` defaulting to "", never freed in this file.
// Likely a borrow into parser-owned source text; using &'static [u8] as Phase-A placeholder.
// Likely a borrow into parser-owned source text; using &'static [u8] as a placeholder.
pub original_path: &'static [u8],

/// Pack all boolean flags into 2 bytes to reduce padding overhead.
Expand Down
4 changes: 2 additions & 2 deletions src/ast/known_global.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ pub enum KnownGlobal {
// `pub const map = bun.ComptimeEnumMap(KnownGlobal);`
//
// PERF(port): Zig's `ComptimeEnumMap` lowers to a comptime-generated switch.
// Phase A used `phf::Map<&[u8], _>`, which on every probe computes a 128-bit
// An earlier port used `phf::Map<&[u8], _>`, which on every probe computes a 128-bit
// SipHash of the name, two modular reductions, a bounds check, and a final
// slice compare. `minify_global_constructor` calls this for every `new Ident`
// expression in the input, and the overwhelming majority of probes are
Expand Down Expand Up @@ -113,7 +113,7 @@ impl KnownGlobal {
}

// PORT NOTE: `_bump` is kept for call-site shape parity with the Zig
// `std.mem.Allocator` arg. Phase-A `Vec` uses the global arena.
// `std.mem.Allocator` arg. The `Vec` uses the global arena.
#[inline(never)]
pub fn minify_global_constructor(
_bump: &Bump,
Expand Down
6 changes: 3 additions & 3 deletions src/ast/lexer_tables.rs
Original file line number Diff line number Diff line change
Expand Up @@ -439,9 +439,9 @@ pub fn is_type_script_accessibility_modifier(s: &[u8]) -> bool {
}
}

/// `.rodata` `[&[u8]; T::COUNT]` indexed by [`T`] discriminant. Replaces the
/// `LazyLock<EnumMap<T, _>>` Phase-A scaffolding so lookup is a plain array
/// index with zero init code (matches Zig `std.EnumArray`).
/// `.rodata` `[&[u8]; T::COUNT]` indexed by [`T`] discriminant. Replaces an
/// earlier `LazyLock<EnumMap<T, _>>` so lookup is a plain array index with
/// zero init code (matches Zig `std.EnumArray`).
#[repr(transparent)]
pub struct TokenEnumType(pub [&'static [u8]; <T as Enum>::LENGTH]);

Expand Down
Loading
Loading