Skip to content

Commit 8d336ff

Browse files
addaleaxBethGriggs
authored andcommitted
deps,src: patch V8 to be API/ABI compatible with 7.4 (from 7.8)
deps: revert 2ac8bb719 from upstream V8 Original commit message: profiler: Allow querying SnapshotObjectId for native objects - Adds regular native heap entries to the HeapObjectsMap. - Adds a side map for keeping a mapping of native objects to their canonical heap entry that they have been merged into. Change-Id: Ida00628126ded1948ceb2a0cbe14da817af7f361 Bug: chromium:988350 Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1720810 Commit-Queue: Michael Lippautz <[email protected]> Reviewed-by: Alexei Filippov <[email protected]> Reviewed-by: Ulan Degenbaev <[email protected]> Cr-Commit-Position: refs/heads/master@{#63140} Refs: v8/v8@2ac8bb7 [The `SuppressMicrotaskExecutionScope` hack only works because the constructor that allows specifying an alternative microtask queue was never actually implemented.] deps: revert fb698cec37 from upstream V8 Original commit message: [isolate-data] Move hot fields closer to isolate_root In generated code, we access fields inside IsolateData through the root-register. On some platforms it is significantly cheaper to access things that are close to the root-register value than things that are located far away. The motivation for this CL was a 5% difference in Octane/Mandreel scores between // Part of the stack check. cmpq rsp,[r13+0x9ea8] and cmpq rsp,[r13-0x30] // Mandreel score improved by 5%. This moves the StackGuard up to fix Mandreel. As a drive-by, also move two more fields up that are accessed by each CallCFunction. Tbr: [email protected] Bug: v8:9534,chromium:993264 Change-Id: I5418b63d40274a138e285fa3c99b96e33a814fb1 Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1751345 Reviewed-by: Jakob Gruber <[email protected]> Reviewed-by: Yang Guo <[email protected]> Auto-Submit: Jakob Gruber <[email protected]> Commit-Queue: Yang Guo <[email protected]> Cr-Commit-Position: refs/heads/master@{#63187} Refs: v8/v8@fb698ce src: re-add flags removed in V8 7.8 as no-ops PR-URL: #30109 Reviewed-By: Myles Borins <[email protected]>
1 parent b335529 commit 8d336ff

20 files changed

+113
-337
lines changed

‎common.gypi‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838

3939
# Reset this number to 0 on major V8 upgrades.
4040
# Increment by one for each non-official patch applied to deps/v8.
41-
'v8_embedder_string': '-node.20',
41+
'v8_embedder_string': '-node.21',
4242

4343
##### V8 defaults for Node.js #####
4444

‎deps/v8/include/v8-internal.h‎

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -152,22 +152,15 @@ class Internals{
152152

153153
staticconstuint32_tkNumIsolateDataSlots = 4;
154154

155-
// IsolateData layout guarantees.
156155
staticconstintkIsolateEmbedderDataOffset = 0;
157156
staticconstintkExternalMemoryOffset =
158157
kNumIsolateDataSlots * kApiSystemPointerSize;
159158
staticconstintkExternalMemoryLimitOffset =
160159
kExternalMemoryOffset + kApiInt64Size;
161160
staticconstintkExternalMemoryAtLastMarkCompactOffset =
162161
kExternalMemoryLimitOffset + kApiInt64Size;
163-
staticconstintkIsolateFastCCallCallerFpOffset =
164-
kExternalMemoryAtLastMarkCompactOffset + kApiInt64Size;
165-
staticconstintkIsolateFastCCallCallerPcOffset =
166-
kIsolateFastCCallCallerFpOffset + kApiSystemPointerSize;
167-
staticconstintkIsolateStackGuardOffset =
168-
kIsolateFastCCallCallerPcOffset + kApiSystemPointerSize;
169162
staticconstintkIsolateRootsOffset =
170-
kIsolateStackGuardOffset + 7 * kApiSystemPointerSize;
163+
kExternalMemoryAtLastMarkCompactOffset + kApiInt64Size;
171164

172165
staticconstintkUndefinedValueRootIndex = 4;
173166
staticconstintkTheHoleValueRootIndex = 5;
@@ -186,7 +179,7 @@ class Internals{
186179

187180
staticconstintkFirstNonstringType = 0x40;
188181
staticconstintkOddballType = 0x43;
189-
staticconstintkForeignType = 0x46;
182+
staticconstintkForeignType = 0x47;
190183
staticconstintkJSSpecialApiObjectType = 0x410;
191184
staticconstintkJSApiObjectType = 0x420;
192185
staticconstintkJSObjectType = 0x421;

‎deps/v8/include/v8-platform.h‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -439,6 +439,14 @@ class Platform{
439439
*/
440440
virtualvoidDumpWithoutCrashing(){}
441441

442+
/**
443+
* Lets the embedder to add crash keys.
444+
*/
445+
virtualvoidAddCrashKey(int id, constchar* name, uintptr_t value){
446+
// "noop" is a valid implementation if the embedder doesn't care to log
447+
// additional data for crashes.
448+
}
449+
442450
protected:
443451
/**
444452
* Default implementation of current wall-clock time in milliseconds

‎deps/v8/include/v8-profiler.h‎

Lines changed: 9 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ namespace v8{
1818
classHeapGraphNode;
1919
structHeapStatsUpdate;
2020

21-
using NativeObject = void*;
22-
using SnapshotObjectId = uint32_t;
21+
typedefuint32_t SnapshotObjectId;
22+
2323

2424
structCpuProfileDeoptFrame{
2525
int script_id;
@@ -272,10 +272,12 @@ class V8_EXPORT CpuProfilingOptions{
272272
* zero, the sampling interval will be equal to
273273
* the profiler's sampling interval.
274274
*/
275-
CpuProfilingOptions(
276-
CpuProfilingMode mode = kLeafNodeLineNumbers,
277-
unsigned max_samples = kNoSampleLimit, int sampling_interval_us = 0,
278-
MaybeLocal<Context> filter_context = MaybeLocal<Context>());
275+
CpuProfilingOptions(CpuProfilingMode mode = kLeafNodeLineNumbers,
276+
unsigned max_samples = kNoSampleLimit,
277+
int sampling_interval_us = 0)
278+
: mode_(mode),
279+
max_samples_(max_samples),
280+
sampling_interval_us_(sampling_interval_us){}
279281

280282
CpuProfilingMode mode() const{return mode_}
281283
unsignedmax_samples() const{return max_samples_}
@@ -284,13 +286,12 @@ class V8_EXPORT CpuProfilingOptions{
284286
private:
285287
friendclassinternal::CpuProfile;
286288

287-
boolhas_filter_context() const{return !filter_context_.IsEmpty()}
289+
boolhas_filter_context() const;
288290
void* raw_filter_context() const;
289291

290292
CpuProfilingMode mode_;
291293
unsigned max_samples_;
292294
int sampling_interval_us_;
293-
CopyablePersistentTraits<Context>::CopyablePersistent filter_context_;
294295
};
295296

296297
/**
@@ -752,12 +753,6 @@ class V8_EXPORT EmbedderGraph{
752753
*/
753754
virtualconstchar* NamePrefix(){returnnullptr}
754755

755-
/**
756-
* Returns the NativeObject that can be used for querying the
757-
* |HeapSnapshot|.
758-
*/
759-
virtual NativeObject GetNativeObject(){returnnullptr}
760-
761756
Node(const Node&) = delete;
762757
Node& operator=(const Node&) = delete;
763758
};
@@ -820,12 +815,6 @@ class V8_EXPORT HeapProfiler{
820815
*/
821816
SnapshotObjectId GetObjectId(Local<Value> value);
822817

823-
/**
824-
* Returns SnapshotObjectId for a native object referenced by |value| if it
825-
* has been seen by the heap profiler, kUnknownObjectId otherwise.
826-
*/
827-
SnapshotObjectId GetObjectId(NativeObject value);
828-
829818
/**
830819
* Returns heap object with given SnapshotObjectId if the object is alive,
831820
* otherwise empty handle is returned.

‎deps/v8/include/v8.h‎

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2094,7 +2094,6 @@ struct SampleInfo{
20942094
StateTag vm_state; // Current VM state.
20952095
void* external_callback_entry; // External callback address if VM is
20962096
// executing an external callback.
2097-
void* top_context; // Incumbent native context address.
20982097
};
20992098

21002099
structMemoryRange{
@@ -7561,9 +7560,8 @@ class V8_EXPORT EmbedderHeapTracer{
75617560
* overriden to fill a |TraceSummary| that is used by V8 to schedule future
75627561
* garbage collections.
75637562
*/
7564-
V8_DEPRECATE_SOON("Use version with parameter.",
7565-
virtualvoidTraceEpilogue()){}
7566-
virtualvoidTraceEpilogue(TraceSummary* trace_summary);
7563+
virtualvoidTraceEpilogue(){}
7564+
virtualvoidTraceEpilogue(TraceSummary* trace_summary){TraceEpilogue()}
75677565

75687566
/**
75697567
* Called upon entering the final marking pause. No more incremental marking
@@ -7835,7 +7833,6 @@ class V8_EXPORT Isolate{
78357833
classV8_EXPORT SuppressMicrotaskExecutionScope{
78367834
public:
78377835
explicitSuppressMicrotaskExecutionScope(Isolate* isolate);
7838-
explicitSuppressMicrotaskExecutionScope(MicrotaskQueue* microtask_queue);
78397836
~SuppressMicrotaskExecutionScope();
78407837

78417838
// Prevent copying of Scope objects.
@@ -7846,8 +7843,13 @@ class V8_EXPORT Isolate{
78467843

78477844
private:
78487845
internal::Isolate* const isolate_;
7849-
internal::MicrotaskQueue* const microtask_queue_;
78507846
internal::Address previous_stack_height_;
7847+
static_assert(sizeof(internal::Address) ==
7848+
sizeof(internal::MicrotaskQueue*) &&
7849+
alignof(internal::Address) ==
7850+
alignof(internal::MicrotaskQueue*),
7851+
"The previous_stack_height_ field can replace the "
7852+
"microtask_queue_ field ABI-wise");
78517853

78527854
friendclassinternal::ThreadLocalTop;
78537855
};

‎deps/v8/src/api/api.cc‎

Lines changed: 6 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -8183,14 +8183,13 @@ Isolate::AllowJavascriptExecutionScope::~AllowJavascriptExecutionScope(){
81838183

81848184
Isolate::SuppressMicrotaskExecutionScope::SuppressMicrotaskExecutionScope(
81858185
Isolate* isolate)
8186-
: isolate_(reinterpret_cast<i::Isolate*>(isolate)),
8187-
microtask_queue_(isolate_->default_microtask_queue()){
8186+
: isolate_(reinterpret_cast<i::Isolate*>(isolate)){
81888187
isolate_->thread_local_top()->IncrementCallDepth(this);
8189-
microtask_queue_->IncrementMicrotasksSuppressions();
8188+
isolate_->default_microtask_queue()->IncrementMicrotasksSuppressions();
81908189
}
81918190

81928191
Isolate::SuppressMicrotaskExecutionScope::~SuppressMicrotaskExecutionScope(){
8193-
microtask_queue_->DecrementMicrotasksSuppressions();
8192+
isolate_->default_microtask_queue()->DecrementMicrotasksSuppressions();
81948193
isolate_->thread_local_top()->DecrementCallDepth(this);
81958194
}
81968195

@@ -9975,25 +9974,12 @@ CpuProfiler* CpuProfiler::New(Isolate* isolate, CpuProfilingNamingMode mode){
99759974
returnNew(isolate, mode, kLazyLogging);
99769975
}
99779976

9978-
CpuProfilingOptions::CpuProfilingOptions(CpuProfilingMode mode,
9979-
unsigned max_samples,
9980-
int sampling_interval_us,
9981-
MaybeLocal<Context> filter_context)
9982-
: mode_(mode),
9983-
max_samples_(max_samples),
9984-
sampling_interval_us_(sampling_interval_us){
9985-
if (!filter_context.IsEmpty()){
9986-
Local<Context> local_filter_context = filter_context.ToLocalChecked();
9987-
filter_context_.Reset(local_filter_context->GetIsolate(),
9988-
local_filter_context);
9989-
}
9977+
boolCpuProfilingOptions::has_filter_context() const{
9978+
returnfalse;
99909979
}
99919980

99929981
void* CpuProfilingOptions::raw_filter_context() const{
9993-
returnreinterpret_cast<void*>(
9994-
i::Context::cast(*Utils::OpenPersistent(filter_context_))
9995-
.native_context()
9996-
.address());
9982+
returnnullptr;
99979983
}
99989984

99999985
voidCpuProfiler::Dispose(){deletereinterpret_cast<i::CpuProfiler*>(this)}
@@ -10265,10 +10251,6 @@ SnapshotObjectId HeapProfiler::GetObjectId(Local<Value> value){
1026510251
returnreinterpret_cast<i::HeapProfiler*>(this)->GetSnapshotObjectId(obj);
1026610252
}
1026710253

10268-
SnapshotObjectId HeapProfiler::GetObjectId(NativeObject value){
10269-
returnreinterpret_cast<i::HeapProfiler*>(this)->GetSnapshotObjectId(value);
10270-
}
10271-
1027210254
Local<Value> HeapProfiler::FindObjectById(SnapshotObjectId id){
1027310255
i::Handle<i::Object> obj =
1027410256
reinterpret_cast<i::HeapProfiler*>(this)->FindHeapObjectById(id);
@@ -10401,17 +10383,6 @@ void EmbedderHeapTracer::TracePrologue(TraceFlags flags){
1040110383
#endif
1040210384
}
1040310385

10404-
voidEmbedderHeapTracer::TraceEpilogue(TraceSummary* trace_summary){
10405-
#if __clang__
10406-
#pragma clang diagnostic push
10407-
#pragma clang diagnostic ignored "-Wdeprecated"
10408-
#endif
10409-
TraceEpilogue();
10410-
#if __clang__
10411-
#pragma clang diagnostic pop
10412-
#endif
10413-
}
10414-
1041510386
voidEmbedderHeapTracer::FinalizeTracing(){
1041610387
if (isolate_){
1041710388
i::Isolate* isolate = reinterpret_cast<i::Isolate*>(isolate_);

‎deps/v8/src/execution/isolate-data.h‎

Lines changed: 15 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -111,27 +111,21 @@ class IsolateData final{
111111
Address* builtins(){return builtins_}
112112

113113
private:
114-
// Static layout definition.
115-
//
116-
// Note: The location of fields within IsolateData is significant. The
117-
// closer they are to the value of kRootRegister (i.e.: isolate_root()), the
118-
// cheaper it is to access them. See also: https://crbug.com/993264.
119-
// The recommend guideline is to put frequently-accessed fields close to the
120-
// beginning of IsolateData.
114+
// Static layout definition.
121115
#defineFIELDS(V) \
122116
V(kEmbedderDataOffset, Internals::kNumIsolateDataSlots* kSystemPointerSize) \
123117
V(kExternalMemoryOffset, kInt64Size) \
124118
V(kExternalMemoryLlimitOffset, kInt64Size) \
125119
V(kExternalMemoryAtLastMarkCompactOffset, kInt64Size) \
126-
V(kFastCCallCallerFPOffset, kSystemPointerSize) \
127-
V(kFastCCallCallerPCOffset, kSystemPointerSize) \
128-
V(kStackGuardOffset, StackGuard::kSizeInBytes) \
129120
V(kRootsTableOffset, RootsTable::kEntriesCount* kSystemPointerSize) \
130121
V(kExternalReferenceTableOffset, ExternalReferenceTable::kSizeInBytes) \
131122
V(kThreadLocalTopOffset, ThreadLocalTop::kSizeInBytes) \
132123
V(kBuiltinEntryTableOffset, Builtins::builtin_count* kSystemPointerSize) \
133124
V(kBuiltinsTableOffset, Builtins::builtin_count* kSystemPointerSize) \
134125
V(kVirtualCallTargetRegisterOffset, kSystemPointerSize) \
126+
V(kFastCCallCallerFPOffset, kSystemPointerSize) \
127+
V(kFastCCallCallerPCOffset, kSystemPointerSize) \
128+
V(kStackGuardOffset, StackGuard::kSizeInBytes) \
135129
V(kStackIsIterableOffset, kUInt8Size) \
136130
/* This padding aligns IsolateData size by 8 bytes. */ \
137131
V(kPaddingOffset, \
@@ -159,17 +153,6 @@ class IsolateData final{
159153
// Caches the amount of external memory registered at the last MC.
160154
int64_t external_memory_at_last_mark_compact_ = 0;
161155

162-
// Stores the state of the caller for TurboAssembler::CallCFunction so that
163-
// the sampling CPU profiler can iterate the stack during such calls. These
164-
// are stored on IsolateData so that they can be stored to with only one move
165-
// instruction in compiled code.
166-
Address fast_c_call_caller_fp_ = kNullAddress;
167-
Address fast_c_call_caller_pc_ = kNullAddress;
168-
169-
// Fields related to the system and JS stack. In particular, this contains the
170-
// stack limit used by stack checks in generated code.
171-
StackGuard stack_guard_;
172-
173156
RootsTable roots_;
174157

175158
ExternalReferenceTable external_reference_table_;
@@ -189,6 +172,17 @@ class IsolateData final{
189172
// ia32 (otherwise the arguments adaptor call runs out of registers).
190173
void* virtual_call_target_register_ = nullptr;
191174

175+
// Stores the state of the caller for TurboAssembler::CallCFunction so that
176+
// the sampling CPU profiler can iterate the stack during such calls. These
177+
// are stored on IsolateData so that they can be stored to with only one move
178+
// instruction in compiled code.
179+
Address fast_c_call_caller_fp_ = kNullAddress;
180+
Address fast_c_call_caller_pc_ = kNullAddress;
181+
182+
// Fields related to the system and JS stack. In particular, this contains the
183+
// stack limit used by stack checks in generated code.
184+
StackGuard stack_guard_;
185+
192186
// Whether the SafeStackFrameIterator can successfully iterate the current
193187
// stack. Only valid values are 0 or 1.
194188
uint8_t stack_is_iterable_ = 1;

‎deps/v8/src/execution/isolate.cc‎

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2924,14 +2924,6 @@ void Isolate::CheckIsolateLayout(){
29242924
CHECK_EQ(OFFSET_OF(Isolate, isolate_data_), 0);
29252925
CHECK_EQ(static_cast<int>(OFFSET_OF(Isolate, isolate_data_.embedder_data_)),
29262926
Internals::kIsolateEmbedderDataOffset);
2927-
CHECK_EQ(static_cast<int>(
2928-
OFFSET_OF(Isolate, isolate_data_.fast_c_call_caller_fp_)),
2929-
Internals::kIsolateFastCCallCallerFpOffset);
2930-
CHECK_EQ(static_cast<int>(
2931-
OFFSET_OF(Isolate, isolate_data_.fast_c_call_caller_pc_)),
2932-
Internals::kIsolateFastCCallCallerPcOffset);
2933-
CHECK_EQ(static_cast<int>(OFFSET_OF(Isolate, isolate_data_.stack_guard_)),
2934-
Internals::kIsolateStackGuardOffset);
29352927
CHECK_EQ(static_cast<int>(OFFSET_OF(Isolate, isolate_data_.roots_)),
29362928
Internals::kIsolateRootsOffset);
29372929
CHECK_EQ(Internals::kExternalMemoryOffset % 8, 0);

‎deps/v8/src/objects/instance-type.h‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,8 +133,8 @@ enum InstanceType : uint16_t{
133133

134134
// "Data", objects that cannot contain non-map-word pointers to heap
135135
// objects.
136-
FOREIGN_TYPE,
137136
BYTE_ARRAY_TYPE,
137+
FOREIGN_TYPE,
138138
BYTECODE_ARRAY_TYPE,
139139
FREE_SPACE_TYPE,
140140
FIXED_DOUBLE_ARRAY_TYPE,

‎deps/v8/src/objects/objects-definitions.h‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,8 @@ namespace internal{
6767
\
6868
V(MAP_TYPE) \
6969
V(CODE_TYPE) \
70-
V(FOREIGN_TYPE) \
7170
V(BYTE_ARRAY_TYPE) \
71+
V(FOREIGN_TYPE) \
7272
V(BYTECODE_ARRAY_TYPE) \
7373
V(FREE_SPACE_TYPE) \
7474
\

0 commit comments

Comments
(0)