Skip to content
Merged
Show file tree
Hide file tree
Changes from 9 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
1 change: 0 additions & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

24 changes: 0 additions & 24 deletions src/install/lockfile/Buffers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -236,10 +236,6 @@ where
let mut clone: Vec<$elem> = Vec::with_capacity(buffers.$field.len());
clone.extend_from_slice(buffers.$field.as_slice());
write_array(stream, clone.as_slice(), $prefix)?;
#[cfg(debug_assertions)]
{
// Output::pretty_errorln(format_args!("Field {}: {} - {}", $name, pos, stream.get_pos()?));
}
}};
}

Expand All @@ -264,10 +260,6 @@ where
// reader ignores this string; only the exact bytes matter.
"\n<install.lockfile.Tree> 20 sizeof, 4 alignof\n",
)?;
#[cfg(debug_assertions)]
{
// Output::pretty_errorln(format_args!("Field {}: {} - {}", "trees", pos, stream.get_pos()?));
}
}

// -- hoisted_dependencies --
Expand Down Expand Up @@ -349,11 +341,6 @@ where
to_clone.as_slice(),
"\n<[26]u8> 26 sizeof, 1 alignof\n",
)?;

#[cfg(debug_assertions)]
{
// Output::pretty_errorln(format_args!("Field {}: {} - {}", "dependencies", pos, stream.get_pos()?));
}
}

