Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
8302294: Cherry-pick WebKit 615.1 stabilization fixes
Backport-of: 97ae4b87c7e2ce0605ff051c82d48328f83a94ca
  • Loading branch information
kevinrushforth committed Mar 13, 2023
1 parent 275147a commit c38fcb2
Show file tree
Hide file tree
Showing 198 changed files with 1,287 additions and 961 deletions.
Expand Up @@ -67,19 +67,17 @@ void BlockDirectory::updatePercentageOfPagedOutPages(SimpleStats& stats)
// For some reason this can be unsigned char or char on different OSes...
using MincoreBufferType = std::remove_pointer_t<FunctionTraits<decltype(mincore)>::ArgumentType<2>>;
static_assert(std::is_same_v<std::make_unsigned_t<MincoreBufferType>, unsigned char>);
// pageSize is effectively a constant so this isn't really variable.
IGNORE_CLANG_WARNINGS_BEGIN("vla")
MincoreBufferType pagedBits[numberOfPagesInMarkedBlock];
IGNORE_CLANG_WARNINGS_END
Vector<MincoreBufferType, 16> pagedBits(numberOfPagesInMarkedBlock, MincoreBufferType { });

for (auto* handle : m_blocks) {
if (!handle)
continue;

auto markedBlockSizeInBytes = static_cast<size_t>(reinterpret_cast<char*>(handle->end()) - reinterpret_cast<char*>(handle->start()));
auto* pageStart = handle->pageStart();
auto markedBlockSizeInBytes = handle->backingStorageSize();
RELEASE_ASSERT(markedBlockSizeInBytes / pageSize <= numberOfPagesInMarkedBlock);
// We could cache this in bulk (e.g. 25 MB chunks) but we haven't seen any data that it actually matters.
auto result = mincore(handle->start(), markedBlockSizeInBytes, pagedBits);
auto result = mincore(pageStart, markedBlockSizeInBytes, pagedBits.data());
RELEASE_ASSERT(!result);
constexpr unsigned pageIsResidentAndNotCompressed = 1;
for (unsigned i = 0; i < numberOfPagesInMarkedBlock; ++i)
Expand Down
Expand Up @@ -169,6 +169,8 @@ class MarkedBlock {
size_t markCount();
size_t size();

size_t backingStorageSize() { return bitwise_cast<uintptr_t>(end()) - bitwise_cast<uintptr_t>(pageStart()); }

bool isAllocated();

bool isLive(HeapVersion markingVersion, HeapVersion newlyAllocatedVersion, bool isMarking, const HeapCell*);
Expand Down Expand Up @@ -202,6 +204,7 @@ class MarkedBlock {
void* end() const { return &m_block->atoms()[m_endAtom]; }
void* atomAt(size_t i) const { return &m_block->atoms()[i]; }
bool contains(void* p) const { return start() <= p && p < end(); }
void* pageStart() const { return &m_block->atoms()[0]; }

void dumpState(PrintStream&);

Expand Down
Expand Up @@ -1304,7 +1304,8 @@ template <class TreeBuilder> TreeDestructuringPattern Parser<LexerType>::parseDe
wasString = true;
break;
case BIGINT:
propertyName = &m_parserArena.identifierArena().makeBigIntDecimalIdentifier(const_cast<VM&>(m_vm), *m_token.m_data.bigIntString, m_token.m_data.radix);
propertyName = m_parserArena.identifierArena().makeBigIntDecimalIdentifier(const_cast<VM&>(m_vm), *m_token.m_data.bigIntString, m_token.m_data.radix);
failIfFalse(propertyName, "Cannot parse big int property name");
break;
case OPENBRACKET:
next();
Expand Down Expand Up @@ -3011,8 +3012,8 @@ template <class TreeBuilder> TreeClassExpression Parser<LexerType>::parseClass(T
next();
break;
case BIGINT:
ident = &m_parserArena.identifierArena().makeBigIntDecimalIdentifier(const_cast<VM&>(m_vm), *m_token.m_data.bigIntString, m_token.m_data.radix);
ASSERT(ident);
ident = m_parserArena.identifierArena().makeBigIntDecimalIdentifier(const_cast<VM&>(m_vm), *m_token.m_data.bigIntString, m_token.m_data.radix);
failIfFalse(ident, "Cannot parse big int property name");
next();
break;
case ESCAPED_KEYWORD:
Expand Down Expand Up @@ -3258,8 +3259,8 @@ template <class TreeBuilder> TreeSourceElements Parser<LexerType>::parseClassFie
next();
break;
case BIGINT:
ident = &m_parserArena.identifierArena().makeBigIntDecimalIdentifier(const_cast<VM&>(m_vm), *m_token.m_data.bigIntString, m_token.m_data.radix);
ASSERT(ident);
ident = m_parserArena.identifierArena().makeBigIntDecimalIdentifier(const_cast<VM&>(m_vm), *m_token.m_data.bigIntString, m_token.m_data.radix);
failIfFalse(ident, "Cannot parse big int property name");
next();
break;
case DOUBLE:
Expand Down Expand Up @@ -4516,7 +4517,8 @@ template <class TreeBuilder> TreeProperty Parser<LexerType>::parseProperty(TreeB
return context.createProperty(const_cast<VM&>(m_vm), m_parserArena, propertyName, node, PropertyNode::Constant, SuperBinding::NotNeeded, ClassElementTag::No);
}
case BIGINT: {
const Identifier* ident = &m_parserArena.identifierArena().makeBigIntDecimalIdentifier(const_cast<VM&>(m_vm), *m_token.m_data.bigIntString, m_token.m_data.radix);
const Identifier* ident = m_parserArena.identifierArena().makeBigIntDecimalIdentifier(const_cast<VM&>(m_vm), *m_token.m_data.bigIntString, m_token.m_data.radix);
failIfFalse(ident, "Cannot parse big int property name");
next();

if (match(OPENPAREN)) {
Expand Down Expand Up @@ -4608,7 +4610,8 @@ template <class TreeBuilder> TreeProperty Parser<LexerType>::parseGetterSetter(T
numericPropertyName = m_token.m_data.doubleValue;
next();
} else if (match(BIGINT)) {
stringPropertyName = &m_parserArena.identifierArena().makeBigIntDecimalIdentifier(const_cast<VM&>(m_vm), *m_token.m_data.bigIntString, m_token.m_data.radix);
stringPropertyName = m_parserArena.identifierArena().makeBigIntDecimalIdentifier(const_cast<VM&>(m_vm), *m_token.m_data.bigIntString, m_token.m_data.radix);
failIfFalse(stringPropertyName, "Cannot parse big int property name");
next();
} else if (match(OPENBRACKET)) {
next();
Expand Down
Expand Up @@ -79,16 +79,22 @@ void ParserArena::allocateFreeablePool()
ASSERT(freeablePool() == pool);
}

const Identifier& IdentifierArena::makeBigIntDecimalIdentifier(VM& vm, const Identifier& identifier, uint8_t radix)
const Identifier* IdentifierArena::makeBigIntDecimalIdentifier(VM& vm, const Identifier& identifier, uint8_t radix)
{
if (radix == 10)
return identifier;
return &identifier;

DeferTermination deferScope(vm);
auto scope = DECLARE_CATCH_SCOPE(vm);
JSValue bigInt = JSBigInt::parseInt(nullptr, vm, identifier.string(), radix, JSBigInt::ErrorParseMode::ThrowExceptions, JSBigInt::ParseIntSign::Unsigned);
scope.assertNoException();

if (bigInt.isEmpty()) {
// Handle out-of-memory or other failures by returning null, since
// we don't have a global object to throw exceptions to in this scope.
return nullptr;
}

// FIXME: We are allocating a JSBigInt just to be able to use
// JSBigInt::tryGetString when radix is not 10.
// This creates some GC pressure, but since these identifiers
Expand All @@ -106,7 +112,7 @@ const Identifier& IdentifierArena::makeBigIntDecimalIdentifier(VM& vm, const Ide
heapBigInt = bigInt.asHeapBigInt();

m_identifiers.append(Identifier::fromString(vm, JSBigInt::tryGetString(vm, heapBigInt, 10)));
return m_identifiers.last();
return &m_identifiers.last();
}

const Identifier& IdentifierArena::makePrivateIdentifier(VM& vm, ASCIILiteral prefix, unsigned identifier)
Expand Down
Expand Up @@ -50,7 +50,7 @@ namespace JSC {
ALWAYS_INLINE const Identifier& makeIdentifierLCharFromUChar(VM&, const UChar* characters, size_t length);
ALWAYS_INLINE const Identifier& makeIdentifier(VM&, SymbolImpl*);

const Identifier& makeBigIntDecimalIdentifier(VM&, const Identifier&, uint8_t radix);
const Identifier* makeBigIntDecimalIdentifier(VM&, const Identifier&, uint8_t radix);
const Identifier& makeNumericIdentifier(VM&, double number);
const Identifier& makePrivateIdentifier(VM&, ASCIILiteral, unsigned);

Expand Down
Expand Up @@ -64,8 +64,11 @@ JSValue iteratorValue(JSGlobalObject* globalObject, JSValue iterResult)

bool iteratorComplete(JSGlobalObject* globalObject, JSValue iterResult)
{
VM& vm = globalObject->vm();
auto scope = DECLARE_THROW_SCOPE(vm);
JSValue done = iterResult.get(globalObject, globalObject->vm().propertyNames->done);
return done.toBoolean(globalObject);
RETURN_IF_EXCEPTION(scope, true);
RELEASE_AND_RETURN(scope, done.toBoolean(globalObject));
}

JSValue iteratorStep(JSGlobalObject* globalObject, IterationRecord iterationRecord)
Expand Down
Expand Up @@ -304,13 +304,10 @@ MediaTime MediaTime::operator*(int32_t rhs) const
return positiveInfiniteTime();
}

MediaTime a = *this;

if (a.hasDoubleValue()) {
a.m_timeValueAsDouble *= rhs;
return a;
}
if (hasDoubleValue())
return MediaTime::createWithDouble(m_timeValueAsDouble * rhs);

MediaTime a = *this;
while (!safeMultiply(a.m_timeValue, rhs, a.m_timeValue)) {
if (a.m_timeScale == 1)
return signum(a.m_timeValue) == signum(rhs) ? positiveInfiniteTime() : negativeInfiniteTime();
Expand Down
Expand Up @@ -1313,3 +1313,9 @@
|| PLATFORM(IOS) && __IPHONE_OS_VERSION_MIN_REQUIRED >= 160000))
#define HAVE_LOCKDOWN_MODE_PDF_ADDITIONS 1
#endif

#if (PLATFORM(GTK) || PLATFORM(WPE)) && defined(__has_include)
#if __has_include(<gio/gdesktopappinfo.h>)
#define HAVE_GDESKTOPAPPINFO 1
#endif
#endif
41 changes: 34 additions & 7 deletions modules/javafx.web/src/main/native/Source/WTF/wtf/URLHelpers.cpp
@@ -1,5 +1,5 @@
/*
* Copyright (C) 2005-2019 Apple Inc. All rights reserved.
* Copyright (C) 2005-2022 Apple Inc. All rights reserved.
* Copyright (C) 2018 Igalia S.L.
*
* Redistribution and use in source and binary forms, with or without
Expand Down Expand Up @@ -48,7 +48,8 @@ constexpr unsigned urlBytesBufferLength = 2048;
// WebKit was compiled.
// This is only really important for platforms that load an external IDN allowed script list.
// Not important for the compiled-in one.
constexpr auto scriptCodeLimit = static_cast<UScriptCode>(256);
constexpr auto scriptCodeLimit = static_cast<UScriptCode>(255);


static uint32_t allowedIDNScriptBits[(scriptCodeLimit + 31) / 32];

Expand Down Expand Up @@ -116,6 +117,16 @@ template<> bool isLookalikeCharacterOfScriptType<USCRIPT_CANADIAN_ABORIGINAL>(UC
}
}

template<> bool isLookalikeCharacterOfScriptType<USCRIPT_THAI>(UChar32 codePoint)
{
switch (codePoint) {
case 0x0E01: // THAI CHARACTER KO KAI
return true;
default:
return false;
}
}

template <UScriptCode ScriptType>
bool isOfScriptType(UChar32 codePoint)
{
Expand Down Expand Up @@ -163,6 +174,20 @@ bool isLookalikeSequence(const std::optional<UChar32>& previousCodePoint, UChar3
|| isLookalikePair(*previousCodePoint, codePoint);
}

template <>
bool isLookalikeSequence<USCRIPT_ARABIC>(const std::optional<UChar32>& previousCodePoint, UChar32 codePoint)
{
auto isArabicDiacritic = [](UChar32 codePoint) {
return 0x064B <= codePoint && codePoint <= 0x065F;
};
auto isArabicCodePoint = [](const std::optional<UChar32>& codePoint) {
if (!codePoint)
return false;
return ublock_getCode(*codePoint) == UBLOCK_ARABIC;
};
return isArabicDiacritic(codePoint) && !isArabicCodePoint(previousCodePoint);
}

static bool isLookalikeCharacter(const std::optional<UChar32>& previousCodePoint, UChar32 codePoint)
{
// This function treats the following as unsafe, lookalike characters:
Expand All @@ -176,22 +201,22 @@ static bool isLookalikeCharacter(const std::optional<UChar32>& previousCodePoint
// slashes into an ASCII solidus. But one of the two callers uses this
// on characters that have not been processed by ICU, so they are needed here.

if (!u_isprint(codePoint) || u_isUWhiteSpace(codePoint) || u_hasBinaryProperty(codePoint, UCHAR_DEFAULT_IGNORABLE_CODE_POINT))
if (!u_isprint(codePoint)
|| u_isUWhiteSpace(codePoint)
|| u_hasBinaryProperty(codePoint, UCHAR_DEFAULT_IGNORABLE_CODE_POINT)
|| ublock_getCode(codePoint) == UBLOCK_IPA_EXTENSIONS)
return true;

switch (codePoint) {