mirror of
https://github.com/nodejs/node.git
synced 2026-10-28 10:15:07 +08:00
deps: V8: backport ebd15783b7ba
Original commit message:
[objects]: Defer CallSiteInfo creation
Store the raw data in a FixedArray and create the CallSiteInfo objects
only on demand.
This can be further optimized to omit CallSiteInfo creation altogether
in some code paths, but currently those code paths are not critically important.
Change-Id: I6480862caf6b64020737527c571e3e3eac704ed3
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/7673818
Commit-Queue: Marja Hölttä <marja@chromium.org>
Reviewed-by: Leszek Swirski <leszeks@chromium.org>
Cr-Commit-Position: refs/heads/main@{#106127}
Refs: https://github.com/v8/v8/commit/ebd15783b7ba67a135212cf7418ca2f85ebb7502
Co-authored-by: Antoine du Hamel <duhamelantoine1995@gmail.com>
PR-URL: https://github.com/nodejs/node/pull/65764
Backport-PR-URL: https://github.com/nodejs/node/pull/66241
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
This commit is contained in:
1 parent
ab70b5d681
commit
3b8eb1a920
12 files changed
+222
-69
No files matched your search
+1
-1
@@ -42,7 +42,7 @@
|
||||
|
||||
# Reset this number to 0 on major V8 upgrades.
|
||||
# Increment by one for each non-official patch applied to deps/v8.
|
||||
'v8_embedder_string': '-node.59',
|
||||
'v8_embedder_string': '-node.60',
|
||||
|
||||
##### V8 defaults for Node.js #####
|
||||
|
||||
|
||||
Vendored
+85
-33
@@ -859,18 +859,21 @@ class CallSiteBuilder {
|
||||
// framework and library code, and stack depth tends to be more than
|
||||
// a dozen frames, so we over-allocate a bit here to avoid growing
|
||||
// the elements array in the common case.
|
||||
elements_ = isolate->factory()->NewFixedArray(std::min(64, limit));
|
||||
elements_ = isolate->factory()->NewFixedArray(CallSiteInfo::Fields::kCount *
|
||||
std::min(64, limit));
|
||||
}
|
||||
|
||||
void SetPrevFrameAsConstructCall() {
|
||||
if (skipped_prev_frame_) return;
|
||||
DCHECK_GT(index_, 0);
|
||||
Tagged<CallSiteInfo> info =
|
||||
Tagged<CallSiteInfo>::cast(elements_->get(index_ - 1));
|
||||
int base_index = (index_ - 1) * CallSiteInfo::Fields::kCount;
|
||||
int flags =
|
||||
Smi::ToInt(elements_->get(base_index + CallSiteInfo::Fields::kFlags));
|
||||
#if V8_ENABLE_WEBASSEMBLY
|
||||
if (info->IsWasm()) return;
|
||||
if (flags & CallSiteInfo::kIsWasm) return;
|
||||
#endif
|
||||
info->set_flags(info->flags() | CallSiteInfo::kIsConstructor);
|
||||
elements_->set(base_index + CallSiteInfo::Fields::kFlags,
|
||||
Smi::FromInt(flags | CallSiteInfo::kIsConstructor));
|
||||
}
|
||||
|
||||
bool Visit(FrameSummary const& summary) {
|
||||
@@ -1032,7 +1035,8 @@ class CallSiteBuilder {
|
||||
bool Full() { return index_ >= limit_; }
|
||||
|
||||
Handle<FixedArray> Build() {
|
||||
return FixedArray::RightTrimOrEmpty(isolate_, elements_, index_);
|
||||
return FixedArray::RightTrimOrEmpty(isolate_, elements_,
|
||||
CallSiteInfo::Fields::kCount * index_);
|
||||
}
|
||||
|
||||
private:
|
||||
@@ -1097,17 +1101,42 @@ class CallSiteBuilder {
|
||||
|
||||
void AppendFrame(DirectHandle<UnionOf<JSAny, Hole>> receiver_or_instance,
|
||||
DirectHandle<UnionOf<Smi, JSFunction>> function,
|
||||
DirectHandle<HeapObject> code, int offset, int flags,
|
||||
DirectHandle<HeapObject> code_obj, int offset, int flags,
|
||||
DirectHandle<FixedArray> parameters) {
|
||||
if (IsTheHole(*receiver_or_instance, isolate_)) {
|
||||
// TODO(jgruber): Fix all cases in which frames give us a hole value
|
||||
// (e.g. the receiver in RegExp constructor frames).
|
||||
receiver_or_instance = isolate_->factory()->undefined_value();
|
||||
}
|
||||
auto info = isolate_->factory()->NewCallSiteInfo(
|
||||
Cast<JSAny>(receiver_or_instance), function, code, offset, flags,
|
||||
parameters);
|
||||
elements_ = FixedArray::SetAndGrow(isolate_, elements_, index_++, info);
|
||||
|
||||
int base_index = index_ * CallSiteInfo::Fields::kCount;
|
||||
|
||||
// Set the last field first and grow the array if needed.
|
||||
static_assert(CallSiteInfo::Fields::kFlags ==
|
||||
CallSiteInfo::Fields::kCount - 1);
|
||||
elements_ = FixedArray::SetAndGrow(
|
||||
isolate_, elements_, base_index + CallSiteInfo::Fields::kFlags,
|
||||
Smi::FromInt(flags));
|
||||
|
||||
elements_->set(base_index + CallSiteInfo::Fields::kReceiver,
|
||||
*receiver_or_instance);
|
||||
elements_->set(base_index + CallSiteInfo::Fields::kFunction, *function);
|
||||
|
||||
if (DirectHandle<Code> code; TryCast(code_obj, &code)) {
|
||||
elements_->set(base_index + CallSiteInfo::Fields::kCode, code->wrapper());
|
||||
} else if (DirectHandle<BytecodeArray> bytecode;
|
||||
TryCast(code_obj, &bytecode)) {
|
||||
elements_->set(base_index + CallSiteInfo::Fields::kCode,
|
||||
bytecode->wrapper());
|
||||
} else {
|
||||
elements_->set(base_index + CallSiteInfo::Fields::kCode,
|
||||
*isolate_->factory()->undefined_value());
|
||||
}
|
||||
|
||||
elements_->set(base_index + CallSiteInfo::Fields::kOffset,
|
||||
Smi::FromInt(offset));
|
||||
|
||||
index_++;
|
||||
skipped_prev_frame_ = false;
|
||||
}
|
||||
|
||||
@@ -1412,13 +1441,18 @@ Handle<FixedArray> CaptureSimpleStackTrace(Isolate* isolate, int limit,
|
||||
}
|
||||
|
||||
DirectHandle<StackTraceInfo> GetDetailedStackTraceFromCallSiteInfos(
|
||||
Isolate* isolate, DirectHandle<FixedArray> call_site_infos, int limit) {
|
||||
auto frames = isolate->factory()->NewFixedArray(
|
||||
std::min(limit, call_site_infos->length()));
|
||||
int index = 0;
|
||||
for (int i = 0; i < call_site_infos->length() && index < limit; ++i) {
|
||||
DirectHandle<CallSiteInfo> call_site_info(
|
||||
Cast<CallSiteInfo>(call_site_infos->get(i)), isolate);
|
||||
Isolate* isolate, DirectHandle<FixedArray> raw_data_for_call_site_infos,
|
||||
uint32_t limit) {
|
||||
uint32_t call_site_infos_len =
|
||||
raw_data_for_call_site_infos->length() /
|
||||
CallSiteInfo::Fields::kCount;
|
||||
auto frames =
|
||||
isolate->factory()->NewFixedArray(std::min(limit, call_site_infos_len));
|
||||
uint32_t index = 0;
|
||||
for (uint32_t i = 0; i < call_site_infos_len && index < limit; ++i) {
|
||||
DirectHandle<CallSiteInfo> call_site_info =
|
||||
CallSiteInfo::ConstructFromRawData(isolate,
|
||||
raw_data_for_call_site_infos, i);
|
||||
if (call_site_info->IsAsync()) {
|
||||
break;
|
||||
}
|
||||
@@ -1489,14 +1523,19 @@ MaybeDirectHandle<JSObject> Isolate::CaptureAndSetErrorStack(
|
||||
stack_trace_for_uncaught_exceptions_frame_limit_,
|
||||
stack_trace_for_uncaught_exceptions_options_);
|
||||
} else {
|
||||
auto call_site_infos =
|
||||
auto raw_data_for_call_site_infos =
|
||||
Cast<FixedArray>(call_site_infos_or_formatted_stack);
|
||||
stack_trace = GetDetailedStackTraceFromCallSiteInfos(
|
||||
this, call_site_infos,
|
||||
stack_trace_for_uncaught_exceptions_frame_limit_);
|
||||
if (stack_trace_limit < call_site_infos->length()) {
|
||||
this, raw_data_for_call_site_infos,
|
||||
static_cast<uint32_t>(
|
||||
stack_trace_for_uncaught_exceptions_frame_limit_));
|
||||
DCHECK_GE(stack_trace_limit, 0);
|
||||
if (static_cast<int>(stack_trace_limit) *
|
||||
CallSiteInfo::Fields::kCount <
|
||||
raw_data_for_call_site_infos->length()) {
|
||||
call_site_infos_or_formatted_stack = FixedArray::RightTrimOrEmpty(
|
||||
this, call_site_infos, stack_trace_limit);
|
||||
this, raw_data_for_call_site_infos,
|
||||
stack_trace_limit * CallSiteInfo::Fields::kCount);
|
||||
}
|
||||
// Notify the debugger.
|
||||
OnStackTraceCaptured(stack_trace);
|
||||
@@ -1526,17 +1565,27 @@ Handle<FixedArray> Isolate::GetSimpleStackTrace(
|
||||
ErrorUtils::StackPropertyLookupResult lookup =
|
||||
ErrorUtils::GetErrorStackProperty(this, maybe_error_object);
|
||||
|
||||
Handle<FixedArray> raw_data;
|
||||
if (IsFixedArray(*lookup.error_stack)) {
|
||||
return Cast<FixedArray>(lookup.error_stack);
|
||||
}
|
||||
if (!IsErrorStackData(*lookup.error_stack)) {
|
||||
raw_data = Cast<FixedArray>(lookup.error_stack);
|
||||
} else if (IsErrorStackData(*lookup.error_stack)) {
|
||||
auto error_stack_data = Cast<ErrorStackData>(lookup.error_stack);
|
||||
if (!error_stack_data->HasRawDataForCallSiteInfos()) {
|
||||
return factory()->empty_fixed_array();
|
||||
}
|
||||
raw_data = handle(error_stack_data->raw_data_for_call_site_infos(), this);
|
||||
} else {
|
||||
return factory()->empty_fixed_array();
|
||||
}
|
||||
auto error_stack_data = Cast<ErrorStackData>(lookup.error_stack);
|
||||
if (!error_stack_data->HasCallSiteInfos()) {
|
||||
return factory()->empty_fixed_array();
|
||||
|
||||
int frame_count = raw_data->length() / CallSiteInfo::Fields::kCount;
|
||||
Handle<FixedArray> call_site_infos = factory()->NewFixedArray(frame_count);
|
||||
for (int i = 0; i < frame_count; ++i) {
|
||||
DirectHandle<CallSiteInfo> call_site_info =
|
||||
CallSiteInfo::ConstructFromRawData(this, raw_data, i);
|
||||
call_site_infos->set(i, *call_site_info);
|
||||
}
|
||||
return handle(error_stack_data->call_site_infos(), this);
|
||||
return call_site_infos;
|
||||
}
|
||||
|
||||
Address Isolate::GetAbstractPC(int* line, int* column) {
|
||||
@@ -2868,8 +2917,11 @@ void Isolate::PrintCurrentStackTrace(
|
||||
this, FixedArray::kMaxLength, SKIP_NONE, factory()->undefined_value());
|
||||
|
||||
IncrementalStringBuilder builder(this);
|
||||
for (int i = 0; i < frames->length(); ++i) {
|
||||
DirectHandle<CallSiteInfo> frame(Cast<CallSiteInfo>(frames->get(i)), this);
|
||||
uint32_t frame_count =
|
||||
frames->length() / CallSiteInfo::Fields::kCount;
|
||||
for (uint32_t i = 0; i < frame_count; ++i) {
|
||||
DirectHandle<CallSiteInfo> frame =
|
||||
CallSiteInfo::ConstructFromRawData(this, frames, i);
|
||||
|
||||
if (should_include_frame_callback) {
|
||||
Tagged<Object> raw_script_name = frame->GetScriptNameOrSourceURL();
|
||||
@@ -2893,7 +2945,7 @@ void Isolate::PrintCurrentStackTrace(
|
||||
SerializeCallSiteInfo(this, frame, &builder);
|
||||
}
|
||||
|
||||
if (i != frames->length() - 1) builder.AppendCharacter('\n');
|
||||
if (i != frame_count - 1) builder.AppendCharacter('\n');
|
||||
}
|
||||
|
||||
DirectHandle<String> stack_trace = builder.Finish().ToHandleChecked();
|
||||
|
||||
Vendored
+24
-15
@@ -24,6 +24,7 @@
|
||||
#include "src/parsing/parse-info.h"
|
||||
#include "src/parsing/parsing.h"
|
||||
#include "src/roots/roots.h"
|
||||
#include "src/sandbox/indirect-pointer-inl.h"
|
||||
#include "src/strings/string-builder-inl.h"
|
||||
|
||||
namespace v8 {
|
||||
@@ -201,15 +202,16 @@ namespace {
|
||||
|
||||
// Convert the raw frames as written by Isolate::CaptureSimpleStackTrace into
|
||||
// a JSArray of JSCallSite objects.
|
||||
MaybeDirectHandle<JSArray> GetStackFrames(Isolate* isolate,
|
||||
DirectHandle<FixedArray> frames) {
|
||||
int frame_count = frames->length();
|
||||
MaybeDirectHandle<JSArray> GetStackFrames(
|
||||
Isolate* isolate, DirectHandle<FixedArray> raw_data_for_call_site_infos) {
|
||||
uint32_t frame_count = raw_data_for_call_site_infos->length() /
|
||||
CallSiteInfo::Fields::kCount;
|
||||
DirectHandle<JSFunction> constructor = isolate->callsite_function();
|
||||
DirectHandle<FixedArray> sites =
|
||||
isolate->factory()->NewFixedArray(frame_count);
|
||||
for (int i = 0; i < frame_count; ++i) {
|
||||
DirectHandle<CallSiteInfo> frame(Cast<CallSiteInfo>(frames->get(i)),
|
||||
isolate);
|
||||
for (uint32_t i = 0; i < frame_count; ++i) {
|
||||
DirectHandle<CallSiteInfo> frame = CallSiteInfo::ConstructFromRawData(
|
||||
isolate, raw_data_for_call_site_infos, i);
|
||||
DirectHandle<JSObject> site;
|
||||
ASSIGN_RETURN_ON_EXCEPTION(isolate, site,
|
||||
JSObject::New(constructor, constructor,
|
||||
@@ -291,7 +293,7 @@ MaybeDirectHandle<Object> ErrorUtils::FormatStackTrace(
|
||||
return isolate->factory()->empty_string();
|
||||
}
|
||||
DCHECK(IsFixedArray(*raw_stack));
|
||||
auto elems = Cast<FixedArray>(raw_stack);
|
||||
auto raw_data_for_call_site_infos = Cast<FixedArray>(raw_stack);
|
||||
|
||||
const bool in_recursion = isolate->formatting_stack_trace();
|
||||
const bool has_overflowed = i::StackLimitCheck{isolate}.HasOverflowed();
|
||||
@@ -302,8 +304,9 @@ MaybeDirectHandle<Object> ErrorUtils::FormatStackTrace(
|
||||
PrepareStackTraceScope scope(isolate);
|
||||
|
||||
DirectHandle<JSArray> sites;
|
||||
ASSIGN_RETURN_ON_EXCEPTION(isolate, sites,
|
||||
GetStackFrames(isolate, elems));
|
||||
ASSIGN_RETURN_ON_EXCEPTION(
|
||||
isolate, sites,
|
||||
GetStackFrames(isolate, raw_data_for_call_site_infos));
|
||||
|
||||
DirectHandle<Object> result;
|
||||
ASSIGN_RETURN_ON_EXCEPTION(
|
||||
@@ -328,8 +331,9 @@ MaybeDirectHandle<Object> ErrorUtils::FormatStackTrace(
|
||||
isolate->CountUsage(v8::Isolate::kErrorPrepareStackTrace);
|
||||
|
||||
DirectHandle<JSArray> sites;
|
||||
ASSIGN_RETURN_ON_EXCEPTION(isolate, sites,
|
||||
GetStackFrames(isolate, elems));
|
||||
ASSIGN_RETURN_ON_EXCEPTION(
|
||||
isolate, sites,
|
||||
GetStackFrames(isolate, raw_data_for_call_site_infos));
|
||||
|
||||
constexpr int argc = 2;
|
||||
std::array<DirectHandle<Object>, argc> args;
|
||||
@@ -358,12 +362,16 @@ MaybeDirectHandle<Object> ErrorUtils::FormatStackTrace(
|
||||
|
||||
RETURN_ON_EXCEPTION(isolate, AppendErrorString(isolate, error, &builder));
|
||||
|
||||
for (int i = 0; i < elems->length(); ++i) {
|
||||
int elems_len = raw_data_for_call_site_infos->length() /
|
||||
CallSiteInfo::Fields::kCount;
|
||||
for (int i = 0; i < elems_len; ++i) {
|
||||
builder.AppendCStringLiteral("\n at ");
|
||||
|
||||
DirectHandle<CallSiteInfo> frame(Cast<CallSiteInfo>(elems->get(i)),
|
||||
isolate);
|
||||
DirectHandle<CallSiteInfo> frame = CallSiteInfo::ConstructFromRawData(
|
||||
isolate, raw_data_for_call_site_infos, i);
|
||||
|
||||
// TODO(marja): Avoid CallSiteInfo creation since we serialize it right
|
||||
// away.
|
||||
v8::TryCatch try_catch(reinterpret_cast<v8::Isolate*>(isolate));
|
||||
SerializeCallSiteInfo(isolate, frame, &builder);
|
||||
|
||||
@@ -1164,7 +1172,8 @@ MaybeDirectHandle<Object> ErrorUtils::GetFormattedStack(
|
||||
isolate, formatted_stack,
|
||||
FormatStackTrace(
|
||||
isolate, error_object,
|
||||
direct_handle(error_stack_data->call_site_infos(), isolate)));
|
||||
direct_handle(error_stack_data->raw_data_for_call_site_infos(),
|
||||
isolate)));
|
||||
error_stack_data->set_formatted_stack(*formatted_stack);
|
||||
return formatted_stack;
|
||||
}
|
||||
|
||||
Vendored
+4
-3
@@ -1527,13 +1527,14 @@ DirectHandle<AccessorInfo> Factory::NewAccessorInfo() {
|
||||
}
|
||||
|
||||
DirectHandle<ErrorStackData> Factory::NewErrorStackData(
|
||||
DirectHandle<UnionOf<JSAny, FixedArray>> call_site_infos_or_formatted_stack,
|
||||
DirectHandle<UnionOf<JSAny, FixedArray>>
|
||||
raw_data_for_call_site_infos_or_formatted_stack,
|
||||
DirectHandle<StackTraceInfo> stack_trace) {
|
||||
Tagged<ErrorStackData> error_stack_data = NewStructInternal<ErrorStackData>(
|
||||
ERROR_STACK_DATA_TYPE, AllocationType::kYoung);
|
||||
DisallowGarbageCollection no_gc;
|
||||
error_stack_data->set_call_site_infos_or_formatted_stack(
|
||||
*call_site_infos_or_formatted_stack, SKIP_WRITE_BARRIER);
|
||||
error_stack_data->set_raw_data_for_call_site_infos_or_formatted_stack(
|
||||
*raw_data_for_call_site_infos_or_formatted_stack, SKIP_WRITE_BARRIER);
|
||||
error_stack_data->set_stack_trace(*stack_trace, SKIP_WRITE_BARRIER);
|
||||
return direct_handle(error_stack_data, isolate());
|
||||
}
|
||||
|
||||
Vendored
+1
-1
@@ -452,7 +452,7 @@ class V8_EXPORT_PRIVATE Factory : public FactoryBase<Factory> {
|
||||
|
||||
DirectHandle<ErrorStackData> NewErrorStackData(
|
||||
DirectHandle<UnionOf<JSAny, FixedArray>>
|
||||
call_site_infos_or_formatted_stack,
|
||||
raw_data_for_call_site_infos_or_formatted_stack,
|
||||
DirectHandle<StackTraceInfo> stack_trace);
|
||||
|
||||
Handle<Script> CloneScript(DirectHandle<Script> script,
|
||||
|
||||
+32
@@ -17,6 +17,38 @@
|
||||
|
||||
namespace v8::internal {
|
||||
|
||||
// static
|
||||
DirectHandle<CallSiteInfo> CallSiteInfo::ConstructFromRawData(
|
||||
Isolate* isolate, DirectHandle<FixedArray> frames, int index) {
|
||||
int base_index = index * Fields::kCount;
|
||||
DirectHandle<Object> receiver(frames->get(base_index + Fields::kReceiver),
|
||||
isolate);
|
||||
DirectHandle<Object> function(frames->get(base_index + Fields::kFunction),
|
||||
isolate);
|
||||
DirectHandle<Object> code_obj(frames->get(base_index + Fields::kCode),
|
||||
isolate);
|
||||
DirectHandle<Union<Code, BytecodeArray, Undefined>> resolved_code;
|
||||
if (IsCodeWrapper(*code_obj)) {
|
||||
resolved_code = handle(Cast<CodeWrapper>(code_obj)->code(isolate), isolate);
|
||||
} else if (IsBytecodeWrapper(*code_obj)) {
|
||||
resolved_code =
|
||||
handle(Cast<BytecodeWrapper>(code_obj)->bytecode(isolate), isolate);
|
||||
} else if (IsUndefined(*code_obj)) {
|
||||
resolved_code = isolate->factory()->undefined_value();
|
||||
} else {
|
||||
UNREACHABLE();
|
||||
}
|
||||
|
||||
int offset = Smi::ToInt(frames->get(base_index + Fields::kOffset));
|
||||
DirectHandle<FixedArray> parameters(
|
||||
Cast<FixedArray>(frames->get(base_index + Fields::kParameters)), isolate);
|
||||
int flags = Smi::ToInt(frames->get(base_index + Fields::kFlags));
|
||||
|
||||
return isolate->factory()->NewCallSiteInfo(
|
||||
Cast<JSAny>(receiver), Cast<UnionOf<Smi, JSFunction>>(function),
|
||||
resolved_code, offset, flags, parameters);
|
||||
}
|
||||
|
||||
bool CallSiteInfo::IsPromiseAll() const {
|
||||
if (!IsAsync()) return false;
|
||||
Tagged<JSFunction> fun = Cast<JSFunction>(function());
|
||||
|
||||
Vendored
+16
@@ -58,6 +58,22 @@ class CallSiteInfo : public TorqueGeneratedCallSiteInfo<CallSiteInfo, Struct> {
|
||||
// Used to signal that the requested field is unknown.
|
||||
static constexpr int kUnknown = kNoSourcePosition;
|
||||
|
||||
// For delayed CallSiteInfo creation (storing the raw data for several
|
||||
// CallSiteInfos in a FixedArray).
|
||||
// kFlags must stay last (see CallSiteBuilder::AppendFrame).
|
||||
enum Fields {
|
||||
kCode = 0,
|
||||
kReceiver,
|
||||
kFunction,
|
||||
kOffset,
|
||||
kParameters,
|
||||
kFlags,
|
||||
kCount
|
||||
};
|
||||
|
||||
static DirectHandle<CallSiteInfo> ConstructFromRawData(
|
||||
Isolate* isolate, DirectHandle<FixedArray> frames, int index);
|
||||
|
||||
V8_EXPORT_PRIVATE static int GetLineNumber(DirectHandle<CallSiteInfo> info);
|
||||
V8_EXPORT_PRIVATE static int GetColumnNumber(DirectHandle<CallSiteInfo> info);
|
||||
|
||||
|
||||
+8
-6
@@ -88,18 +88,20 @@ NEVER_READ_ONLY_SPACE_IMPL(ErrorStackData)
|
||||
TQ_OBJECT_CONSTRUCTORS_IMPL(ErrorStackData)
|
||||
|
||||
bool ErrorStackData::HasFormattedStack() const {
|
||||
return !IsFixedArray(call_site_infos_or_formatted_stack());
|
||||
return !IsFixedArray(raw_data_for_call_site_infos_or_formatted_stack());
|
||||
}
|
||||
|
||||
ACCESSORS_RELAXED_CHECKED2(ErrorStackData, formatted_stack, Tagged<Object>,
|
||||
kCallSiteInfosOrFormattedStackOffset,
|
||||
kRawDataForCallSiteInfosOrFormattedStackOffset,
|
||||
HasFormattedStack(), true)
|
||||
|
||||
bool ErrorStackData::HasCallSiteInfos() const { return !HasFormattedStack(); }
|
||||
bool ErrorStackData::HasRawDataForCallSiteInfos() const {
|
||||
return !HasFormattedStack();
|
||||
}
|
||||
|
||||
DEF_GETTER(ErrorStackData, call_site_infos, Tagged<FixedArray>) {
|
||||
DCHECK(HasCallSiteInfos());
|
||||
return Cast<FixedArray>(call_site_infos_or_formatted_stack());
|
||||
DEF_GETTER(ErrorStackData, raw_data_for_call_site_infos, Tagged<FixedArray>) {
|
||||
DCHECK(HasRawDataForCallSiteInfos());
|
||||
return Cast<FixedArray>(raw_data_for_call_site_infos_or_formatted_stack());
|
||||
}
|
||||
|
||||
} // namespace internal
|
||||
|
||||
Vendored
+2
-2
@@ -261,8 +261,8 @@ class ErrorStackData
|
||||
|
||||
inline bool HasFormattedStack() const;
|
||||
DECL_ACCESSORS(formatted_stack, Tagged<Object>)
|
||||
inline bool HasCallSiteInfos() const;
|
||||
DECL_GETTER(call_site_infos, Tagged<FixedArray>)
|
||||
inline bool HasRawDataForCallSiteInfos() const;
|
||||
DECL_GETTER(raw_data_for_call_site_infos, Tagged<FixedArray>)
|
||||
|
||||
DECL_VERIFIER(ErrorStackData)
|
||||
|
||||
|
||||
Vendored
+4
-4
@@ -102,10 +102,10 @@ extern class StackTraceInfo extends Struct {
|
||||
// (2) A valid JavaScript object and StackTraceInfo once
|
||||
// error.stack was accessed.
|
||||
extern class ErrorStackData extends Struct {
|
||||
// This holds either the FixedArray of CallSiteInfo instances or
|
||||
// the formatted stack value (usually a string) that's returned
|
||||
// from the error.stack property.
|
||||
call_site_infos_or_formatted_stack: FixedArray|JSAny;
|
||||
// This holds either the FixedArray of raw data for constructing the
|
||||
// CallSiteInfo instances or the formatted stack value (usually a string)
|
||||
// that's returned from the error.stack property.
|
||||
raw_data_for_call_site_infos_or_formatted_stack: FixedArray|JSAny;
|
||||
// This holds the StackTraceInfo for inspector stack trace.
|
||||
stack_trace: StackTraceInfo;
|
||||
}
|
||||
Vendored
+32
-4
@@ -21,10 +21,9 @@ bool FixedArrayBase::IsCowArray() const {
|
||||
template <template <typename> typename HandleType>
|
||||
requires(
|
||||
std::is_convertible_v<HandleType<FixedArray>, DirectHandle<FixedArray>>)
|
||||
HandleType<FixedArray> FixedArray::SetAndGrow(Isolate* isolate,
|
||||
HandleType<FixedArray> array,
|
||||
int index,
|
||||
DirectHandle<Object> value) {
|
||||
HandleType<FixedArray> FixedArray::Grow(Isolate* isolate,
|
||||
HandleType<FixedArray> array,
|
||||
int index) {
|
||||
int len = array->length();
|
||||
if (index >= len) {
|
||||
int new_capacity = FixedArray::NewCapacityForIndex(index, len);
|
||||
@@ -33,7 +32,17 @@ HandleType<FixedArray> FixedArray::SetAndGrow(Isolate* isolate,
|
||||
// use `undefined` as a filler. Make this more explicit.
|
||||
array->FillWithHoles(len, new_capacity);
|
||||
}
|
||||
return array;
|
||||
}
|
||||
|
||||
template <template <typename> typename HandleType>
|
||||
requires(
|
||||
std::is_convertible_v<HandleType<FixedArray>, DirectHandle<FixedArray>>)
|
||||
HandleType<FixedArray> FixedArray::SetAndGrow(Isolate* isolate,
|
||||
HandleType<FixedArray> array,
|
||||
int index,
|
||||
DirectHandle<Object> value) {
|
||||
array = Grow(isolate, array, index);
|
||||
array->set(index, *value);
|
||||
return array;
|
||||
}
|
||||
@@ -45,6 +54,25 @@ template IndirectHandle<FixedArray> FixedArray::SetAndGrow(
|
||||
Isolate* isolate, IndirectHandle<FixedArray> array, int index,
|
||||
DirectHandle<Object> value);
|
||||
|
||||
template <template <typename> typename HandleType>
|
||||
requires(
|
||||
std::is_convertible_v<HandleType<FixedArray>, DirectHandle<FixedArray>>)
|
||||
HandleType<FixedArray> FixedArray::SetAndGrow(Isolate* isolate,
|
||||
HandleType<FixedArray> array,
|
||||
int index,
|
||||
Tagged<Smi> value) {
|
||||
array = Grow(isolate, array, index);
|
||||
array->set(index, value);
|
||||
return array;
|
||||
}
|
||||
|
||||
template DirectHandle<FixedArray> FixedArray::SetAndGrow(
|
||||
Isolate* isolate, DirectHandle<FixedArray> array, int index,
|
||||
Tagged<Smi> value);
|
||||
template IndirectHandle<FixedArray> FixedArray::SetAndGrow(
|
||||
Isolate* isolate, IndirectHandle<FixedArray> array, int index,
|
||||
Tagged<Smi> value);
|
||||
|
||||
void FixedArray::RightTrim(Isolate* isolate, int new_capacity) {
|
||||
DCHECK_NE(map(), ReadOnlyRoots{isolate}.fixed_cow_array_map());
|
||||
Super::RightTrim(isolate, new_capacity);
|
||||
|
||||
Vendored
+13
@@ -243,6 +243,12 @@ V8_OBJECT class FixedArray
|
||||
V8_EXPORT_PRIVATE static HandleType<FixedArray> SetAndGrow(
|
||||
Isolate* isolate, HandleType<FixedArray> array, int index,
|
||||
DirectHandle<Object> value);
|
||||
template <template <typename> typename HandleType>
|
||||
requires(
|
||||
std::is_convertible_v<HandleType<FixedArray>, DirectHandle<FixedArray>>)
|
||||
V8_EXPORT_PRIVATE static HandleType<FixedArray> SetAndGrow(
|
||||
Isolate* isolate, HandleType<FixedArray> array, int index,
|
||||
Tagged<Smi> value);
|
||||
|
||||
// Right-trim the array.
|
||||
// Invariant: 0 < new_length <= length()
|
||||
@@ -273,6 +279,13 @@ V8_OBJECT class FixedArray
|
||||
static constexpr int kMaxRegularLength = FixedArray::kMaxRegularCapacity;
|
||||
|
||||
private:
|
||||
template <template <typename> typename HandleType>
|
||||
requires(
|
||||
std::is_convertible_v<HandleType<FixedArray>, DirectHandle<FixedArray>>)
|
||||
static HandleType<FixedArray> Grow(Isolate* isolate,
|
||||
HandleType<FixedArray> array,
|
||||
int index);
|
||||
|
||||
inline static Handle<FixedArray> Resize(
|
||||
Isolate* isolate, DirectHandle<FixedArray> xs, int new_capacity,
|
||||
AllocationType allocation = AllocationType::kYoung,
|
||||
|
||||
Reference in new issue
Block a user