Skip to content

Commit da580ba

Browse files
Hima Bindu Medakevinrushforth
Hima Bindu Meda
authored andcommitted
8292609: Cherry-pick WebKit 614.1 stabilization fixes
Reviewed-by: kcr, arapte, jvos
1 parent 996eb84 commit da580ba

File tree

111 files changed

+1126
-380
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

111 files changed

+1126
-380
lines changed

modules/javafx.web/src/main/native/Source/JavaScriptCore/b3/B3Generate.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,7 @@ void generateToAir(Procedure& procedure)
118118
lowerMacrosAfterOptimizations(procedure);
119119
legalizeMemoryOffsets(procedure);
120120
moveConstants(procedure);
121+
legalizeMemoryOffsets(procedure);
121122
if (Options::useB3CanonicalizePrePostIncrements() && procedure.optLevel() >= 2)
122123
canonicalizePrePostIncrements(procedure);
123124
eliminateDeadCode(procedure);

modules/javafx.web/src/main/native/Source/JavaScriptCore/b3/B3ReduceStrength.cpp

+59-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (C) 2015-2020 Apple Inc. All rights reserved.
2+
* Copyright (C) 2015-2022 Apple Inc. All rights reserved.
33
*
44
* Redistribution and use in source and binary forms, with or without
55
* modification, are permitted provided that the following conditions
@@ -388,6 +388,61 @@ class IntRange {
388388
}
389389
}
390390

391+
template<typename T>
392+
IntRange sExt()
393+
{
394+
ASSERT(m_min >= INT32_MIN);
395+
ASSERT(m_max <= INT32_MAX);
396+
int64_t typeMin = std::numeric_limits<T>::min();
397+
int64_t typeMax = std::numeric_limits<T>::max();
398+
auto min = m_min;
399+
auto max = m_max;
400+
401+
if (typeMin <= min && min <= typeMax
402+
&& typeMin <= max && max <= typeMax)
403+
return IntRange(min, max);
404+
405+
// Given type T with N bits, signed extension will turn bit N-1 as
406+
// a sign bit. If bits N-1 upwards are identical for both min and max,
407+
// then we're guaranteed that even after the sign extension, min and
408+
// max will still be in increasing order.
409+
//
410+
// For example, when T is int8_t, the space of numbers from highest to
411+
// lowest are as follows (in binary bits):
412+
//
413+
// highest 0 111 1111 ^
414+
// ... |
415+
// 1 0 000 0001 | top segment
416+
// 0 0 000 0000 v
417+
//
418+
// -1 1 111 1111 ^
419+
// -2 1 111 1110 | bottom segment
420+
// ... |
421+
// lowest 1 000 0000 v
422+
//
423+
// Note that if we exclude the sign bit, the range is made up of 2 segments
424+
// of contiguous increasing numbers. If min and max are both in the same
425+
// segment before the sign extension, then min and max will continue to be
426+
// in a contiguous segment after the sign extension. Only when min and max
427+
// spans across more than 1 of these segments, will min and max no longer
428+
// be guaranteed to be in a contiguous range after the sign extension.
429+
//
430+
// Hence, we can check if bits N-1 and up are identical for the range min
431+
// and max. If so, then the new min and max can be be computed by simply
432+
// applying sign extension to their original values.
433+
434+
constexpr unsigned numberOfBits = countOfBits<T>;
435+
constexpr int64_t segmentMask = (1ll << (numberOfBits - 1)) - 1;
436+
constexpr int64_t topBitsMask = ~segmentMask;
437+
int64_t minTopBits = topBitsMask & min;
438+
int64_t maxTopBits = topBitsMask & max;
439+
440+
if (minTopBits == maxTopBits)
441+
return IntRange(static_cast<int64_t>(static_cast<T>(min)), static_cast<int64_t>(static_cast<T>(max)));
442+
443+
return top<T>();
444+
}
445+
391446
IntRange zExt32()
392447
{
393448
ASSERT(m_min >= INT32_MIN);
@@ -2765,9 +2820,11 @@ class ReduceStrength {
27652820
rangeFor(value->child(1), timeToLive - 1), value->type());
27662821

27672822
case SExt8:
2823+
return rangeFor(value->child(0), timeToLive - 1).sExt<int8_t>();
27682824
case SExt16:
2825+
return rangeFor(value->child(0), timeToLive - 1).sExt<int16_t>();
27692826
case SExt32:
2770-
return rangeFor(value->child(0), timeToLive - 1);
2827+
return rangeFor(value->child(0), timeToLive - 1).sExt<int32_t>();
27712828

27722829
case ZExt32:
27732830
return rangeFor(value->child(0), timeToLive - 1).zExt32();

modules/javafx.web/src/main/native/Source/JavaScriptCore/b3/testb3.h

+1
Original file line numberDiff line numberDiff line change
@@ -555,6 +555,7 @@ void testTrappingLoadAddStore();
555555
void testTrappingLoadDCE();
556556
void testTrappingStoreElimination();
557557
void testMoveConstants();
558+
void testMoveConstantsWithLargeOffsets();
558559
void testPCOriginMapDoesntInsertNops();
559560
void testBitOrBitOrArgImmImm32(int, int, int c);
560561
void testBitOrImmBitOrArgImm32(int, int, int c);

modules/javafx.web/src/main/native/Source/JavaScriptCore/b3/testb3_1.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -760,6 +760,7 @@ void run(const char* filter)
760760
RUN(testTrappingLoadDCE());
761761
RUN(testTrappingStoreElimination());
762762
RUN(testMoveConstants());
763+
RUN(testMoveConstantsWithLargeOffsets());
763764
RUN(testPCOriginMapDoesntInsertNops());
764765
RUN(testPinRegisters());
765766
RUN(testReduceStrengthReassociation(true));

modules/javafx.web/src/main/native/Source/JavaScriptCore/b3/testb3_6.cpp

+26
Original file line numberDiff line numberDiff line change
@@ -2839,6 +2839,32 @@ void testMoveConstants()
28392839
}
28402840
}
28412841

