Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
73 changes: 0 additions & 73 deletions src/bun_core/fmt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1045,12 +1045,6 @@ pub fn parse_ascii<T: core::str::FromStr>(s: &[u8]) -> Option<T> {
.ok()
}

#[deprecated = "use parse_int / parse_f64 / parse_ascii (no from_utf8)"]
#[inline]
pub fn parse_num<T: core::str::FromStr>(s: &[u8]) -> Option<T> {
parse_ascii(s)
}

// ───────────────────────────────────────────────────────────────────────────
// Latin-1 formatting
// ───────────────────────────────────────────────────────────────────────────
Expand Down Expand Up @@ -2320,69 +2314,6 @@ pub fn format_ip<'a>(
// count
// ───────────────────────────────────────────────────────────────────────────

// ───────────────────────── CountingWriter / Null ─────────────────────────
// One type subsumes a pure discarding sink and a counting forwarding
// wrapper. Implements
// `core::fmt::Write` so it can replace the per-crate private `CountingWriter`
// reinventions (clap). The byte-level `bun_io::Write` counting sink stays in
// `bun_io::DiscardingWriter` (different trait, sits above bun_core).

/// Zero-sized `fmt::Write` no-op — default type param for [`CountingWriter`].
pub struct Null;
impl fmt::Write for Null {
#[inline]
fn write_str(&mut self, _: &str) -> fmt::Result {
Ok(())
}
}

/// Counts every byte written; optionally forwards to a wrapped `fmt::Write`.
/// `inner: None` ⇒ pure discarding sink.
pub struct CountingWriter<'a, W: fmt::Write = Null> {
inner: Option<&'a mut W>,
/// Total bytes written so far (counted before forwarding).
pub count: usize,
}

impl<'a, W: fmt::Write> CountingWriter<'a, W> {
/// Wrap an existing `fmt::Write` sink, forwarding writes through it.
#[inline]
pub fn wrap(w: &'a mut W) -> Self {
Self {
inner: Some(w),
count: 0,
}
}
/// Direct access to the inner sink (bypasses counting). Panics on the
/// `null()` variant — callers know which mode they constructed.
#[inline]
pub fn inner(&mut self) -> &mut W {
self.inner.as_mut().unwrap()
}
}

impl CountingWriter<'static, Null> {
/// Pure discarding sink — `inner: None`, never forwarded.
#[inline]
pub fn null() -> Self {
Self {
inner: None,
count: 0,
}
}
}

impl<W: fmt::Write> fmt::Write for CountingWriter<'_, W> {
#[inline]
fn write_str(&mut self, s: &str) -> fmt::Result {
self.count += s.len();
if let Some(w) = self.inner.as_mut() {
w.write_str(s)?;
}
Ok(())
}
}

/// Number of bytes the formatted args would produce.
///
/// `fmt::Arguments` drives a `fmt::Write` impl that only sums `s.len()`.
Expand Down Expand Up @@ -2888,10 +2819,6 @@ pub fn hex_int_lower<const NIBBLES: usize>(value: u64) -> HexIntFormatter<true,
HexIntFormatter { value }
}

pub fn hex_int_upper<const NIBBLES: usize>(value: u64) -> HexIntFormatter<false, NIBBLES> {
HexIntFormatter { value }
}

/// `{:0N x}` / `{:0N X}` — zero-padded fixed-width hex of a u64 into a stack
/// buffer. Thin alias over [`HexIntFormatter::get_out_buf`] for callers that
/// want bytes, not a `Display` adapter.
Expand Down
4 changes: 2 additions & 2 deletions src/bun_core/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1181,8 +1181,8 @@ pub use crate::fmt::{
format_ip, format_latin1, format_utf16_type, hex_byte_lower, hex_byte_upper, hex_char_lower,
hex_char_upper, hex_digit_value, hex_lower, hex_pair_value, hex_u16, hex_upper, hex2_lower,
hex2_upper, hex4_upper, int_as_bytes, parse_ascii, parse_f32, parse_f64, parse_hex_prefix,
parse_hex_to_int, parse_hex4, parse_int as parse_int_radix, parse_num, print_int, quote, raw,
s, size, truncated_hash32, truncated_hash32_bytes, utf16,
parse_hex_to_int, parse_hex4, parse_int as parse_int_radix, print_int, quote, raw, s, size,
truncated_hash32, truncated_hash32_bytes, utf16,
};

