fix ide heapdump

Signed-off-by: z00522183 <zhanheng2@huawei.com>
Change-Id: I1860c2a354012fdfd6c39cb36a5f871fec1a2cbc
This commit is contained in:
zhanheng 2024-05-10 10:07:06 +08:00
parent 068f004cc6
commit a0090ce8c6
6 changed files with 32 additions and 14 deletions

View File

@ -216,20 +216,20 @@ bool HeapProfiler::DumpHeapSnapshot(DumpFormat dumpFormat, Stream *stream, Progr
bool isFullGC, bool isSimplify, bool isSync)
{
bool res = false;
base::BlockHookScope blockScope;
ThreadManagedScope managedScope(vm_->GetJSThread());
if (isFullGC) {
[[maybe_unused]] bool heapClean = ForceFullGC(vm_);
ASSERT(heapClean);
}
// suspend All.
SuspendAllScope suspendScope(vm_->GetAssociatedJSThread());
if (isFullGC) {
DISALLOW_GARBAGE_COLLECTION;
const_cast<Heap *>(vm_->GetHeap())->Prepare();
}
pid_t pid = -1;
{
base::BlockHookScope blockScope;
ThreadManagedScope managedScope(vm_->GetJSThread());
// suspend All.
SuspendAllScope suspendScope(vm_->GetAssociatedJSThread());
if (isFullGC) {
DISALLOW_GARBAGE_COLLECTION;
const_cast<Heap *>(vm_->GetHeap())->Prepare();
}
// fork
if ((pid = fork()) < 0) {
LOG_ECMA(ERROR) << "DumpHeapSnapshot fork failed!";

View File

@ -1114,7 +1114,8 @@ const CString HeapSnapshot::ParseObjectName(TaggedObject *obj)
{
ASSERT(JSTaggedValue(obj).IsJSObject());
JSThread *thread = vm_->GetJSThread();
return JSObject::ExtractConstructorAndRecordName(thread, obj);
bool isCallGetter = false;
return JSObject::ExtractConstructorAndRecordName(thread, obj, true, &isCallGetter);
}
Node *HeapSnapshot::InsertNodeUnique(Node *node)

View File

@ -2388,14 +2388,20 @@ void JSObject::ToPropertyDescriptor(JSThread *thread, const JSHandle<JSTaggedVal
// 23. Return desc.
}
const CString JSObject::ExtractConstructorAndRecordName(JSThread *thread, TaggedObject *obj)
const CString JSObject::ExtractConstructorAndRecordName(JSThread *thread, TaggedObject *obj, bool noAllocate,
bool *isCallGetter)
{
CString result = "";
const GlobalEnvConstants *globalConst = thread->GlobalConstants();
JSHandle<JSTaggedValue> contructorKey = globalConst->GetHandledConstructorString();
JSTaggedValue objConstructor = ObjectFastOperator::GetPropertyByName(thread, JSTaggedValue(obj),
contructorKey.GetTaggedValue());
contructorKey.GetTaggedValue(), noAllocate,
isCallGetter);
if (*isCallGetter) {
return "JSObject";
}
if (!objConstructor.IsJSFunction()) {
return "JSObject";
}

View File

@ -702,7 +702,8 @@ public:
DECL_VISIT_OBJECT_FOR_JS_OBJECT(ECMAObject, PROPERTIES_OFFSET, SIZE)
DECL_DUMP()
static const CString ExtractConstructorAndRecordName(JSThread *thread, TaggedObject *obj);
static const CString ExtractConstructorAndRecordName(JSThread *thread, TaggedObject *obj, bool noAllocate = false,
bool *isCallGetter = nullptr);
static JSHandle<NameDictionary> PUBLIC_API TransitionToDictionary(const JSThread *thread,
const JSHandle<JSObject> &receiver);

View File

@ -146,7 +146,8 @@ JSTaggedValue ObjectFastOperator::TryGetPropertyByNameThroughCacheAtLocal(JSThre
template<ObjectFastOperator::Status status>
JSTaggedValue ObjectFastOperator::GetPropertyByName(JSThread *thread, JSTaggedValue receiver,
JSTaggedValue key)
JSTaggedValue key, [[maybe_unused]]bool noAllocate,
[[maybe_unused]]bool *isCallGetter)
{
INTERPRETER_TRACE(thread, GetPropertyByName);
// no gc when return hole
@ -194,6 +195,10 @@ JSTaggedValue ObjectFastOperator::GetPropertyByName(JSThread *thread, JSTaggedVa
if (GetInternal(status)) {
return value;
}
if (noAllocate) {
*isCallGetter = true;
return value;
}
return CallGetter(thread, receiver, holder, value);
}
ASSERT(!value.IsAccessor());
@ -213,6 +218,10 @@ JSTaggedValue ObjectFastOperator::GetPropertyByName(JSThread *thread, JSTaggedVa
if (GetInternal(status)) {
return value;
}
if (noAllocate) {
*isCallGetter = true;
return value;
}
return CallGetter(thread, receiver, holder, value);
}
ASSERT(!value.IsAccessor());

View File

@ -56,7 +56,8 @@ public:
template<Status status = Status::None>
static inline JSTaggedValue GetPropertyByName(JSThread *thread, JSTaggedValue receiver,
JSTaggedValue key);
JSTaggedValue key, bool noAllocate = false,
bool *isCallGetter = nullptr);
template <Status status = Status::None>
static inline JSTaggedValue TrySetPropertyByNameThroughCacheAtLocal(JSThread *thread, JSTaggedValue receiver,