2842+
extern "C" {
2843+
static JSC_DECLARE_JIT_OPERATION_WITHOUT_WTF_INTERNAL(testMoveConstantsWithLargeOffsetsFunc, double, (double));
2844+
}
2845+
JSC_DEFINE_JIT_OPERATION(testMoveConstantsWithLargeOffsetsFunc, double, (double a))
2846+
{
2847+
return a;
2848+
}
2849+
2850+
void testMoveConstantsWithLargeOffsets()
2851+
{
2852+
Procedure proc;
2853+
BasicBlock* root = proc.addBlock();
2854+
Value* result = root->appendNew<ConstDoubleValue>(proc, Origin(), 0);
2855+
double rhs = 0;
2856+
for (size_t i = 0; i < 4100; i++) {
2857+
rhs += i;
2858+
Value* callResult = root->appendNew<CCallValue>(proc, Double, Origin(),
2859+
root->appendNew<ConstPtrValue>(proc, Origin(), tagCFunction<OperationPtrTag>(testMoveConstantsWithLargeOffsetsFunc)),
2860+
root->appendNew<ConstDoubleValue>(proc, Origin(), i));
2861+
result = root->appendNew<Value>(proc, Add, Origin(), result, callResult);
2862+
}
2863+
root->appendNewControlValue(proc, Return, Origin(), result);
2864+
2865+
CHECK_EQ(compileAndRun<double>(proc), rhs);
2866+
}
2867+
28422868
void testPCOriginMapDoesntInsertNops()
28432869
{
28442870
Procedure proc;

modules/javafx.web/src/main/native/Source/JavaScriptCore/bytecompiler/NodesCodegen.cpp

+4
Original file line numberDiff line numberDiff line change
@@ -4694,6 +4694,10 @@ void TryNode::emitBytecode(BytecodeGenerator& generator, RegisterID* dst)
46944694
}
46954695

46964696
generator.emitProfileControlFlow(m_tryBlock->endOffset() + 1);
4697+
4698+
if (generator.shouldBeConcernedWithCompletionValue())
4699+
generator.emitLoad(tryCatchDst.get(), jsUndefined());
4700+
46974701
if (m_finallyBlock)
46984702
generator.emitNode(tryCatchDst.get(), m_catchBlock);
46994703
else

