Commit 15f90b0a authored by Seth Brenith's avatar Seth Brenith Committed by Commit Bot

[torque] Improve field types in StackFrameInfo

This is a partial reland of https://crrev.com/c/v8/v8/+/2199640 .

Change-Id: I528e43b8f6c5159148c16f1e2985efce2f1c2ec6
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2216307Reviewed-by: 's avatarToon Verwaest <verwaest@chromium.org>
Reviewed-by: 's avatarTobias Tebbi <tebbi@chromium.org>
Reviewed-by: 's avatarUlan Degenbaev <ulan@chromium.org>
Commit-Queue: Seth Brenith <seth.brenith@microsoft.com>
Cr-Commit-Position: refs/heads/master@{#68075}
parent 61f5e380
......@@ -1534,8 +1534,6 @@ void NormalizedMapCache::NormalizedMapCacheVerify(Isolate* isolate) {
}
}
USE_TORQUE_VERIFIER(StackFrameInfo)
void PreparseData::PreparseDataVerify(Isolate* isolate) {
TorqueGeneratedClassVerifiers::PreparseDataVerify(*this, isolate);
CHECK_LE(0, data_length());
......
......@@ -311,18 +311,18 @@ MaybeHandle<String> FormatEvalOrigin(Isolate* isolate, Handle<Script> script) {
} // namespace
Handle<Object> StackFrameBase::GetEvalOrigin() {
Handle<PrimitiveHeapObject> StackFrameBase::GetEvalOrigin() {
if (!HasScript() || !IsEval()) return isolate_->factory()->undefined_value();
return FormatEvalOrigin(isolate_, GetScript()).ToHandleChecked();
}
Handle<Object> StackFrameBase::GetWasmModuleName() {
Handle<PrimitiveHeapObject> StackFrameBase::GetWasmModuleName() {
return isolate_->factory()->undefined_value();
}
int StackFrameBase::GetWasmFunctionIndex() { return StackFrameBase::kNone; }
Handle<Object> StackFrameBase::GetWasmInstance() {
Handle<HeapObject> StackFrameBase::GetWasmInstance() {
return isolate_->factory()->undefined_value();
}
......@@ -376,7 +376,7 @@ Handle<Object> JSStackFrame::GetFileName() {
return handle(GetScript()->name(), isolate_);
}
Handle<Object> JSStackFrame::GetFunctionName() {
Handle<PrimitiveHeapObject> JSStackFrame::GetFunctionName() {
Handle<String> result = JSFunction::GetDebugName(function_);
if (result->length() != 0) return result;
......@@ -419,7 +419,7 @@ Handle<Object> JSStackFrame::GetScriptNameOrSourceUrl() {
return ScriptNameOrSourceUrl(GetScript(), isolate_);
}
Handle<Object> JSStackFrame::GetMethodName() {
Handle<PrimitiveHeapObject> JSStackFrame::GetMethodName() {
if (receiver_->IsNullOrUndefined(isolate_)) {
return isolate_->factory()->null_value();
}
......@@ -453,7 +453,7 @@ Handle<Object> JSStackFrame::GetMethodName() {
}
HandleScope outer_scope(isolate_);
Handle<Object> result;
Handle<PrimitiveHeapObject> result;
for (PrototypeIterator iter(isolate_, receiver, kStartAtReceiver);
!iter.IsAtEnd(); iter.Advance()) {
Handle<Object> current = PrototypeIterator::GetCurrent(iter);
......@@ -479,7 +479,7 @@ Handle<Object> JSStackFrame::GetMethodName() {
return isolate_->factory()->null_value();
}
Handle<Object> JSStackFrame::GetTypeName() {
Handle<PrimitiveHeapObject> JSStackFrame::GetTypeName() {
// TODO(jgruber): Check for strict/constructor here as in
// CallSitePrototypeGetThis.
......@@ -565,8 +565,8 @@ Handle<Object> WasmStackFrame::GetFunction() const {
return handle(Smi::FromInt(wasm_func_index_), isolate_);
}
Handle<Object> WasmStackFrame::GetFunctionName() {
Handle<Object> name;
Handle<PrimitiveHeapObject> WasmStackFrame::GetFunctionName() {
Handle<PrimitiveHeapObject> name;
Handle<WasmModuleObject> module_object(wasm_instance_->module_object(),
isolate_);
if (!WasmModuleObject::GetFunctionNameOrNull(isolate_, module_object,
......@@ -583,8 +583,8 @@ Handle<Object> WasmStackFrame::GetScriptNameOrSourceUrl() {
return ScriptNameOrSourceUrl(script, isolate_);
}
Handle<Object> WasmStackFrame::GetWasmModuleName() {
Handle<Object> module_name;
Handle<PrimitiveHeapObject> WasmStackFrame::GetWasmModuleName() {
Handle<PrimitiveHeapObject> module_name;
Handle<WasmModuleObject> module_object(wasm_instance_->module_object(),
isolate_);
if (!WasmModuleObject::GetModuleNameOrNull(isolate_, module_object)
......@@ -594,7 +594,7 @@ Handle<Object> WasmStackFrame::GetWasmModuleName() {
return module_name;
}
Handle<Object> WasmStackFrame::GetWasmInstance() { return wasm_instance_; }
Handle<HeapObject> WasmStackFrame::GetWasmInstance() { return wasm_instance_; }
int WasmStackFrame::GetPosition() const {
return IsInterpreted() ? offset_ : code_->GetSourcePositionBefore(offset_);
......@@ -608,7 +608,9 @@ int WasmStackFrame::GetModuleOffset() const {
return function_offset + GetPosition();
}
Handle<Object> WasmStackFrame::Null() const {
Handle<Object> WasmStackFrame::GetFileName() { return Null(); }
Handle<PrimitiveHeapObject> WasmStackFrame::Null() const {
return isolate_->factory()->null_value();
}
......
......@@ -27,6 +27,7 @@ class AbstractCode;
class FrameArray;
class JSMessageObject;
class LookupIterator;
class PrimitiveHeapObject;
class SharedFunctionInfo;
class SourceInfo;
class WasmInstanceObject;
......@@ -67,13 +68,13 @@ class StackFrameBase {
virtual Handle<Object> GetFunction() const = 0;
virtual Handle<Object> GetFileName() = 0;
virtual Handle<Object> GetFunctionName() = 0;
virtual Handle<PrimitiveHeapObject> GetFunctionName() = 0;
virtual Handle<Object> GetScriptNameOrSourceUrl() = 0;
virtual Handle<Object> GetMethodName() = 0;
virtual Handle<Object> GetTypeName() = 0;
virtual Handle<Object> GetEvalOrigin();
virtual Handle<Object> GetWasmModuleName();
virtual Handle<Object> GetWasmInstance();
virtual Handle<PrimitiveHeapObject> GetMethodName() = 0;
virtual Handle<PrimitiveHeapObject> GetTypeName() = 0;
virtual Handle<PrimitiveHeapObject> GetEvalOrigin();
virtual Handle<PrimitiveHeapObject> GetWasmModuleName();
virtual Handle<HeapObject> GetWasmInstance();
// Returns the script ID if one is attached, -1 otherwise.
int GetScriptId() const;
......@@ -123,10 +124,10 @@ class JSStackFrame : public StackFrameBase {
Handle<Object> GetFunction() const override;
Handle<Object> GetFileName() override;
Handle<Object> GetFunctionName() override;
Handle<PrimitiveHeapObject> GetFunctionName() override;
Handle<Object> GetScriptNameOrSourceUrl() override;
Handle<Object> GetMethodName() override;
Handle<Object> GetTypeName() override;
Handle<PrimitiveHeapObject> GetMethodName() override;
Handle<PrimitiveHeapObject> GetTypeName() override;
int GetPosition() const override;
int GetLineNumber() override;
......@@ -171,13 +172,13 @@ class WasmStackFrame : public StackFrameBase {
Handle<Object> GetReceiver() const override;
Handle<Object> GetFunction() const override;
Handle<Object> GetFileName() override { return Null(); }
Handle<Object> GetFunctionName() override;
Handle<Object> GetFileName() override;
Handle<PrimitiveHeapObject> GetFunctionName() override;
Handle<Object> GetScriptNameOrSourceUrl() override;
Handle<Object> GetMethodName() override { return Null(); }
Handle<Object> GetTypeName() override { return Null(); }
Handle<Object> GetWasmModuleName() override;
Handle<Object> GetWasmInstance() override;
Handle<PrimitiveHeapObject> GetMethodName() override { return Null(); }
Handle<PrimitiveHeapObject> GetTypeName() override { return Null(); }
Handle<PrimitiveHeapObject> GetWasmModuleName() override;
Handle<HeapObject> GetWasmInstance() override;
int GetPosition() const override;
int GetLineNumber() override { return 0; }
......@@ -196,7 +197,7 @@ class WasmStackFrame : public StackFrameBase {
bool IsInterpreted() const { return code_ == nullptr; }
protected:
Handle<Object> Null() const;
Handle<PrimitiveHeapObject> Null() const;
bool HasScript() const override;
Handle<Script> GetScript() const override;
......
......@@ -3149,7 +3149,7 @@ Handle<StackFrameInfo> Factory::NewStackFrameInfo(
// TODO(szuend): Adjust this, once it is decided what name to use in both
// "simple" and "detailed" stack traces. This code is for
// backwards compatibility to fullfill test expectations.
auto function_name = frame->GetFunctionName();
Handle<PrimitiveHeapObject> function_name = frame->GetFunctionName();
bool is_user_java_script = false;
if (!is_wasm) {
Handle<Object> function = frame->GetFunction();
......@@ -3160,11 +3160,11 @@ Handle<StackFrameInfo> Factory::NewStackFrameInfo(
}
}
Handle<Object> method_name = undefined_value();
Handle<Object> type_name = undefined_value();
Handle<Object> eval_origin = frame->GetEvalOrigin();
Handle<Object> wasm_module_name = frame->GetWasmModuleName();
Handle<Object> wasm_instance = frame->GetWasmInstance();
Handle<PrimitiveHeapObject> method_name = undefined_value();
Handle<PrimitiveHeapObject> type_name = undefined_value();
Handle<PrimitiveHeapObject> eval_origin = frame->GetEvalOrigin();
Handle<PrimitiveHeapObject> wasm_module_name = frame->GetWasmModuleName();
Handle<HeapObject> wasm_instance = frame->GetWasmInstance();
// MethodName and TypeName are expensive to look up, so they are only
// included when they are strictly needed by the stack trace
......
......@@ -18,39 +18,22 @@
namespace v8 {
namespace internal {
OBJECT_CONSTRUCTORS_IMPL(StackFrameInfo, Struct)
TQ_OBJECT_CONSTRUCTORS_IMPL(StackFrameInfo)
NEVER_READ_ONLY_SPACE_IMPL(StackFrameInfo)
CAST_ACCESSOR(StackFrameInfo)
SMI_ACCESSORS(StackFrameInfo, line_number, kLineNumberOffset)
SMI_ACCESSORS(StackFrameInfo, column_number, kColumnNumberOffset)
SMI_ACCESSORS(StackFrameInfo, script_id, kScriptIdOffset)
SMI_ACCESSORS(StackFrameInfo, wasm_function_index, kWasmFunctionIndexOffset)
SMI_ACCESSORS(StackFrameInfo, promise_combinator_index,
kPromiseCombinatorIndexOffset)
SMI_ACCESSORS_CHECKED(StackFrameInfo, function_offset,
kPromiseCombinatorIndexOffset, is_wasm())
ACCESSORS(StackFrameInfo, script_name, Object, kScriptNameOffset)
ACCESSORS(StackFrameInfo, script_name_or_source_url, Object,
kScriptNameOrSourceUrlOffset)
ACCESSORS(StackFrameInfo, function_name, Object, kFunctionNameOffset)
ACCESSORS(StackFrameInfo, method_name, Object, kMethodNameOffset)
ACCESSORS(StackFrameInfo, type_name, Object, kTypeNameOffset)
ACCESSORS(StackFrameInfo, eval_origin, Object, kEvalOriginOffset)
ACCESSORS(StackFrameInfo, wasm_module_name, Object, kWasmModuleNameOffset)
ACCESSORS(StackFrameInfo, wasm_instance, Object, kWasmInstanceOffset)
SMI_ACCESSORS(StackFrameInfo, flag, kFlagOffset)
BOOL_ACCESSORS(StackFrameInfo, flag, is_eval, kIsEvalBit)
BOOL_ACCESSORS(StackFrameInfo, flag, is_constructor, kIsConstructorBit)
BOOL_ACCESSORS(StackFrameInfo, flag, is_wasm, kIsWasmBit)
BOOL_ACCESSORS(StackFrameInfo, flag, is_asmjs_wasm, kIsAsmJsWasmBit)
BOOL_ACCESSORS(StackFrameInfo, flag, is_user_java_script, kIsUserJavaScriptBit)
BOOL_ACCESSORS(StackFrameInfo, flag, is_toplevel, kIsToplevelBit)
BOOL_ACCESSORS(StackFrameInfo, flag, is_async, kIsAsyncBit)
BOOL_ACCESSORS(StackFrameInfo, flag, is_promise_all, kIsPromiseAllBit)
BOOL_ACCESSORS(StackFrameInfo, flag, is_promise_any, kIsPromiseAnyBit)
BOOL_ACCESSORS(StackFrameInfo, flag, is_eval, IsEvalBit::kShift)
BOOL_ACCESSORS(StackFrameInfo, flag, is_constructor, IsConstructorBit::kShift)
BOOL_ACCESSORS(StackFrameInfo, flag, is_wasm, IsWasmBit::kShift)
BOOL_ACCESSORS(StackFrameInfo, flag, is_asmjs_wasm, IsAsmJsWasmBit::kShift)
BOOL_ACCESSORS(StackFrameInfo, flag, is_user_java_script,
IsUserJavaScriptBit::kShift)
BOOL_ACCESSORS(StackFrameInfo, flag, is_toplevel, IsToplevelBit::kShift)
BOOL_ACCESSORS(StackFrameInfo, flag, is_async, IsAsyncBit::kShift)
BOOL_ACCESSORS(StackFrameInfo, flag, is_promise_all, IsPromiseAllBit::kShift)
BOOL_ACCESSORS(StackFrameInfo, flag, is_promise_any, IsPromiseAnyBit::kShift)
TQ_OBJECT_CONSTRUCTORS_IMPL(StackTraceFrame)
NEVER_READ_ONLY_SPACE_IMPL(StackTraceFrame)
......
......@@ -6,6 +6,7 @@
#define V8_OBJECTS_STACK_FRAME_INFO_H_
#include "src/objects/struct.h"
#include "torque-generated/bit-fields-tq.h"
// Has to be the last include (doesn't have include guards):
#include "src/objects/object-macros.h"
......@@ -16,24 +17,12 @@ namespace internal {
class FrameArray;
class WasmInstanceObject;
class StackFrameInfo : public Struct {
class StackFrameInfo
: public TorqueGeneratedStackFrameInfo<StackFrameInfo, Struct> {
public:
NEVER_READ_ONLY_SPACE
DECL_INT_ACCESSORS(line_number)
DECL_INT_ACCESSORS(column_number)
DECL_INT_ACCESSORS(script_id)
DECL_INT_ACCESSORS(wasm_function_index)
DECL_INT_ACCESSORS(promise_combinator_index)
// Wasm frames only: function_offset instead of promise_combinator_index.
DECL_INT_ACCESSORS(function_offset)
DECL_ACCESSORS(script_name, Object)
DECL_ACCESSORS(script_name_or_source_url, Object)
DECL_ACCESSORS(function_name, Object)
DECL_ACCESSORS(method_name, Object)
DECL_ACCESSORS(type_name, Object)
DECL_ACCESSORS(eval_origin, Object)
DECL_ACCESSORS(wasm_module_name, Object)
DECL_ACCESSORS(wasm_instance, Object)
DECL_BOOLEAN_ACCESSORS(is_eval)
DECL_BOOLEAN_ACCESSORS(is_constructor)
DECL_BOOLEAN_ACCESSORS(is_wasm)
......@@ -43,30 +32,15 @@ class StackFrameInfo : public Struct {
DECL_BOOLEAN_ACCESSORS(is_async)
DECL_BOOLEAN_ACCESSORS(is_promise_all)
DECL_BOOLEAN_ACCESSORS(is_promise_any)
DECL_INT_ACCESSORS(flag)
DECL_CAST(StackFrameInfo)
// Dispatched behavior.
DECL_PRINTER(StackFrameInfo)
DECL_VERIFIER(StackFrameInfo)
DEFINE_FIELD_OFFSET_CONSTANTS(Struct::kHeaderSize,
TORQUE_GENERATED_STACK_FRAME_INFO_FIELDS)
private:
// Bit position in the flag, from least significant bit position.
static const int kIsEvalBit = 0;
static const int kIsConstructorBit = 1;
static const int kIsWasmBit = 2;
static const int kIsAsmJsWasmBit = 3;
static const int kIsUserJavaScriptBit = 4;
static const int kIsToplevelBit = 5;
static const int kIsAsyncBit = 6;
static const int kIsPromiseAllBit = 7;
static const int kIsPromiseAnyBit = 8;
OBJECT_CONSTRUCTORS(StackFrameInfo, Struct);
DEFINE_TORQUE_GENERATED_STACK_FRAME_INFO_FLAGS()
TQ_OBJECT_CONSTRUCTORS(StackFrameInfo)
};
// This class is used to lazily initialize a StackFrameInfo object from
......
......@@ -2,21 +2,34 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
bitfield struct StackFrameInfoFlags extends uint31 {
is_eval: bool: 1 bit;
is_constructor: bool: 1 bit;
is_wasm: bool: 1 bit;
is_asm_js_wasm: bool: 1 bit;
is_user_java_script: bool: 1 bit;
is_toplevel: bool: 1 bit;
is_async: bool: 1 bit;
is_promise_all: bool: 1 bit;
is_promise_any: bool: 1 bit;
}
@generateCppClass
extern class StackFrameInfo extends Struct {
line_number: Smi;
column_number: Smi;
promise_combinator_index: Smi;
script_id: Smi;
wasm_function_index: Smi;
script_name: String|Null|Undefined;
script_name_or_source_url: String|Null|Undefined;
script_name: Object;
script_name_or_source_url: Object;
function_name: String|Null|Undefined;
method_name: String|Null|Undefined;
type_name: String|Null|Undefined;
eval_origin: String|Null|Undefined;
wasm_module_name: String|Null|Undefined;
wasm_instance: WasmInstanceObject|Null|Undefined;
flag: Smi;
flag: SmiTagged<StackFrameInfoFlags>;
}
@generateCppClass
......
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