Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion scripts/build/deps/webkit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* for local mode. Override via `--webkit-version=<hash>` to test a branch.
* From https://github.com/oven-sh/WebKit releases.
*/
export const WEBKIT_VERSION = "6119947592b6e1c1faef02a4c2e03174cf05d062";
export const WEBKIT_VERSION = "d4e7e206dc9b1c58eb8aca8f06eed7a6f4abb98a";

/**
* WebKit (JavaScriptCore) — the JS engine.
Expand Down
3 changes: 1 addition & 2 deletions src/jsc/bindings/Cookie.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -258,8 +258,7 @@ void Cookie::appendTo(JSC::VM& vm, StringBuilder& builder) const
builder.append("; Expires="_s);
// RFC 6265 wants an IMF-fixdate ("Thu, 01 Jan 1970 00:00:00 GMT"). Reuse the
// Date.prototype.toUTCString() formatter, which emits exactly that.
WTF::GregorianDateTime dateTime;
vm.dateCache.msToGregorianDateTime(m_expires, WTF::TimeType::UTCTime, dateTime);
auto dateTime = vm.dateCache.msToGregorianDateTime(m_expires, WTF::TimeType::UTCTime);
builder.append(JSC::formatDateTime(dateTime, JSC::DateTimeFormat::DateAndTime, /* asUTCVariant */ true, vm.dateCache));
}

Expand Down
6 changes: 3 additions & 3 deletions src/jsc/bindings/ExceptionOr.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

#include "Exception.h"
#include <wtf/CrossThreadCopier.h>
#include <wtf/Expected.h>
#include <expected>
#include <wtf/StdLibExtras.h>

namespace WebCore {
Expand All @@ -50,7 +50,7 @@ template<typename T> class [[nodiscard]] ExceptionOr {
ReturnType releaseReturnValue();

private:
Expected<ReturnType, Exception> m_value;
std::expected<ReturnType, Exception> m_value;
#if ASSERT_ENABLED
bool m_wasReleased { false };
#endif
Expand Down Expand Up @@ -86,7 +86,7 @@ template<> class ExceptionOr<void> {
Exception releaseException();

private:
Expected<void, Exception> m_value;
std::expected<void, Exception> m_value;
};

ExceptionOr<void> isolatedCopy(ExceptionOr<void>&&);
Expand Down
10 changes: 1 addition & 9 deletions src/jsc/bindings/JSEnvironmentVariableMap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
#include <JavaScriptCore/JSString.h>
#include <JavaScriptCore/JSStringInlines.h>
#include <JavaScriptCore/DateInstance.h>
#include <JavaScriptCore/DateInstanceCache.h>
#include <JavaScriptCore/JSCast.h>
#include <JavaScriptCore/HeapIterationScope.h>
#include <JavaScriptCore/MarkedSpaceInlines.h>
Expand Down Expand Up @@ -49,16 +48,9 @@ using namespace WebCore;

void invalidateLiveDateInstanceCaches(JSC::VM& vm)
{
// HeapIterationScope stops every allocator (walks all BlockDirectories); only
// forEachLiveCell is subspace-local. Acceptable for rare TZ writes — V8's O(1)
// alternative is a tz-generation counter on DateInstanceData.
JSC::HeapIterationScope iterationScope(vm.heap);
vm.heap.dateInstanceSpace.forEachLiveCell([](JSC::HeapCell* cell, JSC::HeapCell::Kind) -> IterationStatus {
auto* date = static_cast<JSC::DateInstance*>(static_cast<JSC::JSCell*>(cell));
// m_data is private, but its offset is exported for the JIT.
auto& dataSlot = *reinterpret_cast<RefPtr<JSC::DateInstanceData>*>(reinterpret_cast<uint8_t*>(date) + JSC::DateInstance::offsetOfData());
if (dataSlot)
dataSlot->m_gregorianDateTimeCachedForMS = PNaN;
static_cast<JSC::DateInstance*>(static_cast<JSC::JSCell*>(cell))->invalidateCachedLocalGregorianDateTime();
return IterationStatus::Continue;
});
}
Expand Down
4 changes: 2 additions & 2 deletions src/jsc/bindings/JSEnvironmentVariableMap.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,8 @@ class JSEnvironmentVariableMap final : public JSC::JSNonFinalObject {
JSC::JSValue createEnvironmentVariablesMap(Zig::GlobalObject* globalObject);

// Setting TZ must make *existing* Date instances recompute local time. JSC's DateCache
// reset only clears shared slots; live DateInstances keep a Ref to DateInstanceData
// whose gregorian cache still matches, so walk the heap and invalidate those.
// reset only clears shared slots; live DateInstances keep their own cached fields
// that still match, so walk the heap and invalidate those.
void invalidateLiveDateInstanceCaches(JSC::VM&);

// The shared DateCache reset and invalidateLiveDateInstanceCaches() must travel
Expand Down
20 changes: 6 additions & 14 deletions src/jsc/bindings/bindings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6016,22 +6016,14 @@ extern "C" [[ZIG_EXPORT(check_slow)]] double Bun__parseDate(JSC::JSGlobalObject*
extern "C" [[ZIG_EXPORT(check_slow)]] double Bun__gregorianDateTimeToMS(JSC::JSGlobalObject* globalObject, int year, int month, int day, int hour, int minute, int second, int millisecond, bool localTime)
{
auto& vm = JSC::getVM(globalObject);
WTF::GregorianDateTime dateTime;
dateTime.setYear(year);
dateTime.setMonth(month - 1);
dateTime.setMonthDay(day);
dateTime.setHour(hour);
dateTime.setMinute(minute);
dateTime.setSecond(second);
return vm.dateCache.gregorianDateTimeToMS(dateTime, millisecond, localTime ? WTF::TimeType::LocalTime : WTF::TimeType::UTCTime);
return vm.dateCache.gregorianDateTimeToMS(year, month - 1, day, hour, minute, second, millisecond, localTime ? WTF::TimeType::LocalTime : WTF::TimeType::UTCTime);
}

extern "C" [[ZIG_EXPORT(nothrow)]] void Bun__msToGregorianDateTime(JSC::JSGlobalObject* globalObject, double ms, bool localTime,
int* year, int* month, int* day, int* hour, int* minute, int* second, int* weekday)
{
auto& vm = JSC::getVM(globalObject);
WTF::GregorianDateTime dt;
vm.dateCache.msToGregorianDateTime(ms, localTime ? WTF::TimeType::LocalTime : WTF::TimeType::UTCTime, dt);
auto dt = vm.dateCache.msToGregorianDateTime(ms, localTime ? WTF::TimeType::LocalTime : WTF::TimeType::UTCTime);
*year = dt.year();
*month = dt.month() + 1;
*day = dt.monthDay();
Expand Down Expand Up @@ -6275,7 +6267,7 @@ extern "C" int JSC__JSValue__DateNowISOString(JSC::JSGlobalObject* globalObject,

auto& vm = JSC::getVM(globalObject);

const GregorianDateTime* gregorianDateTime = thisDateObj->gregorianDateTimeUTC(vm.dateCache);
auto gregorianDateTime = thisDateObj->gregorianDateTimeUTC(vm.dateCache);
if (!gregorianDateTime)
return -1;

Expand All @@ -6285,10 +6277,10 @@ extern "C" int JSC__JSValue__DateNowISOString(JSC::JSGlobalObject* globalObject,
ms += msPerSecond;

int charactersWritten;
if (gregorianDateTime->year() > 9999 || gregorianDateTime->year() < 0)
charactersWritten = snprintf(buffer, sizeof(buffer), "%+07d-%02d-%02dT%02d:%02d:%02d.%03dZ", gregorianDateTime->year(), gregorianDateTime->month() + 1, gregorianDateTime->monthDay(), gregorianDateTime->hour(), gregorianDateTime->minute(), gregorianDateTime->second(), ms);
if (gregorianDateTime.year() > 9999 || gregorianDateTime.year() < 0)
charactersWritten = snprintf(buffer, sizeof(buffer), "%+07d-%02d-%02dT%02d:%02d:%02d.%03dZ", gregorianDateTime.year(), gregorianDateTime.month() + 1, gregorianDateTime.monthDay(), gregorianDateTime.hour(), gregorianDateTime.minute(), gregorianDateTime.second(), ms);
else
charactersWritten = snprintf(buffer, sizeof(buffer), "%04d-%02d-%02dT%02d:%02d:%02d.%03dZ", gregorianDateTime->year(), gregorianDateTime->month() + 1, gregorianDateTime->monthDay(), gregorianDateTime->hour(), gregorianDateTime->minute(), gregorianDateTime->second(), ms);
charactersWritten = snprintf(buffer, sizeof(buffer), "%04d-%02d-%02dT%02d:%02d:%02d.%03dZ", gregorianDateTime.year(), gregorianDateTime.month() + 1, gregorianDateTime.monthDay(), gregorianDateTime.hour(), gregorianDateTime.minute(), gregorianDateTime.second(), ms);

memcpy(buf, buffer, charactersWritten);

Expand Down
4 changes: 2 additions & 2 deletions src/jsc/bindings/webcore/CallbackResult.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@

#pragma once

#include <wtf/Expected.h>
#include <expected>

namespace WebCore {

Expand All @@ -44,7 +44,7 @@ template<typename ReturnType> class CallbackResult {
ReturnType&& releaseReturnValue();

private:
Expected<ReturnType, CallbackResultType> m_value;
std::expected<ReturnType, CallbackResultType> m_value;
};

template<> class CallbackResult<void> {
Expand Down
12 changes: 6 additions & 6 deletions src/jsc/bindings/webcore/JSDOMConvertResult.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
#include <functional>
#include <type_traits>
#include <utility>
#include <wtf/Expected.h>
#include <expected>

namespace WebCore {

Expand Down Expand Up @@ -61,7 +61,7 @@ struct ConversionResultStorage {

template<typename U>
ConversionResultStorage(ConversionResultStorage<U>&& other)
: value([&]() -> Expected<Type, ConversionResultException> {
: value([&]() -> std::expected<Type, ConversionResultException> {
if (other.hasException())
return makeUnexpected(ConversionResultException());
return ReturnType { other.releaseReturnValue() };
Expand All @@ -72,7 +72,7 @@ struct ConversionResultStorage {
template<typename U>
requires(std::is_pointer_v<Type> && std::is_lvalue_reference_v<U>)
ConversionResultStorage(ConversionResultStorage<U>&& other)
: value([&]() -> Expected<Type, ConversionResultException> {
: value([&]() -> std::expected<Type, ConversionResultException> {
if (other.hasException())
return makeUnexpected(ConversionResultException());
return ReturnType { &other.releaseReturnValue() };
Expand Down Expand Up @@ -103,7 +103,7 @@ struct ConversionResultStorage {
return WTF::move(value.value());
}

Expected<Type, ConversionResultException> value;
std::expected<Type, ConversionResultException> value;
#if ASSERT_ENABLED
bool wasReleased { false };
#endif
Expand All @@ -125,7 +125,7 @@ struct ConversionResultStorage<T&> {

template<typename U>
ConversionResultStorage(ConversionResultStorage<U>&& other)
: value([&]() -> Expected<std::reference_wrapper<Type>, ConversionResultException> {
: value([&]() -> std::expected<std::reference_wrapper<Type>, ConversionResultException> {
if (other.hasException())
return makeUnexpected(ConversionResultException());
return static_cast<ReturnType>(other.releaseReturnValue());
Expand Down Expand Up @@ -156,7 +156,7 @@ struct ConversionResultStorage<T&> {
return WTF::move(value.value()).get();
}

Expected<std::reference_wrapper<Type>, ConversionResultException> value;
std::expected<std::reference_wrapper<Type>, ConversionResultException> value;
#if ASSERT_ENABLED
bool wasReleased { false };
#endif
Expand Down
3 changes: 1 addition & 2 deletions src/jsc/bindings/wtf-bindings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -267,8 +267,7 @@ size_t toISOString(JSC::VM& vm, double date, char in[64])
if (!std::isfinite(date))
return 0;

GregorianDateTime gregorianDateTime;
vm.dateCache.msToGregorianDateTime(date, WTF::TimeType::UTCTime, gregorianDateTime);
auto gregorianDateTime = vm.dateCache.msToGregorianDateTime(date, WTF::TimeType::UTCTime);

// Maximum amount of space we need in buffer: 8 (max. digits in year) + 2 * 5 (2 characters each for month, day, hour, minute, second) + 4 (. + 3 digits for milliseconds)
// 6 for formatting and one for null termination = 29.
Expand Down
Loading