diff --git a/Cargo.lock b/Cargo.lock index eeec9e5dc3d5..6fa7ae52ec9a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2219,7 +2219,6 @@ dependencies = [ "libc", "scopeguard", "strum", - "thiserror", ] [[package]] diff --git a/src/install/lockfile/Buffers.rs b/src/install/lockfile/Buffers.rs index 2cc3d333dcb8..7a2d2db3e158 100644 --- a/src/install/lockfile/Buffers.rs +++ b/src/install/lockfile/Buffers.rs @@ -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()?)); - } }}; } @@ -264,10 +260,6 @@ where // reader ignores this string; only the exact bytes matter. "\n 20 sizeof, 4 alignof\n", )?; - #[cfg(debug_assertions)] - { - // Output::pretty_errorln(format_args!("Field {}: {} - {}", "trees", pos, stream.get_pos()?)); - } } // -- hoisted_dependencies -- @@ -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 -- @@ -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()?)); }}; } // -- trees -- { - #[cfg(debug_assertions)] - let _pos: usize = stream.pos; - let tree_list: Vec = read_array(stream)?; // `set_len` then `iter_mut()` would form `&mut Tree` to uninitialized // memory (UB), so we push into the reserved capacity instead. @@ -455,9 +434,6 @@ pub(crate) fn load( // -- dependencies -- { - #[cfg(debug_assertions)] - let _pos: usize = stream.pos; - external_dependency_list_ = read_array::(stream)?; if let Some(pm) = pm_.as_deref() { if pm.options.log_level.is_verbose() { diff --git a/src/install/lockfile/bun.lock.rs b/src/install/lockfile/bun.lock.rs index ada9255061ad..7a26bc2d3f40 100644 --- a/src/install/lockfile/bun.lock.rs +++ b/src/install/lockfile/bun.lock.rs @@ -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, diff --git a/src/io/posix_event_loop.rs b/src/io/posix_event_loop.rs index 0496d44d57b0..7e3086134f96 100644 --- a/src/io/posix_event_loop.rs +++ b/src/io/posix_event_loop.rs @@ -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; @@ -558,15 +556,6 @@ impl FilePoll { poll } - /// 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_, diff --git a/src/io/windows_event_loop.rs b/src/io/windows_event_loop.rs index 2d7edb3c9d62..5683f2a3796c 100644 --- a/src/io/windows_event_loop.rs +++ b/src/io/windows_event_loop.rs @@ -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 @@ -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; @@ -155,36 +152,6 @@ impl FilePoll { vm.loop_add_active(self.flags.contains(Flags::HasIncrementedPollCount) as u32); } - - /// 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; diff --git a/src/js/node/net.ts b/src/js/node/net.ts index 5125e380715f..6e8dc59a568d 100644 --- a/src/js/node/net.ts +++ b/src/js/node/net.ts @@ -122,6 +122,8 @@ const bunTlsSymbol = Symbol.for("::buntls::"); const bunSocketServerOptions = Symbol.for("::bunnetserveroptions::"); const owner_symbol = Symbol("owner_symbol"); +// Write-only by design: the onconnection write is a GC edge keeping the +// native Listener reachable via accepted socket handles (see a93d2fa48e). const kServerSocket = Symbol("kServerSocket"); const kBytesWritten = Symbol("kBytesWritten"); const bunTLSConnectOptions = Symbol.for("::buntlsconnectoptions::"); @@ -141,7 +143,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"); @@ -1556,7 +1557,6 @@ function Socket(options?) { }); this._parent = null; this._parentWrap = null; - this[kpendingRead] = undefined; this[kupgraded] = null; this[kSetNoDelay] = Boolean(noDelay); diff --git a/src/jsc/bindings/Bindgen/IDLTypes.h b/src/jsc/bindings/Bindgen/IDLTypes.h index d0275d9fb0cd..93089efbe6e6 100644 --- a/src/jsc/bindings/Bindgen/IDLTypes.h +++ b/src/jsc/bindings/Bindgen/IDLTypes.h @@ -17,9 +17,6 @@ struct IDLStrongAny : WebCore::IDLType { } }; -template -struct IsIDLStrongAny : std::integral_constant::value> {}; - // Dictionaries that contain raw `JSValue`s must live on the stack. template struct IDLStackOnlyDictionary : WebCore::IDLType { diff --git a/src/jsc/bindings/BunClientData.h b/src/jsc/bindings/BunClientData.h index 8130d1862ff2..200d3bf1ee0e 100644 --- a/src/jsc/bindings/BunClientData.h +++ b/src/jsc/bindings/BunClientData.h @@ -109,8 +109,6 @@ class JSVMClientData : public JSC::VM::ClientData { ExtendedDOMClientIsoSubspaces& clientSubspaces() { return *m_clientSubspaces.get(); } - Vector& outputConstraintSpaces() { return m_outputConstraintSpaces; } - JSC::GCClient::IsoSubspace& domBuiltinConstructorSpace() { return m_domBuiltinConstructorSpace; } // Constructed eagerly so the concurrent GC marker @@ -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 void forEachOutputConstraintSpace(const Func& func) - { - for (auto* space : m_outputConstraintSpaces) - func(*space); - } - void* bunVM; Bun::JSCTaskScheduler deferredWorkTimer; @@ -178,7 +170,6 @@ class JSVMClientData : public JSC::VM::ClientData { JSC::GCClient::IsoSubspace m_domNamespaceObjectSpace; std::unique_ptr m_clientSubspaces; - Vector m_outputConstraintSpaces; WebCore::HTTPHeaderIdentifiers m_httpHeaderIdentifiers; }; diff --git a/src/jsc/bindings/DeleteCallbackDataTask.h b/src/jsc/bindings/DeleteCallbackDataTask.h index e80ddf6fc75d..fddc4ba9c12a 100644 --- a/src/jsc/bindings/DeleteCallbackDataTask.h +++ b/src/jsc/bindings/DeleteCallbackDataTask.h @@ -6,7 +6,7 @@ class DeleteCallbackDataTask : public EventLoopTask { public: template explicit DeleteCallbackDataTask(CallbackDataType* data) - : EventLoopTask(EventLoopTask::CleanupTask, [data](ScriptExecutionContext&) mutable { + : EventLoopTask([data](ScriptExecutionContext&) mutable { delete data; }) { diff --git a/src/jsc/bindings/EventLoopTask.h b/src/jsc/bindings/EventLoopTask.h index 021c39b1a17e..dc3ffe2aeb93 100644 --- a/src/jsc/bindings/EventLoopTask.h +++ b/src/jsc/bindings/EventLoopTask.h @@ -7,25 +7,14 @@ class EventLoopTask { WTF_MAKE_TZONE_ALLOCATED(EventLoopTask); public: - enum CleanupTaskTag { CleanupTask }; - template::value && std::is_convertible>::value>::type> EventLoopTask(T task) : m_task(WTF::move(task)) - , m_isCleanupTask(false) { } EventLoopTask(Function&& task) : m_task([task = WTF::move(task)](ScriptExecutionContext&) { task(); }) - , m_isCleanupTask(false) - { - } - - template>::value>::type> - EventLoopTask(CleanupTaskTag, T task) - : m_task(WTF::move(task)) - , m_isCleanupTask(true) { } @@ -34,11 +23,9 @@ class EventLoopTask { m_task(context); delete this; } - bool isCleanupTask() const { return m_isCleanupTask; } protected: Function m_task; - bool m_isCleanupTask; }; } diff --git a/src/jsc/bindings/JSBuffer.cpp b/src/jsc/bindings/JSBuffer.cpp index 9d777bf9733b..6c44fd1949a4 100644 --- a/src/jsc/bindings/JSBuffer.cpp +++ b/src/jsc/bindings/JSBuffer.cpp @@ -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 encoded = parseEnumeration(*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. diff --git a/src/jsc/bindings/JSBufferList.cpp b/src/jsc/bindings/JSBufferList.cpp index 11cc614b7eb6..90483db6942d 100644 --- a/src/jsc/bindings/JSBufferList.cpp +++ b/src/jsc/bindings/JSBufferList.cpp @@ -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 diff --git a/src/jsc/bindings/JSBufferList.h b/src/jsc/bindings/JSBufferList.h index 1c8e89ff121a..c3e6773808fe 100644 --- a/src/jsc/bindings/JSBufferList.h +++ b/src/jsc/bindings/JSBufferList.h @@ -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) @@ -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; diff --git a/src/jsc/bindings/JSEnvironmentVariableMap.cpp b/src/jsc/bindings/JSEnvironmentVariableMap.cpp index fc29c4c824fa..dd249e6a7b36 100644 --- a/src/jsc/bindings/JSEnvironmentVariableMap.cpp +++ b/src/jsc/bindings/JSEnvironmentVariableMap.cpp @@ -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 @@ -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. unsigned attributes; JSValue existing = object->getDirect(vm, propertyName, attributes); if (existing && (attributes & JSC::PropertyAttribute::DontEnum)) { diff --git a/src/jsc/bindings/JSMockFunction.h b/src/jsc/bindings/JSMockFunction.h index 1200e289e2c5..e071b4e08758 100644 --- a/src/jsc/bindings/JSMockFunction.h +++ b/src/jsc/bindings/JSMockFunction.h @@ -61,16 +61,6 @@ class MockWithImplementationCleanupData : public JSC::JSInternalFieldObjectImpl< static MockWithImplementationCleanupData* create(JSC::JSGlobalObject* globalObject, JSMockFunction* fn, JSValue impl, JSValue tail, JSValue fallback); static Structure* createStructure(VM&, JSGlobalObject*, JSValue); - static std::array initialValues() - { - return { { - jsUndefined(), - jsUndefined(), - jsUndefined(), - jsUndefined(), - } }; - } - DECLARE_EXPORT_INFO; DECLARE_VISIT_CHILDREN; diff --git a/src/jsc/bindings/JSNextTickQueue.h b/src/jsc/bindings/JSNextTickQueue.h index 5237e9b3b77d..0fa25d43bb69 100644 --- a/src/jsc/bindings/JSNextTickQueue.h +++ b/src/jsc/bindings/JSNextTickQueue.h @@ -18,15 +18,6 @@ class JSNextTickQueue : public JSC::JSInternalFieldObjectImpl<3> { static JSNextTickQueue* create(JSC::JSGlobalObject* globalObject); static Structure* createStructure(VM&, JSGlobalObject*, JSValue); - static std::array initialValues() - { - return { { - jsNumber(-1), - jsUndefined(), - jsUndefined(), - } }; - } - DECLARE_EXPORT_INFO; DECLARE_VISIT_CHILDREN; diff --git a/src/jsc/bindings/JSStringDecoder.cpp b/src/jsc/bindings/JSStringDecoder.cpp index 7ba39e9249ea..c1fea1e60a05 100644 --- a/src/jsc/bindings/JSStringDecoder.cpp +++ b/src/jsc/bindings/JSStringDecoder.cpp @@ -605,15 +605,6 @@ JSC::EncodedJSValue JSStringDecoderConstructor::construct(JSC::JSGlobalObject* l return JSC::JSValue::encode(jsObject); } -void JSStringDecoderConstructor::initializeProperties(VM& vm, JSC::JSGlobalObject* globalObject, JSStringDecoderPrototype* prototype) -{ - putDirect(vm, vm.propertyNames->length, jsNumber(1), JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum); - JSString* nameString = jsNontrivialString(vm, "StringDecoder"_s); - m_originalName.set(vm, this, nameString); - putDirect(vm, vm.propertyNames->name, nameString, JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum); - putDirect(vm, vm.propertyNames->prototype, prototype, JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::DontDelete); -} - const ClassInfo JSStringDecoderConstructor::s_info = { "StringDecoder"_s, &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSStringDecoderConstructor) }; } // namespace Zig diff --git a/src/jsc/bindings/JSStringDecoder.h b/src/jsc/bindings/JSStringDecoder.h index 12fe89bf25ea..88b75417414e 100644 --- a/src/jsc/bindings/JSStringDecoder.h +++ b/src/jsc/bindings/JSStringDecoder.h @@ -110,8 +110,6 @@ class JSStringDecoderConstructor 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, JSStringDecoderPrototype* prototype); - // Must be defined for each specialization class. static JSC::EncodedJSValue JSC_HOST_CALL_ATTRIBUTES construct(JSC::JSGlobalObject*, JSC::CallFrame*); DECLARE_EXPORT_INFO; diff --git a/src/jsc/bindings/ModuleLoader.h b/src/jsc/bindings/ModuleLoader.h index c2a3d65ac588..790ddf09041c 100644 --- a/src/jsc/bindings/ModuleLoader.h +++ b/src/jsc/bindings/ModuleLoader.h @@ -72,15 +72,6 @@ class PendingVirtualModuleResult : public JSC::JSInternalFieldObjectImpl<3> { JSC::JSPromise* internalPromise(); - static std::array initialValues() - { - return { { - jsUndefined(), - jsUndefined(), - jsUndefined(), - } }; - } - DECLARE_EXPORT_INFO; DECLARE_VISIT_CHILDREN; diff --git a/src/jsc/bindings/NapiRef.cpp b/src/jsc/bindings/NapiRef.cpp index 03660630b970..77a260543a57 100644 --- a/src/jsc/bindings/NapiRef.cpp +++ b/src/jsc/bindings/NapiRef.cpp @@ -14,8 +14,6 @@ void NapiRef::ref() auto& vm = globalObject.get()->vm(); strongRef.set(vm, weakValueRef.get()); - // isSet() will return always true after being set once - // We cannot rely on isSet() to check if the value is set we need to use isClear() // .setString/.setObject/.setPrimitive will assert fail if called more than once (even after clear()) // We should not clear the weakValueRef here because we need to keep it if we call NapiRef::unref() // so we can call the finalizer diff --git a/src/jsc/bindings/NodeVM.cpp b/src/jsc/bindings/NodeVM.cpp index 4af8172edc49..804043886410 100644 --- a/src/jsc/bindings/NodeVM.cpp +++ b/src/jsc/bindings/NodeVM.cpp @@ -1111,11 +1111,6 @@ void NodeVMGlobalObject::setContextifiedObject(JSC::JSObject* contextifiedObject m_sandbox.set(vm(), this, contextifiedObject); } -void NodeVMGlobalObject::clearContextifiedObject() -{ - m_sandbox.clear(); -} - void NodeVMGlobalObject::sigintReceived() { vm().notifyNeedTermination(); diff --git a/src/jsc/bindings/NodeVM.h b/src/jsc/bindings/NodeVM.h index fc9b555552ed..9b9076eece83 100644 --- a/src/jsc/bindings/NodeVM.h +++ b/src/jsc/bindings/NodeVM.h @@ -135,7 +135,6 @@ class NodeVMGlobalObject final : public Bun::GlobalScope { static void destroy(JSCell* cell); void setContextifiedObject(JSC::JSObject* contextifiedObject); JSObject* contextifiedObject() const { return m_sandbox.get(); } - void clearContextifiedObject(); void sigintReceived(); bool isNotContextified() const { return m_contextOptions.notContextified; } bool hasOwnMicrotaskQueue() const { return m_contextOptions.ownMicrotaskQueue; } diff --git a/src/jsc/bindings/NodeVMModule.cpp b/src/jsc/bindings/NodeVMModule.cpp index ebb0e31a5990..35397a27d5fa 100644 --- a/src/jsc/bindings/NodeVMModule.cpp +++ b/src/jsc/bindings/NodeVMModule.cpp @@ -20,11 +20,6 @@ NodeVMModuleRequest::NodeVMModuleRequest(WTF::String specifier, WTF::HashMapvm(); diff --git a/src/jsc/bindings/NodeVMModule.h b/src/jsc/bindings/NodeVMModule.h index a0840b85086b..44f0b509d70d 100644 --- a/src/jsc/bindings/NodeVMModule.h +++ b/src/jsc/bindings/NodeVMModule.h @@ -16,10 +16,8 @@ class NodeVMModuleRequest final { NodeVMModuleRequest(WTF::String specifier, WTF::HashMap importAttributes = {}); JSArray* toJS(JSGlobalObject* globalObject) const; - void addImportAttribute(WTF::String key, WTF::String value); const WTF::String& specifier() const { return m_specifier; } - void specifier(WTF::String value) { m_specifier = value; } const WTF::HashMap& importAttributes() const { return m_importAttributes; } private: diff --git a/src/jsc/bindings/NodeVMScript.h b/src/jsc/bindings/NodeVMScript.h index 35d3a15bfcbf..53fb2ee7fd30 100644 --- a/src/jsc/bindings/NodeVMScript.h +++ b/src/jsc/bindings/NodeVMScript.h @@ -71,7 +71,6 @@ class NodeVMScript final : public JSC::JSDestructibleObject, public SigintReceiv const JSC::SourceCode& source() const { return m_source; } WTF::Vector& cachedData() { return m_options.cachedData; } - RefPtr cachedBytecode() const { return m_cachedBytecode; } JSC::ProgramExecutable* cachedExecutable() const { return m_cachedExecutable.get(); } bool cachedDataProduced() const { return m_cachedDataProduced; } void cachedDataProduced(bool value) { m_cachedDataProduced = value; } diff --git a/src/jsc/bindings/NodeVMSourceTextModule.h b/src/jsc/bindings/NodeVMSourceTextModule.h index cf0f96bbcdbd..fc2169d48080 100644 --- a/src/jsc/bindings/NodeVMSourceTextModule.h +++ b/src/jsc/bindings/NodeVMSourceTextModule.h @@ -32,7 +32,6 @@ class NodeVMSourceTextModule final : public NodeVMModule { JSValue createModuleRecord(JSGlobalObject* globalObject); void ensureModuleRecord(JSGlobalObject* globalObject); - bool hasModuleRecord() const { return !!m_moduleRecord; } JSModuleRecord* moduleRecordIfExists() const { return m_moduleRecord.get(); } AbstractModuleRecord* moduleRecord(JSGlobalObject* globalObject); JSValue link(JSGlobalObject* globalObject, JSArray* specifiers, JSArray* moduleNatives, JSValue scriptFetcher); diff --git a/src/jsc/bindings/NodeVMSyntheticModule.h b/src/jsc/bindings/NodeVMSyntheticModule.h index 40986e8d026e..b28df191ff07 100644 --- a/src/jsc/bindings/NodeVMSyntheticModule.h +++ b/src/jsc/bindings/NodeVMSyntheticModule.h @@ -36,7 +36,6 @@ class NodeVMSyntheticModule final : public NodeVMModule { void createModuleRecord(JSGlobalObject* globalObject); void ensureModuleRecord(JSGlobalObject* globalObject); - bool hasModuleRecord() const { return !!m_moduleRecord; } AbstractModuleRecord* moduleRecord(JSGlobalObject* globalObject); JSValue link(JSGlobalObject* globalObject, JSArray* specifiers, JSArray* moduleNatives, JSValue scriptFetcher); JSValue instantiate(JSGlobalObject* globalObject); diff --git a/src/jsc/bindings/blob.h b/src/jsc/bindings/blob.h index 5b3b9231540f..9612ac6942d0 100644 --- a/src/jsc/bindings/blob.h +++ b/src/jsc/bindings/blob.h @@ -38,7 +38,6 @@ struct BlobImplRefDerefTraits { } }; -using BlobRef = Ref, BlobImplRefDerefTraits>; using BlobRefPtr = RefPtr, BlobImplRefDerefTraits>; // TODO: Now that `bun.webcore.Blob` is ref-counted, can `RefPtr` be replaced with `Blob`? diff --git a/src/jsc/bindings/napi.cpp b/src/jsc/bindings/napi.cpp index 396f55991f9f..826427e8b7bc 100644 --- a/src/jsc/bindings/napi.cpp +++ b/src/jsc/bindings/napi.cpp @@ -261,32 +261,6 @@ napi_get_last_error_info(napi_env env, const napi_extended_error_info** result) return napi_ok; } -JSC::SourceCode generateSourceCode(WTF::String keyString, JSC::VM& vm, JSC::JSObject* object, JSC::JSGlobalObject* globalObject) -{ - JSC::JSArray* exportKeys = ownPropertyKeys(globalObject, object, PropertyNameMode::StringsAndSymbols, DontEnumPropertiesMode::Include); - JSC::Identifier ident = JSC::Identifier::fromString(vm, "__BunTemporaryGlobal"_s); - WTF::StringBuilder sourceCodeBuilder = WTF::StringBuilder(); - // TODO: handle symbol collision - sourceCodeBuilder.append("\nvar $$NativeModule = globalThis['__BunTemporaryGlobal']; console.log($$NativeModule); globalThis['__BunTemporaryGlobal'] = null;\n if (!$$NativeModule) { throw new Error('Assertion failure: Native module not found'); }\n\n"_s); - - for (unsigned i = 0; i < exportKeys->length(); i++) { - auto key = exportKeys->getIndexQuickly(i); - if (key.isSymbol()) { - continue; - } - auto named = key.toWTFString(globalObject); - sourceCodeBuilder.append(""_s); - // TODO: handle invalid identifiers - sourceCodeBuilder.append("export var "_s); - sourceCodeBuilder.append(named); - sourceCodeBuilder.append(" = $$NativeModule."_s); - sourceCodeBuilder.append(named); - sourceCodeBuilder.append(";\n"_s); - } - globalObject->putDirect(vm, ident, object, JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::DontEnum); - return JSC::makeSource(sourceCodeBuilder.toString(), JSC::SourceOrigin(), JSC::SourceTaintedOrigin::Untainted, keyString, WTF::TextPosition(), JSC::SourceProviderSourceType::Module); -} - void Napi::NapiRefWeakHandleOwner::finalize(JSC::Handle, void* context) { auto* weakValue = reinterpret_cast(context); diff --git a/src/jsc/bindings/napi.h b/src/jsc/bindings/napi.h index d1188a3aced0..f7896c847b73 100644 --- a/src/jsc/bindings/napi.h +++ b/src/jsc/bindings/napi.h @@ -648,15 +648,8 @@ struct NapiEnv : public WTF::RefCounted { extern "C" void napi_internal_cleanup_env_cpp(napi_env); extern "C" void napi_internal_remove_finalizer(napi_env, napi_finalize callback, void* hint, void* data); -namespace JSC { -class JSGlobalObject; -class JSSourceCode; -} - namespace Napi { -JSC::SourceCode generateSourceCode(WTF::String keyString, JSC::VM& vm, JSC::JSObject* object, JSC::JSGlobalObject* globalObject); - class NapiRefWeakHandleOwner final : public JSC::WeakHandleOwner { public: // Equivalent to v8impl::Ownership::kUserland @@ -723,11 +716,6 @@ class NapiWeakValue { void clear(); bool isClear() const; - bool isSet() const { return m_tag != WeakTypeTag::NotSet; } - bool isPrimitive() const { return m_tag == WeakTypeTag::Primitive; } - bool isCell() const { return m_tag == WeakTypeTag::Cell; } - bool isString() const { return m_tag == WeakTypeTag::String; } - void setPrimitive(JSValue); void setCell(JSCell*, WeakHandleOwner&, void* context); void setString(JSString*, WeakHandleOwner&, void* context); @@ -747,24 +735,6 @@ class NapiWeakValue { } } - JSCell* cell() const - { - ASSERT(isCell()); - return m_value.cell.get(); - } - - JSValue primitive() const - { - ASSERT(isPrimitive()); - return m_value.primitive; - } - - JSString* string() const - { - ASSERT(isString()); - return m_value.string.get(); - } - private: enum class WeakTypeTag { NotSet, Primitive, @@ -892,10 +862,6 @@ class NapiClass final : public JSC::JSFunction { static constexpr unsigned StructureFlags = Base::StructureFlags; static constexpr JSC::DestructionMode needsDestruction = DoesNotNeedDestruction; - static void destroy(JSCell* cell) - { - static_cast(cell)->NapiClass::~NapiClass(); - } template static JSC::GCClient::IsoSubspace* subspaceFor(JSC::VM& vm) { diff --git a/src/zlib/Cargo.toml b/src/zlib/Cargo.toml index f7e5369ed24d..ab97722c782d 100644 --- a/src/zlib/Cargo.toml +++ b/src/zlib/Cargo.toml @@ -10,7 +10,6 @@ path = "lib.rs" workspace = true [dependencies] -thiserror.workspace = true strum.workspace = true bstr.workspace = true scopeguard.workspace = true diff --git a/src/zlib/error.rs b/src/zlib/error.rs deleted file mode 100644 index 58cd3cb2f139..000000000000 --- a/src/zlib/error.rs +++ /dev/null @@ -1,31 +0,0 @@ -#[derive(Debug, Clone, Copy, PartialEq, Eq, thiserror::Error)] -pub enum Error { - #[error("ZlibError")] - ZlibError, - #[error("ShortRead")] - ShortRead, - #[error(transparent)] - Alloc(#[from] bun_alloc::AllocError), - #[error(transparent)] - Core(#[from] bun_core::Error), -} - -impl Error { - #[allow(clippy::trivially_copy_pass_by_ref)] - pub(crate) fn name(&self) -> &'static str { - match self { - Self::ZlibError => "ZlibError", - Self::ShortRead => "ShortRead", - Self::Alloc(_) => "OutOfMemory", - Self::Core(e) => e.name(), - } - } -} - -impl bun_core::output::ErrName for Error { - fn name(&self) -> &[u8] { - (*self).name().as_bytes() - } -} - -pub type Result = core::result::Result; diff --git a/src/zlib/lib.rs b/src/zlib/lib.rs index 465c05f5d609..86a254d3ceeb 100644 --- a/src/zlib/lib.rs +++ b/src/zlib/lib.rs @@ -1,8 +1,5 @@ // @link "deps/zlib/libz.a" -pub mod error; -pub use error::{Error, Result}; - use core::ffi::{c_char, c_int, c_uint, c_void}; use core::mem::size_of; @@ -38,8 +35,7 @@ unsafe extern "C" { ) -> c_int; } -#[allow(non_camel_case_types, unused_imports)] -pub use bun_zlib_sys::shared::{Byte, Bytef, gzFile, struct_gzFile_s, uInt, uLong, uLongf, voidpf}; +pub use bun_zlib_sys::shared::{Bytef, uInt, uLong, uLongf}; // typedef voidpf (*alloc_func) OF((voidpf opaque, uInt items, uInt size)); // typedef void (*free_func) OF((voidpf opaque, voidpf address));