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
40 changes: 19 additions & 21 deletions src/ast/e.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,10 @@ impl Default for Array {
}
}
}
// 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).
// Live subset of `Array` accessors needed by downstream crates.
impl Array {
pub const EMPTY: Array = Array {
items: bun_alloc::AstAlloc::vec(),
Expand All @@ -78,7 +78,7 @@ impl Array {
};

/// 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 @@ impl Array {
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 @@ pub enum JSXSpecialProp {
}
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 @@ impl JSXSpecialProp {

// `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 @@ impl Default for Object {

/// 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 @@ -953,7 +952,7 @@ pub struct RopeQuery<'a> {
pub rope: &'a Rope,
}

// ── live Object accessor surface (round-E unblock) ─────────────────────────
// ── live Object accessor surface ───────────────────────────────────────────
// Adapted to the current `Vec` API (`append(v)`, `slice()`, `slice_mut()`).
// `set_rope`/`get_or_put_array`/sort helpers stay in the gated impl below.
impl Object {
Expand Down Expand Up @@ -1488,7 +1487,7 @@ impl EString {
}
}

// ── live EString accessor surface (round-E unblock) ────────────────────────
// ── live EString accessor surface ──────────────────────────────────────────
// Subset of the gated impl below adapted to the current `bun_core` API
// (`eql_long::<CHECK_LEN>`, no bump-arena `to_utf8_alloc`). Heavy
// transcode/rope-clone paths stay gated.
Expand Down Expand Up @@ -1575,7 +1574,7 @@ impl EString {
}

/// 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 @@ impl EString {
}
}

// ── 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 @@ impl EString {
}
}

// 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
35 changes: 17 additions & 18 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 @@ -176,9 +176,9 @@ impl Default for Query {
}

// ───────────────────────────────────────────────────────────────────────────
// ── live Expr accessor surface (round-E unblock) ───────────────────────────
// ── live Expr accessor surface ─────────────────────────────────────────────
// Subset of the gated impl below; bodies adapted to the live `E::Object` /
// `E::EString` surface added this round. The full set/get_path/rope helpers
// `E::EString` surface in `e.rs`. The full set/get_path/rope helpers
// stay gated.
impl Expr {
#[inline]
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 @@ -779,7 +778,7 @@ struct Serializable {
loc: Loc,
}

// `is_missing` lives in the `init`/`allocate` impl block below (round-A hoist).
// `is_missing` lives in the `init`/`allocate` impl block below.
impl Expr {
/// The goal of this function is to "rotate" the AST if it's possible to use the
/// left-associative property of the operator to avoid unnecessary parentheses.
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 @@ -1181,7 +1180,7 @@ impl Expr {
}
}

// Trivial predicates kept live (round-A `is_missing` callers in G.rs/B.rs).
// Trivial predicates with `is_missing` callers in G.rs/B.rs.
#[inline]
pub fn is_missing(&self) -> bool {
matches!(self.data, Data::EMissing(_))
Expand Down Expand Up @@ -1488,7 +1487,7 @@ impl Expr {
}
}

// `assign` lives in the `init`/`allocate` impl block above (round-A hoist).
// `assign` lives in the `init`/`allocate` impl block above.

#[inline]
pub fn at<T: IntoExprData>(&self, t: T) -> Expr {
Expand Down Expand Up @@ -2314,10 +2313,10 @@ 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.
// only these method bodies wait.

impl Data {
/// Shallow clone: re-allocate the boxed payload (so the caller owns a fresh
Expand Down Expand Up @@ -3127,7 +3126,7 @@ impl Equality {
}

// `adt_const_params` (enum const-generic) is nightly-only. Lower to a sealed
// ZST trait per the round-A `PlatformT` pattern; callers use
// ZST trait, same pattern as `bun_paths::resolve_path::PlatformT`; callers use
// `Data::eql::<P, LooseEql>(...)` / `<P, StrictEql>`.
pub trait EqlKindT: Copy {
const STRICT: bool;
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