modules/javafx.web/src/main/native/Source/JavaScriptCore/dfg/DFGSpeculativeJIT64.cpp

+6-3
Original file line numberDiff line numberDiff line change
@@ -4974,8 +4974,11 @@ void SpeculativeJIT::compile(Node* node)
49744974
if (node->child2().useKind() != UntypedUse)
49754975
speculate(node, node->child2());
49764976

4977-
m_jit.load32(MacroAssembler::Address(mapGPR, HashMapImpl<HashMapBucket<HashMapBucketDataKey>>::offsetOfCapacity()), maskGPR);
4977+
CCallHelpers::JumpList notPresentInTable;
4978+
49784979
m_jit.loadPtr(MacroAssembler::Address(mapGPR, HashMapImpl<HashMapBucket<HashMapBucketDataKey>>::offsetOfBuffer()), bufferGPR);
4980+
notPresentInTable.append(m_jit.branchTestPtr(CCallHelpers::Zero, bufferGPR));
4981+
m_jit.load32(MacroAssembler::Address(mapGPR, HashMapImpl<HashMapBucket<HashMapBucketDataKey>>::offsetOfCapacity()), maskGPR);
49794982
m_jit.sub32(TrustedImm32(1), maskGPR);
49804983
m_jit.move(hashGPR, indexGPR);
49814984

@@ -4987,8 +4990,8 @@ void SpeculativeJIT::compile(Node* node)
49874990
m_jit.and32(maskGPR, indexGPR);
49884991
m_jit.loadPtr(MacroAssembler::BaseIndex(bufferGPR, indexGPR, MacroAssembler::TimesEight), bucketGPR);
49894992
m_jit.move(bucketGPR, resultGPR);
4990-
auto notPresentInTable = m_jit.branchPtr(MacroAssembler::Equal,
4991-
bucketGPR, TrustedImmPtr(bitwise_cast<size_t>(HashMapImpl<HashMapBucket<HashMapBucketDataKey>>::emptyValue())));
4993+
notPresentInTable.append(m_jit.branchPtr(MacroAssembler::Equal,
4994+
bucketGPR, TrustedImmPtr(bitwise_cast<size_t>(HashMapImpl<HashMapBucket<HashMapBucketDataKey>>::emptyValue()))));
49924995
loopAround.append(m_jit.branchPtr(MacroAssembler::Equal,
49934996
bucketGPR, TrustedImmPtr(bitwise_cast<size_t>(HashMapImpl<HashMapBucket<HashMapBucketDataKey>>::deletedValue()))));
49944997

modules/javafx.web/src/main/native/Source/JavaScriptCore/ftl/FTLLowerDFGToB3.cpp

