diff --git a/.github/workflows/bun-mac-x64.yml b/.github/workflows/bun-mac-x64.yml index 8c60d02804..845123303d 100644 --- a/.github/workflows/bun-mac-x64.yml +++ b/.github/workflows/bun-mac-x64.yml @@ -257,7 +257,6 @@ jobs: package: bun-darwin-x64 runner: macos-12 artifact: bun-obj-darwin-x64 - webkit_url: "https://github.com/oven-sh/WebKit/releases/download/2023-oct3-4/bun-webkit-macos-amd64-lto.tar.gz" steps: - uses: actions/checkout@v3 - name: Checkout submodules diff --git a/CMakeLists.txt b/CMakeLists.txt index 210eb32b5b..3f8ca68f02 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -3,7 +3,7 @@ cmake_policy(SET CMP0091 NEW) cmake_policy(SET CMP0067 NEW) set(Bun_VERSION "1.0.18") -set(WEBKIT_TAG 657558d4d4c9c33f41b9670e72d96a5a39fe546e) +set(WEBKIT_TAG b4de09f41b83e9e5c0e43ef414f1aee5968b6f7c) set(BUN_WORKDIR "${CMAKE_CURRENT_BINARY_DIR}") message(STATUS "Configuring Bun ${Bun_VERSION} in ${BUN_WORKDIR}") @@ -447,7 +447,7 @@ elseif(WEBKIT_DIR STREQUAL "omit") message(STATUS "Not using WebKit. This is only valid if you are only trying to build Zig code") else() # Expected to be WebKit/WebKitBuild/${CMAKE_BUILD_TYPE} - if(USE_DEBUG_JSC AND EXISTS "${WEBKIT_DIR}/cmakeconfig.h") + if(EXISTS "${WEBKIT_DIR}/cmakeconfig.h") # You may need to run: # make jsc-compile-debug jsc-copy-headers include_directories( diff --git a/docs/upgrading-webkit.md b/docs/upgrading-webkit.md index e726fb1d8e..637adb4c1e 100644 --- a/docs/upgrading-webkit.md +++ b/docs/upgrading-webkit.md @@ -17,7 +17,9 @@ $ git checkout $COMMIT This is the main command to run: ```bash -$ git pull https://github.com/WebKit/WebKit.git main --no-rebase --allow-unrelated-histories -X theirs +$ git merge upstream main +# If you get an error saying histories are unrelated, run this and try again: +$ git fetch --unshallow ``` Then, you will likely see some silly merge conflicts. Fix them and then run: diff --git a/src/bun.js/WebKit b/src/bun.js/WebKit index 657558d4d4..b4de09f41b 160000 --- a/src/bun.js/WebKit +++ b/src/bun.js/WebKit @@ -1 +1 @@ -Subproject commit 657558d4d4c9c33f41b9670e72d96a5a39fe546e +Subproject commit b4de09f41b83e9e5c0e43ef414f1aee5968b6f7c diff --git a/src/bun.js/bindings/ErrorStackTrace.cpp b/src/bun.js/bindings/ErrorStackTrace.cpp index f7013c9c43..0f5dba4c17 100644 --- a/src/bun.js/bindings/ErrorStackTrace.cpp +++ b/src/bun.js/bindings/ErrorStackTrace.cpp @@ -293,9 +293,9 @@ bool JSCStackFrame::calculateSourcePositions() * Note that we're using m_codeBlock->unlinkedCodeBlock()->expressionRangeForBytecodeOffset rather than m_codeBlock->expressionRangeForBytecodeOffset * in order get the "raw" offsets and avoid the CodeBlock's expressionRangeForBytecodeOffset modifications to the line and column numbers, * (we don't need the column number from it, and we'll calculate the line "fixes" ourselves). */ - int startOffset = 0; - int endOffset = 0; - int divotPoint = 0; + unsigned startOffset = 0; + unsigned endOffset = 0; + unsigned divotPoint = 0; unsigned line = 0; unsigned unusedColumn = 0; m_codeBlock->unlinkedCodeBlock()->expressionRangeForBytecodeIndex(bytecodeIndex, divotPoint, startOffset, endOffset, line, unusedColumn); diff --git a/src/bun.js/bindings/IDLTypes.h b/src/bun.js/bindings/IDLTypes.h index 96906331b1..8eccb08f4e 100644 --- a/src/bun.js/bindings/IDLTypes.h +++ b/src/bun.js/bindings/IDLTypes.h @@ -309,7 +309,7 @@ template struct IDLTypedArray : IDLBufferSource { struct IDLDate : IDLType { using NullableType = WallTime; static WallTime nullValue() { return WallTime::nan(); } - static bool isNullValue(WallTime value) { return std::isnan(value); } + static bool isNullValue(WallTime value) { return value.isNaN(); } static WallTime extractValueFromNullable(WallTime value) { return value; } }; diff --git a/src/bun.js/bindings/InternalModuleRegistry.cpp b/src/bun.js/bindings/InternalModuleRegistry.cpp index 1fbfbf7981..d14164b337 100644 --- a/src/bun.js/bindings/InternalModuleRegistry.cpp +++ b/src/bun.js/bindings/InternalModuleRegistry.cpp @@ -45,7 +45,8 @@ static void maybeAddCodeCoverage(JSC::VM& vm, const JSC::SourceCode& code) Identifier(), \ ImplementationVisibility::Public, \ ConstructorKind::None, \ - ConstructAbility::CannotConstruct) \ + ConstructAbility::CannotConstruct, \ + InlineAttribute::None) \ ->link(vm, nullptr, source), \ static_cast(globalObject)); \ \ diff --git a/src/bun.js/bindings/ModuleLoader.cpp b/src/bun.js/bindings/ModuleLoader.cpp index d3efccec9c..c641d8e65d 100644 --- a/src/bun.js/bindings/ModuleLoader.cpp +++ b/src/bun.js/bindings/ModuleLoader.cpp @@ -74,11 +74,10 @@ static JSC::SyntheticSourceProvider::SyntheticSourceGenerator generateInternalMo GlobalObject* globalObject = jsCast(lexicalGlobalObject); auto throwScope = DECLARE_THROW_SCOPE(vm); - auto* object = jsCast(globalObject->internalModuleRegistry()->requireId(globalObject, vm, moduleId)); - if (!object) { - return; - } + JSValue requireResult = globalObject->internalModuleRegistry()->requireId(globalObject, vm, moduleId); RETURN_IF_EXCEPTION(throwScope, void()); + auto* object = requireResult.getObject(); + ASSERT(object); JSC::EnsureStillAliveScope stillAlive(object); diff --git a/src/bun.js/bindings/Path.cpp b/src/bun.js/bindings/Path.cpp index d9229a5065..4cd252c329 100644 --- a/src/bun.js/bindings/Path.cpp +++ b/src/bun.js/bindings/Path.cpp @@ -38,7 +38,7 @@ using namespace JSC; arguments.reserveInitialCapacity(argCount); \ if (argCount) { \ for (uint16_t i = 0; i < argCount; ++i) { \ - arguments.uncheckedAppend(JSC::JSValue::encode(callFrame->uncheckedArgument(i))); \ + arguments.unsafeAppendWithoutCapacityCheck(JSC::JSValue::encode(callFrame->uncheckedArgument(i))); \ } \ } \ auto clientData = WebCore::clientData(vm); \ diff --git a/src/bun.js/bindings/URLSearchParams.cpp b/src/bun.js/bindings/URLSearchParams.cpp index a949648a18..99ac057d42 100644 --- a/src/bun.js/bindings/URLSearchParams.cpp +++ b/src/bun.js/bindings/URLSearchParams.cpp @@ -141,7 +141,7 @@ Vector URLSearchParams::getAll(const String& name) const values.reserveInitialCapacity(m_pairs.size()); for (const auto& pair : m_pairs) { if (pair.key == name) - values.uncheckedAppend(pair.value); + values.unsafeAppendWithoutCapacityCheck(pair.value); } values.shrinkToFit(); return values; diff --git a/src/bun.js/bindings/bindings.cpp b/src/bun.js/bindings/bindings.cpp index 1cb06c5f8b..2c28ea72fc 100644 --- a/src/bun.js/bindings/bindings.cpp +++ b/src/bun.js/bindings/bindings.cpp @@ -1411,7 +1411,7 @@ JSC__JSValue WebCore__FetchHeaders__createValue(JSC__JSGlobalObject* arg0, Strin for (uint32_t i = 0; i < count; i++) { WTF::String name = Zig::toStringCopy(buf, arg1[i]); WTF::String value = Zig::toStringCopy(buf, arg2[i]); - pairs.uncheckedAppend(KeyValuePair(name, value)); + pairs.unsafeAppendWithoutCapacityCheck(KeyValuePair(name, value)); } Ref headers = WebCore::FetchHeaders::create(); @@ -3678,9 +3678,9 @@ static void populateStackFramePosition(const JSC::StackFrame* stackFrame, BunStr * avoid the CodeBlock's expressionRangeForBytecodeOffset modifications to the line and column * numbers, (we don't need the column number from it, and we'll calculate the line "fixes" * ourselves). */ - int startOffset = 0; - int endOffset = 0; - int divotPoint = 0; + unsigned startOffset = 0; + unsigned endOffset = 0; + unsigned divotPoint = 0; unsigned line = 0; unsigned unusedColumn = 0; m_codeBlock->unlinkedCodeBlock()->expressionRangeForBytecodeIndex( diff --git a/src/bun.js/bindings/webcore/EventPath.cpp b/src/bun.js/bindings/webcore/EventPath.cpp index 237923fbee..bb285566c3 100644 --- a/src/bun.js/bindings/webcore/EventPath.cpp +++ b/src/bun.js/bindings/webcore/EventPath.cpp @@ -262,7 +262,7 @@ EventPath::EventPath(Node& originalTarget, Event& event) // bool movedOutOfShadowTree = depth < currentDepthAllowed; // if (movedOutOfShadowTree) // currentDepthAllowed = depth; -// path.uncheckedAppend(currentContext.currentTarget()); +// path.unsafeAppendWithoutCapacityCheck(currentContext.currentTarget()); // }; // auto currentDepthAllowed = currentTargetDepth; diff --git a/src/bun.js/bindings/webcore/FetchHeaders.cpp b/src/bun.js/bindings/webcore/FetchHeaders.cpp index 02ddbac450..5a9b36557f 100644 --- a/src/bun.js/bindings/webcore/FetchHeaders.cpp +++ b/src/bun.js/bindings/webcore/FetchHeaders.cpp @@ -274,10 +274,10 @@ std::optional> FetchHeaders::Iterator::next() m_keys.resize(0); m_keys.reserveCapacity(m_headers->m_headers.size() + (hasSetCookie ? 1 : 0)); for (auto& header : m_headers->m_headers) - m_keys.uncheckedAppend(header.asciiLowerCaseName()); + m_keys.unsafeAppendWithoutCapacityCheck(header.asciiLowerCaseName()); std::sort(m_keys.begin(), m_keys.end(), WTF::codePointCompareLessThan); if (hasSetCookie) - m_keys.uncheckedAppend(String()); + m_keys.unsafeAppendWithoutCapacityCheck(String()); m_currentIndex += m_cookieIndex; if (hasSetCookie) { diff --git a/src/bun.js/bindings/webcore/JSDOMConvertSequences.h b/src/bun.js/bindings/webcore/JSDOMConvertSequences.h index c2412e5d7a..40b40c61ac 100644 --- a/src/bun.js/bindings/webcore/JSDOMConvertSequences.h +++ b/src/bun.js/bindings/webcore/JSDOMConvertSequences.h @@ -95,9 +95,9 @@ struct NumericSequenceConverter { auto indexValue = array->butterfly()->contiguousInt32().at(array, i).get(); ASSERT(!indexValue || indexValue.isInt32()); if (!indexValue) - result.uncheckedAppend(0); + result.unsafeAppendWithoutCapacityCheck(0); else - result.uncheckedAppend(indexValue.asInt32()); + result.unsafeAppendWithoutCapacityCheck(indexValue.asInt32()); } return WTFMove(result); } @@ -106,12 +106,12 @@ struct NumericSequenceConverter { for (unsigned i = 0; i < length; i++) { double doubleValue = array->butterfly()->contiguousDouble().at(array, i); if (std::isnan(doubleValue)) - result.uncheckedAppend(0); + result.unsafeAppendWithoutCapacityCheck(0); else { auto convertedValue = Converter::convert(lexicalGlobalObject, scope, doubleValue); RETURN_IF_EXCEPTION(scope, {}); - result.uncheckedAppend(convertedValue); + result.unsafeAppendWithoutCapacityCheck(convertedValue); } } return WTFMove(result); @@ -219,7 +219,7 @@ struct SequenceConverter { auto convertedValue = Converter::convert(lexicalGlobalObject, indexValue); RETURN_IF_EXCEPTION(scope, {}); - result.uncheckedAppend(convertedValue); + result.unsafeAppendWithoutCapacityCheck(convertedValue); } return result; } @@ -234,7 +234,7 @@ struct SequenceConverter { auto convertedValue = Converter::convert(lexicalGlobalObject, indexValue); RETURN_IF_EXCEPTION(scope, {}); - result.uncheckedAppend(convertedValue); + result.unsafeAppendWithoutCapacityCheck(convertedValue); } return result; } diff --git a/src/bun.js/bindings/webcore/JSMessageChannel.cpp b/src/bun.js/bindings/webcore/JSMessageChannel.cpp index 8b98dff183..d63d6293b1 100644 --- a/src/bun.js/bindings/webcore/JSMessageChannel.cpp +++ b/src/bun.js/bindings/webcore/JSMessageChannel.cpp @@ -20,8 +20,6 @@ #include "config.h" -#if ENABLE(CHANNEL_MESSAGING) - #include "JSMessageChannel.h" #include "ActiveDOMObject.h" @@ -319,5 +317,3 @@ MessageChannel* JSMessageChannel::toWrapped(JSC::VM&, JSC::JSValue value) } } - -#endif // ENABLE(CHANNEL_MESSAGING) diff --git a/src/bun.js/bindings/webcore/JSMessageChannel.h b/src/bun.js/bindings/webcore/JSMessageChannel.h index 551be7459b..3870ef85d3 100644 --- a/src/bun.js/bindings/webcore/JSMessageChannel.h +++ b/src/bun.js/bindings/webcore/JSMessageChannel.h @@ -20,8 +20,6 @@ #pragma once -#if ENABLE(CHANNEL_MESSAGING) - #include "JSDOMWrapper.h" #include "MessageChannel.h" #include @@ -98,5 +96,3 @@ template<> struct JSDOMWrapperConverterTraits { }; } // namespace WebCore - -#endif // ENABLE(CHANNEL_MESSAGING) diff --git a/src/bun.js/bindings/webcore/JSMessageChannelCustom.cpp b/src/bun.js/bindings/webcore/JSMessageChannelCustom.cpp index 75b0740485..7bfe4e5d89 100644 --- a/src/bun.js/bindings/webcore/JSMessageChannelCustom.cpp +++ b/src/bun.js/bindings/webcore/JSMessageChannelCustom.cpp @@ -25,8 +25,6 @@ #include "config.h" -#if ENABLE(CHANNEL_MESSAGING) - #include "DOMWrapperWorld.h" #include "JSMessageChannel.h" // #include "JSNodeCustom.h" @@ -48,5 +46,3 @@ void JSMessageChannel::visitAdditionalChildren(Visitor& visitor) DEFINE_VISIT_ADDITIONAL_CHILDREN(JSMessageChannel); } // namespace WebCore - -#endif // ENABLE(CHANNEL_MESSAGING) diff --git a/src/bun.js/bindings/webcore/SerializedScriptValue.cpp b/src/bun.js/bindings/webcore/SerializedScriptValue.cpp index 9b9f04aa8a..58a665fa51 100644 --- a/src/bun.js/bindings/webcore/SerializedScriptValue.cpp +++ b/src/bun.js/bindings/webcore/SerializedScriptValue.cpp @@ -4254,7 +4254,7 @@ private: CachedStringRef value; if (!readStringData(value)) return JSValue(); - fingerprints.uncheckedAppend(RTCCertificate::DtlsFingerprint { algorithm->string(), value->string() }); + fingerprints.unsafeAppendWithoutCapacityCheck(RTCCertificate::DtlsFingerprint { algorithm->string(), value->string() }); } if (!m_canCreateDOMObject) diff --git a/src/bun.js/bindings/webcore/SharedBuffer.cpp b/src/bun.js/bindings/webcore/SharedBuffer.cpp index 32b19626be..816be297dd 100644 --- a/src/bun.js/bindings/webcore/SharedBuffer.cpp +++ b/src/bun.js/bindings/webcore/SharedBuffer.cpp @@ -126,7 +126,7 @@ Vector FragmentedSharedBuffer::copyData() const Vector data; data.reserveInitialCapacity(size()); forEachSegment([&data](auto& span) { - data.uncheckedAppend(span); + data.unsafeAppendWithoutCapacityCheck(span.data(), span.size()); }); return data; } @@ -217,7 +217,7 @@ void FragmentedSharedBuffer::append(const FragmentedSharedBuffer& data) ASSERT(!m_contiguous); m_segments.reserveCapacity(m_segments.size() + data.m_segments.size()); for (const auto& element : data.m_segments) { - m_segments.uncheckedAppend({ m_size, element.segment.copyRef() }); + m_segments.unsafeAppendWithoutCapacityCheck(DataSegmentVectorEntry { m_size, element.segment.copyRef() }); m_size += element.segment->size(); } ASSERT(internallyConsistent()); @@ -255,7 +255,7 @@ Ref FragmentedSharedBuffer::copy() const clone->m_size = m_size; clone->m_segments.reserveInitialCapacity(m_segments.size()); for (const auto& element : m_segments) - clone->m_segments.uncheckedAppend({ element.beginPosition, element.segment.copyRef() }); + clone->m_segments.unsafeAppendWithoutCapacityCheck(DataSegmentVectorEntry { element.beginPosition, element.segment.copyRef() }); ASSERT(clone->internallyConsistent()); ASSERT(internallyConsistent()); return clone; diff --git a/src/bun.js/bindings/webcore/WebSocket.cpp b/src/bun.js/bindings/webcore/WebSocket.cpp index 5a0f7a6a5c..d41b8084be 100644 --- a/src/bun.js/bindings/webcore/WebSocket.cpp +++ b/src/bun.js/bindings/webcore/WebSocket.cpp @@ -418,8 +418,8 @@ ExceptionOr WebSocket::connect(const String& url, const Vector& pr headerValues.reserveInitialCapacity(headers.get().internalHeaders().size()); auto iterator = headers.get().createIterator(); while (auto value = iterator.next()) { - headerNames.uncheckedAppend(Zig::toZigString(value->key)); - headerValues.uncheckedAppend(Zig::toZigString(value->value)); + headerNames.unsafeAppendWithoutCapacityCheck(Zig::toZigString(value->key)); + headerValues.unsafeAppendWithoutCapacityCheck(Zig::toZigString(value->value)); } m_isSecure = is_secure; diff --git a/src/codegen/bundle-functions.ts b/src/codegen/bundle-functions.ts index 0c1e4206f2..77e7bb7205 100644 --- a/src/codegen/bundle-functions.ts +++ b/src/codegen/bundle-functions.ts @@ -282,6 +282,9 @@ for (const { basename, functions } of files) { const name = `${lowerBasename}${cap(fn.name)}Code`; bundledCPP += `// ${fn.name} const JSC::ConstructAbility s_${name}ConstructAbility = JSC::ConstructAbility::${fn.constructAbility}; +const JSC::InlineAttribute s_${name}InlineAttribute = JSC::InlineAttribute::${ + fn.directives.alwaysInline ? "Always" : "None" + }; const JSC::ConstructorKind s_${name}ConstructorKind = JSC::ConstructorKind::${fn.constructKind}; const JSC::ImplementationVisibility s_${name}ImplementationVisibility = JSC::ImplementationVisibility::${fn.visibility}; const int s_${name}Length = ${fn.source.length}; @@ -403,6 +406,7 @@ for (const { basename, functions, internal } of files) { extern const char* s_${name}; extern const int s_${name}Length; extern const JSC::ConstructAbility s_${name}ConstructAbility; +extern const JSC::InlineAttribute s_${name}InlineAttribute; extern const JSC::ConstructorKind s_${name}ConstructorKind; extern const JSC::ImplementationVisibility s_${name}ImplementationVisibility; @@ -471,7 +475,7 @@ inline JSC::UnlinkedFunctionExecutable* ${basename}BuiltinsWrapper::name##Execut JSC::Identifier executableName = functionName##PublicName();\\ if (overriddenName)\\ executableName = JSC::Identifier::fromString(m_vm, overriddenName);\\ - m_##name##Executable = JSC::Weak(JSC::createBuiltinExecutable(m_vm, m_##name##Source, executableName, s_##name##ImplementationVisibility, s_##name##ConstructorKind, s_##name##ConstructAbility), this, &m_##name##Executable);\\ + m_##name##Executable = JSC::Weak(JSC::createBuiltinExecutable(m_vm, m_##name##Source, executableName, s_##name##ImplementationVisibility, s_##name##ConstructorKind, s_##name##ConstructAbility, s_##name##InlineAttribute), this, &m_##name##Executable);\\ }\\ return m_##name##Executable.get();\\ } diff --git a/src/js/builtins.d.ts b/src/js/builtins.d.ts index ee7bd68cf8..e6488bb440 100644 --- a/src/js/builtins.d.ts +++ b/src/js/builtins.d.ts @@ -32,6 +32,8 @@ declare var $intrinsic: string; declare var $constructor; /** Place this directly above a function declaration (like a decorator) to NOT include "use strict" */ declare var $sloppy; +/** Place this directly above a function declaration (like a decorator) to always inline the function */ +declare var $alwaysInline; declare function $extractHighWaterMarkFromQueuingStrategyInit(obj: any): any;