diff --git a/CMakeLists.txt b/CMakeLists.txt index d179dbf0d6..0dee4375cb 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1001,6 +1001,8 @@ if(CMAKE_BUILD_TYPE STREQUAL "Debug") -Werror=return-type -Werror=return-stack-address -Werror=implicit-function-declaration + -Werror=uninitialized + -Werror ) else() target_compile_options(${bun} PUBLIC /Od /Z7) @@ -1019,6 +1021,8 @@ elseif(CMAKE_BUILD_TYPE STREQUAL "Release") -Werror=return-type -Werror=return-stack-address -Werror=implicit-function-declaration + -Werror=uninitialized + -Werror ) else() set(LTO_LINK_FLAG "") diff --git a/packages/bun-usockets/src/crypto/openssl.c b/packages/bun-usockets/src/crypto/openssl.c index 9b3c822b49..2e9f8111e7 100644 --- a/packages/bun-usockets/src/crypto/openssl.c +++ b/packages/bun-usockets/src/crypto/openssl.c @@ -806,18 +806,14 @@ int add_ca_cert_to_ctx_store(SSL_CTX *ctx, const char *content, X509_STORE *store) { X509 *x = NULL; - BIO *in; - ERR_clear_error(); // clear error stack for SSL_CTX_use_certificate() - - in = BIO_new_mem_buf(content, strlen(content)); + int count = 0; + BIO *in = BIO_new_mem_buf(content, strlen(content)); if (in == NULL) { OPENSSL_PUT_ERROR(SSL, ERR_R_BUF_LIB); goto end; } - int count = 0; - while ((x = PEM_read_bio_X509(in, NULL, SSL_CTX_get_default_passwd_cb(ctx), SSL_CTX_get_default_passwd_cb_userdata(ctx)))) { diff --git a/src/bun.js/bindings/BunDebugger.cpp b/src/bun.js/bindings/BunDebugger.cpp index 42c3058a13..b5a7c480d0 100644 --- a/src/bun.js/bindings/BunDebugger.cpp +++ b/src/bun.js/bindings/BunDebugger.cpp @@ -542,7 +542,6 @@ enum class AsyncCallTypeUint8 : uint8_t { static Inspector::InspectorDebuggerAgent::AsyncCallType getCallType(AsyncCallTypeUint8 callType) { - Inspector::InspectorDebuggerAgent::AsyncCallType type; switch (callType) { case AsyncCallTypeUint8::DOMTimer: return Inspector::InspectorDebuggerAgent::AsyncCallType::DOMTimer; diff --git a/src/bun.js/bindings/BunInjectedScriptHost.cpp b/src/bun.js/bindings/BunInjectedScriptHost.cpp index d689d42371..f36e4a3e42 100644 --- a/src/bun.js/bindings/BunInjectedScriptHost.cpp +++ b/src/bun.js/bindings/BunInjectedScriptHost.cpp @@ -111,34 +111,6 @@ static JSValue constructDataProperties(VM& vm, JSGlobalObject* exec, JSArray* ar RELEASE_AND_RETURN(scope, array); } -static JSValue constructDataPropertiesSlow(VM& vm, JSGlobalObject* exec, JSArray* array, JSValue value) -{ - auto scope = DECLARE_THROW_SCOPE(vm); - - if (!value.isObject()) - return value; - - auto* object = asObject(value); - PropertyNameArray propertyNames(vm, PropertyNameMode::Strings, PrivateSymbolMode::Exclude); - object->getPropertyNames(exec, propertyNames, DontEnumPropertiesMode::Exclude); - RETURN_IF_EXCEPTION(scope, {}); - unsigned i = 0; - auto catcher = DECLARE_CATCH_SCOPE(vm); - - for (auto& propertyName : propertyNames) { - auto propertyValue = object->get(exec, propertyName); - if (catcher.exception()) { - catcher.clearException(); - propertyValue = jsUndefined(); - } - - array->putDirectIndex(exec, i++, constructInternalProperty(vm, exec, propertyName, propertyValue)); - RETURN_IF_EXCEPTION(scope, {}); - } - - RELEASE_AND_RETURN(scope, array); -} - JSValue BunInjectedScriptHost::getInternalProperties(VM& vm, JSGlobalObject* exec, JSC::JSValue value) { auto scope = DECLARE_THROW_SCOPE(vm); @@ -167,8 +139,6 @@ JSValue BunInjectedScriptHost::getInternalProperties(VM& vm, JSGlobalObject* exe if (type == JSDOMWrapperType) { if (auto* headers = jsDynamicCast(value)) { auto* array = constructEmptyArray(exec, nullptr); - unsigned index = 0; - // array->putDirectIndex(exec, index++, constructInternalProperty(vm, exec, "#inspect"_s, WebCore::getInternalProperties(vm, exec, headers))); constructDataProperties(vm, exec, array, WebCore::getInternalProperties(vm, exec, headers)); RETURN_IF_EXCEPTION(scope, {}); return array; @@ -176,17 +146,13 @@ JSValue BunInjectedScriptHost::getInternalProperties(VM& vm, JSGlobalObject* exe if (auto* params = jsDynamicCast(value)) { auto* array = constructEmptyArray(exec, nullptr); - unsigned index = 0; - // array->putDirectIndex(exec, index++, constructInternalProperty(vm, exec, "#inspect"_s, WebCore::getInternalProperties(vm, exec, params))); constructDataProperties(vm, exec, array, WebCore::getInternalProperties(vm, exec, params)); RETURN_IF_EXCEPTION(scope, {}); return array; } if (auto* formData = jsDynamicCast(value)) { - unsigned index = 0; auto* array = constructEmptyArray(exec, nullptr); - // array->putDirectIndex(exec, index++, constructInternalProperty(vm, exec, "#inspect"_s, WebCore::getInternalProperties(vm, exec, formData))); constructDataProperties(vm, exec, array, WebCore::getInternalProperties(vm, exec, formData)); RETURN_IF_EXCEPTION(scope, {}); return array; diff --git a/src/bun.js/bindings/BunInspector.cpp b/src/bun.js/bindings/BunInspector.cpp index a222e7b63b..521ab36dc0 100644 --- a/src/bun.js/bindings/BunInspector.cpp +++ b/src/bun.js/bindings/BunInspector.cpp @@ -71,7 +71,6 @@ public: Inspector::JSGlobalObjectDebugger* debugger = reinterpret_cast(this->globalObject->debugger()); if (debugger) { debugger->runWhilePausedCallback = [](JSC::JSGlobalObject& globalObject, bool& done) -> void { - Inspector::JSGlobalObjectDebugger* debugger = reinterpret_cast(globalObject.debugger()); Bun__tickWhilePaused(&done); }; } diff --git a/src/bun.js/bindings/BunObject.cpp b/src/bun.js/bindings/BunObject.cpp index 5b18b5b772..7f87a1549d 100644 --- a/src/bun.js/bindings/BunObject.cpp +++ b/src/bun.js/bindings/BunObject.cpp @@ -54,7 +54,6 @@ static inline JSC::EncodedJSValue flattenArrayOfBuffersIntoArrayBuffer(JSGlobalO { auto& vm = lexicalGlobalObject->vm(); - auto clientData = WebCore::clientData(vm); if (arrayValue.isUndefinedOrNull() || !arrayValue) { return JSC::JSValue::encode(JSC::JSArrayBuffer::create(vm, lexicalGlobalObject->arrayBufferStructure(), JSC::ArrayBuffer::create(static_cast(0), 1))); } @@ -333,7 +332,6 @@ static JSC_DECLARE_JIT_OPERATION_WITHOUT_WTF_INTERNAL(functionBunEscapeHTMLWitho JSC_DEFINE_HOST_FUNCTION(functionBunSleepThenCallback, (JSC::JSGlobalObject * globalObject, JSC::CallFrame* callFrame)) { - JSC::VM& vm = globalObject->vm(); JSPromise* promise = jsDynamicCast(callFrame->argument(0)); RELEASE_ASSERT(promise); diff --git a/src/bun.js/bindings/BunPlugin.cpp b/src/bun.js/bindings/BunPlugin.cpp index 7c89c5dd2d..42adf0d640 100644 --- a/src/bun.js/bindings/BunPlugin.cpp +++ b/src/bun.js/bindings/BunPlugin.cpp @@ -54,8 +54,6 @@ static JSC::EncodedJSValue jsFunctionAppendOnLoadPluginBody(JSC::JSGlobalObject* auto* filterObject = callframe->uncheckedArgument(0).toObject(globalObject); RETURN_IF_EXCEPTION(scope, encodedJSValue()); - auto clientData = WebCore::clientData(vm); - auto& builtinNames = clientData->builtinNames(); JSC::RegExpObject* filter = nullptr; if (JSValue filterValue = filterObject->getIfPropertyExists(globalObject, Identifier::fromString(vm, "filter"_s))) { if (filterValue.isCell() && filterValue.asCell()->inherits()) @@ -143,24 +141,8 @@ static EncodedJSValue jsFunctionAppendVirtualModulePluginBody(JSC::JSGlobalObjec virtualModules->set(moduleId, JSC::Strong { vm, jsCast(functionValue) }); - JSMap* esmRegistry; - - if (auto loaderValue = global->getIfPropertyExists(global, JSC::Identifier::fromString(vm, "Loader"_s))) { - if (auto registryValue = loaderValue.getObject()->getIfPropertyExists(global, JSC::Identifier::fromString(vm, "registry"_s))) { - esmRegistry = jsCast(registryValue); - } - } - global->requireMap()->remove(globalObject, moduleIdValue); - if (esmRegistry) - esmRegistry->remove(globalObject, moduleIdValue); - - // bool hasBeenRequired = global->requireMap()->has(globalObject, moduleIdValue); - // bool hasBeenImported = esmRegistry && esmRegistry->has(globalObject, moduleIdValue); - // if (hasBeenRequired || hasBeenImported) { - // // callAndReplaceModule(global, moduleIdValue, functionValue, global->requireMap(), esmRegistry, hasBeenRequired, hasBeenImported); - // // RETURN_IF_EXCEPTION(scope, encodedJSValue()); - // } + global->esmRegistryMap()->remove(globalObject, moduleIdValue); return JSValue::encode(jsUndefined()); } @@ -177,8 +159,6 @@ static JSC::EncodedJSValue jsFunctionAppendOnResolvePluginBody(JSC::JSGlobalObje auto* filterObject = callframe->uncheckedArgument(0).toObject(globalObject); RETURN_IF_EXCEPTION(scope, encodedJSValue()); - auto clientData = WebCore::clientData(vm); - auto& builtinNames = clientData->builtinNames(); JSC::RegExpObject* filter = nullptr; if (JSValue filterValue = filterObject->getIfPropertyExists(globalObject, Identifier::fromString(vm, "filter"_s))) { if (filterValue.isCell() && filterValue.asCell()->inherits()) @@ -287,7 +267,6 @@ extern "C" JSC::EncodedJSValue jsFunctionBunPluginClear(JSC::JSGlobalObject* glo extern "C" JSC::EncodedJSValue setupBunPlugin(JSC::JSGlobalObject* globalObject, JSC::CallFrame* callframe, BunPluginTarget target) { JSC::VM& vm = globalObject->vm(); - auto clientData = WebCore::clientData(vm); auto throwScope = DECLARE_THROW_SCOPE(vm); if (callframe->argumentCount() < 1) { JSC::throwTypeError(globalObject, throwScope, "plugin needs at least one argument (an object)"_s); @@ -322,7 +301,6 @@ extern "C" JSC::EncodedJSValue setupBunPlugin(JSC::JSGlobalObject* globalObject, } } - JSFunction* setupFunction = jsCast(setupFunctionValue); JSObject* builderObject = JSC::constructEmptyObject(globalObject, globalObject->objectPrototype(), 4); builderObject->putDirect(vm, Identifier::fromString(vm, "target"_s), jsString(vm, String("bun"_s)), 0); @@ -373,7 +351,6 @@ extern "C" JSC::EncodedJSValue setupBunPlugin(JSC::JSGlobalObject* globalObject, extern "C" JSC::EncodedJSValue jsFunctionBunPlugin(JSC::JSGlobalObject* globalObject, JSC::CallFrame* callframe) { - Zig::GlobalObject* global = reinterpret_cast(globalObject); return setupBunPlugin(globalObject, callframe, BunPluginTargetBun); } @@ -740,10 +717,9 @@ EncodedJSValue BunPlugin::OnLoad::run(JSC::JSGlobalObject* globalObject, BunStri JSC::VM& vm = globalObject->vm(); JSC::JSObject* paramsObject = JSC::constructEmptyObject(globalObject, globalObject->objectPrototype(), 1); - auto clientData = WebCore::clientData(vm); - auto& builtinNames = clientData->builtinNames(); + const auto& builtinNames = WebCore::builtinNames(vm); paramsObject->putDirect( - vm, clientData->builtinNames().pathPublicName(), + vm, builtinNames.pathPublicName(), jsString(vm, pathString)); arguments.append(paramsObject); @@ -827,13 +803,12 @@ EncodedJSValue BunPlugin::OnResolve::run(JSC::JSGlobalObject* globalObject, BunS JSC::VM& vm = globalObject->vm(); JSC::JSObject* paramsObject = JSC::constructEmptyObject(globalObject, globalObject->objectPrototype(), 2); - auto clientData = WebCore::clientData(vm); - auto& builtinNames = clientData->builtinNames(); + const auto& builtinNames = WebCore::builtinNames(vm); paramsObject->putDirect( - vm, clientData->builtinNames().pathPublicName(), + vm, builtinNames.pathPublicName(), Bun::toJS(globalObject, *path)); paramsObject->putDirect( - vm, clientData->builtinNames().importerPublicName(), + vm, builtinNames.importerPublicName(), Bun::toJS(globalObject, *importer)); arguments.append(paramsObject); diff --git a/src/bun.js/bindings/BunProcess.cpp b/src/bun.js/bindings/BunProcess.cpp index 4f35a4df58..78c9b27c7f 100644 --- a/src/bun.js/bindings/BunProcess.cpp +++ b/src/bun.js/bindings/BunProcess.cpp @@ -702,8 +702,6 @@ void signalHandler(uv_signal_t* signal, int signalNumber) if (UNLIKELY(signalNumberToNameMap->find(signalNumber) == signalNumberToNameMap->end())) return; - SignalHandleValue signal_handle = signalToContextIdsMap->get(signalNumber); - auto* context = ScriptExecutionContext::getMainThreadScriptExecutionContext(); if (UNLIKELY(!context)) return; @@ -839,7 +837,6 @@ static void onDidChangeListeners(EventEmitter& eventEmitter, const Identifier& e #else if (signalNumber != SIGKILL) { // windows has no SIGSTOP #endif - uint32_t contextId = eventEmitter.scriptExecutionContext()->identifier(); if (isAdded) { if (!signalToContextIdsMap->contains(signalNumber)) { @@ -875,10 +872,11 @@ static void onDidChangeListeners(EventEmitter& eventEmitter, const Identifier& e } } else { if (signalToContextIdsMap->find(signalNumber) != signalToContextIdsMap->end()) { - SignalHandleValue signal_handle = signalToContextIdsMap->get(signalNumber); + #if !OS(WINDOWS) signal(signalNumber, SIG_DFL); #else + SignalHandleValue signal_handle = signalToContextIdsMap->get(signalNumber); Bun__UVSignalHandle__close(signal_handle.handle); #endif signalToContextIdsMap->remove(signalNumber); @@ -1257,8 +1255,6 @@ static JSValue constructReportObjectComplete(VM& vm, Zig::GlobalObject* globalOb auto constructUserLimits = [&]() -> JSValue { JSC::JSObject* userLimits = JSC::constructEmptyObject(globalObject, globalObject->objectPrototype(), 11); - rusage usage; - static constexpr int resourceLimits[] = { RLIMIT_CORE, RLIMIT_DATA, @@ -1657,7 +1653,6 @@ static JSValue constructStdioWriteStream(JSC::JSGlobalObject* globalObject, int JSC::MarkedArgumentBuffer args; args.append(JSC::jsNumber(fd)); - auto clientData = WebCore::clientData(vm); JSC::CallData callData = JSC::getCallData(getStdioWriteStream); NakedPtr returnedException = nullptr; @@ -1696,12 +1691,10 @@ 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)); - auto clientData = WebCore::clientData(vm); JSC::CallData callData = JSC::getCallData(getStdioWriteStream); NakedPtr returnedException = nullptr; diff --git a/src/bun.js/bindings/CallSite.cpp b/src/bun.js/bindings/CallSite.cpp index 04e45b301e..d79f7914dd 100644 --- a/src/bun.js/bindings/CallSite.cpp +++ b/src/bun.js/bindings/CallSite.cpp @@ -36,8 +36,6 @@ void CallSite::finishCreation(VM& vm, JSC::JSGlobalObject* globalObject, JSCStac } } - JSC::JSObject* calleeObject = JSC::jsCast(stackFrame.callee()); - // Initialize "this" and "function" (and set the "IsStrict" flag if needed) JSC::CallFrame* callFrame = stackFrame.callFrame(); if (isStrictFrame) { @@ -88,8 +86,6 @@ void CallSite::visitChildrenImpl(JSCell* cell, Visitor& visitor) void CallSite::formatAsString(JSC::VM& vm, JSC::JSGlobalObject* globalObject, WTF::StringBuilder& sb) { - JSString* myTypeName = jsTypeStringForValue(globalObject, thisValue()); - JSString* myFunction = functionName().toString(globalObject); JSString* myFunctionName = functionName().toString(globalObject); JSString* mySourceURL = sourceURL().toString(globalObject); diff --git a/src/bun.js/bindings/CommonJSModuleRecord.cpp b/src/bun.js/bindings/CommonJSModuleRecord.cpp index 1f83c0eecd..56501f14e7 100644 --- a/src/bun.js/bindings/CommonJSModuleRecord.cpp +++ b/src/bun.js/bindings/CommonJSModuleRecord.cpp @@ -631,7 +631,6 @@ JSCommonJSModule* JSCommonJSModule::create( JSC_DEFINE_HOST_FUNCTION(jsFunctionCreateCommonJSModule, (JSGlobalObject * globalObject, CallFrame* callframe)) { - auto& vm = globalObject->vm(); RELEASE_ASSERT(callframe->argumentCount() == 4); auto id = callframe->uncheckedArgument(0).toWTFString(globalObject); @@ -873,7 +872,6 @@ void JSCommonJSModule::toSyntheticSource(JSC::JSGlobalObject* globalObject, { auto result = this->exportsObject(); - auto& vm = globalObject->vm(); populateESMExports(globalObject, result, exportNames, exportValues, this->ignoreESModuleAnnotation); } diff --git a/src/bun.js/bindings/ImportMetaObject.cpp b/src/bun.js/bindings/ImportMetaObject.cpp index cca8678793..f254acb611 100644 --- a/src/bun.js/bindings/ImportMetaObject.cpp +++ b/src/bun.js/bindings/ImportMetaObject.cpp @@ -1,4 +1,3 @@ -#include "JavaScriptCore/JSCJSValue.h" #include "root.h" #include "headers.h" @@ -66,7 +65,6 @@ static JSC::EncodedJSValue functionRequireResolve(JSC::JSGlobalObject* globalObj return JSC::JSValue::encode(JSC::JSValue {}); } default: { - JSValue thisValue = callFrame->thisValue(); JSC::JSValue moduleName = callFrame->argument(0); auto doIt = [&](const WTF::String& fromStr) -> JSC::EncodedJSValue { @@ -523,9 +521,6 @@ JSC::Structure* ImportMetaObject::createStructure(JSC::VM& vm, JSC::JSGlobalObje globalObject, ImportMetaObjectPrototype::createStructure(vm, globalObject)); - auto clientData = WebCore::clientData(vm); - auto& builtinNames = clientData->builtinNames(); - return Structure::create(vm, globalObject, prototype, TypeInfo(ObjectType, StructureFlags), ImportMetaObject::info()); } @@ -628,7 +623,6 @@ DEFINE_VISIT_CHILDREN(ImportMetaObject); void ImportMetaObject::analyzeHeap(JSCell* cell, HeapAnalyzer& analyzer) { - auto* thisObject = jsCast(cell); // if (void* wrapped = thisObject->wrapped()) { // if (thisObject->scriptExecutionContext()) // analyzer.setLabelForCell(cell, "url " + thisObject->scriptExecutionContext()->url().string()); diff --git a/src/bun.js/bindings/JSBuffer.cpp b/src/bun.js/bindings/JSBuffer.cpp index f5929b6452..58e449eaa8 100644 --- a/src/bun.js/bindings/JSBuffer.cpp +++ b/src/bun.js/bindings/JSBuffer.cpp @@ -70,6 +70,8 @@ using namespace WebCore; JSC_DECLARE_HOST_FUNCTION(constructJSBuffer); +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wunused-function" static JSC_DECLARE_HOST_FUNCTION(jsBufferConstructorFunction_alloc); static JSC_DECLARE_HOST_FUNCTION(jsBufferConstructorFunction_allocUnsafe); static JSC_DECLARE_HOST_FUNCTION(jsBufferConstructorFunction_allocUnsafeSlow); @@ -92,6 +94,7 @@ static JSC_DECLARE_HOST_FUNCTION(jsBufferPrototypeFunction_swap32); static JSC_DECLARE_HOST_FUNCTION(jsBufferPrototypeFunction_swap64); static JSC_DECLARE_HOST_FUNCTION(jsBufferPrototypeFunction_toString); static JSC_DECLARE_HOST_FUNCTION(jsBufferPrototypeFunction_write); +#pragma clang diagnostic pop static JSUint8Array* allocBuffer(JSC::JSGlobalObject* lexicalGlobalObject, size_t byteLength) { @@ -361,12 +364,6 @@ static inline JSC::EncodedJSValue constructBufferEmpty(JSGlobalObject* lexicalGl return JSBuffer__bufferFromLength(lexicalGlobalObject, 0); } -// new Buffer(size) -static inline JSC::EncodedJSValue constructBufferFromLength(JSGlobalObject* lexicalGlobalObject, CallFrame* callFrame) -{ - return jsBufferConstructorFunction_allocUnsafeBody(lexicalGlobalObject, callFrame); -} - static JSC::EncodedJSValue constructFromEncoding(JSGlobalObject* lexicalGlobalObject, JSString* str, WebCore::BufferEncodingType encoding) { auto& vm = JSC::getVM(lexicalGlobalObject); @@ -392,6 +389,7 @@ static JSC::EncodedJSValue constructFromEncoding(JSGlobalObject* lexicalGlobalOb break; } default: { + result = 0; break; } } @@ -414,6 +412,7 @@ static JSC::EncodedJSValue constructFromEncoding(JSGlobalObject* lexicalGlobalOb break; } default: { + result = 0; break; } } @@ -435,7 +434,6 @@ static JSC::EncodedJSValue constructFromEncoding(JSGlobalObject* lexicalGlobalOb static inline JSC::EncodedJSValue constructBufferFromStringAndEncoding(JSC::JSGlobalObject* lexicalGlobalObject, JSValue arg0, JSValue arg1) { auto& vm = JSC::getVM(lexicalGlobalObject); - uint32_t offset = 0; WebCore::BufferEncodingType encoding = WebCore::BufferEncodingType::utf8; auto scope = DECLARE_THROW_SCOPE(vm); @@ -645,7 +643,6 @@ static inline JSC::EncodedJSValue jsBufferConstructorFunction_byteLengthBody(JSC { auto& vm = JSC::getVM(lexicalGlobalObject); - uint32_t offset = 0; WebCore::BufferEncodingType encoding = WebCore::BufferEncodingType::utf8; auto scope = DECLARE_THROW_SCOPE(vm); @@ -870,7 +867,6 @@ static inline JSC::EncodedJSValue jsBufferConstructorFunction_concatBody(JSC::JS static inline JSC::EncodedJSValue jsBufferConstructorFunction_isEncodingBody(JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame) { - auto& vm = JSC::getVM(lexicalGlobalObject); auto* encoding_ = callFrame->argument(0).toStringOrNull(lexicalGlobalObject); if (!encoding_) return JSValue::encode(jsBoolean(false)); @@ -2021,7 +2017,6 @@ void JSBufferPrototype::finishCreation(VM& vm, JSC::JSGlobalObject* globalThis) { Base::finishCreation(vm); JSC_TO_STRING_TAG_WITHOUT_TRANSITION(); - auto clientData = WebCore::clientData(vm); reifyStaticProperties(vm, JSBuffer::info(), JSBufferPrototypeTableValues, *this); } @@ -2033,20 +2028,6 @@ const ClassInfo JSBufferPrototype::s_info = { &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSBufferPrototype) }; -static const JSC::DOMJIT::Signature DOMJITSignaturejsBufferConstructorAlloc(jsBufferConstructorAllocWithoutTypeChecks, - JSBufferConstructor::info(), - JSC::DOMJIT::Effect::forWriteKinds(JSC::DFG::AbstractHeapKind::Heap), - JSC::SpecUint8Array, JSC::SpecInt32Only); - -static const JSC::DOMJIT::Signature DOMJITSignaturejsBufferConstructorAllocUnsafe(jsBufferConstructorAllocUnsafeWithoutTypeChecks, - JSBufferConstructor::info(), - JSC::DOMJIT::Effect::forWriteKinds(JSC::DFG::AbstractHeapKind::Heap), - JSC::SpecUint8Array, JSC::SpecInt32Only); -static const JSC::DOMJIT::Signature DOMJITSignaturejsBufferConstructorAllocUnsafeSlow(jsBufferConstructorAllocUnsafeSlowWithoutTypeChecks, - JSBufferConstructor::info(), - JSC::DOMJIT::Effect::forWriteKinds(JSC::DFG::AbstractHeapKind::Heap), - JSC::SpecUint8Array, JSC::SpecInt32Only); - /* Source for JSBuffer.lut.h @begin jsBufferConstructorTable alloc jsBufferConstructorFunction_alloc Constructable|Function 1 diff --git a/src/bun.js/bindings/JSBufferList.cpp b/src/bun.js/bindings/JSBufferList.cpp index 342685944a..3ac2077c9d 100644 --- a/src/bun.js/bindings/JSBufferList.cpp +++ b/src/bun.js/bindings/JSBufferList.cpp @@ -15,7 +15,7 @@ static JSC_DECLARE_CUSTOM_GETTER(JSBufferList_getLength); static JSC_DEFINE_CUSTOM_GETTER(JSBufferList_getLength, (JSC::JSGlobalObject * globalObject, JSC::EncodedJSValue thisValue, JSC::PropertyName)) { JSC::VM& vm = globalObject->vm(); - auto scope = DECLARE_THROW_SCOPE(globalObject->vm()); + auto scope = DECLARE_THROW_SCOPE(vm); JSBufferList* bufferList = JSC::jsDynamicCast(JSValue::decode(thisValue)); if (!bufferList) diff --git a/src/bun.js/bindings/JSReadableState.cpp b/src/bun.js/bindings/JSReadableState.cpp index 22b1ec3573..f3fba3cf96 100644 --- a/src/bun.js/bindings/JSReadableState.cpp +++ b/src/bun.js/bindings/JSReadableState.cpp @@ -395,7 +395,6 @@ JSC::EncodedJSValue JSReadableStateConstructor::construct(JSC::JSGlobalObject* l return JSValue::encode(jsUndefined()); } JSValue optionsVal = callFrame->uncheckedArgument(0); - JSValue streamVal = callFrame->uncheckedArgument(1); JSValue isDuplexVal = callFrame->uncheckedArgument(2); bool isDuplex; diff --git a/src/bun.js/bindings/KeyObject.cpp b/src/bun.js/bindings/KeyObject.cpp index f90c17c7d3..cd162be2dc 100644 --- a/src/bun.js/bindings/KeyObject.cpp +++ b/src/bun.js/bindings/KeyObject.cpp @@ -95,20 +95,21 @@ static bool KeyObject__IsASN1Sequence(const unsigned char* data, size_t size, return true; } -static bool KeyObject__IsRSAPrivateKey(const unsigned char* data, size_t size) -{ - // Both RSAPrivateKey and RSAPublicKey structures start with a SEQUENCE. - size_t offset, len; - if (!KeyObject__IsASN1Sequence(data, size, &offset, &len)) - return false; +// TODO: @cirospaciari - is this supposed to be unused? +// static bool KeyObject__IsRSAPrivateKey(const unsigned char* data, size_t size) +// { +// // Both RSAPrivateKey and RSAPublicKey structures start with a SEQUENCE. +// size_t offset, len; +// if (!KeyObject__IsASN1Sequence(data, size, &offset, &len)) +// return false; - // An RSAPrivateKey sequence always starts with a single-byte integer whose - // value is either 0 or 1, whereas an RSAPublicKey starts with the modulus - // (which is the product of two primes and therefore at least 4), so we can - // decide the type of the structure based on the first three bytes of the - // sequence. - return len >= 3 && data[offset] == 2 && data[offset + 1] == 1 && !(data[offset + 2] & 0xfe); -} +// // An RSAPrivateKey sequence always starts with a single-byte integer whose +// // value is either 0 or 1, whereas an RSAPublicKey starts with the modulus +// // (which is the product of two primes and therefore at least 4), so we can +// // decide the type of the structure based on the first three bytes of the +// // sequence. +// return len >= 3 && data[offset] == 2 && data[offset + 1] == 1 && !(data[offset + 2] & 0xfe); +// } static bool KeyObject__IsEncryptedPrivateKeyInfo(const unsigned char* data, size_t size) { @@ -824,7 +825,6 @@ static JSC::EncodedJSValue KeyObject__createPublicFromPrivate(JSC::JSGlobalObjec return KeyObject__createECFromPrivate(globalObject, pkey, curve, CryptoAlgorithmIdentifier::ECDSA); } else if (pKeyID == EVP_PKEY_ED25519 || pKeyID == EVP_PKEY_X25519) { size_t out_len = 0; - auto& vm = globalObject->vm(); if (!EVP_PKEY_get_raw_private_key(pkey, nullptr, &out_len)) { throwException(globalObject, scope, createTypeError(globalObject, "Invalid private key"_s)); return JSValue::encode(JSC::jsUndefined()); @@ -1375,7 +1375,6 @@ JSC::EncodedJSValue KeyObject__Sign(JSC::JSGlobalObject* globalObject, JSC::Call } auto vectorData = buffer.releaseReturnValue(); auto& wrapped = key->wrapped(); - auto key_type = wrapped.type(); auto id = wrapped.keyClass(); auto hash = WebCore::CryptoAlgorithmIdentifier::SHA_256; @@ -1593,7 +1592,6 @@ JSC::EncodedJSValue KeyObject__Verify(JSC::JSGlobalObject* globalObject, JSC::Ca auto signatureData = signatureBuffer.releaseReturnValue(); auto& wrapped = key->wrapped(); - auto key_type = wrapped.type(); auto id = wrapped.keyClass(); auto hash = WebCore::CryptoAlgorithmIdentifier::SHA_256; @@ -2622,7 +2620,8 @@ JSC::EncodedJSValue KeyObject__generateKeyPairSync(JSC::JSGlobalObject* lexicalG } } - auto saltLengthJS = options->getIfPropertyExists(lexicalGlobalObject, PropertyName(Identifier::fromString(vm, "hashAlgorithm"_s))); + // TODO: @cirospaciari is saltLength supposed to be used here? + // auto saltLengthJS = options->getIfPropertyExists(lexicalGlobalObject, PropertyName(Identifier::fromString(vm, "hashAlgorithm"_s))); auto failureCallback = [&]() { throwException(lexicalGlobalObject, scope, createTypeError(lexicalGlobalObject, "Failed to generate key pair"_s)); @@ -2850,7 +2849,6 @@ JSC::EncodedJSValue KeyObject__Equals(JSC::JSGlobalObject* lexicalGlobalObject, auto& wrapped = key->wrapped(); auto& wrapped2 = key2->wrapped(); auto key_type = wrapped.type(); - auto key_class = wrapped.keyClass(); if (key_type != wrapped2.type()) { return JSC::JSValue::encode(jsBoolean(false)); } diff --git a/src/bun.js/bindings/ModuleLoader.cpp b/src/bun.js/bindings/ModuleLoader.cpp index 2cce537af3..b1d4dfe6d0 100644 --- a/src/bun.js/bindings/ModuleLoader.cpp +++ b/src/bun.js/bindings/ModuleLoader.cpp @@ -814,17 +814,12 @@ extern "C" JSC::EncodedJSValue jsFunctionOnLoadObjectResultResolve(JSC::JSGlobal extern "C" JSC::EncodedJSValue jsFunctionOnLoadObjectResultReject(JSC::JSGlobalObject* globalObject, JSC::CallFrame* callFrame) { JSC::VM& vm = globalObject->vm(); - ErrorableResolvedSource res = {}; JSC::JSValue reason = callFrame->argument(0); PendingVirtualModuleResult* pendingModule = JSC::jsCast(callFrame->argument(1)); - JSC::JSValue specifierString = pendingModule->internalField(0).get(); - JSC::JSValue referrerString = pendingModule->internalField(1).get(); pendingModule->internalField(0).set(vm, pendingModule, JSC::jsUndefined()); pendingModule->internalField(1).set(vm, pendingModule, JSC::jsUndefined()); JSC::JSInternalPromise* promise = pendingModule->internalPromise(); - ZigString specifier = Zig::toZigString(specifierString, globalObject); - ZigString referrer = Zig::toZigString(referrerString, globalObject); pendingModule->internalField(2).set(vm, pendingModule, JSC::jsUndefined()); promise->reject(globalObject, reason); diff --git a/src/bun.js/bindings/NodeVMScript.cpp b/src/bun.js/bindings/NodeVMScript.cpp index 3f7097d96d..84428c2a3b 100644 --- a/src/bun.js/bindings/NodeVMScript.cpp +++ b/src/bun.js/bindings/NodeVMScript.cpp @@ -91,7 +91,6 @@ static EncodedJSValue constructScript(JSGlobalObject* globalObject, CallFrame* callFrame, JSValue newTarget = JSValue()) { VM& vm = globalObject->vm(); - JSValue callee = callFrame->jsCallee(); ArgList args(callFrame); JSValue sourceArg = args.at(0); String sourceString = sourceArg.isUndefined() ? emptyString() : sourceArg.toWTFString(globalObject); @@ -175,7 +174,6 @@ JSC_DEFINE_HOST_FUNCTION(scriptConstructorConstruct, (JSGlobalObject * globalObj JSC_DEFINE_CUSTOM_GETTER(scriptGetCachedDataRejected, (JSGlobalObject * globalObject, JSC::EncodedJSValue thisValue, PropertyName)) { - auto& vm = globalObject->vm(); return JSValue::encode(jsBoolean(true)); // TODO } JSC_DEFINE_HOST_FUNCTION(scriptCreateCachedData, (JSGlobalObject * globalObject, CallFrame* callFrame)) @@ -370,7 +368,8 @@ JSC_DEFINE_HOST_FUNCTION(scriptRunInNewContext, (JSGlobalObject * globalObject, auto& vm = globalObject->vm(); NodeVMScript* script = jsDynamicCast(callFrame->thisValue()); JSValue contextObjectValue = callFrame->argument(0); - JSValue optionsObjectValue = callFrame->argument(1); + // TODO: options + // JSValue optionsObjectValue = callFrame->argument(1); auto scope = DECLARE_THROW_SCOPE(vm); if (!script) { @@ -388,8 +387,8 @@ JSC_DEFINE_HOST_FUNCTION(scriptRunInNewContext, (JSGlobalObject * globalObject, } // we don't care about options for now - - bool didThrow = false; + // TODO: options + // bool didThrow = false; auto* zigGlobal = reinterpret_cast(globalObject); JSObject* context = asObject(contextObjectValue); diff --git a/src/bun.js/bindings/Path.cpp b/src/bun.js/bindings/Path.cpp index e2b50711c2..5db97f3584 100644 --- a/src/bun.js/bindings/Path.cpp +++ b/src/bun.js/bindings/Path.cpp @@ -191,8 +191,6 @@ static JSC::JSObject* createPath(JSGlobalObject* globalThis, bool isWindows) extern JSC__JSValue Bun__Path__create(JSC::JSGlobalObject* globalObject, bool isWindows) { - JSC::VM& vm = globalObject->vm(); - return JSC::JSValue::encode(JSC::JSValue(Zig::createPath( globalObject, isWindows))); } \ No newline at end of file diff --git a/src/bun.js/bindings/bindings.cpp b/src/bun.js/bindings/bindings.cpp index f56b406ecb..df030050d3 100644 --- a/src/bun.js/bindings/bindings.cpp +++ b/src/bun.js/bindings/bindings.cpp @@ -144,9 +144,15 @@ using namespace WebCore; typedef uint8_t ExpectFlags; // Note: keep this in sync with Expect.Flags implementation in zig (at expect.zig) -static const int FLAG_PROMISE_RESOLVES = (1 << 0); -static const int FLAG_PROMISE_REJECTS = (1 << 1); -static const int FLAG_NOT = (1 << 2); +// clang disable unused warning +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wunused-variable" + +static constexpr int FLAG_PROMISE_RESOLVES = (1 << 0); +static constexpr int FLAG_PROMISE_REJECTS = (1 << 1); +static constexpr int FLAG_NOT = (1 << 2); + +#pragma clang diagnostic pop extern "C" bool Expect_readFlagsAndProcessPromise(JSC__JSValue instanceValue, JSC__JSGlobalObject* globalObject, ExpectFlags* flags, JSC__JSValue* value); extern "C" bool ExpectCustomAsymmetricMatcher__execute(void* self, JSC__JSValue thisValue, JSC__JSGlobalObject* globalObject, JSC__JSValue leftValue); @@ -730,9 +736,6 @@ bool Bun__deepEquals(JSC__JSGlobalObject* globalObject, JSValue v1, JSValue v2, JSValue key1 = nextValueObject1->getIndex(globalObject, static_cast(0)); RETURN_IF_EXCEPTION(*scope, false); - JSValue value1 = nextValueObject1->getIndex(globalObject, static_cast(1)); - RETURN_IF_EXCEPTION(*scope, false); - bool found = false; IterationRecord iterationRecord2 = iteratorForIterable(globalObject, v2); @@ -756,9 +759,6 @@ bool Bun__deepEquals(JSC__JSGlobalObject* globalObject, JSValue v1, JSValue v2, JSValue key2 = nextValueObject2->getIndex(globalObject, static_cast(0)); RETURN_IF_EXCEPTION(*scope, false); - JSValue value2 = nextValueObject2->getIndex(globalObject, static_cast(1)); - RETURN_IF_EXCEPTION(*scope, false); - if (Bun__deepEquals(globalObject, key1, key2, gcBuffer, stack, scope, false)) { if (Bun__deepEquals(globalObject, nextValue1, nextValue2, gcBuffer, stack, scope, false)) { found = true; @@ -1358,7 +1358,6 @@ WebCore__FetchHeaders* WebCore__FetchHeaders__cast_(JSC__JSValue JSValue0, JSC__ WebCore__FetchHeaders* WebCore__FetchHeaders__createFromJS(JSC__JSGlobalObject* lexicalGlobalObject, JSC__JSValue argument0_) { - Zig::GlobalObject* globalObject = reinterpret_cast(lexicalGlobalObject); EnsureStillAliveScope argument0 = JSC::JSValue::decode(argument0_); auto throwScope = DECLARE_THROW_SCOPE(lexicalGlobalObject->vm()); @@ -1531,9 +1530,7 @@ WebCore::FetchHeaders* WebCore__FetchHeaders__createFromUWS(JSC__JSGlobalObject* for (const auto& header : req) { StringView nameView = StringView(reinterpret_cast(header.first.data()), header.first.length()); - size_t name_len = nameView.length(); LChar* data = nullptr; - auto value = String::createUninitialized(header.second.length(), data); memcpy(data, header.second.data(), header.second.length()); @@ -1766,7 +1763,7 @@ double JSC__JSValue__getLengthIfPropertyExistsInternal(JSC__JSValue value, JSC__ JSCell* cell = jsValue.asCell(); JSC::JSType type = cell->type(); - switch (type) { + switch (static_cast(type)) { case JSC::JSType::StringType: return static_cast(jsValue.toString(globalObject)->length()); case JSC::JSType::ArrayType: @@ -2328,8 +2325,8 @@ JSC__JSObject* JSC__JSString__toObject(JSC__JSString* arg0, JSC__JSGlobalObject* extern "C" JSC::JSInternalPromise* JSModuleLoader__import(JSC::JSGlobalObject* globalObject, const BunString* moduleNameStr) { auto& vm = globalObject->vm(); - auto scope = DECLARE_THROW_SCOPE(globalObject->vm()); - auto* promise = JSC::importModule(globalObject, JSC::Identifier::fromString(globalObject->vm(), moduleNameStr->toWTFString()), jsUndefined(), jsUndefined(), jsUndefined()); + auto scope = DECLARE_THROW_SCOPE(vm); + auto* promise = JSC::importModule(globalObject, JSC::Identifier::fromString(vm, moduleNameStr->toWTFString()), jsUndefined(), jsUndefined(), jsUndefined()); RETURN_IF_EXCEPTION(scope, nullptr); return promise; @@ -2510,7 +2507,6 @@ bool JSC__JSValue__hasOwnProperty(JSC__JSValue jsValue, JSC__JSGlobalObject* glo bool JSC__JSValue__asArrayBuffer_(JSC__JSValue JSValue0, JSC__JSGlobalObject* arg1, Bun__ArrayBuffer* arg2) { - JSC::VM& vm = arg1->vm(); JSC::JSValue value = JSC::JSValue::decode(JSValue0); if (UNLIKELY(!value) || !value.isCell()) { @@ -2590,7 +2586,6 @@ bool JSC__JSValue__asArrayBuffer_(JSC__JSValue JSValue0, JSC__JSGlobalObject* ar CPP_DECL JSC__JSValue JSC__JSValue__createEmptyArray(JSC__JSGlobalObject* arg0, size_t length) { - JSC::VM& vm = arg0->vm(); return JSC::JSValue::encode(JSC::constructEmptyArray(arg0, nullptr, length)); } CPP_DECL void JSC__JSValue__putIndex(JSC__JSValue JSValue0, JSC__JSGlobalObject* arg1, uint32_t arg2, JSC__JSValue JSValue3) @@ -2971,14 +2966,12 @@ void JSC__JSPromise__rejectOnNextTickWithHandled(JSC__JSPromise* promise, JSC__J RETURN_IF_EXCEPTION(scope, void()); } } -JSC__JSPromise* JSC__JSPromise__resolvedPromise(JSC__JSGlobalObject* arg0, JSC__JSValue JSValue1) +JSC__JSPromise* JSC__JSPromise__resolvedPromise(JSC__JSGlobalObject* globalObject, JSC__JSValue JSValue1) { - Zig::GlobalObject* global = reinterpret_cast(arg0); - JSC::JSPromise* promise = JSC::JSPromise::create(arg0->vm(), arg0->promiseStructure()); - promise->internalField(JSC::JSPromise::Field::Flags).set(arg0->vm(), promise, jsNumber(static_cast(JSC::JSPromise::Status::Fulfilled))); - promise->internalField(JSC::JSPromise::Field::ReactionsOrResult).set(arg0->vm(), promise, JSC::JSValue::decode(JSValue1)); - JSC::ensureStillAliveHere(promise); - JSC::ensureStillAliveHere(JSC::JSValue::decode(JSValue1)); + JSC::VM& vm = globalObject->vm(); + JSC::JSPromise* promise = JSC::JSPromise::create(vm, globalObject->promiseStructure()); + promise->internalField(JSC::JSPromise::Field::Flags).set(vm, promise, jsNumber(static_cast(JSC::JSPromise::Status::Fulfilled))); + promise->internalField(JSC::JSPromise::Field::ReactionsOrResult).set(vm, promise, JSC::JSValue::decode(JSValue1)); return promise; } @@ -3693,7 +3686,6 @@ void JSC__JSValue__getSymbolDescription(JSC__JSValue symbolValue_, JSC__JSGlobal return; JSC::Symbol* symbol = JSC::asSymbol(symbolValue); - JSC::VM& vm = arg1->vm(); WTF::String string = symbol->description(); *arg2 = Zig::toZigString(string); @@ -4277,7 +4269,6 @@ static void fromErrorInstance(ZigException* except, JSC::JSGlobalObject* global, WTF::String stack = stackValue.toWTFString(global); V8StackTraceIterator iterator(stack); - unsigned frameI = 0; const uint8_t frame_count = except->stack.frames_len; except->stack.frames_len = 0; @@ -4699,24 +4690,24 @@ void JSC__VM__throwError(JSC__VM* vm_, JSC__JSGlobalObject* arg1, JSC__JSValue v scope.throwException(arg1, exception); } -JSC__JSValue JSC__JSPromise__rejectedPromiseValue(JSC__JSGlobalObject* arg0, +JSC__JSValue JSC__JSPromise__rejectedPromiseValue(JSC__JSGlobalObject* globalObject, JSC__JSValue JSValue1) { - Zig::GlobalObject* global = reinterpret_cast(arg0); - JSC::JSPromise* promise = JSC::JSPromise::create(arg0->vm(), arg0->promiseStructure()); - promise->internalField(JSC::JSPromise::Field::Flags).set(arg0->vm(), promise, jsNumber(static_cast(JSC::JSPromise::Status::Rejected))); - promise->internalField(JSC::JSPromise::Field::ReactionsOrResult).set(arg0->vm(), promise, JSC::JSValue::decode(JSValue1)); + auto& vm = globalObject->vm(); + JSC::JSPromise* promise = JSC::JSPromise::create(vm, globalObject->promiseStructure()); + promise->internalField(JSC::JSPromise::Field::Flags).set(vm, promise, jsNumber(static_cast(JSC::JSPromise::Status::Rejected))); + promise->internalField(JSC::JSPromise::Field::ReactionsOrResult).set(vm, promise, JSC::JSValue::decode(JSValue1)); JSC::ensureStillAliveHere(promise); JSC::ensureStillAliveHere(JSC::JSValue::decode(JSValue1)); return JSC::JSValue::encode(promise); } -JSC__JSValue JSC__JSPromise__resolvedPromiseValue(JSC__JSGlobalObject* arg0, +JSC__JSValue JSC__JSPromise__resolvedPromiseValue(JSC__JSGlobalObject* globalObject, JSC__JSValue JSValue1) { - Zig::GlobalObject* global = reinterpret_cast(arg0); - JSC::JSPromise* promise = JSC::JSPromise::create(arg0->vm(), arg0->promiseStructure()); - promise->internalField(JSC::JSPromise::Field::Flags).set(arg0->vm(), promise, jsNumber(static_cast(JSC::JSPromise::Status::Fulfilled))); - promise->internalField(JSC::JSPromise::Field::ReactionsOrResult).set(arg0->vm(), promise, JSC::JSValue::decode(JSValue1)); + auto& vm = globalObject->vm(); + JSC::JSPromise* promise = JSC::JSPromise::create(vm, globalObject->promiseStructure()); + promise->internalField(JSC::JSPromise::Field::Flags).set(vm, promise, jsNumber(static_cast(JSC::JSPromise::Status::Fulfilled))); + promise->internalField(JSC::JSPromise::Field::ReactionsOrResult).set(vm, promise, JSC::JSValue::decode(JSValue1)); JSC::ensureStillAliveHere(promise); JSC::ensureStillAliveHere(JSC::JSValue::decode(JSValue1)); return JSC::JSValue::encode(promise); @@ -5193,7 +5184,6 @@ extern "C" size_t JSC__VM__externalMemorySize(JSC__VM* vm) extern "C" void JSC__JSGlobalObject__queueMicrotaskJob(JSC__JSGlobalObject* arg0, JSC__JSValue JSValue1, JSC__JSValue JSValue3, JSC__JSValue JSValue4) { Zig::GlobalObject* globalObject = reinterpret_cast(arg0); - JSC::VM& vm = globalObject->vm(); JSValue microtaskArgs[] = { JSValue::decode(JSValue1), globalObject->m_asyncContextData.get()->getInternalField(0), @@ -5392,7 +5382,6 @@ extern "C" void DOMFormData__toQueryString( CPP_DECL JSC__JSValue WebCore__DOMFormData__createFromURLQuery(JSC__JSGlobalObject* arg0, ZigString* arg1) { - JSC::VM& vm = arg0->vm(); Zig::GlobalObject* globalObject = reinterpret_cast(arg0); // don't need to copy the string because it internally does. auto formData = DOMFormData::create(globalObject->scriptExecutionContext(), toString(*arg1)); @@ -5401,7 +5390,6 @@ CPP_DECL JSC__JSValue WebCore__DOMFormData__createFromURLQuery(JSC__JSGlobalObje CPP_DECL JSC__JSValue WebCore__DOMFormData__create(JSC__JSGlobalObject* arg0) { - JSC::VM& vm = arg0->vm(); Zig::GlobalObject* globalObject = reinterpret_cast(arg0); auto formData = DOMFormData::create(globalObject->scriptExecutionContext()); return JSValue::encode(toJSNewlyCreated(arg0, globalObject, WTFMove(formData))); diff --git a/src/bun.js/bindings/helpers.h b/src/bun.js/bindings/helpers.h index 6ae8f746c4..cbdc6ba6b2 100644 --- a/src/bun.js/bindings/helpers.h +++ b/src/bun.js/bindings/helpers.h @@ -18,6 +18,9 @@ namespace Zig { #include "headers-handwritten.h" +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wunused-function" + template class Wrap { public: Wrap() {}; @@ -350,8 +353,6 @@ static const WTF::String toStringStatic(ZigString str) static JSC::JSValue getErrorInstance(const ZigString* str, JSC__JSGlobalObject* globalObject) { - JSC::VM& vm = globalObject->vm(); - WTF::String message = toStringCopy(*str); if (UNLIKELY(message.isNull() && str->len > 0)) { // pending exception while creating an error. @@ -366,8 +367,6 @@ static JSC::JSValue getErrorInstance(const ZigString* str, JSC__JSGlobalObject* static JSC::JSValue getTypeErrorInstance(const ZigString* str, JSC__JSGlobalObject* globalObject) { - JSC::VM& vm = globalObject->vm(); - JSC::JSObject* result = JSC::createTypeError(globalObject, toStringCopy(*str)); JSC::EnsureStillAliveScope ensureAlive(result); @@ -376,8 +375,6 @@ static JSC::JSValue getTypeErrorInstance(const ZigString* str, JSC__JSGlobalObje static JSC::JSValue getSyntaxErrorInstance(const ZigString* str, JSC__JSGlobalObject* globalObject) { - JSC::VM& vm = globalObject->vm(); - JSC::JSObject* result = JSC::createSyntaxError(globalObject, toStringCopy(*str)); JSC::EnsureStillAliveScope ensureAlive(result); @@ -386,8 +383,6 @@ static JSC::JSValue getSyntaxErrorInstance(const ZigString* str, JSC__JSGlobalOb static JSC::JSValue getRangeErrorInstance(const ZigString* str, JSC__JSGlobalObject* globalObject) { - JSC::VM& vm = globalObject->vm(); - JSC::JSObject* result = JSC::createRangeError(globalObject, toStringCopy(*str)); JSC::EnsureStillAliveScope ensureAlive(result); @@ -420,3 +415,5 @@ OutType* WebCoreCast(JSC__JSValue JSValue0) return reinterpret_cast(&jsdomURL->wrapped()); } + +#pragma clang diagnostic pop \ No newline at end of file diff --git a/src/bun.js/bindings/napi.cpp b/src/bun.js/bindings/napi.cpp index 05fe547a2a..2a46cc676f 100644 --- a/src/bun.js/bindings/napi.cpp +++ b/src/bun.js/bindings/napi.cpp @@ -186,8 +186,9 @@ extern "C" Zig::GlobalObject* Bun__getDefaultGlobal(); WTF_MAKE_ISO_ALLOCATED_IMPL(NapiRef); -static uint32_t getPropertyAttributes(napi_property_attributes attributes) +static uint32_t getPropertyAttributes(napi_property_attributes attributes_) { + const uint32_t attributes = static_cast(attributes_); uint32_t result = 0; if (!(attributes & napi_key_configurable)) { result |= JSC::PropertyAttribute::DontDelete; @@ -869,7 +870,6 @@ extern "C" napi_status napi_wrap(napi_env env, } auto* globalObject = toJS(env); - auto& vm = globalObject->vm(); NapiRef** refPtr = nullptr; if (auto* val = jsDynamicCast(value)) { @@ -889,8 +889,6 @@ extern "C" napi_status napi_wrap(napi_env env, return napi_invalid_arg; } - auto clientData = WebCore::clientData(vm); - auto* ref = new NapiRef(globalObject, 0); ref->weakValueRef.setObject(value.getObject(), weakValueHandleOwner(), ref); @@ -922,8 +920,6 @@ extern "C" napi_status napi_remove_wrap(napi_env env, napi_value js_object, return napi_object_expected; } - auto* globalObject = toJS(env); - auto& vm = globalObject->vm(); NapiRef** refPtr = nullptr; if (auto* val = jsDynamicCast(value)) { refPtr = &val->napiRef; @@ -961,7 +957,6 @@ extern "C" napi_status napi_unwrap(napi_env env, napi_value js_object, if (!value.isObject()) { return NAPI_OBJECT_EXPECTED; } - auto* globalObject = toJS(env); NapiRef* ref = nullptr; if (auto* val = jsDynamicCast(value)) { @@ -1014,7 +1009,6 @@ extern "C" napi_status napi_get_cb_info( { NAPI_PREMABLE - Zig::GlobalObject* globalObject = toJS(env); JSC::CallFrame* callFrame = reinterpret_cast(cbinfo); if (NAPICallFrame* frame = NAPICallFrame::get(callFrame).value_or(nullptr)) { @@ -1149,7 +1143,6 @@ extern "C" napi_status napi_create_reference(napi_env env, napi_value value, } Zig::GlobalObject* globalObject = toJS(env); - JSC::VM& vm = globalObject->vm(); auto* ref = new NapiRef(globalObject, initial_refcount); if (initial_refcount > 0) { @@ -1265,8 +1258,6 @@ extern "C" napi_status napi_is_detached_arraybuffer(napi_env env, bool* result) { NAPI_PREMABLE - Zig::GlobalObject* globalObject = toJS(env); - JSC::VM& vm = globalObject->vm(); JSC::JSArrayBuffer* jsArrayBuffer = JSC::jsDynamicCast(toJS(arraybuffer)); if (UNLIKELY(!jsArrayBuffer)) { @@ -1544,7 +1535,6 @@ extern "C" napi_status napi_get_global(napi_env env, napi_value* result) NAPI_PREMABLE Zig::GlobalObject* globalObject = toJS(env); - JSC::VM& vm = globalObject->vm(); *result = reinterpret_cast(globalObject->globalThis()); return napi_ok; } @@ -1555,7 +1545,6 @@ extern "C" napi_status napi_create_range_error(napi_env env, napi_value code, { NAPI_PREMABLE Zig::GlobalObject* globalObject = toJS(env); - JSC::VM& vm = globalObject->vm(); JSC::EncodedJSValue encodedCode = reinterpret_cast(code); JSC::JSValue codeValue = JSC::JSValue::decode(encodedCode); @@ -1564,6 +1553,9 @@ extern "C" napi_status napi_create_range_error(napi_env env, napi_value code, JSC::JSValue messageValue = JSC::JSValue::decode(encodedMessage); auto error = JSC::createRangeError(globalObject, messageValue.toWTFString(globalObject)); + if (codeValue) { + error->putDirect(globalObject->vm(), WebCore::builtinNames(globalObject->vm()).codePublicName(), codeValue, 0); + } *result = reinterpret_cast(error); return napi_ok; } @@ -1573,8 +1565,6 @@ extern "C" napi_status napi_get_new_target(napi_env env, napi_value* result) { NAPI_PREMABLE - Zig::GlobalObject* globalObject = toJS(env); - JSC::VM& vm = globalObject->vm(); // handle: // - if they call this function when it was originally a getter/setter call // - if they call this function without a result @@ -1661,14 +1651,14 @@ JSC_DEFINE_HOST_FUNCTION(NapiClass_ConstructorFunction, size_t count = callFrame->argumentCount(); MarkedArgumentBufferWithSize<12> args; - size_t argc = callFrame->argumentCount() + 1; + size_t argc = count + 1; args.fill(vm, argc, [&](auto* slot) { memcpy(slot, ADDRESS_OF_THIS_VALUE_IN_CALLFRAME(callFrame), sizeof(JSC::JSValue) * argc); }); NAPICallFrame frame(JSC::ArgList(args), nullptr); frame.newTarget = newTarget; - auto result = napi->constructor()(globalObject, reinterpret_cast(NAPICallFrame::toNapiCallbackInfo(frame))); + napi->constructor()(globalObject, reinterpret_cast(NAPICallFrame::toNapiCallbackInfo(frame))); RETURN_IF_EXCEPTION(scope, {}); RELEASE_AND_RETURN(scope, JSValue::encode(frame.thisValue())); } @@ -1698,21 +1688,8 @@ void NapiClass::finishCreation(VM& vm, NativeExecutable* executable, unsigned le this->m_constructor = reinterpret_cast(constructor); auto globalObject = reinterpret_cast(this->globalObject()); - // toStringTag + "prototype" - // size_t staticPropertyCount = 2; - // prototype always has "constructor", - size_t prototypePropertyCount = 2; - this->putDirect(vm, vm.propertyNames->name, jsString(vm, name), JSC::PropertyAttribute::DontEnum | 0); - auto clientData = WebCore::clientData(vm); - - for (size_t i = 0; i < property_count; i++) { - const napi_property_descriptor& property = properties[i]; - // staticPropertyCount += property.attributes & napi_static ? 1 : 0; - prototypePropertyCount += property.attributes & napi_static ? 0 : 1; - } - NapiPrototype* prototype = NapiPrototype::create(vm, globalObject->NapiPrototypeStructure()); auto throwScope = DECLARE_THROW_SCOPE(vm); @@ -1752,7 +1729,6 @@ extern "C" napi_status napi_get_all_property_names( } auto globalObject = toJS(env); - JSC::VM& vm = globalObject->vm(); auto objectValue = toJS(objectNapi); auto* object = objectValue.getObject(); @@ -1896,7 +1872,6 @@ extern "C" napi_status napi_create_external_buffer(napi_env env, size_t length, } Zig::GlobalObject* globalObject = toJS(env); - JSC::VM& vm = globalObject->vm(); auto arrayBuffer = ArrayBuffer::createFromBytes(data, length, createSharedTask([globalObject, finalize_hint, finalize_cb](void* p) { #if NAPI_VERBOSE @@ -1990,7 +1965,6 @@ extern "C" napi_status napi_get_value_string_utf8(napi_env env, NAPI_PREMABLE JSGlobalObject* globalObject = toJS(env); - JSC::VM& vm = globalObject->vm(); JSValue jsValue = toJS(napiValue); if (!jsValue || !jsValue.isString()) { @@ -2135,9 +2109,6 @@ extern "C" napi_status napi_typeof(napi_env env, napi_value val, if (UNLIKELY(result == nullptr)) return napi_invalid_arg; - Zig::GlobalObject* globalObject = toJS(env); - JSC::VM& vm = globalObject->vm(); - JSC::JSValue value = toJS(val); if (value.isEmpty()) { @@ -2229,8 +2200,6 @@ extern "C" napi_status napi_get_value_bigint_words(napi_env env, { NAPI_PREMABLE - Zig::GlobalObject* globalObject = toJS(env); - JSC::JSValue jsValue = toJS(value); if (UNLIKELY(!jsValue.isBigInt())) return napi_invalid_arg; diff --git a/src/bun.js/bindings/root.h b/src/bun.js/bindings/root.h index f5c978926b..2bb8253a81 100644 --- a/src/bun.js/bindings/root.h +++ b/src/bun.js/bindings/root.h @@ -3,6 +3,11 @@ #ifndef BUN__ROOT__H #define BUN__ROOT__H +// pick an arbitrary #define to test +#ifdef ENABLE_3D_TRANSFORMS +#error "root.h must be included before any other WebCore or JavaScriptCore headers" +#endif + /* * Copyright (C) 2006-2021 Apple Inc. All rights reserved. * Copyright (C) 2006 Samuel Weinig "sam.weinig@gmail.com" diff --git a/src/bun.js/bindings/webcore/JSEventTargetCustom.h b/src/bun.js/bindings/webcore/JSEventTargetCustom.h index 9bbc58004d..92ce177a9e 100644 --- a/src/bun.js/bindings/webcore/JSEventTargetCustom.h +++ b/src/bun.js/bindings/webcore/JSEventTargetCustom.h @@ -68,8 +68,6 @@ public: if (UNLIKELY(!thisObject)) return throwThisTypeError(lexicalGlobalObject, throwScope, "EventTarget", operationName); - auto& wrapped = thisObject->wrapped(); - RELEASE_AND_RETURN(throwScope, (operation(&lexicalGlobalObject, &callFrame, thisObject.get()))); } }; diff --git a/src/bun.js/modules/BunJSCModule.h b/src/bun.js/modules/BunJSCModule.h index c96a6ffbe9..fba2c95861 100644 --- a/src/bun.js/modules/BunJSCModule.h +++ b/src/bun.js/modules/BunJSCModule.h @@ -413,7 +413,6 @@ JSC_DECLARE_HOST_FUNCTION(functionGetProtectedObjects); JSC_DEFINE_HOST_FUNCTION(functionGetProtectedObjects, (JSGlobalObject * globalObject, CallFrame *)) { MarkedArgumentBuffer list; - size_t result = 0; globalObject->vm().heap.forEachProtectedCell( [&](JSCell *cell) { list.append(cell); }); RELEASE_ASSERT(!list.hasOverflowed()); @@ -466,9 +465,6 @@ JSC_DEFINE_HOST_FUNCTION(functionSetTimeZone, (JSGlobalObject * globalObject, String timeZoneName = callFrame->argument(0).toWTFString(globalObject); RETURN_IF_EXCEPTION(scope, encodedJSValue()); - double time = callFrame->argument(1).toNumber(globalObject); - RETURN_IF_EXCEPTION(scope, encodedJSValue()); - if (!WTF::setTimeZoneOverride(timeZoneName)) { throwTypeError(globalObject, scope, makeString("Invalid timezone: \""_s, timeZoneName, "\""_s));