// -- extern_strings --
Expand Down Expand Up @@ -418,25 +405,17 @@ pub(crate) fn load(

macro_rules! load_generic_field {
($field:ident, $name:literal, $elem:ty) => {{
#[cfg(debug_assertions)]
let _pos: usize = stream.pos;

this.$field = read_array::<$elem>(stream)?;
if let Some(pm) = pm_.as_deref() {
if pm.options.log_level.is_verbose() {
bun_core::pretty_errorln!("Loaded {} {}", this.$field.len(), $name);
}
}
// #[cfg(debug_assertions)]
// Output::pretty_errorln(format_args!("Field {}: {} - {}", $name, _pos, stream.get_pos()?));
}};
}

Comment thread
robobun marked this conversation as resolved.
// -- trees --
{
#[cfg(debug_assertions)]
let _pos: usize = stream.pos;

let tree_list: Vec<tree::External> = read_array(stream)?;
// `set_len` then `iter_mut()` would form `&mut Tree` to uninitialized
// memory (UB), so we push into the reserved capacity instead.
Expand All @@ -455,9 +434,6 @@ pub(crate) fn load(

// -- dependencies --
{
#[cfg(debug_assertions)]
let _pos: usize = stream.pos;

external_dependency_list_ = read_array::<dependency::External>(stream)?;
if let Some(pm) = pm_.as_deref() {
if pm.options.log_level.is_verbose() {
Expand Down
4 changes: 0 additions & 4 deletions src/install/lockfile/bun.lock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -165,10 +165,6 @@ pub(crate) struct Stringifier;
impl Stringifier {
const INDENT_SCALAR: usize = 2;

// pub fn save(this: &Lockfile) {
// let _ = this;
// }

pub(crate) fn save_from_binary(
lockfile: &mut BinaryLockfile,
load_result: &LoadResult,
Expand Down
11 changes: 0 additions & 11 deletions src/io/posix_event_loop.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,6 @@ fn loop_sub_active(loop_: &mut Loop, value: u32) {
loop_.active = loop_.active.saturating_sub(value);
}

bun_core::declare_scope!(KeepAlive, visible);

#[cfg(not(windows))]
use bun_sys::syslog;

Expand Down Expand Up @@ -558,15 +556,6 @@ impl FilePoll {
poll
}

Comment thread
robobun marked this conversation as resolved.
/// Allow a poll to keep the process alive.
pub fn ref_(&mut self, event_loop_ctx: EventLoopCtx) {
if self.flags.contains(Flags::Closed) {
return;
}
syslog!("ref");
self.enable_keeping_process_alive(event_loop_ctx);
}

pub fn register(&mut self, loop_: &mut Loop, flag: Flags, one_shot: bool) -> sys::Result<()> {
self.register_with_fd(
loop_,
Expand Down
35 changes: 1 addition & 34 deletions src/io/windows_event_loop.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,6 @@ use crate::posix_event_loop as posix;
// that name them via this module.
pub use crate::posix_event_loop::{EventLoopCtx, OpaqueCallback, js_vm_ctx};

bun_core::declare_scope!(KeepAlive, visible);
bun_core::declare_scope!(FilePoll, visible);

// `Loop` here is the raw
// `uv_loop_t`. (`WindowsLoop` is the uws wrapper that *owns* a `*mut uv::Loop`
// in its `.uv_loop` field; callers that hold a `WindowsLoop*` project that
Expand Down Expand Up @@ -57,7 +54,7 @@ impl FilePoll {
|| self.flags.contains(Flags::PollMachport)
}

/// Make calling ref() on this poll into a no-op.
/// Decrements the active counter if it was previously incremented.
pub(crate) fn disable_keeping_process_alive(&mut self, vm: EventLoopCtx) {
if self.flags.contains(Flags::Closed) {
return;
Expand Down Expand Up @@ -155,36 +152,6 @@ impl FilePoll {

vm.loop_add_active(self.flags.contains(Flags::HasIncrementedPollCount) as u32);
}
Comment thread
robobun marked this conversation as resolved.

/// Only intended to be used from EventLoop.Pollable
pub fn activate(&mut self, loop_: &mut WindowsLoop) {
loop_.add_active(
(!self.flags.contains(Flags::Closed)
&& !self.flags.contains(Flags::HasIncrementedPollCount)) as u32,
);
bun_core::scoped_log!(FilePoll, "activate - {}", loop_.uv().active_handles);
self.flags.insert(Flags::HasIncrementedPollCount);
}

#[inline]
pub fn can_ref(&self) -> bool {
if self.flags.contains(Flags::Closed) {
return false;
}

!self.flags.contains(Flags::HasIncrementedPollCount)
}

/// Allow a poll to keep the process alive.
// pub fn ref(this: *FilePoll, vm: *jsc.VirtualMachine) void {
pub fn ref_(&mut self, event_loop_ctx: EventLoopCtx) {
if self.can_ref() {
return;
}
bun_core::scoped_log!(FilePoll, "ref");
// this.activate(vm.event_loop_handle.?);
self.activate(event_loop_ctx.loop_mut());
}
}

type FilePollHiveArray = bun_collections::hive_array::Fallback<FilePoll, 128>;
Expand Down
4 changes: 0 additions & 4 deletions src/js/node/net.ts
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,6 @@ const bunTlsSymbol = Symbol.for("::buntls::");
const bunSocketServerOptions = Symbol.for("::bunnetserveroptions::");
const owner_symbol = Symbol("owner_symbol");

const kServerSocket = Symbol("kServerSocket");
const kBytesWritten = Symbol("kBytesWritten");
const bunTLSConnectOptions = Symbol.for("::buntlsconnectoptions::");
// tls.Server exposes its native SecureContext constructor through this key so
Expand All @@ -141,7 +140,6 @@ const kSetKeepAliveInitialDelay = Symbol("kSetKeepAliveInitialDelay");
const kConnectOptions = Symbol("connect-options");
const kAttach = Symbol("kAttach");
const kCloseRawConnection = Symbol("kCloseRawConnection");
const kpendingRead = Symbol("kpendingRead");
const kupgraded = Symbol("kupgraded");
const kAdoptedTLSRaw = Symbol("kAdoptedTLSRaw");
const ksocket = Symbol("ksocket");
Expand Down Expand Up @@ -1125,7 +1123,6 @@ function onconnection(err, clientHandle) {
self.emit("error", err);
return;
}
clientHandle[kServerSocket] = handle;
const options = self[bunSocketServerOptions];
const { pauseOnConnect, connectionListener, [kSocketClass]: SClass } = options;
// Propagate the server's half-open/highWaterMark settings to the accepted
Expand Down Expand Up @@ -1556,7 +1553,6 @@ function Socket(options?) {
});
this._parent = null;
this._parentWrap = null;
this[kpendingRead] = undefined;
this[kupgraded] = null;

this[kSetNoDelay] = Boolean(noDelay);
Expand Down
3 changes: 0 additions & 3 deletions src/jsc/bindings/Bindgen/IDLTypes.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,6 @@ struct IDLStrongAny : WebCore::IDLType<Bun::StrongRef> {
}
};

template<typename T>
struct IsIDLStrongAny : std::integral_constant<bool, std::is_base_of<IDLStrongAny, T>::value> {};

// Dictionaries that contain raw `JSValue`s must live on the stack.
template<typename T>
struct IDLStackOnlyDictionary : WebCore::IDLType<T> {
Expand Down
9 changes: 0 additions & 9 deletions src/jsc/bindings/BunClientData.h
Original file line number Diff line number Diff line change
Expand Up @@ -109,8 +109,6 @@ class JSVMClientData : public JSC::VM::ClientData {

ExtendedDOMClientIsoSubspaces& clientSubspaces() { return *m_clientSubspaces.get(); }

Vector<JSC::IsoSubspace*>& outputConstraintSpaces() { return m_outputConstraintSpaces; }

JSC::GCClient::IsoSubspace& domBuiltinConstructorSpace() { return m_domBuiltinConstructorSpace; }

// Constructed eagerly so the concurrent GC marker
Expand All @@ -120,12 +118,6 @@ class JSVMClientData : public JSC::VM::ClientData {
// so there is no startup cost worth deferring.
WebCore::HTTPHeaderIdentifiers& httpHeaderIdentifiers() { return m_httpHeaderIdentifiers; }

template<typename Func> void forEachOutputConstraintSpace(const Func& func)
{
for (auto* space : m_outputConstraintSpaces)
func(*space);
}

void* bunVM;
Bun::JSCTaskScheduler deferredWorkTimer;

Expand Down Expand Up @@ -178,7 +170,6 @@ class JSVMClientData : public JSC::VM::ClientData {
JSC::GCClient::IsoSubspace m_domNamespaceObjectSpace;

std::unique_ptr<ExtendedDOMClientIsoSubspaces> m_clientSubspaces;
Vector<JSC::IsoSubspace*> m_outputConstraintSpaces;

WebCore::HTTPHeaderIdentifiers m_httpHeaderIdentifiers;
};
Expand Down
2 changes: 1 addition & 1 deletion src/jsc/bindings/DeleteCallbackDataTask.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ class DeleteCallbackDataTask : public EventLoopTask {
public:
template<typename CallbackDataType>
explicit DeleteCallbackDataTask(CallbackDataType* data)
: EventLoopTask(EventLoopTask::CleanupTask, [data](ScriptExecutionContext&) mutable {
: EventLoopTask([data](ScriptExecutionContext&) mutable {
delete data;
})
{
Expand Down
13 changes: 0 additions & 13 deletions src/jsc/bindings/EventLoopTask.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,25 +7,14 @@ class EventLoopTask {
WTF_MAKE_TZONE_ALLOCATED(EventLoopTask);

public:
enum CleanupTaskTag { CleanupTask };

template<typename T, typename = typename std::enable_if<!std::is_base_of<EventLoopTask, T>::value && std::is_convertible<T, Function<void(ScriptExecutionContext&)>>::value>::type>
EventLoopTask(T task)
: m_task(WTF::move(task))
, m_isCleanupTask(false)
{
}

EventLoopTask(Function<void()>&& task)
: m_task([task = WTF::move(task)](ScriptExecutionContext&) { task(); })
, m_isCleanupTask(false)
{
}

template<typename T, typename = typename std::enable_if<std::is_convertible<T, Function<void(ScriptExecutionContext&)>>::value>::type>
EventLoopTask(CleanupTaskTag, T task)
: m_task(WTF::move(task))
, m_isCleanupTask(true)
{
}

Expand All @@ -34,11 +23,9 @@ class EventLoopTask {
m_task(context);
delete this;
}
bool isCleanupTask() const { return m_isCleanupTask; }

protected:
Function<void(ScriptExecutionContext&)> m_task;
bool m_isCleanupTask;
};

}
24 changes: 0 additions & 24 deletions src/jsc/bindings/JSBuffer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2391,30 +2391,6 @@ static JSC::EncodedJSValue jsBufferPrototypeFunction_SliceWithEncoding(JSC::JSGl
return jsBufferToString(lexicalGlobalObject, scope, castedThis, start, end - start, encoding);
}

// DOMJIT makes it slower! TODO: investigate why
// JSC_DECLARE_JIT_OPERATION_WITHOUT_WTF_INTERNAL(jsBufferPrototypeToStringWithoutTypeChecks, JSValue, (JSC::JSGlobalObject * lexicalGlobalObject, JSC::JSUint8Array* thisValue, JSC::JSString* encodingValue));

// JSC_DEFINE_JIT_OPERATION(jsBufferPrototypeToStringWithoutTypeChecks, JSValue, (JSC::JSGlobalObject * lexicalGlobalObject, JSUint8Array* thisValue, JSString* encodingValue))
// {
// auto& vm = JSC::getVM(lexicalGlobalObject);
// IGNORE_WARNINGS_BEGIN("frame-address")
// CallFrame* callFrame = DECLARE_CALL_FRAME(vm);
// IGNORE_WARNINGS_END
// JSC::JITOperationPrologueCallFrameTracer tracer(vm, callFrame);

// std::optional<BufferEncodingType> encoded = parseEnumeration<BufferEncodingType>(*lexicalGlobalObject, encodingValue);
// if (!encoded) {
// auto scope = DECLARE_THROW_SCOPE(vm);

// throwTypeError(lexicalGlobalObject, scope, "Invalid encoding"_s);
// return {};
// }

// auto encoding = encoded.value();

// return JSValue::decode(jsBufferToString(vm, lexicalGlobalObject, thisValue, 0, thisValue->byteLength(), encoding));
// }

// https://github.com/nodejs/node/blob/v26.3.0/lib/internal/buffer.js#L962-L990
// Only utf8Write/latin1Write/asciiWrite go through this strict JS wrapper in node;
// the other encodings use jsBufferPrototypeFunction_StringWriteWithEncoding below.
Expand Down
4 changes: 0 additions & 4 deletions src/jsc/bindings/JSBufferList.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -456,10 +456,6 @@ JSC::EncodedJSValue JSBufferListConstructor::construct(JSC::JSGlobalObject* lexi
return JSC::JSValue::encode(bufferList);
}

void JSBufferListConstructor::initializeProperties(VM& vm, JSC::JSGlobalObject* globalObject, JSBufferListPrototype* prototype)
{
}

const ClassInfo JSBufferListConstructor::s_info = { "BufferList"_s, &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSBufferListConstructor) };

} // namespace Zig
3 changes: 0 additions & 3 deletions src/jsc/bindings/JSBufferList.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ class JSBufferList : public JSC::JSNonFinalObject {
}

void finishCreation(JSC::VM& vm, JSC::JSGlobalObject* globalObject);
static void destroy(JSCell*) {}

inline size_t length() { return m_deque.size(); }
void push(JSC::VM& vm, JSC::JSValue v)
Expand Down Expand Up @@ -153,8 +152,6 @@ class JSBufferListConstructor final : public JSC::InternalFunction {
return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::InternalFunctionType, StructureFlags), info());
}

void initializeProperties(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSBufferListPrototype* prototype);

// Must be defined for each specialization class.
static JSC::EncodedJSValue JSC_HOST_CALL_ATTRIBUTES construct(JSC::JSGlobalObject*, JSC::CallFrame*);
DECLARE_EXPORT_INFO;
Expand Down
25 changes: 2 additions & 23 deletions src/jsc/bindings/JSEnvironmentVariableMap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,21 +61,6 @@ JSC_DEFINE_CUSTOM_GETTER(jsGetterEnvironmentVariable, (JSGlobalObject * globalOb
return JSValue::encode(result);
}

JSC_DEFINE_CUSTOM_SETTER(jsSetterEnvironmentVariable, (JSGlobalObject * globalObject, JSC::EncodedJSValue thisValue, JSC::EncodedJSValue value, PropertyName propertyName))
{
VM& vm = globalObject->vm();
JSC::JSObject* object = JSValue::decode(thisValue).getObject();
if (!object)
return false;

auto string = JSValue::decode(value).toString(globalObject);
if (!string) [[unlikely]]
return false;

object->putDirect(vm, propertyName, string, 0);
return true;
}

// Proxy-related env vars (HTTP_PROXY, HTTPS_PROXY, NO_PROXY and lowercase
// variants) are read by fetch()'s native proxy resolution via
// env_loader.getHttpProxyFor(). Writes from JS must sync back to the native env
Expand Down Expand Up @@ -118,14 +103,8 @@ JSC_DEFINE_CUSTOM_SETTER(jsSetterProxyEnvironmentVariable, (JSGlobalObject * glo
BunString val = Bun::toStringView(view);
Bun__setEnvValue(globalObject, &name, &val);

// The proxy-var accessors are added with `DontEnum` when the var was not
// present in the OS env at startup. The regular env-var setter
// (`jsSetterEnvironmentVariable`) makes a written var enumerable by
// replacing the accessor with a data property; this setter keeps the
// accessor (so the native env map stays the source of truth) but must
// still clear `DontEnum` — otherwise `process.env.HTTP_PROXY = "..."`
// followed by `Bun.spawn({env: {...process.env}})` silently drops the var
// (the spread skips non-enumerable properties).
// Proxy-var accessors are installed DontEnum when absent from the OS env
// at startup; clear it on write so `{...process.env}` picks the var up.
Comment thread
robobun marked this conversation as resolved.
unsigned attributes;
JSValue existing = object->getDirect(vm, propertyName, attributes);
if (existing && (attributes & JSC::PropertyAttribute::DontEnum)) {
Expand Down
Loading
Loading