/// Tier-0 surrogate/transcode primitives that [`crate::string::immutable`]
Expand Down
6 changes: 0 additions & 6 deletions src/css/media_query.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1258,12 +1258,6 @@ impl MediaList {
Self { media_queries }
}

/// Alias for `deep_clone`.
#[inline]
pub fn clone_in(&self, bump: &bun_alloc::Arena) -> Self {
self.deep_clone(bump)
}

/// `MediaList` carries no
/// `ImportRecord` indices so this is just `deep_clone`.
#[inline]
Expand Down
33 changes: 0 additions & 33 deletions src/jsc/bindings/AsyncContextFrame.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -114,14 +114,6 @@ extern "C" JSC::EncodedJSValue AsyncContextFrame__withAsyncContextIfNeeded(JSGlo
} \
return result;

// JSValue AsyncContextFrame::call(JSGlobalObject* global, JSValue functionObject, const ArgList& args, ASCIILiteral errorMessage)
// {
// ASYNCCONTEXTFRAME_CALL_IMPL(global, ProfilingReason::API, functionObject, args, errorMessage);
// }
// JSValue AsyncContextFrame::call(JSGlobalObject* global, JSValue functionObject, JSValue thisValue, const ArgList& args, ASCIILiteral errorMessage)
// {
// ASYNCCONTEXTFRAME_CALL_IMPL(global, ProfilingReason::API, functionObject, thisValue, args, errorMessage);
// }
JSValue AsyncContextFrame::call(JSGlobalObject* global, JSValue functionObject, JSValue thisValue, const ArgList& args)
{
#if ASSERT_ENABLED
Expand All @@ -134,33 +126,8 @@ JSValue AsyncContextFrame::call(JSGlobalObject* global, JSValue functionObject,

ASYNCCONTEXTFRAME_CALL_IMPL(global, ProfilingReason::API, functionObject, JSC::getCallData(functionObject), thisValue, args);
}
JSValue AsyncContextFrame::call(JSGlobalObject* global, JSValue functionObject, JSValue thisValue, const ArgList& args, NakedPtr<JSC::Exception>& returnedException)
{
#if ASSERT_ENABLED
auditEverything(global, functionObject, thisValue, args);
#endif

if (!global->isAsyncContextTrackingEnabled()) [[likely]] {
return JSC::profiledCall(global, ProfilingReason::API, functionObject, JSC::getCallData(functionObject), thisValue, args, returnedException);
}

ASYNCCONTEXTFRAME_CALL_IMPL(global, ProfilingReason::API, functionObject, JSC::getCallData(functionObject), thisValue, args, returnedException);
}
JSValue AsyncContextFrame::profiledCall(JSGlobalObject* global, JSValue functionObject, JSValue thisValue, const ArgList& args)
{
return AsyncContextFrame::call(global, functionObject, thisValue, args);
}
JSValue AsyncContextFrame::profiledCall(JSGlobalObject* global, JSValue functionObject, JSValue thisValue, const ArgList& args, NakedPtr<JSC::Exception>& returnedException)
{
return AsyncContextFrame::call(global, functionObject, thisValue, args, returnedException);
}

JSC::JSValue AsyncContextFrame::run(JSGlobalObject* global, JSValue functionObject, JSValue thisValue, const ArgList& args)
{
ASSERT(global->isAsyncContextTrackingEnabled());
#if ASSERT_ENABLED
auditEverything(global, functionObject, thisValue, args);
#endif
ASYNCCONTEXTFRAME_CALL_IMPL(global, ProfilingReason::API, functionObject, JSC::getCallData(functionObject), thisValue, args);
}
#undef ASYNCCONTEXTFRAME_CALL_IMPL
13 changes: 0 additions & 13 deletions src/jsc/bindings/AsyncContextFrame.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,30 +20,17 @@ class AsyncContextFrame : public JSC::JSNonFinalObject {
// The following is JSC::call but
// - it unwraps AsyncContextFrame
// - does not take a CallData, because JSC::getCallData(AsyncContextFrame) -> not callable
// static JSC::JSValue call(JSC::JSGlobalObject*, JSC::JSValue functionObject, const JSC::ArgList&, ASCIILiteral errorMessage);
// static JSC::JSValue call(JSC::JSGlobalObject*, JSC::JSValue functionObject, JSC::JSValue thisValue, const JSC::ArgList&, ASCIILiteral errorMessage);
static JSC::JSValue call(JSC::JSGlobalObject*, JSC::JSValue functionObject, JSC::JSValue thisValue, const JSC::ArgList&);
static JSC::JSValue call(JSC::JSGlobalObject*, JSC::JSValue functionObject, JSC::JSValue thisValue, const JSC::ArgList&, NakedPtr<JSC::Exception>& returnedException);

// Alias of call.
static JSC::JSValue profiledCall(JSC::JSGlobalObject*, JSC::JSValue functionObject, JSC::JSValue thisValue, const JSC::ArgList&);

// Alias of call.
static JSC::JSValue profiledCall(JSC::JSGlobalObject*, JSC::JSValue functionObject, JSC::JSValue thisValue, const JSC::ArgList&, NakedPtr<JSC::Exception>& returnedException);

DECLARE_INFO;
DECLARE_VISIT_CHILDREN;

mutable JSC::WriteBarrier<JSC::Unknown> callback;
mutable JSC::WriteBarrier<JSC::Unknown> context;

/**
* When you have a **specific** AsyncContextFrame to run the function in, use this
*
* Usually, you do not want to use this. Usually, you want to use `call` or `profiledCall`.
*/
JSC::JSValue run(JSC::JSGlobalObject* globalObject, JSC::JSValue functionObject, JSC::JSValue thisValue, const JSC::ArgList& args);

template<typename, JSC::SubspaceAccess mode>
static JSC::GCClient::IsoSubspace* subspaceFor(JSC::VM& vm)
{
Expand Down
1 change: 0 additions & 1 deletion src/jsc/bindings/ConsoleObject.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,6 @@ void ConsoleObject::recordEnd(JSGlobalObject*, Ref<ScriptArguments>&&) {}
void ConsoleObject::screenshot(JSGlobalObject*, Ref<ScriptArguments>&&)
{
}
Comment thread
robobun marked this conversation as resolved.
void ConsoleObject::warnUnimplemented(const String& method) {}

void ConsoleObject::profile(JSC::JSGlobalObject* globalObject, const String& title)
{
Expand Down
31 changes: 0 additions & 31 deletions src/jsc/bindings/ConsoleObject.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,9 @@
#include "root.h"

#include <JavaScriptCore/ConsoleClient.h>
#include <wtf/Vector.h>
#include <wtf/text/WTFString.h>

#include <JavaScriptCore/InspectorConsoleAgent.h>

namespace Inspector {
class InspectorConsoleAgent;
class InspectorDebuggerAgent;
class InspectorScriptProfilerAgent;
} // namespace Inspector
namespace Bun {
using InspectorConsoleAgent = Inspector::InspectorConsoleAgent;
using InspectorDebuggerAgent = Inspector::InspectorDebuggerAgent;
using InspectorScriptProfilerAgent = Inspector::InspectorScriptProfilerAgent;
using namespace JSC;

class ConsoleObject final : public JSC::ConsoleClient {
Expand All @@ -30,16 +19,6 @@ class ConsoleObject final : public JSC::ConsoleClient {
m_client = client;
}

static bool logToSystemConsole();
static void setLogToSystemConsole(bool);

Inspector::InspectorConsoleAgent* consoleAgent() { return m_consoleAgent; }
void setDebuggerAgent(InspectorDebuggerAgent* agent) { m_debuggerAgent = agent; }
void setPersistentScriptProfilerAgent(InspectorScriptProfilerAgent* agent)
{
m_scriptProfilerAgent = agent;
}

void* m_client;

private:
Expand All @@ -57,16 +36,6 @@ class ConsoleObject final : public JSC::ConsoleClient {
void record(JSC::JSGlobalObject*, Ref<Inspector::ScriptArguments>&&);
void recordEnd(JSC::JSGlobalObject*, Ref<Inspector::ScriptArguments>&&);
void screenshot(JSC::JSGlobalObject*, Ref<Inspector::ScriptArguments>&&);
Comment thread
robobun marked this conversation as resolved.

void warnUnimplemented(const String& method);
void internalAddMessage(MessageType, MessageLevel, JSC::JSGlobalObject*,
Ref<Inspector::ScriptArguments>&&);

Inspector::InspectorConsoleAgent* m_consoleAgent;
Inspector::InspectorDebuggerAgent* m_debuggerAgent { nullptr };
Inspector::InspectorScriptProfilerAgent* m_scriptProfilerAgent { nullptr };
Vector<String> m_profiles;
bool m_profileRestoreBreakpointActiveValue { false };
};

} // namespace Zig
75 changes: 0 additions & 75 deletions src/jsc/bindings/JSDOMGlobalObject.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,79 +9,4 @@ Zig::GlobalObject* toJSDOMGlobalObject(ScriptExecutionContext& ctx, DOMWrapperWo
return uncheckedDowncast<Zig::GlobalObject>(ctx.jsGlobalObject());
}

// static JSDOMGlobalObject& callerGlobalObject(JSC::JSGlobalObject& lexicalGlobalObject, JSC::CallFrame* callFrame, bool skipFirstFrame, bool lookUpFromVMEntryScope)
// {
// VM& vm = lexicalGlobalObject.vm();
// if (callFrame) {
// class GetCallerGlobalObjectFunctor {
// public:
// GetCallerGlobalObjectFunctor(bool skipFirstFrame)
// : m_skipFirstFrame(skipFirstFrame)
// {
// }

// StackVisitor::Status operator()(StackVisitor& visitor) const
// {
// if (m_skipFirstFrame) {
// if (!m_hasSkippedFirstFrame) {
// m_hasSkippedFirstFrame = true;
// return StackVisitor::Continue;
// }
// }

// if (auto* codeBlock = visitor->codeBlock())
// m_globalObject = codeBlock->globalObject();
// else {
// ASSERT(visitor->callee().rawPtr());
// // FIXME: Callee is not an object if the caller is Web Assembly.
// // Figure out what to do here. We can probably get the global object
// // from the top-most Wasm Instance. https://bugs.webkit.org/show_bug.cgi?id=165721
// if (visitor->callee().isCell() && visitor->callee().asCell()->isObject())
// m_globalObject = uncheckedDowncast<JSObject>(visitor->callee().asCell())->globalObject();
// }
// return StackVisitor::Done;
// }

// JSC::JSGlobalObject* globalObject() const { return m_globalObject; }

// private:
// bool m_skipFirstFrame { false };
// mutable bool m_hasSkippedFirstFrame { false };
// mutable JSC::JSGlobalObject* m_globalObject { nullptr };
// };

// GetCallerGlobalObjectFunctor iter(skipFirstFrame);
// callFrame->iterate(vm, iter);
// if (iter.globalObject())
// return *uncheckedDowncast<JSDOMGlobalObject>(iter.globalObject());
// }

// // In the case of legacyActiveGlobalObjectForAccessor, it is possible that vm.topCallFrame is nullptr when the script is evaluated as JSONP.
// // Since we put JSGlobalObject to VMEntryScope, we can retrieve the right globalObject from that.
// // For callerGlobalObject, we do not check vm.entryScope to keep it the old behavior.
// if (lookUpFromVMEntryScope) {
// if (vm.entryScope) {
// if (auto* result = vm.entryScope->globalObject())
// return *uncheckedDowncast<JSDOMGlobalObject>(result);
// }
// }

// // If we cannot find JSGlobalObject in caller frames, we just return the current lexicalGlobalObject.
// return *uncheckedDowncast<JSDOMGlobalObject>(&lexicalGlobalObject);
// }

// JSDOMGlobalObject& callerGlobalObject(JSC::JSGlobalObject& lexicalGlobalObject, JSC::CallFrame* callFrame)
// {
// constexpr bool skipFirstFrame = true;
// constexpr bool lookUpFromVMEntryScope = false;
// return callerGlobalObject(lexicalGlobalObject, callFrame, skipFirstFrame, lookUpFromVMEntryScope);
// }

// JSDOMGlobalObject& legacyActiveGlobalObjectForAccessor(JSC::JSGlobalObject& lexicalGlobalObject, JSC::CallFrame* callFrame)
// {
// constexpr bool skipFirstFrame = false;
// constexpr bool lookUpFromVMEntryScope = true;
// return callerGlobalObject(lexicalGlobalObject, callFrame, skipFirstFrame, lookUpFromVMEntryScope);
// }

}
Loading
Loading