Skip to content

Commit a4b2bca

Browse files
committed
feat: Updated V8 to latest version (b1a0dd8503de05b8268d2cad201ed2310084dfe6)
1 parent f745e55 commit a4b2bca

File tree

127 files changed

+7150
-5598
lines changed

Some content is hidden

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

127 files changed

+7150
-5598
lines changed

NativeScript/include/libplatform/libplatform.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@
99

1010
#include "libplatform/libplatform-export.h"
1111
#include "libplatform/v8-tracing.h"
12-
#include "v8-platform.h" // NOLINT(build/include)
13-
#include "v8config.h" // NOLINT(build/include)
12+
#include "v8-platform.h" // NOLINT(build/include_directory)
13+
#include "v8config.h" // NOLINT(build/include_directory)
1414

1515
namespace v8 {
1616
namespace platform {

NativeScript/include/libplatform/v8-tracing.h

+35-21
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,12 @@
1212
#include <vector>
1313

1414
#include "libplatform/libplatform-export.h"
15-
#include "v8-platform.h" // NOLINT(build/include)
15+
#include "v8-platform.h" // NOLINT(build/include_directory)
1616

1717
namespace perfetto {
18+
namespace trace_processor {
19+
class TraceProcessorStorage;
20+
}
1821
class TracingSession;
1922
}
2023

@@ -28,7 +31,6 @@ namespace platform {
2831
namespace tracing {
2932

3033
class TraceEventListener;
31-
class JSONTraceEventListener;
3234

3335
const int kTraceMaxNumArgs = 2;
3436

@@ -197,6 +199,9 @@ class V8_PLATFORM_EXPORT TraceConfig {
197199

198200
TraceConfig() : enable_systrace_(false), enable_argument_filter_(false) {}
199201
TraceRecordMode GetTraceRecordMode() const { return record_mode_; }
202+
const StringList& GetEnabledCategories() const {
203+
return included_categories_;
204+
}
200205
bool IsSystraceEnabled() const { return enable_systrace_; }
201206
bool IsArgumentFilterEnabled() const { return enable_argument_filter_; }
202207

@@ -229,6 +234,17 @@ class V8_PLATFORM_EXPORT TraceConfig {
229234
class V8_PLATFORM_EXPORT TracingController
230235
: public V8_PLATFORM_NON_EXPORTED_BASE(v8::TracingController) {
231236
public:
237+
TracingController();
238+
~TracingController() override;
239+
240+
#if defined(V8_USE_PERFETTO)
241+
// Must be called before StartTracing() if V8_USE_PERFETTO is true. Provides
242+
// the output stream for the JSON trace data.
243+
void InitializeForPerfetto(std::ostream* output_stream);
244+
// Provide an optional listener for testing that will receive trace events.
245+
// Must be called before StartTracing().
246+
void SetTraceEventListenerForTesting(TraceEventListener* listener);
247+
#else // defined(V8_USE_PERFETTO)
232248
// The pointer returned from GetCategoryGroupEnabled() points to a value with
233249
// zero or more of the following bits. Used in this class only. The
234250
// TRACE_EVENT macros should only use the value as a bool. These values must
@@ -242,19 +258,8 @@ class V8_PLATFORM_EXPORT TracingController
242258
ENABLED_FOR_ETW_EXPORT = 1 << 3
243259
};
244260

245-
TracingController();
246-
~TracingController() override;
247-
248261
// Takes ownership of |trace_buffer|.
249262
void Initialize(TraceBuffer* trace_buffer);
250-
#ifdef V8_USE_PERFETTO
251-
// Must be called before StartTracing() if V8_USE_PERFETTO is true. Provides
252-
// the output stream for the JSON trace data.
253-
void InitializeForPerfetto(std::ostream* output_stream);
254-
// Provide an optional listener for testing that will receive trace events.
255-
// Must be called before StartTracing().
256-
void SetTraceEventListenerForTesting(TraceEventListener* listener);
257-
#endif
258263

259264
// v8::TracingController implementation.
260265
const uint8_t* GetCategoryGroupEnabled(const char* category_group) override;
@@ -274,6 +279,10 @@ class V8_PLATFORM_EXPORT TracingController
274279
unsigned int flags, int64_t timestamp) override;
275280
void UpdateTraceEventDuration(const uint8_t* category_enabled_flag,
276281
const char* name, uint64_t handle) override;
282+
283+
static const char* GetCategoryGroupName(const uint8_t* category_enabled_flag);
284+
#endif // !defined(V8_USE_PERFETTO)
285+
277286
void AddTraceStateObserver(
278287
v8::TracingController::TraceStateObserver* observer) override;
279288
void RemoveTraceStateObserver(
@@ -282,27 +291,32 @@ class V8_PLATFORM_EXPORT TracingController
282291
void StartTracing(TraceConfig* trace_config);
283292
void StopTracing();
284293

285-
static const char* GetCategoryGroupName(const uint8_t* category_enabled_flag);
286-
287294
protected:
295+
#if !defined(V8_USE_PERFETTO)
288296
virtual int64_t CurrentTimestampMicroseconds();
289297
virtual int64_t CurrentCpuTimestampMicroseconds();
298+
#endif // !defined(V8_USE_PERFETTO)
290299

291300
private:
301+
#if !defined(V8_USE_PERFETTO)
292302
void UpdateCategoryGroupEnabledFlag(size_t category_index);
293303
void UpdateCategoryGroupEnabledFlags();
304+
#endif // !defined(V8_USE_PERFETTO)
294305

295-
std::unique_ptr<TraceBuffer> trace_buffer_;
296-
std::unique_ptr<TraceConfig> trace_config_;
297306
std::unique_ptr<base::Mutex> mutex_;
298-
std::unordered_set<v8::TracingController::TraceStateObserver*> observers_;
307+
std::unique_ptr<TraceConfig> trace_config_;
299308
std::atomic_bool recording_{false};
300-
#ifdef V8_USE_PERFETTO
309+
std::unordered_set<v8::TracingController::TraceStateObserver*> observers_;
310+
311+
#if defined(V8_USE_PERFETTO)
301312
std::ostream* output_stream_ = nullptr;
302-
std::unique_ptr<JSONTraceEventListener> json_listener_;
313+
std::unique_ptr<perfetto::trace_processor::TraceProcessorStorage>
314+
trace_processor_;
303315
TraceEventListener* listener_for_testing_ = nullptr;
304316
std::unique_ptr<perfetto::TracingSession> tracing_session_;
305-
#endif
317+
#else // !defined(V8_USE_PERFETTO)
318+
std::unique_ptr<TraceBuffer> trace_buffer_;
319+
#endif // !defined(V8_USE_PERFETTO)
306320

307321
// Disallow copy and assign
308322
TracingController(const TracingController&) = delete;

NativeScript/include/v8-inspector.h

+29-29
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
#include <memory>
1212
#include <unordered_map>
1313

14-
#include "v8.h" // NOLINT(build/include)
14+
#include "v8.h" // NOLINT(build/include_directory)
1515

1616
namespace v8_inspector {
1717

@@ -65,15 +65,15 @@ class V8_EXPORT StringView {
6565
class V8_EXPORT StringBuffer {
6666
public:
6767
virtual ~StringBuffer() = default;
68-
virtual const StringView& string() = 0;
68+
virtual StringView string() const = 0;
6969
// This method copies contents.
70-
static std::unique_ptr<StringBuffer> create(const StringView&);
70+
static std::unique_ptr<StringBuffer> create(StringView);
7171
};
7272

7373
class V8_EXPORT V8ContextInfo {
7474
public:
7575
V8ContextInfo(v8::Local<v8::Context> context, int contextGroupId,
76-
const StringView& humanReadableName)
76+
StringView humanReadableName)
7777
: context(context),
7878
contextGroupId(contextGroupId),
7979
humanReadableName(humanReadableName),
@@ -132,37 +132,36 @@ class V8_EXPORT V8InspectorSession {
132132
virtual void addInspectedObject(std::unique_ptr<Inspectable>) = 0;
133133

134134
// Dispatching protocol messages.
135-
static bool canDispatchMethod(const StringView& method);
136-
virtual void dispatchProtocolMessage(const StringView& message) = 0;
135+
static bool canDispatchMethod(StringView method);
136+
virtual void dispatchProtocolMessage(StringView message) = 0;
137137
virtual std::vector<uint8_t> state() = 0;
138138
virtual std::vector<std::unique_ptr<protocol::Schema::API::Domain>>
139139
supportedDomains() = 0;
140140

141141
// Debugger actions.
142-
virtual void schedulePauseOnNextStatement(const StringView& breakReason,
143-
const StringView& breakDetails) = 0;
142+
virtual void schedulePauseOnNextStatement(StringView breakReason,
143+
StringView breakDetails) = 0;
144144
virtual void cancelPauseOnNextStatement() = 0;
145-
virtual void breakProgram(const StringView& breakReason,
146-
const StringView& breakDetails) = 0;
145+
virtual void breakProgram(StringView breakReason,
146+
StringView breakDetails) = 0;
147147
virtual void setSkipAllPauses(bool) = 0;
148148
virtual void resume(bool setTerminateOnResume = false) = 0;
149149
virtual void stepOver() = 0;
150150
virtual std::vector<std::unique_ptr<protocol::Debugger::API::SearchMatch>>
151-
searchInTextByLines(const StringView& text, const StringView& query,
152-
bool caseSensitive, bool isRegex) = 0;
151+
searchInTextByLines(StringView text, StringView query, bool caseSensitive,
152+
bool isRegex) = 0;
153153

154154
// Remote objects.
155155
virtual std::unique_ptr<protocol::Runtime::API::RemoteObject> wrapObject(
156-
v8::Local<v8::Context>, v8::Local<v8::Value>, const StringView& groupName,
156+
v8::Local<v8::Context>, v8::Local<v8::Value>, StringView groupName,
157157
bool generatePreview) = 0;
158158

159159
virtual bool unwrapObject(std::unique_ptr<StringBuffer>* error,
160-
const StringView& objectId, v8::Local<v8::Value>*,
160+
StringView objectId, v8::Local<v8::Value>*,
161161
v8::Local<v8::Context>*,
162162
std::unique_ptr<StringBuffer>* objectGroup) = 0;
163-
virtual void releaseObjectGroup(const StringView&) = 0;
164-
virtual void triggerPreciseCoverageDeltaUpdate(
165-
const StringView& occassion) = 0;
163+
virtual void releaseObjectGroup(StringView) = 0;
164+
virtual void triggerPreciseCoverageDeltaUpdate(StringView occassion) = 0;
166165
};
167166

168167
class V8_EXPORT V8InspectorClient {
@@ -240,7 +239,7 @@ struct V8_EXPORT V8StackTraceId {
240239
V8StackTraceId(uintptr_t id, const std::pair<int64_t, int64_t> debugger_id);
241240
V8StackTraceId(uintptr_t id, const std::pair<int64_t, int64_t> debugger_id,
242241
bool should_pause);
243-
explicit V8StackTraceId(const StringView&);
242+
explicit V8StackTraceId(StringView);
244243
V8StackTraceId& operator=(const V8StackTraceId&) = default;
245244
V8StackTraceId& operator=(V8StackTraceId&&) noexcept = default;
246245
~V8StackTraceId() = default;
@@ -265,26 +264,26 @@ class V8_EXPORT V8Inspector {
265264
virtual void idleFinished() = 0;
266265

267266
// Async stack traces instrumentation.
268-
virtual void asyncTaskScheduled(const StringView& taskName, void* task,
267+
virtual void asyncTaskScheduled(StringView taskName, void* task,
269268
bool recurring) = 0;
270269
virtual void asyncTaskCanceled(void* task) = 0;
271270
virtual void asyncTaskStarted(void* task) = 0;
272271
virtual void asyncTaskFinished(void* task) = 0;
273272
virtual void allAsyncTasksCanceled() = 0;
274273

275-
virtual V8StackTraceId storeCurrentStackTrace(
276-
const StringView& description) = 0;
274+
virtual V8StackTraceId storeCurrentStackTrace(StringView description) = 0;
277275
virtual void externalAsyncTaskStarted(const V8StackTraceId& parent) = 0;
278276
virtual void externalAsyncTaskFinished(const V8StackTraceId& parent) = 0;
279277

280278
// Exceptions instrumentation.
281-
virtual unsigned exceptionThrown(
282-
v8::Local<v8::Context>, const StringView& message,
283-
v8::Local<v8::Value> exception, const StringView& detailedMessage,
284-
const StringView& url, unsigned lineNumber, unsigned columnNumber,
285-
std::unique_ptr<V8StackTrace>, int scriptId) = 0;
279+
virtual unsigned exceptionThrown(v8::Local<v8::Context>, StringView message,
280+
v8::Local<v8::Value> exception,
281+
StringView detailedMessage, StringView url,
282+
unsigned lineNumber, unsigned columnNumber,
283+
std::unique_ptr<V8StackTrace>,
284+
int scriptId) = 0;
286285
virtual void exceptionRevoked(v8::Local<v8::Context>, unsigned exceptionId,
287-
const StringView& message) = 0;
286+
StringView message) = 0;
288287

289288
// Connection.
290289
class V8_EXPORT Channel {
@@ -295,8 +294,9 @@ class V8_EXPORT V8Inspector {
295294
virtual void sendNotification(std::unique_ptr<StringBuffer> message) = 0;
296295
virtual void flushProtocolNotifications() = 0;
297296
};
298-
virtual std::unique_ptr<V8InspectorSession> connect(
299-
int contextGroupId, Channel*, const StringView& state) = 0;
297+
virtual std::unique_ptr<V8InspectorSession> connect(int contextGroupId,
298+
Channel*,
299+
StringView state) = 0;
300300

301301
// API methods.
302302
virtual std::unique_ptr<V8StackTrace> createStackTrace(

NativeScript/include/v8-internal.h

+42-3
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@
1010
#include <string.h>
1111
#include <type_traits>
1212

13-
#include "v8-version.h" // NOLINT(build/include)
14-
#include "v8config.h" // NOLINT(build/include)
13+
#include "v8-version.h" // NOLINT(build/include_directory)
14+
#include "v8config.h" // NOLINT(build/include_directory)
1515

1616
namespace v8 {
1717

@@ -106,6 +106,20 @@ const int kApiTaggedSize = kApiInt32Size;
106106
const int kApiTaggedSize = kApiSystemPointerSize;
107107
#endif
108108

109+
constexpr bool PointerCompressionIsEnabled() {
110+
return kApiTaggedSize != kApiSystemPointerSize;
111+
}
112+
113+
constexpr bool HeapSandboxIsEnabled() {
114+
#ifdef V8_HEAP_SANDBOX
115+
return true;
116+
#else
117+
return false;
118+
#endif
119+
}
120+
121+
using ExternalPointer_t = Address;
122+
109123
#ifdef V8_31BIT_SMIS_ON_64BIT_ARCH
110124
using PlatformSmiTagging = SmiTagging<kApiInt32Size>;
111125
#else
@@ -141,7 +155,6 @@ class Internals {
141155
1 * kApiTaggedSize + 2 * kApiInt32Size;
142156

143157
static const int kOddballKindOffset = 4 * kApiTaggedSize + kApiDoubleSize;
144-
static const int kForeignAddressOffset = kApiTaggedSize;
145158
static const int kJSObjectHeaderSize = 3 * kApiTaggedSize;
146159
static const int kFixedArrayHeaderSize = 2 * kApiTaggedSize;
147160
static const int kEmbedderDataArrayHeaderSize = 2 * kApiTaggedSize;
@@ -326,11 +339,28 @@ class Internals {
326339
#endif
327340
}
328341

342+
V8_INLINE static internal::Address ReadExternalPointerField(
343+
internal::Isolate* isolate, internal::Address heap_object_ptr,
344+
int offset) {
345+
#ifdef V8_COMPRESS_POINTERS
346+
internal::Address value = ReadRawField<Address>(heap_object_ptr, offset);
347+
// We currently have to treat zero as nullptr in embedder slots.
348+
if (value) value = DecodeExternalPointer(isolate, value);
349+
return value;
350+
#else
351+
return ReadRawField<internal::Address>(heap_object_ptr, offset);
352+
#endif
353+
}
354+
329355
#ifdef V8_COMPRESS_POINTERS
330356
// See v8:7703 or src/ptr-compr.* for details about pointer compression.
331357
static constexpr size_t kPtrComprHeapReservationSize = size_t{1} << 32;
332358
static constexpr size_t kPtrComprIsolateRootAlignment = size_t{1} << 32;
333359

360+
// See v8:10391 for details about V8 heap sandbox.
361+
static constexpr uint32_t kExternalPointerSalt =
362+
0x7fffffff & ~static_cast<uint32_t>(kHeapObjectTagMask);
363+
334364
V8_INLINE static internal::Address GetRootFromOnHeapAddress(
335365
internal::Address addr) {
336366
return addr & -static_cast<intptr_t>(kPtrComprIsolateRootAlignment);
@@ -341,6 +371,15 @@ class Internals {
341371
internal::Address root = GetRootFromOnHeapAddress(heap_object_ptr);
342372
return root + static_cast<internal::Address>(static_cast<uintptr_t>(value));
343373
}
374+
375+
V8_INLINE static Address DecodeExternalPointer(
376+
const Isolate* isolate, ExternalPointer_t encoded_pointer) {
377+
#ifndef V8_HEAP_SANDBOX
378+
return encoded_pointer;
379+
#else
380+
return encoded_pointer ^ kExternalPointerSalt;
381+
#endif
382+
}
344383
#endif // V8_COMPRESS_POINTERS
345384
};
346385

0 commit comments

Comments
 (0)