Commit e9c4c530 authored by Jakob Kummerow's avatar Jakob Kummerow Committed by Commit Bot

[ubsan] Port Struct subclasses, part 5

BreakPoint, BreakPointInfo, DebugInfo

Bug: v8:3770
Change-Id: Ibad956b0933b5e994407475faaf4a8770e455318
Reviewed-on: https://chromium-review.googlesource.com/c/1377458
Commit-Queue: Jakob Kummerow <jkummerow@chromium.org>
Reviewed-by: 's avatarToon Verwaest <verwaest@chromium.org>
Cr-Commit-Position: refs/heads/master@{#58269}
parent 316b152a
......@@ -390,14 +390,13 @@ void Debug::Iterate(RootVisitor* v) {
FullObjectSlot(&thread_local_.ignore_step_into_function_));
}
DebugInfoListNode::DebugInfoListNode(Isolate* isolate, DebugInfo* debug_info)
DebugInfoListNode::DebugInfoListNode(Isolate* isolate, DebugInfo debug_info)
: next_(nullptr) {
// Globalize the request debug info object and make it weak.
GlobalHandles* global_handles = isolate->global_handles();
debug_info_ = global_handles->Create(debug_info).location();
}
DebugInfoListNode::~DebugInfoListNode() {
if (debug_info_ == nullptr) return;
GlobalHandles::Destroy(debug_info_);
......@@ -688,7 +687,7 @@ void Debug::ApplyBreakPoints(Handle<DebugInfo> debug_info) {
FixedArray break_points = debug_info->break_points();
for (int i = 0; i < break_points->length(); i++) {
if (break_points->get(i)->IsUndefined(isolate_)) continue;
BreakPointInfo* info = BreakPointInfo::cast(break_points->get(i));
BreakPointInfo info = BreakPointInfo::cast(break_points->get(i));
if (info->GetBreakPointCount(isolate_) == 0) continue;
DCHECK(debug_info->HasInstrumentedBytecodeArray());
BreakIterator it(debug_info);
......@@ -1093,7 +1092,7 @@ Handle<Object> Debug::GetSourceBreakLocations(
int count = 0;
for (int i = 0; i < debug_info->break_points()->length(); ++i) {
if (!debug_info->break_points()->get(i)->IsUndefined(isolate)) {
BreakPointInfo* break_point_info =
BreakPointInfo break_point_info =
BreakPointInfo::cast(debug_info->break_points()->get(i));
int break_points = break_point_info->GetBreakPointCount(isolate);
if (break_points == 0) continue;
......@@ -1782,7 +1781,7 @@ void Debug::OnDebugBreak(Handle<FixedArray> break_points_hit) {
int inspector_break_points_count = 0;
// This array contains breakpoints installed using JS debug API.
for (int i = 0; i < break_points_hit->length(); ++i) {
BreakPoint* break_point = BreakPoint::cast(break_points_hit->get(i));
BreakPoint break_point = BreakPoint::cast(break_points_hit->get(i));
inspector_break_points_hit.push_back(break_point->id());
++inspector_break_points_count;
}
......
......@@ -170,7 +170,7 @@ class BreakIterator {
// weak handles to avoid a debug info object to keep a function alive.
class DebugInfoListNode {
public:
DebugInfoListNode(Isolate* isolate, DebugInfo* debug_info);
DebugInfoListNode(Isolate* isolate, DebugInfo debug_info);
~DebugInfoListNode();
DebugInfoListNode* next() { return next_; }
......
......@@ -2198,7 +2198,7 @@ void ScopeInfo::ScopeInfoPrint(std::ostream& os) { // NOLINT
}
void DebugInfo::DebugInfoPrint(std::ostream& os) { // NOLINT
HeapObject::PrintHeader(os, "DebugInfo");
PrintHeader(os, "DebugInfo");
os << "\n - flags: " << flags();
os << "\n - debugger_hints: " << debugger_hints();
os << "\n - shared: " << Brief(shared());
......
......@@ -14087,21 +14087,21 @@ void SharedFunctionInfo::SetScript(Handle<SharedFunctionInfo> shared,
bool SharedFunctionInfo::HasBreakInfo() const {
if (!HasDebugInfo()) return false;
DebugInfo* info = DebugInfo::cast(GetDebugInfo());
DebugInfo info = GetDebugInfo();
bool has_break_info = info->HasBreakInfo();
return has_break_info;
}
bool SharedFunctionInfo::BreakAtEntry() const {
if (!HasDebugInfo()) return false;
DebugInfo* info = DebugInfo::cast(GetDebugInfo());
DebugInfo info = GetDebugInfo();
bool break_at_entry = info->BreakAtEntry();
return break_at_entry;
}
bool SharedFunctionInfo::HasCoverageInfo() const {
if (!HasDebugInfo()) return false;
DebugInfo* info = DebugInfo::cast(GetDebugInfo());
DebugInfo info = GetDebugInfo();
bool has_coverage_info = info->HasCoverageInfo();
return has_coverage_info;
}
......
......@@ -18,12 +18,17 @@
namespace v8 {
namespace internal {
OBJECT_CONSTRUCTORS_IMPL(BreakPoint, Tuple2Ptr)
OBJECT_CONSTRUCTORS_IMPL(BreakPointInfo, Tuple2Ptr)
OBJECT_CONSTRUCTORS_IMPL(CoverageInfo, FixedArray)
OBJECT_CONSTRUCTORS_IMPL(DebugInfo, StructPtr)
CAST_ACCESSOR(BreakPointInfo)
CAST_ACCESSOR(DebugInfo)
NEVER_READ_ONLY_SPACE_IMPL(DebugInfo)
CAST_ACCESSOR2(BreakPointInfo)
CAST_ACCESSOR2(DebugInfo)
CAST_ACCESSOR2(CoverageInfo)
CAST_ACCESSOR(BreakPoint)
CAST_ACCESSOR2(BreakPoint)
SMI_ACCESSORS(DebugInfo, flags, kFlagsOffset)
ACCESSORS2(DebugInfo, shared, SharedFunctionInfo, kSharedFunctionInfoOffset)
......
......@@ -78,7 +78,7 @@ Object* DebugInfo::GetBreakPointInfo(Isolate* isolate, int source_position) {
DCHECK(HasBreakInfo());
for (int i = 0; i < break_points()->length(); i++) {
if (!break_points()->get(i)->IsUndefined(isolate)) {
BreakPointInfo* break_point_info =
BreakPointInfo break_point_info =
BreakPointInfo::cast(break_points()->get(i));
if (break_point_info->source_position() == source_position) {
return break_point_info;
......@@ -166,7 +166,7 @@ int DebugInfo::GetBreakPointCount(Isolate* isolate) {
int count = 0;
for (int i = 0; i < break_points()->length(); i++) {
if (!break_points()->get(i)->IsUndefined(isolate)) {
BreakPointInfo* break_point_info =
BreakPointInfo break_point_info =
BreakPointInfo::cast(break_points()->get(i));
count += break_point_info->GetBreakPointCount(isolate);
}
......@@ -215,7 +215,7 @@ DebugInfo::SideEffectState DebugInfo::GetSideEffectState(Isolate* isolate) {
}
namespace {
bool IsEqual(BreakPoint* break_point1, BreakPoint* break_point2) {
bool IsEqual(BreakPoint break_point1, BreakPoint break_point2) {
return break_point1->id() == break_point2->id();
}
} // namespace
......
......@@ -20,8 +20,9 @@ class BytecodeArray;
// The DebugInfo class holds additional information for a function being
// debugged.
class DebugInfo : public Struct, public NeverReadOnlySpaceObject {
class DebugInfo : public StructPtr {
public:
NEVER_READ_ONLY_SPACE
enum Flag {
kNone = 0,
kHasBreakInfo = 1 << 0,
......@@ -161,7 +162,7 @@ class DebugInfo : public Struct, public NeverReadOnlySpaceObject {
void ClearCoverageInfo(Isolate* isolate);
DECL_ACCESSORS(coverage_info, Object)
DECL_CAST(DebugInfo)
DECL_CAST2(DebugInfo)
// Dispatched behavior.
DECL_PRINTER(DebugInfo)
......@@ -189,13 +190,13 @@ class DebugInfo : public Struct, public NeverReadOnlySpaceObject {
// Get the break point info object for a source position.
Object* GetBreakPointInfo(Isolate* isolate, int source_position);
DISALLOW_IMPLICIT_CONSTRUCTORS(DebugInfo);
OBJECT_CONSTRUCTORS(DebugInfo, StructPtr);
};
// The BreakPointInfo class holds information for break points set in a
// function. The DebugInfo object holds a BreakPointInfo object for each code
// position with one or more break points.
class BreakPointInfo : public Tuple2 {
class BreakPointInfo : public Tuple2Ptr {
public:
// The position in the source for the break position.
DECL_INT_ACCESSORS(source_position)
......@@ -216,13 +217,12 @@ class BreakPointInfo : public Tuple2 {
int GetStatementPosition(Handle<DebugInfo> debug_info);
DECL_CAST(BreakPointInfo)
DECL_CAST2(BreakPointInfo)
static const int kSourcePositionOffset = kValue1Offset;
static const int kBreakPointsOffset = kValue2Offset;
private:
DISALLOW_IMPLICIT_CONSTRUCTORS(BreakPointInfo);
OBJECT_CONSTRUCTORS(BreakPointInfo, Tuple2Ptr);
};
// Holds information related to block code coverage.
......@@ -265,18 +265,17 @@ class CoverageInfo : public FixedArray {
};
// Holds breakpoint related information. This object is used by inspector.
class BreakPoint : public Tuple2 {
class BreakPoint : public Tuple2Ptr {
public:
DECL_INT_ACCESSORS(id)
DECL_ACCESSORS2(condition, String)
DECL_CAST(BreakPoint)
DECL_CAST2(BreakPoint)
static const int kIdOffset = kValue1Offset;
static const int kConditionOffset = kValue2Offset;
private:
DISALLOW_IMPLICIT_CONSTRUCTORS(BreakPoint);
OBJECT_CONSTRUCTORS(BreakPoint, Tuple2Ptr);
};
} // namespace internal
......
......@@ -662,12 +662,12 @@ bool SharedFunctionInfo::HasDebugInfo() const {
return script_or_debug_info()->IsDebugInfo();
}
DebugInfo* SharedFunctionInfo::GetDebugInfo() const {
DebugInfo SharedFunctionInfo::GetDebugInfo() const {
DCHECK(HasDebugInfo());
return DebugInfo::cast(script_or_debug_info());
}
void SharedFunctionInfo::SetDebugInfo(DebugInfo* debug_info) {
void SharedFunctionInfo::SetDebugInfo(DebugInfo debug_info) {
DCHECK(!HasDebugInfo());
DCHECK_EQ(debug_info->script(), script_or_debug_info());
set_script_or_debug_info(debug_info);
......
......@@ -404,8 +404,8 @@ class SharedFunctionInfo : public HeapObjectPtr {
// The function is subject to debugging if a debug info is attached.
inline bool HasDebugInfo() const;
inline DebugInfo* GetDebugInfo() const;
inline void SetDebugInfo(DebugInfo* debug_info);
inline DebugInfo GetDebugInfo() const;
inline void SetDebugInfo(DebugInfo debug_info);
// The offset of the 'function' token in the script source relative to the
// start position. Can return kFunctionTokenOutOfRange if offset doesn't
......
......@@ -181,7 +181,7 @@ void CodeSerializer::SerializeObject(HeapObject* obj, HowToCode how_to_code,
// is context independent.
DCHECK(!sfi->IsApiFunction() && !sfi->HasAsmWasmData());
DebugInfo* debug_info = nullptr;
DebugInfo debug_info;
BytecodeArray debug_bytecode_array;
if (sfi->HasDebugInfo()) {
// Clear debug info.
......@@ -201,7 +201,7 @@ void CodeSerializer::SerializeObject(HeapObject* obj, HowToCode how_to_code,
sfi->set_deserialized(was_deserialized);
// Restore debug info
if (debug_info != nullptr) {
if (!debug_info.is_null()) {
sfi->set_script_or_debug_info(debug_info);
if (!debug_bytecode_array.is_null()) {
sfi->SetDebugBytecodeArray(debug_bytecode_array);
......
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