From 5bd94b8f47efab5ca736e6ec76b72e991df1da11 Mon Sep 17 00:00:00 2001 From: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com> Date: Sun, 25 Jun 2023 11:43:54 -0700 Subject: Add `process.mainModule` --- src/bun.js/bindings/Process.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'src/bun.js/bindings/Process.cpp') diff --git a/src/bun.js/bindings/Process.cpp b/src/bun.js/bindings/Process.cpp index 69ee11e60..a369faee2 100644 --- a/src/bun.js/bindings/Process.cpp +++ b/src/bun.js/bindings/Process.cpp @@ -10,6 +10,7 @@ #include "ImportMetaObject.h" #include #include "ZigConsoleClient.h" +#include #pragma mark - Node.js Process namespace Zig { @@ -787,6 +788,17 @@ void Process::finishCreation(JSC::VM& vm) this->putDirectNativeFunction(vm, globalObject, JSC::Identifier::fromString(this->vm(), "emitWarning"_s), 1, Process_emitWarning, ImplementationVisibility::Public, NoIntrinsic, 0); + + JSC::JSFunction* requireDotMainFunction = JSFunction::create( + vm, + moduleMainCodeGenerator(vm), + globalObject->globalScope()); + // https://nodejs.org/api/process.html#processmainmodule + this->putDirect( + vm, + JSC::Identifier::fromString(vm, "mainModule"_s), + JSC::GetterSetter::create(vm, globalObject, requireDotMainFunction, JSValue()), + PropertyAttribute::Builtin | PropertyAttribute::Accessor | PropertyAttribute::ReadOnly | PropertyAttribute::DontEnum | 0); } const JSC::ClassInfo Process::s_info = { "Process"_s, &Base::s_info, nullptr, nullptr, -- cgit v1.2.3 From 1e6a41b5cfb405c8550969688a51aa702c5cec1a Mon Sep 17 00:00:00 2001 From: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com> Date: Mon, 26 Jun 2023 16:08:46 -0700 Subject: change the text from "error" to "warn" --- src/bun.js/bindings/Process.cpp | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'src/bun.js/bindings/Process.cpp') diff --git a/src/bun.js/bindings/Process.cpp b/src/bun.js/bindings/Process.cpp index a369faee2..6320deaf1 100644 --- a/src/bun.js/bindings/Process.cpp +++ b/src/bun.js/bindings/Process.cpp @@ -560,26 +560,28 @@ JSC_DEFINE_HOST_FUNCTION(Process_emitWarning, (JSGlobalObject * lexicalGlobalObj auto* process = jsCast(globalObject->processObject()); - auto getError = [&]() -> JSValue { + JSObject* errorInstance = ([&]() -> JSObject* { JSValue arg0 = callFrame->uncheckedArgument(0); if (!arg0.isEmpty() && arg0.isCell() && arg0.asCell()->type() == ErrorInstanceType) { - return arg0; + return arg0.getObject(); } WTF::String str = arg0.toWTFString(globalObject); return createError(globalObject, str); - }; + })(); + + errorInstance->putDirect(vm, Identifier::fromString(vm, "name"_s), jsString(vm, String("warn"_s)), JSC::PropertyAttribute::DontEnum | 0); auto ident = Identifier::fromString(vm, "warning"_s); if (process->wrapped().hasEventListeners(ident)) { JSC::MarkedArgumentBuffer args; - args.append(getError()); + args.append(errorInstance); process->wrapped().emit(ident, args); return JSValue::encode(jsUndefined()); } - auto jsArgs = JSValue::encode(getError()); + auto jsArgs = JSValue::encode(errorInstance); Zig__ConsoleClient__messageWithTypeAndLevel(reinterpret_cast(globalObject->consoleClient().get())->m_client, static_cast(MessageType::Log), static_cast(MessageLevel::Warning), globalObject, &jsArgs, 1); return JSValue::encode(jsUndefined()); -- cgit v1.2.3 From aa8b832ef61ada31176d248e716074ff22bb9dee Mon Sep 17 00:00:00 2001 From: Jarred Sumner Date: Sat, 8 Jul 2023 14:26:19 -0700 Subject: Implement `process.on("beforeExit", cb)` and `process.on("exit", cb)` (#3576) * Support `process.on('beforeExit')` and `process.on('exit')` * [bun:sqlite] Always call sqlite3_close on exit * Update process.test.js --------- Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com> --- src/bun.js/bindings/Process.cpp | 189 +++++++++++++++++---- src/bun.js/bindings/ZigGlobalObject.h | 2 + src/bun.js/bindings/sqlite/JSSQLStatement.cpp | 86 +++++++--- src/bun.js/bindings/sqlite/JSSQLStatement.h | 15 -- src/bun.js/javascript.zig | 50 ++++++ src/bun.js/node/types.zig | 4 +- src/bun_js.zig | 14 +- test/js/node/process/process-exit-fixture.js | 16 ++ test/js/node/process/process-exitCode-fixture.js | 7 + test/js/node/process/process-exitCode-with-exit.js | 8 + .../node/process/process-onBeforeExit-fixture.js | 7 + .../node/process/process-onBeforeExit-keepAlive.js | 18 ++ test/js/node/process/process.test.js | 64 ++++++- 13 files changed, 402 insertions(+), 78 deletions(-) create mode 100644 test/js/node/process/process-exit-fixture.js create mode 100644 test/js/node/process/process-exitCode-fixture.js create mode 100644 test/js/node/process/process-exitCode-with-exit.js create mode 100644 test/js/node/process/process-onBeforeExit-fixture.js create mode 100644 test/js/node/process/process-onBeforeExit-keepAlive.js (limited to 'src/bun.js/bindings/Process.cpp') diff --git a/src/bun.js/bindings/Process.cpp b/src/bun.js/bindings/Process.cpp index 6320deaf1..1d6b5d33a 100644 --- a/src/bun.js/bindings/Process.cpp +++ b/src/bun.js/bindings/Process.cpp @@ -42,6 +42,35 @@ static JSC_DECLARE_CUSTOM_GETTER(Process_getPID); static JSC_DECLARE_CUSTOM_GETTER(Process_getPPID); static JSC_DECLARE_HOST_FUNCTION(Process_functionCwd); +static bool processIsExiting = false; + +extern "C" uint8_t Bun__getExitCode(void*); +extern "C" uint8_t Bun__setExitCode(void*, uint8_t); +extern "C" void* Bun__getVM(); +extern "C" Zig::GlobalObject* Bun__getDefaultGlobal(); + +static void dispatchExitInternal(JSC::JSGlobalObject* globalObject, Process* process, int exitCode) +{ + + if (processIsExiting) + return; + processIsExiting = true; + auto& emitter = process->wrapped(); + auto& vm = globalObject->vm(); + + if (vm.hasTerminationRequest() || vm.hasExceptionsAfterHandlingTraps()) + return; + + auto event = Identifier::fromString(vm, "exit"_s); + if (!emitter.hasEventListeners(event)) { + return; + } + process->putDirect(vm, Identifier::fromString(vm, "_exiting"_s), jsBoolean(true), 0); + + MarkedArgumentBuffer arguments; + arguments.append(jsNumber(exitCode)); + emitter.emit(event, arguments); +} static JSValue constructStdioWriteStream(JSC::JSGlobalObject* globalObject, int fd) { @@ -324,6 +353,29 @@ JSC_DEFINE_HOST_FUNCTION(Process_functionUmask, extern "C" uint64_t Bun__readOriginTimer(void*); extern "C" double Bun__readOriginTimerStart(void*); +// https://github.com/nodejs/node/blob/1936160c31afc9780e4365de033789f39b7cbc0c/src/api/hooks.cc#L49 +extern "C" void Process__dispatchOnBeforeExit(Zig::GlobalObject* globalObject, uint8_t exitCode) +{ + if (!globalObject->hasProcessObject()) { + return; + } + + auto* process = jsCast(globalObject->processObject()); + MarkedArgumentBuffer arguments; + arguments.append(jsNumber(exitCode)); + process->wrapped().emit(Identifier::fromString(globalObject->vm(), "beforeExit"_s), arguments); +} + +extern "C" void Process__dispatchOnExit(Zig::GlobalObject* globalObject, uint8_t exitCode) +{ + if (!globalObject->hasProcessObject()) { + return; + } + + auto* process = jsCast(globalObject->processObject()); + dispatchExitInternal(globalObject, process, exitCode); +} + JSC_DEFINE_HOST_FUNCTION(Process_functionUptime, (JSC::JSGlobalObject * globalObject, JSC::CallFrame* callFrame)) { @@ -336,14 +388,38 @@ JSC_DEFINE_HOST_FUNCTION(Process_functionUptime, JSC_DEFINE_HOST_FUNCTION(Process_functionExit, (JSC::JSGlobalObject * globalObject, JSC::CallFrame* callFrame)) { - if (callFrame->argumentCount() == 0) { - // TODO: exitCode - Bun__Process__exit(globalObject, 0); + auto throwScope = DECLARE_THROW_SCOPE(globalObject->vm()); + uint8_t exitCode = 0; + JSValue arg0 = callFrame->argument(0); + if (arg0.isNumber()) { + if (!arg0.isInt32()) { + throwRangeError(globalObject, throwScope, "The \"code\" argument must be an integer"_s); + return JSC::JSValue::encode(JSC::JSValue {}); + } + + int extiCode32 = arg0.toInt32(globalObject); + RETURN_IF_EXCEPTION(throwScope, JSC::JSValue::encode(JSC::JSValue {})); + + if (extiCode32 < 0 || extiCode32 > 127) { + throwRangeError(globalObject, throwScope, "The \"code\" argument must be an integer between 0 and 127"_s); + return JSC::JSValue::encode(JSC::JSValue {}); + } + + exitCode = static_cast(extiCode32); + } else if (!arg0.isUndefinedOrNull()) { + throwTypeError(globalObject, throwScope, "The \"code\" argument must be an integer"_s); + return JSC::JSValue::encode(JSC::JSValue {}); } else { - Bun__Process__exit(globalObject, callFrame->argument(0).toInt32(globalObject)); + exitCode = Bun__getExitCode(Bun__getVM()); + } + + auto* zigGlobal = jsDynamicCast(globalObject); + if (UNLIKELY(!zigGlobal)) { + zigGlobal = Bun__getDefaultGlobal(); } - return JSC::JSValue::encode(JSC::jsUndefined()); + Process__dispatchOnExit(zigGlobal, exitCode); + Bun__Process__exit(zigGlobal, exitCode); } extern "C" uint64_t Bun__readOriginTimer(void*); @@ -391,18 +467,15 @@ JSC_DEFINE_HOST_FUNCTION(Process_functionHRTime, array->setIndexQuickly(vm, 1, JSC::jsNumber(nanoseconds)); return JSC::JSValue::encode(JSC::JSValue(array)); } -static JSC_DECLARE_HOST_FUNCTION(Process_functionHRTimeBigInt); -static JSC_DEFINE_HOST_FUNCTION(Process_functionHRTimeBigInt, +JSC_DEFINE_HOST_FUNCTION(Process_functionHRTimeBigInt, (JSC::JSGlobalObject * globalObject_, JSC::CallFrame* callFrame)) { Zig::GlobalObject* globalObject = reinterpret_cast(globalObject_); return JSC::JSValue::encode(JSValue(JSC::JSBigInt::createFrom(globalObject, Bun__readOriginTimer(globalObject->bunVM())))); } -static JSC_DECLARE_HOST_FUNCTION(Process_functionChdir); - -static JSC_DEFINE_HOST_FUNCTION(Process_functionChdir, +JSC_DEFINE_HOST_FUNCTION(Process_functionChdir, (JSC::JSGlobalObject * globalObject, JSC::CallFrame* callFrame)) { auto scope = DECLARE_THROW_SCOPE(globalObject->vm()); @@ -611,6 +684,46 @@ JSC_DEFINE_CUSTOM_GETTER(Process_lazyExecArgvGetter, (JSC::JSGlobalObject * glob return ret; } +JSC_DEFINE_CUSTOM_GETTER(Process__getExitCode, (JSC::JSGlobalObject * lexicalGlobalObject, JSC::EncodedJSValue thisValue, JSC::PropertyName name)) +{ + Process* process = jsDynamicCast(JSValue::decode(thisValue)); + if (!process) { + return JSValue::encode(jsUndefined()); + } + + return JSValue::encode(jsNumber(Bun__getExitCode(jsCast(process->globalObject())->bunVM()))); +} +JSC_DEFINE_CUSTOM_SETTER(Process__setExitCode, (JSC::JSGlobalObject * lexicalGlobalObject, JSC::EncodedJSValue thisValue, JSC::EncodedJSValue value, JSC::PropertyName)) +{ + Process* process = jsDynamicCast(JSValue::decode(thisValue)); + if (!process) { + return false; + } + + auto throwScope = DECLARE_THROW_SCOPE(process->vm()); + JSValue exitCode = JSValue::decode(value); + if (!exitCode.isNumber()) { + throwTypeError(lexicalGlobalObject, throwScope, "exitCode must be a number"_s); + return false; + } + + if (!exitCode.isInt32()) { + throwRangeError(lexicalGlobalObject, throwScope, "The \"code\" argument must be an integer"_s); + return JSC::JSValue::encode(JSC::JSValue {}); + } + + int exitCodeInt = exitCode.toInt32(lexicalGlobalObject); + RETURN_IF_EXCEPTION(throwScope, false); + if (exitCodeInt < 0 || exitCodeInt > 127) { + throwRangeError(lexicalGlobalObject, throwScope, "exitCode must be between 0 and 127"_s); + return false; + } + + void* ptr = jsCast(process->globalObject())->bunVM(); + Bun__setExitCode(ptr, static_cast(exitCodeInt)); + return true; +} + JSC_DEFINE_CUSTOM_GETTER(Process_lazyExecPathGetter, (JSC::JSGlobalObject * globalObject, JSC::EncodedJSValue thisValue, JSC::PropertyName name)) { JSC::JSObject* thisObject = JSValue::decode(thisValue).getObject(); @@ -677,39 +790,42 @@ void Process::finishCreation(JSC::VM& vm) vm, clientData->builtinNames().versionsPublicName(), JSC::CustomGetterSetter::create(vm, Process_getVersionsLazy, Process_setVersionsLazy), 0); // this should be transpiled out, but just incase - this->putDirect(this->vm(), JSC::Identifier::fromString(this->vm(), "browser"_s), - JSC::JSValue(false)); + this->putDirect(vm, JSC::Identifier::fromString(vm, "browser"_s), + JSC::JSValue(false), PropertyAttribute::DontEnum | 0); - this->putDirect(this->vm(), JSC::Identifier::fromString(this->vm(), "exitCode"_s), - JSC::JSValue(JSC::jsNumber(0))); + this->putDirectCustomAccessor(vm, JSC::Identifier::fromString(vm, "exitCode"_s), + JSC::CustomGetterSetter::create(vm, + Process__getExitCode, + Process__setExitCode), + 0); - this->putDirect(this->vm(), clientData->builtinNames().versionPublicName(), - JSC::jsString(this->vm(), makeString("v", REPORTED_NODE_VERSION))); + this->putDirect(vm, clientData->builtinNames().versionPublicName(), + JSC::jsString(vm, makeString("v", REPORTED_NODE_VERSION))); // this gives some way of identifying at runtime whether the SSR is happening in node or not. // this should probably be renamed to what the name of the bundler is, instead of "notNodeJS" // but it must be something that won't evaluate to truthy in Node.js - this->putDirect(this->vm(), JSC::Identifier::fromString(this->vm(), "isBun"_s), JSC::JSValue(true)); + this->putDirect(vm, JSC::Identifier::fromString(vm, "isBun"_s), JSC::JSValue(true)); #if defined(__APPLE__) - this->putDirect(this->vm(), JSC::Identifier::fromString(this->vm(), "platform"_s), - JSC::jsString(this->vm(), makeAtomString("darwin"))); + this->putDirect(vm, JSC::Identifier::fromString(vm, "platform"_s), + JSC::jsString(vm, makeAtomString("darwin"))); #else - this->putDirect(this->vm(), JSC::Identifier::fromString(this->vm(), "platform"_s), - JSC::jsString(this->vm(), makeAtomString("linux"))); + this->putDirect(vm, JSC::Identifier::fromString(vm, "platform"_s), + JSC::jsString(vm, makeAtomString("linux"))); #endif #if defined(__x86_64__) - this->putDirect(this->vm(), JSC::Identifier::fromString(this->vm(), "arch"_s), - JSC::jsString(this->vm(), makeAtomString("x64"))); + this->putDirect(vm, JSC::Identifier::fromString(vm, "arch"_s), + JSC::jsString(vm, makeAtomString("x64"))); #elif defined(__i386__) - this->putDirect(this->vm(), JSC::Identifier::fromString(this->vm(), "arch"_s), - JSC::jsString(this->vm(), makeAtomString("x86"))); + this->putDirect(vm, JSC::Identifier::fromString(vm, "arch"_s), + JSC::jsString(vm, makeAtomString("x86"))); #elif defined(__arm__) - this->putDirect(this->vm(), JSC::Identifier::fromString(this->vm(), "arch"_s), - JSC::jsString(this->vm(), makeAtomString("arm"))); + this->putDirect(vm, JSC::Identifier::fromString(vm, "arch"_s), + JSC::jsString(vm, makeAtomString("arm"))); #elif defined(__aarch64__) - this->putDirect(this->vm(), JSC::Identifier::fromString(this->vm(), "arch"_s), - JSC::jsString(this->vm(), makeAtomString("arm64"))); + this->putDirect(vm, JSC::Identifier::fromString(vm, "arch"_s), + JSC::jsString(vm, makeAtomString("arm64"))); #endif JSC::JSFunction* hrtime = JSC::JSFunction::create(vm, globalObject, 0, @@ -719,7 +835,7 @@ void Process::finishCreation(JSC::VM& vm) MAKE_STATIC_STRING_IMPL("bigint"), Process_functionHRTimeBigInt, ImplementationVisibility::Public); hrtime->putDirect(vm, JSC::Identifier::fromString(vm, "bigint"_s), hrtimeBigInt); - this->putDirect(this->vm(), JSC::Identifier::fromString(this->vm(), "hrtime"_s), hrtime); + this->putDirect(vm, JSC::Identifier::fromString(vm, "hrtime"_s), hrtime); this->putDirectCustomAccessor(vm, JSC::PropertyName(JSC::Identifier::fromString(vm, "release"_s)), JSC::CustomGetterSetter::create(vm, Process_getterRelease, Process_setterRelease), 0); @@ -733,7 +849,10 @@ void Process::finishCreation(JSC::VM& vm) this->putDirectCustomAccessor(vm, JSC::PropertyName(JSC::Identifier::fromString(vm, "stdin"_s)), JSC::CustomGetterSetter::create(vm, Process_lazyStdinGetter, Process_defaultSetter), 0); - this->putDirectNativeFunction(vm, globalObject, JSC::Identifier::fromString(this->vm(), "abort"_s), + this->putDirectNativeFunction(vm, globalObject, JSC::Identifier::fromString(vm, "abort"_s), + 0, Process_functionAbort, ImplementationVisibility::Public, NoIntrinsic, 0); + + this->putDirectNativeFunction(vm, globalObject, JSC::Identifier::fromString(vm, "abort"_s), 0, Process_functionAbort, ImplementationVisibility::Public, NoIntrinsic, 0); this->putDirectCustomAccessor(vm, JSC::PropertyName(JSC::Identifier::fromString(vm, "argv0"_s)), @@ -745,13 +864,13 @@ void Process::finishCreation(JSC::VM& vm) this->putDirectCustomAccessor(vm, JSC::PropertyName(JSC::Identifier::fromString(vm, "execArgv"_s)), JSC::CustomGetterSetter::create(vm, Process_lazyExecArgvGetter, Process_defaultSetter), 0); - this->putDirectNativeFunction(vm, globalObject, JSC::Identifier::fromString(this->vm(), "uptime"_s), + this->putDirectNativeFunction(vm, globalObject, JSC::Identifier::fromString(vm, "uptime"_s), 0, Process_functionUptime, ImplementationVisibility::Public, NoIntrinsic, 0); - this->putDirectNativeFunction(vm, globalObject, JSC::Identifier::fromString(this->vm(), "umask"_s), + this->putDirectNativeFunction(vm, globalObject, JSC::Identifier::fromString(vm, "umask"_s), 1, Process_functionUmask, ImplementationVisibility::Public, NoIntrinsic, 0); - this->putDirectBuiltinFunction(vm, globalObject, JSC::Identifier::fromString(this->vm(), "binding"_s), + this->putDirectBuiltinFunction(vm, globalObject, JSC::Identifier::fromString(vm, "binding"_s), processObjectInternalsBindingCodeGenerator(vm), 0); @@ -788,7 +907,7 @@ void Process::finishCreation(JSC::VM& vm) config->putDirect(vm, JSC::Identifier::fromString(vm, "variables"_s), variables, 0); this->putDirect(vm, JSC::Identifier::fromString(vm, "config"_s), config, 0); - this->putDirectNativeFunction(vm, globalObject, JSC::Identifier::fromString(this->vm(), "emitWarning"_s), + this->putDirectNativeFunction(vm, globalObject, JSC::Identifier::fromString(vm, "emitWarning"_s), 1, Process_emitWarning, ImplementationVisibility::Public, NoIntrinsic, 0); JSC::JSFunction* requireDotMainFunction = JSFunction::create( diff --git a/src/bun.js/bindings/ZigGlobalObject.h b/src/bun.js/bindings/ZigGlobalObject.h index da6ba92a0..f44212da1 100644 --- a/src/bun.js/bindings/ZigGlobalObject.h +++ b/src/bun.js/bindings/ZigGlobalObject.h @@ -270,6 +270,8 @@ public: JSWeakMap* vmModuleContextMap() { return m_vmModuleContextMap.getInitializedOnMainThread(this); } + bool hasProcessObject() const { return m_processObject.isInitialized(); } + JSC::JSObject* processObject() { return m_processObject.getInitializedOnMainThread(this); diff --git a/src/bun.js/bindings/sqlite/JSSQLStatement.cpp b/src/bun.js/bindings/sqlite/JSSQLStatement.cpp index a6855fd19..61ac91ba7 100644 --- a/src/bun.js/bindings/sqlite/JSSQLStatement.cpp +++ b/src/bun.js/bindings/sqlite/JSSQLStatement.cpp @@ -107,6 +107,50 @@ static JSC_DECLARE_HOST_FUNCTION(jsSQLStatementDeserialize); return JSValue::encode(jsUndefined()); \ } +class VersionSqlite3 { +public: + explicit VersionSqlite3(sqlite3* db) + : db(db) + , version(0) + { + } + sqlite3* db; + std::atomic version; +}; + +class SQLiteSingleton { +public: + Vector databases; + Vector> schema_versions; +}; + +static SQLiteSingleton* _instance = nullptr; + +static Vector& databases() +{ + if (!_instance) { + _instance = new SQLiteSingleton(); + _instance->databases = Vector(); + _instance->databases.reserveInitialCapacity(4); + _instance->schema_versions = Vector>(); + } + + return _instance->databases; +} + +extern "C" void Bun__closeAllSQLiteDatabasesForTermination() +{ + if (!_instance) { + return; + } + auto& dbs = _instance->databases; + + for (auto& db : dbs) { + if (db->db) + sqlite3_close_v2(db->db); + } +} + namespace WebCore { using namespace JSC; @@ -272,10 +316,6 @@ void JSSQLStatement::destroy(JSC::JSCell* cell) void JSSQLStatementConstructor::destroy(JSC::JSCell* cell) { - JSSQLStatementConstructor* thisObject = static_cast(cell); - for (auto version_db : thisObject->databases) { - delete version_db; - } } static inline bool rebindValue(JSC::JSGlobalObject* lexicalGlobalObject, sqlite3_stmt* stmt, int i, JSC::JSValue value, JSC::ThrowScope& scope, bool clone) @@ -547,8 +587,8 @@ JSC_DEFINE_HOST_FUNCTION(jsSQLStatementDeserialize, (JSC::JSGlobalObject * lexic return JSValue::encode(JSC::jsUndefined()); } - auto count = thisObject->databases.size(); - thisObject->databases.append(new VersionSqlite3(db)); + auto count = databases().size(); + databases().append(new VersionSqlite3(db)); RELEASE_AND_RETURN(scope, JSValue::encode(jsNumber(count))); } @@ -565,12 +605,12 @@ JSC_DEFINE_HOST_FUNCTION(jsSQLStatementSerialize, (JSC::JSGlobalObject * lexical } int32_t dbIndex = callFrame->argument(0).toInt32(lexicalGlobalObject); - if (UNLIKELY(dbIndex < 0 || dbIndex >= thisObject->databases.size())) { + if (UNLIKELY(dbIndex < 0 || dbIndex >= databases().size())) { throwException(lexicalGlobalObject, scope, createError(lexicalGlobalObject, "Invalid database handle"_s)); return JSValue::encode(JSC::jsUndefined()); } - sqlite3* db = thisObject->databases[dbIndex]->db; + sqlite3* db = databases()[dbIndex]->db; if (UNLIKELY(!db)) { throwException(lexicalGlobalObject, scope, createError(lexicalGlobalObject, "Can't do this on a closed database"_s)); return JSValue::encode(JSC::jsUndefined()); @@ -606,7 +646,7 @@ JSC_DEFINE_HOST_FUNCTION(jsSQLStatementLoadExtensionFunction, (JSC::JSGlobalObje } int32_t dbIndex = callFrame->argument(0).toInt32(lexicalGlobalObject); - if (UNLIKELY(dbIndex < 0 || dbIndex >= thisObject->databases.size())) { + if (UNLIKELY(dbIndex < 0 || dbIndex >= databases().size())) { throwException(lexicalGlobalObject, scope, createError(lexicalGlobalObject, "Invalid database handle"_s)); return JSValue::encode(JSC::jsUndefined()); } @@ -620,7 +660,7 @@ JSC_DEFINE_HOST_FUNCTION(jsSQLStatementLoadExtensionFunction, (JSC::JSGlobalObje auto extensionString = extension.toWTFString(lexicalGlobalObject); RETURN_IF_EXCEPTION(scope, {}); - sqlite3* db = thisObject->databases[dbIndex]->db; + sqlite3* db = databases()[dbIndex]->db; if (UNLIKELY(!db)) { throwException(lexicalGlobalObject, scope, createError(lexicalGlobalObject, "Can't do this on a closed database"_s)); return JSValue::encode(JSC::jsUndefined()); @@ -661,11 +701,11 @@ JSC_DEFINE_HOST_FUNCTION(jsSQLStatementExecuteFunction, (JSC::JSGlobalObject * l } int32_t handle = callFrame->argument(0).toInt32(lexicalGlobalObject); - if (thisObject->databases.size() < handle) { + if (databases().size() < handle) { throwException(lexicalGlobalObject, scope, createError(lexicalGlobalObject, "Invalid database handle"_s)); return JSValue::encode(JSC::jsUndefined()); } - sqlite3* db = thisObject->databases[handle]->db; + sqlite3* db = databases()[handle]->db; if (UNLIKELY(!db)) { throwException(lexicalGlobalObject, scope, createError(lexicalGlobalObject, "Database has closed"_s)); @@ -724,7 +764,7 @@ JSC_DEFINE_HOST_FUNCTION(jsSQLStatementExecuteFunction, (JSC::JSGlobalObject * l rc = sqlite3_step(statement); if (!sqlite3_stmt_readonly(statement)) { - thisObject->databases[handle]->version++; + databases()[handle]->version++; } while (rc == SQLITE_ROW) { @@ -765,12 +805,12 @@ JSC_DEFINE_HOST_FUNCTION(jsSQLStatementIsInTransactionFunction, (JSC::JSGlobalOb int32_t handle = dbNumber.toInt32(lexicalGlobalObject); - if (handle < 0 || handle > thisObject->databases.size()) { + if (handle < 0 || handle > databases().size()) { throwException(lexicalGlobalObject, scope, createRangeError(lexicalGlobalObject, "Invalid database handle"_s)); return JSValue::encode(JSC::jsUndefined()); } - sqlite3* db = thisObject->databases[handle]->db; + sqlite3* db = databases()[handle]->db; if (UNLIKELY(!db)) { throwException(lexicalGlobalObject, scope, createError(lexicalGlobalObject, "Database has closed"_s)); @@ -803,12 +843,12 @@ JSC_DEFINE_HOST_FUNCTION(jsSQLStatementPrepareStatementFunction, (JSC::JSGlobalO } int32_t handle = dbNumber.toInt32(lexicalGlobalObject); - if (handle < 0 || handle > thisObject->databases.size()) { + if (handle < 0 || handle > databases().size()) { throwException(lexicalGlobalObject, scope, createRangeError(lexicalGlobalObject, "Invalid database handle"_s)); return JSValue::encode(JSC::jsUndefined()); } - sqlite3* db = thisObject->databases[handle]->db; + sqlite3* db = databases()[handle]->db; if (!db) { throwException(lexicalGlobalObject, scope, createRangeError(lexicalGlobalObject, "Cannot use a closed database"_s)); return JSValue::encode(JSC::jsUndefined()); @@ -848,7 +888,7 @@ JSC_DEFINE_HOST_FUNCTION(jsSQLStatementPrepareStatementFunction, (JSC::JSGlobalO auto* structure = JSSQLStatement::createStructure(vm, lexicalGlobalObject, lexicalGlobalObject->objectPrototype()); // auto* structure = JSSQLStatement::createStructure(vm, globalObject(), thisObject->getDirect(vm, vm.propertyNames->prototype)); JSSQLStatement* sqlStatement = JSSQLStatement::create( - structure, reinterpret_cast(lexicalGlobalObject), statement, thisObject->databases[handle]); + structure, reinterpret_cast(lexicalGlobalObject), statement, databases()[handle]); if (bindings.isObject()) { auto* castedThis = sqlStatement; DO_REBIND(bindings) @@ -924,8 +964,8 @@ JSC_DEFINE_HOST_FUNCTION(jsSQLStatementOpenStatementFunction, (JSC::JSGlobalObje status = sqlite3_db_config(db, SQLITE_DBCONFIG_DEFENSIVE, 1, NULL); assert(status == SQLITE_OK); - auto count = constructor->databases.size(); - constructor->databases.append(new VersionSqlite3(db)); + auto count = databases().size(); + databases().append(new VersionSqlite3(db)); RELEASE_AND_RETURN(scope, JSValue::encode(jsNumber(count))); } @@ -956,12 +996,12 @@ JSC_DEFINE_HOST_FUNCTION(jsSQLStatementCloseStatementFunction, (JSC::JSGlobalObj int dbIndex = dbNumber.toInt32(lexicalGlobalObject); - if (dbIndex < 0 || dbIndex >= constructor->databases.size()) { + if (dbIndex < 0 || dbIndex >= databases().size()) { throwException(lexicalGlobalObject, scope, createError(lexicalGlobalObject, "Invalid database handle"_s)); return JSValue::encode(jsUndefined()); } - sqlite3* db = constructor->databases[dbIndex]->db; + sqlite3* db = databases()[dbIndex]->db; // no-op if already closed if (!db) { return JSValue::encode(jsUndefined()); @@ -973,7 +1013,7 @@ JSC_DEFINE_HOST_FUNCTION(jsSQLStatementCloseStatementFunction, (JSC::JSGlobalObj return JSValue::encode(jsUndefined()); } - constructor->databases[dbIndex]->db = nullptr; + databases()[dbIndex]->db = nullptr; return JSValue::encode(jsUndefined()); } diff --git a/src/bun.js/bindings/sqlite/JSSQLStatement.h b/src/bun.js/bindings/sqlite/JSSQLStatement.h index e63b99fbb..8566fcdd9 100644 --- a/src/bun.js/bindings/sqlite/JSSQLStatement.h +++ b/src/bun.js/bindings/sqlite/JSSQLStatement.h @@ -47,17 +47,6 @@ namespace WebCore { -class VersionSqlite3 { -public: - explicit VersionSqlite3(sqlite3* db) - : db(db) - , version(0) - { - } - sqlite3* db; - std::atomic version; -}; - class JSSQLStatementConstructor final : public JSC::JSFunction { public: using Base = JSC::JSFunction; @@ -82,13 +71,9 @@ public: return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), info()); } - Vector databases; - Vector> schema_versions; - private: JSSQLStatementConstructor(JSC::VM& vm, NativeExecutable* native, JSGlobalObject* globalObject, JSC::Structure* structure) : Base(vm, native, globalObject, structure) - , databases() { } diff --git a/src/bun.js/javascript.zig b/src/bun.js/javascript.zig index b696c6cf2..7d2435823 100644 --- a/src/bun.js/javascript.zig +++ b/src/bun.js/javascript.zig @@ -334,6 +334,33 @@ pub export fn Bun__onDidAppendPlugin(jsc_vm: *VirtualMachine, globalObject: *JSG jsc_vm.bundler.linker.plugin_runner = &jsc_vm.plugin_runner.?; } +pub const ExitHandler = struct { + exit_code: u8 = 0, + + pub export fn Bun__getExitCode(vm: *VirtualMachine) u8 { + return vm.exit_handler.exit_code; + } + + pub export fn Bun__setExitCode(vm: *VirtualMachine, code: u8) void { + vm.exit_handler.exit_code = code; + } + + extern fn Process__dispatchOnBeforeExit(*JSC.JSGlobalObject, code: u8) void; + extern fn Process__dispatchOnExit(*JSC.JSGlobalObject, code: u8) void; + extern fn Bun__closeAllSQLiteDatabasesForTermination() void; + + pub fn dispatchOnExit(this: *ExitHandler) void { + var vm = @fieldParentPtr(VirtualMachine, "exit_handler", this); + Process__dispatchOnExit(vm.global, this.exit_code); + Bun__closeAllSQLiteDatabasesForTermination(); + } + + pub fn dispatchOnBeforeExit(this: *ExitHandler) void { + var vm = @fieldParentPtr(VirtualMachine, "exit_handler", this); + Process__dispatchOnBeforeExit(vm.global, this.exit_code); + } +}; + /// TODO: rename this to ScriptExecutionContext /// This is the shared global state for a single JS instance execution /// Today, Bun is one VM per thread, so the name "VirtualMachine" sort of makes sense @@ -376,6 +403,7 @@ pub const VirtualMachine = struct { plugin_runner: ?PluginRunner = null, is_main_thread: bool = false, last_reported_error_for_dedupe: JSValue = .zero, + exit_handler: ExitHandler = .{}, /// Do not access this field directly /// It exists in the VirtualMachine struct so that @@ -620,7 +648,29 @@ pub const VirtualMachine = struct { loop.run(); } + pub fn onBeforeExit(this: *VirtualMachine) void { + this.exit_handler.dispatchOnBeforeExit(); + var dispatch = false; + while (true) { + while (this.eventLoop().tasks.count > 0 or this.active_tasks > 0 or this.uws_event_loop.?.active > 0) : (dispatch = true) { + this.tick(); + this.eventLoop().autoTickActive(); + } + + if (dispatch) { + this.exit_handler.dispatchOnBeforeExit(); + dispatch = false; + + if (this.eventLoop().tasks.count > 0 or this.active_tasks > 0 or this.uws_event_loop.?.active > 0) continue; + } + + break; + } + } + pub fn onExit(this: *VirtualMachine) void { + this.exit_handler.dispatchOnExit(); + var rare_data = this.rare_data orelse return; var hook = rare_data.cleanup_hook orelse return; hook.execute(); diff --git a/src/bun.js/node/types.zig b/src/bun.js/node/types.zig index 96d04636e..553b292d6 100644 --- a/src/bun.js/node/types.zig +++ b/src/bun.js/node/types.zig @@ -2202,7 +2202,9 @@ pub const Process = struct { } } - pub fn exit(_: *JSC.JSGlobalObject, code: i32) callconv(.C) void { + pub fn exit(globalObject: *JSC.JSGlobalObject, code: i32) callconv(.C) void { + globalObject.bunVM().onExit(); + std.os.exit(@truncate(u8, @intCast(u32, @max(code, 0)))); } diff --git a/src/bun_js.zig b/src/bun_js.zig index 63ffe0611..72b7f8de9 100644 --- a/src/bun_js.zig +++ b/src/bun_js.zig @@ -248,6 +248,8 @@ pub const Run = struct { vm.eventLoop().tick(); vm.eventLoop().tickPossiblyForever(); } else { + vm.exit_handler.exit_code = 1; + vm.onExit(); Global.exit(1); } } @@ -279,6 +281,8 @@ pub const Run = struct { vm.eventLoop().tick(); vm.eventLoop().tickPossiblyForever(); } else { + vm.exit_handler.exit_code = 1; + vm.onExit(); Global.exit(1); } } @@ -315,6 +319,8 @@ pub const Run = struct { vm.eventLoop().autoTickActive(); } + vm.onBeforeExit(); + if (this.vm.pending_internal_promise.status(vm.global.vm()) == .Rejected and prev_promise != this.vm.pending_internal_promise) { prev_promise = this.vm.pending_internal_promise; vm.onUnhandledError(this.vm.global, this.vm.pending_internal_promise.result(vm.global.vm())); @@ -332,6 +338,8 @@ pub const Run = struct { vm.tick(); vm.eventLoop().autoTickActive(); } + + vm.onBeforeExit(); } if (vm.log.msgs.items.len > 0) { @@ -347,10 +355,14 @@ pub const Run = struct { vm.onUnhandledRejection = &onUnhandledRejectionBeforeClose; vm.global.handleRejectedPromises(); + if (this.any_unhandled and this.vm.exit_handler.exit_code == 0) { + this.vm.exit_handler.exit_code = 1; + } + const exit_code = this.vm.exit_handler.exit_code; vm.onExit(); if (!JSC.is_bindgen) JSC.napi.fixDeadCodeElimination(); - Global.exit(@intFromBool(this.any_unhandled)); + Global.exit(exit_code); } }; diff --git a/test/js/node/process/process-exit-fixture.js b/test/js/node/process/process-exit-fixture.js new file mode 100644 index 000000000..c5a492285 --- /dev/null +++ b/test/js/node/process/process-exit-fixture.js @@ -0,0 +1,16 @@ +process.on("beforeExit", () => { + throw new Error("process.on('beforeExit') called"); +}); + +if (process._exiting) { + throw new Error("process._exiting should be undefined"); +} + +process.on("exit", () => { + if (!process._exiting) { + throw new Error("process.on('exit') called with process._exiting false"); + } + console.log("PASS"); +}); + +process.exit(0); diff --git a/test/js/node/process/process-exitCode-fixture.js b/test/js/node/process/process-exitCode-fixture.js new file mode 100644 index 000000000..2d5182d93 --- /dev/null +++ b/test/js/node/process/process-exitCode-fixture.js @@ -0,0 +1,7 @@ +process.exitCode = Number(process.argv.at(-1)); +process.on("exit", code => { + if (code !== process.exitCode) { + throw new Error("process.exitCode should be " + process.exitCode); + } + console.log("PASS"); +}); diff --git a/test/js/node/process/process-exitCode-with-exit.js b/test/js/node/process/process-exitCode-with-exit.js new file mode 100644 index 000000000..610975bc2 --- /dev/null +++ b/test/js/node/process/process-exitCode-with-exit.js @@ -0,0 +1,8 @@ +process.exitCode = Number(process.argv.at(-1)); +process.on("exit", code => { + if (code !== process.exitCode) { + throw new Error("process.exitCode should be " + process.exitCode); + } + console.log("PASS"); +}); +process.exit(); diff --git a/test/js/node/process/process-onBeforeExit-fixture.js b/test/js/node/process/process-onBeforeExit-fixture.js new file mode 100644 index 000000000..8cbdcebf0 --- /dev/null +++ b/test/js/node/process/process-onBeforeExit-fixture.js @@ -0,0 +1,7 @@ +process.on("beforeExit", () => { + console.log("beforeExit"); +}); + +process.on("exit", () => { + console.log("exit"); +}); diff --git a/test/js/node/process/process-onBeforeExit-keepAlive.js b/test/js/node/process/process-onBeforeExit-keepAlive.js new file mode 100644 index 000000000..45b20b763 --- /dev/null +++ b/test/js/node/process/process-onBeforeExit-keepAlive.js @@ -0,0 +1,18 @@ +let counter = 0; +process.on("beforeExit", () => { + if (process._exiting) { + throw new Error("process._exiting should be undefined"); + } + + console.log("beforeExit:", counter); + if (!counter++) { + setTimeout(() => {}, 1); + } +}); + +process.on("exit", () => { + if (!process._exiting) { + throw new Error("process.on('exit') called with process._exiting false"); + } + console.log("exit:", counter); +}); diff --git a/test/js/node/process/process.test.js b/test/js/node/process/process.test.js index 61ac3839c..c4701f664 100644 --- a/test/js/node/process/process.test.js +++ b/test/js/node/process/process.test.js @@ -1,8 +1,8 @@ -import { resolveSync, which } from "bun"; +import { resolveSync, spawnSync, which } from "bun"; import { describe, expect, it } from "bun:test"; import { existsSync, readFileSync, realpathSync } from "fs"; -import { bunExe } from "harness"; -import { basename, resolve } from "path"; +import { bunEnv, bunExe } from "harness"; +import { basename, join, resolve } from "path"; it("process", () => { // this property isn't implemented yet but it should at least return a string @@ -233,3 +233,61 @@ it("process.argv in testing", () => { // assert we aren't creating a new process.argv each call expect(process.argv).toBe(process.argv); }); + +describe("process.exitCode", () => { + it("validates int", () => { + expect(() => (process.exitCode = "potato")).toThrow("exitCode must be a number"); + expect(() => (process.exitCode = 1.2)).toThrow('The "code" argument must be an integer'); + expect(() => (process.exitCode = NaN)).toThrow('The "code" argument must be an integer'); + expect(() => (process.exitCode = Infinity)).toThrow('The "code" argument must be an integer'); + expect(() => (process.exitCode = -Infinity)).toThrow('The "code" argument must be an integer'); + expect(() => (process.exitCode = -1)).toThrow("exitCode must be between 0 and 127"); + }); + + it("works with implicit process.exit", () => { + const { exitCode, stdout } = spawnSync({ + cmd: [bunExe(), join(import.meta.dir, "process-exitCode-with-exit.js"), "42"], + env: bunEnv, + }); + expect(exitCode).toBe(42); + expect(stdout.toString().trim()).toBe("PASS"); + }); + + it("works with explicit process.exit", () => { + const { exitCode, stdout } = spawnSync({ + cmd: [bunExe(), join(import.meta.dir, "process-exitCode-fixture.js"), "42"], + env: bunEnv, + }); + expect(exitCode).toBe(42); + expect(stdout.toString().trim()).toBe("PASS"); + }); +}); + +it("process.exit", () => { + const { exitCode, stdout } = spawnSync({ + cmd: [bunExe(), join(import.meta.dir, "process-exit-fixture.js")], + env: bunEnv, + }); + expect(exitCode).toBe(0); + expect(stdout.toString().trim()).toBe("PASS"); +}); + +describe("process.onBeforeExit", () => { + it("emitted", () => { + const { exitCode, stdout } = spawnSync({ + cmd: [bunExe(), join(import.meta.dir, "process-onBeforeExit-fixture.js")], + env: bunEnv, + }); + expect(exitCode).toBe(0); + expect(stdout.toString().trim()).toBe("beforeExit\nexit"); + }); + + it("works with explicit process.exit", () => { + const { exitCode, stdout } = spawnSync({ + cmd: [bunExe(), join(import.meta.dir, "process-onBeforeExit-keepAlive.js")], + env: bunEnv, + }); + expect(exitCode).toBe(0); + expect(stdout.toString().trim()).toBe("beforeExit: 0\nbeforeExit: 1\nexit: 2"); + }); +}); -- cgit v1.2.3 From ca42c820d29400d8bd93f493064db029f6d4420d Mon Sep 17 00:00:00 2001 From: Jarred Sumner Date: Sun, 9 Jul 2023 16:33:49 -0700 Subject: Implement nearly all of `process` object methods and properties (#3581) * Add special case * Make process object load faster * Fix openStdin --------- Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com> --- src/bun.js/bindings/CommonJSModuleRecord.cpp | 6 + src/bun.js/bindings/Process.cpp | 960 +++++++++++++++------------ src/bun.js/bindings/Process.h | 2 +- src/bun.js/bindings/Process.lut.h | 208 ++++++ src/bun.js/bindings/ZigGlobalObject.cpp | 6 +- src/bun.js/modules/ProcessModule.h | 8 + src/js/builtins/ProcessObjectInternals.ts | 22 +- src/js/builtins/codegen/index.ts | 30 + src/js/out/WebCoreJSBuiltins.cpp | 16 +- src/js/out/WebCoreJSBuiltins.h | 4 +- 10 files changed, 812 insertions(+), 450 deletions(-) create mode 100644 src/bun.js/bindings/Process.lut.h (limited to 'src/bun.js/bindings/Process.cpp') diff --git a/src/bun.js/bindings/CommonJSModuleRecord.cpp b/src/bun.js/bindings/CommonJSModuleRecord.cpp index c7dac89c2..8adba197c 100644 --- a/src/bun.js/bindings/CommonJSModuleRecord.cpp +++ b/src/bun.js/bindings/CommonJSModuleRecord.cpp @@ -817,6 +817,12 @@ JSC_DEFINE_HOST_FUNCTION(jsFunctionRequireCommonJS, (JSGlobalObject * lexicalGlo WTF::String specifier = specifierValue.toWTFString(globalObject); RETURN_IF_EXCEPTION(throwScope, {}); + // Special-case for "process" to just return the process object directly. + if (UNLIKELY(specifier == "process"_s || specifier == "node:process"_s)) { + jsDynamicCast(callframe->argument(1))->putDirect(vm, builtinNames(vm).exportsPublicName(), globalObject->processObject(), 0); + return JSValue::encode(globalObject->processObject()); + } + WTF::String referrer = thisObject->id().toWTFString(globalObject); RETURN_IF_EXCEPTION(throwScope, {}); diff --git a/src/bun.js/bindings/Process.cpp b/src/bun.js/bindings/Process.cpp index 1d6b5d33a..8d94594cc 100644 --- a/src/bun.js/bindings/Process.cpp +++ b/src/bun.js/bindings/Process.cpp @@ -11,13 +11,24 @@ #include #include "ZigConsoleClient.h" #include +#include #pragma mark - Node.js Process +#if !defined(_MSC_VER) +#include // setuid, getuid +#endif + namespace Zig { using namespace JSC; #define REPORTED_NODE_VERSION "18.15.0" +#define processObjectBindingCodeGenerator processObjectInternalsBindingCodeGenerator +#define processObjectMainModuleCodeGenerator moduleMainCodeGenerator + +#if !defined(BUN_WEBKIT_VERSION) +#define BUN_WEBKIT_VERSION "unknown" +#endif using JSGlobalObject = JSC::JSGlobalObject; using Exception = JSC::Exception; @@ -31,23 +42,20 @@ using JSObject = JSC::JSObject; using JSNonFinalObject = JSC::JSNonFinalObject; namespace JSCastingHelpers = JSC::JSCastingHelpers; -static JSC_DECLARE_CUSTOM_SETTER(Process_setTitle); -static JSC_DECLARE_CUSTOM_GETTER(Process_getArgv); -static JSC_DECLARE_CUSTOM_SETTER(Process_setArgv); -static JSC_DECLARE_CUSTOM_GETTER(Process_getTitle); -static JSC_DECLARE_CUSTOM_GETTER(Process_getVersionsLazy); -static JSC_DECLARE_CUSTOM_SETTER(Process_setVersionsLazy); - -static JSC_DECLARE_CUSTOM_GETTER(Process_getPID); -static JSC_DECLARE_CUSTOM_GETTER(Process_getPPID); - -static JSC_DECLARE_HOST_FUNCTION(Process_functionCwd); +JSC_DECLARE_CUSTOM_SETTER(Process_setTitle); +JSC_DECLARE_CUSTOM_GETTER(Process_getArgv); +JSC_DECLARE_CUSTOM_SETTER(Process_setArgv); +JSC_DECLARE_CUSTOM_GETTER(Process_getTitle); +JSC_DECLARE_CUSTOM_GETTER(Process_getPID); +JSC_DECLARE_CUSTOM_GETTER(Process_getPPID); +JSC_DECLARE_HOST_FUNCTION(Process_functionCwd); static bool processIsExiting = false; extern "C" uint8_t Bun__getExitCode(void*); extern "C" uint8_t Bun__setExitCode(void*, uint8_t); extern "C" void* Bun__getVM(); extern "C" Zig::GlobalObject* Bun__getDefaultGlobal(); +extern "C" const char* Bun__githubURL; static void dispatchExitInternal(JSC::JSGlobalObject* globalObject, Process* process, int exitCode) { @@ -72,107 +80,6 @@ static void dispatchExitInternal(JSC::JSGlobalObject* globalObject, Process* pro emitter.emit(event, arguments); } -static JSValue constructStdioWriteStream(JSC::JSGlobalObject* globalObject, int fd) -{ - auto& vm = globalObject->vm(); - auto scope = DECLARE_THROW_SCOPE(vm); - auto* thisObject = reinterpret_cast(globalObject); - JSC::JSFunction* getStdioWriteStream = JSC::JSFunction::create(vm, processObjectInternalsGetStdioWriteStreamCodeGenerator(vm), globalObject); - JSC::MarkedArgumentBuffer args; - WTF::String process = WTF::String("node:process"_s); - JSC::JSValue requireFunction = Zig::ImportMetaObject::createRequireFunction( - vm, - globalObject, - process); - - args.append(JSC::jsNumber(fd)); - args.append(requireFunction); - - auto clientData = WebCore::clientData(vm); - JSC::CallData callData = JSC::getCallData(getStdioWriteStream); - - NakedPtr returnedException = nullptr; - auto result = JSC::call(globalObject, getStdioWriteStream, callData, globalObject->globalThis(), args, returnedException); - RETURN_IF_EXCEPTION(scope, {}); - - if (returnedException) { - throwException(globalObject, scope, returnedException.get()); - return {}; - } - - return result; -} - -JSC_DEFINE_CUSTOM_GETTER( - Process_lazyStdinGetter, - (JSGlobalObject * globalObject, EncodedJSValue thisValue, PropertyName property)) -{ - auto& vm = globalObject->vm(); - auto scope = DECLARE_THROW_SCOPE(vm); - JSC::JSValue value = JSC::JSValue::decode(thisValue); - if (!value || value.isUndefinedOrNull() || !value.isObject()) - return JSValue::encode(jsUndefined()); - - auto* thisObject = reinterpret_cast(globalObject); - JSC::JSFunction* getStdioWriteStream = JSC::JSFunction::create(vm, processObjectInternalsGetStdinStreamCodeGenerator(vm), globalObject); - JSC::MarkedArgumentBuffer args; - WTF::String process = WTF::String("node:process"_s); - JSC::JSValue requireFunction = Zig::ImportMetaObject::createRequireFunction( - vm, - globalObject, - process); - - args.append(JSC::jsNumber(STDIN_FILENO)); - args.append(requireFunction); - args.append(thisObject->get(globalObject, PropertyName(JSC::Identifier::fromString(vm, "Bun"_s)))); - - auto clientData = WebCore::clientData(vm); - JSC::CallData callData = JSC::getCallData(getStdioWriteStream); - - NakedPtr returnedException = nullptr; - auto result = JSC::call(globalObject, getStdioWriteStream, callData, globalObject->globalThis(), args, returnedException); - RETURN_IF_EXCEPTION(scope, {}); - - if (UNLIKELY(returnedException)) { - throwException(globalObject, scope, returnedException.get()); - return {}; - } - - if (LIKELY(result)) - value.getObject()->putDirect(vm, property, result, 0); - - return JSValue::encode(result); -} - -JSC_DEFINE_CUSTOM_GETTER( - Process_lazyStdoutGetter, - (JSGlobalObject * globalObject, EncodedJSValue thisValue, PropertyName property)) -{ - JSValue value = JSValue::decode(thisValue); - auto& vm = globalObject->vm(); - JSC::JSObject* thisObject = value.toObject(globalObject); - JSC::JSValue stream = constructStdioWriteStream(globalObject, 1); - - if (stream) - thisObject->putDirect(vm, property, stream, 0); - - return JSValue::encode(stream); -} - -JSC_DEFINE_CUSTOM_GETTER( - Process_lazyStderrGetter, (JSGlobalObject * globalObject, EncodedJSValue thisValue, PropertyName property)) -{ - JSValue value = JSValue::decode(thisValue); - auto& vm = globalObject->vm(); - JSC::JSObject* thisObject = value.toObject(globalObject); - JSC::JSValue stream = constructStdioWriteStream(globalObject, 2); - - if (stream) - thisObject->putDirect(vm, property, stream, 0); - - return JSValue::encode(stream); -} - JSC_DEFINE_CUSTOM_SETTER(Process_defaultSetter, (JSC::JSGlobalObject * globalObject, JSC::EncodedJSValue thisValue, JSC::EncodedJSValue value, JSC::PropertyName propertyName)) @@ -420,6 +327,7 @@ JSC_DEFINE_HOST_FUNCTION(Process_functionExit, Process__dispatchOnExit(zigGlobal, exitCode); Bun__Process__exit(zigGlobal, exitCode); + __builtin_unreachable(); } extern "C" uint64_t Bun__readOriginTimer(void*); @@ -497,34 +405,6 @@ JSC_DEFINE_HOST_FUNCTION(Process_functionChdir, return JSC::JSValue::encode(result); } -extern "C" const char* Bun__githubURL; - -JSC_DEFINE_CUSTOM_GETTER(Process_getterRelease, (JSGlobalObject * globalObject, EncodedJSValue thisValue, PropertyName)) -{ - auto& vm = globalObject->vm(); - - auto* release = JSC::constructEmptyObject(globalObject); - release->putDirect(vm, Identifier::fromString(vm, "name"_s), jsString(vm, WTF::String("bun"_s)), 0); - release->putDirect(vm, Identifier::fromString(vm, "lts"_s), jsBoolean(false), 0); - release->putDirect(vm, Identifier::fromString(vm, "sourceUrl"_s), jsString(vm, WTF::String(Bun__githubURL, strlen(Bun__githubURL))), 0); - release->putDirect(vm, Identifier::fromString(vm, "headersUrl"_s), jsEmptyString(vm), 0); - release->putDirect(vm, Identifier::fromString(vm, "libUrl"_s), jsEmptyString(vm), 0); - - return JSValue::encode(release); -} - -JSC_DEFINE_CUSTOM_SETTER(Process_setterRelease, - (JSC::JSGlobalObject * globalObject, JSC::EncodedJSValue thisValue, - JSC::EncodedJSValue value, JSC::PropertyName)) -{ - JSC::VM& vm = globalObject->vm(); - - JSC::JSObject* thisObject = JSC::jsDynamicCast(JSValue::decode(thisValue)); - thisObject->putDirect(vm, JSC::Identifier::fromString(vm, "release"_s), JSValue::decode(value), 0); - - return true; -} - // static const NeverDestroyed signalNames[] = { // MAKE_STATIC_STRING_IMPL("SIGHUP"), // MAKE_STATIC_STRING_IMPL("SIGINT"), @@ -660,31 +540,7 @@ JSC_DEFINE_HOST_FUNCTION(Process_emitWarning, (JSGlobalObject * lexicalGlobalObj return JSValue::encode(jsUndefined()); } -JSC_DEFINE_CUSTOM_GETTER(Process_lazyArgv0Getter, (JSC::JSGlobalObject * globalObject, JSC::EncodedJSValue thisValue, JSC::PropertyName name)) -{ - JSC::JSObject* thisObject = JSValue::decode(thisValue).getObject(); - EncodedJSValue ret = Bun__Process__getArgv0(globalObject); - - if (LIKELY(thisObject)) { - thisObject->putDirect(globalObject->vm(), name, JSValue::decode(ret), 0); - } - - return ret; -} - -JSC_DEFINE_CUSTOM_GETTER(Process_lazyExecArgvGetter, (JSC::JSGlobalObject * globalObject, JSC::EncodedJSValue thisValue, JSC::PropertyName name)) -{ - JSC::JSObject* thisObject = JSValue::decode(thisValue).getObject(); - EncodedJSValue ret = Bun__Process__getExecArgv(globalObject); - - if (LIKELY(thisObject)) { - thisObject->putDirect(globalObject->vm(), name, JSValue::decode(ret), 0); - } - - return ret; -} - -JSC_DEFINE_CUSTOM_GETTER(Process__getExitCode, (JSC::JSGlobalObject * lexicalGlobalObject, JSC::EncodedJSValue thisValue, JSC::PropertyName name)) +JSC_DEFINE_CUSTOM_GETTER(processExitCode, (JSC::JSGlobalObject * lexicalGlobalObject, JSC::EncodedJSValue thisValue, JSC::PropertyName name)) { Process* process = jsDynamicCast(JSValue::decode(thisValue)); if (!process) { @@ -693,7 +549,7 @@ JSC_DEFINE_CUSTOM_GETTER(Process__getExitCode, (JSC::JSGlobalObject * lexicalGlo return JSValue::encode(jsNumber(Bun__getExitCode(jsCast(process->globalObject())->bunVM()))); } -JSC_DEFINE_CUSTOM_SETTER(Process__setExitCode, (JSC::JSGlobalObject * lexicalGlobalObject, JSC::EncodedJSValue thisValue, JSC::EncodedJSValue value, JSC::PropertyName)) +JSC_DEFINE_CUSTOM_SETTER(setProcessExitCode, (JSC::JSGlobalObject * lexicalGlobalObject, JSC::EncodedJSValue thisValue, JSC::EncodedJSValue value, JSC::PropertyName)) { Process* process = jsDynamicCast(JSValue::decode(thisValue)); if (!process) { @@ -724,158 +580,56 @@ JSC_DEFINE_CUSTOM_SETTER(Process__setExitCode, (JSC::JSGlobalObject * lexicalGlo return true; } -JSC_DEFINE_CUSTOM_GETTER(Process_lazyExecPathGetter, (JSC::JSGlobalObject * globalObject, JSC::EncodedJSValue thisValue, JSC::PropertyName name)) +static JSValue constructVersions(VM& vm, JSObject* processObject) { - JSC::JSObject* thisObject = JSValue::decode(thisValue).getObject(); - EncodedJSValue ret = Bun__Process__getExecPath(globalObject); - - if (LIKELY(thisObject)) { - thisObject->putDirect(globalObject->vm(), name, JSValue::decode(ret), 0); - } - - return ret; -} - -void Process::finishCreation(JSC::VM& vm) -{ - Base::finishCreation(vm); - auto clientData = WebCore::clientData(vm); - auto* globalObject = reinterpret_cast(this->globalObject()); - - putDirectCustomAccessor(vm, clientData->builtinNames().pidPublicName(), - JSC::CustomGetterSetter::create(vm, Process_getPID, nullptr), - static_cast(JSC::PropertyAttribute::CustomValue)); - - putDirectCustomAccessor(vm, clientData->builtinNames().ppidPublicName(), - JSC::CustomGetterSetter::create(vm, Process_getPPID, nullptr), - static_cast(JSC::PropertyAttribute::CustomValue)); - - putDirectCustomAccessor(vm, JSC::Identifier::fromString(vm, "title"_s), - JSC::CustomGetterSetter::create(vm, Process_getTitle, Process_setTitle), - static_cast(JSC::PropertyAttribute::CustomValue)); - - putDirectCustomAccessor(vm, clientData->builtinNames().argvPublicName(), - JSC::CustomGetterSetter::create(vm, Process_getArgv, Process_setArgv), - static_cast(JSC::PropertyAttribute::CustomValue)); - - putDirect(vm, JSC::Identifier::fromString(vm, "revision"_s), - JSC::jsString(vm, makeAtomString(Bun__version_sha)), 0); - - this->putDirect(vm, clientData->builtinNames().nextTickPublicName(), - JSC::JSFunction::create(vm, globalObject, 1, - MAKE_STATIC_STRING_IMPL("nextTick"), Process_functionNextTick, ImplementationVisibility::Public), - PropertyAttribute::Function | 0); - - this->putDirect(vm, JSC::Identifier::fromString(vm, "dlopen"_s), - JSC::JSFunction::create(vm, globalObject, 1, - MAKE_STATIC_STRING_IMPL("dlopen"), Process_functionDlopen, ImplementationVisibility::Public), - PropertyAttribute::Function | 0); - - this->putDirect(vm, clientData->builtinNames().cwdPublicName(), - JSC::JSFunction::create(vm, globalObject, 0, - MAKE_STATIC_STRING_IMPL("cwd"), Process_functionCwd, ImplementationVisibility::Public), - PropertyAttribute::Function | 0); - - this->putDirect(vm, clientData->builtinNames().chdirPublicName(), - JSC::JSFunction::create(vm, globalObject, 0, - MAKE_STATIC_STRING_IMPL("chdir"), Process_functionChdir, ImplementationVisibility::Public), - PropertyAttribute::Function | 0); - - this->putDirect(vm, JSC::Identifier::fromString(vm, "exit"_s), - JSC::JSFunction::create(vm, globalObject, 0, - MAKE_STATIC_STRING_IMPL("exit"), Process_functionExit, ImplementationVisibility::Public), - PropertyAttribute::Function | 0); - - putDirectCustomAccessor( - vm, clientData->builtinNames().versionsPublicName(), - JSC::CustomGetterSetter::create(vm, Process_getVersionsLazy, Process_setVersionsLazy), 0); - // this should be transpiled out, but just incase - this->putDirect(vm, JSC::Identifier::fromString(vm, "browser"_s), - JSC::JSValue(false), PropertyAttribute::DontEnum | 0); - - this->putDirectCustomAccessor(vm, JSC::Identifier::fromString(vm, "exitCode"_s), - JSC::CustomGetterSetter::create(vm, - Process__getExitCode, - Process__setExitCode), - 0); - - this->putDirect(vm, clientData->builtinNames().versionPublicName(), - JSC::jsString(vm, makeString("v", REPORTED_NODE_VERSION))); - - // this gives some way of identifying at runtime whether the SSR is happening in node or not. - // this should probably be renamed to what the name of the bundler is, instead of "notNodeJS" - // but it must be something that won't evaluate to truthy in Node.js - this->putDirect(vm, JSC::Identifier::fromString(vm, "isBun"_s), JSC::JSValue(true)); -#if defined(__APPLE__) - this->putDirect(vm, JSC::Identifier::fromString(vm, "platform"_s), - JSC::jsString(vm, makeAtomString("darwin"))); -#else - this->putDirect(vm, JSC::Identifier::fromString(vm, "platform"_s), - JSC::jsString(vm, makeAtomString("linux"))); -#endif - -#if defined(__x86_64__) - this->putDirect(vm, JSC::Identifier::fromString(vm, "arch"_s), - JSC::jsString(vm, makeAtomString("x64"))); -#elif defined(__i386__) - this->putDirect(vm, JSC::Identifier::fromString(vm, "arch"_s), - JSC::jsString(vm, makeAtomString("x86"))); -#elif defined(__arm__) - this->putDirect(vm, JSC::Identifier::fromString(vm, "arch"_s), - JSC::jsString(vm, makeAtomString("arm"))); -#elif defined(__aarch64__) - this->putDirect(vm, JSC::Identifier::fromString(vm, "arch"_s), - JSC::jsString(vm, makeAtomString("arm64"))); -#endif - - JSC::JSFunction* hrtime = JSC::JSFunction::create(vm, globalObject, 0, - MAKE_STATIC_STRING_IMPL("hrtime"), Process_functionHRTime, ImplementationVisibility::Public); - - JSC::JSFunction* hrtimeBigInt = JSC::JSFunction::create(vm, globalObject, 0, - MAKE_STATIC_STRING_IMPL("bigint"), Process_functionHRTimeBigInt, ImplementationVisibility::Public); - - hrtime->putDirect(vm, JSC::Identifier::fromString(vm, "bigint"_s), hrtimeBigInt); - this->putDirect(vm, JSC::Identifier::fromString(vm, "hrtime"_s), hrtime); - - this->putDirectCustomAccessor(vm, JSC::PropertyName(JSC::Identifier::fromString(vm, "release"_s)), - JSC::CustomGetterSetter::create(vm, Process_getterRelease, Process_setterRelease), 0); - - this->putDirectCustomAccessor(vm, JSC::PropertyName(JSC::Identifier::fromString(vm, "stdout"_s)), - JSC::CustomGetterSetter::create(vm, Process_lazyStdoutGetter, Process_defaultSetter), 0); - - this->putDirectCustomAccessor(vm, JSC::PropertyName(JSC::Identifier::fromString(vm, "stderr"_s)), - JSC::CustomGetterSetter::create(vm, Process_lazyStderrGetter, Process_defaultSetter), 0); - - this->putDirectCustomAccessor(vm, JSC::PropertyName(JSC::Identifier::fromString(vm, "stdin"_s)), - JSC::CustomGetterSetter::create(vm, Process_lazyStdinGetter, Process_defaultSetter), 0); - - this->putDirectNativeFunction(vm, globalObject, JSC::Identifier::fromString(vm, "abort"_s), - 0, Process_functionAbort, ImplementationVisibility::Public, NoIntrinsic, 0); - - this->putDirectNativeFunction(vm, globalObject, JSC::Identifier::fromString(vm, "abort"_s), - 0, Process_functionAbort, ImplementationVisibility::Public, NoIntrinsic, 0); - - this->putDirectCustomAccessor(vm, JSC::PropertyName(JSC::Identifier::fromString(vm, "argv0"_s)), - JSC::CustomGetterSetter::create(vm, Process_lazyArgv0Getter, Process_defaultSetter), 0); - - this->putDirectCustomAccessor(vm, JSC::PropertyName(JSC::Identifier::fromString(vm, "execPath"_s)), - JSC::CustomGetterSetter::create(vm, Process_lazyExecPathGetter, Process_defaultSetter), 0); - - this->putDirectCustomAccessor(vm, JSC::PropertyName(JSC::Identifier::fromString(vm, "execArgv"_s)), - JSC::CustomGetterSetter::create(vm, Process_lazyExecArgvGetter, Process_defaultSetter), 0); + auto* globalObject = processObject->globalObject(); + JSC::JSObject* object = JSC::constructEmptyObject(globalObject, globalObject->objectPrototype(), 19); - this->putDirectNativeFunction(vm, globalObject, JSC::Identifier::fromString(vm, "uptime"_s), - 0, Process_functionUptime, ImplementationVisibility::Public, NoIntrinsic, 0); + object->putDirect(vm, JSC::Identifier::fromString(vm, "node"_s), + JSC::JSValue(JSC::jsOwnedString(vm, makeAtomString(REPORTED_NODE_VERSION)))); + object->putDirect( + vm, JSC::Identifier::fromString(vm, "bun"_s), + JSC::JSValue(JSC::jsOwnedString(vm, makeAtomString(Bun__version + 1 /* prefix with v */)))); + object->putDirect(vm, JSC::Identifier::fromString(vm, "webkit"_s), + JSC::JSValue(JSC::jsOwnedString(vm, makeAtomString(BUN_WEBKIT_VERSION)))); + object->putDirect(vm, JSC::Identifier::fromString(vm, "boringssl"_s), + JSC::JSValue(JSC::jsString(vm, makeString(Bun__versions_boringssl))), 0); + object->putDirect(vm, JSC::Identifier::fromString(vm, "libarchive"_s), + JSC::JSValue(JSC::jsString(vm, makeString(Bun__versions_libarchive))), 0); + object->putDirect(vm, JSC::Identifier::fromString(vm, "mimalloc"_s), + JSC::JSValue(JSC::jsString(vm, makeString(Bun__versions_mimalloc))), 0); + object->putDirect(vm, JSC::Identifier::fromString(vm, "picohttpparser"_s), + JSC::JSValue(JSC::jsString(vm, makeString(Bun__versions_picohttpparser))), 0); + object->putDirect(vm, JSC::Identifier::fromString(vm, "uwebsockets"_s), + JSC::JSValue(JSC::jsString(vm, makeString(Bun__versions_uws))), 0); + object->putDirect(vm, JSC::Identifier::fromString(vm, "webkit"_s), + JSC::JSValue(JSC::jsString(vm, makeString(Bun__versions_webkit))), 0); + object->putDirect(vm, JSC::Identifier::fromString(vm, "zig"_s), + JSC::JSValue(JSC::jsString(vm, makeString(Bun__versions_zig))), 0); + object->putDirect(vm, JSC::Identifier::fromString(vm, "zlib"_s), + JSC::JSValue(JSC::jsString(vm, makeString(Bun__versions_zlib))), 0); + object->putDirect(vm, JSC::Identifier::fromString(vm, "tinycc"_s), + JSC::JSValue(JSC::jsString(vm, makeString(Bun__versions_tinycc))), 0); + object->putDirect(vm, JSC::Identifier::fromString(vm, "lolhtml"_s), + JSC::JSValue(JSC::jsString(vm, makeString(Bun__versions_lolhtml))), 0); + object->putDirect(vm, JSC::Identifier::fromString(vm, "ares"_s), + JSC::JSValue(JSC::jsString(vm, makeString(Bun__versions_c_ares))), 0); + object->putDirect(vm, JSC::Identifier::fromString(vm, "usockets"_s), + JSC::JSValue(JSC::jsString(vm, makeString(Bun__versions_usockets))), 0); - this->putDirectNativeFunction(vm, globalObject, JSC::Identifier::fromString(vm, "umask"_s), - 1, Process_functionUmask, ImplementationVisibility::Public, NoIntrinsic, 0); + object->putDirect(vm, JSC::Identifier::fromString(vm, "v8"_s), JSValue(JSC::jsString(vm, makeString("10.8.168.20-node.8"_s))), 0); + object->putDirect(vm, JSC::Identifier::fromString(vm, "uv"_s), JSValue(JSC::jsString(vm, makeString("1.44.2"_s))), 0); + object->putDirect(vm, JSC::Identifier::fromString(vm, "napi"_s), JSValue(JSC::jsString(vm, makeString("8"_s))), 0); - this->putDirectBuiltinFunction(vm, globalObject, JSC::Identifier::fromString(vm, "binding"_s), - processObjectInternalsBindingCodeGenerator(vm), - 0); + object->putDirect(vm, JSC::Identifier::fromString(vm, "modules"_s), + JSC::JSValue(JSC::jsString(vm, makeAtomString("108")))); - this->putDirect(vm, vm.propertyNames->toStringTagSymbol, jsString(vm, String("process"_s)), 0); + return object; +} +static JSValue constructProcessConfigObject(VM& vm, JSObject* processObject) +{ + auto* globalObject = processObject->globalObject(); // target_defaults: // { cflags: [], // default_configuration: 'Release', @@ -905,179 +659,455 @@ void Process::finishCreation(JSC::VM& vm) JSC::jsNumber(1), 0); config->putDirect(vm, JSC::Identifier::fromString(vm, "target_defaults"_s), JSC::constructEmptyObject(globalObject), 0); config->putDirect(vm, JSC::Identifier::fromString(vm, "variables"_s), variables, 0); - this->putDirect(vm, JSC::Identifier::fromString(vm, "config"_s), config, 0); - - this->putDirectNativeFunction(vm, globalObject, JSC::Identifier::fromString(vm, "emitWarning"_s), - 1, Process_emitWarning, ImplementationVisibility::Public, NoIntrinsic, 0); - - JSC::JSFunction* requireDotMainFunction = JSFunction::create( - vm, - moduleMainCodeGenerator(vm), - globalObject->globalScope()); - // https://nodejs.org/api/process.html#processmainmodule - this->putDirect( - vm, - JSC::Identifier::fromString(vm, "mainModule"_s), - JSC::GetterSetter::create(vm, globalObject, requireDotMainFunction, JSValue()), - PropertyAttribute::Builtin | PropertyAttribute::Accessor | PropertyAttribute::ReadOnly | PropertyAttribute::DontEnum | 0); + + return config; } -const JSC::ClassInfo Process::s_info = { "Process"_s, &Base::s_info, nullptr, nullptr, - CREATE_METHOD_TABLE(Process) }; +static JSValue constructProcessReleaseObject(VM& vm, JSObject* processObject) +{ + auto* globalObject = processObject->globalObject(); + auto* release = JSC::constructEmptyObject(globalObject); + release->putDirect(vm, Identifier::fromString(vm, "name"_s), jsString(vm, WTF::String("bun"_s)), 0); + release->putDirect(vm, Identifier::fromString(vm, "lts"_s), jsBoolean(false), 0); + release->putDirect(vm, Identifier::fromString(vm, "sourceUrl"_s), jsString(vm, WTF::String(Bun__githubURL, strlen(Bun__githubURL))), 0); + release->putDirect(vm, Identifier::fromString(vm, "headersUrl"_s), jsEmptyString(vm), 0); + release->putDirect(vm, Identifier::fromString(vm, "libUrl"_s), jsEmptyString(vm), 0); + + return release; +} -JSC_DEFINE_CUSTOM_GETTER(Process_getTitle, (JSC::JSGlobalObject * globalObject, JSC::EncodedJSValue thisValue, JSC::PropertyName)) +static JSValue constructProcessHrtimeObject(VM& vm, JSObject* processObject) { - ZigString str; - Bun__Process__getTitle(globalObject, &str); - return JSValue::encode(Zig::toJSStringValue(str, globalObject)); + auto* globalObject = processObject->globalObject(); + JSC::JSFunction* hrtime = JSC::JSFunction::create(vm, globalObject, 0, + MAKE_STATIC_STRING_IMPL("hrtime"), Process_functionHRTime, ImplementationVisibility::Public); + + JSC::JSFunction* hrtimeBigInt = JSC::JSFunction::create(vm, globalObject, 0, + MAKE_STATIC_STRING_IMPL("bigint"), Process_functionHRTimeBigInt, ImplementationVisibility::Public); + + hrtime->putDirect(vm, JSC::Identifier::fromString(vm, "bigint"_s), hrtimeBigInt); + + return hrtime; } -JSC_DEFINE_CUSTOM_SETTER(Process_setTitle, - (JSC::JSGlobalObject * globalObject, JSC::EncodedJSValue thisValue, - JSC::EncodedJSValue value, JSC::PropertyName)) +static JSValue constructStdioWriteStream(JSC::JSGlobalObject* globalObject, int fd) { - JSC::VM& vm = globalObject->vm(); + auto& vm = globalObject->vm(); + auto scope = DECLARE_THROW_SCOPE(vm); + JSC::JSFunction* getStdioWriteStream = JSC::JSFunction::create(vm, processObjectInternalsGetStdioWriteStreamCodeGenerator(vm), globalObject); + JSC::MarkedArgumentBuffer args; + args.append(JSC::jsNumber(fd)); - JSC::JSObject* thisObject = JSC::jsDynamicCast(JSValue::decode(thisValue)); - JSC::JSString* jsString = JSC::jsDynamicCast(JSValue::decode(value)); - if (!thisObject || !jsString) { - return false; + auto clientData = WebCore::clientData(vm); + JSC::CallData callData = JSC::getCallData(getStdioWriteStream); + + NakedPtr returnedException = nullptr; + auto result = JSC::call(globalObject, getStdioWriteStream, callData, globalObject->globalThis(), args, returnedException); + RETURN_IF_EXCEPTION(scope, {}); + + if (returnedException) { + throwException(globalObject, scope, returnedException.get()); + return {}; } - ZigString str = Zig::toZigString(jsString, globalObject); - Bun__Process__setTitle(globalObject, &str); + return result; +} - return true; +static JSValue constructStdout(VM& vm, JSObject* processObject) +{ + auto* globalObject = Bun__getDefaultGlobal(); + return constructStdioWriteStream(globalObject, 1); } -JSC_DEFINE_CUSTOM_GETTER(Process_getArgv, (JSC::JSGlobalObject * globalObject, JSC::EncodedJSValue thisValue, JSC::PropertyName)) +static JSValue constructStderr(VM& vm, JSObject* processObject) { - JSC::VM& vm = globalObject->vm(); + auto* globalObject = Bun__getDefaultGlobal(); + return constructStdioWriteStream(globalObject, 2); +} - Zig::Process* thisObject = JSC::jsDynamicCast(JSValue::decode(thisValue)); - if (!thisObject) { - return JSValue::encode(JSC::jsUndefined()); - } +static JSValue constructStdin(VM& vm, JSObject* processObject) +{ + auto* globalObject = Bun__getDefaultGlobal(); + auto scope = DECLARE_THROW_SCOPE(vm); + auto* thisObject = reinterpret_cast(globalObject); + JSC::JSFunction* getStdioWriteStream = JSC::JSFunction::create(vm, processObjectInternalsGetStdinStreamCodeGenerator(vm), globalObject); + JSC::MarkedArgumentBuffer args; + args.append(JSC::jsNumber(STDIN_FILENO)); - JSC::EncodedJSValue argv_ = Bun__Process__getArgv(globalObject); auto clientData = WebCore::clientData(vm); + JSC::CallData callData = JSC::getCallData(getStdioWriteStream); + + NakedPtr returnedException = nullptr; + auto result = JSC::call(globalObject, getStdioWriteStream, callData, globalObject, args, returnedException); + RETURN_IF_EXCEPTION(scope, {}); - thisObject->putDirect(vm, clientData->builtinNames().argvPublicName(), - JSC::JSValue::decode(argv_), 0); + if (UNLIKELY(returnedException)) { + throwException(globalObject, scope, returnedException.get()); + return {}; + } - return argv_; + RELEASE_AND_RETURN(scope, result); } -JSC_DEFINE_CUSTOM_SETTER(Process_setArgv, - (JSC::JSGlobalObject * globalObject, JSC::EncodedJSValue thisValue, - JSC::EncodedJSValue value, JSC::PropertyName)) +static JSValue constructPid(VM& vm, JSObject* processObject) { - JSC::VM& vm = globalObject->vm(); + return jsNumber(getpid()); +} - JSC::JSObject* thisObject = JSC::jsDynamicCast(JSValue::decode(thisValue)); - if (!thisObject) { - return false; - } +static JSValue constructPpid(VM& vm, JSObject* processObject) +{ + return jsNumber(getppid()); +} - auto clientData = WebCore::clientData(vm); +static JSValue constructArgv0(VM& vm, JSObject* processObject) +{ + auto* globalObject = processObject->globalObject(); + return JSValue::decode(Bun__Process__getArgv0(globalObject)); +} - return thisObject->putDirect(vm, clientData->builtinNames().argvPublicName(), - JSC::JSValue::decode(value)); +static JSValue constructExecArgv(VM& vm, JSObject* processObject) +{ + auto* globalObject = processObject->globalObject(); + return JSValue::decode(Bun__Process__getExecArgv(globalObject)); } -JSC_DEFINE_CUSTOM_GETTER(Process_getPID, (JSC::JSGlobalObject * globalObject, JSC::EncodedJSValue thisValue, JSC::PropertyName)) +static JSValue constructExecPath(VM& vm, JSObject* processObject) { - return JSC::JSValue::encode(JSC::JSValue(getpid())); + auto* globalObject = processObject->globalObject(); + return JSValue::decode(Bun__Process__getExecPath(globalObject)); } -JSC_DEFINE_CUSTOM_GETTER(Process_getPPID, (JSC::JSGlobalObject * globalObject, JSC::EncodedJSValue thisValue, JSC::PropertyName)) +static JSValue constructArgv(VM& vm, JSObject* processObject) { - return JSC::JSValue::encode(JSC::JSValue(getppid())); + auto* globalObject = processObject->globalObject(); + return JSValue::decode(Bun__Process__getArgv(globalObject)); } -#if !defined(BUN_WEBKIT_VERSION) -#define BUN_WEBKIT_VERSION "unknown" +static JSValue constructArch(VM& vm, JSObject* processObject) +{ +#if defined(__x86_64__) + return JSC::jsString(vm, makeAtomString("x64")); +#elif defined(__i386__) + return JSC::jsString(vm, makeAtomString("x86")); +#elif defined(__arm__) + return JSC::jsString(vm, makeAtomString("arm")); +#elif defined(__aarch64__) + return JSC::jsString(vm, makeAtomString("arm64")); +#else +#error "Unknown architecture" #endif +} -JSC_DEFINE_CUSTOM_GETTER(Process_getVersionsLazy, - (JSC::JSGlobalObject * globalObject, JSC::EncodedJSValue thisValue, - JSC::PropertyName)) +static JSValue constructPlatform(VM& vm, JSObject* processObject) { - JSC::VM& vm = globalObject->vm(); - auto clientData = WebCore::clientData(vm); +#if defined(__APPLE__) + return JSC::jsString(vm, makeAtomString("darwin")); +#elif defined(__linux__) + return JSC::jsString(vm, makeAtomString("linux")); +#else +#error "Unknown platform" +#endif +} - Zig::Process* thisObject = JSC::jsDynamicCast(JSValue::decode(thisValue)); - if (!thisObject) { - return JSValue::encode(JSC::jsUndefined()); +static JSValue constructBrowser(VM& vm, JSObject* processObject) +{ + return jsBoolean(false); +} + +static JSValue constructVersion(VM& vm, JSObject* processObject) +{ + return JSC::jsString(vm, makeString("v", REPORTED_NODE_VERSION)); +} + +static JSValue constructIsBun(VM& vm, JSObject* processObject) +{ + return jsBoolean(true); +} + +static JSValue constructRevision(VM& vm, JSObject* processObject) +{ + return JSC::jsString(vm, makeAtomString(Bun__version_sha)); +} + +static JSValue constructEnv(VM& vm, JSObject* processObject) +{ + auto* globalObject = jsCast(processObject->globalObject()); + return globalObject->processEnvObject(); +} + +JSC_DEFINE_HOST_FUNCTION(Process_functiongetuid, (JSGlobalObject * globalObject, CallFrame* callFrame)) +{ + return JSValue::encode(jsNumber(getuid())); +} + +JSC_DEFINE_HOST_FUNCTION(Process_functiongeteuid, (JSGlobalObject * globalObject, CallFrame* callFrame)) +{ + return JSValue::encode(jsNumber(geteuid())); +} + +JSC_DEFINE_HOST_FUNCTION(Process_functiongetegid, (JSGlobalObject * globalObject, CallFrame* callFrame)) +{ + return JSValue::encode(jsNumber(getegid())); +} + +JSC_DEFINE_HOST_FUNCTION(Process_functiongetgid, (JSGlobalObject * globalObject, CallFrame* callFrame)) +{ + return JSValue::encode(jsNumber(getgid())); +} + +JSC_DEFINE_HOST_FUNCTION(Process_functiongetgroups, (JSGlobalObject * globalObject, CallFrame* callFrame)) +{ + auto& vm = globalObject->vm(); + int ngroups = getgroups(0, nullptr); + auto throwScope = DECLARE_THROW_SCOPE(vm); + if (ngroups == -1) { + SystemError error; + error.errno_ = errno; + error.syscall = Bun::toString("getgroups"_s); + throwException(globalObject, throwScope, JSValue::decode(SystemError__toErrorInstance(&error, globalObject))); + return JSValue::encode(jsUndefined()); } - auto scope = DECLARE_THROW_SCOPE(vm); - JSC::JSObject* object = JSC::constructEmptyObject(globalObject, globalObject->objectPrototype(), 19); + gid_t egid = getegid(); + JSArray* groups = constructEmptyArray(globalObject, nullptr, static_cast(ngroups)); + Vector groupVector(ngroups); + getgroups(1, &egid); + bool needsEgid = true; + for (unsigned i = 0; i < ngroups; i++) { + auto current = groupVector[i]; + if (current == needsEgid) { + needsEgid = false; + } - object->putDirect(vm, JSC::Identifier::fromString(vm, "node"_s), - JSC::JSValue(JSC::jsOwnedString(vm, makeAtomString(REPORTED_NODE_VERSION)))); - object->putDirect( - vm, JSC::Identifier::fromString(vm, "bun"_s), - JSC::JSValue(JSC::jsOwnedString(vm, makeAtomString(Bun__version + 1 /* prefix with v */)))); - object->putDirect(vm, JSC::Identifier::fromString(vm, "webkit"_s), - JSC::JSValue(JSC::jsOwnedString(vm, makeAtomString(BUN_WEBKIT_VERSION)))); - object->putDirect(vm, JSC::Identifier::fromString(vm, "boringssl"_s), - JSC::JSValue(JSC::jsString(vm, makeString(Bun__versions_boringssl))), 0); - object->putDirect(vm, JSC::Identifier::fromString(vm, "libarchive"_s), - JSC::JSValue(JSC::jsString(vm, makeString(Bun__versions_libarchive))), 0); - object->putDirect(vm, JSC::Identifier::fromString(vm, "mimalloc"_s), - JSC::JSValue(JSC::jsString(vm, makeString(Bun__versions_mimalloc))), 0); - object->putDirect(vm, JSC::Identifier::fromString(vm, "picohttpparser"_s), - JSC::JSValue(JSC::jsString(vm, makeString(Bun__versions_picohttpparser))), 0); - object->putDirect(vm, JSC::Identifier::fromString(vm, "uwebsockets"_s), - JSC::JSValue(JSC::jsString(vm, makeString(Bun__versions_uws))), 0); - object->putDirect(vm, JSC::Identifier::fromString(vm, "webkit"_s), - JSC::JSValue(JSC::jsString(vm, makeString(Bun__versions_webkit))), 0); - object->putDirect(vm, JSC::Identifier::fromString(vm, "zig"_s), - JSC::JSValue(JSC::jsString(vm, makeString(Bun__versions_zig))), 0); - object->putDirect(vm, JSC::Identifier::fromString(vm, "zlib"_s), - JSC::JSValue(JSC::jsString(vm, makeString(Bun__versions_zlib))), 0); - object->putDirect(vm, JSC::Identifier::fromString(vm, "tinycc"_s), - JSC::JSValue(JSC::jsString(vm, makeString(Bun__versions_tinycc))), 0); - object->putDirect(vm, JSC::Identifier::fromString(vm, "lolhtml"_s), - JSC::JSValue(JSC::jsString(vm, makeString(Bun__versions_lolhtml))), 0); - object->putDirect(vm, JSC::Identifier::fromString(vm, "ares"_s), - JSC::JSValue(JSC::jsString(vm, makeString(Bun__versions_c_ares))), 0); - object->putDirect(vm, JSC::Identifier::fromString(vm, "usockets"_s), - JSC::JSValue(JSC::jsString(vm, makeString(Bun__versions_usockets))), 0); + groups->putDirectIndex(globalObject, i, jsNumber(current)); + } - object->putDirect(vm, JSC::Identifier::fromString(vm, "v8"_s), JSValue(JSC::jsString(vm, makeString("10.8.168.20-node.8"_s))), 0); - object->putDirect(vm, JSC::Identifier::fromString(vm, "uv"_s), JSValue(JSC::jsString(vm, makeString("1.44.2"_s))), 0); - object->putDirect(vm, JSC::Identifier::fromString(vm, "napi"_s), JSValue(JSC::jsString(vm, makeString("8"_s))), 0); + if (needsEgid) + groups->push(globalObject, jsNumber(egid)); - object->putDirect(vm, JSC::Identifier::fromString(vm, "modules"_s), - JSC::JSValue(JSC::jsOwnedString(vm, makeAtomString("108")))); + return JSValue::encode(groups); +} - thisObject->putDirect(vm, clientData->builtinNames().versionsPublicName(), object, 0); +JSC_DEFINE_HOST_FUNCTION(Process_functionAssert, (JSGlobalObject * globalObject, CallFrame* callFrame)) +{ + auto& vm = globalObject->vm(); + auto throwScope = DECLARE_THROW_SCOPE(vm); - RETURN_IF_EXCEPTION(scope, {}); + JSValue arg0 = callFrame->argument(0); + bool condition = arg0.toBoolean(globalObject); + RETURN_IF_EXCEPTION(throwScope, JSValue::encode(jsUndefined())); + if (condition) { + return JSValue::encode(jsUndefined()); + } - return JSValue::encode(object); + JSValue arg1 = callFrame->argument(1); + String message = arg1.isUndefined() ? String() : arg1.toWTFString(globalObject); + RETURN_IF_EXCEPTION(throwScope, JSValue::encode(jsUndefined())); + auto error = createError(globalObject, makeString("Assertion failed: "_s, message)); + error->putDirect(vm, Identifier::fromString(vm, "code"_s), jsString(vm, makeString("ERR_ASSERTION"_s))); + throwException(globalObject, throwScope, error); + return JSValue::encode(jsUndefined()); } -JSC_DEFINE_CUSTOM_SETTER(Process_setVersionsLazy, + +JSC_DEFINE_HOST_FUNCTION(Process_functionReallyExit, (JSGlobalObject * globalObject, CallFrame* callFrame)) +{ + auto& vm = globalObject->vm(); + auto throwScope = DECLARE_THROW_SCOPE(vm); + uint8_t exitCode = 0; + JSValue arg0 = callFrame->argument(0); + if (arg0.isNumber()) { + if (!arg0.isInt32()) { + throwRangeError(globalObject, throwScope, "The \"code\" argument must be an integer"_s); + return JSC::JSValue::encode(JSC::JSValue {}); + } + + int extiCode32 = arg0.toInt32(globalObject); + RETURN_IF_EXCEPTION(throwScope, JSC::JSValue::encode(JSC::JSValue {})); + + if (extiCode32 < 0 || extiCode32 > 127) { + throwRangeError(globalObject, throwScope, "The \"code\" argument must be an integer between 0 and 127"_s); + return JSC::JSValue::encode(JSC::JSValue {}); + } + + exitCode = static_cast(extiCode32); + } else if (!arg0.isUndefinedOrNull()) { + throwTypeError(globalObject, throwScope, "The \"code\" argument must be an integer"_s); + return JSC::JSValue::encode(JSC::JSValue {}); + } else { + exitCode = Bun__getExitCode(Bun__getVM()); + } + + auto* zigGlobal = jsDynamicCast(globalObject); + if (UNLIKELY(!zigGlobal)) { + zigGlobal = Bun__getDefaultGlobal(); + } + Bun__Process__exit(zigGlobal, exitCode); + __builtin_unreachable(); +} + +JSC_DEFINE_HOST_FUNCTION(Process_functionOpenStdin, (JSGlobalObject * globalObject, CallFrame* callFrame)) +{ + auto& vm = globalObject->vm(); + Zig::GlobalObject* global = jsDynamicCast(globalObject); + if (UNLIKELY(!global)) { + global = Bun__getDefaultGlobal(); + } + auto throwScope = DECLARE_THROW_SCOPE(vm); + + if (JSValue stdin = global->processObject()->getIfPropertyExists(globalObject, Identifier::fromString(vm, "stdin"_s))) { + RETURN_IF_EXCEPTION(throwScope, JSValue::encode(jsUndefined())); + + if (!stdin.isObject()) { + throwTypeError(globalObject, throwScope, "stdin is not an object"_s); + return JSValue::encode(jsUndefined()); + } + + JSValue resumeValue = stdin.getObject()->getIfPropertyExists(globalObject, Identifier::fromString(vm, "resume"_s)); + RETURN_IF_EXCEPTION(throwScope, JSValue::encode(jsUndefined())); + if (!resumeValue.isUndefinedOrNull()) { + auto resumeFunction = jsDynamicCast(resumeValue); + if (UNLIKELY(!resumeFunction)) { + throwTypeError(globalObject, throwScope, "stdin.resume is not a function"_s); + return JSValue::encode(jsUndefined()); + } + + auto callData = getCallData(resumeFunction); + + MarkedArgumentBuffer args; + JSC::call(globalObject, resumeFunction, callData, stdin, args); + RETURN_IF_EXCEPTION(throwScope, JSValue::encode(jsUndefined())); + } + + RELEASE_AND_RETURN(throwScope, JSValue::encode(stdin)); + } + + RELEASE_AND_RETURN(throwScope, JSValue::encode(jsUndefined())); +} + +JSC_DEFINE_HOST_FUNCTION(Process_stubEmptyFunction, (JSGlobalObject * globalObject, CallFrame* callFrame)) +{ + return JSValue::encode(jsUndefined()); +} + +JSC_DEFINE_HOST_FUNCTION(Process_stubFunctionReturningArray, (JSGlobalObject * globalObject, CallFrame* callFrame)) +{ + return JSValue::encode(JSC::constructEmptyArray(globalObject, nullptr)); +} + +static JSValue Process_stubEmptyObject(VM& vm, JSObject* processObject) +{ + return JSC::constructEmptyObject(processObject->globalObject()); +} + +static JSValue Process_stubEmptyArray(VM& vm, JSObject* processObject) +{ + return JSC::constructEmptyArray(processObject->globalObject(), nullptr); +} + +static JSValue Process_stubEmptySet(VM& vm, JSObject* processObject) +{ + auto* globalObject = processObject->globalObject(); + return JSSet::create(vm, globalObject->setStructure()); +} + +static JSValue constructFeatures(VM& vm, JSObject* processObject) +{ + // { + // inspector: true, + // debug: false, + // uv: true, + // ipv6: true, + // tls_alpn: true, + // tls_sni: true, + // tls_ocsp: true, + // tls: true, + // cached_builtins: [Getter] + // } + auto* globalObject = processObject->globalObject(); + auto* object = constructEmptyObject(globalObject); + + object->putDirect(vm, Identifier::fromString(vm, "inspector"_s), jsBoolean(true)); +#ifdef BUN_DEBUG + object->putDirect(vm, Identifier::fromString(vm, "debug"_s), jsBoolean(true)); +#else + object->putDirect(vm, Identifier::fromString(vm, "debug"_s), jsBoolean(false)); +#endif + // lying + object->putDirect(vm, Identifier::fromString(vm, "uv"_s), jsBoolean(true)); + + object->putDirect(vm, Identifier::fromString(vm, "ipv6"_s), jsBoolean(true)); + object->putDirect(vm, Identifier::fromString(vm, "tls_alpn"_s), jsBoolean(true)); + object->putDirect(vm, Identifier::fromString(vm, "tls_sni"_s), jsBoolean(true)); + object->putDirect(vm, Identifier::fromString(vm, "tls_ocsp"_s), jsBoolean(true)); + object->putDirect(vm, Identifier::fromString(vm, "tls"_s), jsBoolean(true)); + object->putDirect(vm, Identifier::fromString(vm, "cached_builtins"_s), jsBoolean(true)); + + return object; +} + +static int _debugPort; + +JSC_DEFINE_CUSTOM_GETTER(processDebugPort, (JSC::JSGlobalObject * globalObject, JSC::EncodedJSValue thisValue, JSC::PropertyName)) +{ + if (_debugPort == 0) { + _debugPort = 9229; + } + + return JSC::JSValue::encode(jsNumber(_debugPort)); +} + +JSC_DEFINE_CUSTOM_SETTER(setProcessDebugPort, + (JSC::JSGlobalObject * globalObject, JSC::EncodedJSValue thisValue, + JSC::EncodedJSValue encodedValue, JSC::PropertyName)) +{ + auto& vm = globalObject->vm(); + auto scope = DECLARE_THROW_SCOPE(vm); + JSValue value = JSValue::decode(encodedValue); + + if (!value.isInt32()) { + throwRangeError(globalObject, scope, "debugPort must be 0 or in range 1024 to 65535"_s); + return false; + } + + int port = value.asInt32(); + + if (port != 0) { + if (port < 1024 || port > 65535) { + throwRangeError(globalObject, scope, "debugPort must be 0 or in range 1024 to 65535"_s); + return false; + } + } + + _debugPort = port; + return true; +} + +JSC_DEFINE_CUSTOM_GETTER(processTitle, (JSC::JSGlobalObject * globalObject, JSC::EncodedJSValue thisValue, JSC::PropertyName)) +{ + ZigString str; + Bun__Process__getTitle(globalObject, &str); + return JSValue::encode(Zig::toJSStringValue(str, globalObject)); +} + +JSC_DEFINE_CUSTOM_SETTER(setProcessTitle, (JSC::JSGlobalObject * globalObject, JSC::EncodedJSValue thisValue, JSC::EncodedJSValue value, JSC::PropertyName)) { JSC::VM& vm = globalObject->vm(); - auto clientData = WebCore::clientData(vm); - Zig::Process* thisObject = JSC::jsDynamicCast(JSValue::decode(thisValue)); - if (!thisObject) { - return JSValue::encode(JSC::jsUndefined()); + JSC::JSObject* thisObject = JSC::jsDynamicCast(JSValue::decode(thisValue)); + JSC::JSString* jsString = JSC::jsDynamicCast(JSValue::decode(value)); + if (!thisObject || !jsString) { + return false; } - thisObject->putDirect(vm, clientData->builtinNames().versionsPublicName(), - JSC::JSValue::decode(value), 0); + ZigString str = Zig::toZigString(jsString, globalObject); + Bun__Process__setTitle(globalObject, &str); return true; } -static JSC_DEFINE_HOST_FUNCTION(Process_functionCwd, +JSC_DEFINE_HOST_FUNCTION(Process_functionCwd, (JSC::JSGlobalObject * globalObject, JSC::CallFrame* callFrame)) { auto scope = DECLARE_THROW_SCOPE(globalObject->vm()); @@ -1091,4 +1121,78 @@ static JSC_DEFINE_HOST_FUNCTION(Process_functionCwd, return JSC::JSValue::encode(result); } +/* Source for Process.lut.h +@begin processObjectTable + abort Process_functionAbort Function 1 + allowedNodeEnvironmentFlags Process_stubEmptySet PropertyCallback + arch constructArch PropertyCallback + argv constructArgv PropertyCallback + argv0 constructArgv0 PropertyCallback + assert Process_functionAssert Function 1 + binding JSBuiltin Function 1 + browser constructBrowser PropertyCallback + chdir Process_functionChdir Function 1 + config constructProcessConfigObject PropertyCallback + debugPort processDebugPort CustomAccessor + exitCode processExitCode CustomAccessor + title processTitle CustomAccessor + cwd Process_functionCwd Function 1 + dlopen Process_functionDlopen Function 1 + emitWarning Process_emitWarning Function 1 + env constructEnv PropertyCallback + execArgv constructExecArgv PropertyCallback + execPath constructExecPath PropertyCallback + exit Process_functionExit Function 1 + features constructFeatures PropertyCallback + getActiveResourcesInfo Process_stubFunctionReturningArray Function 0 + getegid Process_functiongetegid Function 0 + geteuid Process_functiongeteuid Function 0 + getgid Process_functiongetgid Function 0 + getgroups Process_functiongetgroups Function 0 + getuid Process_functiongetuid Function 0 + hrtime constructProcessHrtimeObject PropertyCallback + isBun constructIsBun PropertyCallback + mainModule JSBuiltin ReadOnly|Builtin|Accessor|Function 0 + moduleLoadList Process_stubEmptyArray PropertyCallback + nextTick Process_functionNextTick Function 1 + openStdin Process_functionOpenStdin Function 0 + pid constructPid PropertyCallback + platform constructPlatform PropertyCallback + ppid constructPpid PropertyCallback + reallyExit Process_functionReallyExit Function 1 + release constructProcessReleaseObject PropertyCallback + revision constructRevision PropertyCallback + setSourceMapsEnabled Process_stubEmptyFunction Function 1 + stderr constructStderr PropertyCallback + stdin constructStdin PropertyCallback + stdout constructStdout PropertyCallback + umask Process_functionUmask Function 1 + uptime Process_functionUptime Function 1 + version constructVersion PropertyCallback + versions constructVersions PropertyCallback + _debugEnd Process_stubEmptyFunction Function 0 + _debugProcess Process_stubEmptyFunction Function 0 + _fatalException Process_stubEmptyFunction Function 1 + _getActiveRequests Process_stubFunctionReturningArray Function 0 + _getActiveHandles Process_stubFunctionReturningArray Function 0 + _linkedBinding Process_stubEmptyFunction Function 0 + _preload_modules Process_stubEmptyObject PropertyCallback + _rawDebug Process_stubEmptyFunction Function 0 + _startProfilerIdleNotifier Process_stubEmptyFunction Function 0 + _stopProfilerIdleNotifier Process_stubEmptyFunction Function 0 + _tickCallback Process_stubEmptyFunction Function 0 +@end +*/ + +#include "Process.lut.h" +const JSC::ClassInfo Process::s_info = { "Process"_s, &Base::s_info, &processObjectTable, nullptr, + CREATE_METHOD_TABLE(Process) }; + +void Process::finishCreation(JSC::VM& vm) +{ + Base::finishCreation(vm); + + this->putDirect(vm, vm.propertyNames->toStringTagSymbol, jsString(vm, String("process"_s)), 0); +} + } // namespace Zig diff --git a/src/bun.js/bindings/Process.h b/src/bun.js/bindings/Process.h index 322b39078..8b703b8b1 100644 --- a/src/bun.js/bindings/Process.h +++ b/src/bun.js/bindings/Process.h @@ -28,7 +28,7 @@ public: ~Process(); - static constexpr unsigned StructureFlags = Base::StructureFlags; + static constexpr unsigned StructureFlags = Base::StructureFlags | HasStaticPropertyTable; static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype) diff --git a/src/bun.js/bindings/Process.lut.h b/src/bun.js/bindings/Process.lut.h new file mode 100644 index 000000000..5c0bd2c5a --- /dev/null +++ b/src/bun.js/bindings/Process.lut.h @@ -0,0 +1,208 @@ +// File generated via `make generate-builtins` +static const struct CompactHashIndex processObjectTableIndex[141] = { + { 42, -1 }, + { -1, -1 }, + { -1, -1 }, + { -1, -1 }, + { -1, -1 }, + { -1, -1 }, + { -1, -1 }, + { -1, -1 }, + { -1, -1 }, + { -1, -1 }, + { -1, -1 }, + { 16, 130 }, + { -1, -1 }, + { -1, -1 }, + { 19, 137 }, + { -1, -1 }, + { 43, -1 }, + { -1, -1 }, + { -1, -1 }, + { -1, -1 }, + { -1, -1 }, + { -1, -1 }, + { -1, -1 }, + { -1, -1 }, + { -1, -1 }, + { -1, -1 }, + { -1, -1 }, + { -1, -1 }, + { -1, -1 }, + { -1, -1 }, + { -1, -1 }, + { -1, -1 }, + { -1, -1 }, + { 3, 140 }, + { 1, 128 }, + { -1, -1 }, + { 57, -1 }, + { -1, -1 }, + { -1, -1 }, + { -1, -1 }, + { -1, -1 }, + { 30, -1 }, + { -1, -1 }, + { -1, -1 }, + { -1, -1 }, + { -1, -1 }, + { 50, -1 }, + { 27, -1 }, + { 10, -1 }, + { -1, -1 }, + { 11, -1 }, + { -1, -1 }, + { 15, 136 }, + { -1, -1 }, + { 35, -1 }, + { -1, -1 }, + { 37, -1 }, + { 53, -1 }, + { 34, -1 }, + { 6, 138 }, + { -1, -1 }, + { 49, -1 }, + { 4, -1 }, + { 45, -1 }, + { -1, -1 }, + { -1, -1 }, + { -1, -1 }, + { -1, -1 }, + { 2, -1 }, + { 7, -1 }, + { -1, -1 }, + { -1, -1 }, + { -1, -1 }, + { -1, -1 }, + { -1, -1 }, + { 39, -1 }, + { -1, -1 }, + { 36, -1 }, + { -1, -1 }, + { 0, -1 }, + { 12, 129 }, + { 17, 131 }, + { 38, -1 }, + { -1, -1 }, + { 23, -1 }, + { 13, -1 }, + { -1, -1 }, + { -1, -1 }, + { 56, -1 }, + { -1, -1 }, + { -1, -1 }, + { 47, -1 }, + { -1, -1 }, + { 29, -1 }, + { 22, -1 }, + { -1, -1 }, + { -1, -1 }, + { 24, -1 }, + { -1, -1 }, + { -1, -1 }, + { 20, -1 }, + { -1, -1 }, + { 5, -1 }, + { -1, -1 }, + { -1, -1 }, + { 46, -1 }, + { -1, -1 }, + { -1, -1 }, + { -1, -1 }, + { -1, -1 }, + { 14, 132 }, + { -1, -1 }, + { -1, -1 }, + { -1, -1 }, + { 9, -1 }, + { 25, 134 }, + { -1, -1 }, + { -1, -1 }, + { -1, -1 }, + { -1, -1 }, + { -1, -1 }, + { 21, 135 }, + { -1, -1 }, + { -1, -1 }, + { -1, -1 }, + { 44, 139 }, + { -1, -1 }, + { 18, -1 }, + { 8, -1 }, + { 26, -1 }, + { 28, -1 }, + { 31, 133 }, + { 32, -1 }, + { 33, -1 }, + { 40, -1 }, + { 41, -1 }, + { 48, -1 }, + { 51, -1 }, + { 52, -1 }, + { 54, -1 }, + { 55, -1 }, +}; + +static const struct HashTableValue processObjectTableValues[58] = { + { "abort"_s, static_cast(PropertyAttribute::Function), NoIntrinsic, { HashTableValue::NativeFunctionType, Process_functionAbort, 1 } }, + { "allowedNodeEnvironmentFlags"_s, static_cast(PropertyAttribute::PropertyCallback), NoIntrinsic, { HashTableValue::LazyPropertyType, Process_stubEmptySet } }, + { "arch"_s, static_cast(PropertyAttribute::PropertyCallback), NoIntrinsic, { HashTableValue::LazyPropertyType, constructArch } }, + { "argv"_s, static_cast(PropertyAttribute::PropertyCallback), NoIntrinsic, { HashTableValue::LazyPropertyType, constructArgv } }, + { "argv0"_s, static_cast(PropertyAttribute::PropertyCallback), NoIntrinsic, { HashTableValue::LazyPropertyType, constructArgv0 } }, + { "assert"_s, static_cast(PropertyAttribute::Function), NoIntrinsic, { HashTableValue::NativeFunctionType, Process_functionAssert, 1 } }, + { "binding"_s, ((static_cast(PropertyAttribute::Function)) & ~PropertyAttribute::Function) | PropertyAttribute::Builtin, NoIntrinsic, { HashTableValue::BuiltinGeneratorType, processObjectBindingCodeGenerator, 1 } }, + { "browser"_s, static_cast(PropertyAttribute::PropertyCallback), NoIntrinsic, { HashTableValue::LazyPropertyType, constructBrowser } }, + { "chdir"_s, static_cast(PropertyAttribute::Function), NoIntrinsic, { HashTableValue::NativeFunctionType, Process_functionChdir, 1 } }, + { "config"_s, static_cast(PropertyAttribute::PropertyCallback), NoIntrinsic, { HashTableValue::LazyPropertyType, constructProcessConfigObject } }, + { "debugPort"_s, static_cast(PropertyAttribute::CustomAccessor), NoIntrinsic, { HashTableValue::GetterSetterType, processDebugPort, setProcessDebugPort } }, + { "exitCode"_s, static_cast(PropertyAttribute::CustomAccessor), NoIntrinsic, { HashTableValue::GetterSetterType, processExitCode, setProcessExitCode } }, + { "title"_s, static_cast(PropertyAttribute::CustomAccessor), NoIntrinsic, { HashTableValue::GetterSetterType, processTitle, setProcessTitle } }, + { "cwd"_s, static_cast(PropertyAttribute::Function), NoIntrinsic, { HashTableValue::NativeFunctionType, Process_functionCwd, 1 } }, + { "dlopen"_s, static_cast(PropertyAttribute::Function), NoIntrinsic, { HashTableValue::NativeFunctionType, Process_functionDlopen, 1 } }, + { "emitWarning"_s, static_cast(PropertyAttribute::Function), NoIntrinsic, { HashTableValue::NativeFunctionType, Process_emitWarning, 1 } }, + { "env"_s, static_cast(PropertyAttribute::PropertyCallback), NoIntrinsic, { HashTableValue::LazyPropertyType, constructEnv } }, + { "execArgv"_s, static_cast(PropertyAttribute::PropertyCallback), NoIntrinsic, { HashTableValue::LazyPropertyType, constructExecArgv } }, + { "execPath"_s, static_cast(PropertyAttribute::PropertyCallback), NoIntrinsic, { HashTableValue::LazyPropertyType, constructExecPath } }, + { "exit"_s, static_cast(PropertyAttribute::Function), NoIntrinsic, { HashTableValue::NativeFunctionType, Process_functionExit, 1 } }, + { "features"_s, static_cast(PropertyAttribute::PropertyCallback), NoIntrinsic, { HashTableValue::LazyPropertyType, constructFeatures } }, + { "getActiveResourcesInfo"_s, static_cast(PropertyAttribute::Function), NoIntrinsic, { HashTableValue::NativeFunctionType, Process_stubFunctionReturningArray, 0 } }, + { "getegid"_s, static_cast(PropertyAttribute::Function), NoIntrinsic, { HashTableValue::NativeFunctionType, Process_functiongetegid, 0 } }, + { "geteuid"_s, static_cast(PropertyAttribute::Function), NoIntrinsic, { HashTableValue::NativeFunctionType, Process_functiongeteuid, 0 } }, + { "getgid"_s, static_cast(PropertyAttribute::Function), NoIntrinsic, { HashTableValue::NativeFunctionType, Process_functiongetgid, 0 } }, + { "getgroups"_s, static_cast(PropertyAttribute::Function), NoIntrinsic, { HashTableValue::NativeFunctionType, Process_functiongetgroups, 0 } }, + { "getuid"_s, static_cast(PropertyAttribute::Function), NoIntrinsic, { HashTableValue::NativeFunctionType, Process_functiongetuid, 0 } }, + { "hrtime"_s, static_cast(PropertyAttribute::PropertyCallback), NoIntrinsic, { HashTableValue::LazyPropertyType, constructProcessHrtimeObject } }, + { "isBun"_s, static_cast(PropertyAttribute::PropertyCallback), NoIntrinsic, { HashTableValue::LazyPropertyType, constructIsBun } }, + { "mainModule"_s, ((static_cast(PropertyAttribute::ReadOnly|PropertyAttribute::Builtin|PropertyAttribute::Accessor|PropertyAttribute::Function)) & ~PropertyAttribute::Function) | PropertyAttribute::Builtin, NoIntrinsic, { HashTableValue::BuiltinGeneratorType, processObjectMainModuleCodeGenerator, 0 } }, + { "moduleLoadList"_s, static_cast(PropertyAttribute::PropertyCallback), NoIntrinsic, { HashTableValue::LazyPropertyType, Process_stubEmptyArray } }, + { "nextTick"_s, static_cast(PropertyAttribute::Function), NoIntrinsic, { HashTableValue::NativeFunctionType, Process_functionNextTick, 1 } }, + { "openStdin"_s, static_cast(PropertyAttribute::Function), NoIntrinsic, { HashTableValue::NativeFunctionType, Process_functionOpenStdin, 0 } }, + { "pid"_s, static_cast(PropertyAttribute::PropertyCallback), NoIntrinsic, { HashTableValue::LazyPropertyType, constructPid } }, + { "platform"_s, static_cast(PropertyAttribute::PropertyCallback), NoIntrinsic, { HashTableValue::LazyPropertyType, constructPlatform } }, + { "ppid"_s, static_cast(PropertyAttribute::PropertyCallback), NoIntrinsic, { HashTableValue::LazyPropertyType, constructPpid } }, + { "reallyExit"_s, static_cast(PropertyAttribute::Function), NoIntrinsic, { HashTableValue::NativeFunctionType, Process_functionReallyExit, 1 } }, + { "release"_s, static_cast(PropertyAttribute::PropertyCallback), NoIntrinsic, { HashTableValue::LazyPropertyType, constructProcessReleaseObject } }, + { "revision"_s, static_cast(PropertyAttribute::PropertyCallback), NoIntrinsic, { HashTableValue::LazyPropertyType, constructRevision } }, + { "setSourceMapsEnabled"_s, static_cast(PropertyAttribute::Function), NoIntrinsic, { HashTableValue::NativeFunctionType, Process_stubEmptyFunction, 1 } }, + { "stderr"_s, static_cast(PropertyAttribute::PropertyCallback), NoIntrinsic, { HashTableValue::LazyPropertyType, constructStderr } }, + { "stdin"_s, static_cast(PropertyAttribute::PropertyCallback), NoIntrinsic, { HashTableValue::LazyPropertyType, constructStdin } }, + { "stdout"_s, static_cast(PropertyAttribute::PropertyCallback), NoIntrinsic, { HashTableValue::LazyPropertyType, constructStdout } }, + { "umask"_s, static_cast(PropertyAttribute::Function), NoIntrinsic, { HashTableValue::NativeFunctionType, Process_functionUmask, 1 } }, + { "uptime"_s, static_cast(PropertyAttribute::Function), NoIntrinsic, { HashTableValue::NativeFunctionType, Process_functionUptime, 1 } }, + { "version"_s, static_cast(PropertyAttribute::PropertyCallback), NoIntrinsic, { HashTableValue::LazyPropertyType, constructVersion } }, + { "versions"_s, static_cast(PropertyAttribute::PropertyCallback), NoIntrinsic, { HashTableValue::LazyPropertyType, constructVersions } }, + { "_debugEnd"_s, static_cast(PropertyAttribute::Function), NoIntrinsic, { HashTableValue::NativeFunctionType, Process_stubEmptyFunction, 0 } }, + { "_debugProcess"_s, static_cast(PropertyAttribute::Function), NoIntrinsic, { HashTableValue::NativeFunctionType, Process_stubEmptyFunction, 0 } }, + { "_fatalException"_s, static_cast(PropertyAttribute::Function), NoIntrinsic, { HashTableValue::NativeFunctionType, Process_stubEmptyFunction, 1 } }, + { "_getActiveRequests"_s, static_cast(PropertyAttribute::Function), NoIntrinsic, { HashTableValue::NativeFunctionType, Process_stubFunctionReturningArray, 0 } }, + { "_getActiveHandles"_s, static_cast(PropertyAttribute::Function), NoIntrinsic, { HashTableValue::NativeFunctionType, Process_stubFunctionReturningArray, 0 } }, + { "_linkedBinding"_s, static_cast(PropertyAttribute::Function), NoIntrinsic, { HashTableValue::NativeFunctionType, Process_stubEmptyFunction, 0 } }, + { "_preload_modules"_s, static_cast(PropertyAttribute::PropertyCallback), NoIntrinsic, { HashTableValue::LazyPropertyType, Process_stubEmptyObject } }, + { "_rawDebug"_s, static_cast(PropertyAttribute::Function), NoIntrinsic, { HashTableValue::NativeFunctionType, Process_stubEmptyFunction, 0 } }, + { "_startProfilerIdleNotifier"_s, static_cast(PropertyAttribute::Function), NoIntrinsic, { HashTableValue::NativeFunctionType, Process_stubEmptyFunction, 0 } }, + { "_stopProfilerIdleNotifier"_s, static_cast(PropertyAttribute::Function), NoIntrinsic, { HashTableValue::NativeFunctionType, Process_stubEmptyFunction, 0 } }, + { "_tickCallback"_s, static_cast(PropertyAttribute::Function), NoIntrinsic, { HashTableValue::NativeFunctionType, Process_stubEmptyFunction, 0 } }, +}; + +static const struct HashTable processObjectTable = + { 58, 127, true, nullptr, processObjectTableValues, processObjectTableIndex }; diff --git a/src/bun.js/bindings/ZigGlobalObject.cpp b/src/bun.js/bindings/ZigGlobalObject.cpp index 4bb5445e1..3291b204e 100644 --- a/src/bun.js/bindings/ZigGlobalObject.cpp +++ b/src/bun.js/bindings/ZigGlobalObject.cpp @@ -3160,11 +3160,7 @@ void GlobalObject::finishCreation(VM& vm) Zig::GlobalObject* globalObject = reinterpret_cast(init.owner); auto* process = Zig::Process::create( *globalObject, Zig::Process::createStructure(init.vm, init.owner, WebCore::JSEventEmitter::prototype(init.vm, *globalObject))); - process->putDirectCustomAccessor(init.vm, JSC::Identifier::fromString(init.vm, "env"_s), - JSC::CustomGetterSetter::create(init.vm, lazyProcessEnvGetter, lazyProcessEnvSetter), - JSC::PropertyAttribute::DontDelete - | JSC::PropertyAttribute::CustomValue - | 0); + init.set(process); }); diff --git a/src/bun.js/modules/ProcessModule.h b/src/bun.js/modules/ProcessModule.h index 2df74598a..fab0298ae 100644 --- a/src/bun.js/modules/ProcessModule.h +++ b/src/bun.js/modules/ProcessModule.h @@ -44,11 +44,19 @@ inline void generateProcessSourceCode(JSC::JSGlobalObject *lexicalGlobalObject, reinterpret_cast(lexicalGlobalObject); JSC::JSObject *process = globalObject->processObject(); + auto scope = DECLARE_THROW_SCOPE(vm); + if (!process->staticPropertiesReified()) { + process->reifyAllStaticProperties(globalObject); + if (scope.exception()) + return; + } PropertyNameArray properties(vm, PropertyNameMode::Strings, PrivateSymbolMode::Exclude); process->getPropertyNames(globalObject, properties, DontEnumPropertiesMode::Exclude); + if (scope.exception()) + return; exportNames.append(vm.propertyNames->defaultKeyword); exportValues.append(process); diff --git a/src/js/builtins/ProcessObjectInternals.ts b/src/js/builtins/ProcessObjectInternals.ts index 8b24e68ba..8e2449a43 100644 --- a/src/js/builtins/ProcessObjectInternals.ts +++ b/src/js/builtins/ProcessObjectInternals.ts @@ -49,9 +49,14 @@ export function binding(bindingName) { return constants; } -export function getStdioWriteStream(fd_, rawRequire) { - var module = { path: "node:process", require: rawRequire }; - var require = path => module.require(path); +export function getStdioWriteStream(fd_) { + var require = path => { + var existing = $requireMap.get(path); + if (existing) return existing.exports; + + return $internalRequire(path); + }; + var module = { path: "node:process", require }; function createStdioWriteStream(fd_) { var { Duplex, eos, destroy } = require("node:stream"); @@ -472,10 +477,15 @@ export function getStdioWriteStream(fd_, rawRequire) { return new FastStdioWriteStream(fd_); } -export function getStdinStream(fd_, rawRequire, Bun) { - var module = { path: "node:process", require: rawRequire }; - var require = path => module.require(path); +export function getStdinStream(fd_) { + var require = path => { + var existing = $requireMap.get(path); + if (existing) return existing.exports; + + return $internalRequire(path); + }; + var module = { path: "node:process", require: require }; var { Duplex, eos, destroy } = require("node:stream"); var StdinStream = class StdinStream extends Duplex { diff --git a/src/js/builtins/codegen/index.ts b/src/js/builtins/codegen/index.ts index e20601a15..a5d3c2dc8 100644 --- a/src/js/builtins/codegen/index.ts +++ b/src/js/builtins/codegen/index.ts @@ -3,7 +3,35 @@ import path from "path"; import { sliceSourceCode } from "./builtin-parser"; import { applyGlobalReplacements, enums, globalsToPrefix } from "./replacements"; import { cap, fmtCPPString, low } from "./helpers"; +import { spawn, spawnSync } from "bun"; + +async function createStaticHashtables() { + const STATIC_HASH_TABLES = ["src/bun.js/bindings/Process.cpp"]; + console.time("Creating static hash tables..."); + const create_hash_table = path.join( + import.meta.dir, + "../../../../bun-webkit/Source/JavaScriptCore/create_hash_table", + ); + for (let cpp of STATIC_HASH_TABLES) { + cpp = path.join(import.meta.dir, "../../../../", cpp); + const { stdout, exited } = spawn({ + cmd: [create_hash_table, cpp], + stdout: "pipe", + stderr: "inherit", + }); + await exited; + let str = await new Response(stdout).text(); + str = str.replaceAll(/^\/\/.*$/gm, ""); + str = str.replaceAll(/^#include.*$/gm, ""); + str = str.replaceAll(`namespace JSC {`, ""); + str = str.replaceAll(`} // namespace JSC`, ""); + str = "// File generated via `make generate-builtins`\n" + str.trim() + "\n"; + await Bun.write(cpp.replace(/\.cpp$/, ".lut.h"), str); + } + console.timeEnd("Creating static hash tables..."); +} +const staticHashTablePromise = createStaticHashtables(); console.log("Bundling Bun builtins..."); const MINIFY = process.argv.includes("--minify") || process.argv.includes("-m"); @@ -618,6 +646,8 @@ if (!KEEP_TMP) { await rmSync(TMP_DIR, { recursive: true }); } +await staticHashTablePromise; + console.log( `Embedded JS size: %s bytes (across %s functions, %s files)`, totalJSSize, diff --git a/src/js/out/WebCoreJSBuiltins.cpp b/src/js/out/WebCoreJSBuiltins.cpp index 5ad79fa10..f20f626d4 100644 --- a/src/js/out/WebCoreJSBuiltins.cpp +++ b/src/js/out/WebCoreJSBuiltins.cpp @@ -372,7 +372,7 @@ const JSC::ConstructorKind s_writableStreamInternalsSetUpWritableStreamDefaultCo const JSC::ImplementationVisibility s_writableStreamInternalsSetUpWritableStreamDefaultControllerFromUnderlyingSinkCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_writableStreamInternalsSetUpWritableStreamDefaultControllerFromUnderlyingSinkCodeLength = 561; static const JSC::Intrinsic s_writableStreamInternalsSetUpWritableStreamDefaultControllerFromUnderlyingSinkCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_writableStreamInternalsSetUpWritableStreamDefaultControllerFromUnderlyingSinkCode = "(function (C,_,v,E,F){\"use strict\";const f=new @WritableStreamDefaultController;let p=()=>{},q=()=>{return @Promise.@resolve()},x=()=>{return @Promise.@resolve()},B=()=>{return @Promise.@resolve()};if(\"start\"in v){const P=v.start;p=()=>@promiseInvokeOrNoopMethodNoCatch(_,P,[f])}if(\"write\"in v){const P=v.write;q=(j)=>@promiseInvokeOrNoopMethod(_,P,[j,f])}if(\"close\"in v){const P=v.close;x=()=>@promiseInvokeOrNoopMethod(_,P,[])}if(\"abort\"in v){const P=v.abort;B=(j)=>@promiseInvokeOrNoopMethod(_,P,[j])}@setUpWritableStreamDefaultController(C,f,p,q,x,B,E,F)})\n"; +const char* const s_writableStreamInternalsSetUpWritableStreamDefaultControllerFromUnderlyingSinkCode = "(function (C,O,_,E,F){\"use strict\";const f=new @WritableStreamDefaultController;let q=()=>{},v=()=>{return @Promise.@resolve()},x=()=>{return @Promise.@resolve()},B=()=>{return @Promise.@resolve()};if(\"start\"in _){const p=_.start;q=()=>@promiseInvokeOrNoopMethodNoCatch(O,p,[f])}if(\"write\"in _){const p=_.write;v=(j)=>@promiseInvokeOrNoopMethod(O,p,[j,f])}if(\"close\"in _){const p=_.close;x=()=>@promiseInvokeOrNoopMethod(O,p,[])}if(\"abort\"in _){const p=_.abort;B=(j)=>@promiseInvokeOrNoopMethod(O,p,[j])}@setUpWritableStreamDefaultController(C,f,q,v,x,B,E,F)})\n"; // writableStreamDefaultControllerAdvanceQueueIfNeeded const JSC::ConstructAbility s_writableStreamInternalsWritableStreamDefaultControllerAdvanceQueueIfNeededCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -646,17 +646,17 @@ const char* const s_processObjectInternalsBindingCode = "(function (I){\"use str const JSC::ConstructAbility s_processObjectInternalsGetStdioWriteStreamCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; const JSC::ConstructorKind s_processObjectInternalsGetStdioWriteStreamCodeConstructorKind = JSC::ConstructorKind::None; const JSC::ImplementationVisibility s_processObjectInternalsGetStdioWriteStreamCodeImplementationVisibility = JSC::ImplementationVisibility::Public; -const int s_processObjectInternalsGetStdioWriteStreamCodeLength = 4250; +const int s_processObjectInternalsGetStdioWriteStreamCodeLength = 4311; static const JSC::Intrinsic s_processObjectInternalsGetStdioWriteStreamCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_processObjectInternalsGetStdioWriteStreamCode = "(function (Z,Y){\"use strict\";var P={path:\"node:process\",require:Y},L=(M)=>P.require(M);function A(M){var{Duplex:B,eos:j,destroy:z}=L(\"node:stream\"),J=class O extends B{#j;#$;#M=!0;#N=!0;#J;#z;#B;#G;#H;#K;get isTTY(){return this.#K\?\?=L(\"node:tty\").isatty(M)}get fd(){return M}constructor(G){super({readable:!0,writable:!0});this.#J=`/dev/fd/${G}`}#L(G){const H=this.#z;if(this.#z=null,H)H(G);else if(G)this.destroy(G);else if(!this.#M&&!this.#N)this.destroy()}_destroy(G,H){if(!G&&this.#z!==null){var N=class X extends Error{code;name;constructor(Q=\"The operation was aborted\",K=void 0){if(K!==void 0&&typeof K!==\"object\")throw new Error(`Invalid AbortError options:\\n\\n${JSON.stringify(K,null,2)}`);super(Q,K);this.code=\"ABORT_ERR\",this.name=\"AbortError\"}};G=new N}if(this.#B=null,this.#G=null,this.#z===null)H(G);else{if(this.#z=H,this.#j)z(this.#j,G);if(this.#$)z(this.#$,G)}}_write(G,H,N){if(!this.#j){var{createWriteStream:X}=L(\"node:fs\"),Q=this.#j=X(this.#J);Q.on(\"finish\",()=>{if(this.#G){const K=this.#G;this.#G=null,K()}}),Q.on(\"drain\",()=>{if(this.#B){const K=this.#B;this.#B=null,K()}}),j(Q,(K)=>{if(this.#N=!1,K)z(Q,K);this.#L(K)})}if(Q.write(G,H))N();else this.#B=N}_final(G){this.#j&&this.#j.end(),this.#G=G}#O(){var{createReadStream:G}=L(\"node:fs\"),H=this.#$=G(this.#J);return H.on(\"readable\",()=>{if(this.#H){const N=this.#H;this.#H=null,N()}else this.read()}),H.on(\"end\",()=>{this.push(null)}),j(H,(N)=>{if(this.#M=!1,N)z(H,N);this.#L(N)}),H}_read(){var G=this.#$;if(!G)G=this.#O();while(!0){const H=G.read();if(H===null||!this.push(H))return}}};return new J(M)}var{EventEmitter:T}=L(\"node:events\");function V(M){if(!M)return!0;var B=M.toLowerCase();return B===\"utf8\"||B===\"utf-8\"||B===\"buffer\"||B===\"binary\"}var U,x=class M extends T{#j;#$;#M;#N;bytesWritten=0;setDefaultEncoding(B){if(this.#$||!V(B))return this.#B(),this.#$.setDefaultEncoding(B)}#J(){switch(this.#j){case 1:{var B=@Bun.stdout.writer({highWaterMark:0});return B.unref(),B}case 2:{var B=@Bun.stderr.writer({highWaterMark:0});return B.unref(),B}default:throw new Error(\"Unsupported writer\")}}#z(){return this.#M\?\?=this.#J()}constructor(B){super();this.#j=B}get fd(){return this.#j}get isTTY(){return this.#N\?\?=L(\"node:tty\").isatty(this.#j)}cursorTo(B,j,z){return(U\?\?=L(\"readline\")).cursorTo(this,B,j,z)}moveCursor(B,j,z){return(U\?\?=L(\"readline\")).moveCursor(this,B,j,z)}clearLine(B,j){return(U\?\?=L(\"readline\")).clearLine(this,B,j)}clearScreenDown(B){return(U\?\?=L(\"readline\")).clearScreenDown(this,B)}ref(){this.#z().ref()}unref(){this.#z().unref()}on(B,j){if(B===\"close\"||B===\"finish\")return this.#B(),this.#$.on(B,j);if(B===\"drain\")return super.on(\"drain\",j);if(B===\"error\")return super.on(\"error\",j);return super.on(B,j)}get _writableState(){return this.#B(),this.#$._writableState}get _readableState(){return this.#B(),this.#$._readableState}pipe(B){return this.#B(),this.#$.pipe(B)}unpipe(B){return this.#B(),this.#$.unpipe(B)}#B(){if(this.#$)return;this.#$=A(this.#j);const B=this.eventNames();for(let j of B)this.#$.on(j,(...z)=>{this.emit(j,...z)})}#G(B){var j=this.#z();const z=j.write(B);this.bytesWritten+=z;const J=j.flush(!1);return!!(z||J)}#H(B,j){if(!V(j))return this.#B(),this.#$.write(B,j);return this.#G(B)}#K(B,j){if(j)this.emit(\"error\",j);try{B(j\?j:null)}catch(z){this.emit(\"error\",z)}}#L(B,j,z){if(!V(j))return this.#B(),this.#$.write(B,j,z);var J=this.#z();const O=J.write(B),G=J.flush(!0);if(G\?.then)return G.then(()=>{this.#K(z),this.emit(\"drain\")},(H)=>this.#K(z,H)),!1;return queueMicrotask(()=>{this.#K(z)}),!!(O||G)}write(B,j,z){const J=this._write(B,j,z);if(J)this.emit(\"drain\");return J}get hasColors(){return @Bun.tty[this.#j].hasColors}_write(B,j,z){var J=this.#$;if(J)return J.write(B,j,z);switch(arguments.length){case 0:{var O=new Error(\"Invalid arguments\");throw O.code=\"ERR_INVALID_ARG_TYPE\",O}case 1:return this.#G(B);case 2:if(typeof j===\"function\")return this.#L(B,\"\",j);else if(typeof j===\"string\")return this.#H(B,j);default:{if(typeof j!==\"undefined\"&&typeof j!==\"string\"||typeof z!==\"undefined\"&&typeof z!==\"function\"){var O=new Error(\"Invalid arguments\");throw O.code=\"ERR_INVALID_ARG_TYPE\",O}if(typeof z===\"undefined\")return this.#H(B,j);return this.#L(B,j,z)}}}destroy(){return this}end(){return this}};return new x(Z)})\n"; +const char* const s_processObjectInternalsGetStdioWriteStreamCode = "(function (Z){\"use strict\";var L=(M)=>{var G=@requireMap.get(M);if(G)return G.exports;return @internalRequire(M)},D={path:\"node:process\",require:L};function Y(M){var{Duplex:G,eos:j,destroy:z}=L(\"node:stream\"),J=class O extends G{#j;#$;#M=!0;#N=!0;#J;#z;#G;#B;#H;#K;get isTTY(){return this.#K\?\?=L(\"node:tty\").isatty(M)}get fd(){return M}constructor(B){super({readable:!0,writable:!0});this.#J=`/dev/fd/${B}`}#L(B){const H=this.#z;if(this.#z=null,H)H(B);else if(B)this.destroy(B);else if(!this.#M&&!this.#N)this.destroy()}_destroy(B,H){if(!B&&this.#z!==null){var N=class X extends Error{code;name;constructor(Q=\"The operation was aborted\",K=void 0){if(K!==void 0&&typeof K!==\"object\")throw new Error(`Invalid AbortError options:\\n\\n${JSON.stringify(K,null,2)}`);super(Q,K);this.code=\"ABORT_ERR\",this.name=\"AbortError\"}};B=new N}if(this.#G=null,this.#B=null,this.#z===null)H(B);else{if(this.#z=H,this.#j)z(this.#j,B);if(this.#$)z(this.#$,B)}}_write(B,H,N){if(!this.#j){var{createWriteStream:X}=L(\"node:fs\"),Q=this.#j=X(this.#J);Q.on(\"finish\",()=>{if(this.#B){const K=this.#B;this.#B=null,K()}}),Q.on(\"drain\",()=>{if(this.#G){const K=this.#G;this.#G=null,K()}}),j(Q,(K)=>{if(this.#N=!1,K)z(Q,K);this.#L(K)})}if(Q.write(B,H))N();else this.#G=N}_final(B){this.#j&&this.#j.end(),this.#B=B}#O(){var{createReadStream:B}=L(\"node:fs\"),H=this.#$=B(this.#J);return H.on(\"readable\",()=>{if(this.#H){const N=this.#H;this.#H=null,N()}else this.read()}),H.on(\"end\",()=>{this.push(null)}),j(H,(N)=>{if(this.#M=!1,N)z(H,N);this.#L(N)}),H}_read(){var B=this.#$;if(!B)B=this.#O();while(!0){const H=B.read();if(H===null||!this.push(H))return}}};return new J(M)}var{EventEmitter:P}=L(\"node:events\");function V(M){if(!M)return!0;var G=M.toLowerCase();return G===\"utf8\"||G===\"utf-8\"||G===\"buffer\"||G===\"binary\"}var U,A=class M extends P{#j;#$;#M;#N;bytesWritten=0;setDefaultEncoding(G){if(this.#$||!V(G))return this.#G(),this.#$.setDefaultEncoding(G)}#J(){switch(this.#j){case 1:{var G=@Bun.stdout.writer({highWaterMark:0});return G.unref(),G}case 2:{var G=@Bun.stderr.writer({highWaterMark:0});return G.unref(),G}default:throw new Error(\"Unsupported writer\")}}#z(){return this.#M\?\?=this.#J()}constructor(G){super();this.#j=G}get fd(){return this.#j}get isTTY(){return this.#N\?\?=L(\"node:tty\").isatty(this.#j)}cursorTo(G,j,z){return(U\?\?=L(\"readline\")).cursorTo(this,G,j,z)}moveCursor(G,j,z){return(U\?\?=L(\"readline\")).moveCursor(this,G,j,z)}clearLine(G,j){return(U\?\?=L(\"readline\")).clearLine(this,G,j)}clearScreenDown(G){return(U\?\?=L(\"readline\")).clearScreenDown(this,G)}ref(){this.#z().ref()}unref(){this.#z().unref()}on(G,j){if(G===\"close\"||G===\"finish\")return this.#G(),this.#$.on(G,j);if(G===\"drain\")return super.on(\"drain\",j);if(G===\"error\")return super.on(\"error\",j);return super.on(G,j)}get _writableState(){return this.#G(),this.#$._writableState}get _readableState(){return this.#G(),this.#$._readableState}pipe(G){return this.#G(),this.#$.pipe(G)}unpipe(G){return this.#G(),this.#$.unpipe(G)}#G(){if(this.#$)return;this.#$=Y(this.#j);const G=this.eventNames();for(let j of G)this.#$.on(j,(...z)=>{this.emit(j,...z)})}#B(G){var j=this.#z();const z=j.write(G);this.bytesWritten+=z;const J=j.flush(!1);return!!(z||J)}#H(G,j){if(!V(j))return this.#G(),this.#$.write(G,j);return this.#B(G)}#K(G,j){if(j)this.emit(\"error\",j);try{G(j\?j:null)}catch(z){this.emit(\"error\",z)}}#L(G,j,z){if(!V(j))return this.#G(),this.#$.write(G,j,z);var J=this.#z();const O=J.write(G),B=J.flush(!0);if(B\?.then)return B.then(()=>{this.#K(z),this.emit(\"drain\")},(H)=>this.#K(z,H)),!1;return queueMicrotask(()=>{this.#K(z)}),!!(O||B)}write(G,j,z){const J=this._write(G,j,z);if(J)this.emit(\"drain\");return J}get hasColors(){return @Bun.tty[this.#j].hasColors}_write(G,j,z){var J=this.#$;if(J)return J.write(G,j,z);switch(arguments.length){case 0:{var O=new Error(\"Invalid arguments\");throw O.code=\"ERR_INVALID_ARG_TYPE\",O}case 1:return this.#B(G);case 2:if(typeof j===\"function\")return this.#L(G,\"\",j);else if(typeof j===\"string\")return this.#H(G,j);default:{if(typeof j!==\"undefined\"&&typeof j!==\"string\"||typeof z!==\"undefined\"&&typeof z!==\"function\"){var O=new Error(\"Invalid arguments\");throw O.code=\"ERR_INVALID_ARG_TYPE\",O}if(typeof z===\"undefined\")return this.#H(G,j);return this.#L(G,j,z)}}}destroy(){return this}end(){return this}};return new A(Z)})\n"; // getStdinStream const JSC::ConstructAbility s_processObjectInternalsGetStdinStreamCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; const JSC::ConstructorKind s_processObjectInternalsGetStdinStreamCodeConstructorKind = JSC::ConstructorKind::None; const JSC::ImplementationVisibility s_processObjectInternalsGetStdinStreamCodeImplementationVisibility = JSC::ImplementationVisibility::Public; -const int s_processObjectInternalsGetStdinStreamCodeLength = 1799; +const int s_processObjectInternalsGetStdinStreamCodeLength = 1861; static const JSC::Intrinsic s_processObjectInternalsGetStdinStreamCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_processObjectInternalsGetStdinStreamCode = "(function (L,N,P){\"use strict\";var Q={path:\"node:process\",require:N},J=(K)=>Q.require(K),{Duplex:T,eos:U,destroy:M}=J(\"node:stream\"),V=class K extends T{#K;#j;#Y;#H=!0;#I=!1;#L=!0;#z;#$;#G;get isTTY(){return J(\"tty\").isatty(L)}get fd(){return L}constructor(){super({readable:!0,writable:!0})}#J(Y){const j=this.#$;if(this.#$=null,j)j(Y);else if(Y)this.destroy(Y);else if(!this.#H&&!this.#L)this.destroy()}_destroy(Y,j){if(!Y&&this.#$!==null){var z=class G extends Error{constructor(H=\"The operation was aborted\",I=void 0){if(I!==void 0&&typeof I!==\"object\")throw new Error(`Invalid AbortError options:\\n\\n${JSON.stringify(I,null,2)}`);super(H,I);this.code=\"ABORT_ERR\",this.name=\"AbortError\"}};Y=new z}if(this.#$===null)j(Y);else if(this.#$=j,this.#Y)M(this.#Y,Y)}setRawMode(Y){}on(Y,j){if(Y===\"readable\")this.ref(),this.#I=!0;return super.on(Y,j)}pause(){return this.unref(),super.pause()}resume(){return this.ref(),super.resume()}ref(){this.#K\?\?=P.stdin.stream().getReader(),this.#j\?\?=setInterval(()=>{},1<<30)}unref(){if(this.#j)clearInterval(this.#j),this.#j=null}async#M(){try{var Y,j;const z=this.#K.readMany();if(!z\?.then)({done:Y,value:j}=z);else({done:Y,value:j}=await z);if(!Y){this.push(j[0]);const G=j.length;for(let H=1;H{if(this.#z){const z=this.#z;this.#z=null,z()}}),j.on(\"drain\",()=>{if(this.#G){const z=this.#G;this.#G=null,z()}}),U(j,(z)=>{if(this.#L=!1,z)M(j,z);this.#J(z)}),j}_write(Y,j,z){var G=this.#Y;if(!G)G=this.#N();if(G.write(Y,j))z();else this.#G=z}_final(Y){this.#Y.end(),this.#z=(...j)=>Y(...j)}};return new V})\n"; +const char* const s_processObjectInternalsGetStdinStreamCode = "(function (K){\"use strict\";var H=(I)=>{var N=@requireMap.get(I);if(N)return N.exports;return @internalRequire(I)},T={path:\"node:process\",require:H},{Duplex:M,eos:P,destroy:L}=H(\"node:stream\"),Q=class I extends M{#J;#j;#$;#G=!0;#H=!1;#K=!0;#z;#N;#B;get isTTY(){return H(\"tty\").isatty(K)}get fd(){return K}constructor(){super({readable:!0,writable:!0})}#I(N){const j=this.#N;if(this.#N=null,j)j(N);else if(N)this.destroy(N);else if(!this.#G&&!this.#K)this.destroy()}_destroy(N,j){if(!N&&this.#N!==null){var z=class B extends Error{constructor(G=\"The operation was aborted\",J=void 0){if(J!==void 0&&typeof J!==\"object\")throw new Error(`Invalid AbortError options:\\n\\n${JSON.stringify(J,null,2)}`);super(G,J);this.code=\"ABORT_ERR\",this.name=\"AbortError\"}};N=new z}if(this.#N===null)j(N);else if(this.#N=j,this.#$)L(this.#$,N)}setRawMode(N){}on(N,j){if(N===\"readable\")this.ref(),this.#H=!0;return super.on(N,j)}pause(){return this.unref(),super.pause()}resume(){return this.ref(),super.resume()}ref(){this.#J\?\?=@Bun.stdin.stream().getReader(),this.#j\?\?=setInterval(()=>{},1<<30)}unref(){if(this.#j)clearInterval(this.#j),this.#j=null}async#L(){try{var N,j;const z=this.#J.readMany();if(!z\?.then)({done:N,value:j}=z);else({done:N,value:j}=await z);if(!N){this.push(j[0]);const B=j.length;for(let G=1;G{if(this.#z){const z=this.#z;this.#z=null,z()}}),j.on(\"drain\",()=>{if(this.#B){const z=this.#B;this.#B=null,z()}}),P(j,(z)=>{if(this.#K=!1,z)L(j,z);this.#I(z)}),j}_write(N,j,z){var B=this.#$;if(!B)B=this.#M();if(B.write(N,j))z();else this.#B=z}_final(N){this.#$.end(),this.#z=(...j)=>N(...j)}};return new Q})\n"; #define DEFINE_BUILTIN_GENERATOR(codeName, functionName, overriddenName, argumentCount) \ JSC::FunctionExecutable* codeName##Generator(JSC::VM& vm) \ @@ -2028,7 +2028,7 @@ const JSC::ConstructorKind s_readableStreamDefaultReaderReadManyCodeConstructorK const JSC::ImplementationVisibility s_readableStreamDefaultReaderReadManyCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_readableStreamDefaultReaderReadManyCodeLength = 2598; static const JSC::Intrinsic s_readableStreamDefaultReaderReadManyCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_readableStreamDefaultReaderReadManyCode = "(function (){\"use strict\";if(!@isReadableStreamDefaultReader(this))@throwTypeError(\"ReadableStreamDefaultReader.readMany() should not be called directly\");const k=@getByIdDirectPrivate(this,\"ownerReadableStream\");if(!k)@throwTypeError(\"readMany() called on a reader owned by no readable stream\");const H=@getByIdDirectPrivate(k,\"state\");if(@putByIdDirectPrivate(k,\"disturbed\",!0),H===@streamClosed)return{value:[],size:0,done:!0};else if(H===@streamErrored)throw @getByIdDirectPrivate(k,\"storedError\");var w=@getByIdDirectPrivate(k,\"readableStreamController\"),E=@getByIdDirectPrivate(w,\"queue\");if(!E)return w.@pull(w).@then(function({done:_,value:B}){return _\?{done:!0,value:[],size:0}:{value:[B],size:1,done:!1}});const N=E.content;var O=E.size,A=N.toArray(!1),C=A.length;if(C>0){var j=@newArrayWithSize(C);if(@isReadableByteStreamController(w)){{const _=A[0];if(!(@ArrayBuffer.@isView(_)||_ instanceof @ArrayBuffer))@putByValDirect(j,0,new @Uint8Array(_.buffer,_.byteOffset,_.byteLength));else @putByValDirect(j,0,_)}for(var d=1;d{if(_.done)return{value:[],size:0,done:!0};var B=@getByIdDirectPrivate(k,\"readableStreamController\"),F=@getByIdDirectPrivate(B,\"queue\"),x=[_.value].concat(F.content.toArray(!1)),K=x.length;if(@isReadableByteStreamController(B))for(var I=0;I0){var D=@newArrayWithSize(C);if(@isReadableByteStreamController(B)){{const _=x[0];if(!(@ArrayBuffer.@isView(_)||_ instanceof @ArrayBuffer))@putByValDirect(D,0,new @Uint8Array(_.buffer,_.byteOffset,_.byteLength));else @putByValDirect(D,0,_)}for(var d=1;d{if(_.done)return{value:[],size:0,done:!0};var w=@getByIdDirectPrivate(j,\"readableStreamController\"),G=@getByIdDirectPrivate(w,\"queue\"),k=[_.value].concat(G.content.toArray(!1)),K=k.length;if(@isReadableByteStreamController(w))for(var A=0;A0}shift(){var{_head:v,_tail:b,_list:g,_capacityMask:k}=this;if(v===b)return @undefined;var w=g[v];if(@putByValDirect(g,v,@undefined),v=this._head=v+1&k,v<2&&b>1e4&&b<=g.length>>>2)this._shrinkArray();return w}peek(){if(this._head===this._tail)return @undefined;return this._list[this._head]}push(v){var b=this._tail;if(@putByValDirect(this._list,b,v),this._tail=b+1&this._capacityMask,this._tail===this._head)this._growArray()}toArray(v){var b=this._list,g=@toLength(b.length);if(v||this._head>this._tail){var k=@toLength(this._head),w=@toLength(this._tail),F=@toLength(g-k+w),z=@newArrayWithSize(F),B=0;for(var x=k;x>>=1,this._capacityMask>>>=1}}return new A})\n"; +const char* const s_streamInternalsCreateFIFOCode = "(function (){\"use strict\";var E=@Array.prototype.slice;class A{constructor(){this._head=0,this._tail=0,this._capacityMask=3,this._list=@newArrayWithSize(4)}_head;_tail;_capacityMask;_list;size(){if(this._head===this._tail)return 0;if(this._head0}shift(){var{_head:g,_tail:b,_list:x,_capacityMask:M}=this;if(g===b)return @undefined;var w=x[g];if(@putByValDirect(x,g,@undefined),g=this._head=g+1&M,g<2&&b>1e4&&b<=x.length>>>2)this._shrinkArray();return w}peek(){if(this._head===this._tail)return @undefined;return this._list[this._head]}push(g){var b=this._tail;if(@putByValDirect(this._list,b,g),this._tail=b+1&this._capacityMask,this._tail===this._head)this._growArray()}toArray(g){var b=this._list,x=@toLength(b.length);if(g||this._head>this._tail){var M=@toLength(this._head),w=@toLength(this._tail),F=@toLength(x-M+w),z=@newArrayWithSize(F),B=0;for(var v=M;v>>=1,this._capacityMask>>>=1}}return new A})\n"; // newQueue const JSC::ConstructAbility s_streamInternalsNewQueueCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; diff --git a/src/js/out/WebCoreJSBuiltins.h b/src/js/out/WebCoreJSBuiltins.h index d00ae735e..42d14b154 100644 --- a/src/js/out/WebCoreJSBuiltins.h +++ b/src/js/out/WebCoreJSBuiltins.h @@ -1181,8 +1181,8 @@ extern const JSC::ImplementationVisibility s_processObjectInternalsGetStdinStrea #define WEBCORE_FOREACH_PROCESSOBJECTINTERNALS_BUILTIN_DATA(macro) \ macro(binding, processObjectInternalsBinding, 1) \ - macro(getStdioWriteStream, processObjectInternalsGetStdioWriteStream, 2) \ - macro(getStdinStream, processObjectInternalsGetStdinStream, 3) \ + macro(getStdioWriteStream, processObjectInternalsGetStdioWriteStream, 1) \ + macro(getStdinStream, processObjectInternalsGetStdinStream, 1) \ #define WEBCORE_FOREACH_PROCESSOBJECTINTERNALS_BUILTIN_CODE(macro) \ macro(processObjectInternalsBindingCode, binding, ASCIILiteral(), s_processObjectInternalsBindingCodeLength) \ -- cgit v1.2.3 From 2f5e4fffe9554fcc7afa6980b3af6b33bc3a3a5e Mon Sep 17 00:00:00 2001 From: Jarred Sumner Date: Sun, 9 Jul 2023 21:50:19 -0700 Subject: Implement process.memoryUsage() and process.cpuUsage() (#3586) * Implement process.memoryUsage() and process.cpuUsage() * Avoid mi_process_info * Update bench * Update Process.cpp * fixup * More tests + linux fixup * Skip it for now since it seems less accurate --------- Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com> --- bench/snippets/process-info.mjs | 33 ++ src/bun.js/bindings/Process.cpp | 388 ++++++++++++++++++++- src/bun.js/bindings/Process.h | 18 + src/bun.js/bindings/Process.lut.h | 97 +++--- .../bindings/webcore/DOMClientIsoSubspaces.h | 1 + src/bun.js/bindings/webcore/DOMIsoSubspaces.h | 1 + test/js/node/process/process.test.js | 142 +++++++- 7 files changed, 620 insertions(+), 60 deletions(-) create mode 100644 bench/snippets/process-info.mjs (limited to 'src/bun.js/bindings/Process.cpp') diff --git a/bench/snippets/process-info.mjs b/bench/snippets/process-info.mjs new file mode 100644 index 000000000..0366472e5 --- /dev/null +++ b/bench/snippets/process-info.mjs @@ -0,0 +1,33 @@ +import { bench, run } from "./runner.mjs"; +import { performance } from "perf_hooks"; + +bench("process.memoryUsage()", () => { + process.memoryUsage(); +}); + +bench("process.memoryUsage.rss()", () => { + process.memoryUsage.rss(); +}); + +bench("process.cpuUsage()", () => { + process.cpuUsage(); +}); + +const init = process.cpuUsage(); +bench("process.cpuUsage(delta)", () => { + process.cpuUsage(init); +}); + +bench("performance.now()", () => { + performance.now(); +}); + +bench("process.hrtime()", () => { + process.hrtime(); +}); + +bench("process.hrtime.bigint()", () => { + process.hrtime.bigint(); +}); + +await run(); diff --git a/src/bun.js/bindings/Process.cpp b/src/bun.js/bindings/Process.cpp index 8d94594cc..7d7bdd982 100644 --- a/src/bun.js/bindings/Process.cpp +++ b/src/bun.js/bindings/Process.cpp @@ -12,8 +12,24 @@ #include "ZigConsoleClient.h" #include #include +#include +#include +#include + #pragma mark - Node.js Process +#if defined(__APPLE__) +#include +#include +#endif + +#if defined(__linux__) +#include +#include +#include +#include +#endif + #if !defined(_MSC_VER) #include // setuid, getuid #endif @@ -335,9 +351,12 @@ extern "C" uint64_t Bun__readOriginTimer(void*); JSC_DEFINE_HOST_FUNCTION(Process_functionHRTime, (JSC::JSGlobalObject * globalObject_, JSC::CallFrame* callFrame)) { + Zig::GlobalObject* globalObject = reinterpret_cast(globalObject_); auto& vm = globalObject->vm(); + auto throwScope = DECLARE_THROW_SCOPE(vm); + uint64_t time = Bun__readOriginTimer(globalObject->bunVM()); int64_t seconds = static_cast(time / 1000000000); int64_t nanoseconds = time % 1000000000; @@ -346,7 +365,6 @@ JSC_DEFINE_HOST_FUNCTION(Process_functionHRTime, JSC::JSValue arg0 = callFrame->uncheckedArgument(0); if (!arg0.isUndefinedOrNull()) { JSArray* relativeArray = JSC::jsDynamicCast(arg0); - auto throwScope = DECLARE_THROW_SCOPE(vm); if ((!relativeArray && !arg0.isUndefinedOrNull()) || relativeArray->length() < 2) { JSC::throwTypeError(globalObject, throwScope, "hrtime() argument must be an array or undefined"_s); return JSC::JSValue::encode(JSC::JSValue {}); @@ -366,14 +384,28 @@ JSC_DEFINE_HOST_FUNCTION(Process_functionHRTime, seconds--; nanoseconds += 1000000000; } - throwScope.release(); } } - auto* array = JSArray::create(vm, globalObject->originalArrayStructureForIndexingType(ArrayWithContiguous), 2); - array->setIndexQuickly(vm, 0, JSC::jsNumber(seconds)); - array->setIndexQuickly(vm, 1, JSC::jsNumber(nanoseconds)); - return JSC::JSValue::encode(JSC::JSValue(array)); + JSC::JSArray* array = nullptr; + { + JSC::ObjectInitializationScope initializationScope(vm); + if ((array = JSC::JSArray::tryCreateUninitializedRestricted( + initializationScope, nullptr, + globalObject->arrayStructureForIndexingTypeDuringAllocation(JSC::ArrayWithContiguous), + 2))) { + + array->initializeIndex(initializationScope, 0, JSC::jsNumber(seconds)); + array->initializeIndex(initializationScope, 1, JSC::jsNumber(nanoseconds)); + } + } + + if (UNLIKELY(!array)) { + JSC::throwOutOfMemoryError(globalObject, throwScope); + return JSC::JSValue::encode(JSC::JSValue {}); + } + + RELEASE_AND_RETURN(throwScope, JSC::JSValue::encode(array)); } JSC_DEFINE_HOST_FUNCTION(Process_functionHRTimeBigInt, @@ -680,10 +712,10 @@ static JSValue constructProcessHrtimeObject(VM& vm, JSObject* processObject) { auto* globalObject = processObject->globalObject(); JSC::JSFunction* hrtime = JSC::JSFunction::create(vm, globalObject, 0, - MAKE_STATIC_STRING_IMPL("hrtime"), Process_functionHRTime, ImplementationVisibility::Public); + String("hrtime"_s), Process_functionHRTime, ImplementationVisibility::Public); JSC::JSFunction* hrtimeBigInt = JSC::JSFunction::create(vm, globalObject, 0, - MAKE_STATIC_STRING_IMPL("bigint"), Process_functionHRTimeBigInt, ImplementationVisibility::Public); + String("bigint"_s), Process_functionHRTimeBigInt, ImplementationVisibility::Public); hrtime->putDirect(vm, JSC::Identifier::fromString(vm, "bigint"_s), hrtimeBigInt); @@ -945,6 +977,317 @@ JSC_DEFINE_HOST_FUNCTION(Process_functionReallyExit, (JSGlobalObject * globalObj __builtin_unreachable(); } +template +void Process::visitChildrenImpl(JSCell* cell, Visitor& visitor) +{ + Process* thisObject = jsCast(cell); + ASSERT_GC_OBJECT_INHERITS(thisObject, info()); + Base::visitChildren(thisObject, visitor); + thisObject->cpuUsageStructure.visit(visitor); + thisObject->memoryUsageStructure.visit(visitor); +} + +DEFINE_VISIT_CHILDREN(Process); + +static Structure* constructCPUUsageStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject) +{ + JSC::Structure* structure = globalObject->structureCache().emptyObjectStructureForPrototype(globalObject, globalObject->objectPrototype(), 2); + PropertyOffset offset; + structure = structure->addPropertyTransition( + vm, + structure, + JSC::Identifier::fromString(vm, "user"_s), + 0, + offset); + structure = structure->addPropertyTransition( + vm, + structure, + JSC::Identifier::fromString(vm, "system"_s), + 0, + offset); + return structure; +} +static Structure* constructMemoryUsageStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject) +{ + JSC::Structure* structure = globalObject->structureCache().emptyObjectStructureForPrototype(globalObject, globalObject->objectPrototype(), 5); + PropertyOffset offset; + structure = structure->addPropertyTransition( + vm, + structure, + JSC::Identifier::fromString(vm, "rss"_s), + 0, + offset); + structure = structure->addPropertyTransition( + vm, + structure, + JSC::Identifier::fromString(vm, "heapTotal"_s), + 0, + offset); + structure = structure->addPropertyTransition( + vm, + structure, + JSC::Identifier::fromString(vm, "heapUsed"_s), + 0, + offset); + structure = structure->addPropertyTransition( + vm, + structure, + JSC::Identifier::fromString(vm, "external"_s), + 0, + offset); + structure = structure->addPropertyTransition( + vm, + structure, + JSC::Identifier::fromString(vm, "arrayBuffers"_s), + 0, + offset); + + return structure; +} + +static Process* getProcessObject(JSC::JSGlobalObject* lexicalGlobalObject, JSValue thisValue) +{ + Process* process = jsDynamicCast(thisValue); + + // Handle "var memoryUsage = process.memoryUsage; memoryUsage()" + if (UNLIKELY(!process)) { + // Handle calling this function from inside a node:vm + Zig::GlobalObject* zigGlobalObject = jsDynamicCast(lexicalGlobalObject); + + if (UNLIKELY(!zigGlobalObject)) { + zigGlobalObject = Bun__getDefaultGlobal(); + } + + return jsCast(zigGlobalObject->processObject()); + } + + return process; +} + +JSC_DEFINE_HOST_FUNCTION(Process_functionCpuUsage, + (JSC::JSGlobalObject * globalObject, JSC::CallFrame* callFrame)) +{ + JSC::VM& vm = globalObject->vm(); + auto throwScope = DECLARE_THROW_SCOPE(vm); + struct rusage rusage; + if (getrusage(RUSAGE_SELF, &rusage) != 0) { + SystemError error; + error.errno_ = errno; + error.syscall = Bun::toString("getrusage"_s); + error.message = Bun::toString("Failed to get CPU usage"_s); + throwException(globalObject, throwScope, JSValue::decode(SystemError__toErrorInstance(&error, globalObject))); + return JSValue::encode(jsUndefined()); + } + + auto* process = getProcessObject(globalObject, callFrame->thisValue()); + + Structure* cpuUsageStructure = process->cpuUsageStructure.getInitializedOnMainThread(process); + + constexpr double MICROS_PER_SEC = 1000000.0; + + double user = MICROS_PER_SEC * rusage.ru_utime.tv_sec + rusage.ru_utime.tv_usec; + double system = MICROS_PER_SEC * rusage.ru_stime.tv_sec + rusage.ru_stime.tv_usec; + + if (callFrame->argumentCount() > 0) { + JSValue comparatorValue = callFrame->argument(0); + if (!comparatorValue.isUndefined()) { + if (UNLIKELY(!comparatorValue.isObject())) { + throwTypeError(globalObject, throwScope, "Expected an object as the first argument"_s); + return JSC::JSValue::encode(JSC::jsUndefined()); + } + + JSC::JSObject* comparator = comparatorValue.getObject(); + JSValue userValue; + JSValue systemValue; + + if (LIKELY(comparator->structureID() == cpuUsageStructure->id())) { + userValue = comparator->getDirect(0); + systemValue = comparator->getDirect(1); + } else { + userValue = comparator->getIfPropertyExists(globalObject, JSC::Identifier::fromString(vm, "user"_s)); + RETURN_IF_EXCEPTION(throwScope, JSC::JSValue::encode(JSC::jsUndefined())); + + systemValue = comparator->getIfPropertyExists(globalObject, JSC::Identifier::fromString(vm, "system"_s)); + RETURN_IF_EXCEPTION(throwScope, JSC::JSValue::encode(JSC::jsUndefined())); + } + + if (UNLIKELY(!userValue || !userValue.isNumber())) { + throwTypeError(globalObject, throwScope, "Expected a number for the user property"_s); + return JSC::JSValue::encode(JSC::jsUndefined()); + } + + if (UNLIKELY(!systemValue || !systemValue.isNumber())) { + throwTypeError(globalObject, throwScope, "Expected a number for the system property"_s); + return JSC::JSValue::encode(JSC::jsUndefined()); + } + + double userComparator = userValue.asNumber(); + double systemComparator = systemValue.asNumber(); + + user -= userComparator; + system -= systemComparator; + } + } + + JSC::JSObject* result = JSC::constructEmptyObject(vm, cpuUsageStructure); + RETURN_IF_EXCEPTION(throwScope, JSC::JSValue::encode(JSC::jsUndefined())); + + result->putDirectOffset(vm, 0, JSC::jsNumber(user)); + result->putDirectOffset(vm, 1, JSC::jsNumber(system)); + + RELEASE_AND_RETURN(throwScope, JSC::JSValue::encode(result)); +} + +static int getRSS(size_t* rss) +{ +#if defined(__APPLE__) + mach_msg_type_number_t count; + task_basic_info_data_t info; + kern_return_t err; + + count = TASK_BASIC_INFO_COUNT; + err = task_info(mach_task_self(), + TASK_BASIC_INFO, + reinterpret_cast(&info), + &count); + + if (err == KERN_SUCCESS) { + *rss = (size_t)info.resident_size; + return 0; + } + + return -1; +#elif defined(__linux__) + // Taken from libuv. + char buf[1024]; + const char* s; + ssize_t n; + long val; + int fd; + int i; + + do + fd = open("/proc/self/stat", O_RDONLY); + while (fd == -1 && errno == EINTR); + + if (fd == -1) + return errno; + + do + n = read(fd, buf, sizeof(buf) - 1); + while (n == -1 && errno == EINTR); + + int closeErrno = 0; + do { + closeErrno = close(fd); + } while (closeErrno == -1 && errno == EINTR); + + if (n == -1) + return errno; + buf[n] = '\0'; + + s = strchr(buf, ' '); + if (s == NULL) + goto err; + + s += 1; + if (*s != '(') + goto err; + + s = strchr(s, ')'); + if (s == NULL) + goto err; + + for (i = 1; i <= 22; i++) { + s = strchr(s + 1, ' '); + if (s == NULL) + goto err; + } + + errno = 0; + val = strtol(s, NULL, 10); + if (errno != 0) + goto err; + if (val < 0) + goto err; + + *rss = val * getpagesize(); + return 0; + +err: + return EINVAL; +#else +#error "Unsupported platform" +#endif +} + +JSC_DEFINE_HOST_FUNCTION(Process_functionMemoryUsage, + (JSC::JSGlobalObject * globalObject, JSC::CallFrame* callFrame)) +{ + JSC::VM& vm = globalObject->vm(); + auto throwScope = DECLARE_THROW_SCOPE(vm); + auto* process = getProcessObject(globalObject, callFrame->thisValue()); + + size_t current_rss = 0; + if (getRSS(¤t_rss) != 0) { + SystemError error; + error.errno_ = errno; + error.syscall = Bun::toString("memoryUsage"_s); + error.message = Bun::toString("Failed to get memory usage"_s); + throwException(globalObject, throwScope, JSValue::decode(SystemError__toErrorInstance(&error, globalObject))); + return JSC::JSValue::encode(JSC::JSValue {}); + } + + JSC::JSObject* result = JSC::constructEmptyObject(vm, process->memoryUsageStructure.getInitializedOnMainThread(process)); + if (UNLIKELY(throwScope.exception())) { + return JSC::JSValue::encode(JSC::JSValue {}); + } + + // Node.js: + // { + // rss: 4935680, + // heapTotal: 1826816, + // heapUsed: 650472, + // external: 49879, + // arrayBuffers: 9386 + // } + + result->putDirectOffset(vm, 0, JSC::jsNumber(current_rss)); + result->putDirectOffset(vm, 1, JSC::jsNumber(vm.heap.blockBytesAllocated())); + + // heap.size() loops through every cell... + // TODO: add a binding for heap.sizeAfterLastCollection() + result->putDirectOffset(vm, 2, JSC::jsNumber(vm.heap.sizeAfterLastEdenCollection())); + + result->putDirectOffset(vm, 3, JSC::jsNumber(vm.heap.externalMemorySize())); + + // We report 0 for this because m_arrayBuffers in JSC::Heap is private and we need to add a binding + // If we use objectTypeCounts(), it's hideously slow because it loops through every single object in the heap + // TODO: add a binding for m_arrayBuffers, registerWrapper() in TypedArrayController doesn't work + result->putDirectOffset(vm, 4, JSC::jsNumber(0)); + + RELEASE_AND_RETURN(throwScope, JSC::JSValue::encode(result)); +} + +JSC_DEFINE_HOST_FUNCTION(Process_functionMemoryUsageRSS, + (JSC::JSGlobalObject * globalObject, JSC::CallFrame* callFrame)) +{ + JSC::VM& vm = globalObject->vm(); + auto throwScope = DECLARE_THROW_SCOPE(vm); + + size_t current_rss = 0; + if (getRSS(¤t_rss) != 0) { + SystemError error; + error.errno_ = errno; + error.syscall = Bun::toString("memoryUsage"_s); + error.message = Bun::toString("Failed to get memory usage"_s); + throwException(globalObject, throwScope, JSValue::decode(SystemError__toErrorInstance(&error, globalObject))); + return JSC::JSValue::encode(JSC::JSValue {}); + } + + RELEASE_AND_RETURN(throwScope, JSValue::encode(jsNumber(current_rss))); +} + JSC_DEFINE_HOST_FUNCTION(Process_functionOpenStdin, (JSGlobalObject * globalObject, CallFrame* callFrame)) { auto& vm = globalObject->vm(); @@ -1010,6 +1353,19 @@ static JSValue Process_stubEmptySet(VM& vm, JSObject* processObject) return JSSet::create(vm, globalObject->setStructure()); } +static JSValue constructMemoryUsage(VM& vm, JSObject* processObject) +{ + auto* globalObject = processObject->globalObject(); + JSC::JSFunction* memoryUsage = JSC::JSFunction::create(vm, globalObject, 0, + String("memoryUsage"_s), Process_functionMemoryUsage, ImplementationVisibility::Public); + + JSC::JSFunction* rss = JSC::JSFunction::create(vm, globalObject, 0, + String("rss"_s), Process_functionMemoryUsageRSS, ImplementationVisibility::Public); + + memoryUsage->putDirect(vm, JSC::Identifier::fromString(vm, "rss"_s), rss, JSC::PropertyAttribute::Function | 0); + return memoryUsage; +} + static JSValue constructFeatures(VM& vm, JSObject* processObject) { // { @@ -1133,16 +1489,16 @@ JSC_DEFINE_HOST_FUNCTION(Process_functionCwd, browser constructBrowser PropertyCallback chdir Process_functionChdir Function 1 config constructProcessConfigObject PropertyCallback - debugPort processDebugPort CustomAccessor - exitCode processExitCode CustomAccessor - title processTitle CustomAccessor + cpuUsage Process_functionCpuUsage Function 1 cwd Process_functionCwd Function 1 + debugPort processDebugPort CustomAccessor dlopen Process_functionDlopen Function 1 emitWarning Process_emitWarning Function 1 env constructEnv PropertyCallback execArgv constructExecArgv PropertyCallback execPath constructExecPath PropertyCallback exit Process_functionExit Function 1 + exitCode processExitCode CustomAccessor features constructFeatures PropertyCallback getActiveResourcesInfo Process_stubFunctionReturningArray Function 0 getegid Process_functiongetegid Function 0 @@ -1153,6 +1509,7 @@ JSC_DEFINE_HOST_FUNCTION(Process_functionCwd, hrtime constructProcessHrtimeObject PropertyCallback isBun constructIsBun PropertyCallback mainModule JSBuiltin ReadOnly|Builtin|Accessor|Function 0 + memoryUsage constructMemoryUsage PropertyCallback moduleLoadList Process_stubEmptyArray PropertyCallback nextTick Process_functionNextTick Function 1 openStdin Process_functionOpenStdin Function 0 @@ -1166,6 +1523,7 @@ JSC_DEFINE_HOST_FUNCTION(Process_functionCwd, stderr constructStderr PropertyCallback stdin constructStdin PropertyCallback stdout constructStdout PropertyCallback + title processTitle CustomAccessor umask Process_functionUmask Function 1 uptime Process_functionUptime Function 1 version constructVersion PropertyCallback @@ -1192,6 +1550,14 @@ void Process::finishCreation(JSC::VM& vm) { Base::finishCreation(vm); + this->cpuUsageStructure.initLater([](const JSC::LazyProperty::Initializer& init) { + init.set(constructCPUUsageStructure(init.vm, init.owner->globalObject())); + }); + + this->memoryUsageStructure.initLater([](const JSC::LazyProperty::Initializer& init) { + init.set(constructMemoryUsageStructure(init.vm, init.owner->globalObject())); + }); + this->putDirect(vm, vm.propertyNames->toStringTagSymbol, jsString(vm, String("process"_s)), 0); } diff --git a/src/bun.js/bindings/Process.h b/src/bun.js/bindings/Process.h index 8b703b8b1..fbad9b1ff 100644 --- a/src/bun.js/bindings/Process.h +++ b/src/bun.js/bindings/Process.h @@ -45,6 +45,24 @@ public: return accessor; } + LazyProperty cpuUsageStructure; + LazyProperty memoryUsageStructure; + + DECLARE_VISIT_CHILDREN; + + template + static JSC::GCClient::IsoSubspace* subspaceFor(JSC::VM& vm) + { + if constexpr (mode == JSC::SubspaceAccess::Concurrently) + return nullptr; + return WebCore::subspaceForImpl( + vm, + [](auto& spaces) { return spaces.m_clientSubspaceForProcessObject.get(); }, + [](auto& spaces, auto&& space) { spaces.m_clientSubspaceForProcessObject = std::forward(space); }, + [](auto& spaces) { return spaces.m_subspaceForProcessObject.get(); }, + [](auto& spaces, auto&& space) { spaces.m_subspaceForProcessObject = std::forward(space); }); + } + void finishCreation(JSC::VM& vm); }; diff --git a/src/bun.js/bindings/Process.lut.h b/src/bun.js/bindings/Process.lut.h index 5c0bd2c5a..81eb1b7b9 100644 --- a/src/bun.js/bindings/Process.lut.h +++ b/src/bun.js/bindings/Process.lut.h @@ -1,6 +1,6 @@ // File generated via `make generate-builtins` -static const struct CompactHashIndex processObjectTableIndex[141] = { - { 42, -1 }, +static const struct CompactHashIndex processObjectTableIndex[142] = { + { 43, -1 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, @@ -11,12 +11,12 @@ static const struct CompactHashIndex processObjectTableIndex[141] = { { -1, -1 }, { -1, -1 }, { -1, -1 }, - { 16, 130 }, + { 15, 129 }, { -1, -1 }, { -1, -1 }, - { 19, 137 }, + { 18, 138 }, { -1, -1 }, - { 43, -1 }, + { 45, -1 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, @@ -33,37 +33,37 @@ static const struct CompactHashIndex processObjectTableIndex[141] = { { -1, -1 }, { -1, -1 }, { -1, -1 }, - { 3, 140 }, + { 3, 141 }, { 1, 128 }, { -1, -1 }, - { 57, -1 }, - { -1, -1 }, + { 59, -1 }, { -1, -1 }, + { 10, -1 }, { -1, -1 }, { -1, -1 }, - { 30, -1 }, + { 31, -1 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, - { 50, -1 }, + { 52, -1 }, { 27, -1 }, - { 10, -1 }, + { 12, -1 }, { -1, -1 }, - { 11, -1 }, + { 19, -1 }, { -1, -1 }, - { 15, 136 }, + { 14, 137 }, { -1, -1 }, - { 35, -1 }, + { 36, -1 }, { -1, -1 }, - { 37, -1 }, - { 53, -1 }, - { 34, -1 }, - { 6, 138 }, + { 38, -1 }, + { 55, -1 }, + { 35, -1 }, + { 6, 139 }, { -1, -1 }, - { 49, -1 }, + { 51, -1 }, { 4, -1 }, - { 45, -1 }, + { 47, -1 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, @@ -75,23 +75,23 @@ static const struct CompactHashIndex processObjectTableIndex[141] = { { -1, -1 }, { -1, -1 }, { -1, -1 }, - { 39, -1 }, + { 40, -1 }, { -1, -1 }, - { 36, -1 }, + { 37, -1 }, { -1, -1 }, { 0, -1 }, - { 12, 129 }, - { 17, 131 }, - { 38, -1 }, + { 26, 135 }, + { 16, 130 }, + { 39, -1 }, { -1, -1 }, { 23, -1 }, - { 13, -1 }, + { 11, -1 }, { -1, -1 }, { -1, -1 }, - { 56, -1 }, + { 58, -1 }, { -1, -1 }, { -1, -1 }, - { 47, -1 }, + { 30, 136 }, { -1, -1 }, { 29, -1 }, { 22, -1 }, @@ -105,45 +105,46 @@ static const struct CompactHashIndex processObjectTableIndex[141] = { { 5, -1 }, { -1, -1 }, { -1, -1 }, - { 46, -1 }, + { 48, -1 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, - { 14, 132 }, + { 13, 131 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, { 9, -1 }, - { 25, 134 }, + { 25, 133 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, - { 21, 135 }, + { 21, 134 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, - { 44, 139 }, + { 46, 140 }, { -1, -1 }, - { 18, -1 }, + { 17, -1 }, { 8, -1 }, - { 26, -1 }, { 28, -1 }, - { 31, 133 }, - { 32, -1 }, + { 32, 132 }, { 33, -1 }, - { 40, -1 }, + { 34, -1 }, { 41, -1 }, - { 48, -1 }, - { 51, -1 }, - { 52, -1 }, + { 42, -1 }, + { 44, -1 }, + { 49, -1 }, + { 50, -1 }, + { 53, -1 }, { 54, -1 }, - { 55, -1 }, + { 56, -1 }, + { 57, -1 }, }; -static const struct HashTableValue processObjectTableValues[58] = { +static const struct HashTableValue processObjectTableValues[60] = { { "abort"_s, static_cast(PropertyAttribute::Function), NoIntrinsic, { HashTableValue::NativeFunctionType, Process_functionAbort, 1 } }, { "allowedNodeEnvironmentFlags"_s, static_cast(PropertyAttribute::PropertyCallback), NoIntrinsic, { HashTableValue::LazyPropertyType, Process_stubEmptySet } }, { "arch"_s, static_cast(PropertyAttribute::PropertyCallback), NoIntrinsic, { HashTableValue::LazyPropertyType, constructArch } }, @@ -154,16 +155,16 @@ static const struct HashTableValue processObjectTableValues[58] = { { "browser"_s, static_cast(PropertyAttribute::PropertyCallback), NoIntrinsic, { HashTableValue::LazyPropertyType, constructBrowser } }, { "chdir"_s, static_cast(PropertyAttribute::Function), NoIntrinsic, { HashTableValue::NativeFunctionType, Process_functionChdir, 1 } }, { "config"_s, static_cast(PropertyAttribute::PropertyCallback), NoIntrinsic, { HashTableValue::LazyPropertyType, constructProcessConfigObject } }, - { "debugPort"_s, static_cast(PropertyAttribute::CustomAccessor), NoIntrinsic, { HashTableValue::GetterSetterType, processDebugPort, setProcessDebugPort } }, - { "exitCode"_s, static_cast(PropertyAttribute::CustomAccessor), NoIntrinsic, { HashTableValue::GetterSetterType, processExitCode, setProcessExitCode } }, - { "title"_s, static_cast(PropertyAttribute::CustomAccessor), NoIntrinsic, { HashTableValue::GetterSetterType, processTitle, setProcessTitle } }, + { "cpuUsage"_s, static_cast(PropertyAttribute::Function), NoIntrinsic, { HashTableValue::NativeFunctionType, Process_functionCpuUsage, 1 } }, { "cwd"_s, static_cast(PropertyAttribute::Function), NoIntrinsic, { HashTableValue::NativeFunctionType, Process_functionCwd, 1 } }, + { "debugPort"_s, static_cast(PropertyAttribute::CustomAccessor), NoIntrinsic, { HashTableValue::GetterSetterType, processDebugPort, setProcessDebugPort } }, { "dlopen"_s, static_cast(PropertyAttribute::Function), NoIntrinsic, { HashTableValue::NativeFunctionType, Process_functionDlopen, 1 } }, { "emitWarning"_s, static_cast(PropertyAttribute::Function), NoIntrinsic, { HashTableValue::NativeFunctionType, Process_emitWarning, 1 } }, { "env"_s, static_cast(PropertyAttribute::PropertyCallback), NoIntrinsic, { HashTableValue::LazyPropertyType, constructEnv } }, { "execArgv"_s, static_cast(PropertyAttribute::PropertyCallback), NoIntrinsic, { HashTableValue::LazyPropertyType, constructExecArgv } }, { "execPath"_s, static_cast(PropertyAttribute::PropertyCallback), NoIntrinsic, { HashTableValue::LazyPropertyType, constructExecPath } }, { "exit"_s, static_cast(PropertyAttribute::Function), NoIntrinsic, { HashTableValue::NativeFunctionType, Process_functionExit, 1 } }, + { "exitCode"_s, static_cast(PropertyAttribute::CustomAccessor), NoIntrinsic, { HashTableValue::GetterSetterType, processExitCode, setProcessExitCode } }, { "features"_s, static_cast(PropertyAttribute::PropertyCallback), NoIntrinsic, { HashTableValue::LazyPropertyType, constructFeatures } }, { "getActiveResourcesInfo"_s, static_cast(PropertyAttribute::Function), NoIntrinsic, { HashTableValue::NativeFunctionType, Process_stubFunctionReturningArray, 0 } }, { "getegid"_s, static_cast(PropertyAttribute::Function), NoIntrinsic, { HashTableValue::NativeFunctionType, Process_functiongetegid, 0 } }, @@ -174,6 +175,7 @@ static const struct HashTableValue processObjectTableValues[58] = { { "hrtime"_s, static_cast(PropertyAttribute::PropertyCallback), NoIntrinsic, { HashTableValue::LazyPropertyType, constructProcessHrtimeObject } }, { "isBun"_s, static_cast(PropertyAttribute::PropertyCallback), NoIntrinsic, { HashTableValue::LazyPropertyType, constructIsBun } }, { "mainModule"_s, ((static_cast(PropertyAttribute::ReadOnly|PropertyAttribute::Builtin|PropertyAttribute::Accessor|PropertyAttribute::Function)) & ~PropertyAttribute::Function) | PropertyAttribute::Builtin, NoIntrinsic, { HashTableValue::BuiltinGeneratorType, processObjectMainModuleCodeGenerator, 0 } }, + { "memoryUsage"_s, static_cast(PropertyAttribute::PropertyCallback), NoIntrinsic, { HashTableValue::LazyPropertyType, constructMemoryUsage } }, { "moduleLoadList"_s, static_cast(PropertyAttribute::PropertyCallback), NoIntrinsic, { HashTableValue::LazyPropertyType, Process_stubEmptyArray } }, { "nextTick"_s, static_cast(PropertyAttribute::Function), NoIntrinsic, { HashTableValue::NativeFunctionType, Process_functionNextTick, 1 } }, { "openStdin"_s, static_cast(PropertyAttribute::Function), NoIntrinsic, { HashTableValue::NativeFunctionType, Process_functionOpenStdin, 0 } }, @@ -187,6 +189,7 @@ static const struct HashTableValue processObjectTableValues[58] = { { "stderr"_s, static_cast(PropertyAttribute::PropertyCallback), NoIntrinsic, { HashTableValue::LazyPropertyType, constructStderr } }, { "stdin"_s, static_cast(PropertyAttribute::PropertyCallback), NoIntrinsic, { HashTableValue::LazyPropertyType, constructStdin } }, { "stdout"_s, static_cast(PropertyAttribute::PropertyCallback), NoIntrinsic, { HashTableValue::LazyPropertyType, constructStdout } }, + { "title"_s, static_cast(PropertyAttribute::CustomAccessor), NoIntrinsic, { HashTableValue::GetterSetterType, processTitle, setProcessTitle } }, { "umask"_s, static_cast(PropertyAttribute::Function), NoIntrinsic, { HashTableValue::NativeFunctionType, Process_functionUmask, 1 } }, { "uptime"_s, static_cast(PropertyAttribute::Function), NoIntrinsic, { HashTableValue::NativeFunctionType, Process_functionUptime, 1 } }, { "version"_s, static_cast(PropertyAttribute::PropertyCallback), NoIntrinsic, { HashTableValue::LazyPropertyType, constructVersion } }, @@ -205,4 +208,4 @@ static const struct HashTableValue processObjectTableValues[58] = { }; static const struct HashTable processObjectTable = - { 58, 127, true, nullptr, processObjectTableValues, processObjectTableIndex }; + { 60, 127, true, nullptr, processObjectTableValues, processObjectTableIndex }; diff --git a/src/bun.js/bindings/webcore/DOMClientIsoSubspaces.h b/src/bun.js/bindings/webcore/DOMClientIsoSubspaces.h index 65875d091..82a2c6a24 100644 --- a/src/bun.js/bindings/webcore/DOMClientIsoSubspaces.h +++ b/src/bun.js/bindings/webcore/DOMClientIsoSubspaces.h @@ -38,6 +38,7 @@ public: std::unique_ptr m_clientSubspaceForJSMockImplementation; std::unique_ptr m_clientSubspaceForJSMockFunction; std::unique_ptr m_clientSubspaceForMockWithImplementationCleanupData; + std::unique_ptr m_clientSubspaceForProcessObject; #include "ZigGeneratedClasses+DOMClientIsoSubspaces.h" /* --- bun --- */ diff --git a/src/bun.js/bindings/webcore/DOMIsoSubspaces.h b/src/bun.js/bindings/webcore/DOMIsoSubspaces.h index 433832450..f1b290d25 100644 --- a/src/bun.js/bindings/webcore/DOMIsoSubspaces.h +++ b/src/bun.js/bindings/webcore/DOMIsoSubspaces.h @@ -38,6 +38,7 @@ public: std::unique_ptr m_subspaceForJSMockImplementation; std::unique_ptr m_subspaceForJSMockFunction; std::unique_ptr m_subspaceForMockWithImplementationCleanupData; + std::unique_ptr m_subspaceForProcessObject; #include "ZigGeneratedClasses+DOMIsoSubspaces.h" /*-- BUN --*/ diff --git a/test/js/node/process/process.test.js b/test/js/node/process/process.test.js index c4701f664..e038383de 100644 --- a/test/js/node/process/process.test.js +++ b/test/js/node/process/process.test.js @@ -162,7 +162,8 @@ it("process.umask()", () => { expect(process.umask()).toBe(orig); }); -const versions = existsSync(import.meta.dir + "/../../src/generated_versions_list.zig"); +const generated_versions_list = join(import.meta.dir, "../../../../src/generated_versions_list.zig"); +const versions = existsSync(generated_versions_list); (versions ? it : it.skip)("process.versions", () => { // Generate a list of all the versions in the versions object // example: @@ -178,7 +179,7 @@ const versions = existsSync(import.meta.dir + "/../../src/generated_versions_lis // pub const c_ares = "0e7a5dee0fbb04080750cf6eabbe89d8bae87faa"; // pub const usockets = "fafc241e8664243fc0c51d69684d5d02b9805134"; const versions = Object.fromEntries( - readFileSync(import.meta.dir + "/../../src/generated_versions_list.zig", "utf8") + readFileSync(generated_versions_list, "utf8") .split("\n") .filter(line => line.startsWith("pub const") && !line.includes("zig") && line.includes(' = "')) .map(line => line.split(" = ")) @@ -291,3 +292,140 @@ describe("process.onBeforeExit", () => { expect(stdout.toString().trim()).toBe("beforeExit: 0\nbeforeExit: 1\nexit: 2"); }); }); + +it("process.memoryUsage", () => { + expect(process.memoryUsage()).toEqual({ + rss: expect.any(Number), + heapTotal: expect.any(Number), + heapUsed: expect.any(Number), + external: expect.any(Number), + arrayBuffers: expect.any(Number), + }); +}); + +it("process.memoryUsage.rss", () => { + expect(process.memoryUsage.rss()).toEqual(expect.any(Number)); +}); + +describe("process.cpuUsage", () => { + it("works", () => { + expect(process.cpuUsage()).toEqual({ + user: expect.any(Number), + system: expect.any(Number), + }); + }); + + it("works with diff", () => { + const init = process.cpuUsage(); + for (let i = 0; i < 1000; i++) {} + const delta = process.cpuUsage(init); + expect(delta.user).toBeGreaterThan(0); + expect(delta.system).toBeGreaterThan(0); + }); + + it("works with diff of different structure", () => { + const init = { + user: 0, + system: 0, + }; + for (let i = 0; i < 1000; i++) {} + const delta = process.cpuUsage(init); + expect(delta.user).toBeGreaterThan(0); + expect(delta.system).toBeGreaterThan(0); + }); + + it("throws on invalid property", () => { + const fixtures = [ + {}, + { user: null }, + { user: {} }, + { user: "potato" }, + + { user: 123 }, + { user: 123, system: null }, + { user: 123, system: "potato" }, + ]; + for (const fixture of fixtures) { + expect(() => process.cpuUsage(fixture)).toThrow(); + } + }); + + // Skipped on Linux because it seems to not change as often as on macOS + it.skipIf(process.platform === "linux")("increases monotonically", () => { + const init = process.cpuUsage(); + for (let i = 0; i < 10000; i++) {} + const another = process.cpuUsage(); + expect(another.user).toBeGreaterThan(init.user); + expect(another.system).toBeGreaterThan(init.system); + }); +}); + +it("process.getegid", () => { + expect(typeof process.getegid()).toBe("number"); +}); +it("process.geteuid", () => { + expect(typeof process.geteuid()).toBe("number"); +}); +it("process.getgid", () => { + expect(typeof process.getgid()).toBe("number"); +}); +it("process.getgroups", () => { + expect(process.getgroups()).toBeInstanceOf(Array); + expect(process.getgroups().length).toBeGreaterThan(0); +}); +it("process.getuid", () => { + expect(typeof process.getuid()).toBe("number"); +}); + +it("process.getuid", () => { + expect(typeof process.getuid()).toBe("number"); +}); + +const undefinedStubs = [ + "_debugEnd", + "_debugProcess", + "_fatalException", + "_linkedBinding", + "_rawDebug", + "_startProfilerIdleNotifier", + "_stopProfilerIdleNotifier", + "_tickCallback", +]; + +for (const stub of undefinedStubs) { + it(`process.${stub}`, () => { + expect(process[stub]()).toBeUndefined(); + }); +} + +const arrayStubs = ["getActiveResourcesInfo", "_getActiveRequests", "_getActiveHandles"]; + +for (const stub of arrayStubs) { + it(`process.${stub}`, () => { + expect(process[stub]()).toBeInstanceOf(Array); + }); +} + +const emptyObjectStubs = ["_preload_modules"]; +const emptySetStubs = ["allowedNodeEnvironmentFlags"]; +const emptyArrayStubs = ["moduleLoadList"]; + +for (const stub of emptyObjectStubs) { + it(`process.${stub}`, () => { + expect(process[stub]).toEqual({}); + }); +} + +for (const stub of emptySetStubs) { + it(`process.${stub}`, () => { + expect(process[stub]).toBeInstanceOf(Set); + expect(process[stub].size).toBe(0); + }); +} + +for (const stub of emptyArrayStubs) { + it(`process.${stub}`, () => { + expect(process[stub]).toBeInstanceOf(Array); + expect(process[stub]).toHaveLength(0); + }); +} -- cgit v1.2.3 From 5c8726d602fe73e49d027194fef65b9432872c8b Mon Sep 17 00:00:00 2001 From: Dylan Conway <35280289+dylan-conway@users.noreply.github.com> Date: Tue, 11 Jul 2023 12:48:46 -0700 Subject: process signal events (#3569) * signal events * simple tests * ignore SIGSTOP * better tests * use `EventEmitter` * use `Bun__getDefaultGlobal` * progress * don't use 'Bun__getDefaultGlobal` * fix tests * remove signals from map * update tests * don't overwrite event emitter methods * avoid two lookups * use `std::once` * releaseEarly() * Remove signal handler after use * Update call-raise.js * Create process-signal-handler.fixture.js * Don't register duplicates * Add missing lock * another test * update test * revert some changes --------- Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com> --- src/bun.js/bindings/JSBundlerPlugin.cpp | 3 +- src/bun.js/bindings/Process.cpp | 290 +++++++++++++++------ src/bun.js/bindings/Process.h | 2 + src/bun.js/bindings/ScriptExecutionContext.cpp | 6 + src/bun.js/bindings/ScriptExecutionContext.h | 8 +- src/bun.js/bindings/webcore/EventEmitter.cpp | 7 + src/bun.js/bindings/webcore/EventEmitter.h | 6 +- src/bun.js/bindings/webcore/JSEventEmitter.cpp | 15 +- src/bun.js/bindings/webcore/JSEventEmitter.h | 3 + test/js/node/process/call-raise.js | 15 ++ .../node/process/process-signal-handler.fixture.js | 63 +++++ test/js/node/process/process.test.js | 26 +- 12 files changed, 352 insertions(+), 92 deletions(-) create mode 100644 test/js/node/process/call-raise.js create mode 100644 test/js/node/process/process-signal-handler.fixture.js (limited to 'src/bun.js/bindings/Process.cpp') diff --git a/src/bun.js/bindings/JSBundlerPlugin.cpp b/src/bun.js/bindings/JSBundlerPlugin.cpp index d55c5fc2e..ec3933574 100644 --- a/src/bun.js/bindings/JSBundlerPlugin.cpp +++ b/src/bun.js/bindings/JSBundlerPlugin.cpp @@ -157,7 +157,8 @@ public: JSC::LazyProperty setupFunction; private: - JSBundlerPlugin(JSC::VM& vm, JSC::JSGlobalObject*, JSC::Structure* structure, void* config, BunPluginTarget target, JSBundlerPluginAddErrorCallback addError, JSBundlerPluginOnLoadAsyncCallback onLoadAsync, JSBundlerPluginOnResolveAsyncCallback onResolveAsync) + JSBundlerPlugin(JSC::VM& vm, JSC::JSGlobalObject*, JSC::Structure* structure, void* config, BunPluginTarget target, + JSBundlerPluginAddErrorCallback addError, JSBundlerPluginOnLoadAsyncCallback onLoadAsync, JSBundlerPluginOnResolveAsyncCallback onResolveAsync) : JSC::JSNonFinalObject(vm, structure) , plugin(BundlerPlugin(config, target, addError, onLoadAsync, onResolveAsync)) { diff --git a/src/bun.js/bindings/Process.cpp b/src/bun.js/bindings/Process.cpp index 7d7bdd982..f9fb85b95 100644 --- a/src/bun.js/bindings/Process.cpp +++ b/src/bun.js/bindings/Process.cpp @@ -437,91 +437,215 @@ JSC_DEFINE_HOST_FUNCTION(Process_functionChdir, return JSC::JSValue::encode(result); } -// static const NeverDestroyed signalNames[] = { -// MAKE_STATIC_STRING_IMPL("SIGHUP"), -// MAKE_STATIC_STRING_IMPL("SIGINT"), -// MAKE_STATIC_STRING_IMPL("SIGQUIT"), -// MAKE_STATIC_STRING_IMPL("SIGILL"), -// MAKE_STATIC_STRING_IMPL("SIGTRAP"), -// MAKE_STATIC_STRING_IMPL("SIGABRT"), -// MAKE_STATIC_STRING_IMPL("SIGIOT"), -// MAKE_STATIC_STRING_IMPL("SIGBUS"), -// MAKE_STATIC_STRING_IMPL("SIGFPE"), -// MAKE_STATIC_STRING_IMPL("SIGKILL"), -// MAKE_STATIC_STRING_IMPL("SIGUSR1"), -// MAKE_STATIC_STRING_IMPL("SIGSEGV"), -// MAKE_STATIC_STRING_IMPL("SIGUSR2"), -// MAKE_STATIC_STRING_IMPL("SIGPIPE"), -// MAKE_STATIC_STRING_IMPL("SIGALRM"), -// MAKE_STATIC_STRING_IMPL("SIGTERM"), -// MAKE_STATIC_STRING_IMPL("SIGCHLD"), -// MAKE_STATIC_STRING_IMPL("SIGCONT"), -// MAKE_STATIC_STRING_IMPL("SIGSTOP"), -// MAKE_STATIC_STRING_IMPL("SIGTSTP"), -// MAKE_STATIC_STRING_IMPL("SIGTTIN"), -// MAKE_STATIC_STRING_IMPL("SIGTTOU"), -// MAKE_STATIC_STRING_IMPL("SIGURG"), -// MAKE_STATIC_STRING_IMPL("SIGXCPU"), -// MAKE_STATIC_STRING_IMPL("SIGXFSZ"), -// MAKE_STATIC_STRING_IMPL("SIGVTALRM"), -// MAKE_STATIC_STRING_IMPL("SIGPROF"), -// MAKE_STATIC_STRING_IMPL("SIGWINCH"), -// MAKE_STATIC_STRING_IMPL("SIGIO"), -// MAKE_STATIC_STRING_IMPL("SIGINFO"), -// MAKE_STATIC_STRING_IMPL("SIGSYS"), -// }; -// static const int signalNumbers[] = { -// SIGHUP, -// SIGINT, -// SIGQUIT, -// SIGILL, -// SIGTRAP, -// SIGABRT, -// SIGIOT, -// SIGBUS, -// SIGFPE, -// SIGKILL, -// SIGUSR1, -// SIGSEGV, -// SIGUSR2, -// SIGPIPE, -// SIGALRM, -// SIGTERM, -// SIGCHLD, -// SIGCONT, -// SIGSTOP, -// SIGTSTP, -// SIGTTIN, -// SIGTTOU, -// SIGURG, -// SIGXCPU, -// SIGXFSZ, -// SIGVTALRM, -// SIGPROF, -// SIGWINCH, -// SIGIO, -// SIGINFO, -// SIGSYS, -// }; - -// JSC_DEFINE_HOST_FUNCTION(jsFunctionProcessOn, (JSGlobalObject * globalObject, CallFrame* callFrame)) -// { -// VM& vm = globalObject->vm(); -// auto scope = DECLARE_THROW_SCOPE(vm); - -// if (callFrame->argumentCount() < 2) { -// throwVMError(globalObject, scope, "Not enough arguments"_s); -// return JSValue::encode(jsUndefined()); -// } - -// String eventName = callFrame->uncheckedArgument(0).toWTFString(globalObject); -// RETURN_IF_EXCEPTION(scope, encodedJSValue()); -// } +static HashMap* signalNameToNumberMap = nullptr; +static HashMap* signalNumberToNameMap = nullptr; + +// signal number to array of script execution context ids that care about the signal +static HashMap>* signalToContextIdsMap = nullptr; +static Lock signalToContextIdsMapLock; + +static void onDidChangeListeners(EventEmitter& eventEmitter, const Identifier& eventName, bool isAdded) +{ + + static const NeverDestroyed signalNames[] = { + MAKE_STATIC_STRING_IMPL("SIGHUP"), + MAKE_STATIC_STRING_IMPL("SIGINT"), + MAKE_STATIC_STRING_IMPL("SIGQUIT"), + MAKE_STATIC_STRING_IMPL("SIGILL"), + MAKE_STATIC_STRING_IMPL("SIGTRAP"), + MAKE_STATIC_STRING_IMPL("SIGABRT"), + MAKE_STATIC_STRING_IMPL("SIGIOT"), + MAKE_STATIC_STRING_IMPL("SIGBUS"), + MAKE_STATIC_STRING_IMPL("SIGFPE"), + MAKE_STATIC_STRING_IMPL("SIGKILL"), + MAKE_STATIC_STRING_IMPL("SIGUSR1"), + MAKE_STATIC_STRING_IMPL("SIGSEGV"), + MAKE_STATIC_STRING_IMPL("SIGUSR2"), + MAKE_STATIC_STRING_IMPL("SIGPIPE"), + MAKE_STATIC_STRING_IMPL("SIGALRM"), + MAKE_STATIC_STRING_IMPL("SIGTERM"), + MAKE_STATIC_STRING_IMPL("SIGCHLD"), + MAKE_STATIC_STRING_IMPL("SIGCONT"), + MAKE_STATIC_STRING_IMPL("SIGSTOP"), + MAKE_STATIC_STRING_IMPL("SIGTSTP"), + MAKE_STATIC_STRING_IMPL("SIGTTIN"), + MAKE_STATIC_STRING_IMPL("SIGTTOU"), + MAKE_STATIC_STRING_IMPL("SIGURG"), + MAKE_STATIC_STRING_IMPL("SIGXCPU"), + MAKE_STATIC_STRING_IMPL("SIGXFSZ"), + MAKE_STATIC_STRING_IMPL("SIGVTALRM"), + MAKE_STATIC_STRING_IMPL("SIGPROF"), + MAKE_STATIC_STRING_IMPL("SIGWINCH"), + MAKE_STATIC_STRING_IMPL("SIGIO"), + MAKE_STATIC_STRING_IMPL("SIGINFO"), + MAKE_STATIC_STRING_IMPL("SIGSYS"), + }; + + static std::once_flag signalNameToNumberMapOnceFlag; + std::call_once(signalNameToNumberMapOnceFlag, [] { + signalNameToNumberMap = new HashMap(); + signalNameToNumberMap->reserveInitialCapacity(31); + signalNameToNumberMap->add(signalNames[0], SIGHUP); + signalNameToNumberMap->add(signalNames[1], SIGINT); + signalNameToNumberMap->add(signalNames[2], SIGQUIT); + signalNameToNumberMap->add(signalNames[3], SIGILL); + signalNameToNumberMap->add(signalNames[4], SIGTRAP); + signalNameToNumberMap->add(signalNames[5], SIGABRT); + signalNameToNumberMap->add(signalNames[6], SIGIOT); + signalNameToNumberMap->add(signalNames[7], SIGBUS); + signalNameToNumberMap->add(signalNames[8], SIGFPE); + // signalNameToNumberMap->add(signalNames[9], SIGKILL); + signalNameToNumberMap->add(signalNames[10], SIGUSR1); + signalNameToNumberMap->add(signalNames[11], SIGSEGV); + signalNameToNumberMap->add(signalNames[12], SIGUSR2); + signalNameToNumberMap->add(signalNames[13], SIGPIPE); + signalNameToNumberMap->add(signalNames[14], SIGALRM); + signalNameToNumberMap->add(signalNames[15], SIGTERM); + signalNameToNumberMap->add(signalNames[16], SIGCHLD); + signalNameToNumberMap->add(signalNames[17], SIGCONT); + // signalNameToNumberMap->add(signalNames[18], SIGSTOP); + signalNameToNumberMap->add(signalNames[19], SIGTSTP); + signalNameToNumberMap->add(signalNames[20], SIGTTIN); + signalNameToNumberMap->add(signalNames[21], SIGTTOU); + signalNameToNumberMap->add(signalNames[22], SIGURG); + signalNameToNumberMap->add(signalNames[23], SIGXCPU); + signalNameToNumberMap->add(signalNames[24], SIGXFSZ); + signalNameToNumberMap->add(signalNames[25], SIGVTALRM); + signalNameToNumberMap->add(signalNames[26], SIGPROF); + signalNameToNumberMap->add(signalNames[27], SIGWINCH); + signalNameToNumberMap->add(signalNames[28], SIGIO); +#ifdef SIGINFO + signalNameToNumberMap->add(signalNames[29], SIGINFO); +#endif + +#ifndef SIGINFO + signalNameToNumberMap->add(signalNames[29], 255); +#endif + signalNameToNumberMap->add(signalNames[30], SIGSYS); + }); + + static std::once_flag signalNumberToNameMapOnceFlag; + std::call_once(signalNumberToNameMapOnceFlag, [] { + signalNumberToNameMap = new HashMap(); + signalNumberToNameMap->reserveInitialCapacity(31); + signalNumberToNameMap->add(SIGHUP, signalNames[0]); + signalNumberToNameMap->add(SIGINT, signalNames[1]); + signalNumberToNameMap->add(SIGQUIT, signalNames[2]); + signalNumberToNameMap->add(SIGILL, signalNames[3]); + signalNumberToNameMap->add(SIGTRAP, signalNames[4]); + signalNumberToNameMap->add(SIGABRT, signalNames[5]); + signalNumberToNameMap->add(SIGIOT, signalNames[6]); + signalNumberToNameMap->add(SIGBUS, signalNames[7]); + signalNumberToNameMap->add(SIGFPE, signalNames[8]); + // signalNumberToNameMap->add(SIGKILL, signalNames[9]); + signalNumberToNameMap->add(SIGUSR1, signalNames[10]); + signalNumberToNameMap->add(SIGSEGV, signalNames[11]); + signalNumberToNameMap->add(SIGUSR2, signalNames[12]); + signalNumberToNameMap->add(SIGPIPE, signalNames[13]); + signalNumberToNameMap->add(SIGALRM, signalNames[14]); + signalNumberToNameMap->add(SIGTERM, signalNames[15]); + signalNumberToNameMap->add(SIGCHLD, signalNames[16]); + signalNumberToNameMap->add(SIGCONT, signalNames[17]); + // signalNumberToNameMap->add(SIGSTOP, signalNames[18]); + signalNumberToNameMap->add(SIGTSTP, signalNames[19]); + signalNumberToNameMap->add(SIGTTIN, signalNames[20]); + signalNumberToNameMap->add(SIGTTOU, signalNames[21]); + signalNumberToNameMap->add(SIGURG, signalNames[22]); + signalNumberToNameMap->add(SIGXCPU, signalNames[23]); + signalNumberToNameMap->add(SIGXFSZ, signalNames[24]); + signalNumberToNameMap->add(SIGVTALRM, signalNames[25]); + signalNumberToNameMap->add(SIGPROF, signalNames[26]); + signalNumberToNameMap->add(SIGWINCH, signalNames[27]); + signalNumberToNameMap->add(SIGIO, signalNames[28]); +#ifdef SIGINFO + signalNameToNumberMap->add(signalNames[29], SIGINFO); +#endif + signalNumberToNameMap->add(SIGSYS, signalNames[30]); + }); + + if (!signalToContextIdsMap) { + signalToContextIdsMap = new HashMap>(); + } + + if (isAdded) { + if (auto signalNumber = signalNameToNumberMap->get(eventName.string())) { + uint32_t contextId = eventEmitter.scriptExecutionContext()->identifier(); + Locker lock { signalToContextIdsMapLock }; + if (!signalToContextIdsMap->contains(signalNumber)) { + HashSet contextIds; + contextIds.add(contextId); + signalToContextIdsMap->set(signalNumber, contextIds); + + lock.unlockEarly(); + + struct sigaction action; + memset(&action, 0, sizeof(struct sigaction)); + + // Set the handler in the action struct + action.sa_handler = [](int signalNumber) { + if (UNLIKELY(signalNumberToNameMap->find(signalNumber) == signalNumberToNameMap->end())) + return; + + Locker lock { signalToContextIdsMapLock }; + if (UNLIKELY(signalToContextIdsMap->find(signalNumber) == signalToContextIdsMap->end())) + return; + auto contextIds = signalToContextIdsMap->get(signalNumber); + + for (int contextId : contextIds) { + auto* context = ScriptExecutionContext::getScriptExecutionContext(contextId); + if (UNLIKELY(!context)) + continue; + + JSGlobalObject* lexicalGlobalObject = context->jsGlobalObject(); + Zig::GlobalObject* globalObject = static_cast(lexicalGlobalObject); + + Process* process = jsCast(globalObject->processObject()); + + context->postCrossThreadTask(*process, &Process::emitSignalEvent, signalNumber); + } + }; + + // Clear the sa_mask + sigemptyset(&action.sa_mask); + sigaddset(&action.sa_mask, signalNumber); + action.sa_flags = SA_RESTART; + + sigaction(signalNumber, &action, nullptr); + } else { + auto contextIds = signalToContextIdsMap->get(signalNumber); + contextIds.add(contextId); + signalToContextIdsMap->set(signalNumber, contextIds); + } + } + } else { + if (auto signalNumber = signalNameToNumberMap->get(eventName.string())) { + uint32_t contextId = eventEmitter.scriptExecutionContext()->identifier(); + Locker lock { signalToContextIdsMapLock }; + if (signalToContextIdsMap->find(signalNumber) != signalToContextIdsMap->end()) { + HashSet contextIds = signalToContextIdsMap->get(signalNumber); + contextIds.remove(contextId); + if (contextIds.isEmpty()) { + signal(signalNumber, SIG_DFL); + signalToContextIdsMap->remove(signalNumber); + } else { + signalToContextIdsMap->set(signalNumber, contextIds); + } + } + } + } +} + +void Process::emitSignalEvent(int signalNumber) +{ + String signalName = signalNumberToNameMap->get(signalNumber); + Identifier signalNameIdentifier = Identifier::fromString(vm(), signalName); + MarkedArgumentBuffer args; + args.append(jsNumber(signalNumber)); + wrapped().emitForBindings(signalNameIdentifier, args); +} Process::~Process() { - for (auto& listener : this->wrapped().eventListenerMap().entries()) { - } } JSC_DEFINE_HOST_FUNCTION(Process_functionAbort, (JSGlobalObject * globalObject, CallFrame*)) @@ -1550,6 +1674,8 @@ void Process::finishCreation(JSC::VM& vm) { Base::finishCreation(vm); + this->wrapped().onDidChangeListener = &onDidChangeListeners; + this->cpuUsageStructure.initLater([](const JSC::LazyProperty::Initializer& init) { init.set(constructCPUUsageStructure(init.vm, init.owner->globalObject())); }); diff --git a/src/bun.js/bindings/Process.h b/src/bun.js/bindings/Process.h index fbad9b1ff..0ee6f4243 100644 --- a/src/bun.js/bindings/Process.h +++ b/src/bun.js/bindings/Process.h @@ -19,6 +19,8 @@ public: { } + void emitSignalEvent(int signalNumber); + DECLARE_EXPORT_INFO; static void destroy(JSC::JSCell* cell) diff --git a/src/bun.js/bindings/ScriptExecutionContext.cpp b/src/bun.js/bindings/ScriptExecutionContext.cpp index e8cae5e33..3262bdb5d 100644 --- a/src/bun.js/bindings/ScriptExecutionContext.cpp +++ b/src/bun.js/bindings/ScriptExecutionContext.cpp @@ -20,6 +20,12 @@ static HashMap& allSc return contexts; } +ScriptExecutionContext* ScriptExecutionContext::getScriptExecutionContext(ScriptExecutionContextIdentifier identifier) +{ + Locker locker { allScriptExecutionContextsMapLock }; + return allScriptExecutionContextsMap().get(identifier); +} + template static void registerHTTPContextForWebSocket(ScriptExecutionContext* script, us_socket_context_t* ctx, us_loop_t* loop) { diff --git a/src/bun.js/bindings/ScriptExecutionContext.h b/src/bun.js/bindings/ScriptExecutionContext.h index 5f6c56a90..aed7977a5 100644 --- a/src/bun.js/bindings/ScriptExecutionContext.h +++ b/src/bun.js/bindings/ScriptExecutionContext.h @@ -96,7 +96,12 @@ public: } } - const WTF::URL& url() const { return m_url; } + static ScriptExecutionContext* getScriptExecutionContext(ScriptExecutionContextIdentifier identifier); + + const WTF::URL& url() const + { + return m_url; + } bool activeDOMObjectsAreSuspended() { return false; } bool activeDOMObjectsAreStopped() { return false; } bool isContextThread() { return true; } @@ -141,6 +146,7 @@ public: auto* task = new EventLoopTask(WTFMove(lambda)); postTaskOnTimeout(task, timeout); } + template void postCrossThreadTask(Arguments&&... arguments) { diff --git a/src/bun.js/bindings/webcore/EventEmitter.cpp b/src/bun.js/bindings/webcore/EventEmitter.cpp index 0650d624c..0e273042b 100644 --- a/src/bun.js/bindings/webcore/EventEmitter.cpp +++ b/src/bun.js/bindings/webcore/EventEmitter.cpp @@ -35,6 +35,8 @@ bool EventEmitter::addListener(const Identifier& eventType, Ref&& } eventListenersDidChange(); + if (this->onDidChangeListener) + this->onDidChangeListener(*this, eventType, true); return true; } @@ -62,6 +64,9 @@ bool EventEmitter::removeListener(const Identifier& eventType, EventListener& li if (data->eventListenerMap.remove(eventType, listener)) { eventListenersDidChange(); + + if (this->onDidChangeListener) + this->onDidChangeListener(*this, eventType, false); return true; } return false; @@ -93,6 +98,8 @@ bool EventEmitter::removeAllListeners(const Identifier& eventType) if (data->eventListenerMap.removeAll(eventType)) { eventListenersDidChange(); + if (this->onDidChangeListener) + this->onDidChangeListener(*this, eventType, false); return true; } return false; diff --git a/src/bun.js/bindings/webcore/EventEmitter.h b/src/bun.js/bindings/webcore/EventEmitter.h index b46bcff5d..8db59c188 100644 --- a/src/bun.js/bindings/webcore/EventEmitter.h +++ b/src/bun.js/bindings/webcore/EventEmitter.h @@ -67,6 +67,8 @@ public: bool hasActiveEventListeners(const Identifier& eventType) const; bool hasEventListeners(JSC::VM& vm, ASCIILiteral eventType) const; + WTF::Function onDidChangeListener = WTF::Function(nullptr); + unsigned getMaxListeners() const { return m_maxListeners; }; void setMaxListeners(unsigned count); @@ -101,7 +103,9 @@ private: EventEmitterData* eventTargetData() { return &m_eventTargetData; } EventEmitterData* eventTargetDataConcurrently() { return &m_eventTargetData; } EventEmitterData& ensureEventEmitterData() { return m_eventTargetData; } - void eventListenersDidChange() {} + void eventListenersDidChange() + { + } void innerInvokeEventListeners(const Identifier&, SimpleEventListenerVector, const MarkedArgumentBuffer& arguments); void invalidateEventListenerRegions(); diff --git a/src/bun.js/bindings/webcore/JSEventEmitter.cpp b/src/bun.js/bindings/webcore/JSEventEmitter.cpp index 231ae0db4..959cbd8d7 100644 --- a/src/bun.js/bindings/webcore/JSEventEmitter.cpp +++ b/src/bun.js/bindings/webcore/JSEventEmitter.cpp @@ -219,7 +219,7 @@ JSC_DEFINE_CUSTOM_GETTER(jsEventEmitterConstructor, (JSGlobalObject * lexicalGlo return JSValue::encode(JSEventEmitter::getConstructor(JSC::getVM(lexicalGlobalObject), prototype->globalObject())); } -static inline JSC::EncodedJSValue addListener(JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame, typename IDLOperation::ClassParameter castedThis, bool once, bool prepend) +inline JSC::EncodedJSValue JSEventEmitter::addListener(JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame, JSEventEmitter* castedThis, bool once, bool prepend) { auto& vm = JSC::getVM(lexicalGlobalObject); auto throwScope = DECLARE_THROW_SCOPE(vm); @@ -251,7 +251,7 @@ static inline JSC::EncodedJSValue addListener(JSC::JSGlobalObject* lexicalGlobal static inline JSC::EncodedJSValue jsEventEmitterPrototypeFunction_addListenerBody(JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame, typename IDLOperation::ClassParameter castedThis) { - return addListener(lexicalGlobalObject, callFrame, castedThis, false, false); + return JSEventEmitter::addListener(lexicalGlobalObject, callFrame, castedThis, false, false); } static inline JSC::EncodedJSValue jsEventEmitterPrototypeFunction_setMaxListenersBody(JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame, typename IDLOperation::ClassParameter castedThis) @@ -280,17 +280,17 @@ static inline JSC::EncodedJSValue jsEventEmitterPrototypeFunction_getMaxListener static inline JSC::EncodedJSValue jsEventEmitterPrototypeFunction_addOnceListenerBody(JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame, typename IDLOperation::ClassParameter castedThis) { - return addListener(lexicalGlobalObject, callFrame, castedThis, true, false); + return JSEventEmitter::addListener(lexicalGlobalObject, callFrame, castedThis, true, false); } static inline JSC::EncodedJSValue jsEventEmitterPrototypeFunction_prependListenerBody(JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame, typename IDLOperation::ClassParameter castedThis) { - return addListener(lexicalGlobalObject, callFrame, castedThis, false, true); + return JSEventEmitter::addListener(lexicalGlobalObject, callFrame, castedThis, false, true); } static inline JSC::EncodedJSValue jsEventEmitterPrototypeFunction_prependOnceListenerBody(JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame, typename IDLOperation::ClassParameter castedThis) { - return addListener(lexicalGlobalObject, callFrame, castedThis, true, true); + return JSEventEmitter::addListener(lexicalGlobalObject, callFrame, castedThis, true, true); } JSC_DEFINE_HOST_FUNCTION(jsEventEmitterPrototypeFunction_addListener, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame)) @@ -324,6 +324,11 @@ JSC_DEFINE_HOST_FUNCTION(jsEventEmitterPrototypeFunction_prependOnceListener, (J } static inline JSC::EncodedJSValue jsEventEmitterPrototypeFunction_removeListenerBody(JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame, typename IDLOperation::ClassParameter castedThis) +{ + return JSEventEmitter::removeListener(lexicalGlobalObject, callFrame, castedThis); +} + +inline JSC::EncodedJSValue JSEventEmitter::removeListener(JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame, JSEventEmitter* castedThis) { auto& vm = JSC::getVM(lexicalGlobalObject); auto throwScope = DECLARE_THROW_SCOPE(vm); diff --git a/src/bun.js/bindings/webcore/JSEventEmitter.h b/src/bun.js/bindings/webcore/JSEventEmitter.h index 855241011..30d62d792 100644 --- a/src/bun.js/bindings/webcore/JSEventEmitter.h +++ b/src/bun.js/bindings/webcore/JSEventEmitter.h @@ -27,6 +27,9 @@ public: static EventEmitter* toWrapped(JSC::VM&, JSC::JSValue); static void destroy(JSC::JSCell*); + static inline JSC::EncodedJSValue addListener(JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame, JSEventEmitter* castedThis, bool once, bool prepend); + static inline JSC::EncodedJSValue removeListener(JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame, JSEventEmitter* castedThis); + DECLARE_INFO; static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype) diff --git a/test/js/node/process/call-raise.js b/test/js/node/process/call-raise.js new file mode 100644 index 000000000..898906759 --- /dev/null +++ b/test/js/node/process/call-raise.js @@ -0,0 +1,15 @@ +import { dlopen } from "bun:ffi"; + +var lazyRaise; +export function raise(signal) { + if (!lazyRaise) { + const suffix = process.platform === "darwin" ? "dylib" : "so.6"; + lazyRaise = dlopen(`libc.${suffix}`, { + raise: { + args: ["int"], + returns: "int", + }, + }).symbols.raise; + } + lazyRaise(signal); +} diff --git a/test/js/node/process/process-signal-handler.fixture.js b/test/js/node/process/process-signal-handler.fixture.js new file mode 100644 index 000000000..de5a78bda --- /dev/null +++ b/test/js/node/process/process-signal-handler.fixture.js @@ -0,0 +1,63 @@ +import os from "os"; +import { raise } from "./call-raise"; + +var counter = 0; +function done() { + counter++; + if (counter === 2) { + setTimeout(() => { + if (counter !== 2) { + console.log(counter); + console.log("FAIL"); + process.exit(1); + } + + console.log("PASS"); + process.exit(0); + }, 1); + } +} + +var counter2 = 0; +function done2() { + counter2++; + if (counter2 === 2) { + setTimeout(() => { + if (counter2 !== 2) { + console.log(counter2); + console.log("FAIL"); + process.exit(1); + } + + console.log("PASS"); + process.exit(0); + }, 1); + } +} + +const SIGUSR1 = os.constants.signals.SIGUSR1; +const SIGUSR2 = os.constants.signals.SIGUSR2; + +switch (process.argv.at(-1)) { + case "SIGUSR1": { + process.on("SIGUSR1", () => { + done(); + }); + process.on("SIGUSR1", () => { + done(); + }); + raise(SIGUSR1); + break; + } + case "SIGUSR2": { + process.on("SIGUSR2", () => { + done2(); + }); + process.emit("SIGUSR2"); + raise(SIGUSR2); + break; + } + default: { + throw new Error("Unknown argument: " + process.argv.at(-1)); + } +} diff --git a/test/js/node/process/process.test.js b/test/js/node/process/process.test.js index e038383de..51825b2b4 100644 --- a/test/js/node/process/process.test.js +++ b/test/js/node/process/process.test.js @@ -1,6 +1,6 @@ -import { resolveSync, spawnSync, which } from "bun"; +import { spawnSync, which } from "bun"; import { describe, expect, it } from "bun:test"; -import { existsSync, readFileSync, realpathSync } from "fs"; +import { existsSync, readFileSync } from "fs"; import { bunEnv, bunExe } from "harness"; import { basename, join, resolve } from "path"; @@ -381,6 +381,28 @@ it("process.getuid", () => { expect(typeof process.getuid()).toBe("number"); }); +describe("signal", () => { + const fixture = join(import.meta.dir, "./process-signal-handler.fixture.js"); + it("simple case works", async () => { + const child = Bun.spawn({ + cmd: [bunExe(), fixture, "SIGUSR1"], + env: bunEnv, + }); + + expect(await child.exited).toBe(0); + expect(await new Response(child.stdout).text()).toBe("PASS\n"); + }); + it("process.emit will call signal events", async () => { + const child = Bun.spawn({ + cmd: [bunExe(), fixture, "SIGUSR2"], + env: bunEnv, + }); + + expect(await child.exited).toBe(0); + expect(await new Response(child.stdout).text()).toBe("PASS\n"); + }); +}); + const undefinedStubs = [ "_debugEnd", "_debugProcess", -- cgit v1.2.3 From c5f228048936b266ac5c2dd840e59222c2e893c3 Mon Sep 17 00:00:00 2001 From: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com> Date: Tue, 11 Jul 2023 19:06:01 -0700 Subject: Implement `process.kill` and `process._kill` --- packages/bun-types/globals.d.ts | 2 + src/bun.js/bindings/Process.cpp | 147 +++++++++++++---- src/bun.js/bindings/Process.lut.h | 77 ++++----- src/js/out/WebCoreJSBuiltins.cpp | 300 +++++++++++++++++------------------ test/js/node/process/process.test.js | 27 ++++ 5 files changed, 331 insertions(+), 222 deletions(-) (limited to 'src/bun.js/bindings/Process.cpp') diff --git a/packages/bun-types/globals.d.ts b/packages/bun-types/globals.d.ts index f3f941488..9e9b5138d 100644 --- a/packages/bun-types/globals.d.ts +++ b/packages/bun-types/globals.d.ts @@ -433,6 +433,8 @@ interface Process { * Does nothing in Bun */ setSourceMapsEnabled(enabled: boolean): void; + + kill(pid: number, signal?: string | number): void; } interface MemoryUsageObject { diff --git a/src/bun.js/bindings/Process.cpp b/src/bun.js/bindings/Process.cpp index f9fb85b95..745be0e47 100644 --- a/src/bun.js/bindings/Process.cpp +++ b/src/bun.js/bindings/Process.cpp @@ -444,43 +444,43 @@ static HashMap* signalNumberToNameMap = nullptr; static HashMap>* signalToContextIdsMap = nullptr; static Lock signalToContextIdsMapLock; -static void onDidChangeListeners(EventEmitter& eventEmitter, const Identifier& eventName, bool isAdded) +static const NeverDestroyed signalNames[] = { + MAKE_STATIC_STRING_IMPL("SIGHUP"), + MAKE_STATIC_STRING_IMPL("SIGINT"), + MAKE_STATIC_STRING_IMPL("SIGQUIT"), + MAKE_STATIC_STRING_IMPL("SIGILL"), + MAKE_STATIC_STRING_IMPL("SIGTRAP"), + MAKE_STATIC_STRING_IMPL("SIGABRT"), + MAKE_STATIC_STRING_IMPL("SIGIOT"), + MAKE_STATIC_STRING_IMPL("SIGBUS"), + MAKE_STATIC_STRING_IMPL("SIGFPE"), + MAKE_STATIC_STRING_IMPL("SIGKILL"), + MAKE_STATIC_STRING_IMPL("SIGUSR1"), + MAKE_STATIC_STRING_IMPL("SIGSEGV"), + MAKE_STATIC_STRING_IMPL("SIGUSR2"), + MAKE_STATIC_STRING_IMPL("SIGPIPE"), + MAKE_STATIC_STRING_IMPL("SIGALRM"), + MAKE_STATIC_STRING_IMPL("SIGTERM"), + MAKE_STATIC_STRING_IMPL("SIGCHLD"), + MAKE_STATIC_STRING_IMPL("SIGCONT"), + MAKE_STATIC_STRING_IMPL("SIGSTOP"), + MAKE_STATIC_STRING_IMPL("SIGTSTP"), + MAKE_STATIC_STRING_IMPL("SIGTTIN"), + MAKE_STATIC_STRING_IMPL("SIGTTOU"), + MAKE_STATIC_STRING_IMPL("SIGURG"), + MAKE_STATIC_STRING_IMPL("SIGXCPU"), + MAKE_STATIC_STRING_IMPL("SIGXFSZ"), + MAKE_STATIC_STRING_IMPL("SIGVTALRM"), + MAKE_STATIC_STRING_IMPL("SIGPROF"), + MAKE_STATIC_STRING_IMPL("SIGWINCH"), + MAKE_STATIC_STRING_IMPL("SIGIO"), + MAKE_STATIC_STRING_IMPL("SIGINFO"), + MAKE_STATIC_STRING_IMPL("SIGSYS"), +}; + +static void loadSignalNumberMap() { - static const NeverDestroyed signalNames[] = { - MAKE_STATIC_STRING_IMPL("SIGHUP"), - MAKE_STATIC_STRING_IMPL("SIGINT"), - MAKE_STATIC_STRING_IMPL("SIGQUIT"), - MAKE_STATIC_STRING_IMPL("SIGILL"), - MAKE_STATIC_STRING_IMPL("SIGTRAP"), - MAKE_STATIC_STRING_IMPL("SIGABRT"), - MAKE_STATIC_STRING_IMPL("SIGIOT"), - MAKE_STATIC_STRING_IMPL("SIGBUS"), - MAKE_STATIC_STRING_IMPL("SIGFPE"), - MAKE_STATIC_STRING_IMPL("SIGKILL"), - MAKE_STATIC_STRING_IMPL("SIGUSR1"), - MAKE_STATIC_STRING_IMPL("SIGSEGV"), - MAKE_STATIC_STRING_IMPL("SIGUSR2"), - MAKE_STATIC_STRING_IMPL("SIGPIPE"), - MAKE_STATIC_STRING_IMPL("SIGALRM"), - MAKE_STATIC_STRING_IMPL("SIGTERM"), - MAKE_STATIC_STRING_IMPL("SIGCHLD"), - MAKE_STATIC_STRING_IMPL("SIGCONT"), - MAKE_STATIC_STRING_IMPL("SIGSTOP"), - MAKE_STATIC_STRING_IMPL("SIGTSTP"), - MAKE_STATIC_STRING_IMPL("SIGTTIN"), - MAKE_STATIC_STRING_IMPL("SIGTTOU"), - MAKE_STATIC_STRING_IMPL("SIGURG"), - MAKE_STATIC_STRING_IMPL("SIGXCPU"), - MAKE_STATIC_STRING_IMPL("SIGXFSZ"), - MAKE_STATIC_STRING_IMPL("SIGVTALRM"), - MAKE_STATIC_STRING_IMPL("SIGPROF"), - MAKE_STATIC_STRING_IMPL("SIGWINCH"), - MAKE_STATIC_STRING_IMPL("SIGIO"), - MAKE_STATIC_STRING_IMPL("SIGINFO"), - MAKE_STATIC_STRING_IMPL("SIGSYS"), - }; - static std::once_flag signalNameToNumberMapOnceFlag; std::call_once(signalNameToNumberMapOnceFlag, [] { signalNameToNumberMap = new HashMap(); @@ -523,6 +523,11 @@ static void onDidChangeListeners(EventEmitter& eventEmitter, const Identifier& e #endif signalNameToNumberMap->add(signalNames[30], SIGSYS); }); +} + +static void onDidChangeListeners(EventEmitter& eventEmitter, const Identifier& eventName, bool isAdded) +{ + loadSignalNumberMap(); static std::once_flag signalNumberToNameMapOnceFlag; std::call_once(signalNumberToNameMapOnceFlag, [] { @@ -1601,6 +1606,76 @@ JSC_DEFINE_HOST_FUNCTION(Process_functionCwd, return JSC::JSValue::encode(result); } +JSC_DEFINE_HOST_FUNCTION(Process_functionReallyKill, + (JSC::JSGlobalObject * globalObject, JSC::CallFrame* callFrame)) +{ + auto scope = DECLARE_THROW_SCOPE(globalObject->vm()); + + int pid = callFrame->argument(0).toInt32(globalObject); + RETURN_IF_EXCEPTION(scope, {}); + + int signal = callFrame->argument(1).toInt32(globalObject); + RETURN_IF_EXCEPTION(scope, {}); + + int result = kill(pid, signal); + if (result == -1) { + SystemError error; + error.errno_ = errno; + error.syscall = Bun::toString("kill"_s); + throwException(globalObject, scope, JSValue::decode(SystemError__toErrorInstance(&error, globalObject))); + return JSValue::encode(jsUndefined()); + } + + return JSValue::encode(jsUndefined()); +} +JSC_DEFINE_HOST_FUNCTION(Process_functionKill, + (JSC::JSGlobalObject * globalObject, JSC::CallFrame* callFrame)) +{ + auto scope = DECLARE_THROW_SCOPE(globalObject->vm()); + + int pid = callFrame->argument(0).toInt32(globalObject); + RETURN_IF_EXCEPTION(scope, {}); + if (pid < 0) { + throwRangeError(globalObject, scope, "pid must be a positive integer"_s); + return JSValue::encode(jsUndefined()); + } + + JSC::JSValue signalValue = callFrame->argument(1); + + int signal = SIGTERM; + + if (signalValue.isNumber()) { + signal = signalValue.toInt32(globalObject); + RETURN_IF_EXCEPTION(scope, {}); + } else if (signalValue.isString()) { + loadSignalNumberMap(); + if (auto num = signalNameToNumberMap->get(signalValue.toWTFString(globalObject))) { + signal = num; + RETURN_IF_EXCEPTION(scope, {}); + } else { + throwRangeError(globalObject, scope, "Unknown signal name"_s); + return JSValue::encode(jsUndefined()); + } + + RETURN_IF_EXCEPTION(scope, {}); + } else if (!signalValue.isUndefinedOrNull()) { + throwTypeError(globalObject, scope, "signal must be a string or number"_s); + return JSValue::encode(jsUndefined()); + } + + int result = kill(pid, signal); + + if (result == -1) { + SystemError error; + error.errno_ = errno; + error.syscall = Bun::toString("kill"_s); + throwException(globalObject, scope, JSValue::decode(SystemError__toErrorInstance(&error, globalObject))); + return JSValue::encode(jsUndefined()); + } + + return JSValue::encode(jsUndefined()); +} + /* Source for Process.lut.h @begin processObjectTable abort Process_functionAbort Function 1 @@ -1632,6 +1707,7 @@ JSC_DEFINE_HOST_FUNCTION(Process_functionCwd, getuid Process_functiongetuid Function 0 hrtime constructProcessHrtimeObject PropertyCallback isBun constructIsBun PropertyCallback + kill Process_functionKill Function 2 mainModule JSBuiltin ReadOnly|Builtin|Accessor|Function 0 memoryUsage constructMemoryUsage PropertyCallback moduleLoadList Process_stubEmptyArray PropertyCallback @@ -1663,6 +1739,7 @@ JSC_DEFINE_HOST_FUNCTION(Process_functionCwd, _startProfilerIdleNotifier Process_stubEmptyFunction Function 0 _stopProfilerIdleNotifier Process_stubEmptyFunction Function 0 _tickCallback Process_stubEmptyFunction Function 0 + _kill Process_functionReallyKill Function 2 @end */ diff --git a/src/bun.js/bindings/Process.lut.h b/src/bun.js/bindings/Process.lut.h index 81eb1b7b9..81cf98c7d 100644 --- a/src/bun.js/bindings/Process.lut.h +++ b/src/bun.js/bindings/Process.lut.h @@ -1,6 +1,6 @@ // File generated via `make generate-builtins` -static const struct CompactHashIndex processObjectTableIndex[142] = { - { 43, -1 }, +static const struct CompactHashIndex processObjectTableIndex[143] = { + { 44, -1 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, @@ -14,9 +14,9 @@ static const struct CompactHashIndex processObjectTableIndex[142] = { { 15, 129 }, { -1, -1 }, { -1, -1 }, - { 18, 138 }, + { 18, 139 }, { -1, -1 }, - { 45, -1 }, + { 46, -1 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, @@ -33,37 +33,37 @@ static const struct CompactHashIndex processObjectTableIndex[142] = { { -1, -1 }, { -1, -1 }, { -1, -1 }, - { 3, 141 }, + { 3, 142 }, { 1, 128 }, { -1, -1 }, - { 59, -1 }, + { 60, -1 }, { -1, -1 }, { 10, -1 }, { -1, -1 }, { -1, -1 }, - { 31, -1 }, + { 32, -1 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, - { 52, -1 }, + { 53, -1 }, { 27, -1 }, { 12, -1 }, { -1, -1 }, { 19, -1 }, { -1, -1 }, - { 14, 137 }, + { 14, 138 }, { -1, -1 }, - { 36, -1 }, + { 37, -1 }, { -1, -1 }, - { 38, -1 }, - { 55, -1 }, - { 35, -1 }, - { 6, 139 }, + { 39, -1 }, + { 56, -1 }, + { 36, -1 }, + { 6, 140 }, { -1, -1 }, - { 51, -1 }, + { 52, -1 }, { 4, -1 }, - { 47, -1 }, + { 48, -1 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, @@ -75,25 +75,25 @@ static const struct CompactHashIndex processObjectTableIndex[142] = { { -1, -1 }, { -1, -1 }, { -1, -1 }, - { 40, -1 }, + { 41, -1 }, { -1, -1 }, - { 37, -1 }, + { 29, 133 }, { -1, -1 }, { 0, -1 }, - { 26, 135 }, + { 26, 136 }, { 16, 130 }, - { 39, -1 }, + { 40, -1 }, { -1, -1 }, { 23, -1 }, { 11, -1 }, { -1, -1 }, { -1, -1 }, - { 58, -1 }, + { 59, -1 }, { -1, -1 }, { -1, -1 }, - { 30, 136 }, + { 31, 137 }, { -1, -1 }, - { 29, -1 }, + { 30, -1 }, { 22, -1 }, { -1, -1 }, { -1, -1 }, @@ -104,8 +104,8 @@ static const struct CompactHashIndex processObjectTableIndex[142] = { { -1, -1 }, { 5, -1 }, { -1, -1 }, - { -1, -1 }, - { 48, -1 }, + { 61, -1 }, + { 49, -1 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, @@ -115,36 +115,37 @@ static const struct CompactHashIndex processObjectTableIndex[142] = { { -1, -1 }, { -1, -1 }, { 9, -1 }, - { 25, 133 }, + { 25, 134 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, - { 21, 134 }, + { 21, 135 }, { -1, -1 }, { -1, -1 }, { -1, -1 }, - { 46, 140 }, + { 47, 141 }, { -1, -1 }, { 17, -1 }, { 8, -1 }, { 28, -1 }, - { 32, 132 }, - { 33, -1 }, + { 33, 132 }, { 34, -1 }, - { 41, -1 }, + { 35, -1 }, + { 38, -1 }, { 42, -1 }, - { 44, -1 }, - { 49, -1 }, + { 43, -1 }, + { 45, -1 }, { 50, -1 }, - { 53, -1 }, + { 51, -1 }, { 54, -1 }, - { 56, -1 }, + { 55, -1 }, { 57, -1 }, + { 58, -1 }, }; -static const struct HashTableValue processObjectTableValues[60] = { +static const struct HashTableValue processObjectTableValues[62] = { { "abort"_s, static_cast(PropertyAttribute::Function), NoIntrinsic, { HashTableValue::NativeFunctionType, Process_functionAbort, 1 } }, { "allowedNodeEnvironmentFlags"_s, static_cast(PropertyAttribute::PropertyCallback), NoIntrinsic, { HashTableValue::LazyPropertyType, Process_stubEmptySet } }, { "arch"_s, static_cast(PropertyAttribute::PropertyCallback), NoIntrinsic, { HashTableValue::LazyPropertyType, constructArch } }, @@ -174,6 +175,7 @@ static const struct HashTableValue processObjectTableValues[60] = { { "getuid"_s, static_cast(PropertyAttribute::Function), NoIntrinsic, { HashTableValue::NativeFunctionType, Process_functiongetuid, 0 } }, { "hrtime"_s, static_cast(PropertyAttribute::PropertyCallback), NoIntrinsic, { HashTableValue::LazyPropertyType, constructProcessHrtimeObject } }, { "isBun"_s, static_cast(PropertyAttribute::PropertyCallback), NoIntrinsic, { HashTableValue::LazyPropertyType, constructIsBun } }, + { "kill"_s, static_cast(PropertyAttribute::Function), NoIntrinsic, { HashTableValue::NativeFunctionType, Process_functionKill, 2 } }, { "mainModule"_s, ((static_cast(PropertyAttribute::ReadOnly|PropertyAttribute::Builtin|PropertyAttribute::Accessor|PropertyAttribute::Function)) & ~PropertyAttribute::Function) | PropertyAttribute::Builtin, NoIntrinsic, { HashTableValue::BuiltinGeneratorType, processObjectMainModuleCodeGenerator, 0 } }, { "memoryUsage"_s, static_cast(PropertyAttribute::PropertyCallback), NoIntrinsic, { HashTableValue::LazyPropertyType, constructMemoryUsage } }, { "moduleLoadList"_s, static_cast(PropertyAttribute::PropertyCallback), NoIntrinsic, { HashTableValue::LazyPropertyType, Process_stubEmptyArray } }, @@ -205,7 +207,8 @@ static const struct HashTableValue processObjectTableValues[60] = { { "_startProfilerIdleNotifier"_s, static_cast(PropertyAttribute::Function), NoIntrinsic, { HashTableValue::NativeFunctionType, Process_stubEmptyFunction, 0 } }, { "_stopProfilerIdleNotifier"_s, static_cast(PropertyAttribute::Function), NoIntrinsic, { HashTableValue::NativeFunctionType, Process_stubEmptyFunction, 0 } }, { "_tickCallback"_s, static_cast(PropertyAttribute::Function), NoIntrinsic, { HashTableValue::NativeFunctionType, Process_stubEmptyFunction, 0 } }, + { "_kill"_s, static_cast(PropertyAttribute::Function), NoIntrinsic, { HashTableValue::NativeFunctionType, Process_functionReallyKill, 2 } }, }; static const struct HashTable processObjectTable = - { 60, 127, true, nullptr, processObjectTableValues, processObjectTableIndex }; + { 62, 127, true, nullptr, processObjectTableValues, processObjectTableIndex }; diff --git a/src/js/out/WebCoreJSBuiltins.cpp b/src/js/out/WebCoreJSBuiltins.cpp index fb3100762..f20f626d4 100644 --- a/src/js/out/WebCoreJSBuiltins.cpp +++ b/src/js/out/WebCoreJSBuiltins.cpp @@ -16,7 +16,7 @@ const JSC::ConstructorKind s_bundlerPluginRunSetupFunctionCodeConstructorKind = const JSC::ImplementationVisibility s_bundlerPluginRunSetupFunctionCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_bundlerPluginRunSetupFunctionCodeLength = 2165; static const JSC::Intrinsic s_bundlerPluginRunSetupFunctionCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_bundlerPluginRunSetupFunctionCode = "(function (_,E){\"use strict\";var w=new Map,h=new Map;function q(D,F,G){if(!D||!@isObject(D))@throwTypeError('Expected an object with \"filter\" RegExp');if(!F||!@isCallable(F))@throwTypeError(\"callback must be a function\");var{filter:H,namespace:I=\"file\"}=D;if(!H)@throwTypeError('Expected an object with \"filter\" RegExp');if(!@isRegExpObject(H))@throwTypeError(\"filter must be a RegExp\");if(I&&typeof I!==\"string\")@throwTypeError(\"namespace must be a string\");if((I\?.length\?\?0)===0)I=\"file\";if(!/^([/@a-zA-Z0-9_\\\\-]+)$/.test(I))@throwTypeError(\"namespace can only contain $a-zA-Z0-9_\\\\-\");var J=G.@get(I);if(!J)G.@set(I,[[H,F]]);else @arrayPush(J,[H,F])}function z(D,F){q(D,F,w)}function A(D,F){q(D,F,h)}const B=()=>{var D=!1,F=!1;for(var[G,H]of w.entries())for(var[I]of H)this.addFilter(I,G,1),D=!0;for(var[G,H]of h.entries())for(var[I]of H)this.addFilter(I,G,0),F=!0;if(F){var J=this.onResolve;if(!J)this.onResolve=h;else for(var[G,H]of h.entries()){var K=J.@get(G);if(!K)J.@set(G,H);else J.@set(G,K.concat(H))}}if(D){var M=this.onLoad;if(!M)this.onLoad=w;else for(var[G,H]of w.entries()){var K=M.@get(G);if(!K)M.@set(G,H);else M.@set(G,K.concat(H))}}return D||F};var C=_({config:E,onDispose:()=>@throwTypeError(`@{@2} is not implemented yet. See https://github.com/oven-sh/bun/issues/@1`),onEnd:()=>@throwTypeError(`@{@2} is not implemented yet. See https://github.com/oven-sh/bun/issues/@1`),onLoad:z,onResolve:A,onStart:()=>@throwTypeError(`@{@2} is not implemented yet. See https://github.com/oven-sh/bun/issues/@1`),resolve:()=>@throwTypeError(`@{@2} is not implemented yet. See https://github.com/oven-sh/bun/issues/@1`),initialOptions:{...E,bundle:!0,entryPoints:E.entrypoints\?\?E.entryPoints\?\?[],minify:typeof E.minify===\"boolean\"\?E.minify:!1,minifyIdentifiers:E.minify===!0||E.minify\?.identifiers,minifyWhitespace:E.minify===!0||E.minify\?.whitespace,minifySyntax:E.minify===!0||E.minify\?.syntax,outbase:E.root,platform:E.target===\"bun\"\?\"node\":E.target},esbuild:{}});if(C&&@isPromise(C))if(@getPromiseInternalField(C,@promiseFieldFlags)&@promiseStateFulfilled)C=@getPromiseInternalField(C,@promiseFieldReactionsOrResult);else return C.@then(B);return B()})\n"; +const char* const s_bundlerPluginRunSetupFunctionCode = "(function (J,_){\"use strict\";var D=new Map,F=new Map;function H(q,h,E){if(!q||!@isObject(q))@throwTypeError('Expected an object with \"filter\" RegExp');if(!h||!@isCallable(h))@throwTypeError(\"callback must be a function\");var{filter:w,namespace:z=\"file\"}=q;if(!w)@throwTypeError('Expected an object with \"filter\" RegExp');if(!@isRegExpObject(w))@throwTypeError(\"filter must be a RegExp\");if(z&&typeof z!==\"string\")@throwTypeError(\"namespace must be a string\");if((z\?.length\?\?0)===0)z=\"file\";if(!/^([/@a-zA-Z0-9_\\\\-]+)$/.test(z))@throwTypeError(\"namespace can only contain $a-zA-Z0-9_\\\\-\");var A=E.@get(z);if(!A)E.@set(z,[[w,h]]);else @arrayPush(A,[w,h])}function K(q,h){H(q,h,D)}function M(q,h){H(q,h,F)}const I=()=>{var q=!1,h=!1;for(var[E,w]of D.entries())for(var[z]of w)this.addFilter(z,E,1),q=!0;for(var[E,w]of F.entries())for(var[z]of w)this.addFilter(z,E,0),h=!0;if(h){var A=this.onResolve;if(!A)this.onResolve=F;else for(var[E,w]of F.entries()){var C=A.@get(E);if(!C)A.@set(E,w);else A.@set(E,C.concat(w))}}if(q){var G=this.onLoad;if(!G)this.onLoad=D;else for(var[E,w]of D.entries()){var C=G.@get(E);if(!C)G.@set(E,w);else G.@set(E,C.concat(w))}}return q||h};var B=J({config:_,onDispose:()=>@throwTypeError(`@{@2} is not implemented yet. See https://github.com/oven-sh/bun/issues/@1`),onEnd:()=>@throwTypeError(`@{@2} is not implemented yet. See https://github.com/oven-sh/bun/issues/@1`),onLoad:K,onResolve:M,onStart:()=>@throwTypeError(`@{@2} is not implemented yet. See https://github.com/oven-sh/bun/issues/@1`),resolve:()=>@throwTypeError(`@{@2} is not implemented yet. See https://github.com/oven-sh/bun/issues/@1`),initialOptions:{..._,bundle:!0,entryPoints:_.entrypoints\?\?_.entryPoints\?\?[],minify:typeof _.minify===\"boolean\"\?_.minify:!1,minifyIdentifiers:_.minify===!0||_.minify\?.identifiers,minifyWhitespace:_.minify===!0||_.minify\?.whitespace,minifySyntax:_.minify===!0||_.minify\?.syntax,outbase:_.root,platform:_.target===\"bun\"\?\"node\":_.target},esbuild:{}});if(B&&@isPromise(B))if(@getPromiseInternalField(B,@promiseFieldFlags)&@promiseStateFulfilled)B=@getPromiseInternalField(B,@promiseFieldReactionsOrResult);else return B.@then(I);return I()})\n"; // runOnResolvePlugins const JSC::ConstructAbility s_bundlerPluginRunOnResolvePluginsCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -24,7 +24,7 @@ const JSC::ConstructorKind s_bundlerPluginRunOnResolvePluginsCodeConstructorKind const JSC::ImplementationVisibility s_bundlerPluginRunOnResolvePluginsCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_bundlerPluginRunOnResolvePluginsCodeLength = 1711; static const JSC::Intrinsic s_bundlerPluginRunOnResolvePluginsCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_bundlerPluginRunOnResolvePluginsCode = "(function (_,w,g,y,b){\"use strict\";const j=[\"entry-point\",\"import-statement\",\"require-call\",\"dynamic-import\",\"require-resolve\",\"import-rule\",\"url-token\",\"internal\"][b];var q=(async(z,A,B,C)=>{var{onResolve:E,onLoad:F}=this,G=E.@get(A);if(!G)return this.onResolveAsync(y,null,null,null),null;for(let[O,Q]of G)if(O.test(z)){var H=Q({path:z,importer:B,namespace:A,kind:C});while(H&&@isPromise(H)&&(@getPromiseInternalField(H,@promiseFieldFlags)&@promiseStateMask)===@promiseStateFulfilled)H=@getPromiseInternalField(H,@promiseFieldReactionsOrResult);if(H&&@isPromise(H))H=await H;if(!H||!@isObject(H))continue;var{path:J,namespace:K=A,external:M}=H;if(typeof J!==\"string\"||typeof K!==\"string\")@throwTypeError(\"onResolve plugins must return an object with a string 'path' and string 'loader' field\");if(!J)continue;if(!K)K=A;if(typeof M!==\"boolean\"&&!@isUndefinedOrNull(M))@throwTypeError('onResolve plugins \"external\" field must be boolean or unspecified');if(!M){if(K===\"file\"){if(darwin!==\"win32\"){if(J[0]!==\"/\"||J.includes(\"..\"))@throwTypeError('onResolve plugin \"path\" must be absolute when the namespace is \"file\"')}}if(K===\"dataurl\"){if(!J.startsWith(\"data:\"))@throwTypeError('onResolve plugin \"path\" must start with \"data:\" when the namespace is \"dataurl\"')}if(K&&K!==\"file\"&&(!F||!F.@has(K)))@throwTypeError(`Expected onLoad plugin for namespace ${K} to exist`)}return this.onResolveAsync(y,J,K,M),null}return this.onResolveAsync(y,null,null,null),null})(_,w,g,j);while(q&&@isPromise(q)&&(@getPromiseInternalField(q,@promiseFieldFlags)&@promiseStateMask)===@promiseStateFulfilled)q=@getPromiseInternalField(q,@promiseFieldReactionsOrResult);if(q&&@isPromise(q))q.then(()=>{},(z)=>{this.addError(y,z,0)})})\n"; +const char* const s_bundlerPluginRunOnResolvePluginsCode = "(function (C,E,F,b,G){\"use strict\";const H=[\"entry-point\",\"import-statement\",\"require-call\",\"dynamic-import\",\"require-resolve\",\"import-rule\",\"url-token\",\"internal\"][G];var g=(async(j,q,J,K)=>{var{onResolve:M,onLoad:A}=this,B=M.@get(q);if(!B)return this.onResolveAsync(b,null,null,null),null;for(let[O,Q]of B)if(O.test(j)){var _=Q({path:j,importer:J,namespace:q,kind:K});while(_&&@isPromise(_)&&(@getPromiseInternalField(_,@promiseFieldFlags)&@promiseStateMask)===@promiseStateFulfilled)_=@getPromiseInternalField(_,@promiseFieldReactionsOrResult);if(_&&@isPromise(_))_=await _;if(!_||!@isObject(_))continue;var{path:y,namespace:w=q,external:z}=_;if(typeof y!==\"string\"||typeof w!==\"string\")@throwTypeError(\"onResolve plugins must return an object with a string 'path' and string 'loader' field\");if(!y)continue;if(!w)w=q;if(typeof z!==\"boolean\"&&!@isUndefinedOrNull(z))@throwTypeError('onResolve plugins \"external\" field must be boolean or unspecified');if(!z){if(w===\"file\"){if(darwin!==\"win32\"){if(y[0]!==\"/\"||y.includes(\"..\"))@throwTypeError('onResolve plugin \"path\" must be absolute when the namespace is \"file\"')}}if(w===\"dataurl\"){if(!y.startsWith(\"data:\"))@throwTypeError('onResolve plugin \"path\" must start with \"data:\" when the namespace is \"dataurl\"')}if(w&&w!==\"file\"&&(!A||!A.@has(w)))@throwTypeError(`Expected onLoad plugin for namespace ${w} to exist`)}return this.onResolveAsync(b,y,w,z),null}return this.onResolveAsync(b,null,null,null),null})(C,E,F,H);while(g&&@isPromise(g)&&(@getPromiseInternalField(g,@promiseFieldFlags)&@promiseStateMask)===@promiseStateFulfilled)g=@getPromiseInternalField(g,@promiseFieldReactionsOrResult);if(g&&@isPromise(g))g.then(()=>{},(j)=>{this.addError(b,j,0)})})\n"; // runOnLoadPlugins const JSC::ConstructAbility s_bundlerPluginRunOnLoadPluginsCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -32,7 +32,7 @@ const JSC::ConstructorKind s_bundlerPluginRunOnLoadPluginsCodeConstructorKind = const JSC::ImplementationVisibility s_bundlerPluginRunOnLoadPluginsCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_bundlerPluginRunOnLoadPluginsCodeLength = 1325; static const JSC::Intrinsic s_bundlerPluginRunOnLoadPluginsCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_bundlerPluginRunOnLoadPluginsCode = "(function (b,g,j,q){\"use strict\";const v={jsx:0,js:1,ts:2,tsx:3,css:4,file:5,json:6,toml:7,wasm:8,napi:9,base64:10,dataurl:11,text:12},w=[\"jsx\",\"js\",\"ts\",\"tsx\",\"css\",\"file\",\"json\",\"toml\",\"wasm\",\"napi\",\"base64\",\"dataurl\",\"text\"][q];var x=(async(y,z,B,C)=>{var F=this.onLoad.@get(B);if(!F)return this.onLoadAsync(y,null,null),null;for(let[K,Q]of F)if(K.test(z)){var G=Q({path:z,namespace:B,loader:C});while(G&&@isPromise(G)&&(@getPromiseInternalField(G,@promiseFieldFlags)&@promiseStateMask)===@promiseStateFulfilled)G=@getPromiseInternalField(G,@promiseFieldReactionsOrResult);if(G&&@isPromise(G))G=await G;if(!G||!@isObject(G))continue;var{contents:H,loader:J=C}=G;if(typeof H!==\"string\"&&!@isTypedArrayView(H))@throwTypeError('onLoad plugins must return an object with \"contents\" as a string or Uint8Array');if(typeof J!==\"string\")@throwTypeError('onLoad plugins must return an object with \"loader\" as a string');const T=v[J];if(T===@undefined)@throwTypeError(`Loader ${J} is not supported.`);return this.onLoadAsync(y,H,T),null}return this.onLoadAsync(y,null,null),null})(b,g,j,w);while(x&&@isPromise(x)&&(@getPromiseInternalField(x,@promiseFieldFlags)&@promiseStateMask)===@promiseStateFulfilled)x=@getPromiseInternalField(x,@promiseFieldReactionsOrResult);if(x&&@isPromise(x))x.then(()=>{},(y)=>{this.addError(b,y,1)})})\n"; +const char* const s_bundlerPluginRunOnLoadPluginsCode = "(function (w,F,G,H){\"use strict\";const J={jsx:0,js:1,ts:2,tsx:3,css:4,file:5,json:6,toml:7,wasm:8,napi:9,base64:10,dataurl:11,text:12},K=[\"jsx\",\"js\",\"ts\",\"tsx\",\"css\",\"file\",\"json\",\"toml\",\"wasm\",\"napi\",\"base64\",\"dataurl\",\"text\"][H];var g=(async(j,x,y,z)=>{var B=this.onLoad.@get(y);if(!B)return this.onLoadAsync(j,null,null),null;for(let[Q,T]of B)if(Q.test(x)){var b=T({path:x,namespace:y,loader:z});while(b&&@isPromise(b)&&(@getPromiseInternalField(b,@promiseFieldFlags)&@promiseStateMask)===@promiseStateFulfilled)b=@getPromiseInternalField(b,@promiseFieldReactionsOrResult);if(b&&@isPromise(b))b=await b;if(!b||!@isObject(b))continue;var{contents:q,loader:v=z}=b;if(typeof q!==\"string\"&&!@isTypedArrayView(q))@throwTypeError('onLoad plugins must return an object with \"contents\" as a string or Uint8Array');if(typeof v!==\"string\")@throwTypeError('onLoad plugins must return an object with \"loader\" as a string');const C=J[v];if(C===@undefined)@throwTypeError(`Loader ${v} is not supported.`);return this.onLoadAsync(j,q,C),null}return this.onLoadAsync(j,null,null),null})(w,F,G,K);while(g&&@isPromise(g)&&(@getPromiseInternalField(g,@promiseFieldFlags)&@promiseStateMask)===@promiseStateFulfilled)g=@getPromiseInternalField(g,@promiseFieldReactionsOrResult);if(g&&@isPromise(g))g.then(()=>{},(j)=>{this.addError(w,j,1)})})\n"; #define DEFINE_BUILTIN_GENERATOR(codeName, functionName, overriddenName, argumentCount) \ JSC::FunctionExecutable* codeName##Generator(JSC::VM& vm) \ @@ -108,7 +108,7 @@ const JSC::ConstructorKind s_writableStreamInternalsCreateWritableStreamCodeCons const JSC::ImplementationVisibility s_writableStreamInternalsCreateWritableStreamCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_writableStreamInternalsCreateWritableStreamCodeLength = 278; static const JSC::Intrinsic s_writableStreamInternalsCreateWritableStreamCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_writableStreamInternalsCreateWritableStreamCode = "(function (u,N,d,f,p,_){\"use strict\";@assert(typeof p===\"number\"&&!@isNaN(p)&&p>=0);const j={};@initializeWritableStreamSlots(j,{});const q=new @WritableStreamDefaultController;return @setUpWritableStreamDefaultController(j,q,u,N,d,f,p,_),@createWritableStreamFromInternal(j)})\n"; +const char* const s_writableStreamInternalsCreateWritableStreamCode = "(function (p,N,_,f,u,j){\"use strict\";@assert(typeof u===\"number\"&&!@isNaN(u)&&u>=0);const d={};@initializeWritableStreamSlots(d,{});const q=new @WritableStreamDefaultController;return @setUpWritableStreamDefaultController(d,q,p,N,_,f,u,j),@createWritableStreamFromInternal(d)})\n"; // createInternalWritableStreamFromUnderlyingSink const JSC::ConstructAbility s_writableStreamInternalsCreateInternalWritableStreamFromUnderlyingSinkCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -116,7 +116,7 @@ const JSC::ConstructorKind s_writableStreamInternalsCreateInternalWritableStream const JSC::ImplementationVisibility s_writableStreamInternalsCreateInternalWritableStreamFromUnderlyingSinkCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_writableStreamInternalsCreateInternalWritableStreamFromUnderlyingSinkCodeLength = 920; static const JSC::Intrinsic s_writableStreamInternalsCreateInternalWritableStreamFromUnderlyingSinkCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_writableStreamInternalsCreateInternalWritableStreamFromUnderlyingSinkCode = "(function (f,o){\"use strict\";const w={};if(f===@undefined)f={};if(o===@undefined)o={};if(!@isObject(f))@throwTypeError(\"WritableStream constructor takes an object as first argument\");if(\"type\"in f)@throwRangeError(\"Invalid type is specified\");const C=@extractSizeAlgorithm(o),E=@extractHighWaterMark(o,1),_={};if(\"start\"in f){if(_.start=f.start,typeof _.start!==\"function\")@throwTypeError(\"underlyingSink.start should be a function\")}if(\"write\"in f){if(_.write=f.write,typeof _.write!==\"function\")@throwTypeError(\"underlyingSink.write should be a function\")}if(\"close\"in f){if(_.close=f.close,typeof _.close!==\"function\")@throwTypeError(\"underlyingSink.close should be a function\")}if(\"abort\"in f){if(_.abort=f.abort,typeof _.abort!==\"function\")@throwTypeError(\"underlyingSink.abort should be a function\")}return @initializeWritableStreamSlots(w,f),@setUpWritableStreamDefaultControllerFromUnderlyingSink(w,f,_,E,C),w})\n"; +const char* const s_writableStreamInternalsCreateInternalWritableStreamFromUnderlyingSinkCode = "(function (f,w){\"use strict\";const C={};if(f===@undefined)f={};if(w===@undefined)w={};if(!@isObject(f))@throwTypeError(\"WritableStream constructor takes an object as first argument\");if(\"type\"in f)@throwRangeError(\"Invalid type is specified\");const E=@extractSizeAlgorithm(w),_=@extractHighWaterMark(w,1),o={};if(\"start\"in f){if(o.start=f.start,typeof o.start!==\"function\")@throwTypeError(\"underlyingSink.start should be a function\")}if(\"write\"in f){if(o.write=f.write,typeof o.write!==\"function\")@throwTypeError(\"underlyingSink.write should be a function\")}if(\"close\"in f){if(o.close=f.close,typeof o.close!==\"function\")@throwTypeError(\"underlyingSink.close should be a function\")}if(\"abort\"in f){if(o.abort=f.abort,typeof o.abort!==\"function\")@throwTypeError(\"underlyingSink.abort should be a function\")}return @initializeWritableStreamSlots(C,f),@setUpWritableStreamDefaultControllerFromUnderlyingSink(C,f,o,_,E),C})\n"; // initializeWritableStreamSlots const JSC::ConstructAbility s_writableStreamInternalsInitializeWritableStreamSlotsCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -156,7 +156,7 @@ const JSC::ConstructorKind s_writableStreamInternalsSetUpWritableStreamDefaultWr const JSC::ImplementationVisibility s_writableStreamInternalsSetUpWritableStreamDefaultWriterCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_writableStreamInternalsSetUpWritableStreamDefaultWriterCodeLength = 887; static const JSC::Intrinsic s_writableStreamInternalsSetUpWritableStreamDefaultWriterCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_writableStreamInternalsSetUpWritableStreamDefaultWriterCode = "(function (n,v){\"use strict\";if(@isWritableStreamLocked(v))@throwTypeError(\"WritableStream is locked\");@putByIdDirectPrivate(n,\"stream\",v),@putByIdDirectPrivate(v,\"writer\",n);const g=@newPromiseCapability(@Promise),h=@newPromiseCapability(@Promise);@putByIdDirectPrivate(n,\"readyPromise\",g),@putByIdDirectPrivate(n,\"closedPromise\",h);const B=@getByIdDirectPrivate(v,\"state\");if(B===\"writable\"){if(@writableStreamCloseQueuedOrInFlight(v)||!@getByIdDirectPrivate(v,\"backpressure\"))g.@resolve.@call()}else if(B===\"erroring\")g.@reject.@call(@undefined,@getByIdDirectPrivate(v,\"storedError\")),@markPromiseAsHandled(g.@promise);else if(B===\"closed\")g.@resolve.@call(),h.@resolve.@call();else{@assert(B===\"errored\");const _=@getByIdDirectPrivate(v,\"storedError\");g.@reject.@call(@undefined,_),@markPromiseAsHandled(g.@promise),h.@reject.@call(@undefined,_),@markPromiseAsHandled(h.@promise)}})\n"; +const char* const s_writableStreamInternalsSetUpWritableStreamDefaultWriterCode = "(function (g,n){\"use strict\";if(@isWritableStreamLocked(n))@throwTypeError(\"WritableStream is locked\");@putByIdDirectPrivate(g,\"stream\",n),@putByIdDirectPrivate(n,\"writer\",g);const v=@newPromiseCapability(@Promise),h=@newPromiseCapability(@Promise);@putByIdDirectPrivate(g,\"readyPromise\",v),@putByIdDirectPrivate(g,\"closedPromise\",h);const B=@getByIdDirectPrivate(n,\"state\");if(B===\"writable\"){if(@writableStreamCloseQueuedOrInFlight(n)||!@getByIdDirectPrivate(n,\"backpressure\"))v.@resolve.@call()}else if(B===\"erroring\")v.@reject.@call(@undefined,@getByIdDirectPrivate(n,\"storedError\")),@markPromiseAsHandled(v.@promise);else if(B===\"closed\")v.@resolve.@call(),h.@resolve.@call();else{@assert(B===\"errored\");const _=@getByIdDirectPrivate(n,\"storedError\");v.@reject.@call(@undefined,_),@markPromiseAsHandled(v.@promise),h.@reject.@call(@undefined,_),@markPromiseAsHandled(h.@promise)}})\n"; // writableStreamAbort const JSC::ConstructAbility s_writableStreamInternalsWritableStreamAbortCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -164,7 +164,7 @@ const JSC::ConstructorKind s_writableStreamInternalsWritableStreamAbortCodeConst const JSC::ImplementationVisibility s_writableStreamInternalsWritableStreamAbortCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_writableStreamInternalsWritableStreamAbortCodeLength = 501; static const JSC::Intrinsic s_writableStreamInternalsWritableStreamAbortCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_writableStreamInternalsWritableStreamAbortCode = "(function (c,h){\"use strict\";const B=@getByIdDirectPrivate(c,\"state\");if(B===\"closed\"||B===\"errored\")return @Promise.@resolve();const f=@getByIdDirectPrivate(c,\"pendingAbortRequest\");if(f!==@undefined)return f.promise.@promise;@assert(B===\"writable\"||B===\"erroring\");let _=!1;if(B===\"erroring\")_=!0,h=@undefined;const j=@newPromiseCapability(@Promise);if(@putByIdDirectPrivate(c,\"pendingAbortRequest\",{promise:j,reason:h,wasAlreadyErroring:_}),!_)@writableStreamStartErroring(c,h);return j.@promise})\n"; +const char* const s_writableStreamInternalsWritableStreamAbortCode = "(function (h,B){\"use strict\";const c=@getByIdDirectPrivate(h,\"state\");if(c===\"closed\"||c===\"errored\")return @Promise.@resolve();const f=@getByIdDirectPrivate(h,\"pendingAbortRequest\");if(f!==@undefined)return f.promise.@promise;@assert(c===\"writable\"||c===\"erroring\");let _=!1;if(c===\"erroring\")_=!0,B=@undefined;const j=@newPromiseCapability(@Promise);if(@putByIdDirectPrivate(h,\"pendingAbortRequest\",{promise:j,reason:B,wasAlreadyErroring:_}),!_)@writableStreamStartErroring(h,B);return j.@promise})\n"; // writableStreamClose const JSC::ConstructAbility s_writableStreamInternalsWritableStreamCloseCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -196,7 +196,7 @@ const JSC::ConstructorKind s_writableStreamInternalsWritableStreamDealWithReject const JSC::ImplementationVisibility s_writableStreamInternalsWritableStreamDealWithRejectionCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_writableStreamInternalsWritableStreamDealWithRejectionCodeLength = 189; static const JSC::Intrinsic s_writableStreamInternalsWritableStreamDealWithRejectionCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_writableStreamInternalsWritableStreamDealWithRejectionCode = "(function (i,n){\"use strict\";const c=@getByIdDirectPrivate(i,\"state\");if(c===\"writable\"){@writableStreamStartErroring(i,n);return}@assert(c===\"erroring\"),@writableStreamFinishErroring(i)})\n"; +const char* const s_writableStreamInternalsWritableStreamDealWithRejectionCode = "(function (i,c){\"use strict\";const n=@getByIdDirectPrivate(i,\"state\");if(n===\"writable\"){@writableStreamStartErroring(i,c);return}@assert(n===\"erroring\"),@writableStreamFinishErroring(i)})\n"; // writableStreamFinishErroring const JSC::ConstructAbility s_writableStreamInternalsWritableStreamFinishErroringCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -204,7 +204,7 @@ const JSC::ConstructorKind s_writableStreamInternalsWritableStreamFinishErroring const JSC::ImplementationVisibility s_writableStreamInternalsWritableStreamFinishErroringCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_writableStreamInternalsWritableStreamFinishErroringCodeLength = 1058; static const JSC::Intrinsic s_writableStreamInternalsWritableStreamFinishErroringCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_writableStreamInternalsWritableStreamFinishErroringCode = "(function (i){\"use strict\";@assert(@getByIdDirectPrivate(i,\"state\")===\"erroring\"),@assert(!@writableStreamHasOperationMarkedInFlight(i)),@putByIdDirectPrivate(i,\"state\",\"errored\");const _=@getByIdDirectPrivate(i,\"controller\");@getByIdDirectPrivate(_,\"errorSteps\").@call();const p=@getByIdDirectPrivate(i,\"storedError\"),h=@getByIdDirectPrivate(i,\"writeRequests\");for(var A=h.shift();A;A=h.shift())A.@reject.@call(@undefined,p);@putByIdDirectPrivate(i,\"writeRequests\",@createFIFO());const B=@getByIdDirectPrivate(i,\"pendingAbortRequest\");if(B===@undefined){@writableStreamRejectCloseAndClosedPromiseIfNeeded(i);return}if(@putByIdDirectPrivate(i,\"pendingAbortRequest\",@undefined),B.wasAlreadyErroring){B.promise.@reject.@call(@undefined,p),@writableStreamRejectCloseAndClosedPromiseIfNeeded(i);return}@getByIdDirectPrivate(_,\"abortSteps\").@call(@undefined,B.reason).@then(()=>{B.promise.@resolve.@call(),@writableStreamRejectCloseAndClosedPromiseIfNeeded(i)},(I)=>{B.promise.@reject.@call(@undefined,I),@writableStreamRejectCloseAndClosedPromiseIfNeeded(i)})})\n"; +const char* const s_writableStreamInternalsWritableStreamFinishErroringCode = "(function (i){\"use strict\";@assert(@getByIdDirectPrivate(i,\"state\")===\"erroring\"),@assert(!@writableStreamHasOperationMarkedInFlight(i)),@putByIdDirectPrivate(i,\"state\",\"errored\");const h=@getByIdDirectPrivate(i,\"controller\");@getByIdDirectPrivate(h,\"errorSteps\").@call();const A=@getByIdDirectPrivate(i,\"storedError\"),B=@getByIdDirectPrivate(i,\"writeRequests\");for(var p=B.shift();p;p=B.shift())p.@reject.@call(@undefined,A);@putByIdDirectPrivate(i,\"writeRequests\",@createFIFO());const _=@getByIdDirectPrivate(i,\"pendingAbortRequest\");if(_===@undefined){@writableStreamRejectCloseAndClosedPromiseIfNeeded(i);return}if(@putByIdDirectPrivate(i,\"pendingAbortRequest\",@undefined),_.wasAlreadyErroring){_.promise.@reject.@call(@undefined,A),@writableStreamRejectCloseAndClosedPromiseIfNeeded(i);return}@getByIdDirectPrivate(h,\"abortSteps\").@call(@undefined,_.reason).@then(()=>{_.promise.@resolve.@call(),@writableStreamRejectCloseAndClosedPromiseIfNeeded(i)},(I)=>{_.promise.@reject.@call(@undefined,I),@writableStreamRejectCloseAndClosedPromiseIfNeeded(i)})})\n"; // writableStreamFinishInFlightClose const JSC::ConstructAbility s_writableStreamInternalsWritableStreamFinishInFlightCloseCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -212,7 +212,7 @@ const JSC::ConstructorKind s_writableStreamInternalsWritableStreamFinishInFlight const JSC::ImplementationVisibility s_writableStreamInternalsWritableStreamFinishInFlightCloseCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_writableStreamInternalsWritableStreamFinishInFlightCloseCodeLength = 751; static const JSC::Intrinsic s_writableStreamInternalsWritableStreamFinishInFlightCloseCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_writableStreamInternalsWritableStreamFinishInFlightCloseCode = "(function (d){\"use strict\";@getByIdDirectPrivate(d,\"inFlightCloseRequest\").@resolve.@call(),@putByIdDirectPrivate(d,\"inFlightCloseRequest\",@undefined);const n=@getByIdDirectPrivate(d,\"state\");if(@assert(n===\"writable\"||n===\"erroring\"),n===\"erroring\"){@putByIdDirectPrivate(d,\"storedError\",@undefined);const c=@getByIdDirectPrivate(d,\"pendingAbortRequest\");if(c!==@undefined)c.promise.@resolve.@call(),@putByIdDirectPrivate(d,\"pendingAbortRequest\",@undefined)}@putByIdDirectPrivate(d,\"state\",\"closed\");const _=@getByIdDirectPrivate(d,\"writer\");if(_!==@undefined)@getByIdDirectPrivate(_,\"closedPromise\").@resolve.@call();@assert(@getByIdDirectPrivate(d,\"pendingAbortRequest\")===@undefined),@assert(@getByIdDirectPrivate(d,\"storedError\")===@undefined)})\n"; +const char* const s_writableStreamInternalsWritableStreamFinishInFlightCloseCode = "(function (d){\"use strict\";@getByIdDirectPrivate(d,\"inFlightCloseRequest\").@resolve.@call(),@putByIdDirectPrivate(d,\"inFlightCloseRequest\",@undefined);const i=@getByIdDirectPrivate(d,\"state\");if(@assert(i===\"writable\"||i===\"erroring\"),i===\"erroring\"){@putByIdDirectPrivate(d,\"storedError\",@undefined);const _=@getByIdDirectPrivate(d,\"pendingAbortRequest\");if(_!==@undefined)_.promise.@resolve.@call(),@putByIdDirectPrivate(d,\"pendingAbortRequest\",@undefined)}@putByIdDirectPrivate(d,\"state\",\"closed\");const n=@getByIdDirectPrivate(d,\"writer\");if(n!==@undefined)@getByIdDirectPrivate(n,\"closedPromise\").@resolve.@call();@assert(@getByIdDirectPrivate(d,\"pendingAbortRequest\")===@undefined),@assert(@getByIdDirectPrivate(d,\"storedError\")===@undefined)})\n"; // writableStreamFinishInFlightCloseWithError const JSC::ConstructAbility s_writableStreamInternalsWritableStreamFinishInFlightCloseWithErrorCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -292,7 +292,7 @@ const JSC::ConstructorKind s_writableStreamInternalsWritableStreamDefaultWriterA const JSC::ImplementationVisibility s_writableStreamInternalsWritableStreamDefaultWriterAbortCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_writableStreamInternalsWritableStreamDefaultWriterAbortCodeLength = 130; static const JSC::Intrinsic s_writableStreamInternalsWritableStreamDefaultWriterAbortCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_writableStreamInternalsWritableStreamDefaultWriterAbortCode = "(function (c,d){\"use strict\";const f=@getByIdDirectPrivate(c,\"stream\");return @assert(f!==@undefined),@writableStreamAbort(f,d)})\n"; +const char* const s_writableStreamInternalsWritableStreamDefaultWriterAbortCode = "(function (d,f){\"use strict\";const c=@getByIdDirectPrivate(d,\"stream\");return @assert(c!==@undefined),@writableStreamAbort(c,f)})\n"; // writableStreamDefaultWriterClose const JSC::ConstructAbility s_writableStreamInternalsWritableStreamDefaultWriterCloseCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -300,7 +300,7 @@ const JSC::ConstructorKind s_writableStreamInternalsWritableStreamDefaultWriterC const JSC::ImplementationVisibility s_writableStreamInternalsWritableStreamDefaultWriterCloseCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_writableStreamInternalsWritableStreamDefaultWriterCloseCodeLength = 126; static const JSC::Intrinsic s_writableStreamInternalsWritableStreamDefaultWriterCloseCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_writableStreamInternalsWritableStreamDefaultWriterCloseCode = "(function (_){\"use strict\";const c=@getByIdDirectPrivate(_,\"stream\");return @assert(c!==@undefined),@writableStreamClose(c)})\n"; +const char* const s_writableStreamInternalsWritableStreamDefaultWriterCloseCode = "(function (c){\"use strict\";const _=@getByIdDirectPrivate(c,\"stream\");return @assert(_!==@undefined),@writableStreamClose(_)})\n"; // writableStreamDefaultWriterCloseWithErrorPropagation const JSC::ConstructAbility s_writableStreamInternalsWritableStreamDefaultWriterCloseWithErrorPropagationCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -308,7 +308,7 @@ const JSC::ConstructorKind s_writableStreamInternalsWritableStreamDefaultWriterC const JSC::ImplementationVisibility s_writableStreamInternalsWritableStreamDefaultWriterCloseWithErrorPropagationCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_writableStreamInternalsWritableStreamDefaultWriterCloseWithErrorPropagationCodeLength = 385; static const JSC::Intrinsic s_writableStreamInternalsWritableStreamDefaultWriterCloseWithErrorPropagationCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_writableStreamInternalsWritableStreamDefaultWriterCloseWithErrorPropagationCode = "(function (c){\"use strict\";const l=@getByIdDirectPrivate(c,\"stream\");@assert(l!==@undefined);const u=@getByIdDirectPrivate(l,\"state\");if(@writableStreamCloseQueuedOrInFlight(l)||u===\"closed\")return @Promise.@resolve();if(u===\"errored\")return @Promise.@reject(@getByIdDirectPrivate(l,\"storedError\"));return @assert(u===\"writable\"||u===\"erroring\"),@writableStreamDefaultWriterClose(c)})\n"; +const char* const s_writableStreamInternalsWritableStreamDefaultWriterCloseWithErrorPropagationCode = "(function (u){\"use strict\";const c=@getByIdDirectPrivate(u,\"stream\");@assert(c!==@undefined);const l=@getByIdDirectPrivate(c,\"state\");if(@writableStreamCloseQueuedOrInFlight(c)||l===\"closed\")return @Promise.@resolve();if(l===\"errored\")return @Promise.@reject(@getByIdDirectPrivate(c,\"storedError\"));return @assert(l===\"writable\"||l===\"erroring\"),@writableStreamDefaultWriterClose(u)})\n"; // writableStreamDefaultWriterEnsureClosedPromiseRejected const JSC::ConstructAbility s_writableStreamInternalsWritableStreamDefaultWriterEnsureClosedPromiseRejectedCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -316,7 +316,7 @@ const JSC::ConstructorKind s_writableStreamInternalsWritableStreamDefaultWriterE const JSC::ImplementationVisibility s_writableStreamInternalsWritableStreamDefaultWriterEnsureClosedPromiseRejectedCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_writableStreamInternalsWritableStreamDefaultWriterEnsureClosedPromiseRejectedCodeLength = 329; static const JSC::Intrinsic s_writableStreamInternalsWritableStreamDefaultWriterEnsureClosedPromiseRejectedCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_writableStreamInternalsWritableStreamDefaultWriterEnsureClosedPromiseRejectedCode = "(function (_,n){\"use strict\";let h=@getByIdDirectPrivate(_,\"closedPromise\"),u=h.@promise;if((@getPromiseInternalField(u,@promiseFieldFlags)&@promiseStateMask)!==@promiseStatePending)h=@newPromiseCapability(@Promise),u=h.@promise,@putByIdDirectPrivate(_,\"closedPromise\",h);h.@reject.@call(@undefined,n),@markPromiseAsHandled(u)})\n"; +const char* const s_writableStreamInternalsWritableStreamDefaultWriterEnsureClosedPromiseRejectedCode = "(function (h,u){\"use strict\";let _=@getByIdDirectPrivate(h,\"closedPromise\"),n=_.@promise;if((@getPromiseInternalField(n,@promiseFieldFlags)&@promiseStateMask)!==@promiseStatePending)_=@newPromiseCapability(@Promise),n=_.@promise,@putByIdDirectPrivate(h,\"closedPromise\",_);_.@reject.@call(@undefined,u),@markPromiseAsHandled(n)})\n"; // writableStreamDefaultWriterEnsureReadyPromiseRejected const JSC::ConstructAbility s_writableStreamInternalsWritableStreamDefaultWriterEnsureReadyPromiseRejectedCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -324,7 +324,7 @@ const JSC::ConstructorKind s_writableStreamInternalsWritableStreamDefaultWriterE const JSC::ImplementationVisibility s_writableStreamInternalsWritableStreamDefaultWriterEnsureReadyPromiseRejectedCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_writableStreamInternalsWritableStreamDefaultWriterEnsureReadyPromiseRejectedCodeLength = 327; static const JSC::Intrinsic s_writableStreamInternalsWritableStreamDefaultWriterEnsureReadyPromiseRejectedCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_writableStreamInternalsWritableStreamDefaultWriterEnsureReadyPromiseRejectedCode = "(function (c,g){\"use strict\";let h=@getByIdDirectPrivate(c,\"readyPromise\"),n=h.@promise;if((@getPromiseInternalField(n,@promiseFieldFlags)&@promiseStateMask)!==@promiseStatePending)h=@newPromiseCapability(@Promise),n=h.@promise,@putByIdDirectPrivate(c,\"readyPromise\",h);h.@reject.@call(@undefined,g),@markPromiseAsHandled(n)})\n"; +const char* const s_writableStreamInternalsWritableStreamDefaultWriterEnsureReadyPromiseRejectedCode = "(function (h,n){\"use strict\";let c=@getByIdDirectPrivate(h,\"readyPromise\"),g=c.@promise;if((@getPromiseInternalField(g,@promiseFieldFlags)&@promiseStateMask)!==@promiseStatePending)c=@newPromiseCapability(@Promise),g=c.@promise,@putByIdDirectPrivate(h,\"readyPromise\",c);c.@reject.@call(@undefined,n),@markPromiseAsHandled(g)})\n"; // writableStreamDefaultWriterGetDesiredSize const JSC::ConstructAbility s_writableStreamInternalsWritableStreamDefaultWriterGetDesiredSizeCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -332,7 +332,7 @@ const JSC::ConstructorKind s_writableStreamInternalsWritableStreamDefaultWriterG const JSC::ImplementationVisibility s_writableStreamInternalsWritableStreamDefaultWriterGetDesiredSizeCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_writableStreamInternalsWritableStreamDefaultWriterGetDesiredSizeCodeLength = 299; static const JSC::Intrinsic s_writableStreamInternalsWritableStreamDefaultWriterGetDesiredSizeCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_writableStreamInternalsWritableStreamDefaultWriterGetDesiredSizeCode = "(function (c){\"use strict\";const l=@getByIdDirectPrivate(c,\"stream\");@assert(l!==@undefined);const _=@getByIdDirectPrivate(l,\"state\");if(_===\"errored\"||_===\"erroring\")return null;if(_===\"closed\")return 0;return @writableStreamDefaultControllerGetDesiredSize(@getByIdDirectPrivate(l,\"controller\"))})\n"; +const char* const s_writableStreamInternalsWritableStreamDefaultWriterGetDesiredSizeCode = "(function (_){\"use strict\";const c=@getByIdDirectPrivate(_,\"stream\");@assert(c!==@undefined);const l=@getByIdDirectPrivate(c,\"state\");if(l===\"errored\"||l===\"erroring\")return null;if(l===\"closed\")return 0;return @writableStreamDefaultControllerGetDesiredSize(@getByIdDirectPrivate(c,\"controller\"))})\n"; // writableStreamDefaultWriterRelease const JSC::ConstructAbility s_writableStreamInternalsWritableStreamDefaultWriterReleaseCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -340,7 +340,7 @@ const JSC::ConstructorKind s_writableStreamInternalsWritableStreamDefaultWriterR const JSC::ImplementationVisibility s_writableStreamInternalsWritableStreamDefaultWriterReleaseCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_writableStreamInternalsWritableStreamDefaultWriterReleaseCodeLength = 414; static const JSC::Intrinsic s_writableStreamInternalsWritableStreamDefaultWriterReleaseCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_writableStreamInternalsWritableStreamDefaultWriterReleaseCode = "(function (_){\"use strict\";const h=@getByIdDirectPrivate(_,\"stream\");@assert(h!==@undefined),@assert(@getByIdDirectPrivate(h,\"writer\")===_);const c=@makeTypeError(\"writableStreamDefaultWriterRelease\");@writableStreamDefaultWriterEnsureReadyPromiseRejected(_,c),@writableStreamDefaultWriterEnsureClosedPromiseRejected(_,c),@putByIdDirectPrivate(h,\"writer\",@undefined),@putByIdDirectPrivate(_,\"stream\",@undefined)})\n"; +const char* const s_writableStreamInternalsWritableStreamDefaultWriterReleaseCode = "(function (_){\"use strict\";const c=@getByIdDirectPrivate(_,\"stream\");@assert(c!==@undefined),@assert(@getByIdDirectPrivate(c,\"writer\")===_);const h=@makeTypeError(\"writableStreamDefaultWriterRelease\");@writableStreamDefaultWriterEnsureReadyPromiseRejected(_,h),@writableStreamDefaultWriterEnsureClosedPromiseRejected(_,h),@putByIdDirectPrivate(c,\"writer\",@undefined),@putByIdDirectPrivate(_,\"stream\",@undefined)})\n"; // writableStreamDefaultWriterWrite const JSC::ConstructAbility s_writableStreamInternalsWritableStreamDefaultWriterWriteCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -348,7 +348,7 @@ const JSC::ConstructorKind s_writableStreamInternalsWritableStreamDefaultWriterW const JSC::ImplementationVisibility s_writableStreamInternalsWritableStreamDefaultWriterWriteCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_writableStreamInternalsWritableStreamDefaultWriterWriteCodeLength = 919; static const JSC::Intrinsic s_writableStreamInternalsWritableStreamDefaultWriterWriteCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_writableStreamInternalsWritableStreamDefaultWriterWriteCode = "(function (d,g){\"use strict\";const P=@getByIdDirectPrivate(d,\"stream\");@assert(P!==@undefined);const W=@getByIdDirectPrivate(P,\"controller\");@assert(W!==@undefined);const _=@writableStreamDefaultControllerGetChunkSize(W,g);if(P!==@getByIdDirectPrivate(d,\"stream\"))return @Promise.@reject(@makeTypeError(\"writer is not stream's writer\"));const b=@getByIdDirectPrivate(P,\"state\");if(b===\"errored\")return @Promise.@reject(@getByIdDirectPrivate(P,\"storedError\"));if(@writableStreamCloseQueuedOrInFlight(P)||b===\"closed\")return @Promise.@reject(@makeTypeError(\"stream is closing or closed\"));if(@writableStreamCloseQueuedOrInFlight(P)||b===\"closed\")return @Promise.@reject(@makeTypeError(\"stream is closing or closed\"));if(b===\"erroring\")return @Promise.@reject(@getByIdDirectPrivate(P,\"storedError\"));@assert(b===\"writable\");const f=@writableStreamAddWriteRequest(P);return @writableStreamDefaultControllerWrite(W,g,_),f})\n"; +const char* const s_writableStreamInternalsWritableStreamDefaultWriterWriteCode = "(function (W,_){\"use strict\";const d=@getByIdDirectPrivate(W,\"stream\");@assert(d!==@undefined);const P=@getByIdDirectPrivate(d,\"controller\");@assert(P!==@undefined);const b=@writableStreamDefaultControllerGetChunkSize(P,_);if(d!==@getByIdDirectPrivate(W,\"stream\"))return @Promise.@reject(@makeTypeError(\"writer is not stream's writer\"));const g=@getByIdDirectPrivate(d,\"state\");if(g===\"errored\")return @Promise.@reject(@getByIdDirectPrivate(d,\"storedError\"));if(@writableStreamCloseQueuedOrInFlight(d)||g===\"closed\")return @Promise.@reject(@makeTypeError(\"stream is closing or closed\"));if(@writableStreamCloseQueuedOrInFlight(d)||g===\"closed\")return @Promise.@reject(@makeTypeError(\"stream is closing or closed\"));if(g===\"erroring\")return @Promise.@reject(@getByIdDirectPrivate(d,\"storedError\"));@assert(g===\"writable\");const f=@writableStreamAddWriteRequest(d);return @writableStreamDefaultControllerWrite(P,_,b),f})\n"; // setUpWritableStreamDefaultController const JSC::ConstructAbility s_writableStreamInternalsSetUpWritableStreamDefaultControllerCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -356,7 +356,7 @@ const JSC::ConstructorKind s_writableStreamInternalsSetUpWritableStreamDefaultCo const JSC::ImplementationVisibility s_writableStreamInternalsSetUpWritableStreamDefaultControllerCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_writableStreamInternalsSetUpWritableStreamDefaultControllerCodeLength = 700; static const JSC::Intrinsic s_writableStreamInternalsSetUpWritableStreamDefaultControllerCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_writableStreamInternalsSetUpWritableStreamDefaultControllerCode = "(function (_,B,d,v,f,P,j,U){\"use strict\";@assert(@isWritableStream(_)),@assert(@getByIdDirectPrivate(_,\"controller\")===@undefined),@putByIdDirectPrivate(B,\"stream\",_),@putByIdDirectPrivate(_,\"controller\",B),@resetQueue(@getByIdDirectPrivate(B,\"queue\")),@putByIdDirectPrivate(B,\"started\",-1),@putByIdDirectPrivate(B,\"startAlgorithm\",d),@putByIdDirectPrivate(B,\"strategySizeAlgorithm\",U),@putByIdDirectPrivate(B,\"strategyHWM\",j),@putByIdDirectPrivate(B,\"writeAlgorithm\",v),@putByIdDirectPrivate(B,\"closeAlgorithm\",f),@putByIdDirectPrivate(B,\"abortAlgorithm\",P);const q=@writableStreamDefaultControllerGetBackpressure(B);@writableStreamUpdateBackpressure(_,q),@writableStreamDefaultControllerStart(B)})\n"; +const char* const s_writableStreamInternalsSetUpWritableStreamDefaultControllerCode = "(function (B,_,v,P,U,d,f,j){\"use strict\";@assert(@isWritableStream(B)),@assert(@getByIdDirectPrivate(B,\"controller\")===@undefined),@putByIdDirectPrivate(_,\"stream\",B),@putByIdDirectPrivate(B,\"controller\",_),@resetQueue(@getByIdDirectPrivate(_,\"queue\")),@putByIdDirectPrivate(_,\"started\",-1),@putByIdDirectPrivate(_,\"startAlgorithm\",v),@putByIdDirectPrivate(_,\"strategySizeAlgorithm\",j),@putByIdDirectPrivate(_,\"strategyHWM\",f),@putByIdDirectPrivate(_,\"writeAlgorithm\",P),@putByIdDirectPrivate(_,\"closeAlgorithm\",U),@putByIdDirectPrivate(_,\"abortAlgorithm\",d);const q=@writableStreamDefaultControllerGetBackpressure(_);@writableStreamUpdateBackpressure(B,q),@writableStreamDefaultControllerStart(_)})\n"; // writableStreamDefaultControllerStart const JSC::ConstructAbility s_writableStreamInternalsWritableStreamDefaultControllerStartCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -364,7 +364,7 @@ const JSC::ConstructorKind s_writableStreamInternalsWritableStreamDefaultControl const JSC::ImplementationVisibility s_writableStreamInternalsWritableStreamDefaultControllerStartCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_writableStreamInternalsWritableStreamDefaultControllerStartCodeLength = 647; static const JSC::Intrinsic s_writableStreamInternalsWritableStreamDefaultControllerStartCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_writableStreamInternalsWritableStreamDefaultControllerStartCode = "(function (i){\"use strict\";if(@getByIdDirectPrivate(i,\"started\")!==-1)return;@putByIdDirectPrivate(i,\"started\",0);const _=@getByIdDirectPrivate(i,\"startAlgorithm\");@putByIdDirectPrivate(i,\"startAlgorithm\",@undefined);const d=@getByIdDirectPrivate(i,\"stream\");return @Promise.@resolve(_.@call()).@then(()=>{const u=@getByIdDirectPrivate(d,\"state\");@assert(u===\"writable\"||u===\"erroring\"),@putByIdDirectPrivate(i,\"started\",1),@writableStreamDefaultControllerAdvanceQueueIfNeeded(i)},(u)=>{const p=@getByIdDirectPrivate(d,\"state\");@assert(p===\"writable\"||p===\"erroring\"),@putByIdDirectPrivate(i,\"started\",1),@writableStreamDealWithRejection(d,u)})})\n"; +const char* const s_writableStreamInternalsWritableStreamDefaultControllerStartCode = "(function (i){\"use strict\";if(@getByIdDirectPrivate(i,\"started\")!==-1)return;@putByIdDirectPrivate(i,\"started\",0);const p=@getByIdDirectPrivate(i,\"startAlgorithm\");@putByIdDirectPrivate(i,\"startAlgorithm\",@undefined);const d=@getByIdDirectPrivate(i,\"stream\");return @Promise.@resolve(p.@call()).@then(()=>{const _=@getByIdDirectPrivate(d,\"state\");@assert(_===\"writable\"||_===\"erroring\"),@putByIdDirectPrivate(i,\"started\",1),@writableStreamDefaultControllerAdvanceQueueIfNeeded(i)},(_)=>{const u=@getByIdDirectPrivate(d,\"state\");@assert(u===\"writable\"||u===\"erroring\"),@putByIdDirectPrivate(i,\"started\",1),@writableStreamDealWithRejection(d,_)})})\n"; // setUpWritableStreamDefaultControllerFromUnderlyingSink const JSC::ConstructAbility s_writableStreamInternalsSetUpWritableStreamDefaultControllerFromUnderlyingSinkCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -372,7 +372,7 @@ const JSC::ConstructorKind s_writableStreamInternalsSetUpWritableStreamDefaultCo const JSC::ImplementationVisibility s_writableStreamInternalsSetUpWritableStreamDefaultControllerFromUnderlyingSinkCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_writableStreamInternalsSetUpWritableStreamDefaultControllerFromUnderlyingSinkCodeLength = 561; static const JSC::Intrinsic s_writableStreamInternalsSetUpWritableStreamDefaultControllerFromUnderlyingSinkCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_writableStreamInternalsSetUpWritableStreamDefaultControllerFromUnderlyingSinkCode = "(function (_,j,v,p,f){\"use strict\";const q=new @WritableStreamDefaultController;let x=()=>{},B=()=>{return @Promise.@resolve()},C=()=>{return @Promise.@resolve()},O=()=>{return @Promise.@resolve()};if(\"start\"in v){const E=v.start;x=()=>@promiseInvokeOrNoopMethodNoCatch(j,E,[q])}if(\"write\"in v){const E=v.write;B=(F)=>@promiseInvokeOrNoopMethod(j,E,[F,q])}if(\"close\"in v){const E=v.close;C=()=>@promiseInvokeOrNoopMethod(j,E,[])}if(\"abort\"in v){const E=v.abort;O=(F)=>@promiseInvokeOrNoopMethod(j,E,[F])}@setUpWritableStreamDefaultController(_,q,x,B,C,O,p,f)})\n"; +const char* const s_writableStreamInternalsSetUpWritableStreamDefaultControllerFromUnderlyingSinkCode = "(function (C,O,_,E,F){\"use strict\";const f=new @WritableStreamDefaultController;let q=()=>{},v=()=>{return @Promise.@resolve()},x=()=>{return @Promise.@resolve()},B=()=>{return @Promise.@resolve()};if(\"start\"in _){const p=_.start;q=()=>@promiseInvokeOrNoopMethodNoCatch(O,p,[f])}if(\"write\"in _){const p=_.write;v=(j)=>@promiseInvokeOrNoopMethod(O,p,[j,f])}if(\"close\"in _){const p=_.close;x=()=>@promiseInvokeOrNoopMethod(O,p,[])}if(\"abort\"in _){const p=_.abort;B=(j)=>@promiseInvokeOrNoopMethod(O,p,[j])}@setUpWritableStreamDefaultController(C,f,q,v,x,B,E,F)})\n"; // writableStreamDefaultControllerAdvanceQueueIfNeeded const JSC::ConstructAbility s_writableStreamInternalsWritableStreamDefaultControllerAdvanceQueueIfNeededCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -412,7 +412,7 @@ const JSC::ConstructorKind s_writableStreamInternalsWritableStreamDefaultControl const JSC::ImplementationVisibility s_writableStreamInternalsWritableStreamDefaultControllerErrorCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_writableStreamInternalsWritableStreamDefaultControllerErrorCodeLength = 237; static const JSC::Intrinsic s_writableStreamInternalsWritableStreamDefaultControllerErrorCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_writableStreamInternalsWritableStreamDefaultControllerErrorCode = "(function (i,h){\"use strict\";const b=@getByIdDirectPrivate(i,\"stream\");@assert(b!==@undefined),@assert(@getByIdDirectPrivate(b,\"state\")===\"writable\"),@writableStreamDefaultControllerClearAlgorithms(i),@writableStreamStartErroring(b,h)})\n"; +const char* const s_writableStreamInternalsWritableStreamDefaultControllerErrorCode = "(function (h,b){\"use strict\";const i=@getByIdDirectPrivate(h,\"stream\");@assert(i!==@undefined),@assert(@getByIdDirectPrivate(i,\"state\")===\"writable\"),@writableStreamDefaultControllerClearAlgorithms(h),@writableStreamStartErroring(i,b)})\n"; // writableStreamDefaultControllerErrorIfNeeded const JSC::ConstructAbility s_writableStreamInternalsWritableStreamDefaultControllerErrorIfNeededCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -460,7 +460,7 @@ const JSC::ConstructorKind s_writableStreamInternalsWritableStreamDefaultControl const JSC::ImplementationVisibility s_writableStreamInternalsWritableStreamDefaultControllerProcessWriteCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_writableStreamInternalsWritableStreamDefaultControllerProcessWriteCodeLength = 734; static const JSC::Intrinsic s_writableStreamInternalsWritableStreamDefaultControllerProcessWriteCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_writableStreamInternalsWritableStreamDefaultControllerProcessWriteCode = "(function (i,d){\"use strict\";const _=@getByIdDirectPrivate(i,\"stream\");@writableStreamMarkFirstWriteRequestInFlight(_),@getByIdDirectPrivate(i,\"writeAlgorithm\").@call(@undefined,d).@then(()=>{@writableStreamFinishInFlightWrite(_);const v=@getByIdDirectPrivate(_,\"state\");if(@assert(v===\"writable\"||v===\"erroring\"),@dequeueValue(@getByIdDirectPrivate(i,\"queue\")),!@writableStreamCloseQueuedOrInFlight(_)&&v===\"writable\"){const M=@writableStreamDefaultControllerGetBackpressure(i);@writableStreamUpdateBackpressure(_,M)}@writableStreamDefaultControllerAdvanceQueueIfNeeded(i)},(v)=>{if(@getByIdDirectPrivate(_,\"state\")===\"writable\")@writableStreamDefaultControllerClearAlgorithms(i);@writableStreamFinishInFlightWriteWithError(_,v)})})\n"; +const char* const s_writableStreamInternalsWritableStreamDefaultControllerProcessWriteCode = "(function (d,v){\"use strict\";const i=@getByIdDirectPrivate(d,\"stream\");@writableStreamMarkFirstWriteRequestInFlight(i),@getByIdDirectPrivate(d,\"writeAlgorithm\").@call(@undefined,v).@then(()=>{@writableStreamFinishInFlightWrite(i);const _=@getByIdDirectPrivate(i,\"state\");if(@assert(_===\"writable\"||_===\"erroring\"),@dequeueValue(@getByIdDirectPrivate(d,\"queue\")),!@writableStreamCloseQueuedOrInFlight(i)&&_===\"writable\"){const q=@writableStreamDefaultControllerGetBackpressure(d);@writableStreamUpdateBackpressure(i,q)}@writableStreamDefaultControllerAdvanceQueueIfNeeded(d)},(_)=>{if(@getByIdDirectPrivate(i,\"state\")===\"writable\")@writableStreamDefaultControllerClearAlgorithms(d);@writableStreamFinishInFlightWriteWithError(i,_)})})\n"; // writableStreamDefaultControllerWrite const JSC::ConstructAbility s_writableStreamInternalsWritableStreamDefaultControllerWriteCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -468,7 +468,7 @@ const JSC::ConstructorKind s_writableStreamInternalsWritableStreamDefaultControl const JSC::ImplementationVisibility s_writableStreamInternalsWritableStreamDefaultControllerWriteCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_writableStreamInternalsWritableStreamDefaultControllerWriteCodeLength = 450; static const JSC::Intrinsic s_writableStreamInternalsWritableStreamDefaultControllerWriteCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_writableStreamInternalsWritableStreamDefaultControllerWriteCode = "(function (y,B,D){\"use strict\";try{@enqueueValueWithSize(@getByIdDirectPrivate(y,\"queue\"),B,D);const I=@getByIdDirectPrivate(y,\"stream\"),_=@getByIdDirectPrivate(I,\"state\");if(!@writableStreamCloseQueuedOrInFlight(I)&&_===\"writable\"){const d=@writableStreamDefaultControllerGetBackpressure(y);@writableStreamUpdateBackpressure(I,d)}@writableStreamDefaultControllerAdvanceQueueIfNeeded(y)}catch(I){@writableStreamDefaultControllerErrorIfNeeded(y,I)}})\n"; +const char* const s_writableStreamInternalsWritableStreamDefaultControllerWriteCode = "(function (d,B,D){\"use strict\";try{@enqueueValueWithSize(@getByIdDirectPrivate(d,\"queue\"),B,D);const y=@getByIdDirectPrivate(d,\"stream\"),I=@getByIdDirectPrivate(y,\"state\");if(!@writableStreamCloseQueuedOrInFlight(y)&&I===\"writable\"){const _=@writableStreamDefaultControllerGetBackpressure(d);@writableStreamUpdateBackpressure(y,_)}@writableStreamDefaultControllerAdvanceQueueIfNeeded(d)}catch(y){@writableStreamDefaultControllerErrorIfNeeded(d,y)}})\n"; #define DEFINE_BUILTIN_GENERATOR(codeName, functionName, overriddenName, argumentCount) \ JSC::FunctionExecutable* codeName##Generator(JSC::VM& vm) \ @@ -502,7 +502,7 @@ const JSC::ConstructorKind s_transformStreamInternalsCreateTransformStreamCodeCo const JSC::ImplementationVisibility s_transformStreamInternalsCreateTransformStreamCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_transformStreamInternalsCreateTransformStreamCodeLength = 513; static const JSC::Intrinsic s_transformStreamInternalsCreateTransformStreamCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_transformStreamInternalsCreateTransformStreamCode = "(function (j,q,v,x,B,D,E){\"use strict\";if(x===@undefined)x=1;if(B===@undefined)B=()=>1;if(D===@undefined)D=0;if(E===@undefined)E=()=>1;@assert(x>=0),@assert(D>=0);const F={};@putByIdDirectPrivate(F,\"TransformStream\",!0);const G=new @TransformStream(F),I=@newPromiseCapability(@Promise);@initializeTransformStream(G,I.@promise,x,B,D,E);const _=new @TransformStreamDefaultController;return @setUpTransformStreamDefaultController(G,_,q,v),j().@then(()=>{I.@resolve.@call()},(c)=>{I.@reject.@call(@undefined,c)}),G})\n"; +const char* const s_transformStreamInternalsCreateTransformStreamCode = "(function (D,E,F,_,j,c,q){\"use strict\";if(_===@undefined)_=1;if(j===@undefined)j=()=>1;if(c===@undefined)c=0;if(q===@undefined)q=()=>1;@assert(_>=0),@assert(c>=0);const B={};@putByIdDirectPrivate(B,\"TransformStream\",!0);const v=new @TransformStream(B),x=@newPromiseCapability(@Promise);@initializeTransformStream(v,x.@promise,_,j,c,q);const G=new @TransformStreamDefaultController;return @setUpTransformStreamDefaultController(v,G,E,F),D().@then(()=>{x.@resolve.@call()},(I)=>{x.@reject.@call(@undefined,I)}),v})\n"; // initializeTransformStream const JSC::ConstructAbility s_transformStreamInternalsInitializeTransformStreamCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -510,7 +510,7 @@ const JSC::ConstructorKind s_transformStreamInternalsInitializeTransformStreamCo const JSC::ImplementationVisibility s_transformStreamInternalsInitializeTransformStreamCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_transformStreamInternalsInitializeTransformStreamCodeLength = 1015; static const JSC::Intrinsic s_transformStreamInternalsInitializeTransformStreamCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_transformStreamInternalsInitializeTransformStreamCode = "(function (f,G,B,T,C,F){\"use strict\";const I=()=>{return G},J=(x)=>{return @transformStreamDefaultSinkWriteAlgorithm(f,x)},K=(x)=>{return @transformStreamDefaultSinkAbortAlgorithm(f,x)},j=()=>{return @transformStreamDefaultSinkCloseAlgorithm(f)},L=@createWritableStream(I,J,j,K,B,T),N=()=>{return @transformStreamDefaultSourcePullAlgorithm(f)},q=(x)=>{return @transformStreamErrorWritableAndUnblockWrite(f,x),@Promise.@resolve()},D={};@putByIdDirectPrivate(D,\"start\",I),@putByIdDirectPrivate(D,\"pull\",N),@putByIdDirectPrivate(D,\"cancel\",q);const E={};@putByIdDirectPrivate(E,\"size\",F),@putByIdDirectPrivate(E,\"highWaterMark\",C);const v=new @ReadableStream(D,E);@putByIdDirectPrivate(f,\"writable\",L),@putByIdDirectPrivate(f,\"internalWritable\",@getInternalWritableStream(L)),@putByIdDirectPrivate(f,\"readable\",v),@putByIdDirectPrivate(f,\"backpressure\",@undefined),@putByIdDirectPrivate(f,\"backpressureChangePromise\",@undefined),@transformStreamSetBackpressure(f,!0),@putByIdDirectPrivate(f,\"controller\",@undefined)})\n"; +const char* const s_transformStreamInternalsInitializeTransformStreamCode = "(function (f,x,C,D,E,F){\"use strict\";const q=()=>{return x},G=(B)=>{return @transformStreamDefaultSinkWriteAlgorithm(f,B)},I=(B)=>{return @transformStreamDefaultSinkAbortAlgorithm(f,B)},J=()=>{return @transformStreamDefaultSinkCloseAlgorithm(f)},v=@createWritableStream(q,G,J,I,C,D),K=()=>{return @transformStreamDefaultSourcePullAlgorithm(f)},L=(B)=>{return @transformStreamErrorWritableAndUnblockWrite(f,B),@Promise.@resolve()},T={};@putByIdDirectPrivate(T,\"start\",q),@putByIdDirectPrivate(T,\"pull\",K),@putByIdDirectPrivate(T,\"cancel\",L);const j={};@putByIdDirectPrivate(j,\"size\",F),@putByIdDirectPrivate(j,\"highWaterMark\",E);const N=new @ReadableStream(T,j);@putByIdDirectPrivate(f,\"writable\",v),@putByIdDirectPrivate(f,\"internalWritable\",@getInternalWritableStream(v)),@putByIdDirectPrivate(f,\"readable\",N),@putByIdDirectPrivate(f,\"backpressure\",@undefined),@putByIdDirectPrivate(f,\"backpressureChangePromise\",@undefined),@transformStreamSetBackpressure(f,!0),@putByIdDirectPrivate(f,\"controller\",@undefined)})\n"; // transformStreamError const JSC::ConstructAbility s_transformStreamInternalsTransformStreamErrorCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -526,7 +526,7 @@ const JSC::ConstructorKind s_transformStreamInternalsTransformStreamErrorWritabl const JSC::ImplementationVisibility s_transformStreamInternalsTransformStreamErrorWritableAndUnblockWriteCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_transformStreamInternalsTransformStreamErrorWritableAndUnblockWriteCodeLength = 339; static const JSC::Intrinsic s_transformStreamInternalsTransformStreamErrorWritableAndUnblockWriteCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_transformStreamInternalsTransformStreamErrorWritableAndUnblockWriteCode = "(function (_,o){\"use strict\";@transformStreamDefaultControllerClearAlgorithms(@getByIdDirectPrivate(_,\"controller\"));const n=@getByIdDirectPrivate(_,\"internalWritable\");if(@writableStreamDefaultControllerErrorIfNeeded(@getByIdDirectPrivate(n,\"controller\"),o),@getByIdDirectPrivate(_,\"backpressure\"))@transformStreamSetBackpressure(_,!1)})\n"; +const char* const s_transformStreamInternalsTransformStreamErrorWritableAndUnblockWriteCode = "(function (_,n){\"use strict\";@transformStreamDefaultControllerClearAlgorithms(@getByIdDirectPrivate(_,\"controller\"));const o=@getByIdDirectPrivate(_,\"internalWritable\");if(@writableStreamDefaultControllerErrorIfNeeded(@getByIdDirectPrivate(o,\"controller\"),n),@getByIdDirectPrivate(_,\"backpressure\"))@transformStreamSetBackpressure(_,!1)})\n"; // transformStreamSetBackpressure const JSC::ConstructAbility s_transformStreamInternalsTransformStreamSetBackpressureCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -550,7 +550,7 @@ const JSC::ConstructorKind s_transformStreamInternalsSetUpTransformStreamDefault const JSC::ImplementationVisibility s_transformStreamInternalsSetUpTransformStreamDefaultControllerFromTransformerCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_transformStreamInternalsSetUpTransformStreamDefaultControllerFromTransformerCodeLength = 443; static const JSC::Intrinsic s_transformStreamInternalsSetUpTransformStreamDefaultControllerFromTransformerCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_transformStreamInternalsSetUpTransformStreamDefaultControllerFromTransformerCode = "(function (_,d,p){\"use strict\";const v=new @TransformStreamDefaultController;let b=(q)=>{try{@transformStreamDefaultControllerEnqueue(v,q)}catch(w){return @Promise.@reject(w)}return @Promise.@resolve()},j=()=>{return @Promise.@resolve()};if(\"transform\"in p)b=(q)=>{return @promiseInvokeOrNoopMethod(d,p.transform,[q,v])};if(\"flush\"in p)j=()=>{return @promiseInvokeOrNoopMethod(d,p.flush,[v])};@setUpTransformStreamDefaultController(_,v,b,j)})\n"; +const char* const s_transformStreamInternalsSetUpTransformStreamDefaultControllerFromTransformerCode = "(function (q,v,_){\"use strict\";const d=new @TransformStreamDefaultController;let b=(p)=>{try{@transformStreamDefaultControllerEnqueue(d,p)}catch(w){return @Promise.@reject(w)}return @Promise.@resolve()},j=()=>{return @Promise.@resolve()};if(\"transform\"in _)b=(p)=>{return @promiseInvokeOrNoopMethod(v,_.transform,[p,d])};if(\"flush\"in _)j=()=>{return @promiseInvokeOrNoopMethod(v,_.flush,[d])};@setUpTransformStreamDefaultController(q,d,b,j)})\n"; // transformStreamDefaultControllerClearAlgorithms const JSC::ConstructAbility s_transformStreamInternalsTransformStreamDefaultControllerClearAlgorithmsCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -566,7 +566,7 @@ const JSC::ConstructorKind s_transformStreamInternalsTransformStreamDefaultContr const JSC::ImplementationVisibility s_transformStreamInternalsTransformStreamDefaultControllerEnqueueCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_transformStreamInternalsTransformStreamDefaultControllerEnqueueCodeLength = 622; static const JSC::Intrinsic s_transformStreamInternalsTransformStreamDefaultControllerEnqueueCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_transformStreamInternalsTransformStreamDefaultControllerEnqueueCode = "(function (S,W){\"use strict\";const f=@getByIdDirectPrivate(S,\"stream\"),g=@getByIdDirectPrivate(f,\"readable\"),i=@getByIdDirectPrivate(g,\"readableStreamController\");if(@assert(i!==@undefined),!@readableStreamDefaultControllerCanCloseOrEnqueue(i))@throwTypeError(\"TransformStream.readable cannot close or enqueue\");try{@readableStreamDefaultControllerEnqueue(i,W)}catch(j){throw @transformStreamErrorWritableAndUnblockWrite(f,j),@getByIdDirectPrivate(g,\"storedError\")}const _=!@readableStreamDefaultControllerShouldCallPull(i);if(_!==@getByIdDirectPrivate(f,\"backpressure\"))@assert(_),@transformStreamSetBackpressure(f,!0)})\n"; +const char* const s_transformStreamInternalsTransformStreamDefaultControllerEnqueueCode = "(function (g,i){\"use strict\";const _=@getByIdDirectPrivate(g,\"stream\"),W=@getByIdDirectPrivate(_,\"readable\"),S=@getByIdDirectPrivate(W,\"readableStreamController\");if(@assert(S!==@undefined),!@readableStreamDefaultControllerCanCloseOrEnqueue(S))@throwTypeError(\"TransformStream.readable cannot close or enqueue\");try{@readableStreamDefaultControllerEnqueue(S,i)}catch(j){throw @transformStreamErrorWritableAndUnblockWrite(_,j),@getByIdDirectPrivate(W,\"storedError\")}const f=!@readableStreamDefaultControllerShouldCallPull(S);if(f!==@getByIdDirectPrivate(_,\"backpressure\"))@assert(f),@transformStreamSetBackpressure(_,!0)})\n"; // transformStreamDefaultControllerError const JSC::ConstructAbility s_transformStreamInternalsTransformStreamDefaultControllerErrorCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -582,7 +582,7 @@ const JSC::ConstructorKind s_transformStreamInternalsTransformStreamDefaultContr const JSC::ImplementationVisibility s_transformStreamInternalsTransformStreamDefaultControllerPerformTransformCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_transformStreamInternalsTransformStreamDefaultControllerPerformTransformCodeLength = 277; static const JSC::Intrinsic s_transformStreamInternalsTransformStreamDefaultControllerPerformTransformCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_transformStreamInternalsTransformStreamDefaultControllerPerformTransformCode = "(function (_,d){\"use strict\";const f=@newPromiseCapability(@Promise);return @getByIdDirectPrivate(_,\"transformAlgorithm\").@call(@undefined,d).@then(()=>{f.@resolve()},(j)=>{@transformStreamError(@getByIdDirectPrivate(_,\"stream\"),j),f.@reject.@call(@undefined,j)}),f.@promise})\n"; +const char* const s_transformStreamInternalsTransformStreamDefaultControllerPerformTransformCode = "(function (d,g){\"use strict\";const _=@newPromiseCapability(@Promise);return @getByIdDirectPrivate(d,\"transformAlgorithm\").@call(@undefined,g).@then(()=>{_.@resolve()},(f)=>{@transformStreamError(@getByIdDirectPrivate(d,\"stream\"),f),_.@reject.@call(@undefined,f)}),_.@promise})\n"; // transformStreamDefaultControllerTerminate const JSC::ConstructAbility s_transformStreamInternalsTransformStreamDefaultControllerTerminateCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -590,7 +590,7 @@ const JSC::ConstructorKind s_transformStreamInternalsTransformStreamDefaultContr const JSC::ImplementationVisibility s_transformStreamInternalsTransformStreamDefaultControllerTerminateCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_transformStreamInternalsTransformStreamDefaultControllerTerminateCodeLength = 367; static const JSC::Intrinsic s_transformStreamInternalsTransformStreamDefaultControllerTerminateCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_transformStreamInternalsTransformStreamDefaultControllerTerminateCode = "(function (i){\"use strict\";const _=@getByIdDirectPrivate(i,\"stream\"),f=@getByIdDirectPrivate(_,\"readable\"),k=@getByIdDirectPrivate(f,\"readableStreamController\");if(@readableStreamDefaultControllerCanCloseOrEnqueue(k))@readableStreamDefaultControllerClose(k);const u=@makeTypeError(\"the stream has been terminated\");@transformStreamErrorWritableAndUnblockWrite(_,u)})\n"; +const char* const s_transformStreamInternalsTransformStreamDefaultControllerTerminateCode = "(function (f){\"use strict\";const i=@getByIdDirectPrivate(f,\"stream\"),k=@getByIdDirectPrivate(i,\"readable\"),_=@getByIdDirectPrivate(k,\"readableStreamController\");if(@readableStreamDefaultControllerCanCloseOrEnqueue(_))@readableStreamDefaultControllerClose(_);const u=@makeTypeError(\"the stream has been terminated\");@transformStreamErrorWritableAndUnblockWrite(i,u)})\n"; // transformStreamDefaultSinkWriteAlgorithm const JSC::ConstructAbility s_transformStreamInternalsTransformStreamDefaultSinkWriteAlgorithmCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -598,7 +598,7 @@ const JSC::ConstructorKind s_transformStreamInternalsTransformStreamDefaultSinkW const JSC::ImplementationVisibility s_transformStreamInternalsTransformStreamDefaultSinkWriteAlgorithmCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_transformStreamInternalsTransformStreamDefaultSinkWriteAlgorithmCodeLength = 764; static const JSC::Intrinsic s_transformStreamInternalsTransformStreamDefaultSinkWriteAlgorithmCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_transformStreamInternalsTransformStreamDefaultSinkWriteAlgorithmCode = "(function (d,v){\"use strict\";const f=@getByIdDirectPrivate(d,\"internalWritable\");@assert(@getByIdDirectPrivate(f,\"state\")===\"writable\");const j=@getByIdDirectPrivate(d,\"controller\");if(@getByIdDirectPrivate(d,\"backpressure\")){const q=@newPromiseCapability(@Promise),_=@getByIdDirectPrivate(d,\"backpressureChangePromise\");return @assert(_!==@undefined),_.@promise.@then(()=>{const x=@getByIdDirectPrivate(f,\"state\");if(x===\"erroring\"){q.@reject.@call(@undefined,@getByIdDirectPrivate(f,\"storedError\"));return}@assert(x===\"writable\"),@transformStreamDefaultControllerPerformTransform(j,v).@then(()=>{q.@resolve()},(z)=>{q.@reject.@call(@undefined,z)})},(x)=>{q.@reject.@call(@undefined,x)}),q.@promise}return @transformStreamDefaultControllerPerformTransform(j,v)})\n"; +const char* const s_transformStreamInternalsTransformStreamDefaultSinkWriteAlgorithmCode = "(function (d,j){\"use strict\";const f=@getByIdDirectPrivate(d,\"internalWritable\");@assert(@getByIdDirectPrivate(f,\"state\")===\"writable\");const q=@getByIdDirectPrivate(d,\"controller\");if(@getByIdDirectPrivate(d,\"backpressure\")){const _=@newPromiseCapability(@Promise),x=@getByIdDirectPrivate(d,\"backpressureChangePromise\");return @assert(x!==@undefined),x.@promise.@then(()=>{const v=@getByIdDirectPrivate(f,\"state\");if(v===\"erroring\"){_.@reject.@call(@undefined,@getByIdDirectPrivate(f,\"storedError\"));return}@assert(v===\"writable\"),@transformStreamDefaultControllerPerformTransform(q,j).@then(()=>{_.@resolve()},(z)=>{_.@reject.@call(@undefined,z)})},(v)=>{_.@reject.@call(@undefined,v)}),_.@promise}return @transformStreamDefaultControllerPerformTransform(q,j)})\n"; // transformStreamDefaultSinkAbortAlgorithm const JSC::ConstructAbility s_transformStreamInternalsTransformStreamDefaultSinkAbortAlgorithmCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -606,7 +606,7 @@ const JSC::ConstructorKind s_transformStreamInternalsTransformStreamDefaultSinkA const JSC::ImplementationVisibility s_transformStreamInternalsTransformStreamDefaultSinkAbortAlgorithmCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_transformStreamInternalsTransformStreamDefaultSinkAbortAlgorithmCodeLength = 85; static const JSC::Intrinsic s_transformStreamInternalsTransformStreamDefaultSinkAbortAlgorithmCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_transformStreamInternalsTransformStreamDefaultSinkAbortAlgorithmCode = "(function (t,d){\"use strict\";return @transformStreamError(t,d),@Promise.@resolve()})\n"; +const char* const s_transformStreamInternalsTransformStreamDefaultSinkAbortAlgorithmCode = "(function (d,t){\"use strict\";return @transformStreamError(d,t),@Promise.@resolve()})\n"; // transformStreamDefaultSinkCloseAlgorithm const JSC::ConstructAbility s_transformStreamInternalsTransformStreamDefaultSinkCloseAlgorithmCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -614,7 +614,7 @@ const JSC::ConstructorKind s_transformStreamInternalsTransformStreamDefaultSinkC const JSC::ImplementationVisibility s_transformStreamInternalsTransformStreamDefaultSinkCloseAlgorithmCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_transformStreamInternalsTransformStreamDefaultSinkCloseAlgorithmCodeLength = 789; static const JSC::Intrinsic s_transformStreamInternalsTransformStreamDefaultSinkCloseAlgorithmCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_transformStreamInternalsTransformStreamDefaultSinkCloseAlgorithmCode = "(function (_){\"use strict\";const I=@getByIdDirectPrivate(_,\"readable\"),k=@getByIdDirectPrivate(_,\"controller\"),f=@getByIdDirectPrivate(I,\"readableStreamController\"),u=@getByIdDirectPrivate(k,\"flushAlgorithm\");@assert(u!==@undefined);const v=@getByIdDirectPrivate(k,\"flushAlgorithm\").@call();@transformStreamDefaultControllerClearAlgorithms(k);const q=@newPromiseCapability(@Promise);return v.@then(()=>{if(@getByIdDirectPrivate(I,\"state\")===@streamErrored){q.@reject.@call(@undefined,@getByIdDirectPrivate(I,\"storedError\"));return}if(@readableStreamDefaultControllerCanCloseOrEnqueue(f))@readableStreamDefaultControllerClose(f);q.@resolve()},(j)=>{@transformStreamError(@getByIdDirectPrivate(k,\"stream\"),j),q.@reject.@call(@undefined,@getByIdDirectPrivate(I,\"storedError\"))}),q.@promise})\n"; +const char* const s_transformStreamInternalsTransformStreamDefaultSinkCloseAlgorithmCode = "(function (f){\"use strict\";const _=@getByIdDirectPrivate(f,\"readable\"),q=@getByIdDirectPrivate(f,\"controller\"),j=@getByIdDirectPrivate(_,\"readableStreamController\"),k=@getByIdDirectPrivate(q,\"flushAlgorithm\");@assert(k!==@undefined);const u=@getByIdDirectPrivate(q,\"flushAlgorithm\").@call();@transformStreamDefaultControllerClearAlgorithms(q);const I=@newPromiseCapability(@Promise);return u.@then(()=>{if(@getByIdDirectPrivate(_,\"state\")===@streamErrored){I.@reject.@call(@undefined,@getByIdDirectPrivate(_,\"storedError\"));return}if(@readableStreamDefaultControllerCanCloseOrEnqueue(j))@readableStreamDefaultControllerClose(j);I.@resolve()},(v)=>{@transformStreamError(@getByIdDirectPrivate(q,\"stream\"),v),I.@reject.@call(@undefined,@getByIdDirectPrivate(_,\"storedError\"))}),I.@promise})\n"; // transformStreamDefaultSourcePullAlgorithm const JSC::ConstructAbility s_transformStreamInternalsTransformStreamDefaultSourcePullAlgorithmCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -640,7 +640,7 @@ const JSC::ConstructorKind s_processObjectInternalsBindingCodeConstructorKind = const JSC::ImplementationVisibility s_processObjectInternalsBindingCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_processObjectInternalsBindingCodeLength = 473; static const JSC::Intrinsic s_processObjectInternalsBindingCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_processObjectInternalsBindingCode = "(function (d){\"use strict\";if(d!==\"constants\")@throwTypeError(\"process.binding() is not supported in Bun. If that breaks something, please file an issue and include a reproducible code sample.\");var l=globalThis.Symbol.for(\"process.bindings.constants\"),I=globalThis[l];if(!I){const{constants:r}=globalThis[globalThis.Symbol.for(\"Bun.lazy\")](\"createImportMeta\",\"node:process\").require(\"node:fs\");I={fs:r,zlib:{},crypto:{},os:@Bun._Os().constants},globalThis[l]=I}return I})\n"; +const char* const s_processObjectInternalsBindingCode = "(function (I){\"use strict\";if(I!==\"constants\")@throwTypeError(\"process.binding() is not supported in Bun. If that breaks something, please file an issue and include a reproducible code sample.\");var r=globalThis.Symbol.for(\"process.bindings.constants\"),l=globalThis[r];if(!l){const{constants:d}=globalThis[globalThis.Symbol.for(\"Bun.lazy\")](\"createImportMeta\",\"node:process\").require(\"node:fs\");l={fs:d,zlib:{},crypto:{},os:@Bun._Os().constants},globalThis[r]=l}return l})\n"; // getStdioWriteStream const JSC::ConstructAbility s_processObjectInternalsGetStdioWriteStreamCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -648,7 +648,7 @@ const JSC::ConstructorKind s_processObjectInternalsGetStdioWriteStreamCodeConstr const JSC::ImplementationVisibility s_processObjectInternalsGetStdioWriteStreamCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_processObjectInternalsGetStdioWriteStreamCodeLength = 4311; static const JSC::Intrinsic s_processObjectInternalsGetStdioWriteStreamCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_processObjectInternalsGetStdioWriteStreamCode = "(function (z){\"use strict\";var G=(U)=>{var V=@requireMap.get(U);if(V)return V.exports;return @internalRequire(U)},J={path:\"node:process\",require:G};function K(U){var{Duplex:V,eos:X,destroy:j}=G(\"node:stream\"),B=class Z extends V{#$;#G;#j=!0;#z=!0;#B;#H;#J;#K;#L;#M;get isTTY(){return this.#M\?\?=G(\"node:tty\").isatty(U)}get fd(){return U}constructor(Y){super({readable:!0,writable:!0});this.#B=`/dev/fd/${Y}`}#N(Y){const P=this.#H;if(this.#H=null,P)P(Y);else if(Y)this.destroy(Y);else if(!this.#j&&!this.#z)this.destroy()}_destroy(Y,P){if(!Y&&this.#H!==null){var A=class D extends Error{code;name;constructor(H=\"The operation was aborted\",N=void 0){if(N!==void 0&&typeof N!==\"object\")throw new Error(`Invalid AbortError options:\\n\\n${JSON.stringify(N,null,2)}`);super(H,N);this.code=\"ABORT_ERR\",this.name=\"AbortError\"}};Y=new A}if(this.#J=null,this.#K=null,this.#H===null)P(Y);else{if(this.#H=P,this.#$)j(this.#$,Y);if(this.#G)j(this.#G,Y)}}_write(Y,P,A){if(!this.#$){var{createWriteStream:D}=G(\"node:fs\"),H=this.#$=D(this.#B);H.on(\"finish\",()=>{if(this.#K){const N=this.#K;this.#K=null,N()}}),H.on(\"drain\",()=>{if(this.#J){const N=this.#J;this.#J=null,N()}}),X(H,(N)=>{if(this.#z=!1,N)j(H,N);this.#N(N)})}if(H.write(Y,P))A();else this.#J=A}_final(Y){this.#$&&this.#$.end(),this.#K=Y}#O(){var{createReadStream:Y}=G(\"node:fs\"),P=this.#G=Y(this.#B);return P.on(\"readable\",()=>{if(this.#L){const A=this.#L;this.#L=null,A()}else this.read()}),P.on(\"end\",()=>{this.push(null)}),X(P,(A)=>{if(this.#j=!1,A)j(P,A);this.#N(A)}),P}_read(){var Y=this.#G;if(!Y)Y=this.#O();while(!0){const P=Y.read();if(P===null||!this.push(P))return}}};return new B(U)}var{EventEmitter:L}=G(\"node:events\");function O(U){if(!U)return!0;var V=U.toLowerCase();return V===\"utf8\"||V===\"utf-8\"||V===\"buffer\"||V===\"binary\"}var M,Q=class U extends L{#$;#G;#j;#z;bytesWritten=0;setDefaultEncoding(V){if(this.#G||!O(V))return this.#J(),this.#G.setDefaultEncoding(V)}#B(){switch(this.#$){case 1:{var V=@Bun.stdout.writer({highWaterMark:0});return V.unref(),V}case 2:{var V=@Bun.stderr.writer({highWaterMark:0});return V.unref(),V}default:throw new Error(\"Unsupported writer\")}}#H(){return this.#j\?\?=this.#B()}constructor(V){super();this.#$=V}get fd(){return this.#$}get isTTY(){return this.#z\?\?=G(\"node:tty\").isatty(this.#$)}cursorTo(V,X,j){return(M\?\?=G(\"readline\")).cursorTo(this,V,X,j)}moveCursor(V,X,j){return(M\?\?=G(\"readline\")).moveCursor(this,V,X,j)}clearLine(V,X){return(M\?\?=G(\"readline\")).clearLine(this,V,X)}clearScreenDown(V){return(M\?\?=G(\"readline\")).clearScreenDown(this,V)}ref(){this.#H().ref()}unref(){this.#H().unref()}on(V,X){if(V===\"close\"||V===\"finish\")return this.#J(),this.#G.on(V,X);if(V===\"drain\")return super.on(\"drain\",X);if(V===\"error\")return super.on(\"error\",X);return super.on(V,X)}get _writableState(){return this.#J(),this.#G._writableState}get _readableState(){return this.#J(),this.#G._readableState}pipe(V){return this.#J(),this.#G.pipe(V)}unpipe(V){return this.#J(),this.#G.unpipe(V)}#J(){if(this.#G)return;this.#G=K(this.#$);const V=this.eventNames();for(let X of V)this.#G.on(X,(...j)=>{this.emit(X,...j)})}#K(V){var X=this.#H();const j=X.write(V);this.bytesWritten+=j;const B=X.flush(!1);return!!(j||B)}#L(V,X){if(!O(X))return this.#J(),this.#G.write(V,X);return this.#K(V)}#M(V,X){if(X)this.emit(\"error\",X);try{V(X\?X:null)}catch(j){this.emit(\"error\",j)}}#N(V,X,j){if(!O(X))return this.#J(),this.#G.write(V,X,j);var B=this.#H();const Z=B.write(V),Y=B.flush(!0);if(Y\?.then)return Y.then(()=>{this.#M(j),this.emit(\"drain\")},(P)=>this.#M(j,P)),!1;return queueMicrotask(()=>{this.#M(j)}),!!(Z||Y)}write(V,X,j){const B=this._write(V,X,j);if(B)this.emit(\"drain\");return B}get hasColors(){return @Bun.tty[this.#$].hasColors}_write(V,X,j){var B=this.#G;if(B)return B.write(V,X,j);switch(arguments.length){case 0:{var Z=new Error(\"Invalid arguments\");throw Z.code=\"ERR_INVALID_ARG_TYPE\",Z}case 1:return this.#K(V);case 2:if(typeof X===\"function\")return this.#N(V,\"\",X);else if(typeof X===\"string\")return this.#L(V,X);default:{if(typeof X!==\"undefined\"&&typeof X!==\"string\"||typeof j!==\"undefined\"&&typeof j!==\"function\"){var Z=new Error(\"Invalid arguments\");throw Z.code=\"ERR_INVALID_ARG_TYPE\",Z}if(typeof j===\"undefined\")return this.#L(V,X);return this.#N(V,X,j)}}}destroy(){return this}end(){return this}};return new Q(z)})\n"; +const char* const s_processObjectInternalsGetStdioWriteStreamCode = "(function (Z){\"use strict\";var L=(M)=>{var G=@requireMap.get(M);if(G)return G.exports;return @internalRequire(M)},D={path:\"node:process\",require:L};function Y(M){var{Duplex:G,eos:j,destroy:z}=L(\"node:stream\"),J=class O extends G{#j;#$;#M=!0;#N=!0;#J;#z;#G;#B;#H;#K;get isTTY(){return this.#K\?\?=L(\"node:tty\").isatty(M)}get fd(){return M}constructor(B){super({readable:!0,writable:!0});this.#J=`/dev/fd/${B}`}#L(B){const H=this.#z;if(this.#z=null,H)H(B);else if(B)this.destroy(B);else if(!this.#M&&!this.#N)this.destroy()}_destroy(B,H){if(!B&&this.#z!==null){var N=class X extends Error{code;name;constructor(Q=\"The operation was aborted\",K=void 0){if(K!==void 0&&typeof K!==\"object\")throw new Error(`Invalid AbortError options:\\n\\n${JSON.stringify(K,null,2)}`);super(Q,K);this.code=\"ABORT_ERR\",this.name=\"AbortError\"}};B=new N}if(this.#G=null,this.#B=null,this.#z===null)H(B);else{if(this.#z=H,this.#j)z(this.#j,B);if(this.#$)z(this.#$,B)}}_write(B,H,N){if(!this.#j){var{createWriteStream:X}=L(\"node:fs\"),Q=this.#j=X(this.#J);Q.on(\"finish\",()=>{if(this.#B){const K=this.#B;this.#B=null,K()}}),Q.on(\"drain\",()=>{if(this.#G){const K=this.#G;this.#G=null,K()}}),j(Q,(K)=>{if(this.#N=!1,K)z(Q,K);this.#L(K)})}if(Q.write(B,H))N();else this.#G=N}_final(B){this.#j&&this.#j.end(),this.#B=B}#O(){var{createReadStream:B}=L(\"node:fs\"),H=this.#$=B(this.#J);return H.on(\"readable\",()=>{if(this.#H){const N=this.#H;this.#H=null,N()}else this.read()}),H.on(\"end\",()=>{this.push(null)}),j(H,(N)=>{if(this.#M=!1,N)z(H,N);this.#L(N)}),H}_read(){var B=this.#$;if(!B)B=this.#O();while(!0){const H=B.read();if(H===null||!this.push(H))return}}};return new J(M)}var{EventEmitter:P}=L(\"node:events\");function V(M){if(!M)return!0;var G=M.toLowerCase();return G===\"utf8\"||G===\"utf-8\"||G===\"buffer\"||G===\"binary\"}var U,A=class M extends P{#j;#$;#M;#N;bytesWritten=0;setDefaultEncoding(G){if(this.#$||!V(G))return this.#G(),this.#$.setDefaultEncoding(G)}#J(){switch(this.#j){case 1:{var G=@Bun.stdout.writer({highWaterMark:0});return G.unref(),G}case 2:{var G=@Bun.stderr.writer({highWaterMark:0});return G.unref(),G}default:throw new Error(\"Unsupported writer\")}}#z(){return this.#M\?\?=this.#J()}constructor(G){super();this.#j=G}get fd(){return this.#j}get isTTY(){return this.#N\?\?=L(\"node:tty\").isatty(this.#j)}cursorTo(G,j,z){return(U\?\?=L(\"readline\")).cursorTo(this,G,j,z)}moveCursor(G,j,z){return(U\?\?=L(\"readline\")).moveCursor(this,G,j,z)}clearLine(G,j){return(U\?\?=L(\"readline\")).clearLine(this,G,j)}clearScreenDown(G){return(U\?\?=L(\"readline\")).clearScreenDown(this,G)}ref(){this.#z().ref()}unref(){this.#z().unref()}on(G,j){if(G===\"close\"||G===\"finish\")return this.#G(),this.#$.on(G,j);if(G===\"drain\")return super.on(\"drain\",j);if(G===\"error\")return super.on(\"error\",j);return super.on(G,j)}get _writableState(){return this.#G(),this.#$._writableState}get _readableState(){return this.#G(),this.#$._readableState}pipe(G){return this.#G(),this.#$.pipe(G)}unpipe(G){return this.#G(),this.#$.unpipe(G)}#G(){if(this.#$)return;this.#$=Y(this.#j);const G=this.eventNames();for(let j of G)this.#$.on(j,(...z)=>{this.emit(j,...z)})}#B(G){var j=this.#z();const z=j.write(G);this.bytesWritten+=z;const J=j.flush(!1);return!!(z||J)}#H(G,j){if(!V(j))return this.#G(),this.#$.write(G,j);return this.#B(G)}#K(G,j){if(j)this.emit(\"error\",j);try{G(j\?j:null)}catch(z){this.emit(\"error\",z)}}#L(G,j,z){if(!V(j))return this.#G(),this.#$.write(G,j,z);var J=this.#z();const O=J.write(G),B=J.flush(!0);if(B\?.then)return B.then(()=>{this.#K(z),this.emit(\"drain\")},(H)=>this.#K(z,H)),!1;return queueMicrotask(()=>{this.#K(z)}),!!(O||B)}write(G,j,z){const J=this._write(G,j,z);if(J)this.emit(\"drain\");return J}get hasColors(){return @Bun.tty[this.#j].hasColors}_write(G,j,z){var J=this.#$;if(J)return J.write(G,j,z);switch(arguments.length){case 0:{var O=new Error(\"Invalid arguments\");throw O.code=\"ERR_INVALID_ARG_TYPE\",O}case 1:return this.#B(G);case 2:if(typeof j===\"function\")return this.#L(G,\"\",j);else if(typeof j===\"string\")return this.#H(G,j);default:{if(typeof j!==\"undefined\"&&typeof j!==\"string\"||typeof z!==\"undefined\"&&typeof z!==\"function\"){var O=new Error(\"Invalid arguments\");throw O.code=\"ERR_INVALID_ARG_TYPE\",O}if(typeof z===\"undefined\")return this.#H(G,j);return this.#L(G,j,z)}}}destroy(){return this}end(){return this}};return new A(Z)})\n"; // getStdinStream const JSC::ConstructAbility s_processObjectInternalsGetStdinStreamCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -656,7 +656,7 @@ const JSC::ConstructorKind s_processObjectInternalsGetStdinStreamCodeConstructor const JSC::ImplementationVisibility s_processObjectInternalsGetStdinStreamCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_processObjectInternalsGetStdinStreamCodeLength = 1861; static const JSC::Intrinsic s_processObjectInternalsGetStdinStreamCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_processObjectInternalsGetStdinStreamCode = "(function (N){\"use strict\";var j=(J)=>{var K=@requireMap.get(J);if(K)return K.exports;return @internalRequire(J)},z={path:\"node:process\",require:j},{Duplex:B,eos:G,destroy:H}=j(\"node:stream\"),I=class J extends B{#$;#N;#j;#z=!0;#B=!1;#G=!0;#H;#I;#J;get isTTY(){return j(\"tty\").isatty(N)}get fd(){return N}constructor(){super({readable:!0,writable:!0})}#K(K){const L=this.#I;if(this.#I=null,L)L(K);else if(K)this.destroy(K);else if(!this.#z&&!this.#G)this.destroy()}_destroy(K,L){if(!K&&this.#I!==null){var M=class P extends Error{constructor(Q=\"The operation was aborted\",T=void 0){if(T!==void 0&&typeof T!==\"object\")throw new Error(`Invalid AbortError options:\\n\\n${JSON.stringify(T,null,2)}`);super(Q,T);this.code=\"ABORT_ERR\",this.name=\"AbortError\"}};K=new M}if(this.#I===null)L(K);else if(this.#I=L,this.#j)H(this.#j,K)}setRawMode(K){}on(K,L){if(K===\"readable\")this.ref(),this.#B=!0;return super.on(K,L)}pause(){return this.unref(),super.pause()}resume(){return this.ref(),super.resume()}ref(){this.#$\?\?=@Bun.stdin.stream().getReader(),this.#N\?\?=setInterval(()=>{},1<<30)}unref(){if(this.#N)clearInterval(this.#N),this.#N=null}async#L(){try{var K,L;const M=this.#$.readMany();if(!M\?.then)({done:K,value:L}=M);else({done:K,value:L}=await M);if(!K){this.push(L[0]);const P=L.length;for(let Q=1;Q{if(this.#H){const M=this.#H;this.#H=null,M()}}),L.on(\"drain\",()=>{if(this.#J){const M=this.#J;this.#J=null,M()}}),G(L,(M)=>{if(this.#G=!1,M)H(L,M);this.#K(M)}),L}_write(K,L,M){var P=this.#j;if(!P)P=this.#M();if(P.write(K,L))M();else this.#J=M}_final(K){this.#j.end(),this.#H=(...L)=>K(...L)}};return new I})\n"; +const char* const s_processObjectInternalsGetStdinStreamCode = "(function (K){\"use strict\";var H=(I)=>{var N=@requireMap.get(I);if(N)return N.exports;return @internalRequire(I)},T={path:\"node:process\",require:H},{Duplex:M,eos:P,destroy:L}=H(\"node:stream\"),Q=class I extends M{#J;#j;#$;#G=!0;#H=!1;#K=!0;#z;#N;#B;get isTTY(){return H(\"tty\").isatty(K)}get fd(){return K}constructor(){super({readable:!0,writable:!0})}#I(N){const j=this.#N;if(this.#N=null,j)j(N);else if(N)this.destroy(N);else if(!this.#G&&!this.#K)this.destroy()}_destroy(N,j){if(!N&&this.#N!==null){var z=class B extends Error{constructor(G=\"The operation was aborted\",J=void 0){if(J!==void 0&&typeof J!==\"object\")throw new Error(`Invalid AbortError options:\\n\\n${JSON.stringify(J,null,2)}`);super(G,J);this.code=\"ABORT_ERR\",this.name=\"AbortError\"}};N=new z}if(this.#N===null)j(N);else if(this.#N=j,this.#$)L(this.#$,N)}setRawMode(N){}on(N,j){if(N===\"readable\")this.ref(),this.#H=!0;return super.on(N,j)}pause(){return this.unref(),super.pause()}resume(){return this.ref(),super.resume()}ref(){this.#J\?\?=@Bun.stdin.stream().getReader(),this.#j\?\?=setInterval(()=>{},1<<30)}unref(){if(this.#j)clearInterval(this.#j),this.#j=null}async#L(){try{var N,j;const z=this.#J.readMany();if(!z\?.then)({done:N,value:j}=z);else({done:N,value:j}=await z);if(!N){this.push(j[0]);const B=j.length;for(let G=1;G{if(this.#z){const z=this.#z;this.#z=null,z()}}),j.on(\"drain\",()=>{if(this.#B){const z=this.#B;this.#B=null,z()}}),P(j,(z)=>{if(this.#K=!1,z)L(j,z);this.#I(z)}),j}_write(N,j,z){var B=this.#$;if(!B)B=this.#M();if(B.write(N,j))z();else this.#B=z}_final(N){this.#$.end(),this.#z=(...j)=>N(...j)}};return new Q})\n"; #define DEFINE_BUILTIN_GENERATOR(codeName, functionName, overriddenName, argumentCount) \ JSC::FunctionExecutable* codeName##Generator(JSC::VM& vm) \ @@ -674,7 +674,7 @@ const JSC::ConstructorKind s_transformStreamInitializeTransformStreamCodeConstru const JSC::ImplementationVisibility s_transformStreamInitializeTransformStreamCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_transformStreamInitializeTransformStreamCodeLength = 1304; static const JSC::Intrinsic s_transformStreamInitializeTransformStreamCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_transformStreamInitializeTransformStreamCode = "(function (){\"use strict\";let j=arguments[0];if(@isObject(j)&&@getByIdDirectPrivate(j,\"TransformStream\"))return this;let q=arguments[1],v=arguments[2];if(j===@undefined)j=null;if(v===@undefined)v={};if(q===@undefined)q={};let x={};if(j!==null){if(\"start\"in j){if(x.start=j.start,typeof x.start!==\"function\")@throwTypeError(\"transformer.start should be a function\")}if(\"transform\"in j){if(x.transform=j.transform,typeof x.transform!==\"function\")@throwTypeError(\"transformer.transform should be a function\")}if(\"flush\"in j){if(x.flush=j.flush,typeof x.flush!==\"function\")@throwTypeError(\"transformer.flush should be a function\")}if(\"readableType\"in j)@throwRangeError(\"TransformStream transformer has a readableType\");if(\"writableType\"in j)@throwRangeError(\"TransformStream transformer has a writableType\")}const B=@extractHighWaterMark(v,0),E=@extractSizeAlgorithm(v),F=@extractHighWaterMark(q,1),G=@extractSizeAlgorithm(q),I=@newPromiseCapability(@Promise);if(@initializeTransformStream(this,I.@promise,F,G,B,E),@setUpTransformStreamDefaultControllerFromTransformer(this,j,x),(\"start\"in x)){const J=@getByIdDirectPrivate(this,\"controller\");(()=>@promiseInvokeOrNoopMethodNoCatch(j,x.start,[J]))().@then(()=>{I.@resolve.@call()},(u)=>{I.@reject.@call(@undefined,u)})}else I.@resolve.@call();return this})\n"; +const char* const s_transformStreamInitializeTransformStreamCode = "(function (){\"use strict\";let _=arguments[0];if(@isObject(_)&&@getByIdDirectPrivate(_,\"TransformStream\"))return this;let j=arguments[1],q=arguments[2];if(_===@undefined)_=null;if(q===@undefined)q={};if(j===@undefined)j={};let u={};if(_!==null){if(\"start\"in _){if(u.start=_.start,typeof u.start!==\"function\")@throwTypeError(\"transformer.start should be a function\")}if(\"transform\"in _){if(u.transform=_.transform,typeof u.transform!==\"function\")@throwTypeError(\"transformer.transform should be a function\")}if(\"flush\"in _){if(u.flush=_.flush,typeof u.flush!==\"function\")@throwTypeError(\"transformer.flush should be a function\")}if(\"readableType\"in _)@throwRangeError(\"TransformStream transformer has a readableType\");if(\"writableType\"in _)@throwRangeError(\"TransformStream transformer has a writableType\")}const x=@extractHighWaterMark(q,0),B=@extractSizeAlgorithm(q),E=@extractHighWaterMark(j,1),F=@extractSizeAlgorithm(j),v=@newPromiseCapability(@Promise);if(@initializeTransformStream(this,v.@promise,E,F,x,B),@setUpTransformStreamDefaultControllerFromTransformer(this,_,u),(\"start\"in u)){const G=@getByIdDirectPrivate(this,\"controller\");(()=>@promiseInvokeOrNoopMethodNoCatch(_,u.start,[G]))().@then(()=>{v.@resolve.@call()},(I)=>{v.@reject.@call(@undefined,I)})}else v.@resolve.@call();return this})\n"; // readable const JSC::ConstructAbility s_transformStreamReadableCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -716,7 +716,7 @@ const JSC::ConstructorKind s_moduleRequireCodeConstructorKind = JSC::Constructor const JSC::ImplementationVisibility s_moduleRequireCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_moduleRequireCodeLength = 1035; static const JSC::Intrinsic s_moduleRequireCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_moduleRequireCode = "(function (_){\"use strict\";const M=@requireMap.@get(_)||@requireMap.@get(_=@resolveSync(_,this.path,!1));if(M)return @evaluateCommonJSModule(M),M.exports;if(_.endsWith(\".json\")||_.endsWith(\".toml\")||_.endsWith(\".node\"))return @internalRequire(_);let S=@Loader.registry.@get(_);if(S\?.evaluated&&(S.state\?\?0)>=@ModuleReady){const b=S.module,h=@Loader.getModuleNamespaceObject(b),r=h\?.[@commonJSSymbol]===0||h\?.default\?.[@commonJSSymbol]===0\?h.default:h.__esModule\?h:Object.create(h,{__esModule:{value:!0}});return @requireMap.@set(_,@createCommonJSModule(_,r,!0)),r}const f=@createCommonJSModule(_,{},!1);@requireMap.@set(_,f);var L=this.@require(_,f);if(L===-1){try{L=@requireESM(_)}catch(b){throw @requireMap.@delete(_),b}if(S=@Loader.registry.@get(_),S\?.evaluated&&(S.state\?\?0)>=@ModuleReady){const b=@Loader.getModuleNamespaceObject(S.module);return f.exports=b\?.[@commonJSSymbol]===0||b\?.default\?.[@commonJSSymbol]===0\?b.default:b.__esModule\?b:Object.create(b,{__esModule:{value:!0}})}}return @evaluateCommonJSModule(f),f.exports})\n"; +const char* const s_moduleRequireCode = "(function (_){\"use strict\";const b=@requireMap.@get(_)||@requireMap.@get(_=@resolveSync(_,this.path,!1));if(b)return @evaluateCommonJSModule(b),b.exports;if(_.endsWith(\".json\")||_.endsWith(\".toml\")||_.endsWith(\".node\"))return @internalRequire(_);let S=@Loader.registry.@get(_);if(S\?.evaluated&&(S.state\?\?0)>=@ModuleReady){const M=S.module,f=@Loader.getModuleNamespaceObject(M),r=f\?.[@commonJSSymbol]===0||f\?.default\?.[@commonJSSymbol]===0\?f.default:f.__esModule\?f:Object.create(f,{__esModule:{value:!0}});return @requireMap.@set(_,@createCommonJSModule(_,r,!0)),r}const L=@createCommonJSModule(_,{},!1);@requireMap.@set(_,L);var h=this.@require(_,L);if(h===-1){try{h=@requireESM(_)}catch(M){throw @requireMap.@delete(_),M}if(S=@Loader.registry.@get(_),S\?.evaluated&&(S.state\?\?0)>=@ModuleReady){const M=@Loader.getModuleNamespaceObject(S.module);return L.exports=M\?.[@commonJSSymbol]===0||M\?.default\?.[@commonJSSymbol]===0\?M.default:M.__esModule\?M:Object.create(M,{__esModule:{value:!0}})}}return @evaluateCommonJSModule(L),L.exports})\n"; // requireResolve const JSC::ConstructAbility s_moduleRequireResolveCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -830,7 +830,7 @@ const JSC::ConstructorKind s_jsBufferPrototypeReadIntLECodeConstructorKind = JSC const JSC::ImplementationVisibility s_jsBufferPrototypeReadIntLECodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_jsBufferPrototypeReadIntLECodeLength = 528; static const JSC::Intrinsic s_jsBufferPrototypeReadIntLECodeIntrinsic = JSC::NoIntrinsic; -const char* const s_jsBufferPrototypeReadIntLECode = "(function (d,r){\"use strict\";const _=this.@dataView||=new DataView(this.buffer,this.byteOffset,this.byteLength);switch(r){case 1:return _.getInt8(d);case 2:return _.getInt16(d,!0);case 3:{const u=_.getUint16(d,!0)+_.getUint8(d+2)*65536;return u|(u&8388608)*510}case 4:return _.getInt32(d,!0);case 5:{const u=_.getUint8(d+4);return(u|(u&128)*33554430)*4294967296+_.getUint32(d,!0)}case 6:{const u=_.getUint16(d+4,!0);return(u|(u&32768)*131070)*4294967296+_.getUint32(d,!0)}}@throwRangeError(\"byteLength must be >= 1 and <= 6\")})\n"; +const char* const s_jsBufferPrototypeReadIntLECode = "(function (d,u){\"use strict\";const r=this.@dataView||=new DataView(this.buffer,this.byteOffset,this.byteLength);switch(u){case 1:return r.getInt8(d);case 2:return r.getInt16(d,!0);case 3:{const _=r.getUint16(d,!0)+r.getUint8(d+2)*65536;return _|(_&8388608)*510}case 4:return r.getInt32(d,!0);case 5:{const _=r.getUint8(d+4);return(_|(_&128)*33554430)*4294967296+r.getUint32(d,!0)}case 6:{const _=r.getUint16(d+4,!0);return(_|(_&32768)*131070)*4294967296+r.getUint32(d,!0)}}@throwRangeError(\"byteLength must be >= 1 and <= 6\")})\n"; // readIntBE const JSC::ConstructAbility s_jsBufferPrototypeReadIntBECodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -838,7 +838,7 @@ const JSC::ConstructorKind s_jsBufferPrototypeReadIntBECodeConstructorKind = JSC const JSC::ImplementationVisibility s_jsBufferPrototypeReadIntBECodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_jsBufferPrototypeReadIntBECodeLength = 528; static const JSC::Intrinsic s_jsBufferPrototypeReadIntBECodeIntrinsic = JSC::NoIntrinsic; -const char* const s_jsBufferPrototypeReadIntBECode = "(function (r,d){\"use strict\";const u=this.@dataView||=new DataView(this.buffer,this.byteOffset,this.byteLength);switch(d){case 1:return u.getInt8(r);case 2:return u.getInt16(r,!1);case 3:{const c=u.getUint16(r+1,!1)+u.getUint8(r)*65536;return c|(c&8388608)*510}case 4:return u.getInt32(r,!1);case 5:{const c=u.getUint8(r);return(c|(c&128)*33554430)*4294967296+u.getUint32(r+1,!1)}case 6:{const c=u.getUint16(r,!1);return(c|(c&32768)*131070)*4294967296+u.getUint32(r+2,!1)}}@throwRangeError(\"byteLength must be >= 1 and <= 6\")})\n"; +const char* const s_jsBufferPrototypeReadIntBECode = "(function (r,c){\"use strict\";const d=this.@dataView||=new DataView(this.buffer,this.byteOffset,this.byteLength);switch(c){case 1:return d.getInt8(r);case 2:return d.getInt16(r,!1);case 3:{const u=d.getUint16(r+1,!1)+d.getUint8(r)*65536;return u|(u&8388608)*510}case 4:return d.getInt32(r,!1);case 5:{const u=d.getUint8(r);return(u|(u&128)*33554430)*4294967296+d.getUint32(r+1,!1)}case 6:{const u=d.getUint16(r,!1);return(u|(u&32768)*131070)*4294967296+d.getUint32(r+2,!1)}}@throwRangeError(\"byteLength must be >= 1 and <= 6\")})\n"; // readUIntLE const JSC::ConstructAbility s_jsBufferPrototypeReadUIntLECodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -846,7 +846,7 @@ const JSC::ConstructorKind s_jsBufferPrototypeReadUIntLECodeConstructorKind = JS const JSC::ImplementationVisibility s_jsBufferPrototypeReadUIntLECodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_jsBufferPrototypeReadUIntLECodeLength = 445; static const JSC::Intrinsic s_jsBufferPrototypeReadUIntLECodeIntrinsic = JSC::NoIntrinsic; -const char* const s_jsBufferPrototypeReadUIntLECode = "(function (a,d){\"use strict\";const r=this.@dataView||=new DataView(this.buffer,this.byteOffset,this.byteLength);switch(d){case 1:return r.getUint8(a);case 2:return r.getUint16(a,!0);case 3:return r.getUint16(a,!0)+r.getUint8(a+2)*65536;case 4:return r.getUint32(a,!0);case 5:return r.getUint8(a+4)*4294967296+r.getUint32(a,!0);case 6:return r.getUint16(a+4,!0)*4294967296+r.getUint32(a,!0)}@throwRangeError(\"byteLength must be >= 1 and <= 6\")})\n"; +const char* const s_jsBufferPrototypeReadUIntLECode = "(function (a,r){\"use strict\";const d=this.@dataView||=new DataView(this.buffer,this.byteOffset,this.byteLength);switch(r){case 1:return d.getUint8(a);case 2:return d.getUint16(a,!0);case 3:return d.getUint16(a,!0)+d.getUint8(a+2)*65536;case 4:return d.getUint32(a,!0);case 5:return d.getUint8(a+4)*4294967296+d.getUint32(a,!0);case 6:return d.getUint16(a+4,!0)*4294967296+d.getUint32(a,!0)}@throwRangeError(\"byteLength must be >= 1 and <= 6\")})\n"; // readUIntBE const JSC::ConstructAbility s_jsBufferPrototypeReadUIntBECodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -854,7 +854,7 @@ const JSC::ConstructorKind s_jsBufferPrototypeReadUIntBECodeConstructorKind = JS const JSC::ImplementationVisibility s_jsBufferPrototypeReadUIntBECodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_jsBufferPrototypeReadUIntBECodeLength = 504; static const JSC::Intrinsic s_jsBufferPrototypeReadUIntBECodeIntrinsic = JSC::NoIntrinsic; -const char* const s_jsBufferPrototypeReadUIntBECode = "(function (d,r){\"use strict\";const c=this.@dataView||=new DataView(this.buffer,this.byteOffset,this.byteLength);switch(r){case 1:return c.getUint8(d);case 2:return c.getUint16(d,!1);case 3:return c.getUint16(d+1,!1)+c.getUint8(d)*65536;case 4:return c.getUint32(d,!1);case 5:{const p=c.getUint8(d);return(p|(p&128)*33554430)*4294967296+c.getUint32(d+1,!1)}case 6:{const p=c.getUint16(d,!1);return(p|(p&32768)*131070)*4294967296+c.getUint32(d+2,!1)}}@throwRangeError(\"byteLength must be >= 1 and <= 6\")})\n"; +const char* const s_jsBufferPrototypeReadUIntBECode = "(function (d,p){\"use strict\";const r=this.@dataView||=new DataView(this.buffer,this.byteOffset,this.byteLength);switch(p){case 1:return r.getUint8(d);case 2:return r.getUint16(d,!1);case 3:return r.getUint16(d+1,!1)+r.getUint8(d)*65536;case 4:return r.getUint32(d,!1);case 5:{const c=r.getUint8(d);return(c|(c&128)*33554430)*4294967296+r.getUint32(d+1,!1)}case 6:{const c=r.getUint16(d,!1);return(c|(c&32768)*131070)*4294967296+r.getUint32(d+2,!1)}}@throwRangeError(\"byteLength must be >= 1 and <= 6\")})\n"; // readFloatLE const JSC::ConstructAbility s_jsBufferPrototypeReadFloatLECodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -926,7 +926,7 @@ const JSC::ConstructorKind s_jsBufferPrototypeWriteInt8CodeConstructorKind = JSC const JSC::ImplementationVisibility s_jsBufferPrototypeWriteInt8CodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_jsBufferPrototypeWriteInt8CodeLength = 131; static const JSC::Intrinsic s_jsBufferPrototypeWriteInt8CodeIntrinsic = JSC::NoIntrinsic; -const char* const s_jsBufferPrototypeWriteInt8Code = "(function (d,r){\"use strict\";return(this.@dataView||=new DataView(this.buffer,this.byteOffset,this.byteLength)).setInt8(r,d),r+1})\n"; +const char* const s_jsBufferPrototypeWriteInt8Code = "(function (r,d){\"use strict\";return(this.@dataView||=new DataView(this.buffer,this.byteOffset,this.byteLength)).setInt8(d,r),d+1})\n"; // writeUInt8 const JSC::ConstructAbility s_jsBufferPrototypeWriteUInt8CodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -934,7 +934,7 @@ const JSC::ConstructorKind s_jsBufferPrototypeWriteUInt8CodeConstructorKind = JS const JSC::ImplementationVisibility s_jsBufferPrototypeWriteUInt8CodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_jsBufferPrototypeWriteUInt8CodeLength = 132; static const JSC::Intrinsic s_jsBufferPrototypeWriteUInt8CodeIntrinsic = JSC::NoIntrinsic; -const char* const s_jsBufferPrototypeWriteUInt8Code = "(function (c,d){\"use strict\";return(this.@dataView||=new DataView(this.buffer,this.byteOffset,this.byteLength)).setUint8(d,c),d+1})\n"; +const char* const s_jsBufferPrototypeWriteUInt8Code = "(function (d,c){\"use strict\";return(this.@dataView||=new DataView(this.buffer,this.byteOffset,this.byteLength)).setUint8(c,d),c+1})\n"; // writeInt16LE const JSC::ConstructAbility s_jsBufferPrototypeWriteInt16LECodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -942,7 +942,7 @@ const JSC::ConstructorKind s_jsBufferPrototypeWriteInt16LECodeConstructorKind = const JSC::ImplementationVisibility s_jsBufferPrototypeWriteInt16LECodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_jsBufferPrototypeWriteInt16LECodeLength = 135; static const JSC::Intrinsic s_jsBufferPrototypeWriteInt16LECodeIntrinsic = JSC::NoIntrinsic; -const char* const s_jsBufferPrototypeWriteInt16LECode = "(function (c,d){\"use strict\";return(this.@dataView||=new DataView(this.buffer,this.byteOffset,this.byteLength)).setInt16(d,c,!0),d+2})\n"; +const char* const s_jsBufferPrototypeWriteInt16LECode = "(function (d,c){\"use strict\";return(this.@dataView||=new DataView(this.buffer,this.byteOffset,this.byteLength)).setInt16(c,d,!0),c+2})\n"; // writeInt16BE const JSC::ConstructAbility s_jsBufferPrototypeWriteInt16BECodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -950,7 +950,7 @@ const JSC::ConstructorKind s_jsBufferPrototypeWriteInt16BECodeConstructorKind = const JSC::ImplementationVisibility s_jsBufferPrototypeWriteInt16BECodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_jsBufferPrototypeWriteInt16BECodeLength = 135; static const JSC::Intrinsic s_jsBufferPrototypeWriteInt16BECodeIntrinsic = JSC::NoIntrinsic; -const char* const s_jsBufferPrototypeWriteInt16BECode = "(function (c,d){\"use strict\";return(this.@dataView||=new DataView(this.buffer,this.byteOffset,this.byteLength)).setInt16(d,c,!1),d+2})\n"; +const char* const s_jsBufferPrototypeWriteInt16BECode = "(function (d,c){\"use strict\";return(this.@dataView||=new DataView(this.buffer,this.byteOffset,this.byteLength)).setInt16(c,d,!1),c+2})\n"; // writeUInt16LE const JSC::ConstructAbility s_jsBufferPrototypeWriteUInt16LECodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -958,7 +958,7 @@ const JSC::ConstructorKind s_jsBufferPrototypeWriteUInt16LECodeConstructorKind = const JSC::ImplementationVisibility s_jsBufferPrototypeWriteUInt16LECodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_jsBufferPrototypeWriteUInt16LECodeLength = 136; static const JSC::Intrinsic s_jsBufferPrototypeWriteUInt16LECodeIntrinsic = JSC::NoIntrinsic; -const char* const s_jsBufferPrototypeWriteUInt16LECode = "(function (c,d){\"use strict\";return(this.@dataView||=new DataView(this.buffer,this.byteOffset,this.byteLength)).setUint16(d,c,!0),d+2})\n"; +const char* const s_jsBufferPrototypeWriteUInt16LECode = "(function (d,c){\"use strict\";return(this.@dataView||=new DataView(this.buffer,this.byteOffset,this.byteLength)).setUint16(c,d,!0),c+2})\n"; // writeUInt16BE const JSC::ConstructAbility s_jsBufferPrototypeWriteUInt16BECodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -966,7 +966,7 @@ const JSC::ConstructorKind s_jsBufferPrototypeWriteUInt16BECodeConstructorKind = const JSC::ImplementationVisibility s_jsBufferPrototypeWriteUInt16BECodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_jsBufferPrototypeWriteUInt16BECodeLength = 136; static const JSC::Intrinsic s_jsBufferPrototypeWriteUInt16BECodeIntrinsic = JSC::NoIntrinsic; -const char* const s_jsBufferPrototypeWriteUInt16BECode = "(function (c,d){\"use strict\";return(this.@dataView||=new DataView(this.buffer,this.byteOffset,this.byteLength)).setUint16(d,c,!1),d+2})\n"; +const char* const s_jsBufferPrototypeWriteUInt16BECode = "(function (d,c){\"use strict\";return(this.@dataView||=new DataView(this.buffer,this.byteOffset,this.byteLength)).setUint16(c,d,!1),c+2})\n"; // writeInt32LE const JSC::ConstructAbility s_jsBufferPrototypeWriteInt32LECodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -974,7 +974,7 @@ const JSC::ConstructorKind s_jsBufferPrototypeWriteInt32LECodeConstructorKind = const JSC::ImplementationVisibility s_jsBufferPrototypeWriteInt32LECodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_jsBufferPrototypeWriteInt32LECodeLength = 135; static const JSC::Intrinsic s_jsBufferPrototypeWriteInt32LECodeIntrinsic = JSC::NoIntrinsic; -const char* const s_jsBufferPrototypeWriteInt32LECode = "(function (c,d){\"use strict\";return(this.@dataView||=new DataView(this.buffer,this.byteOffset,this.byteLength)).setInt32(d,c,!0),d+4})\n"; +const char* const s_jsBufferPrototypeWriteInt32LECode = "(function (d,c){\"use strict\";return(this.@dataView||=new DataView(this.buffer,this.byteOffset,this.byteLength)).setInt32(c,d,!0),c+4})\n"; // writeInt32BE const JSC::ConstructAbility s_jsBufferPrototypeWriteInt32BECodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -982,7 +982,7 @@ const JSC::ConstructorKind s_jsBufferPrototypeWriteInt32BECodeConstructorKind = const JSC::ImplementationVisibility s_jsBufferPrototypeWriteInt32BECodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_jsBufferPrototypeWriteInt32BECodeLength = 135; static const JSC::Intrinsic s_jsBufferPrototypeWriteInt32BECodeIntrinsic = JSC::NoIntrinsic; -const char* const s_jsBufferPrototypeWriteInt32BECode = "(function (c,d){\"use strict\";return(this.@dataView||=new DataView(this.buffer,this.byteOffset,this.byteLength)).setInt32(d,c,!1),d+4})\n"; +const char* const s_jsBufferPrototypeWriteInt32BECode = "(function (d,c){\"use strict\";return(this.@dataView||=new DataView(this.buffer,this.byteOffset,this.byteLength)).setInt32(c,d,!1),c+4})\n"; // writeUInt32LE const JSC::ConstructAbility s_jsBufferPrototypeWriteUInt32LECodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -990,7 +990,7 @@ const JSC::ConstructorKind s_jsBufferPrototypeWriteUInt32LECodeConstructorKind = const JSC::ImplementationVisibility s_jsBufferPrototypeWriteUInt32LECodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_jsBufferPrototypeWriteUInt32LECodeLength = 136; static const JSC::Intrinsic s_jsBufferPrototypeWriteUInt32LECodeIntrinsic = JSC::NoIntrinsic; -const char* const s_jsBufferPrototypeWriteUInt32LECode = "(function (c,d){\"use strict\";return(this.@dataView||=new DataView(this.buffer,this.byteOffset,this.byteLength)).setUint32(d,c,!0),d+4})\n"; +const char* const s_jsBufferPrototypeWriteUInt32LECode = "(function (d,c){\"use strict\";return(this.@dataView||=new DataView(this.buffer,this.byteOffset,this.byteLength)).setUint32(c,d,!0),c+4})\n"; // writeUInt32BE const JSC::ConstructAbility s_jsBufferPrototypeWriteUInt32BECodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -998,7 +998,7 @@ const JSC::ConstructorKind s_jsBufferPrototypeWriteUInt32BECodeConstructorKind = const JSC::ImplementationVisibility s_jsBufferPrototypeWriteUInt32BECodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_jsBufferPrototypeWriteUInt32BECodeLength = 136; static const JSC::Intrinsic s_jsBufferPrototypeWriteUInt32BECodeIntrinsic = JSC::NoIntrinsic; -const char* const s_jsBufferPrototypeWriteUInt32BECode = "(function (c,d){\"use strict\";return(this.@dataView||=new DataView(this.buffer,this.byteOffset,this.byteLength)).setUint32(d,c,!1),d+4})\n"; +const char* const s_jsBufferPrototypeWriteUInt32BECode = "(function (d,c){\"use strict\";return(this.@dataView||=new DataView(this.buffer,this.byteOffset,this.byteLength)).setUint32(c,d,!1),c+4})\n"; // writeIntLE const JSC::ConstructAbility s_jsBufferPrototypeWriteIntLECodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1006,7 +1006,7 @@ const JSC::ConstructorKind s_jsBufferPrototypeWriteIntLECodeConstructorKind = JS const JSC::ImplementationVisibility s_jsBufferPrototypeWriteIntLECodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_jsBufferPrototypeWriteIntLECodeLength = 573; static const JSC::Intrinsic s_jsBufferPrototypeWriteIntLECodeIntrinsic = JSC::NoIntrinsic; -const char* const s_jsBufferPrototypeWriteIntLECode = "(function (d,r,c){\"use strict\";const j=this.@dataView||=new DataView(this.buffer,this.byteOffset,this.byteLength);switch(c){case 1:{j.setInt8(r,d);break}case 2:{j.setInt16(r,d,!0);break}case 3:{j.setUint16(r,d&65535,!0),j.setInt8(r+2,Math.floor(d*0.0000152587890625));break}case 4:{j.setInt32(r,d,!0);break}case 5:{j.setUint32(r,d|0,!0),j.setInt8(r+4,Math.floor(d*0.00000000023283064365386964));break}case 6:{j.setUint32(r,d|0,!0),j.setInt16(r+4,Math.floor(d*0.00000000023283064365386964),!0);break}default:@throwRangeError(\"byteLength must be >= 1 and <= 6\")}return r+c})\n"; +const char* const s_jsBufferPrototypeWriteIntLECode = "(function (r,d,j){\"use strict\";const c=this.@dataView||=new DataView(this.buffer,this.byteOffset,this.byteLength);switch(j){case 1:{c.setInt8(d,r);break}case 2:{c.setInt16(d,r,!0);break}case 3:{c.setUint16(d,r&65535,!0),c.setInt8(d+2,Math.floor(r*0.0000152587890625));break}case 4:{c.setInt32(d,r,!0);break}case 5:{c.setUint32(d,r|0,!0),c.setInt8(d+4,Math.floor(r*0.00000000023283064365386964));break}case 6:{c.setUint32(d,r|0,!0),c.setInt16(d+4,Math.floor(r*0.00000000023283064365386964),!0);break}default:@throwRangeError(\"byteLength must be >= 1 and <= 6\")}return d+j})\n"; // writeIntBE const JSC::ConstructAbility s_jsBufferPrototypeWriteIntBECodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1014,7 +1014,7 @@ const JSC::ConstructorKind s_jsBufferPrototypeWriteIntBECodeConstructorKind = JS const JSC::ImplementationVisibility s_jsBufferPrototypeWriteIntBECodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_jsBufferPrototypeWriteIntBECodeLength = 573; static const JSC::Intrinsic s_jsBufferPrototypeWriteIntBECodeIntrinsic = JSC::NoIntrinsic; -const char* const s_jsBufferPrototypeWriteIntBECode = "(function (d,r,E){\"use strict\";const c=this.@dataView||=new DataView(this.buffer,this.byteOffset,this.byteLength);switch(E){case 1:{c.setInt8(r,d);break}case 2:{c.setInt16(r,d,!1);break}case 3:{c.setUint16(r+1,d&65535,!1),c.setInt8(r,Math.floor(d*0.0000152587890625));break}case 4:{c.setInt32(r,d,!1);break}case 5:{c.setUint32(r+1,d|0,!1),c.setInt8(r,Math.floor(d*0.00000000023283064365386964));break}case 6:{c.setUint32(r+2,d|0,!1),c.setInt16(r,Math.floor(d*0.00000000023283064365386964),!1);break}default:@throwRangeError(\"byteLength must be >= 1 and <= 6\")}return r+E})\n"; +const char* const s_jsBufferPrototypeWriteIntBECode = "(function (r,d,c){\"use strict\";const E=this.@dataView||=new DataView(this.buffer,this.byteOffset,this.byteLength);switch(c){case 1:{E.setInt8(d,r);break}case 2:{E.setInt16(d,r,!1);break}case 3:{E.setUint16(d+1,r&65535,!1),E.setInt8(d,Math.floor(r*0.0000152587890625));break}case 4:{E.setInt32(d,r,!1);break}case 5:{E.setUint32(d+1,r|0,!1),E.setInt8(d,Math.floor(r*0.00000000023283064365386964));break}case 6:{E.setUint32(d+2,r|0,!1),E.setInt16(d,Math.floor(r*0.00000000023283064365386964),!1);break}default:@throwRangeError(\"byteLength must be >= 1 and <= 6\")}return d+c})\n"; // writeUIntLE const JSC::ConstructAbility s_jsBufferPrototypeWriteUIntLECodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1022,7 +1022,7 @@ const JSC::ConstructorKind s_jsBufferPrototypeWriteUIntLECodeConstructorKind = J const JSC::ImplementationVisibility s_jsBufferPrototypeWriteUIntLECodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_jsBufferPrototypeWriteUIntLECodeLength = 579; static const JSC::Intrinsic s_jsBufferPrototypeWriteUIntLECodeIntrinsic = JSC::NoIntrinsic; -const char* const s_jsBufferPrototypeWriteUIntLECode = "(function (d,r,E){\"use strict\";const c=this.@dataView||=new DataView(this.buffer,this.byteOffset,this.byteLength);switch(E){case 1:{c.setUint8(r,d);break}case 2:{c.setUint16(r,d,!0);break}case 3:{c.setUint16(r,d&65535,!0),c.setUint8(r+2,Math.floor(d*0.0000152587890625));break}case 4:{c.setUint32(r,d,!0);break}case 5:{c.setUint32(r,d|0,!0),c.setUint8(r+4,Math.floor(d*0.00000000023283064365386964));break}case 6:{c.setUint32(r,d|0,!0),c.setUint16(r+4,Math.floor(d*0.00000000023283064365386964),!0);break}default:@throwRangeError(\"byteLength must be >= 1 and <= 6\")}return r+E})\n"; +const char* const s_jsBufferPrototypeWriteUIntLECode = "(function (r,d,c){\"use strict\";const E=this.@dataView||=new DataView(this.buffer,this.byteOffset,this.byteLength);switch(c){case 1:{E.setUint8(d,r);break}case 2:{E.setUint16(d,r,!0);break}case 3:{E.setUint16(d,r&65535,!0),E.setUint8(d+2,Math.floor(r*0.0000152587890625));break}case 4:{E.setUint32(d,r,!0);break}case 5:{E.setUint32(d,r|0,!0),E.setUint8(d+4,Math.floor(r*0.00000000023283064365386964));break}case 6:{E.setUint32(d,r|0,!0),E.setUint16(d+4,Math.floor(r*0.00000000023283064365386964),!0);break}default:@throwRangeError(\"byteLength must be >= 1 and <= 6\")}return d+c})\n"; // writeUIntBE const JSC::ConstructAbility s_jsBufferPrototypeWriteUIntBECodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1030,7 +1030,7 @@ const JSC::ConstructorKind s_jsBufferPrototypeWriteUIntBECodeConstructorKind = J const JSC::ImplementationVisibility s_jsBufferPrototypeWriteUIntBECodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_jsBufferPrototypeWriteUIntBECodeLength = 579; static const JSC::Intrinsic s_jsBufferPrototypeWriteUIntBECodeIntrinsic = JSC::NoIntrinsic; -const char* const s_jsBufferPrototypeWriteUIntBECode = "(function (d,r,p){\"use strict\";const _=this.@dataView||=new DataView(this.buffer,this.byteOffset,this.byteLength);switch(p){case 1:{_.setUint8(r,d);break}case 2:{_.setUint16(r,d,!1);break}case 3:{_.setUint16(r+1,d&65535,!1),_.setUint8(r,Math.floor(d*0.0000152587890625));break}case 4:{_.setUint32(r,d,!1);break}case 5:{_.setUint32(r+1,d|0,!1),_.setUint8(r,Math.floor(d*0.00000000023283064365386964));break}case 6:{_.setUint32(r+2,d|0,!1),_.setUint16(r,Math.floor(d*0.00000000023283064365386964),!1);break}default:@throwRangeError(\"byteLength must be >= 1 and <= 6\")}return r+p})\n"; +const char* const s_jsBufferPrototypeWriteUIntBECode = "(function (r,d,_){\"use strict\";const p=this.@dataView||=new DataView(this.buffer,this.byteOffset,this.byteLength);switch(_){case 1:{p.setUint8(d,r);break}case 2:{p.setUint16(d,r,!1);break}case 3:{p.setUint16(d+1,r&65535,!1),p.setUint8(d,Math.floor(r*0.0000152587890625));break}case 4:{p.setUint32(d,r,!1);break}case 5:{p.setUint32(d+1,r|0,!1),p.setUint8(d,Math.floor(r*0.00000000023283064365386964));break}case 6:{p.setUint32(d+2,r|0,!1),p.setUint16(d,Math.floor(r*0.00000000023283064365386964),!1);break}default:@throwRangeError(\"byteLength must be >= 1 and <= 6\")}return d+_})\n"; // writeFloatLE const JSC::ConstructAbility s_jsBufferPrototypeWriteFloatLECodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1038,7 +1038,7 @@ const JSC::ConstructorKind s_jsBufferPrototypeWriteFloatLECodeConstructorKind = const JSC::ImplementationVisibility s_jsBufferPrototypeWriteFloatLECodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_jsBufferPrototypeWriteFloatLECodeLength = 137; static const JSC::Intrinsic s_jsBufferPrototypeWriteFloatLECodeIntrinsic = JSC::NoIntrinsic; -const char* const s_jsBufferPrototypeWriteFloatLECode = "(function (c,d){\"use strict\";return(this.@dataView||=new DataView(this.buffer,this.byteOffset,this.byteLength)).setFloat32(d,c,!0),d+4})\n"; +const char* const s_jsBufferPrototypeWriteFloatLECode = "(function (d,c){\"use strict\";return(this.@dataView||=new DataView(this.buffer,this.byteOffset,this.byteLength)).setFloat32(c,d,!0),c+4})\n"; // writeFloatBE const JSC::ConstructAbility s_jsBufferPrototypeWriteFloatBECodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1046,7 +1046,7 @@ const JSC::ConstructorKind s_jsBufferPrototypeWriteFloatBECodeConstructorKind = const JSC::ImplementationVisibility s_jsBufferPrototypeWriteFloatBECodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_jsBufferPrototypeWriteFloatBECodeLength = 137; static const JSC::Intrinsic s_jsBufferPrototypeWriteFloatBECodeIntrinsic = JSC::NoIntrinsic; -const char* const s_jsBufferPrototypeWriteFloatBECode = "(function (c,d){\"use strict\";return(this.@dataView||=new DataView(this.buffer,this.byteOffset,this.byteLength)).setFloat32(d,c,!1),d+4})\n"; +const char* const s_jsBufferPrototypeWriteFloatBECode = "(function (d,c){\"use strict\";return(this.@dataView||=new DataView(this.buffer,this.byteOffset,this.byteLength)).setFloat32(c,d,!1),c+4})\n"; // writeDoubleLE const JSC::ConstructAbility s_jsBufferPrototypeWriteDoubleLECodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1054,7 +1054,7 @@ const JSC::ConstructorKind s_jsBufferPrototypeWriteDoubleLECodeConstructorKind = const JSC::ImplementationVisibility s_jsBufferPrototypeWriteDoubleLECodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_jsBufferPrototypeWriteDoubleLECodeLength = 137; static const JSC::Intrinsic s_jsBufferPrototypeWriteDoubleLECodeIntrinsic = JSC::NoIntrinsic; -const char* const s_jsBufferPrototypeWriteDoubleLECode = "(function (c,d){\"use strict\";return(this.@dataView||=new DataView(this.buffer,this.byteOffset,this.byteLength)).setFloat64(d,c,!0),d+8})\n"; +const char* const s_jsBufferPrototypeWriteDoubleLECode = "(function (d,c){\"use strict\";return(this.@dataView||=new DataView(this.buffer,this.byteOffset,this.byteLength)).setFloat64(c,d,!0),c+8})\n"; // writeDoubleBE const JSC::ConstructAbility s_jsBufferPrototypeWriteDoubleBECodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1062,7 +1062,7 @@ const JSC::ConstructorKind s_jsBufferPrototypeWriteDoubleBECodeConstructorKind = const JSC::ImplementationVisibility s_jsBufferPrototypeWriteDoubleBECodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_jsBufferPrototypeWriteDoubleBECodeLength = 137; static const JSC::Intrinsic s_jsBufferPrototypeWriteDoubleBECodeIntrinsic = JSC::NoIntrinsic; -const char* const s_jsBufferPrototypeWriteDoubleBECode = "(function (c,d){\"use strict\";return(this.@dataView||=new DataView(this.buffer,this.byteOffset,this.byteLength)).setFloat64(d,c,!1),d+8})\n"; +const char* const s_jsBufferPrototypeWriteDoubleBECode = "(function (d,c){\"use strict\";return(this.@dataView||=new DataView(this.buffer,this.byteOffset,this.byteLength)).setFloat64(c,d,!1),c+8})\n"; // writeBigInt64LE const JSC::ConstructAbility s_jsBufferPrototypeWriteBigInt64LECodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1070,7 +1070,7 @@ const JSC::ConstructorKind s_jsBufferPrototypeWriteBigInt64LECodeConstructorKind const JSC::ImplementationVisibility s_jsBufferPrototypeWriteBigInt64LECodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_jsBufferPrototypeWriteBigInt64LECodeLength = 138; static const JSC::Intrinsic s_jsBufferPrototypeWriteBigInt64LECodeIntrinsic = JSC::NoIntrinsic; -const char* const s_jsBufferPrototypeWriteBigInt64LECode = "(function (c,d){\"use strict\";return(this.@dataView||=new DataView(this.buffer,this.byteOffset,this.byteLength)).setBigInt64(d,c,!0),d+8})\n"; +const char* const s_jsBufferPrototypeWriteBigInt64LECode = "(function (d,c){\"use strict\";return(this.@dataView||=new DataView(this.buffer,this.byteOffset,this.byteLength)).setBigInt64(c,d,!0),c+8})\n"; // writeBigInt64BE const JSC::ConstructAbility s_jsBufferPrototypeWriteBigInt64BECodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1078,7 +1078,7 @@ const JSC::ConstructorKind s_jsBufferPrototypeWriteBigInt64BECodeConstructorKind const JSC::ImplementationVisibility s_jsBufferPrototypeWriteBigInt64BECodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_jsBufferPrototypeWriteBigInt64BECodeLength = 138; static const JSC::Intrinsic s_jsBufferPrototypeWriteBigInt64BECodeIntrinsic = JSC::NoIntrinsic; -const char* const s_jsBufferPrototypeWriteBigInt64BECode = "(function (c,d){\"use strict\";return(this.@dataView||=new DataView(this.buffer,this.byteOffset,this.byteLength)).setBigInt64(d,c,!1),d+8})\n"; +const char* const s_jsBufferPrototypeWriteBigInt64BECode = "(function (d,c){\"use strict\";return(this.@dataView||=new DataView(this.buffer,this.byteOffset,this.byteLength)).setBigInt64(c,d,!1),c+8})\n"; // writeBigUInt64LE const JSC::ConstructAbility s_jsBufferPrototypeWriteBigUInt64LECodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1086,7 +1086,7 @@ const JSC::ConstructorKind s_jsBufferPrototypeWriteBigUInt64LECodeConstructorKin const JSC::ImplementationVisibility s_jsBufferPrototypeWriteBigUInt64LECodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_jsBufferPrototypeWriteBigUInt64LECodeLength = 139; static const JSC::Intrinsic s_jsBufferPrototypeWriteBigUInt64LECodeIntrinsic = JSC::NoIntrinsic; -const char* const s_jsBufferPrototypeWriteBigUInt64LECode = "(function (c,d){\"use strict\";return(this.@dataView||=new DataView(this.buffer,this.byteOffset,this.byteLength)).setBigUint64(d,c,!0),d+8})\n"; +const char* const s_jsBufferPrototypeWriteBigUInt64LECode = "(function (d,c){\"use strict\";return(this.@dataView||=new DataView(this.buffer,this.byteOffset,this.byteLength)).setBigUint64(c,d,!0),c+8})\n"; // writeBigUInt64BE const JSC::ConstructAbility s_jsBufferPrototypeWriteBigUInt64BECodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1094,7 +1094,7 @@ const JSC::ConstructorKind s_jsBufferPrototypeWriteBigUInt64BECodeConstructorKin const JSC::ImplementationVisibility s_jsBufferPrototypeWriteBigUInt64BECodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_jsBufferPrototypeWriteBigUInt64BECodeLength = 139; static const JSC::Intrinsic s_jsBufferPrototypeWriteBigUInt64BECodeIntrinsic = JSC::NoIntrinsic; -const char* const s_jsBufferPrototypeWriteBigUInt64BECode = "(function (c,d){\"use strict\";return(this.@dataView||=new DataView(this.buffer,this.byteOffset,this.byteLength)).setBigUint64(d,c,!1),d+8})\n"; +const char* const s_jsBufferPrototypeWriteBigUInt64BECode = "(function (d,c){\"use strict\";return(this.@dataView||=new DataView(this.buffer,this.byteOffset,this.byteLength)).setBigUint64(c,d,!1),c+8})\n"; // utf8Write const JSC::ConstructAbility s_jsBufferPrototypeUtf8WriteCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1118,7 +1118,7 @@ const JSC::ConstructorKind s_jsBufferPrototypeUtf16leWriteCodeConstructorKind = const JSC::ImplementationVisibility s_jsBufferPrototypeUtf16leWriteCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_jsBufferPrototypeUtf16leWriteCodeLength = 68; static const JSC::Intrinsic s_jsBufferPrototypeUtf16leWriteCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_jsBufferPrototypeUtf16leWriteCode = "(function (r,d,a){\"use strict\";return this.write(r,d,a,\"utf16le\")})\n"; +const char* const s_jsBufferPrototypeUtf16leWriteCode = "(function (d,r,a){\"use strict\";return this.write(d,r,a,\"utf16le\")})\n"; // latin1Write const JSC::ConstructAbility s_jsBufferPrototypeLatin1WriteCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1238,7 +1238,7 @@ const JSC::ConstructorKind s_jsBufferPrototypeSliceCodeConstructorKind = JSC::Co const JSC::ImplementationVisibility s_jsBufferPrototypeSliceCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_jsBufferPrototypeSliceCodeLength = 260; static const JSC::Intrinsic s_jsBufferPrototypeSliceCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_jsBufferPrototypeSliceCode = "(function (i,q){\"use strict\";var{buffer:c,byteOffset:v,byteLength:p}=this;function w(z,m){if(z=@trunc(z),z===0||@isNaN(z))return 0;else if(z<0)return z+=m,z>0\?z:0;else return zk\?x-k:0)})\n"; +const char* const s_jsBufferPrototypeSliceCode = "(function (w,m){\"use strict\";var{buffer:x,byteOffset:z,byteLength:p}=this;function q(c,k){if(c=@trunc(c),c===0||@isNaN(c))return 0;else if(c<0)return c+=k,c>0\?c:0;else return ci\?v-i:0)})\n"; // parent const JSC::ConstructAbility s_jsBufferPrototypeParentCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1312,7 +1312,7 @@ const JSC::ConstructorKind s_readableByteStreamControllerByobRequestCodeConstruc const JSC::ImplementationVisibility s_readableByteStreamControllerByobRequestCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_readableByteStreamControllerByobRequestCodeLength = 523; static const JSC::Intrinsic s_readableByteStreamControllerByobRequestCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_readableByteStreamControllerByobRequestCode = "(function (){\"use strict\";if(!@isReadableByteStreamController(this))throw @makeGetterTypeError(\"ReadableByteStreamController\",\"byobRequest\");var _=@getByIdDirectPrivate(this,\"byobRequest\");if(_===@undefined){var a=@getByIdDirectPrivate(this,\"pendingPullIntos\");const l=a.peek();if(l){const m=new @Uint8Array(l.buffer,l.byteOffset+l.bytesFilled,l.byteLength-l.bytesFilled);@putByIdDirectPrivate(this,\"byobRequest\",new @ReadableStreamBYOBRequest(this,m,@isReadableStream))}}return @getByIdDirectPrivate(this,\"byobRequest\")})\n"; +const char* const s_readableByteStreamControllerByobRequestCode = "(function (){\"use strict\";if(!@isReadableByteStreamController(this))throw @makeGetterTypeError(\"ReadableByteStreamController\",\"byobRequest\");var a=@getByIdDirectPrivate(this,\"byobRequest\");if(a===@undefined){var l=@getByIdDirectPrivate(this,\"pendingPullIntos\");const _=l.peek();if(_){const m=new @Uint8Array(_.buffer,_.byteOffset+_.bytesFilled,_.byteLength-_.bytesFilled);@putByIdDirectPrivate(this,\"byobRequest\",new @ReadableStreamBYOBRequest(this,m,@isReadableStream))}}return @getByIdDirectPrivate(this,\"byobRequest\")})\n"; // desiredSize const JSC::ConstructAbility s_readableByteStreamControllerDesiredSizeCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1338,7 +1338,7 @@ const JSC::ConstructorKind s_consoleObjectAsyncIteratorCodeConstructorKind = JSC const JSC::ImplementationVisibility s_consoleObjectAsyncIteratorCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_consoleObjectAsyncIteratorCodeLength = 577; static const JSC::Intrinsic s_consoleObjectAsyncIteratorCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_consoleObjectAsyncIteratorCode = "(function (){\"use strict\";const w=async function*_(){var G=@Bun.stdin.stream().getReader(),B=new globalThis.TextDecoder(\"utf-8\",{fatal:!1}),H,J=@Bun.indexOfLine;try{while(!0){var j,D,K;const q=G.readMany();if(@isPromise(q))({done:j,value:D}=await q);else({done:j,value:D}=q);if(j){if(K)yield B.decode(K);return}var m;for(let M of D){if(m=M,K)m=@Buffer.concat([K,M]),K=null;var L=0,F=J(m,L);while(F!==-1)yield B.decode(m.subarray(L,F)),L=F+1,F=J(m,L);K=m.subarray(L)}}}catch(q){H=q}finally{if(G.releaseLock(),H)throw H}},z=globalThis.Symbol.asyncIterator;return this[z]=w,w()})\n"; +const char* const s_consoleObjectAsyncIteratorCode = "(function (){\"use strict\";const D=async function*L(){var F=@Bun.stdin.stream().getReader(),G=new globalThis.TextDecoder(\"utf-8\",{fatal:!1}),z,H=@Bun.indexOfLine;try{while(!0){var A,B,w;const m=F.readMany();if(@isPromise(m))({done:A,value:B}=await m);else({done:A,value:B}=m);if(A){if(w)yield G.decode(w);return}var _;for(let J of B){if(_=J,w)_=@Buffer.concat([w,J]),w=null;var j=0,q=H(_,j);while(q!==-1)yield G.decode(_.subarray(j,q)),j=q+1,q=H(_,j);w=_.subarray(j)}}}catch(m){z=m}finally{if(F.releaseLock(),z)throw z}},K=globalThis.Symbol.asyncIterator;return this[K]=D,D()})\n"; // write const JSC::ConstructAbility s_consoleObjectWriteCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1346,7 +1346,7 @@ const JSC::ConstructorKind s_consoleObjectWriteCodeConstructorKind = JSC::Constr const JSC::ImplementationVisibility s_consoleObjectWriteCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_consoleObjectWriteCodeLength = 310; static const JSC::Intrinsic s_consoleObjectWriteCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_consoleObjectWriteCode = "(function (d){\"use strict\";var _=@getByIdDirectPrivate(this,\"writer\");if(!_){var b=@toLength(d\?.length\?\?0);_=@Bun.stdout.writer({highWaterMark:b>65536\?b:65536}),@putByIdDirectPrivate(this,\"writer\",_)}var c=_.write(d);const f=@argumentCount();for(var a=1;a65536\?b:65536}),@putByIdDirectPrivate(this,\"writer\",a)}var c=a.write(_);const f=@argumentCount();for(var d=1;d{},(c)=>{h.error(c)});function S(){@readableStreamDefaultReaderRead(y).@then(function(c){if(c.done){h.close();return}try{h.enqueue(c.value)}catch(g){h.error(\"ReadableStream chunk enqueueing in the sink failed\");return}S()},function(c){h.error(c)})}S()})\n"; +const char* const s_readableStreamInternalsReadableStreamPipeToCode = "(function (g,c){\"use strict\";@assert(@isReadableStream(g));const h=new @ReadableStreamDefaultReader(g);@getByIdDirectPrivate(h,\"closedPromiseCapability\").@promise.@then(()=>{},(_)=>{c.error(_)});function y(){@readableStreamDefaultReaderRead(h).@then(function(_){if(_.done){c.close();return}try{c.enqueue(_.value)}catch(S){c.error(\"ReadableStream chunk enqueueing in the sink failed\");return}y()},function(_){c.error(_)})}y()})\n"; // acquireReadableStreamDefaultReader const JSC::ConstructAbility s_readableStreamInternalsAcquireReadableStreamDefaultReaderCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1404,7 +1404,7 @@ const JSC::ConstructorKind s_readableStreamInternalsSetupReadableStreamDefaultCo const JSC::ImplementationVisibility s_readableStreamInternalsSetupReadableStreamDefaultControllerCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_readableStreamInternalsSetupReadableStreamDefaultControllerCodeLength = 523; static const JSC::Intrinsic s_readableStreamInternalsSetupReadableStreamDefaultControllerCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_readableStreamInternalsSetupReadableStreamDefaultControllerCode = "(function (b,v,_,w,f,x,j){\"use strict\";const B=new @ReadableStreamDefaultController(b,v,_,w,@isReadableStream),C=()=>@promiseInvokeOrNoopMethod(v,x,[B]),q=(D)=>@promiseInvokeOrNoopMethod(v,j,[D]);@putByIdDirectPrivate(B,\"pullAlgorithm\",C),@putByIdDirectPrivate(B,\"cancelAlgorithm\",q),@putByIdDirectPrivate(B,\"pull\",@readableStreamDefaultControllerPull),@putByIdDirectPrivate(B,\"cancel\",@readableStreamDefaultControllerCancel),@putByIdDirectPrivate(b,\"readableStreamController\",B),@readableStreamDefaultControllerStart(B)})\n"; +const char* const s_readableStreamInternalsSetupReadableStreamDefaultControllerCode = "(function (b,f,j,q,D,v,w){\"use strict\";const _=new @ReadableStreamDefaultController(b,f,j,q,@isReadableStream),x=()=>@promiseInvokeOrNoopMethod(f,v,[_]),B=(C)=>@promiseInvokeOrNoopMethod(f,w,[C]);@putByIdDirectPrivate(_,\"pullAlgorithm\",x),@putByIdDirectPrivate(_,\"cancelAlgorithm\",B),@putByIdDirectPrivate(_,\"pull\",@readableStreamDefaultControllerPull),@putByIdDirectPrivate(_,\"cancel\",@readableStreamDefaultControllerCancel),@putByIdDirectPrivate(b,\"readableStreamController\",_),@readableStreamDefaultControllerStart(_)})\n"; // createReadableStreamController const JSC::ConstructAbility s_readableStreamInternalsCreateReadableStreamControllerCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1412,7 +1412,7 @@ const JSC::ConstructorKind s_readableStreamInternalsCreateReadableStreamControll const JSC::ImplementationVisibility s_readableStreamInternalsCreateReadableStreamControllerCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_readableStreamInternalsCreateReadableStreamControllerCodeLength = 671; static const JSC::Intrinsic s_readableStreamInternalsCreateReadableStreamControllerCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_readableStreamInternalsCreateReadableStreamControllerCode = "(function (f,v,w){\"use strict\";const A=v.type,C=@toString(A);if(C===\"bytes\"){if(w.highWaterMark===@undefined)w.highWaterMark=0;if(w.size!==@undefined)@throwRangeError(\"Strategy for a ReadableByteStreamController cannot have a size\");@putByIdDirectPrivate(f,\"readableStreamController\",new @ReadableByteStreamController(f,v,w.highWaterMark,@isReadableStream))}else if(C===\"direct\"){var b=w\?.highWaterMark;@initializeArrayBufferStream.@call(f,v,b)}else if(A===@undefined){if(w.highWaterMark===@undefined)w.highWaterMark=1;@setupReadableStreamDefaultController(f,v,w.size,w.highWaterMark,v.start,v.pull,v.cancel)}else @throwRangeError(\"Invalid type for underlying source\")})\n"; +const char* const s_readableStreamInternalsCreateReadableStreamControllerCode = "(function (w,v,f){\"use strict\";const A=v.type,C=@toString(A);if(C===\"bytes\"){if(f.highWaterMark===@undefined)f.highWaterMark=0;if(f.size!==@undefined)@throwRangeError(\"Strategy for a ReadableByteStreamController cannot have a size\");@putByIdDirectPrivate(w,\"readableStreamController\",new @ReadableByteStreamController(w,v,f.highWaterMark,@isReadableStream))}else if(C===\"direct\"){var b=f\?.highWaterMark;@initializeArrayBufferStream.@call(w,v,b)}else if(A===@undefined){if(f.highWaterMark===@undefined)f.highWaterMark=1;@setupReadableStreamDefaultController(w,v,f.size,f.highWaterMark,v.start,v.pull,v.cancel)}else @throwRangeError(\"Invalid type for underlying source\")})\n"; // readableStreamDefaultControllerStart const JSC::ConstructAbility s_readableStreamInternalsReadableStreamDefaultControllerStartCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1428,7 +1428,7 @@ const JSC::ConstructorKind s_readableStreamInternalsReadableStreamPipeToWritable const JSC::ImplementationVisibility s_readableStreamInternalsReadableStreamPipeToWritableStreamCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_readableStreamInternalsReadableStreamPipeToWritableStreamCodeLength = 1631; static const JSC::Intrinsic s_readableStreamInternalsReadableStreamPipeToWritableStreamCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_readableStreamInternalsReadableStreamPipeToWritableStreamCode = "(function (_,f,D,E,T,k){\"use strict\";if(@assert(@isReadableStream(_)),@assert(@isWritableStream(f)),@assert(!@isReadableStreamLocked(_)),@assert(!@isWritableStreamLocked(f)),@assert(k===@undefined||@isAbortSignal(k)),@getByIdDirectPrivate(_,\"underlyingByteSource\")!==@undefined)return @Promise.@reject(\"Piping to a readable bytestream is not supported\");let q={source:_,destination:f,preventAbort:E,preventCancel:T,preventClose:D,signal:k};if(q.reader=@acquireReadableStreamDefaultReader(_),q.writer=@acquireWritableStreamDefaultWriter(f),@putByIdDirectPrivate(_,\"disturbed\",!0),q.finalized=!1,q.shuttingDown=!1,q.promiseCapability=@newPromiseCapability(@Promise),q.pendingReadPromiseCapability=@newPromiseCapability(@Promise),q.pendingReadPromiseCapability.@resolve.@call(),q.pendingWritePromise=@Promise.@resolve(),k!==@undefined){const w=(x)=>{if(q.finalized)return;@pipeToShutdownWithAction(q,()=>{const B=!q.preventAbort&&@getByIdDirectPrivate(q.destination,\"state\")===\"writable\"\?@writableStreamAbort(q.destination,x):@Promise.@resolve(),G=!q.preventCancel&&@getByIdDirectPrivate(q.source,\"state\")===@streamReadable\?@readableStreamCancel(q.source,x):@Promise.@resolve();let H=@newPromiseCapability(@Promise),I=!0,J=()=>{if(I){I=!1;return}H.@resolve.@call()},K=(L)=>{H.@reject.@call(@undefined,L)};return B.@then(J,K),G.@then(J,K),H.@promise},x)};if(@whenSignalAborted(k,w))return q.promiseCapability.@promise}return @pipeToErrorsMustBePropagatedForward(q),@pipeToErrorsMustBePropagatedBackward(q),@pipeToClosingMustBePropagatedForward(q),@pipeToClosingMustBePropagatedBackward(q),@pipeToLoop(q),q.promiseCapability.@promise})\n"; +const char* const s_readableStreamInternalsReadableStreamPipeToWritableStreamCode = "(function (f,E,z,B,F,D){\"use strict\";if(@assert(@isReadableStream(f)),@assert(@isWritableStream(E)),@assert(!@isReadableStreamLocked(f)),@assert(!@isWritableStreamLocked(E)),@assert(D===@undefined||@isAbortSignal(D)),@getByIdDirectPrivate(f,\"underlyingByteSource\")!==@undefined)return @Promise.@reject(\"Piping to a readable bytestream is not supported\");let _={source:f,destination:E,preventAbort:B,preventCancel:F,preventClose:z,signal:D};if(_.reader=@acquireReadableStreamDefaultReader(f),_.writer=@acquireWritableStreamDefaultWriter(E),@putByIdDirectPrivate(f,\"disturbed\",!0),_.finalized=!1,_.shuttingDown=!1,_.promiseCapability=@newPromiseCapability(@Promise),_.pendingReadPromiseCapability=@newPromiseCapability(@Promise),_.pendingReadPromiseCapability.@resolve.@call(),_.pendingWritePromise=@Promise.@resolve(),D!==@undefined){const G=(T)=>{if(_.finalized)return;@pipeToShutdownWithAction(_,()=>{const H=!_.preventAbort&&@getByIdDirectPrivate(_.destination,\"state\")===\"writable\"\?@writableStreamAbort(_.destination,T):@Promise.@resolve(),I=!_.preventCancel&&@getByIdDirectPrivate(_.source,\"state\")===@streamReadable\?@readableStreamCancel(_.source,T):@Promise.@resolve();let k=@newPromiseCapability(@Promise),q=!0,w=()=>{if(q){q=!1;return}k.@resolve.@call()},x=(J)=>{k.@reject.@call(@undefined,J)};return H.@then(w,x),I.@then(w,x),k.@promise},T)};if(@whenSignalAborted(D,G))return _.promiseCapability.@promise}return @pipeToErrorsMustBePropagatedForward(_),@pipeToErrorsMustBePropagatedBackward(_),@pipeToClosingMustBePropagatedForward(_),@pipeToClosingMustBePropagatedBackward(_),@pipeToLoop(_),_.promiseCapability.@promise})\n"; // pipeToLoop const JSC::ConstructAbility s_readableStreamInternalsPipeToLoopCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1452,7 +1452,7 @@ const JSC::ConstructorKind s_readableStreamInternalsPipeToErrorsMustBePropagated const JSC::ImplementationVisibility s_readableStreamInternalsPipeToErrorsMustBePropagatedForwardCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_readableStreamInternalsPipeToErrorsMustBePropagatedForwardCodeLength = 438; static const JSC::Intrinsic s_readableStreamInternalsPipeToErrorsMustBePropagatedForwardCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_readableStreamInternalsPipeToErrorsMustBePropagatedForwardCode = "(function (_){\"use strict\";const b=()=>{_.pendingReadPromiseCapability.@resolve.@call(@undefined,!1);const d=@getByIdDirectPrivate(_.source,\"storedError\");if(!_.preventAbort){@pipeToShutdownWithAction(_,()=>@writableStreamAbort(_.destination,d),d);return}@pipeToShutdown(_,d)};if(@getByIdDirectPrivate(_.source,\"state\")===@streamErrored){b();return}@getByIdDirectPrivate(_.reader,\"closedPromiseCapability\").@promise.@then(@undefined,b)})\n"; +const char* const s_readableStreamInternalsPipeToErrorsMustBePropagatedForwardCode = "(function (_){\"use strict\";const d=()=>{_.pendingReadPromiseCapability.@resolve.@call(@undefined,!1);const b=@getByIdDirectPrivate(_.source,\"storedError\");if(!_.preventAbort){@pipeToShutdownWithAction(_,()=>@writableStreamAbort(_.destination,b),b);return}@pipeToShutdown(_,b)};if(@getByIdDirectPrivate(_.source,\"state\")===@streamErrored){d();return}@getByIdDirectPrivate(_.reader,\"closedPromiseCapability\").@promise.@then(@undefined,d)})\n"; // pipeToErrorsMustBePropagatedBackward const JSC::ConstructAbility s_readableStreamInternalsPipeToErrorsMustBePropagatedBackwardCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1460,7 +1460,7 @@ const JSC::ConstructorKind s_readableStreamInternalsPipeToErrorsMustBePropagated const JSC::ImplementationVisibility s_readableStreamInternalsPipeToErrorsMustBePropagatedBackwardCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_readableStreamInternalsPipeToErrorsMustBePropagatedBackwardCodeLength = 369; static const JSC::Intrinsic s_readableStreamInternalsPipeToErrorsMustBePropagatedBackwardCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_readableStreamInternalsPipeToErrorsMustBePropagatedBackwardCode = "(function (m){\"use strict\";const h=()=>{const y=@getByIdDirectPrivate(m.destination,\"storedError\");if(!m.preventCancel){@pipeToShutdownWithAction(m,()=>@readableStreamCancel(m.source,y),y);return}@pipeToShutdown(m,y)};if(@getByIdDirectPrivate(m.destination,\"state\")===\"errored\"){h();return}@getByIdDirectPrivate(m.writer,\"closedPromise\").@promise.@then(@undefined,h)})\n"; +const char* const s_readableStreamInternalsPipeToErrorsMustBePropagatedBackwardCode = "(function (m){\"use strict\";const y=()=>{const h=@getByIdDirectPrivate(m.destination,\"storedError\");if(!m.preventCancel){@pipeToShutdownWithAction(m,()=>@readableStreamCancel(m.source,h),h);return}@pipeToShutdown(m,h)};if(@getByIdDirectPrivate(m.destination,\"state\")===\"errored\"){y();return}@getByIdDirectPrivate(m.writer,\"closedPromise\").@promise.@then(@undefined,y)})\n"; // pipeToClosingMustBePropagatedForward const JSC::ConstructAbility s_readableStreamInternalsPipeToClosingMustBePropagatedForwardCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1484,7 +1484,7 @@ const JSC::ConstructorKind s_readableStreamInternalsPipeToShutdownWithActionCode const JSC::ImplementationVisibility s_readableStreamInternalsPipeToShutdownWithActionCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_readableStreamInternalsPipeToShutdownWithActionCodeLength = 458; static const JSC::Intrinsic s_readableStreamInternalsPipeToShutdownWithActionCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_readableStreamInternalsPipeToShutdownWithActionCode = "(function (_,m){\"use strict\";if(_.shuttingDown)return;_.shuttingDown=!0;const b=arguments.length>2,d=arguments[2],g=()=>{m().@then(()=>{if(b)@pipeToFinalize(_,d);else @pipeToFinalize(_)},(j)=>{@pipeToFinalize(_,j)})};if(@getByIdDirectPrivate(_.destination,\"state\")===\"writable\"&&!@writableStreamCloseQueuedOrInFlight(_.destination)){_.pendingReadPromiseCapability.@promise.@then(()=>{_.pendingWritePromise.@then(g,g)},(h)=>@pipeToFinalize(_,h));return}g()})\n"; +const char* const s_readableStreamInternalsPipeToShutdownWithActionCode = "(function (_,d){\"use strict\";if(_.shuttingDown)return;_.shuttingDown=!0;const g=arguments.length>2,h=arguments[2],m=()=>{d().@then(()=>{if(g)@pipeToFinalize(_,h);else @pipeToFinalize(_)},(j)=>{@pipeToFinalize(_,j)})};if(@getByIdDirectPrivate(_.destination,\"state\")===\"writable\"&&!@writableStreamCloseQueuedOrInFlight(_.destination)){_.pendingReadPromiseCapability.@promise.@then(()=>{_.pendingWritePromise.@then(m,m)},(b)=>@pipeToFinalize(_,b));return}m()})\n"; // pipeToShutdown const JSC::ConstructAbility s_readableStreamInternalsPipeToShutdownCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1492,7 +1492,7 @@ const JSC::ConstructorKind s_readableStreamInternalsPipeToShutdownCodeConstructo const JSC::ImplementationVisibility s_readableStreamInternalsPipeToShutdownCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_readableStreamInternalsPipeToShutdownCodeLength = 411; static const JSC::Intrinsic s_readableStreamInternalsPipeToShutdownCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_readableStreamInternalsPipeToShutdownCode = "(function (_){\"use strict\";if(_.shuttingDown)return;_.shuttingDown=!0;const d=arguments.length>1,m=arguments[1],u=()=>{if(d)@pipeToFinalize(_,m);else @pipeToFinalize(_)};if(@getByIdDirectPrivate(_.destination,\"state\")===\"writable\"&&!@writableStreamCloseQueuedOrInFlight(_.destination)){_.pendingReadPromiseCapability.@promise.@then(()=>{_.pendingWritePromise.@then(u,u)},(I)=>@pipeToFinalize(_,I));return}u()})\n"; +const char* const s_readableStreamInternalsPipeToShutdownCode = "(function (_){\"use strict\";if(_.shuttingDown)return;_.shuttingDown=!0;const m=arguments.length>1,u=arguments[1],d=()=>{if(m)@pipeToFinalize(_,u);else @pipeToFinalize(_)};if(@getByIdDirectPrivate(_.destination,\"state\")===\"writable\"&&!@writableStreamCloseQueuedOrInFlight(_.destination)){_.pendingReadPromiseCapability.@promise.@then(()=>{_.pendingWritePromise.@then(d,d)},(I)=>@pipeToFinalize(_,I));return}d()})\n"; // pipeToFinalize const JSC::ConstructAbility s_readableStreamInternalsPipeToFinalizeCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1508,7 +1508,7 @@ const JSC::ConstructorKind s_readableStreamInternalsReadableStreamTeeCodeConstru const JSC::ImplementationVisibility s_readableStreamInternalsReadableStreamTeeCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_readableStreamInternalsReadableStreamTeeCodeLength = 1104; static const JSC::Intrinsic s_readableStreamInternalsReadableStreamTeeCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_readableStreamInternalsReadableStreamTeeCode = "(function (_,f){\"use strict\";@assert(@isReadableStream(_)),@assert(typeof f===\"boolean\");var g=@getByIdDirectPrivate(_,\"start\");if(g)@putByIdDirectPrivate(_,\"start\",@undefined),g();const j=new @ReadableStreamDefaultReader(_),k={closedOrErrored:!1,canceled1:!1,canceled2:!1,reason1:@undefined,reason2:@undefined};k.cancelPromiseCapability=@newPromiseCapability(@Promise);const q=@readableStreamTeePullFunction(k,j,f),v={};@putByIdDirectPrivate(v,\"pull\",q),@putByIdDirectPrivate(v,\"cancel\",@readableStreamTeeBranch1CancelFunction(k,_));const w={};@putByIdDirectPrivate(w,\"pull\",q),@putByIdDirectPrivate(w,\"cancel\",@readableStreamTeeBranch2CancelFunction(k,_));const x=new @ReadableStream(v),y=new @ReadableStream(w);return @getByIdDirectPrivate(j,\"closedPromiseCapability\").@promise.@then(@undefined,function(i){if(k.closedOrErrored)return;if(@readableStreamDefaultControllerError(x.@readableStreamController,i),@readableStreamDefaultControllerError(y.@readableStreamController,i),k.closedOrErrored=!0,!k.canceled1||!k.canceled2)k.cancelPromiseCapability.@resolve.@call()}),k.branch1=x,k.branch2=y,[x,y]})\n"; +const char* const s_readableStreamInternalsReadableStreamTeeCode = "(function (_,q){\"use strict\";@assert(@isReadableStream(_)),@assert(typeof q===\"boolean\");var v=@getByIdDirectPrivate(_,\"start\");if(v)@putByIdDirectPrivate(_,\"start\",@undefined),v();const w=new @ReadableStreamDefaultReader(_),i={closedOrErrored:!1,canceled1:!1,canceled2:!1,reason1:@undefined,reason2:@undefined};i.cancelPromiseCapability=@newPromiseCapability(@Promise);const x=@readableStreamTeePullFunction(i,w,q),f={};@putByIdDirectPrivate(f,\"pull\",x),@putByIdDirectPrivate(f,\"cancel\",@readableStreamTeeBranch1CancelFunction(i,_));const g={};@putByIdDirectPrivate(g,\"pull\",x),@putByIdDirectPrivate(g,\"cancel\",@readableStreamTeeBranch2CancelFunction(i,_));const j=new @ReadableStream(f),k=new @ReadableStream(g);return @getByIdDirectPrivate(w,\"closedPromiseCapability\").@promise.@then(@undefined,function(y){if(i.closedOrErrored)return;if(@readableStreamDefaultControllerError(j.@readableStreamController,y),@readableStreamDefaultControllerError(k.@readableStreamController,y),i.closedOrErrored=!0,!i.canceled1||!i.canceled2)i.cancelPromiseCapability.@resolve.@call()}),i.branch1=j,i.branch2=k,[j,k]})\n"; // readableStreamTeePullFunction const JSC::ConstructAbility s_readableStreamInternalsReadableStreamTeePullFunctionCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1516,7 +1516,7 @@ const JSC::ConstructorKind s_readableStreamInternalsReadableStreamTeePullFunctio const JSC::ImplementationVisibility s_readableStreamInternalsReadableStreamTeePullFunctionCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_readableStreamInternalsReadableStreamTeePullFunctionCodeLength = 764; static const JSC::Intrinsic s_readableStreamInternalsReadableStreamTeePullFunctionCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_readableStreamInternalsReadableStreamTeePullFunctionCode = "(function (i,_,f){\"use strict\";return function(){@Promise.prototype.@then.@call(@readableStreamDefaultReaderRead(_),function(m){if(@assert(@isObject(m)),@assert(typeof m.done===\"boolean\"),m.done&&!i.closedOrErrored){if(!i.canceled1)@readableStreamDefaultControllerClose(i.branch1.@readableStreamController);if(!i.canceled2)@readableStreamDefaultControllerClose(i.branch2.@readableStreamController);if(i.closedOrErrored=!0,!i.canceled1||!i.canceled2)i.cancelPromiseCapability.@resolve.@call()}if(i.closedOrErrored)return;if(!i.canceled1)@readableStreamDefaultControllerEnqueue(i.branch1.@readableStreamController,m.value);if(!i.canceled2)@readableStreamDefaultControllerEnqueue(i.branch2.@readableStreamController,f\?@structuredCloneForStream(m.value):m.value)})}})\n"; +const char* const s_readableStreamInternalsReadableStreamTeePullFunctionCode = "(function (i,f,m){\"use strict\";return function(){@Promise.prototype.@then.@call(@readableStreamDefaultReaderRead(f),function(_){if(@assert(@isObject(_)),@assert(typeof _.done===\"boolean\"),_.done&&!i.closedOrErrored){if(!i.canceled1)@readableStreamDefaultControllerClose(i.branch1.@readableStreamController);if(!i.canceled2)@readableStreamDefaultControllerClose(i.branch2.@readableStreamController);if(i.closedOrErrored=!0,!i.canceled1||!i.canceled2)i.cancelPromiseCapability.@resolve.@call()}if(i.closedOrErrored)return;if(!i.canceled1)@readableStreamDefaultControllerEnqueue(i.branch1.@readableStreamController,_.value);if(!i.canceled2)@readableStreamDefaultControllerEnqueue(i.branch2.@readableStreamController,m\?@structuredCloneForStream(_.value):_.value)})}})\n"; // readableStreamTeeBranch1CancelFunction const JSC::ConstructAbility s_readableStreamInternalsReadableStreamTeeBranch1CancelFunctionCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1564,7 +1564,7 @@ const JSC::ConstructorKind s_readableStreamInternalsReadDirectStreamCodeConstruc const JSC::ImplementationVisibility s_readableStreamInternalsReadDirectStreamCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_readableStreamInternalsReadDirectStreamCodeLength = 900; static const JSC::Intrinsic s_readableStreamInternalsReadDirectStreamCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_readableStreamInternalsReadDirectStreamCode = "(function (_,x,f){\"use strict\";@putByIdDirectPrivate(_,\"underlyingSource\",@undefined),@putByIdDirectPrivate(_,\"start\",@undefined);function j(v,A){if(A&&f\?.cancel){try{var w=f.cancel(A);@markPromiseAsHandled(w)}catch(B){}f=@undefined}if(v){if(@putByIdDirectPrivate(v,\"readableStreamController\",@undefined),@putByIdDirectPrivate(v,\"reader\",@undefined),A)@putByIdDirectPrivate(v,\"state\",@streamErrored),@putByIdDirectPrivate(v,\"storedError\",A);else @putByIdDirectPrivate(v,\"state\",@streamClosed);v=@undefined}}if(!f.pull){j();return}if(!@isCallable(f.pull)){j(),@throwTypeError(\"pull is not a function\");return}@putByIdDirectPrivate(_,\"readableStreamController\",x);const q=@getByIdDirectPrivate(_,\"highWaterMark\");x.start({highWaterMark:!q||q<64\?64:q}),@startDirectStream.@call(x,_,f.pull,j),@putByIdDirectPrivate(_,\"reader\",{});var z=f.pull(x);if(x=@undefined,z&&@isPromise(z))return z.@then(()=>{})})\n"; +const char* const s_readableStreamInternalsReadDirectStreamCode = "(function (j,q,_){\"use strict\";@putByIdDirectPrivate(j,\"underlyingSource\",@undefined),@putByIdDirectPrivate(j,\"start\",@undefined);function w(f,v){if(v&&_\?.cancel){try{var A=_.cancel(v);@markPromiseAsHandled(A)}catch(B){}_=@undefined}if(f){if(@putByIdDirectPrivate(f,\"readableStreamController\",@undefined),@putByIdDirectPrivate(f,\"reader\",@undefined),v)@putByIdDirectPrivate(f,\"state\",@streamErrored),@putByIdDirectPrivate(f,\"storedError\",v);else @putByIdDirectPrivate(f,\"state\",@streamClosed);f=@undefined}}if(!_.pull){w();return}if(!@isCallable(_.pull)){w(),@throwTypeError(\"pull is not a function\");return}@putByIdDirectPrivate(j,\"readableStreamController\",q);const x=@getByIdDirectPrivate(j,\"highWaterMark\");q.start({highWaterMark:!x||x<64\?64:x}),@startDirectStream.@call(q,j,_.pull,w),@putByIdDirectPrivate(j,\"reader\",{});var z=_.pull(q);if(q=@undefined,z&&@isPromise(z))return z.@then(()=>{})})\n"; // assignToStream const JSC::ConstructAbility s_readableStreamInternalsAssignToStreamCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1580,7 +1580,7 @@ const JSC::ConstructorKind s_readableStreamInternalsReadStreamIntoSinkCodeConstr const JSC::ImplementationVisibility s_readableStreamInternalsReadStreamIntoSinkCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_readableStreamInternalsReadStreamIntoSinkCodeLength = 1395; static const JSC::Intrinsic s_readableStreamInternalsReadStreamIntoSinkCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_readableStreamInternalsReadStreamIntoSinkCode = "(async function (c,F,f){\"use strict\";var I=!1,D=!1;try{var E=c.getReader(),G=E.readMany();if(G&&@isPromise(G))G=await G;if(G.done)return I=!0,F.end();var H=G.value.length;const x=@getByIdDirectPrivate(c,\"highWaterMark\");if(f)@startDirectStream.@call(F,c,@undefined,()=>!D&&@markPromiseAsHandled(c.cancel()));F.start({highWaterMark:x||0});for(var J=0,P=G.value,z=G.value.length;J!B&&@markPromiseAsHandled(_.cancel()));c.start({highWaterMark:q||0});for(var D=0,F=f.value,G=f.value.length;D{var j=@createFulfilledPromise({value:v,done:!1});return v=@undefined,@readableStreamClose(b),b=@undefined,j}}else if(this._pendingRead){var y=this._pendingRead;this._pendingRead=@undefined,@putByIdDirectPrivate(this,\"pull\",@noopDoneFunction),@fulfillPromise(y,{value:@undefined,done:!0})}@readableStreamClose(b)})\n"; +const char* const s_readableStreamInternalsOnCloseDirectStreamCode = "(function (S){\"use strict\";var c=this.@controlledReadableStream;if(!c||@getByIdDirectPrivate(c,\"state\")!==@streamReadable)return;if(this._deferClose!==0){this._deferClose=1,this._deferCloseReason=S;return}if(@putByIdDirectPrivate(c,\"state\",@streamClosing),typeof this.@underlyingSource.close===\"function\")try{this.@underlyingSource.close.@call(this.@underlyingSource,S)}catch(b){}var v;try{v=this.@sink.end(),@putByIdDirectPrivate(this,\"sink\",@undefined)}catch(b){if(this._pendingRead){var y=this._pendingRead;this._pendingRead=@undefined,@rejectPromise(y,b)}@readableStreamError(c,b);return}this.error=this.flush=this.write=this.close=this.end=@onReadableStreamDirectControllerClosed;var B=@getByIdDirectPrivate(c,\"reader\");if(B&&@isReadableStreamDefaultReader(B)){var C=this._pendingRead;if(C&&@isPromise(C)&&v\?.byteLength){this._pendingRead=@undefined,@fulfillPromise(C,{value:v,done:!1}),@readableStreamClose(c);return}}if(v\?.byteLength){var j=@getByIdDirectPrivate(B,\"readRequests\");if(j\?.isNotEmpty()){@readableStreamFulfillReadRequest(c,v,!1),@readableStreamClose(c);return}@putByIdDirectPrivate(c,\"state\",@streamReadable),this.@pull=()=>{var b=@createFulfilledPromise({value:v,done:!1});return v=@undefined,@readableStreamClose(c),c=@undefined,b}}else if(this._pendingRead){var y=this._pendingRead;this._pendingRead=@undefined,@putByIdDirectPrivate(this,\"pull\",@noopDoneFunction),@fulfillPromise(y,{value:@undefined,done:!0})}@readableStreamClose(c)})\n"; // onFlushDirectStream const JSC::ConstructAbility s_readableStreamInternalsOnFlushDirectStreamCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1636,7 +1636,7 @@ const JSC::ConstructorKind s_readableStreamInternalsOnFlushDirectStreamCodeConst const JSC::ImplementationVisibility s_readableStreamInternalsOnFlushDirectStreamCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_readableStreamInternalsOnFlushDirectStreamCodeLength = 591; static const JSC::Intrinsic s_readableStreamInternalsOnFlushDirectStreamCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_readableStreamInternalsOnFlushDirectStreamCode = "(function (){\"use strict\";var c=this.@controlledReadableStream,B=@getByIdDirectPrivate(c,\"reader\");if(!B||!@isReadableStreamDefaultReader(B))return;var b=this._pendingRead;if(this._pendingRead=@undefined,b&&@isPromise(b)){var i=this.@sink.flush();if(i\?.byteLength)this._pendingRead=@getByIdDirectPrivate(c,\"readRequests\")\?.shift(),@fulfillPromise(b,{value:i,done:!1});else this._pendingRead=b}else if(@getByIdDirectPrivate(c,\"readRequests\")\?.isNotEmpty()){var i=this.@sink.flush();if(i\?.byteLength)@readableStreamFulfillReadRequest(c,i,!1)}else if(this._deferFlush===-1)this._deferFlush=1})\n"; +const char* const s_readableStreamInternalsOnFlushDirectStreamCode = "(function (){\"use strict\";var B=this.@controlledReadableStream,i=@getByIdDirectPrivate(B,\"reader\");if(!i||!@isReadableStreamDefaultReader(i))return;var b=this._pendingRead;if(this._pendingRead=@undefined,b&&@isPromise(b)){var c=this.@sink.flush();if(c\?.byteLength)this._pendingRead=@getByIdDirectPrivate(B,\"readRequests\")\?.shift(),@fulfillPromise(b,{value:c,done:!1});else this._pendingRead=b}else if(@getByIdDirectPrivate(B,\"readRequests\")\?.isNotEmpty()){var c=this.@sink.flush();if(c\?.byteLength)@readableStreamFulfillReadRequest(B,c,!1)}else if(this._deferFlush===-1)this._deferFlush=1})\n"; // createTextStream const JSC::ConstructAbility s_readableStreamInternalsCreateTextStreamCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1644,7 +1644,7 @@ const JSC::ConstructorKind s_readableStreamInternalsCreateTextStreamCodeConstruc const JSC::ImplementationVisibility s_readableStreamInternalsCreateTextStreamCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_readableStreamInternalsCreateTextStreamCodeLength = 984; static const JSC::Intrinsic s_readableStreamInternalsCreateTextStreamCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_readableStreamInternalsCreateTextStreamCode = "(function (v){\"use strict\";var _,w=[],A=!1,C=!1,j=\"\",x=@toLength(0),E=@newPromiseCapability(@Promise),F=!1;return _={start(){},write(q){if(typeof q===\"string\"){var z=@toLength(q.length);if(z>0)j+=q,A=!0,x+=z;return z}if(!q||!(@ArrayBuffer.@isView(q)||q instanceof @ArrayBuffer))@throwTypeError(\"Expected text, ArrayBuffer or ArrayBufferView\");const G=@toLength(q.byteLength);if(G>0)if(C=!0,j.length>0)@arrayPush(w,j,q),j=\"\";else @arrayPush(w,q);return x+=G,G},flush(){return 0},end(){if(F)return\"\";return _.fulfill()},fulfill(){F=!0;const q=_.finishInternal();return @fulfillPromise(E.@promise,q),q},finishInternal(){if(!A&&!C)return\"\";if(A&&!C)return j;if(C&&!A)return new globalThis.TextDecoder().decode(@Bun.concatArrayBuffers(w));var q=new @Bun.ArrayBufferSink;q.start({highWaterMark:x,asUint8Array:!0});for(let z of w)q.write(z);if(w.length=0,j.length>0)q.write(j),j=\"\";return new globalThis.TextDecoder().decode(q.end())},close(){try{if(!F)F=!0,_.fulfill()}catch(q){}}},[_,E]})\n"; +const char* const s_readableStreamInternalsCreateTextStreamCode = "(function (G){\"use strict\";var q,v=[],x=!1,z=!1,j=\"\",C=@toLength(0),F=@newPromiseCapability(@Promise),A=!1;return q={start(){},write(_){if(typeof _===\"string\"){var w=@toLength(_.length);if(w>0)j+=_,x=!0,C+=w;return w}if(!_||!(@ArrayBuffer.@isView(_)||_ instanceof @ArrayBuffer))@throwTypeError(\"Expected text, ArrayBuffer or ArrayBufferView\");const E=@toLength(_.byteLength);if(E>0)if(z=!0,j.length>0)@arrayPush(v,j,_),j=\"\";else @arrayPush(v,_);return C+=E,E},flush(){return 0},end(){if(A)return\"\";return q.fulfill()},fulfill(){A=!0;const _=q.finishInternal();return @fulfillPromise(F.@promise,_),_},finishInternal(){if(!x&&!z)return\"\";if(x&&!z)return j;if(z&&!x)return new globalThis.TextDecoder().decode(@Bun.concatArrayBuffers(v));var _=new @Bun.ArrayBufferSink;_.start({highWaterMark:C,asUint8Array:!0});for(let w of v)_.write(w);if(v.length=0,j.length>0)_.write(j),j=\"\";return new globalThis.TextDecoder().decode(_.end())},close(){try{if(!A)A=!0,q.fulfill()}catch(_){}}},[q,F]})\n"; // initializeTextStream const JSC::ConstructAbility s_readableStreamInternalsInitializeTextStreamCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1652,7 +1652,7 @@ const JSC::ConstructorKind s_readableStreamInternalsInitializeTextStreamCodeCons const JSC::ImplementationVisibility s_readableStreamInternalsInitializeTextStreamCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_readableStreamInternalsInitializeTextStreamCodeLength = 578; static const JSC::Intrinsic s_readableStreamInternalsInitializeTextStreamCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_readableStreamInternalsInitializeTextStreamCode = "(function (_,m){\"use strict\";var[p,b]=@createTextStream(m),f={@underlyingSource:_,@pull:@onPullDirectStream,@controlledReadableStream:this,@sink:p,close:@onCloseDirectStream,write:p.write,error:@handleDirectStreamError,end:@onCloseDirectStream,@close:@onCloseDirectStream,flush:@onFlushDirectStream,_pendingRead:@undefined,_deferClose:0,_deferFlush:0,_deferCloseReason:@undefined,_handleError:@undefined};return @putByIdDirectPrivate(this,\"readableStreamController\",f),@putByIdDirectPrivate(this,\"underlyingSource\",@undefined),@putByIdDirectPrivate(this,\"start\",@undefined),b})\n"; +const char* const s_readableStreamInternalsInitializeTextStreamCode = "(function (m,p){\"use strict\";var[_,b]=@createTextStream(p),f={@underlyingSource:m,@pull:@onPullDirectStream,@controlledReadableStream:this,@sink:_,close:@onCloseDirectStream,write:_.write,error:@handleDirectStreamError,end:@onCloseDirectStream,@close:@onCloseDirectStream,flush:@onFlushDirectStream,_pendingRead:@undefined,_deferClose:0,_deferFlush:0,_deferCloseReason:@undefined,_handleError:@undefined};return @putByIdDirectPrivate(this,\"readableStreamController\",f),@putByIdDirectPrivate(this,\"underlyingSource\",@undefined),@putByIdDirectPrivate(this,\"start\",@undefined),b})\n"; // initializeArrayStream const JSC::ConstructAbility s_readableStreamInternalsInitializeArrayStreamCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1660,7 +1660,7 @@ const JSC::ConstructorKind s_readableStreamInternalsInitializeArrayStreamCodeCon const JSC::ImplementationVisibility s_readableStreamInternalsInitializeArrayStreamCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_readableStreamInternalsInitializeArrayStreamCodeLength = 797; static const JSC::Intrinsic s_readableStreamInternalsInitializeArrayStreamCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_readableStreamInternalsInitializeArrayStreamCode = "(function (t,_){\"use strict\";var p=[],b=@newPromiseCapability(@Promise),d=!1;function m(){return d=!0,b.@resolve.@call(@undefined,p),p}var j={start(){},write(v){return @arrayPush(p,v),v.byteLength||v.length},flush(){return 0},end(){if(d)return[];return m()},close(){if(!d)m()}},q={@underlyingSource:t,@pull:@onPullDirectStream,@controlledReadableStream:this,@sink:j,close:@onCloseDirectStream,write:j.write,error:@handleDirectStreamError,end:@onCloseDirectStream,@close:@onCloseDirectStream,flush:@onFlushDirectStream,_pendingRead:@undefined,_deferClose:0,_deferFlush:0,_deferCloseReason:@undefined,_handleError:@undefined};return @putByIdDirectPrivate(this,\"readableStreamController\",q),@putByIdDirectPrivate(this,\"underlyingSource\",@undefined),@putByIdDirectPrivate(this,\"start\",@undefined),b})\n"; +const char* const s_readableStreamInternalsInitializeArrayStreamCode = "(function (m,v){\"use strict\";var _=[],b=@newPromiseCapability(@Promise),t=!1;function d(){return t=!0,b.@resolve.@call(@undefined,_),_}var j={start(){},write(p){return @arrayPush(_,p),p.byteLength||p.length},flush(){return 0},end(){if(t)return[];return d()},close(){if(!t)d()}},q={@underlyingSource:m,@pull:@onPullDirectStream,@controlledReadableStream:this,@sink:j,close:@onCloseDirectStream,write:j.write,error:@handleDirectStreamError,end:@onCloseDirectStream,@close:@onCloseDirectStream,flush:@onFlushDirectStream,_pendingRead:@undefined,_deferClose:0,_deferFlush:0,_deferCloseReason:@undefined,_handleError:@undefined};return @putByIdDirectPrivate(this,\"readableStreamController\",q),@putByIdDirectPrivate(this,\"underlyingSource\",@undefined),@putByIdDirectPrivate(this,\"start\",@undefined),b})\n"; // initializeArrayBufferStream const JSC::ConstructAbility s_readableStreamInternalsInitializeArrayBufferStreamCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1668,7 +1668,7 @@ const JSC::ConstructorKind s_readableStreamInternalsInitializeArrayBufferStreamC const JSC::ImplementationVisibility s_readableStreamInternalsInitializeArrayBufferStreamCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_readableStreamInternalsInitializeArrayBufferStreamCodeLength = 690; static const JSC::Intrinsic s_readableStreamInternalsInitializeArrayBufferStreamCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_readableStreamInternalsInitializeArrayBufferStreamCode = "(function (_,m){\"use strict\";var w=m&&typeof m===\"number\"\?{highWaterMark:m,stream:!0,asUint8Array:!0}:{stream:!0,asUint8Array:!0},D=new @Bun.ArrayBufferSink;D.start(w);var b={@underlyingSource:_,@pull:@onPullDirectStream,@controlledReadableStream:this,@sink:D,close:@onCloseDirectStream,write:D.write.bind(D),error:@handleDirectStreamError,end:@onCloseDirectStream,@close:@onCloseDirectStream,flush:@onFlushDirectStream,_pendingRead:@undefined,_deferClose:0,_deferFlush:0,_deferCloseReason:@undefined,_handleError:@undefined};@putByIdDirectPrivate(this,\"readableStreamController\",b),@putByIdDirectPrivate(this,\"underlyingSource\",@undefined),@putByIdDirectPrivate(this,\"start\",@undefined)})\n"; +const char* const s_readableStreamInternalsInitializeArrayBufferStreamCode = "(function (w,m){\"use strict\";var D=m&&typeof m===\"number\"\?{highWaterMark:m,stream:!0,asUint8Array:!0}:{stream:!0,asUint8Array:!0},_=new @Bun.ArrayBufferSink;_.start(D);var b={@underlyingSource:w,@pull:@onPullDirectStream,@controlledReadableStream:this,@sink:_,close:@onCloseDirectStream,write:_.write.bind(_),error:@handleDirectStreamError,end:@onCloseDirectStream,@close:@onCloseDirectStream,flush:@onFlushDirectStream,_pendingRead:@undefined,_deferClose:0,_deferFlush:0,_deferCloseReason:@undefined,_handleError:@undefined};@putByIdDirectPrivate(this,\"readableStreamController\",b),@putByIdDirectPrivate(this,\"underlyingSource\",@undefined),@putByIdDirectPrivate(this,\"start\",@undefined)})\n"; // readableStreamError const JSC::ConstructAbility s_readableStreamInternalsReadableStreamErrorCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1676,7 +1676,7 @@ const JSC::ConstructorKind s_readableStreamInternalsReadableStreamErrorCodeConst const JSC::ImplementationVisibility s_readableStreamInternalsReadableStreamErrorCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_readableStreamInternalsReadableStreamErrorCodeLength = 840; static const JSC::Intrinsic s_readableStreamInternalsReadableStreamErrorCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_readableStreamInternalsReadableStreamErrorCode = "(function (i,c){\"use strict\";@assert(@isReadableStream(i)),@assert(@getByIdDirectPrivate(i,\"state\")===@streamReadable),@putByIdDirectPrivate(i,\"state\",@streamErrored),@putByIdDirectPrivate(i,\"storedError\",c);const n=@getByIdDirectPrivate(i,\"reader\");if(!n)return;if(@isReadableStreamDefaultReader(n)){const _=@getByIdDirectPrivate(n,\"readRequests\");@putByIdDirectPrivate(n,\"readRequests\",@createFIFO());for(var f=_.shift();f;f=_.shift())@rejectPromise(f,c)}else{@assert(@isReadableStreamBYOBReader(n));const _=@getByIdDirectPrivate(n,\"readIntoRequests\");@putByIdDirectPrivate(n,\"readIntoRequests\",@createFIFO());for(var f=_.shift();f;f=_.shift())@rejectPromise(f,c)}@getByIdDirectPrivate(n,\"closedPromiseCapability\").@reject.@call(@undefined,c);const h=@getByIdDirectPrivate(n,\"closedPromiseCapability\").@promise;@markPromiseAsHandled(h)})\n"; +const char* const s_readableStreamInternalsReadableStreamErrorCode = "(function (c,f){\"use strict\";@assert(@isReadableStream(c)),@assert(@getByIdDirectPrivate(c,\"state\")===@streamReadable),@putByIdDirectPrivate(c,\"state\",@streamErrored),@putByIdDirectPrivate(c,\"storedError\",f);const _=@getByIdDirectPrivate(c,\"reader\");if(!_)return;if(@isReadableStreamDefaultReader(_)){const n=@getByIdDirectPrivate(_,\"readRequests\");@putByIdDirectPrivate(_,\"readRequests\",@createFIFO());for(var i=n.shift();i;i=n.shift())@rejectPromise(i,f)}else{@assert(@isReadableStreamBYOBReader(_));const n=@getByIdDirectPrivate(_,\"readIntoRequests\");@putByIdDirectPrivate(_,\"readIntoRequests\",@createFIFO());for(var i=n.shift();i;i=n.shift())@rejectPromise(i,f)}@getByIdDirectPrivate(_,\"closedPromiseCapability\").@reject.@call(@undefined,f);const h=@getByIdDirectPrivate(_,\"closedPromiseCapability\").@promise;@markPromiseAsHandled(h)})\n"; // readableStreamDefaultControllerShouldCallPull const JSC::ConstructAbility s_readableStreamInternalsReadableStreamDefaultControllerShouldCallPullCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1708,7 +1708,7 @@ const JSC::ConstructorKind s_readableStreamInternalsReadableStreamDefaultControl const JSC::ImplementationVisibility s_readableStreamInternalsReadableStreamDefaultControllerGetDesiredSizeCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_readableStreamInternalsReadableStreamDefaultControllerGetDesiredSizeCodeLength = 283; static const JSC::Intrinsic s_readableStreamInternalsReadableStreamDefaultControllerGetDesiredSizeCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_readableStreamInternalsReadableStreamDefaultControllerGetDesiredSizeCode = "(function (i){\"use strict\";const d=@getByIdDirectPrivate(i,\"controlledReadableStream\"),g=@getByIdDirectPrivate(d,\"state\");if(g===@streamErrored)return null;if(g===@streamClosed)return 0;return @getByIdDirectPrivate(i,\"strategy\").highWaterMark-@getByIdDirectPrivate(i,\"queue\").size})\n"; +const char* const s_readableStreamInternalsReadableStreamDefaultControllerGetDesiredSizeCode = "(function (i){\"use strict\";const g=@getByIdDirectPrivate(i,\"controlledReadableStream\"),d=@getByIdDirectPrivate(g,\"state\");if(d===@streamErrored)return null;if(d===@streamClosed)return 0;return @getByIdDirectPrivate(i,\"strategy\").highWaterMark-@getByIdDirectPrivate(i,\"queue\").size})\n"; // readableStreamReaderGenericCancel const JSC::ConstructAbility s_readableStreamInternalsReadableStreamReaderGenericCancelCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1716,7 +1716,7 @@ const JSC::ConstructorKind s_readableStreamInternalsReadableStreamReaderGenericC const JSC::ImplementationVisibility s_readableStreamInternalsReadableStreamReaderGenericCancelCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_readableStreamInternalsReadableStreamReaderGenericCancelCodeLength = 133; static const JSC::Intrinsic s_readableStreamInternalsReadableStreamReaderGenericCancelCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_readableStreamInternalsReadableStreamReaderGenericCancelCode = "(function (c,h){\"use strict\";const i=@getByIdDirectPrivate(c,\"ownerReadableStream\");return @assert(!!i),@readableStreamCancel(i,h)})\n"; +const char* const s_readableStreamInternalsReadableStreamReaderGenericCancelCode = "(function (h,i){\"use strict\";const c=@getByIdDirectPrivate(h,\"ownerReadableStream\");return @assert(!!c),@readableStreamCancel(c,i)})\n"; // readableStreamCancel const JSC::ConstructAbility s_readableStreamInternalsReadableStreamCancelCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1724,7 +1724,7 @@ const JSC::ConstructorKind s_readableStreamInternalsReadableStreamCancelCodeCons const JSC::ImplementationVisibility s_readableStreamInternalsReadableStreamCancelCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_readableStreamInternalsReadableStreamCancelCodeLength = 509; static const JSC::Intrinsic s_readableStreamInternalsReadableStreamCancelCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_readableStreamInternalsReadableStreamCancelCode = "(function (_,d){\"use strict\";@putByIdDirectPrivate(_,\"disturbed\",!0);const h=@getByIdDirectPrivate(_,\"state\");if(h===@streamClosed)return @Promise.@resolve();if(h===@streamErrored)return @Promise.@reject(@getByIdDirectPrivate(_,\"storedError\"));@readableStreamClose(_);var p=@getByIdDirectPrivate(_,\"readableStreamController\"),u=p.@cancel;if(u)return u(p,d).@then(function(){});var i=p.close;if(i)return @Promise.@resolve(p.close(d));@throwTypeError(\"ReadableStreamController has no cancel or close method\")})\n"; +const char* const s_readableStreamInternalsReadableStreamCancelCode = "(function (i,d){\"use strict\";@putByIdDirectPrivate(i,\"disturbed\",!0);const h=@getByIdDirectPrivate(i,\"state\");if(h===@streamClosed)return @Promise.@resolve();if(h===@streamErrored)return @Promise.@reject(@getByIdDirectPrivate(i,\"storedError\"));@readableStreamClose(i);var _=@getByIdDirectPrivate(i,\"readableStreamController\"),p=_.@cancel;if(p)return p(_,d).@then(function(){});var u=_.close;if(u)return @Promise.@resolve(_.close(d));@throwTypeError(\"ReadableStreamController has no cancel or close method\")})\n"; // readableStreamDefaultControllerCancel const JSC::ConstructAbility s_readableStreamInternalsReadableStreamDefaultControllerCancelCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1740,7 +1740,7 @@ const JSC::ConstructorKind s_readableStreamInternalsReadableStreamDefaultControl const JSC::ImplementationVisibility s_readableStreamInternalsReadableStreamDefaultControllerPullCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_readableStreamInternalsReadableStreamDefaultControllerPullCodeLength = 519; static const JSC::Intrinsic s_readableStreamInternalsReadableStreamDefaultControllerPullCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_readableStreamInternalsReadableStreamDefaultControllerPullCode = "(function (a){\"use strict\";var d=@getByIdDirectPrivate(a,\"queue\");if(d.content.isNotEmpty()){const _=@dequeueValue(d);if(@getByIdDirectPrivate(a,\"closeRequested\")&&d.content.isEmpty())@readableStreamClose(@getByIdDirectPrivate(a,\"controlledReadableStream\"));else @readableStreamDefaultControllerCallPullIfNeeded(a);return @createFulfilledPromise({value:_,done:!1})}const f=@readableStreamAddReadRequest(@getByIdDirectPrivate(a,\"controlledReadableStream\"));return @readableStreamDefaultControllerCallPullIfNeeded(a),f})\n"; +const char* const s_readableStreamInternalsReadableStreamDefaultControllerPullCode = "(function (a){\"use strict\";var _=@getByIdDirectPrivate(a,\"queue\");if(_.content.isNotEmpty()){const f=@dequeueValue(_);if(@getByIdDirectPrivate(a,\"closeRequested\")&&_.content.isEmpty())@readableStreamClose(@getByIdDirectPrivate(a,\"controlledReadableStream\"));else @readableStreamDefaultControllerCallPullIfNeeded(a);return @createFulfilledPromise({value:f,done:!1})}const d=@readableStreamAddReadRequest(@getByIdDirectPrivate(a,\"controlledReadableStream\"));return @readableStreamDefaultControllerCallPullIfNeeded(a),d})\n"; // readableStreamDefaultControllerClose const JSC::ConstructAbility s_readableStreamInternalsReadableStreamDefaultControllerCloseCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1756,7 +1756,7 @@ const JSC::ConstructorKind s_readableStreamInternalsReadableStreamCloseCodeConst const JSC::ImplementationVisibility s_readableStreamInternalsReadableStreamCloseCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_readableStreamInternalsReadableStreamCloseCodeLength = 617; static const JSC::Intrinsic s_readableStreamInternalsReadableStreamCloseCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_readableStreamInternalsReadableStreamCloseCode = "(function (_){\"use strict\";if(@assert(@getByIdDirectPrivate(_,\"state\")===@streamReadable),@putByIdDirectPrivate(_,\"state\",@streamClosed),!@getByIdDirectPrivate(_,\"reader\"))return;if(@isReadableStreamDefaultReader(@getByIdDirectPrivate(_,\"reader\"))){const d=@getByIdDirectPrivate(@getByIdDirectPrivate(_,\"reader\"),\"readRequests\");if(d.isNotEmpty()){@putByIdDirectPrivate(@getByIdDirectPrivate(_,\"reader\"),\"readRequests\",@createFIFO());for(var i=d.shift();i;i=d.shift())@fulfillPromise(i,{value:@undefined,done:!0})}}@getByIdDirectPrivate(@getByIdDirectPrivate(_,\"reader\"),\"closedPromiseCapability\").@resolve.@call()})\n"; +const char* const s_readableStreamInternalsReadableStreamCloseCode = "(function (_){\"use strict\";if(@assert(@getByIdDirectPrivate(_,\"state\")===@streamReadable),@putByIdDirectPrivate(_,\"state\",@streamClosed),!@getByIdDirectPrivate(_,\"reader\"))return;if(@isReadableStreamDefaultReader(@getByIdDirectPrivate(_,\"reader\"))){const i=@getByIdDirectPrivate(@getByIdDirectPrivate(_,\"reader\"),\"readRequests\");if(i.isNotEmpty()){@putByIdDirectPrivate(@getByIdDirectPrivate(_,\"reader\"),\"readRequests\",@createFIFO());for(var d=i.shift();d;d=i.shift())@fulfillPromise(d,{value:@undefined,done:!0})}}@getByIdDirectPrivate(@getByIdDirectPrivate(_,\"reader\"),\"closedPromiseCapability\").@resolve.@call()})\n"; // readableStreamFulfillReadRequest const JSC::ConstructAbility s_readableStreamInternalsReadableStreamFulfillReadRequestCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1764,7 +1764,7 @@ const JSC::ConstructorKind s_readableStreamInternalsReadableStreamFulfillReadReq const JSC::ImplementationVisibility s_readableStreamInternalsReadableStreamFulfillReadRequestCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_readableStreamInternalsReadableStreamFulfillReadRequestCodeLength = 157; static const JSC::Intrinsic s_readableStreamInternalsReadableStreamFulfillReadRequestCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_readableStreamInternalsReadableStreamFulfillReadRequestCode = "(function (p,y,_){\"use strict\";const i=@getByIdDirectPrivate(@getByIdDirectPrivate(p,\"reader\"),\"readRequests\").shift();@fulfillPromise(i,{value:y,done:_})})\n"; +const char* const s_readableStreamInternalsReadableStreamFulfillReadRequestCode = "(function (i,p,y){\"use strict\";const _=@getByIdDirectPrivate(@getByIdDirectPrivate(i,\"reader\"),\"readRequests\").shift();@fulfillPromise(_,{value:p,done:y})})\n"; // readableStreamDefaultControllerEnqueue const JSC::ConstructAbility s_readableStreamInternalsReadableStreamDefaultControllerEnqueueCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1772,7 +1772,7 @@ const JSC::ConstructorKind s_readableStreamInternalsReadableStreamDefaultControl const JSC::ImplementationVisibility s_readableStreamInternalsReadableStreamDefaultControllerEnqueueCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_readableStreamInternalsReadableStreamDefaultControllerEnqueueCodeLength = 659; static const JSC::Intrinsic s_readableStreamInternalsReadableStreamDefaultControllerEnqueueCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_readableStreamInternalsReadableStreamDefaultControllerEnqueueCode = "(function (_,d){\"use strict\";const D=@getByIdDirectPrivate(_,\"controlledReadableStream\");if(@assert(@readableStreamDefaultControllerCanCloseOrEnqueue(_)),@isReadableStreamLocked(D)&&@getByIdDirectPrivate(@getByIdDirectPrivate(D,\"reader\"),\"readRequests\")\?.isNotEmpty()){@readableStreamFulfillReadRequest(D,d,!1),@readableStreamDefaultControllerCallPullIfNeeded(_);return}try{let E=1;if(@getByIdDirectPrivate(_,\"strategy\").size!==@undefined)E=@getByIdDirectPrivate(_,\"strategy\").size(d);@enqueueValueWithSize(@getByIdDirectPrivate(_,\"queue\"),d,E)}catch(E){throw @readableStreamDefaultControllerError(_,E),E}@readableStreamDefaultControllerCallPullIfNeeded(_)})\n"; +const char* const s_readableStreamInternalsReadableStreamDefaultControllerEnqueueCode = "(function (_,D){\"use strict\";const E=@getByIdDirectPrivate(_,\"controlledReadableStream\");if(@assert(@readableStreamDefaultControllerCanCloseOrEnqueue(_)),@isReadableStreamLocked(E)&&@getByIdDirectPrivate(@getByIdDirectPrivate(E,\"reader\"),\"readRequests\")\?.isNotEmpty()){@readableStreamFulfillReadRequest(E,D,!1),@readableStreamDefaultControllerCallPullIfNeeded(_);return}try{let d=1;if(@getByIdDirectPrivate(_,\"strategy\").size!==@undefined)d=@getByIdDirectPrivate(_,\"strategy\").size(D);@enqueueValueWithSize(@getByIdDirectPrivate(_,\"queue\"),D,d)}catch(d){throw @readableStreamDefaultControllerError(_,d),d}@readableStreamDefaultControllerCallPullIfNeeded(_)})\n"; // readableStreamDefaultReaderRead const JSC::ConstructAbility s_readableStreamInternalsReadableStreamDefaultReaderReadCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1780,7 +1780,7 @@ const JSC::ConstructorKind s_readableStreamInternalsReadableStreamDefaultReaderR const JSC::ImplementationVisibility s_readableStreamInternalsReadableStreamDefaultReaderReadCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_readableStreamInternalsReadableStreamDefaultReaderReadCodeLength = 491; static const JSC::Intrinsic s_readableStreamInternalsReadableStreamDefaultReaderReadCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_readableStreamInternalsReadableStreamDefaultReaderReadCode = "(function (i){\"use strict\";const n=@getByIdDirectPrivate(i,\"ownerReadableStream\");@assert(!!n);const y=@getByIdDirectPrivate(n,\"state\");if(@putByIdDirectPrivate(n,\"disturbed\",!0),y===@streamClosed)return @createFulfilledPromise({value:@undefined,done:!0});if(y===@streamErrored)return @Promise.@reject(@getByIdDirectPrivate(n,\"storedError\"));return @assert(y===@streamReadable),@getByIdDirectPrivate(n,\"readableStreamController\").@pull(@getByIdDirectPrivate(n,\"readableStreamController\"))})\n"; +const char* const s_readableStreamInternalsReadableStreamDefaultReaderReadCode = "(function (y){\"use strict\";const i=@getByIdDirectPrivate(y,\"ownerReadableStream\");@assert(!!i);const n=@getByIdDirectPrivate(i,\"state\");if(@putByIdDirectPrivate(i,\"disturbed\",!0),n===@streamClosed)return @createFulfilledPromise({value:@undefined,done:!0});if(n===@streamErrored)return @Promise.@reject(@getByIdDirectPrivate(i,\"storedError\"));return @assert(n===@streamReadable),@getByIdDirectPrivate(i,\"readableStreamController\").@pull(@getByIdDirectPrivate(i,\"readableStreamController\"))})\n"; // readableStreamAddReadRequest const JSC::ConstructAbility s_readableStreamInternalsReadableStreamAddReadRequestCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1820,7 +1820,7 @@ const JSC::ConstructorKind s_readableStreamInternalsLazyLoadStreamCodeConstructo const JSC::ImplementationVisibility s_readableStreamInternalsLazyLoadStreamCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_readableStreamInternalsLazyLoadStreamCodeLength = 1589; static const JSC::Intrinsic s_readableStreamInternalsLazyLoadStreamCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_readableStreamInternalsLazyLoadStreamCode = "(function (P,F){\"use strict\";var L=@getByIdDirectPrivate(P,\"bunNativeType\"),G=@getByIdDirectPrivate(P,\"bunNativePtr\"),H=@lazyStreamPrototypeMap.@get(L);if(H===@undefined){let j=function(B){var{c:p,v:z}=this;this.c=@undefined,this.v=@undefined,W(B,p,z)},Z=function(B){try{B.close()}catch(p){globalThis.reportError(p)}},_=function(B,p,z,A){A[0]=!1;var D;try{D=b(B,z,A)}catch(E){return p.error(E)}return W(D,p,z)};var f=j,O=Z,m=_,[b,I,M,q,J,N,Q]=@lazyLoad(L),U=[!1],W;W=function B(p,z,A){if(p&&@isPromise(p))return p.then(j.bind({c:z,v:A}),(D)=>z.error(D));else if(typeof p===\"number\")if(A&&A.byteLength===p&&A.buffer===z.byobRequest\?.view\?.buffer)z.byobRequest.respondWithNewView(A);else z.byobRequest.respond(p);else if(p.constructor===@Uint8Array)z.enqueue(p);if(U[0]||p===!1)@enqueueJob(Z,z),U[0]=!1};const y=J\?new FinalizationRegistry(J):null;H=class B{constructor(p,z,A){if(this.#f=p,this.#b={},this.pull=this.#j.bind(this),this.cancel=this.#m.bind(this),this.autoAllocateChunkSize=z,A!==@undefined)this.start=(D)=>{D.enqueue(A)};if(y)y.register(this,p,this.#b)}#b;pull;cancel;start;#f;type=\"bytes\";autoAllocateChunkSize=0;static startSync=I;#j(p){var z=this.#f;if(!z){p.close();return}_(z,p,p.byobRequest.view,U)}#m(p){var z=this.#f;y&&y.unregister(this.#b),N&&N(z,!1),M(z,p)}static deinit=J;static drain=Q},@lazyStreamPrototypeMap.@set(L,H)}const X=H.startSync(G,F);var Y;const{drain:x,deinit:K}=H;if(x)Y=x(G);if(X===0){if(J&&G&&@enqueueJob(J,G),(Y\?.byteLength\?\?0)>0)return{start(j){j.enqueue(Y),j.close()},type:\"bytes\"};return{start(j){j.close()},type:\"bytes\"}}return new H(G,X,Y)})\n"; +const char* const s_readableStreamInternalsLazyLoadStreamCode = "(function (J,P){\"use strict\";var G=@getByIdDirectPrivate(J,\"bunNativeType\"),B=@getByIdDirectPrivate(J,\"bunNativePtr\"),x=@lazyStreamPrototypeMap.@get(G);if(x===@undefined){let q=function(m){var{c:b,v:f}=this;this.c=@undefined,this.v=@undefined,I(m,b,f)},N=function(m){try{m.close()}catch(b){globalThis.reportError(b)}},O=function(m,b,f,j){j[0]=!1;var y;try{y=Q(m,f,j)}catch(Y){return b.error(Y)}return I(y,b,f)};var z=q,A=N,p=O,[Q,U,W,Z,D,K,X]=@lazyLoad(G),H=[!1],I;I=function m(b,f,j){if(b&&@isPromise(b))return b.then(q.bind({c:f,v:j}),(y)=>f.error(y));else if(typeof b===\"number\")if(j&&j.byteLength===b&&j.buffer===f.byobRequest\?.view\?.buffer)f.byobRequest.respondWithNewView(j);else f.byobRequest.respond(b);else if(b.constructor===@Uint8Array)f.enqueue(b);if(H[0]||b===!1)@enqueueJob(N,f),H[0]=!1};const F=D\?new FinalizationRegistry(D):null;x=class m{constructor(b,f,j){if(this.#f=b,this.#b={},this.pull=this.#j.bind(this),this.cancel=this.#m.bind(this),this.autoAllocateChunkSize=f,j!==@undefined)this.start=(y)=>{y.enqueue(j)};if(F)F.register(this,b,this.#b)}#b;pull;cancel;start;#f;type=\"bytes\";autoAllocateChunkSize=0;static startSync=U;#j(b){var f=this.#f;if(!f){b.close();return}O(f,b,b.byobRequest.view,H)}#m(b){var f=this.#f;F&&F.unregister(this.#b),K&&K(f,!1),W(f,b)}static deinit=D;static drain=X},@lazyStreamPrototypeMap.@set(G,x)}const L=x.startSync(B,P);var E;const{drain:M,deinit:_}=x;if(M)E=M(B);if(L===0){if(D&&B&&@enqueueJob(D,B),(E\?.byteLength\?\?0)>0)return{start(q){q.enqueue(E),q.close()},type:\"bytes\"};return{start(q){q.close()},type:\"bytes\"}}return new x(B,L,E)})\n"; // readableStreamIntoArray const JSC::ConstructAbility s_readableStreamInternalsReadableStreamIntoArrayCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1828,7 +1828,7 @@ const JSC::ConstructorKind s_readableStreamInternalsReadableStreamIntoArrayCodeC const JSC::ImplementationVisibility s_readableStreamInternalsReadableStreamIntoArrayCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_readableStreamInternalsReadableStreamIntoArrayCodeLength = 247; static const JSC::Intrinsic s_readableStreamInternalsReadableStreamIntoArrayCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_readableStreamInternalsReadableStreamIntoArrayCode = "(function (_){\"use strict\";var b=_.getReader(),g=b.readMany();async function j(p){if(p.done)return[];var f=p.value||[];while(!0){var q=await b.read();if(q.done)break;f=f.concat(q.value)}return f}if(g&&@isPromise(g))return g.@then(j);return j(g)})\n"; +const char* const s_readableStreamInternalsReadableStreamIntoArrayCode = "(function (q){\"use strict\";var b=q.getReader(),f=b.readMany();async function g(j){if(j.done)return[];var _=j.value||[];while(!0){var p=await b.read();if(p.done)break;_=_.concat(p.value)}return _}if(f&&@isPromise(f))return f.@then(g);return g(f)})\n"; // readableStreamIntoText const JSC::ConstructAbility s_readableStreamInternalsReadableStreamIntoTextCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1836,7 +1836,7 @@ const JSC::ConstructorKind s_readableStreamInternalsReadableStreamIntoTextCodeCo const JSC::ImplementationVisibility s_readableStreamInternalsReadableStreamIntoTextCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_readableStreamInternalsReadableStreamIntoTextCodeLength = 214; static const JSC::Intrinsic s_readableStreamInternalsReadableStreamIntoTextCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_readableStreamInternalsReadableStreamIntoTextCode = "(function (i){\"use strict\";const[_,d]=@createTextStream(@getByIdDirectPrivate(i,\"highWaterMark\")),h=@readStreamIntoSink(i,_,!1);if(h&&@isPromise(h))return @Promise.@resolve(h).@then(d.@promise);return d.@promise})\n"; +const char* const s_readableStreamInternalsReadableStreamIntoTextCode = "(function (_){\"use strict\";const[h,d]=@createTextStream(@getByIdDirectPrivate(_,\"highWaterMark\")),i=@readStreamIntoSink(_,h,!1);if(i&&@isPromise(i))return @Promise.@resolve(i).@then(d.@promise);return d.@promise})\n"; // readableStreamToArrayBufferDirect const JSC::ConstructAbility s_readableStreamInternalsReadableStreamToArrayBufferDirectCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1844,7 +1844,7 @@ const JSC::ConstructorKind s_readableStreamInternalsReadableStreamToArrayBufferD const JSC::ImplementationVisibility s_readableStreamInternalsReadableStreamToArrayBufferDirectCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_readableStreamInternalsReadableStreamToArrayBufferDirectCodeLength = 727; static const JSC::Intrinsic s_readableStreamInternalsReadableStreamToArrayBufferDirectCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_readableStreamInternalsReadableStreamToArrayBufferDirectCode = "(function (O,_){\"use strict\";var q=new @Bun.ArrayBufferSink;@putByIdDirectPrivate(O,\"underlyingSource\",@undefined);var v=@getByIdDirectPrivate(O,\"highWaterMark\");q.start(v\?{highWaterMark:v}:{});var w=@newPromiseCapability(@Promise),A=!1,z=_.pull,B=_.close,C={start(){},close(F){if(!A){if(A=!0,B)B();@fulfillPromise(w.@promise,q.end())}},end(){if(!A){if(A=!0,B)B();@fulfillPromise(w.@promise,q.end())}},flush(){return 0},write:q.write.bind(q)},D=!1;try{const F=z(C);if(F&&@isObject(F)&&@isPromise(F))return async function(G,j,x){while(!A)await x(G);return await j}(C,promise,z);return w.@promise}catch(F){return D=!0,@readableStreamError(O,F),@Promise.@reject(F)}finally{if(!D&&O)@readableStreamClose(O);C=B=q=z=O=@undefined}})\n"; +const char* const s_readableStreamInternalsReadableStreamToArrayBufferDirectCode = "(function (O,A){\"use strict\";var j=new @Bun.ArrayBufferSink;@putByIdDirectPrivate(O,\"underlyingSource\",@undefined);var B=@getByIdDirectPrivate(O,\"highWaterMark\");j.start(B\?{highWaterMark:B}:{});var w=@newPromiseCapability(@Promise),q=!1,x=A.pull,v=A.close,z={start(){},close(_){if(!q){if(q=!0,v)v();@fulfillPromise(w.@promise,j.end())}},end(){if(!q){if(q=!0,v)v();@fulfillPromise(w.@promise,j.end())}},flush(){return 0},write:j.write.bind(j)},C=!1;try{const _=x(z);if(_&&@isObject(_)&&@isPromise(_))return async function(D,F,G){while(!q)await G(D);return await F}(z,promise,x);return w.@promise}catch(_){return C=!0,@readableStreamError(O,_),@Promise.@reject(_)}finally{if(!C&&O)@readableStreamClose(O);z=v=j=x=O=@undefined}})\n"; // readableStreamToTextDirect const JSC::ConstructAbility s_readableStreamInternalsReadableStreamToTextDirectCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1852,7 +1852,7 @@ const JSC::ConstructorKind s_readableStreamInternalsReadableStreamToTextDirectCo const JSC::ImplementationVisibility s_readableStreamInternalsReadableStreamToTextDirectCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_readableStreamInternalsReadableStreamToTextDirectCodeLength = 278; static const JSC::Intrinsic s_readableStreamInternalsReadableStreamToTextDirectCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_readableStreamInternalsReadableStreamToTextDirectCode = "(async function (f,h){\"use strict\";const j=@initializeTextStream.@call(f,h,@undefined);var k=f.getReader();while(@getByIdDirectPrivate(f,\"state\")===@streamReadable){var p=await k.read();if(p.done)break}try{k.releaseLock()}catch(_){}return k=@undefined,f=@undefined,j.@promise})\n"; +const char* const s_readableStreamInternalsReadableStreamToTextDirectCode = "(async function (_,h){\"use strict\";const j=@initializeTextStream.@call(_,h,@undefined);var f=_.getReader();while(@getByIdDirectPrivate(_,\"state\")===@streamReadable){var k=await f.read();if(k.done)break}try{f.releaseLock()}catch(p){}return f=@undefined,_=@undefined,j.@promise})\n"; // readableStreamToArrayDirect const JSC::ConstructAbility s_readableStreamInternalsReadableStreamToArrayDirectCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1860,7 +1860,7 @@ const JSC::ConstructorKind s_readableStreamInternalsReadableStreamToArrayDirectC const JSC::ImplementationVisibility s_readableStreamInternalsReadableStreamToArrayDirectCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_readableStreamInternalsReadableStreamToArrayDirectCodeLength = 354; static const JSC::Intrinsic s_readableStreamInternalsReadableStreamToArrayDirectCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_readableStreamInternalsReadableStreamToArrayDirectCode = "(async function (_,j){\"use strict\";const k=@initializeArrayStream.@call(_,j,@undefined);j=@undefined;var p=_.getReader();try{while(@getByIdDirectPrivate(_,\"state\")===@streamReadable){var q=await p.read();if(q.done)break}try{p.releaseLock()}catch(f){}return p=@undefined,@Promise.@resolve(k.@promise)}catch(f){throw f}finally{_=@undefined,p=@undefined}})\n"; +const char* const s_readableStreamInternalsReadableStreamToArrayDirectCode = "(async function (f,j){\"use strict\";const p=@initializeArrayStream.@call(f,j,@undefined);j=@undefined;var _=f.getReader();try{while(@getByIdDirectPrivate(f,\"state\")===@streamReadable){var q=await _.read();if(q.done)break}try{_.releaseLock()}catch(k){}return _=@undefined,@Promise.@resolve(p.@promise)}catch(k){throw k}finally{f=@undefined,_=@undefined}})\n"; // readableStreamDefineLazyIterators const JSC::ConstructAbility s_readableStreamInternalsReadableStreamDefineLazyIteratorsCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1868,7 +1868,7 @@ const JSC::ConstructorKind s_readableStreamInternalsReadableStreamDefineLazyIter const JSC::ImplementationVisibility s_readableStreamInternalsReadableStreamDefineLazyIteratorsCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_readableStreamInternalsReadableStreamDefineLazyIteratorsCodeLength = 516; static const JSC::Intrinsic s_readableStreamInternalsReadableStreamDefineLazyIteratorsCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_readableStreamInternalsReadableStreamDefineLazyIteratorsCode = "(function (k){\"use strict\";var B=globalThis.Symbol.asyncIterator,g=async function*z(D,F){var G=D.getReader(),j;try{while(!0){var x,h;const q=G.readMany();if(@isPromise(q))({done:x,value:h}=await q);else({done:x,value:h}=q);if(x)return;yield*h}}catch(q){j=q}finally{if(G.releaseLock(),!F)D.cancel(j);if(j)throw j}},i=function z(){return g(this,!1)},w=function z({preventCancel:D=!1}={preventCancel:!1}){return g(this,D)};return @Object.@defineProperty(k,B,{value:i}),@Object.@defineProperty(k,\"values\",{value:w}),k})\n"; +const char* const s_readableStreamInternalsReadableStreamDefineLazyIteratorsCode = "(function (i){\"use strict\";var B=globalThis.Symbol.asyncIterator,w=async function*x(k,G){var z=k.getReader(),g;try{while(!0){var j,q;const h=z.readMany();if(@isPromise(h))({done:j,value:q}=await h);else({done:j,value:q}=h);if(j)return;yield*q}}catch(h){g=h}finally{if(z.releaseLock(),!G)k.cancel(g);if(g)throw g}},D=function x(){return w(this,!1)},F=function x({preventCancel:k=!1}={preventCancel:!1}){return w(this,k)};return @Object.@defineProperty(i,B,{value:D}),@Object.@defineProperty(i,\"values\",{value:F}),i})\n"; #define DEFINE_BUILTIN_GENERATOR(codeName, functionName, overriddenName, argumentCount) \ JSC::FunctionExecutable* codeName##Generator(JSC::VM& vm) \ @@ -1894,7 +1894,7 @@ const JSC::ConstructorKind s_transformStreamDefaultControllerDesiredSizeCodeCons const JSC::ImplementationVisibility s_transformStreamDefaultControllerDesiredSizeCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_transformStreamDefaultControllerDesiredSizeCodeLength = 339; static const JSC::Intrinsic s_transformStreamDefaultControllerDesiredSizeCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_transformStreamDefaultControllerDesiredSizeCode = "(function (){\"use strict\";if(!@isTransformStreamDefaultController(this))throw @makeThisTypeError(\"TransformStreamDefaultController\",\"enqueue\");const _=@getByIdDirectPrivate(this,\"stream\"),i=@getByIdDirectPrivate(_,\"readable\"),u=@getByIdDirectPrivate(i,\"readableStreamController\");return @readableStreamDefaultControllerGetDesiredSize(u)})\n"; +const char* const s_transformStreamDefaultControllerDesiredSizeCode = "(function (){\"use strict\";if(!@isTransformStreamDefaultController(this))throw @makeThisTypeError(\"TransformStreamDefaultController\",\"enqueue\");const _=@getByIdDirectPrivate(this,\"stream\"),u=@getByIdDirectPrivate(_,\"readable\"),i=@getByIdDirectPrivate(u,\"readableStreamController\");return @readableStreamDefaultControllerGetDesiredSize(i)})\n"; // enqueue const JSC::ConstructAbility s_transformStreamDefaultControllerEnqueueCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1986,7 +1986,7 @@ const JSC::ConstructorKind s_jsBufferConstructorFromCodeConstructorKind = JSC::C const JSC::ImplementationVisibility s_jsBufferConstructorFromCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_jsBufferConstructorFromCodeLength = 1107; static const JSC::Intrinsic s_jsBufferConstructorFromCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_jsBufferConstructorFromCode = "(function (n){\"use strict\";if(@isUndefinedOrNull(n))@throwTypeError(\"The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object.\");if(typeof n===\"string\"||typeof n===\"object\"&&(@isTypedArrayView(n)||n instanceof @ArrayBuffer||n instanceof SharedArrayBuffer||n instanceof String))switch(@argumentCount()){case 1:return new @Buffer(n);case 2:return new @Buffer(n,@argument(1));default:return new @Buffer(n,@argument(1),@argument(2))}var d=@toObject(n,\"The first argument must be of type string or an instance of Buffer, ArrayBuffer, or Array or an Array-like Object.\");if(!@isJSArray(d)){const f=@tryGetByIdWithWellKnownSymbol(n,\"toPrimitive\");if(f){const u=f.@call(n,\"string\");if(typeof u===\"string\")switch(@argumentCount()){case 1:return new @Buffer(u);case 2:return new @Buffer(u,@argument(1));default:return new @Buffer(u,@argument(1),@argument(2))}}if(!(\"length\"in d)||@isCallable(d))@throwTypeError(\"The first argument must be of type string or an instance of Buffer, ArrayBuffer, or Array or an Array-like Object.\")}return new @Buffer(@Uint8Array.from(d).buffer)})\n"; +const char* const s_jsBufferConstructorFromCode = "(function (n){\"use strict\";if(@isUndefinedOrNull(n))@throwTypeError(\"The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object.\");if(typeof n===\"string\"||typeof n===\"object\"&&(@isTypedArrayView(n)||n instanceof @ArrayBuffer||n instanceof SharedArrayBuffer||n instanceof String))switch(@argumentCount()){case 1:return new @Buffer(n);case 2:return new @Buffer(n,@argument(1));default:return new @Buffer(n,@argument(1),@argument(2))}var d=@toObject(n,\"The first argument must be of type string or an instance of Buffer, ArrayBuffer, or Array or an Array-like Object.\");if(!@isJSArray(d)){const u=@tryGetByIdWithWellKnownSymbol(n,\"toPrimitive\");if(u){const f=u.@call(n,\"string\");if(typeof f===\"string\")switch(@argumentCount()){case 1:return new @Buffer(f);case 2:return new @Buffer(f,@argument(1));default:return new @Buffer(f,@argument(1),@argument(2))}}if(!(\"length\"in d)||@isCallable(d))@throwTypeError(\"The first argument must be of type string or an instance of Buffer, ArrayBuffer, or Array or an Array-like Object.\")}return new @Buffer(@Uint8Array.from(d).buffer)})\n"; // isBuffer const JSC::ConstructAbility s_jsBufferConstructorIsBufferCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -2028,7 +2028,7 @@ const JSC::ConstructorKind s_readableStreamDefaultReaderReadManyCodeConstructorK const JSC::ImplementationVisibility s_readableStreamDefaultReaderReadManyCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_readableStreamDefaultReaderReadManyCodeLength = 2598; static const JSC::Intrinsic s_readableStreamDefaultReaderReadManyCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_readableStreamDefaultReaderReadManyCode = "(function (){\"use strict\";if(!@isReadableStreamDefaultReader(this))@throwTypeError(\"ReadableStreamDefaultReader.readMany() should not be called directly\");const S=@getByIdDirectPrivate(this,\"ownerReadableStream\");if(!S)@throwTypeError(\"readMany() called on a reader owned by no readable stream\");const k=@getByIdDirectPrivate(S,\"state\");if(@putByIdDirectPrivate(S,\"disturbed\",!0),k===@streamClosed)return{value:[],size:0,done:!0};else if(k===@streamErrored)throw @getByIdDirectPrivate(S,\"storedError\");var G=@getByIdDirectPrivate(S,\"readableStreamController\"),x=@getByIdDirectPrivate(G,\"queue\");if(!x)return G.@pull(G).@then(function({done:K,value:B}){return K\?{done:!0,value:[],size:0}:{value:[B],size:1,done:!1}});const C=x.content;var _=x.size,E=C.toArray(!1),I=E.length;if(I>0){var D=@newArrayWithSize(I);if(@isReadableByteStreamController(G)){{const K=E[0];if(!(@ArrayBuffer.@isView(K)||K instanceof @ArrayBuffer))@putByValDirect(D,0,new @Uint8Array(K.buffer,K.byteOffset,K.byteLength));else @putByValDirect(D,0,K)}for(var J=1;J{if(K.done)return{value:[],size:0,done:!0};var B=@getByIdDirectPrivate(S,\"readableStreamController\"),F=@getByIdDirectPrivate(B,\"queue\"),N=[K.value].concat(F.content.toArray(!1)),j=N.length;if(@isReadableByteStreamController(B))for(var H=0;H0){var D=@newArrayWithSize(C);if(@isReadableByteStreamController(B)){{const _=x[0];if(!(@ArrayBuffer.@isView(_)||_ instanceof @ArrayBuffer))@putByValDirect(D,0,new @Uint8Array(_.buffer,_.byteOffset,_.byteLength));else @putByValDirect(D,0,_)}for(var d=1;d{if(_.done)return{value:[],size:0,done:!0};var w=@getByIdDirectPrivate(j,\"readableStreamController\"),G=@getByIdDirectPrivate(w,\"queue\"),k=[_.value].concat(G.content.toArray(!1)),K=k.length;if(@isReadableByteStreamController(w))for(var A=0;A0}shift(){var{_head:x,_tail:g,_list:M,_capacityMask:z}=this;if(x===g)return @undefined;var A=M[x];if(@putByValDirect(M,x,@undefined),x=this._head=x+1&z,x<2&&g>1e4&&g<=M.length>>>2)this._shrinkArray();return A}peek(){if(this._head===this._tail)return @undefined;return this._list[this._head]}push(x){var g=this._tail;if(@putByValDirect(this._list,g,x),this._tail=g+1&this._capacityMask,this._tail===this._head)this._growArray()}toArray(x){var g=this._list,M=@toLength(g.length);if(x||this._head>this._tail){var z=@toLength(this._head),A=@toLength(this._tail),B=@toLength(M-z+A),E=@newArrayWithSize(B),v=0;for(var F=z;F>>=1,this._capacityMask>>>=1}}return new w})\n"; +const char* const s_streamInternalsCreateFIFOCode = "(function (){\"use strict\";var E=@Array.prototype.slice;class A{constructor(){this._head=0,this._tail=0,this._capacityMask=3,this._list=@newArrayWithSize(4)}_head;_tail;_capacityMask;_list;size(){if(this._head===this._tail)return 0;if(this._head0}shift(){var{_head:g,_tail:b,_list:x,_capacityMask:M}=this;if(g===b)return @undefined;var w=x[g];if(@putByValDirect(x,g,@undefined),g=this._head=g+1&M,g<2&&b>1e4&&b<=x.length>>>2)this._shrinkArray();return w}peek(){if(this._head===this._tail)return @undefined;return this._list[this._head]}push(g){var b=this._tail;if(@putByValDirect(this._list,b,g),this._tail=b+1&this._capacityMask,this._tail===this._head)this._growArray()}toArray(g){var b=this._list,x=@toLength(b.length);if(g||this._head>this._tail){var M=@toLength(this._head),w=@toLength(this._tail),F=@toLength(x-M+w),z=@newArrayWithSize(F),B=0;for(var v=M;v>>=1,this._capacityMask>>>=1}}return new A})\n"; // newQueue const JSC::ConstructAbility s_streamInternalsNewQueueCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -2158,7 +2158,7 @@ const JSC::ConstructorKind s_streamInternalsEnqueueValueWithSizeCodeConstructorK const JSC::ImplementationVisibility s_streamInternalsEnqueueValueWithSizeCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_streamInternalsEnqueueValueWithSizeCodeLength = 161; static const JSC::Intrinsic s_streamInternalsEnqueueValueWithSizeCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_streamInternalsEnqueueValueWithSizeCode = "(function (n,d,o){\"use strict\";if(o=@toNumber(o),!@isFinite(o)||o<0)@throwRangeError(\"size has an incorrect value\");n.content.push({value:d,size:o}),n.size+=o})\n"; +const char* const s_streamInternalsEnqueueValueWithSizeCode = "(function (d,o,n){\"use strict\";if(n=@toNumber(n),!@isFinite(n)||n<0)@throwRangeError(\"size has an incorrect value\");d.content.push({value:o,size:n}),d.size+=n})\n"; // peekQueueValue const JSC::ConstructAbility s_streamInternalsPeekQueueValueCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -2182,7 +2182,7 @@ const JSC::ConstructorKind s_streamInternalsExtractSizeAlgorithmCodeConstructorK const JSC::ImplementationVisibility s_streamInternalsExtractSizeAlgorithmCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_streamInternalsExtractSizeAlgorithmCodeLength = 176; static const JSC::Intrinsic s_streamInternalsExtractSizeAlgorithmCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_streamInternalsExtractSizeAlgorithmCode = "(function (d){\"use strict\";const p=d.size;if(p===@undefined)return()=>1;if(typeof p!==\"function\")@throwTypeError(\"strategy.size must be a function\");return(w)=>{return p(w)}})\n"; +const char* const s_streamInternalsExtractSizeAlgorithmCode = "(function (p){\"use strict\";const d=p.size;if(d===@undefined)return()=>1;if(typeof d!==\"function\")@throwTypeError(\"strategy.size must be a function\");return(w)=>{return d(w)}})\n"; // extractHighWaterMark const JSC::ConstructAbility s_streamInternalsExtractHighWaterMarkCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -2190,7 +2190,7 @@ const JSC::ConstructorKind s_streamInternalsExtractHighWaterMarkCodeConstructorK const JSC::ImplementationVisibility s_streamInternalsExtractHighWaterMarkCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_streamInternalsExtractHighWaterMarkCodeLength = 188; static const JSC::Intrinsic s_streamInternalsExtractHighWaterMarkCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_streamInternalsExtractHighWaterMarkCode = "(function (o,b){\"use strict\";const c=o.highWaterMark;if(c===@undefined)return b;if(@isNaN(c)||c<0)@throwRangeError(\"highWaterMark value is negative or not a number\");return @toNumber(c)})\n"; +const char* const s_streamInternalsExtractHighWaterMarkCode = "(function (b,c){\"use strict\";const o=b.highWaterMark;if(o===@undefined)return c;if(@isNaN(o)||o<0)@throwRangeError(\"highWaterMark value is negative or not a number\");return @toNumber(o)})\n"; // extractHighWaterMarkFromQueuingStrategyInit const JSC::ConstructAbility s_streamInternalsExtractHighWaterMarkFromQueuingStrategyInitCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -2206,7 +2206,7 @@ const JSC::ConstructorKind s_streamInternalsCreateFulfilledPromiseCodeConstructo const JSC::ImplementationVisibility s_streamInternalsCreateFulfilledPromiseCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_streamInternalsCreateFulfilledPromiseCodeLength = 81; static const JSC::Intrinsic s_streamInternalsCreateFulfilledPromiseCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_streamInternalsCreateFulfilledPromiseCode = "(function (d){\"use strict\";const n=@newPromise();return @fulfillPromise(n,d),n})\n"; +const char* const s_streamInternalsCreateFulfilledPromiseCode = "(function (n){\"use strict\";const d=@newPromise();return @fulfillPromise(d,n),d})\n"; // toDictionary const JSC::ConstructAbility s_streamInternalsToDictionaryCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -2232,7 +2232,7 @@ const JSC::ConstructorKind s_importMetaObjectLoadCJS2ESMCodeConstructorKind = JS const JSC::ImplementationVisibility s_importMetaObjectLoadCJS2ESMCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_importMetaObjectLoadCJS2ESMCodeLength = 1387; static const JSC::Intrinsic s_importMetaObjectLoadCJS2ESMCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_importMetaObjectLoadCJS2ESMCode = "(function (D){\"use strict\";var H=@Loader,_=@createFIFO(),I=D;while(I){var w=H.registry.@get(I);if((w\?.state\?\?0)<=@ModuleFetch)@fulfillModuleSync(I),w=H.registry.@get(I);var L=@getPromiseInternalField(w.fetch,@promiseFieldReactionsOrResult),J=H.parseModule(I,L),Q=w.module;if(J&&@isPromise(J)){var T=@getPromiseInternalField(J,@promiseFieldReactionsOrResult),x=@getPromiseInternalField(J,@promiseFieldFlags),U=x&@promiseStateMask;if(U===@promiseStatePending||T&&@isPromise(T))@throwTypeError(`require() async module \"${I}\" is unsupported. use \"await import()\" instead.`);else if(U===@promiseStateRejected){if(!T\?.message)@throwTypeError(`${T+\"\"\?T:\"An error occurred\"} occurred while parsing module \\\"${I}\\\"`);throw T}w.module=Q=T}else if(J&&!Q)w.module=Q=J;@setStateToMax(w,@ModuleLink);var V=Q.dependenciesMap,W=H.requestedModules(Q),X=@newArrayWithSize(W.length);for(var Y=0,Z=W.length;Y=@ModuleLink)I=_.shift()}var G=H.linkAndEvaluateModule(D,@undefined);if(G&&@isPromise(G))@throwTypeError(`require() async module \\\"${D}\\\" is unsupported. use \"await import()\" instead.`);return H.registry.@get(D)})\n"; +const char* const s_importMetaObjectLoadCJS2ESMCode = "(function (B){\"use strict\";var D=@Loader,H=@createFIFO(),_=B;while(_){var w=D.registry.@get(_);if((w\?.state\?\?0)<=@ModuleFetch)@fulfillModuleSync(_),w=D.registry.@get(_);var W=@getPromiseInternalField(w.fetch,@promiseFieldReactionsOrResult),x=D.parseModule(_,W),z=w.module;if(x&&@isPromise(x)){var J=@getPromiseInternalField(x,@promiseFieldReactionsOrResult),X=@getPromiseInternalField(x,@promiseFieldFlags),Q=X&@promiseStateMask;if(Q===@promiseStatePending||J&&@isPromise(J))@throwTypeError(`require() async module \"${_}\" is unsupported. use \"await import()\" instead.`);else if(Q===@promiseStateRejected){if(!J\?.message)@throwTypeError(`${J+\"\"\?J:\"An error occurred\"} occurred while parsing module \\\"${_}\\\"`);throw J}w.module=z=J}else if(x&&!z)w.module=z=x;@setStateToMax(w,@ModuleLink);var Y=z.dependenciesMap,I=D.requestedModules(z),T=@newArrayWithSize(I.length);for(var F=0,Z=I.length;F=@ModuleLink)_=H.shift()}var V=D.linkAndEvaluateModule(B,@undefined);if(V&&@isPromise(V))@throwTypeError(`require() async module \\\"${B}\\\" is unsupported. use \"await import()\" instead.`);return D.registry.@get(B)})\n"; // requireESM const JSC::ConstructAbility s_importMetaObjectRequireESMCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -2240,7 +2240,7 @@ const JSC::ConstructorKind s_importMetaObjectRequireESMCodeConstructorKind = JSC const JSC::ImplementationVisibility s_importMetaObjectRequireESMCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_importMetaObjectRequireESMCodeLength = 325; static const JSC::Intrinsic s_importMetaObjectRequireESMCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_importMetaObjectRequireESMCode = "(function (a){\"use strict\";var c=@Loader.registry.@get(a);if(!c||!c.evaluated)c=@loadCJS2ESM(a);if(!c||!c.evaluated||!c.module)@throwTypeError(`require() failed to evaluate module \"${a}\". This is an internal consistentency error.`);var _=@Loader.getModuleNamespaceObject(c.module);if(_[@commonJSSymbol]===0)return;return _})\n"; +const char* const s_importMetaObjectRequireESMCode = "(function (c){\"use strict\";var a=@Loader.registry.@get(c);if(!a||!a.evaluated)a=@loadCJS2ESM(c);if(!a||!a.evaluated||!a.module)@throwTypeError(`require() failed to evaluate module \"${c}\". This is an internal consistentency error.`);var _=@Loader.getModuleNamespaceObject(a.module);if(_[@commonJSSymbol]===0)return;return _})\n"; // internalRequire const JSC::ConstructAbility s_importMetaObjectInternalRequireCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -2248,7 +2248,7 @@ const JSC::ConstructorKind s_importMetaObjectInternalRequireCodeConstructorKind const JSC::ImplementationVisibility s_importMetaObjectInternalRequireCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_importMetaObjectInternalRequireCodeLength = 747; static const JSC::Intrinsic s_importMetaObjectInternalRequireCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_importMetaObjectInternalRequireCode = "(function (b){\"use strict\";var g=@requireMap.@get(b);const j=b.substring(b.length-5);if(g)return g.exports;if(j===\".json\"){var k=globalThis[Symbol.for(\"_fs\")]||=@Bun.fs(),n=JSON.parse(k.readFileSync(b,\"utf8\"));return @requireMap.@set(b,@createCommonJSModule(b,n,!0)),n}else if(j===\".node\"){const q=@createCommonJSModule(b,{},!0);return process.dlopen(q,b),@requireMap.@set(b,q),q.exports}else if(j===\".toml\"){var k=globalThis[Symbol.for(\"_fs\")]||=@Bun.fs(),n=@Bun.TOML.parse(k.readFileSync(b,\"utf8\"));return @requireMap.@set(b,@createCommonJSModule(b,n,!0)),n}else{var n=@requireESM(b);const v=@requireMap.@get(b);if(v)return v.exports;var _=n\?.default;if(_\?.[@commonJSSymbol]===0)n=_;return @requireMap.@set(b,@createCommonJSModule(b,n,!0)),n}})\n"; +const char* const s_importMetaObjectInternalRequireCode = "(function (_){\"use strict\";var n=@requireMap.@get(_);const g=_.substring(_.length-5);if(n)return n.exports;if(g===\".json\"){var j=globalThis[Symbol.for(\"_fs\")]||=@Bun.fs(),b=JSON.parse(j.readFileSync(_,\"utf8\"));return @requireMap.@set(_,@createCommonJSModule(_,b,!0)),b}else if(g===\".node\"){const k=@createCommonJSModule(_,{},!0);return process.dlopen(k,_),@requireMap.@set(_,k),k.exports}else if(g===\".toml\"){var j=globalThis[Symbol.for(\"_fs\")]||=@Bun.fs(),b=@Bun.TOML.parse(j.readFileSync(_,\"utf8\"));return @requireMap.@set(_,@createCommonJSModule(_,b,!0)),b}else{var b=@requireESM(_);const v=@requireMap.@get(_);if(v)return v.exports;var q=b\?.default;if(q\?.[@commonJSSymbol]===0)b=q;return @requireMap.@set(_,@createCommonJSModule(_,b,!0)),b}})\n"; // createRequireCache const JSC::ConstructAbility s_importMetaObjectCreateRequireCacheCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -2256,7 +2256,7 @@ const JSC::ConstructorKind s_importMetaObjectCreateRequireCacheCodeConstructorKi const JSC::ImplementationVisibility s_importMetaObjectCreateRequireCacheCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_importMetaObjectCreateRequireCacheCodeLength = 854; static const JSC::Intrinsic s_importMetaObjectCreateRequireCacheCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_importMetaObjectCreateRequireCacheCode = "(function (){\"use strict\";var _=new Map,f={};return new Proxy(f,{get(h,t){const u=@requireMap.@get(t);if(u)return u;const L=@Loader.registry.@get(t);if(L\?.evaluated){const b=@Loader.getModuleNamespaceObject(L.module),c=b[@commonJSSymbol]===0||b.default\?.[@commonJSSymbol]\?b.default:b,g=@createCommonJSModule(t,c,!0);return @requireMap.@set(t,g),g}return f[t]},set(h,t,u){return @requireMap.@set(t,u),!0},has(h,t){return @requireMap.@has(t)||@Loader.registry.@has(t)},deleteProperty(h,t){return _.@delete(t),@requireMap.@delete(t),@Loader.registry.@delete(t),!0},ownKeys(h){var t=[...@requireMap.@keys()];const u=[...@Loader.registry.@keys()];for(let L of u)if(!t.includes(L))@arrayPush(t,L);return t},getPrototypeOf(h){return null},getOwnPropertyDescriptor(h,t){if(@requireMap.@has(t)||@Loader.registry.@has(t))return{configurable:!0,enumerable:!0}}})})\n"; +const char* const s_importMetaObjectCreateRequireCacheCode = "(function (){\"use strict\";var c=new Map,L={};return new Proxy(L,{get(f,_){const h=@requireMap.@get(_);if(h)return h;const t=@Loader.registry.@get(_);if(t\?.evaluated){const u=@Loader.getModuleNamespaceObject(t.module),g=u[@commonJSSymbol]===0||u.default\?.[@commonJSSymbol]\?u.default:u,b=@createCommonJSModule(_,g,!0);return @requireMap.@set(_,b),b}return L[_]},set(f,_,h){return @requireMap.@set(_,h),!0},has(f,_){return @requireMap.@has(_)||@Loader.registry.@has(_)},deleteProperty(f,_){return c.@delete(_),@requireMap.@delete(_),@Loader.registry.@delete(_),!0},ownKeys(f){var _=[...@requireMap.@keys()];const h=[...@Loader.registry.@keys()];for(let t of h)if(!_.includes(t))@arrayPush(_,t);return _},getPrototypeOf(f){return null},getOwnPropertyDescriptor(f,_){if(@requireMap.@has(_)||@Loader.registry.@has(_))return{configurable:!0,enumerable:!0}}})})\n"; // require const JSC::ConstructAbility s_importMetaObjectRequireCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -2440,7 +2440,7 @@ const JSC::ConstructorKind s_readableStreamInitializeReadableStreamCodeConstruct const JSC::ImplementationVisibility s_readableStreamInitializeReadableStreamCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_readableStreamInitializeReadableStreamCodeLength = 2065; static const JSC::Intrinsic s_readableStreamInitializeReadableStreamCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_readableStreamInitializeReadableStreamCode = "(function (f,m){\"use strict\";if(f===@undefined)f={@bunNativeType:0,@bunNativePtr:0,@lazy:!1};if(m===@undefined)m={};if(!@isObject(f))@throwTypeError(\"ReadableStream constructor takes an object as first argument\");if(m!==@undefined&&!@isObject(m))@throwTypeError(\"ReadableStream constructor takes an object as second argument, if any\");@putByIdDirectPrivate(this,\"state\",@streamReadable),@putByIdDirectPrivate(this,\"reader\",@undefined),@putByIdDirectPrivate(this,\"storedError\",@undefined),@putByIdDirectPrivate(this,\"disturbed\",!1),@putByIdDirectPrivate(this,\"readableStreamController\",null),@putByIdDirectPrivate(this,\"bunNativeType\",@getByIdDirectPrivate(f,\"bunNativeType\")\?\?0),@putByIdDirectPrivate(this,\"bunNativePtr\",@getByIdDirectPrivate(f,\"bunNativePtr\")\?\?0);const v=f.type===\"direct\",B=!!f.@lazy,I=v||B;if(@getByIdDirectPrivate(f,\"pull\")!==@undefined&&!I){const _=@getByIdDirectPrivate(m,\"size\"),b=@getByIdDirectPrivate(m,\"highWaterMark\");return @putByIdDirectPrivate(this,\"highWaterMark\",b),@putByIdDirectPrivate(this,\"underlyingSource\",@undefined),@setupReadableStreamDefaultController(this,f,_,b!==@undefined\?b:1,@getByIdDirectPrivate(f,\"start\"),@getByIdDirectPrivate(f,\"pull\"),@getByIdDirectPrivate(f,\"cancel\")),this}if(v)@putByIdDirectPrivate(this,\"underlyingSource\",f),@putByIdDirectPrivate(this,\"highWaterMark\",@getByIdDirectPrivate(m,\"highWaterMark\")),@putByIdDirectPrivate(this,\"start\",()=>@createReadableStreamController(this,f,m));else if(I){const _=f.autoAllocateChunkSize;@putByIdDirectPrivate(this,\"highWaterMark\",@undefined),@putByIdDirectPrivate(this,\"underlyingSource\",@undefined),@putByIdDirectPrivate(this,\"highWaterMark\",_||@getByIdDirectPrivate(m,\"highWaterMark\")),@putByIdDirectPrivate(this,\"start\",()=>{const b=@lazyLoadStream(this,_);if(b)@createReadableStreamController(this,b,m)})}else @putByIdDirectPrivate(this,\"underlyingSource\",@undefined),@putByIdDirectPrivate(this,\"highWaterMark\",@getByIdDirectPrivate(m,\"highWaterMark\")),@putByIdDirectPrivate(this,\"start\",@undefined),@createReadableStreamController(this,f,m);return this})\n"; +const char* const s_readableStreamInitializeReadableStreamCode = "(function (_,f){\"use strict\";if(_===@undefined)_={@bunNativeType:0,@bunNativePtr:0,@lazy:!1};if(f===@undefined)f={};if(!@isObject(_))@throwTypeError(\"ReadableStream constructor takes an object as first argument\");if(f!==@undefined&&!@isObject(f))@throwTypeError(\"ReadableStream constructor takes an object as second argument, if any\");@putByIdDirectPrivate(this,\"state\",@streamReadable),@putByIdDirectPrivate(this,\"reader\",@undefined),@putByIdDirectPrivate(this,\"storedError\",@undefined),@putByIdDirectPrivate(this,\"disturbed\",!1),@putByIdDirectPrivate(this,\"readableStreamController\",null),@putByIdDirectPrivate(this,\"bunNativeType\",@getByIdDirectPrivate(_,\"bunNativeType\")\?\?0),@putByIdDirectPrivate(this,\"bunNativePtr\",@getByIdDirectPrivate(_,\"bunNativePtr\")\?\?0);const B=_.type===\"direct\",b=!!_.@lazy,I=B||b;if(@getByIdDirectPrivate(_,\"pull\")!==@undefined&&!I){const v=@getByIdDirectPrivate(f,\"size\"),m=@getByIdDirectPrivate(f,\"highWaterMark\");return @putByIdDirectPrivate(this,\"highWaterMark\",m),@putByIdDirectPrivate(this,\"underlyingSource\",@undefined),@setupReadableStreamDefaultController(this,_,v,m!==@undefined\?m:1,@getByIdDirectPrivate(_,\"start\"),@getByIdDirectPrivate(_,\"pull\"),@getByIdDirectPrivate(_,\"cancel\")),this}if(B)@putByIdDirectPrivate(this,\"underlyingSource\",_),@putByIdDirectPrivate(this,\"highWaterMark\",@getByIdDirectPrivate(f,\"highWaterMark\")),@putByIdDirectPrivate(this,\"start\",()=>@createReadableStreamController(this,_,f));else if(I){const v=_.autoAllocateChunkSize;@putByIdDirectPrivate(this,\"highWaterMark\",@undefined),@putByIdDirectPrivate(this,\"underlyingSource\",@undefined),@putByIdDirectPrivate(this,\"highWaterMark\",v||@getByIdDirectPrivate(f,\"highWaterMark\")),@putByIdDirectPrivate(this,\"start\",()=>{const m=@lazyLoadStream(this,v);if(m)@createReadableStreamController(this,m,f)})}else @putByIdDirectPrivate(this,\"underlyingSource\",@undefined),@putByIdDirectPrivate(this,\"highWaterMark\",@getByIdDirectPrivate(f,\"highWaterMark\")),@putByIdDirectPrivate(this,\"start\",@undefined),@createReadableStreamController(this,_,f);return this})\n"; // readableStreamToArray const JSC::ConstructAbility s_readableStreamReadableStreamToArrayCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -2448,7 +2448,7 @@ const JSC::ConstructorKind s_readableStreamReadableStreamToArrayCodeConstructorK const JSC::ImplementationVisibility s_readableStreamReadableStreamToArrayCodeImplementationVisibility = JSC::ImplementationVisibility::Private; const int s_readableStreamReadableStreamToArrayCodeLength = 173; static const JSC::Intrinsic s_readableStreamReadableStreamToArrayCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_readableStreamReadableStreamToArrayCode = "(function (b){\"use strict\";var _=@getByIdDirectPrivate(b,\"underlyingSource\");if(_!==@undefined)return @readableStreamToArrayDirect(b,_);return @readableStreamIntoArray(b)})\n"; +const char* const s_readableStreamReadableStreamToArrayCode = "(function (_){\"use strict\";var b=@getByIdDirectPrivate(_,\"underlyingSource\");if(b!==@undefined)return @readableStreamToArrayDirect(_,b);return @readableStreamIntoArray(_)})\n"; // readableStreamToText const JSC::ConstructAbility s_readableStreamReadableStreamToTextCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -2464,7 +2464,7 @@ const JSC::ConstructorKind s_readableStreamReadableStreamToArrayBufferCodeConstr const JSC::ImplementationVisibility s_readableStreamReadableStreamToArrayBufferCodeImplementationVisibility = JSC::ImplementationVisibility::Private; const int s_readableStreamReadableStreamToArrayBufferCodeLength = 270; static const JSC::Intrinsic s_readableStreamReadableStreamToArrayBufferCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_readableStreamReadableStreamToArrayBufferCode = "(function (_){\"use strict\";var b=@getByIdDirectPrivate(_,\"underlyingSource\");if(b!==@undefined)return @readableStreamToArrayBufferDirect(_,b);var p=@Bun.readableStreamToArray(_);if(@isPromise(p))return p.then(@Bun.concatArrayBuffers);return @Bun.concatArrayBuffers(p)})\n"; +const char* const s_readableStreamReadableStreamToArrayBufferCode = "(function (_){\"use strict\";var p=@getByIdDirectPrivate(_,\"underlyingSource\");if(p!==@undefined)return @readableStreamToArrayBufferDirect(_,p);var b=@Bun.readableStreamToArray(_);if(@isPromise(b))return b.then(@Bun.concatArrayBuffers);return @Bun.concatArrayBuffers(b)})\n"; // readableStreamToJSON const JSC::ConstructAbility s_readableStreamReadableStreamToJSONCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -2488,7 +2488,7 @@ const JSC::ConstructorKind s_readableStreamConsumeReadableStreamCodeConstructorK const JSC::ImplementationVisibility s_readableStreamConsumeReadableStreamCodeImplementationVisibility = JSC::ImplementationVisibility::Private; const int s_readableStreamConsumeReadableStreamCodeLength = 1603; static const JSC::Intrinsic s_readableStreamConsumeReadableStreamCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_readableStreamConsumeReadableStreamCode = "(function (w,x,A){\"use strict\";const B=globalThis.Symbol.for(\"Bun.consumeReadableStreamPrototype\");var j=globalThis[B];if(!j)j=globalThis[B]=[];var I=j[x];if(I===@undefined){var[k,J,K,L,G,_]=globalThis[globalThis.Symbol.for(\"Bun.lazy\")](x);I=class H{handleError;handleClosed;processResult;constructor(D,N){this.#_=N,this.#F=D,this.#$=!1,this.handleError=this._handleError.bind(this),this.handleClosed=this._handleClosed.bind(this),this.processResult=this._processResult.bind(this),D.closed.then(this.handleClosed,this.handleError)}_handleClosed(){if(this.#$)return;this.#$=!0;var D=this.#_;this.#_=0,L(D),_(D)}_handleError(D){if(this.#$)return;this.#$=!0;var N=this.#_;this.#_=0,J(N,D),_(N)}#_;#$=!1;#F;_handleReadMany({value:D,done:N,size:q}){if(N){this.handleClosed();return}if(this.#$)return;K(this.#_,D,N,q)}read(){if(!this.#_)return @throwTypeError(\"ReadableStreamSink is already closed\");return this.processResult(this.#F.read())}_processResult(D){if(D&&@isPromise(D)){if(@getPromiseInternalField(D,@promiseFieldFlags)&@promiseStateFulfilled){const q=@getPromiseInternalField(D,@promiseFieldReactionsOrResult);if(q)D=q}}if(D&&@isPromise(D))return D.then(this.processResult,this.handleError),null;if(D.done)return this.handleClosed(),0;else if(D.value)return D.value;else return-1}readMany(){if(!this.#_)return @throwTypeError(\"ReadableStreamSink is already closed\");return this.processResult(this.#F.readMany())}};const F=x+1;if(j.length{@putByIdDirectPrivate(d,\"started\",1),@assert(!@getByIdDirectPrivate(d,\"pulling\")),@assert(!@getByIdDirectPrivate(d,\"pullAgain\")),@readableByteStreamControllerCallPullIfNeeded(d)},(f)=>{if(@getByIdDirectPrivate(_,\"state\")===@streamReadable)@readableByteStreamControllerError(d,f)}),@putByIdDirectPrivate(this,\"cancel\",@readableByteStreamControllerCancel),@putByIdDirectPrivate(this,\"pull\",@readableByteStreamControllerPull),this})\n"; +const char* const s_readableByteStreamInternalsPrivateInitializeReadableByteStreamControllerCode = "(function (b,p,R){\"use strict\";if(!@isReadableStream(b))@throwTypeError(\"ReadableByteStreamController needs a ReadableStream\");if(@getByIdDirectPrivate(b,\"readableStreamController\")!==null)@throwTypeError(\"ReadableStream already has a controller\");@putByIdDirectPrivate(this,\"controlledReadableStream\",b),@putByIdDirectPrivate(this,\"underlyingByteSource\",p),@putByIdDirectPrivate(this,\"pullAgain\",!1),@putByIdDirectPrivate(this,\"pulling\",!1),@readableByteStreamControllerClearPendingPullIntos(this),@putByIdDirectPrivate(this,\"queue\",@newQueue()),@putByIdDirectPrivate(this,\"started\",0),@putByIdDirectPrivate(this,\"closeRequested\",!1);let f=@toNumber(R);if(@isNaN(f)||f<0)@throwRangeError(\"highWaterMark value is negative or not a number\");@putByIdDirectPrivate(this,\"strategyHWM\",f);let _=p.autoAllocateChunkSize;if(_!==@undefined){if(_=@toNumber(_),_<=0||_===@Infinity||_===-@Infinity)@throwRangeError(\"autoAllocateChunkSize value is negative or equal to positive or negative infinity\")}@putByIdDirectPrivate(this,\"autoAllocateChunkSize\",_),@putByIdDirectPrivate(this,\"pendingPullIntos\",@createFIFO());const v=this;return @promiseInvokeOrNoopNoCatch(@getByIdDirectPrivate(v,\"underlyingByteSource\"),\"start\",[v]).@then(()=>{@putByIdDirectPrivate(v,\"started\",1),@assert(!@getByIdDirectPrivate(v,\"pulling\")),@assert(!@getByIdDirectPrivate(v,\"pullAgain\")),@readableByteStreamControllerCallPullIfNeeded(v)},(d)=>{if(@getByIdDirectPrivate(b,\"state\")===@streamReadable)@readableByteStreamControllerError(v,d)}),@putByIdDirectPrivate(this,\"cancel\",@readableByteStreamControllerCancel),@putByIdDirectPrivate(this,\"pull\",@readableByteStreamControllerPull),this})\n"; // readableStreamByteStreamControllerStart const JSC::ConstructAbility s_readableByteStreamInternalsReadableStreamByteStreamControllerStartCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -2684,7 +2684,7 @@ const JSC::ConstructorKind s_readableByteStreamInternalsReadableByteStreamContro const JSC::ImplementationVisibility s_readableByteStreamInternalsReadableByteStreamControllerCancelCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_readableByteStreamInternalsReadableByteStreamControllerCancelCodeLength = 248; static const JSC::Intrinsic s_readableByteStreamInternalsReadableByteStreamControllerCancelCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_readableByteStreamInternalsReadableByteStreamControllerCancelCode = "(function (a,p){\"use strict\";var u=@getByIdDirectPrivate(a,\"pendingPullIntos\"),_=u.peek();if(_)_.bytesFilled=0;return @putByIdDirectPrivate(a,\"queue\",@newQueue()),@promiseInvokeOrNoop(@getByIdDirectPrivate(a,\"underlyingByteSource\"),\"cancel\",[p])})\n"; +const char* const s_readableByteStreamInternalsReadableByteStreamControllerCancelCode = "(function (a,u){\"use strict\";var _=@getByIdDirectPrivate(a,\"pendingPullIntos\"),p=_.peek();if(p)p.bytesFilled=0;return @putByIdDirectPrivate(a,\"queue\",@newQueue()),@promiseInvokeOrNoop(@getByIdDirectPrivate(a,\"underlyingByteSource\"),\"cancel\",[u])})\n"; // readableByteStreamControllerError const JSC::ConstructAbility s_readableByteStreamInternalsReadableByteStreamControllerErrorCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -2716,7 +2716,7 @@ const JSC::ConstructorKind s_readableByteStreamInternalsReadableByteStreamContro const JSC::ImplementationVisibility s_readableByteStreamInternalsReadableByteStreamControllerGetDesiredSizeCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_readableByteStreamInternalsReadableByteStreamControllerGetDesiredSizeCodeLength = 272; static const JSC::Intrinsic s_readableByteStreamInternalsReadableByteStreamControllerGetDesiredSizeCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_readableByteStreamInternalsReadableByteStreamControllerGetDesiredSizeCode = "(function (u){\"use strict\";const d=@getByIdDirectPrivate(u,\"controlledReadableStream\"),_=@getByIdDirectPrivate(d,\"state\");if(_===@streamErrored)return null;if(_===@streamClosed)return 0;return @getByIdDirectPrivate(u,\"strategyHWM\")-@getByIdDirectPrivate(u,\"queue\").size})\n"; +const char* const s_readableByteStreamInternalsReadableByteStreamControllerGetDesiredSizeCode = "(function (u){\"use strict\";const _=@getByIdDirectPrivate(u,\"controlledReadableStream\"),d=@getByIdDirectPrivate(_,\"state\");if(d===@streamErrored)return null;if(d===@streamClosed)return 0;return @getByIdDirectPrivate(u,\"strategyHWM\")-@getByIdDirectPrivate(u,\"queue\").size})\n"; // readableStreamHasBYOBReader const JSC::ConstructAbility s_readableByteStreamInternalsReadableStreamHasBYOBReaderCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -2724,7 +2724,7 @@ const JSC::ConstructorKind s_readableByteStreamInternalsReadableStreamHasBYOBRea const JSC::ImplementationVisibility s_readableByteStreamInternalsReadableStreamHasBYOBReaderCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_readableByteStreamInternalsReadableStreamHasBYOBReaderCodeLength = 125; static const JSC::Intrinsic s_readableByteStreamInternalsReadableStreamHasBYOBReaderCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_readableByteStreamInternalsReadableStreamHasBYOBReaderCode = "(function (n){\"use strict\";const u=@getByIdDirectPrivate(n,\"reader\");return u!==@undefined&&@isReadableStreamBYOBReader(u)})\n"; +const char* const s_readableByteStreamInternalsReadableStreamHasBYOBReaderCode = "(function (u){\"use strict\";const n=@getByIdDirectPrivate(u,\"reader\");return n!==@undefined&&@isReadableStreamBYOBReader(n)})\n"; // readableStreamHasDefaultReader const JSC::ConstructAbility s_readableByteStreamInternalsReadableStreamHasDefaultReaderCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -2732,7 +2732,7 @@ const JSC::ConstructorKind s_readableByteStreamInternalsReadableStreamHasDefault const JSC::ImplementationVisibility s_readableByteStreamInternalsReadableStreamHasDefaultReaderCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_readableByteStreamInternalsReadableStreamHasDefaultReaderCodeLength = 128; static const JSC::Intrinsic s_readableByteStreamInternalsReadableStreamHasDefaultReaderCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_readableByteStreamInternalsReadableStreamHasDefaultReaderCode = "(function (l){\"use strict\";const n=@getByIdDirectPrivate(l,\"reader\");return n!==@undefined&&@isReadableStreamDefaultReader(n)})\n"; +const char* const s_readableByteStreamInternalsReadableStreamHasDefaultReaderCode = "(function (n){\"use strict\";const l=@getByIdDirectPrivate(n,\"reader\");return l!==@undefined&&@isReadableStreamDefaultReader(l)})\n"; // readableByteStreamControllerHandleQueueDrain const JSC::ConstructAbility s_readableByteStreamInternalsReadableByteStreamControllerHandleQueueDrainCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -2748,7 +2748,7 @@ const JSC::ConstructorKind s_readableByteStreamInternalsReadableByteStreamContro const JSC::ImplementationVisibility s_readableByteStreamInternalsReadableByteStreamControllerPullCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_readableByteStreamInternalsReadableByteStreamControllerPullCodeLength = 1005; static const JSC::Intrinsic s_readableByteStreamInternalsReadableByteStreamControllerPullCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_readableByteStreamInternalsReadableByteStreamControllerPullCode = "(function (_){\"use strict\";const h=@getByIdDirectPrivate(_,\"controlledReadableStream\");if(@assert(@readableStreamHasDefaultReader(h)),@getByIdDirectPrivate(_,\"queue\").content\?.isNotEmpty()){const F=@getByIdDirectPrivate(_,\"queue\").content.shift();@getByIdDirectPrivate(_,\"queue\").size-=F.byteLength,@readableByteStreamControllerHandleQueueDrain(_);let P;try{P=new @Uint8Array(F.buffer,F.byteOffset,F.byteLength)}catch(R){return @Promise.@reject(R)}return @createFulfilledPromise({value:P,done:!1})}if(@getByIdDirectPrivate(_,\"autoAllocateChunkSize\")!==@undefined){let F;try{F=@createUninitializedArrayBuffer(@getByIdDirectPrivate(_,\"autoAllocateChunkSize\"))}catch(R){return @Promise.@reject(R)}const P={buffer:F,byteOffset:0,byteLength:@getByIdDirectPrivate(_,\"autoAllocateChunkSize\"),bytesFilled:0,elementSize:1,ctor:@Uint8Array,readerType:\"default\"};@getByIdDirectPrivate(_,\"pendingPullIntos\").push(P)}const d=@readableStreamAddReadRequest(h);return @readableByteStreamControllerCallPullIfNeeded(_),d})\n"; +const char* const s_readableByteStreamInternalsReadableByteStreamControllerPullCode = "(function (_){\"use strict\";const P=@getByIdDirectPrivate(_,\"controlledReadableStream\");if(@assert(@readableStreamHasDefaultReader(P)),@getByIdDirectPrivate(_,\"queue\").content\?.isNotEmpty()){const d=@getByIdDirectPrivate(_,\"queue\").content.shift();@getByIdDirectPrivate(_,\"queue\").size-=d.byteLength,@readableByteStreamControllerHandleQueueDrain(_);let h;try{h=new @Uint8Array(d.buffer,d.byteOffset,d.byteLength)}catch(F){return @Promise.@reject(F)}return @createFulfilledPromise({value:h,done:!1})}if(@getByIdDirectPrivate(_,\"autoAllocateChunkSize\")!==@undefined){let d;try{d=@createUninitializedArrayBuffer(@getByIdDirectPrivate(_,\"autoAllocateChunkSize\"))}catch(F){return @Promise.@reject(F)}const h={buffer:d,byteOffset:0,byteLength:@getByIdDirectPrivate(_,\"autoAllocateChunkSize\"),bytesFilled:0,elementSize:1,ctor:@Uint8Array,readerType:\"default\"};@getByIdDirectPrivate(_,\"pendingPullIntos\").push(h)}const R=@readableStreamAddReadRequest(P);return @readableByteStreamControllerCallPullIfNeeded(_),R})\n"; // readableByteStreamControllerShouldCallPull const JSC::ConstructAbility s_readableByteStreamInternalsReadableByteStreamControllerShouldCallPullCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -2788,7 +2788,7 @@ const JSC::ConstructorKind s_readableByteStreamInternalsReadableByteStreamContro const JSC::ImplementationVisibility s_readableByteStreamInternalsReadableByteStreamControllerEnqueueCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_readableByteStreamInternalsReadableByteStreamControllerEnqueueCodeLength = 1076; static const JSC::Intrinsic s_readableByteStreamInternalsReadableByteStreamControllerEnqueueCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_readableByteStreamInternalsReadableByteStreamControllerEnqueueCode = "(function (i,_){\"use strict\";const f=@getByIdDirectPrivate(i,\"controlledReadableStream\");switch(@assert(!@getByIdDirectPrivate(i,\"closeRequested\")),@assert(@getByIdDirectPrivate(f,\"state\")===@streamReadable),@getByIdDirectPrivate(f,\"reader\")\?@readableStreamReaderKind(@getByIdDirectPrivate(f,\"reader\")):0){case 1:{if(!@getByIdDirectPrivate(@getByIdDirectPrivate(f,\"reader\"),\"readRequests\")\?.isNotEmpty())@readableByteStreamControllerEnqueueChunk(i,@transferBufferToCurrentRealm(_.buffer),_.byteOffset,_.byteLength);else{@assert(!@getByIdDirectPrivate(i,\"queue\").content.size());const d=_.constructor===@Uint8Array\?_:new @Uint8Array(_.buffer,_.byteOffset,_.byteLength);@readableStreamFulfillReadRequest(f,d,!1)}break}case 2:{@readableByteStreamControllerEnqueueChunk(i,@transferBufferToCurrentRealm(_.buffer),_.byteOffset,_.byteLength),@readableByteStreamControllerProcessPullDescriptors(i);break}case 3:break;default:{@assert(!@isReadableStreamLocked(f)),@readableByteStreamControllerEnqueueChunk(i,@transferBufferToCurrentRealm(_.buffer),_.byteOffset,_.byteLength);break}}})\n"; +const char* const s_readableByteStreamInternalsReadableByteStreamControllerEnqueueCode = "(function (d,i){\"use strict\";const _=@getByIdDirectPrivate(d,\"controlledReadableStream\");switch(@assert(!@getByIdDirectPrivate(d,\"closeRequested\")),@assert(@getByIdDirectPrivate(_,\"state\")===@streamReadable),@getByIdDirectPrivate(_,\"reader\")\?@readableStreamReaderKind(@getByIdDirectPrivate(_,\"reader\")):0){case 1:{if(!@getByIdDirectPrivate(@getByIdDirectPrivate(_,\"reader\"),\"readRequests\")\?.isNotEmpty())@readableByteStreamControllerEnqueueChunk(d,@transferBufferToCurrentRealm(i.buffer),i.byteOffset,i.byteLength);else{@assert(!@getByIdDirectPrivate(d,\"queue\").content.size());const f=i.constructor===@Uint8Array\?i:new @Uint8Array(i.buffer,i.byteOffset,i.byteLength);@readableStreamFulfillReadRequest(_,f,!1)}break}case 2:{@readableByteStreamControllerEnqueueChunk(d,@transferBufferToCurrentRealm(i.buffer),i.byteOffset,i.byteLength),@readableByteStreamControllerProcessPullDescriptors(d);break}case 3:break;default:{@assert(!@isReadableStreamLocked(_)),@readableByteStreamControllerEnqueueChunk(d,@transferBufferToCurrentRealm(i.buffer),i.byteOffset,i.byteLength);break}}})\n"; // readableByteStreamControllerEnqueueChunk const JSC::ConstructAbility s_readableByteStreamInternalsReadableByteStreamControllerEnqueueChunkCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -2796,7 +2796,7 @@ const JSC::ConstructorKind s_readableByteStreamInternalsReadableByteStreamContro const JSC::ImplementationVisibility s_readableByteStreamInternalsReadableByteStreamControllerEnqueueChunkCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_readableByteStreamInternalsReadableByteStreamControllerEnqueueChunkCodeLength = 160; static const JSC::Intrinsic s_readableByteStreamInternalsReadableByteStreamControllerEnqueueChunkCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_readableByteStreamInternalsReadableByteStreamControllerEnqueueChunkCode = "(function (_,a,d,p){\"use strict\";@getByIdDirectPrivate(_,\"queue\").content.push({buffer:a,byteOffset:d,byteLength:p}),@getByIdDirectPrivate(_,\"queue\").size+=p})\n"; +const char* const s_readableByteStreamInternalsReadableByteStreamControllerEnqueueChunkCode = "(function (_,d,p,a){\"use strict\";@getByIdDirectPrivate(_,\"queue\").content.push({buffer:d,byteOffset:p,byteLength:a}),@getByIdDirectPrivate(_,\"queue\").size+=a})\n"; // readableByteStreamControllerRespondWithNewView const JSC::ConstructAbility s_readableByteStreamInternalsReadableByteStreamControllerRespondWithNewViewCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -2804,7 +2804,7 @@ const JSC::ConstructorKind s_readableByteStreamInternalsReadableByteStreamContro const JSC::ImplementationVisibility s_readableByteStreamInternalsReadableByteStreamControllerRespondWithNewViewCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_readableByteStreamInternalsReadableByteStreamControllerRespondWithNewViewCodeLength = 417; static const JSC::Intrinsic s_readableByteStreamInternalsReadableByteStreamControllerRespondWithNewViewCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_readableByteStreamInternalsReadableByteStreamControllerRespondWithNewViewCode = "(function (u,a){\"use strict\";@assert(@getByIdDirectPrivate(u,\"pendingPullIntos\").isNotEmpty());let d=@getByIdDirectPrivate(u,\"pendingPullIntos\").peek();if(d.byteOffset+d.bytesFilled!==a.byteOffset)@throwRangeError(\"Invalid value for view.byteOffset\");if(d.byteLength!==a.byteLength)@throwRangeError(\"Invalid value for view.byteLength\");d.buffer=a.buffer,@readableByteStreamControllerRespondInternal(u,a.byteLength)})\n"; +const char* const s_readableByteStreamInternalsReadableByteStreamControllerRespondWithNewViewCode = "(function (d,u){\"use strict\";@assert(@getByIdDirectPrivate(d,\"pendingPullIntos\").isNotEmpty());let a=@getByIdDirectPrivate(d,\"pendingPullIntos\").peek();if(a.byteOffset+a.bytesFilled!==u.byteOffset)@throwRangeError(\"Invalid value for view.byteOffset\");if(a.byteLength!==u.byteLength)@throwRangeError(\"Invalid value for view.byteLength\");a.buffer=u.buffer,@readableByteStreamControllerRespondInternal(d,u.byteLength)})\n"; // readableByteStreamControllerRespond const JSC::ConstructAbility s_readableByteStreamInternalsReadableByteStreamControllerRespondCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -2812,7 +2812,7 @@ const JSC::ConstructorKind s_readableByteStreamInternalsReadableByteStreamContro const JSC::ImplementationVisibility s_readableByteStreamInternalsReadableByteStreamControllerRespondCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_readableByteStreamInternalsReadableByteStreamControllerRespondCodeLength = 251; static const JSC::Intrinsic s_readableByteStreamInternalsReadableByteStreamControllerRespondCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_readableByteStreamInternalsReadableByteStreamControllerRespondCode = "(function (u,I){\"use strict\";if(I=@toNumber(I),@isNaN(I)||I===@Infinity||I<0)@throwRangeError(\"bytesWritten has an incorrect value\");@assert(@getByIdDirectPrivate(u,\"pendingPullIntos\").isNotEmpty()),@readableByteStreamControllerRespondInternal(u,I)})\n"; +const char* const s_readableByteStreamInternalsReadableByteStreamControllerRespondCode = "(function (I,u){\"use strict\";if(u=@toNumber(u),@isNaN(u)||u===@Infinity||u<0)@throwRangeError(\"bytesWritten has an incorrect value\");@assert(@getByIdDirectPrivate(I,\"pendingPullIntos\").isNotEmpty()),@readableByteStreamControllerRespondInternal(I,u)})\n"; // readableByteStreamControllerRespondInternal const JSC::ConstructAbility s_readableByteStreamInternalsReadableByteStreamControllerRespondInternalCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -2828,7 +2828,7 @@ const JSC::ConstructorKind s_readableByteStreamInternalsReadableByteStreamContro const JSC::ImplementationVisibility s_readableByteStreamInternalsReadableByteStreamControllerRespondInReadableStateCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_readableByteStreamInternalsReadableByteStreamControllerRespondInReadableStateCodeLength = 799; static const JSC::Intrinsic s_readableByteStreamInternalsReadableByteStreamControllerRespondInReadableStateCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_readableByteStreamInternalsReadableByteStreamControllerRespondInReadableStateCode = "(function (f,R,w){\"use strict\";if(w.bytesFilled+R>w.byteLength)@throwRangeError(\"bytesWritten value is too great\");if(@assert(@getByIdDirectPrivate(f,\"pendingPullIntos\").isEmpty()||@getByIdDirectPrivate(f,\"pendingPullIntos\").peek()===w),@readableByteStreamControllerInvalidateBYOBRequest(f),w.bytesFilled+=R,w.bytesFilled0){const g=w.byteOffset+w.bytesFilled,h=@cloneArrayBuffer(w.buffer,g-_,_);@readableByteStreamControllerEnqueueChunk(f,h,0,h.byteLength)}w.buffer=@transferBufferToCurrentRealm(w.buffer),w.bytesFilled-=_,@readableByteStreamControllerCommitDescriptor(@getByIdDirectPrivate(f,\"controlledReadableStream\"),w),@readableByteStreamControllerProcessPullDescriptors(f)})\n"; +const char* const s_readableByteStreamInternalsReadableByteStreamControllerRespondInReadableStateCode = "(function (w,_,f){\"use strict\";if(f.bytesFilled+_>f.byteLength)@throwRangeError(\"bytesWritten value is too great\");if(@assert(@getByIdDirectPrivate(w,\"pendingPullIntos\").isEmpty()||@getByIdDirectPrivate(w,\"pendingPullIntos\").peek()===f),@readableByteStreamControllerInvalidateBYOBRequest(w),f.bytesFilled+=_,f.bytesFilled0){const h=f.byteOffset+f.bytesFilled,g=@cloneArrayBuffer(f.buffer,h-R,R);@readableByteStreamControllerEnqueueChunk(w,g,0,g.byteLength)}f.buffer=@transferBufferToCurrentRealm(f.buffer),f.bytesFilled-=R,@readableByteStreamControllerCommitDescriptor(@getByIdDirectPrivate(w,\"controlledReadableStream\"),f),@readableByteStreamControllerProcessPullDescriptors(w)})\n"; // readableByteStreamControllerRespondInClosedState const JSC::ConstructAbility s_readableByteStreamInternalsReadableByteStreamControllerRespondInClosedStateCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -2852,7 +2852,7 @@ const JSC::ConstructorKind s_readableByteStreamInternalsReadableByteStreamContro const JSC::ImplementationVisibility s_readableByteStreamInternalsReadableByteStreamControllerFillDescriptorFromQueueCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_readableByteStreamInternalsReadableByteStreamControllerFillDescriptorFromQueueCodeLength = 970; static const JSC::Intrinsic s_readableByteStreamInternalsReadableByteStreamControllerFillDescriptorFromQueueCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_readableByteStreamInternalsReadableByteStreamControllerFillDescriptorFromQueueCode = "(function (_,q){\"use strict\";const z=q.bytesFilled-q.bytesFilled%q.elementSize,j=@getByIdDirectPrivate(_,\"queue\").sizez)G=k-q.bytesFilled,v=!0;while(G>0){let H=@getByIdDirectPrivate(_,\"queue\").content.peek();const w=G0),@assert(q.bytesFilledH)v=G-_.bytesFilled,w=!0;while(v>0){let j=@getByIdDirectPrivate(q,\"queue\").content.peek();const k=v0),@assert(_.bytesFilled<_.elementSize);return w})\n"; // readableByteStreamControllerShiftPendingDescriptor const JSC::ConstructAbility s_readableByteStreamInternalsReadableByteStreamControllerShiftPendingDescriptorCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -2892,7 +2892,7 @@ const JSC::ConstructorKind s_readableByteStreamInternalsReadableStreamFulfillRea const JSC::ImplementationVisibility s_readableByteStreamInternalsReadableStreamFulfillReadIntoRequestCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_readableByteStreamInternalsReadableStreamFulfillReadIntoRequestCodeLength = 161; static const JSC::Intrinsic s_readableByteStreamInternalsReadableStreamFulfillReadIntoRequestCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_readableByteStreamInternalsReadableStreamFulfillReadIntoRequestCode = "(function (l,p,_){\"use strict\";const i=@getByIdDirectPrivate(@getByIdDirectPrivate(l,\"reader\"),\"readIntoRequests\").shift();@fulfillPromise(i,{value:p,done:_})})\n"; +const char* const s_readableByteStreamInternalsReadableStreamFulfillReadIntoRequestCode = "(function (l,i,p){\"use strict\";const _=@getByIdDirectPrivate(@getByIdDirectPrivate(l,\"reader\"),\"readIntoRequests\").shift();@fulfillPromise(_,{value:i,done:p})})\n"; // readableStreamBYOBReaderRead const JSC::ConstructAbility s_readableByteStreamInternalsReadableStreamBYOBReaderReadCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -2900,7 +2900,7 @@ const JSC::ConstructorKind s_readableByteStreamInternalsReadableStreamBYOBReader const JSC::ImplementationVisibility s_readableByteStreamInternalsReadableStreamBYOBReaderReadCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_readableByteStreamInternalsReadableStreamBYOBReaderReadCodeLength = 356; static const JSC::Intrinsic s_readableByteStreamInternalsReadableStreamBYOBReaderReadCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_readableByteStreamInternalsReadableStreamBYOBReaderReadCode = "(function (o,c){\"use strict\";const l=@getByIdDirectPrivate(o,\"ownerReadableStream\");if(@assert(!!l),@putByIdDirectPrivate(l,\"disturbed\",!0),@getByIdDirectPrivate(l,\"state\")===@streamErrored)return @Promise.@reject(@getByIdDirectPrivate(l,\"storedError\"));return @readableByteStreamControllerPullInto(@getByIdDirectPrivate(l,\"readableStreamController\"),c)})\n"; +const char* const s_readableByteStreamInternalsReadableStreamBYOBReaderReadCode = "(function (c,l){\"use strict\";const o=@getByIdDirectPrivate(c,\"ownerReadableStream\");if(@assert(!!o),@putByIdDirectPrivate(o,\"disturbed\",!0),@getByIdDirectPrivate(o,\"state\")===@streamErrored)return @Promise.@reject(@getByIdDirectPrivate(o,\"storedError\"));return @readableByteStreamControllerPullInto(@getByIdDirectPrivate(o,\"readableStreamController\"),l)})\n"; // readableByteStreamControllerPullInto const JSC::ConstructAbility s_readableByteStreamInternalsReadableByteStreamControllerPullIntoCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -2908,7 +2908,7 @@ const JSC::ConstructorKind s_readableByteStreamInternalsReadableByteStreamContro const JSC::ImplementationVisibility s_readableByteStreamInternalsReadableByteStreamControllerPullIntoCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_readableByteStreamInternalsReadableByteStreamControllerPullIntoCodeLength = 1255; static const JSC::Intrinsic s_readableByteStreamInternalsReadableByteStreamControllerPullIntoCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_readableByteStreamInternalsReadableByteStreamControllerPullIntoCode = "(function (_,E){\"use strict\";const b=@getByIdDirectPrivate(_,\"controlledReadableStream\");let d=1;if(E.BYTES_PER_ELEMENT!==@undefined)d=E.BYTES_PER_ELEMENT;const k=E.constructor,A={buffer:E.buffer,byteOffset:E.byteOffset,byteLength:E.byteLength,bytesFilled:0,elementSize:d,ctor:k,readerType:\"byob\"};var L=@getByIdDirectPrivate(_,\"pendingPullIntos\");if(L\?.isNotEmpty())return A.buffer=@transferBufferToCurrentRealm(A.buffer),L.push(A),@readableStreamAddReadIntoRequest(b);if(@getByIdDirectPrivate(b,\"state\")===@streamClosed){const R=new k(A.buffer,A.byteOffset,0);return @createFulfilledPromise({value:R,done:!0})}if(@getByIdDirectPrivate(_,\"queue\").size>0){if(@readableByteStreamControllerFillDescriptorFromQueue(_,A)){const R=@readableByteStreamControllerConvertDescriptor(A);return @readableByteStreamControllerHandleQueueDrain(_),@createFulfilledPromise({value:R,done:!1})}if(@getByIdDirectPrivate(_,\"closeRequested\")){const R=@makeTypeError(\"Closing stream has been requested\");return @readableByteStreamControllerError(_,R),@Promise.@reject(R)}}A.buffer=@transferBufferToCurrentRealm(A.buffer),@getByIdDirectPrivate(_,\"pendingPullIntos\").push(A);const N=@readableStreamAddReadIntoRequest(b);return @readableByteStreamControllerCallPullIfNeeded(_),N})\n"; +const char* const s_readableByteStreamInternalsReadableByteStreamControllerPullIntoCode = "(function (b,d){\"use strict\";const A=@getByIdDirectPrivate(b,\"controlledReadableStream\");let E=1;if(d.BYTES_PER_ELEMENT!==@undefined)E=d.BYTES_PER_ELEMENT;const L=d.constructor,_={buffer:d.buffer,byteOffset:d.byteOffset,byteLength:d.byteLength,bytesFilled:0,elementSize:E,ctor:L,readerType:\"byob\"};var N=@getByIdDirectPrivate(b,\"pendingPullIntos\");if(N\?.isNotEmpty())return _.buffer=@transferBufferToCurrentRealm(_.buffer),N.push(_),@readableStreamAddReadIntoRequest(A);if(@getByIdDirectPrivate(A,\"state\")===@streamClosed){const k=new L(_.buffer,_.byteOffset,0);return @createFulfilledPromise({value:k,done:!0})}if(@getByIdDirectPrivate(b,\"queue\").size>0){if(@readableByteStreamControllerFillDescriptorFromQueue(b,_)){const k=@readableByteStreamControllerConvertDescriptor(_);return @readableByteStreamControllerHandleQueueDrain(b),@createFulfilledPromise({value:k,done:!1})}if(@getByIdDirectPrivate(b,\"closeRequested\")){const k=@makeTypeError(\"Closing stream has been requested\");return @readableByteStreamControllerError(b,k),@Promise.@reject(k)}}_.buffer=@transferBufferToCurrentRealm(_.buffer),@getByIdDirectPrivate(b,\"pendingPullIntos\").push(_);const R=@readableStreamAddReadIntoRequest(A);return @readableByteStreamControllerCallPullIfNeeded(b),R})\n"; // readableStreamAddReadIntoRequest const JSC::ConstructAbility s_readableByteStreamInternalsReadableStreamAddReadIntoRequestCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -2942,7 +2942,7 @@ const JSC::ConstructorKind s_writableStreamDefaultControllerErrorCodeConstructor const JSC::ImplementationVisibility s_writableStreamDefaultControllerErrorCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_writableStreamDefaultControllerErrorCodeLength = 301; static const JSC::Intrinsic s_writableStreamDefaultControllerErrorCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_writableStreamDefaultControllerErrorCode = "(function (t){\"use strict\";if(@getByIdDirectPrivate(this,\"abortSteps\")===@undefined)throw @makeThisTypeError(\"WritableStreamDefaultController\",\"error\");const r=@getByIdDirectPrivate(this,\"stream\");if(@getByIdDirectPrivate(r,\"state\")!==\"writable\")return;@writableStreamDefaultControllerError(this,t)})\n"; +const char* const s_writableStreamDefaultControllerErrorCode = "(function (r){\"use strict\";if(@getByIdDirectPrivate(this,\"abortSteps\")===@undefined)throw @makeThisTypeError(\"WritableStreamDefaultController\",\"error\");const t=@getByIdDirectPrivate(this,\"stream\");if(@getByIdDirectPrivate(t,\"state\")!==\"writable\")return;@writableStreamDefaultControllerError(this,r)})\n"; #define DEFINE_BUILTIN_GENERATOR(codeName, functionName, overriddenName, argumentCount) \ JSC::FunctionExecutable* codeName##Generator(JSC::VM& vm) \ @@ -2960,7 +2960,7 @@ const JSC::ConstructorKind s_eventSourceGetEventSourceCodeConstructorKind = JSC: const JSC::ImplementationVisibility s_eventSourceGetEventSourceCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_eventSourceGetEventSourceCodeLength = 5477; static const JSC::Intrinsic s_eventSourceGetEventSourceCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_eventSourceGetEventSourceCode = "(function (){\"use strict\";class F extends EventTarget{#$;#j;#w;#A;#B;#F=!1;#G=null;#J=\"\";#K=\"\";#L=\"\";#M=!0;#O=0;#Q=0;#U=0;#V=null;static#W(W){W.#H()}static#X(W,Y){const O=W.data,Z=O.#L\?`Last-Event-ID: ${O.#L}\\r\\n`:\"\",j=`GET ${Y.pathname}${Y.search} HTTP/1.1\\r\\nHost: bun\\r\\nContent-type: text/event-stream\\r\\nContent-length: 0\\r\\n${Z}\\r\\n`,G=W.write(j);if(G!==j.length)O.#K=j.substring(G)}static#Y(W,Y,O){for(;;){if(O>=Y.length)return;let Z=-1,j=Y.indexOf(\"\\r\\n\",O);const G=j+2;if(j>0)if(W.#O===0){const w=parseInt(Y.substring(O,j),16);if(w===0){W.#j=2,W.#G\?.end();return}Z=G+w}else Z=Y.length;else{if(W.#J.length===0){W.#J+=Y.substring(O);return}Z=Y.length}let z=Y.substring(G,Z);O=Z+2;let B=0,J=z.indexOf(\"\\n\\n\");if(J==-1){W.#J+=Y.substring(G);return}if(W.#J.length)W.#J+=z,z=W.#J,W.#J=\"\";let K=!0;while(K){const w=z.substring(B,J);let Q,L=\"\",X,A=0,U=-1;for(;;){let V=w.indexOf(\"\\n\",A);if(V===-1){if(A>=w.length)break;V=w.length}const H=w.substring(A,V);if(H.startsWith(\"data:\"))if(L.length)L+=`\\n${H.substring(5).trim()}`;else L=H.substring(5).trim();else if(H.startsWith(\"event:\"))Q=H.substring(6).trim();else if(H.startsWith(\"id:\"))X=H.substring(3).trim();else if(H.startsWith(\"retry:\")){if(U=parseInt(H.substring(6).trim(),10),@isNaN(U))U=-1}A=V+1}if(W.#L=X||\"\",U>=0)W.#U=U;if(L||X||Q)W.dispatchEvent(new MessageEvent(Q||\"message\",{data:L||\"\",origin:W.#$.origin,source:W,lastEventId:X}));if(z.length===J+2){K=!1;break}const M=z.indexOf(\"\\n\\n\",J+1);if(M===-1)break;B=J,J=M}}}static#Z={open(W){const Y=W.data;if(Y.#G=W,!Y.#F)F.#X(W,Y.#$)},handshake(W,Y,O){const Z=W.data;if(Y)F.#X(W,Z.#$);else Z.#j=2,Z.dispatchEvent(new ErrorEvent(\"error\",{error:O})),W.end()},data(W,Y){const O=W.data;switch(O.#j){case 0:{let Z=Y.toString();const j=Z.indexOf(\"\\r\\n\\r\\n\");if(j===-1){O.#J+=Z;return}if(O.#J.length)O.#J+=Z,Z=O.#J,O.#J=\"\";const G=Z.substring(0,j),z=G.indexOf(\"\\r\\n\");if(z===-1){O.#j=2,O.dispatchEvent(new ErrorEvent(\"error\",{error:new Error(\"Invalid HTTP request\")})),W.end();return}const B=G.substring(0,z);if(B!==\"HTTP/1.1 200 OK\"){O.#j=2,O.dispatchEvent(new ErrorEvent(\"error\",{error:new Error(B)})),W.end();return}let J=z+1,K=!1,w=-1;for(;;){let L=G.indexOf(\"\\r\\n\",J);if(L===-1){if(J>=G.length){if(!K)O.#j=2,O.dispatchEvent(new ErrorEvent(\"error\",{error:new Error(`EventSource's response has no MIME type and \"text/event-stream\" is required. Aborting the connection.`)})),W.end();return}L=G.length}const X=G.substring(J+1,L),A=X.indexOf(\":\"),U=X.substring(0,A),M=U.localeCompare(\"content-type\",@undefined,{sensitivity:\"accent\"})===0;if(J=L+1,M)if(X.endsWith(\" text/event-stream\"))K=!0;else{O.#j=2,O.dispatchEvent(new ErrorEvent(\"error\",{error:new Error(`EventSource's response has a MIME type that is not \"text/event-stream\". Aborting the connection.`)})),W.end();return}else if(U.localeCompare(\"content-length\",@undefined,{sensitivity:\"accent\"})===0){if(w=parseInt(X.substring(A+1).trim(),10),@isNaN(w)||w<=0){O.dispatchEvent(new ErrorEvent(\"error\",{error:new Error(`EventSource's Content-Length is invalid. Aborting the connection.`)})),W.end();return}if(K)break}else if(U.localeCompare(\"transfer-encoding\",@undefined,{sensitivity:\"accent\"})===0){if(X.substring(A+1).trim()!==\"chunked\"){O.dispatchEvent(new ErrorEvent(\"error\",{error:new Error(`EventSource's Transfer-Encoding is invalid. Aborting the connection.`)})),W.end();return}if(w=0,K)break}}O.#O=w,O.#j=1,O.dispatchEvent(new Event(\"open\"));const Q=Z.substring(j+4);if(F.#Y(O,Q,0),O.#O>0){if(O.#Q+=Q.length,O.#Q>=O.#O)O.#j=2,W.end()}return}case 1:if(F.#Y(O,Y.toString(),2),O.#O>0){if(O.#Q+=Y.byteLength,O.#Q>=O.#O)O.#j=2,W.end()}return;default:break}},drain(W){const Y=W.data;if(Y.#j===0){const O=Y.#J;if(O.length){const Z=W.write(O);if(Z!==O.length)W.data.#K=O.substring(Z);else W.data.#K=\"\"}}},close:F.#z,end(W){F.#z(W).dispatchEvent(new ErrorEvent(\"error\",{error:new Error(\"Connection closed by server\")}))},timeout(W){F.#z(W).dispatchEvent(new ErrorEvent(\"error\",{error:new Error(\"Timeout\")}))},binaryType:\"buffer\"};static#z(W){const Y=W.data;if(Y.#G=null,Y.#Q=0,Y.#j=2,Y.#M){if(Y.#V)clearTimeout(Y.#V);Y.#V=setTimeout(F.#W,Y.#U,Y)}return Y}constructor(W,Y=@undefined){super();const O=new URL(W);this.#F=O.protocol===\"https:\",this.#$=O,this.#j=2,process.nextTick(F.#W,this)}ref(){this.#V\?.ref(),this.#G\?.ref()}unref(){this.#V\?.unref(),this.#G\?.unref()}#H(){if(this.#j!==2)return;const W=this.#$,Y=this.#F;this.#j=0,@Bun.connect({data:this,socket:F.#Z,hostname:W.hostname,port:parseInt(W.port||(Y\?\"443\":\"80\"),10),tls:Y\?{requestCert:!0,rejectUnauthorized:!1}:!1}).catch((O)=>{if(super.dispatchEvent(new ErrorEvent(\"error\",{error:O})),this.#M){if(this.#V)this.#V.unref\?.();this.#V=setTimeout(F.#W,1000,this)}})}get url(){return this.#$.href}get readyState(){return this.#j}close(){this.#M=!1,this.#j=2,this.#G\?.unref(),this.#G\?.end()}get onopen(){return this.#B}get onerror(){return this.#w}get onmessage(){return this.#A}set onopen(W){if(this.#B)super.removeEventListener(\"close\",this.#B);super.addEventListener(\"open\",W),this.#B=W}set onerror(W){if(this.#w)super.removeEventListener(\"error\",this.#w);super.addEventListener(\"error\",W),this.#w=W}set onmessage(W){if(this.#A)super.removeEventListener(\"message\",this.#A);super.addEventListener(\"message\",W),this.#A=W}}return Object.defineProperty(F.prototype,\"CONNECTING\",{enumerable:!0,value:0}),Object.defineProperty(F.prototype,\"OPEN\",{enumerable:!0,value:1}),Object.defineProperty(F.prototype,\"CLOSED\",{enumerable:!0,value:2}),F[Symbol.for(\"CommonJS\")]=0,F})\n"; +const char* const s_eventSourceGetEventSourceCode = "(function (){\"use strict\";class F extends EventTarget{#B;#$;#J;#K;#L;#M=!1;#A=null;#j=\"\";#O=\"\";#Q=\"\";#U=!0;#F=0;#G=0;#X=0;#w=null;static#V(j){j.#H()}static#Y(j,A){const w=j.data,B=w.#Q\?`Last-Event-ID: ${w.#Q}\\r\\n`:\"\",K=`GET ${A.pathname}${A.search} HTTP/1.1\\r\\nHost: bun\\r\\nContent-type: text/event-stream\\r\\nContent-length: 0\\r\\n${B}\\r\\n`,G=j.write(K);if(G!==K.length)w.#O=K.substring(G)}static#Z(j,A,w){for(;;){if(w>=A.length)return;let B=-1,K=A.indexOf(\"\\r\\n\",w);const G=K+2;if(K>0)if(j.#F===0){const J=parseInt(A.substring(w,K),16);if(J===0){j.#$=2,j.#A\?.end();return}B=G+J}else B=A.length;else{if(j.#j.length===0){j.#j+=A.substring(w);return}B=A.length}let M=A.substring(G,B);w=B+2;let Z=0,L=M.indexOf(\"\\n\\n\");if(L==-1){j.#j+=A.substring(G);return}if(j.#j.length)j.#j+=M,M=j.#j,j.#j=\"\";let X=!0;while(X){const J=M.substring(Z,L);let Y,O=\"\",Q,W=0,V=-1;for(;;){let z=J.indexOf(\"\\n\",W);if(z===-1){if(W>=J.length)break;z=J.length}const U=J.substring(W,z);if(U.startsWith(\"data:\"))if(O.length)O+=`\\n${U.substring(5).trim()}`;else O=U.substring(5).trim();else if(U.startsWith(\"event:\"))Y=U.substring(6).trim();else if(U.startsWith(\"id:\"))Q=U.substring(3).trim();else if(U.startsWith(\"retry:\")){if(V=parseInt(U.substring(6).trim(),10),@isNaN(V))V=-1}W=z+1}if(j.#Q=Q||\"\",V>=0)j.#X=V;if(O||Q||Y)j.dispatchEvent(new MessageEvent(Y||\"message\",{data:O||\"\",origin:j.#B.origin,source:j,lastEventId:Q}));if(M.length===L+2){X=!1;break}const H=M.indexOf(\"\\n\\n\",L+1);if(H===-1)break;Z=L,L=H}}}static#z={open(j){const A=j.data;if(A.#A=j,!A.#M)F.#Y(j,A.#B)},handshake(j,A,w){const B=j.data;if(A)F.#Y(j,B.#B);else B.#$=2,B.dispatchEvent(new ErrorEvent(\"error\",{error:w})),j.end()},data(j,A){const w=j.data;switch(w.#$){case 0:{let B=A.toString();const K=B.indexOf(\"\\r\\n\\r\\n\");if(K===-1){w.#j+=B;return}if(w.#j.length)w.#j+=B,B=w.#j,w.#j=\"\";const G=B.substring(0,K),M=G.indexOf(\"\\r\\n\");if(M===-1){w.#$=2,w.dispatchEvent(new ErrorEvent(\"error\",{error:new Error(\"Invalid HTTP request\")})),j.end();return}const Z=G.substring(0,M);if(Z!==\"HTTP/1.1 200 OK\"){w.#$=2,w.dispatchEvent(new ErrorEvent(\"error\",{error:new Error(Z)})),j.end();return}let L=M+1,X=!1,J=-1;for(;;){let O=G.indexOf(\"\\r\\n\",L);if(O===-1){if(L>=G.length){if(!X)w.#$=2,w.dispatchEvent(new ErrorEvent(\"error\",{error:new Error(`EventSource's response has no MIME type and \"text/event-stream\" is required. Aborting the connection.`)})),j.end();return}O=G.length}const Q=G.substring(L+1,O),W=Q.indexOf(\":\"),V=Q.substring(0,W),H=V.localeCompare(\"content-type\",@undefined,{sensitivity:\"accent\"})===0;if(L=O+1,H)if(Q.endsWith(\" text/event-stream\"))X=!0;else{w.#$=2,w.dispatchEvent(new ErrorEvent(\"error\",{error:new Error(`EventSource's response has a MIME type that is not \"text/event-stream\". Aborting the connection.`)})),j.end();return}else if(V.localeCompare(\"content-length\",@undefined,{sensitivity:\"accent\"})===0){if(J=parseInt(Q.substring(W+1).trim(),10),@isNaN(J)||J<=0){w.dispatchEvent(new ErrorEvent(\"error\",{error:new Error(`EventSource's Content-Length is invalid. Aborting the connection.`)})),j.end();return}if(X)break}else if(V.localeCompare(\"transfer-encoding\",@undefined,{sensitivity:\"accent\"})===0){if(Q.substring(W+1).trim()!==\"chunked\"){w.dispatchEvent(new ErrorEvent(\"error\",{error:new Error(`EventSource's Transfer-Encoding is invalid. Aborting the connection.`)})),j.end();return}if(J=0,X)break}}w.#F=J,w.#$=1,w.dispatchEvent(new Event(\"open\"));const Y=B.substring(K+4);if(F.#Z(w,Y,0),w.#F>0){if(w.#G+=Y.length,w.#G>=w.#F)w.#$=2,j.end()}return}case 1:if(F.#Z(w,A.toString(),2),w.#F>0){if(w.#G+=A.byteLength,w.#G>=w.#F)w.#$=2,j.end()}return;default:break}},drain(j){const A=j.data;if(A.#$===0){const w=A.#j;if(w.length){const B=j.write(w);if(B!==w.length)j.data.#O=w.substring(B);else j.data.#O=\"\"}}},close:F.#W,end(j){F.#W(j).dispatchEvent(new ErrorEvent(\"error\",{error:new Error(\"Connection closed by server\")}))},timeout(j){F.#W(j).dispatchEvent(new ErrorEvent(\"error\",{error:new Error(\"Timeout\")}))},binaryType:\"buffer\"};static#W(j){const A=j.data;if(A.#A=null,A.#G=0,A.#$=2,A.#U){if(A.#w)clearTimeout(A.#w);A.#w=setTimeout(F.#V,A.#X,A)}return A}constructor(j,A=@undefined){super();const w=new URL(j);this.#M=w.protocol===\"https:\",this.#B=w,this.#$=2,process.nextTick(F.#V,this)}ref(){this.#w\?.ref(),this.#A\?.ref()}unref(){this.#w\?.unref(),this.#A\?.unref()}#H(){if(this.#$!==2)return;const j=this.#B,A=this.#M;this.#$=0,@Bun.connect({data:this,socket:F.#z,hostname:j.hostname,port:parseInt(j.port||(A\?\"443\":\"80\"),10),tls:A\?{requestCert:!0,rejectUnauthorized:!1}:!1}).catch((w)=>{if(super.dispatchEvent(new ErrorEvent(\"error\",{error:w})),this.#U){if(this.#w)this.#w.unref\?.();this.#w=setTimeout(F.#V,1000,this)}})}get url(){return this.#B.href}get readyState(){return this.#$}close(){this.#U=!1,this.#$=2,this.#A\?.unref(),this.#A\?.end()}get onopen(){return this.#L}get onerror(){return this.#J}get onmessage(){return this.#K}set onopen(j){if(this.#L)super.removeEventListener(\"close\",this.#L);super.addEventListener(\"open\",j),this.#L=j}set onerror(j){if(this.#J)super.removeEventListener(\"error\",this.#J);super.addEventListener(\"error\",j),this.#J=j}set onmessage(j){if(this.#K)super.removeEventListener(\"message\",this.#K);super.addEventListener(\"message\",j),this.#K=j}}return Object.defineProperty(F.prototype,\"CONNECTING\",{enumerable:!0,value:0}),Object.defineProperty(F.prototype,\"OPEN\",{enumerable:!0,value:1}),Object.defineProperty(F.prototype,\"CLOSED\",{enumerable:!0,value:2}),F[Symbol.for(\"CommonJS\")]=0,F})\n"; #define DEFINE_BUILTIN_GENERATOR(codeName, functionName, overriddenName, argumentCount) \ JSC::FunctionExecutable* codeName##Generator(JSC::VM& vm) \ diff --git a/test/js/node/process/process.test.js b/test/js/node/process/process.test.js index 51825b2b4..890f5032e 100644 --- a/test/js/node/process/process.test.js +++ b/test/js/node/process/process.test.js @@ -401,6 +401,33 @@ describe("signal", () => { expect(await child.exited).toBe(0); expect(await new Response(child.stdout).text()).toBe("PASS\n"); }); + + it("process.kill(2) works", async () => { + const child = Bun.spawn({ + cmd: ["bash", "-c", "sleep 1000000"], + stdout: "pipe", + }); + const prom = child.exited; + process.kill(child.pid, "SIGTERM"); + await prom; + expect(child.signalCode).toBe("SIGTERM"); + }); + + it("process._kill(2) works", async () => { + const child = Bun.spawn({ + cmd: ["bash", "-c", "sleep 1000000"], + stdout: "pipe", + }); + const prom = child.exited; + process.kill(child.pid, 9); + await prom; + expect(child.signalCode).toBe("SIGKILL"); + }); + + it("process.kill(2) throws on invalid input", async () => { + expect(() => process.kill(0, "SIGPOOP")).toThrow(); + expect(() => process.kill(0, 456)).toThrow(); + }); }); const undefinedStubs = [ -- cgit v1.2.3