Commit 93d6356c authored by Simon Zünd's avatar Simon Zünd Committed by Commit Bot

[stack-trace] Remove JSArray wrapper for simple stack traces

This CL changes the Symbol "stack_trace_symbol" to directly hold a
FrameArray instead of wrapping it with a JSArray first.

Bug: v8:9115
Change-Id: I2ac0b1fb380211568abdc6d9f50431c405349dec
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1564060Reviewed-by: 's avatarBenedikt Meurer <bmeurer@chromium.org>
Commit-Queue: Simon Zünd <szuend@chromium.org>
Cr-Commit-Position: refs/heads/master@{#60801}
parent a35d999b
...@@ -1111,7 +1111,7 @@ Handle<Object> CaptureStackTrace(Isolate* isolate, Handle<Object> caller, ...@@ -1111,7 +1111,7 @@ Handle<Object> CaptureStackTrace(Isolate* isolate, Handle<Object> caller,
// TODO(yangguo): Queue this structured stack trace for preprocessing on GC. // TODO(yangguo): Queue this structured stack trace for preprocessing on GC.
if (options.capture_result == CaptureStackTraceOptions::RAW_FRAME_ARRAY) { if (options.capture_result == CaptureStackTraceOptions::RAW_FRAME_ARRAY) {
return isolate->factory()->NewJSArrayWithElements(builder.GetElements()); return builder.GetElements();
} }
return builder.GetElementsAsStackTraceFrameArray(); return builder.GetElementsAsStackTraceFrameArray();
} }
...@@ -2110,11 +2110,9 @@ bool Isolate::ComputeLocationFromStackTrace(MessageLocation* target, ...@@ -2110,11 +2110,9 @@ bool Isolate::ComputeLocationFromStackTrace(MessageLocation* target,
Handle<Name> key = factory()->stack_trace_symbol(); Handle<Name> key = factory()->stack_trace_symbol();
Handle<Object> property = Handle<Object> property =
JSReceiver::GetDataProperty(Handle<JSObject>::cast(exception), key); JSReceiver::GetDataProperty(Handle<JSObject>::cast(exception), key);
if (!property->IsJSArray()) return false; if (!property->IsFixedArray()) return false;
Handle<JSArray> simple_stack_trace = Handle<JSArray>::cast(property);
Handle<FrameArray> elements(FrameArray::cast(simple_stack_trace->elements()), Handle<FrameArray> elements = Handle<FrameArray>::cast(property);
this);
const int frame_count = elements->FrameCount(); const int frame_count = elements->FrameCount();
for (int i = 0; i < frame_count; i++) { for (int i = 0; i < frame_count; i++) {
......
...@@ -974,12 +974,8 @@ class PrepareStackTraceScope { ...@@ -974,12 +974,8 @@ class PrepareStackTraceScope {
MaybeHandle<Object> ErrorUtils::FormatStackTrace(Isolate* isolate, MaybeHandle<Object> ErrorUtils::FormatStackTrace(Isolate* isolate,
Handle<JSObject> error, Handle<JSObject> error,
Handle<Object> raw_stack) { Handle<Object> raw_stack) {
DCHECK(raw_stack->IsJSArray()); DCHECK(raw_stack->IsFixedArray());
Handle<JSArray> raw_stack_array = Handle<JSArray>::cast(raw_stack); Handle<FrameArray> elems = Handle<FrameArray>::cast(raw_stack);
DCHECK(raw_stack_array->elements()->IsFixedArray());
Handle<FrameArray> elems(FrameArray::cast(raw_stack_array->elements()),
isolate);
const bool in_recursion = isolate->formatting_stack_trace(); const bool in_recursion = isolate->formatting_stack_trace();
if (!in_recursion) { if (!in_recursion) {
......
...@@ -3553,12 +3553,8 @@ void DetailedErrorStackTraceTest(const char* src, ...@@ -3553,12 +3553,8 @@ void DetailedErrorStackTraceTest(const char* src,
Isolate* isolate = CcTest::i_isolate(); Isolate* isolate = CcTest::i_isolate();
Handle<Name> key = isolate->factory()->stack_trace_symbol(); Handle<Name> key = isolate->factory()->stack_trace_symbol();
Handle<FrameArray> stack_trace( Handle<FrameArray> stack_trace(Handle<FrameArray>::cast(
FrameArray::cast( Object::GetProperty(isolate, exception, key).ToHandleChecked()));
Handle<JSArray>::cast(
Object::GetProperty(isolate, exception, key).ToHandleChecked())
->elements()),
isolate);
test(stack_trace); test(stack_trace);
} }
...@@ -5150,8 +5146,8 @@ TEST(PreprocessStackTrace) { ...@@ -5150,8 +5146,8 @@ TEST(PreprocessStackTrace) {
Object::GetElement(isolate, stack_trace, 3).ToHandleChecked(); Object::GetElement(isolate, stack_trace, 3).ToHandleChecked();
CHECK(pos->IsSmi()); CHECK(pos->IsSmi());
Handle<JSArray> stack_trace_array = Handle<JSArray>::cast(stack_trace); Handle<FrameArray> frame_array = Handle<FrameArray>::cast(stack_trace);
int array_length = Smi::ToInt(stack_trace_array->length()); int array_length = frame_array->FrameCount();
for (int i = 0; i < array_length; i++) { for (int i = 0; i < array_length; i++) {
Handle<Object> element = Handle<Object> element =
Object::GetElement(isolate, stack_trace, i).ToHandleChecked(); Object::GetElement(isolate, stack_trace, i).ToHandleChecked();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment