Skip to content

Commit 7f29117

Browse files
committed
deps: patch V8 to 7.4.288.21
Refs: v8/v8@7.4.288.18...7.4.288.21 PR-URL: #27265 Reviewed-By: Ruben Bridgewater <[email protected]> Reviewed-By: Michaël Zasso <[email protected]> Reviewed-By: Colin Ihrig <[email protected]>
1 parent a7d7d4d commit 7f29117

9 files changed

+129
-83
lines changed

deps/v8/include/v8-version.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
#define V8_MAJOR_VERSION 7
1212
#define V8_MINOR_VERSION 4
1313
#define V8_BUILD_NUMBER 288
14-
#define V8_PATCH_LEVEL 18
14+
#define V8_PATCH_LEVEL 21
1515

1616
// Use 1 for candidates and 0 otherwise.
1717
// (Boolean macro values are not supported by all preprocessors.)

deps/v8/src/arm/macro-assembler-arm.cc

+11-12
Original file line numberDiff line numberDiff line change
@@ -332,31 +332,30 @@ void TurboAssembler::LoadCodeObjectEntry(Register destination,
332332

333333
if (options().isolate_independent_code) {
334334
DCHECK(root_array_available());
335-
Label if_code_is_builtin, out;
335+
Label if_code_is_off_heap, out;
336336

337337
UseScratchRegisterScope temps(this);
338338
Register scratch = temps.Acquire();
339339

340340
DCHECK(!AreAliased(destination, scratch));
341341
DCHECK(!AreAliased(code_object, scratch));
342342

343-
// Check whether the Code object is a builtin. If so, call its (off-heap)
344-
// entry point directly without going through the (on-heap) trampoline.
345-
// Otherwise, just call the Code object as always.
343+
// Check whether the Code object is an off-heap trampoline. If so, call its
344+
// (off-heap) entry point directly without going through the (on-heap)
345+
// trampoline. Otherwise, just call the Code object as always.
346+
ldr(scratch, FieldMemOperand(code_object, Code::kFlagsOffset));
347+
tst(scratch, Operand(Code::IsOffHeapTrampoline::kMask));
348+
b(ne, &if_code_is_off_heap);
346349

347-
ldr(scratch, FieldMemOperand(code_object, Code::kBuiltinIndexOffset));
348-
cmp(scratch, Operand(Builtins::kNoBuiltinId));
349-
b(ne, &if_code_is_builtin);
350-
351-
// A non-builtin Code object, the entry point is at
350+
// Not an off-heap trampoline, the entry point is at
352351
// Code::raw_instruction_start().
353352
add(destination, code_object, Operand(Code::kHeaderSize - kHeapObjectTag));
354353
jmp(&out);
355354

356-
// A builtin Code object, the entry point is loaded from the builtin entry
355+
// An off-heap trampoline, the entry point is loaded from the builtin entry
357356
// table.
358-
// The builtin index is loaded in scratch.
359-
bind(&if_code_is_builtin);
357+
bind(&if_code_is_off_heap);
358+
ldr(scratch, FieldMemOperand(code_object, Code::kBuiltinIndexOffset));
360359
lsl(destination, scratch, Operand(kSystemPointerSizeLog2));
361360
add(destination, destination, kRootRegister);
362361
ldr(destination,

deps/v8/src/arm64/macro-assembler-arm64.cc

+11-11
Original file line numberDiff line numberDiff line change
@@ -2054,31 +2054,31 @@ void TurboAssembler::LoadCodeObjectEntry(Register destination,
20542054

20552055
if (options().isolate_independent_code) {
20562056
DCHECK(root_array_available());
2057-
Label if_code_is_builtin, out;
2057+
Label if_code_is_off_heap, out;
20582058

20592059
UseScratchRegisterScope temps(this);
20602060
Register scratch = temps.AcquireX();
20612061

20622062
DCHECK(!AreAliased(destination, scratch));
20632063
DCHECK(!AreAliased(code_object, scratch));
20642064

2065-
// Check whether the Code object is a builtin. If so, call its (off-heap)
2066-
// entry point directly without going through the (on-heap) trampoline.
2067-
// Otherwise, just call the Code object as always.
2065+
// Check whether the Code object is an off-heap trampoline. If so, call its
2066+
// (off-heap) entry point directly without going through the (on-heap)
2067+
// trampoline. Otherwise, just call the Code object as always.
20682068

2069-
Ldrsw(scratch, FieldMemOperand(code_object, Code::kBuiltinIndexOffset));
2070-
Cmp(scratch, Operand(Builtins::kNoBuiltinId));
2071-
B(ne, &if_code_is_builtin);
2069+
Ldrsw(scratch, FieldMemOperand(code_object, Code::kFlagsOffset));
2070+
Tst(scratch, Operand(Code::IsOffHeapTrampoline::kMask));
2071+
B(ne, &if_code_is_off_heap);
20722072

2073-
// A non-builtin Code object, the entry point is at
2073+
// Not an off-heap trampoline object, the entry point is at
20742074
// Code::raw_instruction_start().
20752075
Add(destination, code_object, Code::kHeaderSize - kHeapObjectTag);
20762076
B(&out);
20772077

2078-
// A builtin Code object, the entry point is loaded from the builtin entry
2078+
// An off-heap trampoline, the entry point is loaded from the builtin entry
20792079
// table.
2080-
// The builtin index is loaded in scratch.
2081-
bind(&if_code_is_builtin);
2080+
bind(&if_code_is_off_heap);
2081+
Ldrsw(scratch, FieldMemOperand(code_object, Code::kBuiltinIndexOffset));
20822082
Lsl(destination, scratch, kSystemPointerSizeLog2);
20832083
Add(destination, destination, kRootRegister);
20842084
Ldr(destination,

deps/v8/src/ia32/macro-assembler-ia32.cc

+10-10
Original file line numberDiff line numberDiff line change
@@ -1905,24 +1905,24 @@ void TurboAssembler::LoadCodeObjectEntry(Register destination,
19051905

19061906
if (options().isolate_independent_code) {
19071907
DCHECK(root_array_available());
1908-
Label if_code_is_builtin, out;
1908+
Label if_code_is_off_heap, out;
19091909

1910-
// Check whether the Code object is a builtin. If so, call its (off-heap)
1911-
// entry point directly without going through the (on-heap) trampoline.
1912-
// Otherwise, just call the Code object as always.
1913-
cmp(FieldOperand(code_object, Code::kBuiltinIndexOffset),
1914-
Immediate(Builtins::kNoBuiltinId));
1915-
j(not_equal, &if_code_is_builtin);
1910+
// Check whether the Code object is an off-heap trampoline. If so, call its
1911+
// (off-heap) entry point directly without going through the (on-heap)
1912+
// trampoline. Otherwise, just call the Code object as always.
1913+
test(FieldOperand(code_object, Code::kFlagsOffset),
1914+
Immediate(Code::IsOffHeapTrampoline::kMask));
1915+
j(not_equal, &if_code_is_off_heap);
19161916

1917-
// A non-builtin Code object, the entry point is at
1917+
// Not an off-heap trampoline, the entry point is at
19181918
// Code::raw_instruction_start().
19191919
Move(destination, code_object);
19201920
add(destination, Immediate(Code::kHeaderSize - kHeapObjectTag));
19211921
jmp(&out);
19221922

1923-
// A builtin Code object, the entry point is loaded from the builtin entry
1923+
// An off-heap trampoline, the entry point is loaded from the builtin entry
19241924
// table.
1925-
bind(&if_code_is_builtin);
1925+
bind(&if_code_is_off_heap);
19261926
mov(destination, FieldOperand(code_object, Code::kBuiltinIndexOffset));
19271927
mov(destination,
19281928
Operand(kRootRegister, destination, times_system_pointer_size,

deps/v8/src/wasm/module-compiler.cc

+53-38
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,8 @@ class CompilationStateImpl {
129129
void SetNumberOfFunctionsToCompile(int num_functions);
130130

131131
// Add the callback function to be called on compilation events. Needs to be
132-
// set before {AddCompilationUnits} is run.
132+
// set before {AddCompilationUnits} is run to ensure that it receives all
133+
// events. The callback object must support being deleted from any thread.
133134
void AddCallback(CompilationState::callback_t);
134135

135136
// Inserts new functions to compile and kicks off compilation.
@@ -153,7 +154,7 @@ class CompilationStateImpl {
153154
}
154155

155156
bool baseline_compilation_finished() const {
156-
base::MutexGuard guard(&mutex_);
157+
base::MutexGuard guard(&callbacks_mutex_);
157158
return outstanding_baseline_units_ == 0 ||
158159
(compile_mode_ == CompileMode::kTiering &&
159160
outstanding_tiering_units_ == 0);
@@ -203,8 +204,6 @@ class CompilationStateImpl {
203204
: func_index(func_index), error(std::move(error)) {}
204205
};
205206

206-
void NotifyOnEvent(CompilationEvent event);
207-
208207
NativeModule* const native_module_;
209208
const std::shared_ptr<BackgroundCompileToken> background_compile_token_;
210209
const CompileMode compile_mode_;
@@ -236,16 +235,26 @@ class CompilationStateImpl {
236235
// compiling.
237236
std::shared_ptr<WireBytesStorage> wire_bytes_storage_;
238237

239-
int outstanding_baseline_units_ = 0;
240-
int outstanding_tiering_units_ = 0;
241-
242238
// End of fields protected by {mutex_}.
243239
//////////////////////////////////////////////////////////////////////////////
244240

245-
// Callback functions to be called on compilation events. Only accessible from
246-
// the foreground thread.
241+
// This mutex protects the callbacks vector, and the counters used to
242+
// determine which callbacks to call. The counters plus the callbacks
243+
// themselves need to be synchronized to ensure correct order of events.
244+
mutable base::Mutex callbacks_mutex_;
245+
246+
//////////////////////////////////////////////////////////////////////////////
247+
// Protected by {callbacks_mutex_}:
248+
249+
// Callback functions to be called on compilation events.
247250
std::vector<CompilationState::callback_t> callbacks_;
248251

252+
int outstanding_baseline_units_ = 0;
253+
int outstanding_tiering_units_ = 0;
254+
255+
// End of fields protected by {callbacks_mutex_}.
256+
//////////////////////////////////////////////////////////////////////////////
257+
249258
const int max_background_tasks_ = 0;
250259
};
251260

@@ -852,6 +861,7 @@ std::shared_ptr<StreamingDecoder> AsyncCompileJob::CreateStreamingDecoder() {
852861
}
853862

854863
AsyncCompileJob::~AsyncCompileJob() {
864+
// Note: This destructor always runs on the foreground thread of the isolate.
855865
background_task_manager_.CancelAndWait();
856866
// If the runtime objects were not created yet, then initial compilation did
857867
// not finish yet. In this case we can abort compilation.
@@ -1473,12 +1483,13 @@ CompilationStateImpl::~CompilationStateImpl() {
14731483
void CompilationStateImpl::AbortCompilation() {
14741484
background_compile_token_->Cancel();
14751485
// No more callbacks after abort.
1486+
base::MutexGuard callbacks_guard(&callbacks_mutex_);
14761487
callbacks_.clear();
14771488
}
14781489

14791490
void CompilationStateImpl::SetNumberOfFunctionsToCompile(int num_functions) {
14801491
DCHECK(!failed());
1481-
base::MutexGuard guard(&mutex_);
1492+
base::MutexGuard guard(&callbacks_mutex_);
14821493
outstanding_baseline_units_ = num_functions;
14831494

14841495
if (compile_mode_ == CompileMode::kTiering) {
@@ -1487,6 +1498,7 @@ void CompilationStateImpl::SetNumberOfFunctionsToCompile(int num_functions) {
14871498
}
14881499

14891500
void CompilationStateImpl::AddCallback(CompilationState::callback_t callback) {
1501+
base::MutexGuard callbacks_guard(&callbacks_mutex_);
14901502
callbacks_.emplace_back(std::move(callback));
14911503
}
14921504

@@ -1536,7 +1548,7 @@ CompilationStateImpl::GetNextCompilationUnit() {
15361548

15371549
void CompilationStateImpl::OnFinishedUnit(ExecutionTier tier, WasmCode* code) {
15381550
// This mutex guarantees that events happen in the right order.
1539-
base::MutexGuard guard(&mutex_);
1551+
base::MutexGuard guard(&callbacks_mutex_);
15401552

15411553
// If we are *not* compiling in tiering mode, then all units are counted as
15421554
// baseline units.
@@ -1547,28 +1559,36 @@ void CompilationStateImpl::OnFinishedUnit(ExecutionTier tier, WasmCode* code) {
15471559
// tiering units.
15481560
DCHECK_IMPLIES(!is_tiering_mode, outstanding_tiering_units_ == 0);
15491561

1562+
bool baseline_finished = false;
1563+
bool tiering_finished = false;
15501564
if (is_tiering_unit) {
15511565
DCHECK_LT(0, outstanding_tiering_units_);
15521566
--outstanding_tiering_units_;
1553-
if (outstanding_tiering_units_ == 0) {
1554-
// If baseline compilation has not finished yet, then also trigger
1555-
// {kFinishedBaselineCompilation}.
1556-
if (outstanding_baseline_units_ > 0) {
1557-
NotifyOnEvent(CompilationEvent::kFinishedBaselineCompilation);
1558-
}
1559-
NotifyOnEvent(CompilationEvent::kFinishedTopTierCompilation);
1560-
}
1567+
tiering_finished = outstanding_tiering_units_ == 0;
1568+
// If baseline compilation has not finished yet, then also trigger
1569+
// {kFinishedBaselineCompilation}.
1570+
baseline_finished = tiering_finished && outstanding_baseline_units_ > 0;
15611571
} else {
15621572
DCHECK_LT(0, outstanding_baseline_units_);
15631573
--outstanding_baseline_units_;
1564-
if (outstanding_baseline_units_ == 0) {
1565-
NotifyOnEvent(CompilationEvent::kFinishedBaselineCompilation);
1566-
// If we are not tiering, then we also trigger the "top tier finished"
1567-
// event when baseline compilation is finished.
1568-
if (!is_tiering_mode) {
1569-
NotifyOnEvent(CompilationEvent::kFinishedTopTierCompilation);
1570-
}
1571-
}
1574+
// If we are in tiering mode and tiering finished before, then do not
1575+
// trigger baseline finished.
1576+
baseline_finished = outstanding_baseline_units_ == 0 &&
1577+
(!is_tiering_mode || outstanding_tiering_units_ > 0);
1578+
// If we are not tiering, then we also trigger the "top tier finished"
1579+
// event when baseline compilation is finished.
1580+
tiering_finished = baseline_finished && !is_tiering_mode;
1581+
}
1582+
1583+
if (baseline_finished) {
1584+
for (auto& callback : callbacks_)
1585+
callback(CompilationEvent::kFinishedBaselineCompilation);
1586+
}
1587+
if (tiering_finished) {
1588+
for (auto& callback : callbacks_)
1589+
callback(CompilationEvent::kFinishedTopTierCompilation);
1590+
// Clear the callbacks because no more events will be delivered.
1591+
callbacks_.clear();
15721592
}
15731593

15741594
if (code != nullptr) native_module_->engine()->LogCode(code);
@@ -1648,17 +1668,12 @@ void CompilationStateImpl::SetError(uint32_t func_index,
16481668
if (!set) return;
16491669
// If set successfully, give up ownership.
16501670
compile_error.release();
1651-
// Schedule a foreground task to call the callback and notify users about the
1652-
// compile error.
1653-
NotifyOnEvent(CompilationEvent::kFailedCompilation);
1654-
}
1655-
1656-
void CompilationStateImpl::NotifyOnEvent(CompilationEvent event) {
1657-
for (auto& callback : callbacks_) callback(event);
1658-
// If no more events are expected after this one, clear the callbacks to free
1659-
// memory. We can safely do this here, as this method is only called from
1660-
// foreground tasks.
1661-
if (event >= CompilationEvent::kFirstFinalEvent) callbacks_.clear();
1671+
base::MutexGuard callbacks_guard(&callbacks_mutex_);
1672+
for (auto& callback : callbacks_) {
1673+
callback(CompilationEvent::kFailedCompilation);
1674+
}
1675+
// No more callbacks after an error.
1676+
callbacks_.clear();
16621677
}
16631678

16641679
void CompileJsToWasmWrappers(Isolate* isolate, const WasmModule* module,

deps/v8/src/x64/macro-assembler-x64.cc

+10-10
Original file line numberDiff line numberDiff line change
@@ -1588,24 +1588,24 @@ void TurboAssembler::LoadCodeObjectEntry(Register destination,
15881588

15891589
if (options().isolate_independent_code) {
15901590
DCHECK(root_array_available());
1591-
Label if_code_is_builtin, out;
1591+
Label if_code_is_off_heap, out;
15921592

1593-
// Check whether the Code object is a builtin. If so, call its (off-heap)
1594-
// entry point directly without going through the (on-heap) trampoline.
1595-
// Otherwise, just call the Code object as always.
1596-
cmpl(FieldOperand(code_object, Code::kBuiltinIndexOffset),
1597-
Immediate(Builtins::kNoBuiltinId));
1598-
j(not_equal, &if_code_is_builtin);
1593+
// Check whether the Code object is an off-heap trampoline. If so, call its
1594+
// (off-heap) entry point directly without going through the (on-heap)
1595+
// trampoline. Otherwise, just call the Code object as always.
1596+
testl(FieldOperand(code_object, Code::kFlagsOffset),
1597+
Immediate(Code::IsOffHeapTrampoline::kMask));
1598+
j(not_equal, &if_code_is_off_heap);
15991599

1600-
// A non-builtin Code object, the entry point is at
1600+
// Not an off-heap trampoline, the entry point is at
16011601
// Code::raw_instruction_start().
16021602
Move(destination, code_object);
16031603
addq(destination, Immediate(Code::kHeaderSize - kHeapObjectTag));
16041604
jmp(&out);
16051605

1606-
// A builtin Code object, the entry point is loaded from the builtin entry
1606+
// An off-heap trampoline, the entry point is loaded from the builtin entry
16071607
// table.
1608-
bind(&if_code_is_builtin);
1608+
bind(&if_code_is_off_heap);
16091609
movl(destination, FieldOperand(code_object, Code::kBuiltinIndexOffset));
16101610
movq(destination,
16111611
Operand(kRootRegister, destination, times_system_pointer_size,

deps/v8/src/zone/accounting-allocator.cc

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ Segment* AccountingAllocator::AllocateSegment(size_t bytes) {
2424
if (memory == nullptr) return nullptr;
2525

2626
size_t current =
27-
current_memory_usage_.fetch_add(bytes, std::memory_order_relaxed);
27+
current_memory_usage_.fetch_add(bytes, std::memory_order_relaxed) + bytes;
2828
size_t max = max_memory_usage_.load(std::memory_order_relaxed);
2929
while (current > max && !max_memory_usage_.compare_exchange_weak(
3030
max, current, std::memory_order_relaxed)) {

deps/v8/test/cctest/cctest.status

+4
Original file line numberDiff line numberDiff line change
@@ -615,6 +615,10 @@
615615
'test-run-wasm-exceptions/RunWasmTurbofan_TryCatchThrow': [SKIP],
616616
'test-run-wasm-exceptions/RunWasmTurbofan_TryCatchTrapTypeError': [SKIP],
617617

618+
# --interpreted-frames-native-stack tests
619+
'test-log/ExternalCodeEventListenerWithInterpretedFramesNativeStack': [SKIP],
620+
'test-log/LogInterpretedFramesNativeStack': [SKIP],
621+
618622
# Crashes on native arm.
619623
'test-macro-assembler-arm/ExtractLane': [PASS, ['arch == arm and not simulator_run', SKIP]],
620624
'test-macro-assembler-arm/LoadAndStoreWithRepresentation': [PASS, ['arch == arm and not simulator_run', SKIP]],

deps/v8/test/cctest/test-allocation.cc

+28
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,34 @@ TEST(AccountingAllocatorOOM) {
105105
CHECK_EQ(result == nullptr, platform.oom_callback_called);
106106
}
107107

108+
TEST(AccountingAllocatorCurrentAndMax) {
109+
AllocationPlatform platform;
110+
v8::internal::AccountingAllocator allocator;
111+
static constexpr size_t kAllocationSizes[] = {51, 231, 27};
112+
std::vector<v8::internal::Segment*> segments;
113+
CHECK_EQ(0, allocator.GetCurrentMemoryUsage());
114+
CHECK_EQ(0, allocator.GetMaxMemoryUsage());
115+
size_t expected_current = 0;
116+
size_t expected_max = 0;
117+
for (size_t size : kAllocationSizes) {
118+
segments.push_back(allocator.AllocateSegment(size));
119+
CHECK_NOT_NULL(segments.back());
120+
CHECK_EQ(size, segments.back()->total_size());
121+
expected_current += size;
122+
if (expected_current > expected_max) expected_max = expected_current;
123+
CHECK_EQ(expected_current, allocator.GetCurrentMemoryUsage());
124+
CHECK_EQ(expected_max, allocator.GetMaxMemoryUsage());
125+
}
126+
for (auto* segment : segments) {
127+
expected_current -= segment->total_size();
128+
allocator.ReturnSegment(segment);
129+
CHECK_EQ(expected_current, allocator.GetCurrentMemoryUsage());
130+
}
131+
CHECK_EQ(expected_max, allocator.GetMaxMemoryUsage());
132+
CHECK_EQ(0, allocator.GetCurrentMemoryUsage());
133+
CHECK(!platform.oom_callback_called);
134+
}
135+
108136
TEST(MallocedOperatorNewOOM) {
109137
AllocationPlatform platform;
110138
CHECK(!platform.oom_callback_called);

0 commit comments

Comments
 (0)