+5-3
Original file line numberDiff line numberDiff line change
@@ -12322,6 +12322,7 @@ IGNORE_CLANG_WARNINGS_END
1232212322
void compileGetMapBucket()
1232312323
{
1232412324
JSGlobalObject* globalObject = m_graph.globalObjectFor(m_origin.semantic);
12325+
LBasicBlock indexSetUp = m_out.newBlock();
1232512326
LBasicBlock loopStart = m_out.newBlock();
1232612327
LBasicBlock loopAround = m_out.newBlock();
1232712328
LBasicBlock slowPath = m_out.newBlock();
@@ -12330,8 +12331,6 @@ IGNORE_CLANG_WARNINGS_END
1233012331
LBasicBlock notDeletedValue = m_out.newBlock();
1233112332
LBasicBlock continuation = m_out.newBlock();
1233212333

12333-
LBasicBlock lastNext = m_out.insertNewBlocksBefore(loopStart);
12334-
1233512334
LValue map;
1233612335
if (m_node->child1().useKind() == MapObjectUse)
1233712336
map = lowMapObject(m_node->child1());
@@ -12347,8 +12346,11 @@ IGNORE_CLANG_WARNINGS_END
1234712346
LValue hash = lowInt32(m_node->child3());
1234812347

1234912348
LValue buffer = m_out.loadPtr(map, m_heaps.HashMapImpl_buffer);
12350-
LValue mask = m_out.sub(m_out.load32(map, m_heaps.HashMapImpl_capacity), m_out.int32One);
1235112349

12350+
m_out.branch(m_out.isNull(buffer), unsure(notPresentInTable), unsure(indexSetUp));
12351+
12352+
LBasicBlock lastNext = m_out.appendTo(indexSetUp, loopStart);
12353+
LValue mask = m_out.sub(m_out.load32(map, m_heaps.HashMapImpl_capacity), m_out.int32One);
1235212354
ValueFromBlock indexStart = m_out.anchor(hash);
1235312355
m_out.jump(loopStart);
1235412356

modules/javafx.web/src/main/native/Source/JavaScriptCore/inspector/remote/RemoteInspector.h

+1
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@ class JS_EXPORT_PRIVATE RemoteInspector final
9393
Vector<std::pair<String, String>> certificates;
9494
struct Proxy {
9595
String type;
96+
std::optional<String> autoconfigURL;
9697
std::optional<String> ftpURL;
9798
std::optional<String> httpURL;
9899
std::optional<String> httpsURL;

modules/javafx.web/src/main/native/Source/JavaScriptCore/runtime/AbstractModuleRecord.cpp

+1-5
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,6 @@ AbstractModuleRecord::AbstractModuleRecord(VM& vm, Structure* structure, const I
5151

5252
void AbstractModuleRecord::finishCreation(JSGlobalObject* globalObject, VM& vm)
5353
{
54-
DeferTerminationForAWhile deferScope(vm);
55-
auto scope = DECLARE_CATCH_SCOPE(vm);
56-
5754
Base::finishCreation(vm);
5855
ASSERT(inherits(vm, info()));
5956

@@ -62,8 +59,7 @@ void AbstractModuleRecord::finishCreation(JSGlobalObject* globalObject, VM& vm)
6259
for (unsigned index = 0; index < values.size(); ++index)
6360
Base::internalField(index).set(vm, this, values[index]);
6461

65-
JSMap* map = JSMap::create(globalObject, vm, globalObject->mapStructure());
66-
scope.releaseAssertNoException();
62+
JSMap* map = JSMap::create(vm, globalObject->mapStructure());
6763
m_dependenciesMap.set(vm, this, map);
6864
putDirect(vm, Identifier::fromString(vm, "dependenciesMap"_s), m_dependenciesMap.get());
6965
}

modules/javafx.web/src/main/native/Source/JavaScriptCore/runtime/HashMapImpl.h

+14-30
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,7 @@ class HashMapBuffer {
209209
return bitwise_cast<BucketType**>(this);
210210
}
211211

212-
static HashMapBuffer* create(JSGlobalObject* globalObject, VM& vm, JSCell*, uint32_t capacity)
212+
static HashMapBuffer* tryCreate(JSGlobalObject* globalObject, VM& vm, uint32_t capacity)
213213
{
214214
auto scope = DECLARE_THROW_SCOPE(vm);
215215
size_t allocationSize = HashMapBuffer::allocationSize(capacity);
@@ -239,7 +239,7 @@ ALWAYS_INLINE uint32_t wangsInt64Hash(uint64_t key);
239239
ALWAYS_INLINE uint32_t jsMapHash(JSBigInt*);
240240
ALWAYS_INLINE uint32_t jsMapHash(JSGlobalObject*, VM&, JSValue);
241241
ALWAYS_INLINE uint32_t shouldShrink(uint32_t capacity, uint32_t keyCount);
242-
ALWAYS_INLINE uint32_t shouldRehashAfterAdd(uint32_t capacity, uint32_t keyCount, uint32_t deleteCount);
242+
ALWAYS_INLINE uint32_t shouldRehash(uint32_t capacity, uint32_t keyCount, uint32_t deleteCount);
243243
ALWAYS_INLINE uint32_t nextCapacity(uint32_t capacity, uint32_t keyCount);
244244

245245
template <typename HashMapBucketType>
@@ -256,28 +256,15 @@ class HashMapImpl : public JSNonFinalObject {
256256

257257
HashMapImpl(VM& vm, Structure* structure)
258258
: Base(vm, structure)
259-
, m_keyCount(0)
260-
, m_deleteCount(0)
261-
, m_capacity(4)
262259
{
263260
}
264261

265-
HashMapImpl(VM& vm, Structure* structure, uint32_t sizeHint)
266-
: Base(vm, structure)
267-
, m_keyCount(0)
268-
, m_deleteCount(0)
269-
{
270-
uint32_t capacity = (Checked<uint32_t>(sizeHint) * 2) + 1;
271-
capacity = std::max<uint32_t>(WTF::roundUpToPowerOfTwo(capacity), 4U);
272-
m_capacity = capacity;
273-
}
274-
275262
ALWAYS_INLINE HashMapBucketType** buffer() const
276263
{
277264
return m_buffer->buffer();
278265
}
279266

280-
void finishCreation(JSGlobalObject*, VM&);
267+
void finishCreation(VM&);
281268
void finishCreation(JSGlobalObject*, VM&, HashMapImpl* base);
282269

283270
static HashMapBucketType* emptyValue()
@@ -320,7 +307,7 @@ class HashMapImpl : public JSNonFinalObject {
320307
return m_keyCount;
321308
}
322309

323-
ALWAYS_INLINE void clear(JSGlobalObject*);
310+
ALWAYS_INLINE void clear(VM&);
324311

325312
ALWAYS_INLINE size_t bufferSizeInBytes() const
326313
{
@@ -355,42 +342,39 @@ class HashMapImpl : public JSNonFinalObject {
355342
}
356343

357344
private:
358-
ALWAYS_INLINE uint32_t shouldRehashAfterAdd() const
359-
{
360-
return JSC::shouldRehashAfterAdd(m_capacity, m_keyCount, m_deleteCount);
361-
}
362-
363345
ALWAYS_INLINE uint32_t shouldShrink() const
364346
{
365347
return JSC::shouldShrink(m_capacity, m_keyCount);
366348
}
367349

368-
ALWAYS_INLINE void setUpHeadAndTail(JSGlobalObject*, VM&);
350+
ALWAYS_INLINE void setUpHeadAndTail(VM&);
369351

370352
ALWAYS_INLINE void addNormalizedNonExistingForCloning(JSGlobalObject*, JSValue key, JSValue = JSValue());
353+
ALWAYS_INLINE HashMapBucketType* addNormalizedNonExistingForCloningInternal(JSGlobalObject*, JSValue key, JSValue, uint32_t hash);
371354

372355
template<typename CanUseBucket>
373356
ALWAYS_INLINE void addNormalizedInternal(JSGlobalObject*, JSValue key, JSValue, const CanUseBucket&);
374357

375358
template<typename CanUseBucket>
376-
ALWAYS_INLINE HashMapBucketType* addNormalizedInternal(VM&, JSValue key, JSValue, uint32_t hash, const CanUseBucket&);
359+
ALWAYS_INLINE HashMapBucketType* addNormalizedInternal(JSGlobalObject*, JSValue key, JSValue, uint32_t hash, const CanUseBucket&);
377360

378361
ALWAYS_INLINE HashMapBucketType** findBucketAlreadyHashedAndNormalized(JSGlobalObject*, JSValue key, uint32_t hash);
379362

380-
void rehash(JSGlobalObject*);
363+
enum class RehashMode { BeforeAddition, AfterRemoval };
364+
void rehash(JSGlobalObject*, RehashMode);
381365

382366
ALWAYS_INLINE void checkConsistency() const;
383367

384-
void makeAndSetNewBuffer(JSGlobalObject*, VM&);
368+
void makeAndSetNewBuffer(JSGlobalObject*, uint32_t newCapacity, VM&);
385369

386-
ALWAYS_INLINE void assertBufferIsEmpty() const;
370+
ALWAYS_INLINE static void assertBufferIsEmpty(HashMapBucketType**, uint32_t capacity);
387371

388372
WriteBarrier<HashMapBucketType> m_head;
389373
WriteBarrier<HashMapBucketType> m_tail;
390374
AuxiliaryBarrier<HashMapBufferType*> m_buffer;
391-
uint32_t m_keyCount;
392-
uint32_t m_deleteCount;
393-
uint32_t m_capacity;
375+
uint32_t m_keyCount { 0 };
376+
uint32_t m_deleteCount { 0 };
377+
uint32_t m_capacity { 0 };
394378
};
395379

396380
} // namespace JSC

0 commit comments

Comments
 (0)