diff --git a/runtime/compiler/ecmascript_runtime_interface.cpp b/runtime/compiler/ecmascript_runtime_interface.cpp index 7e2e913acb25f1597131bbf1ab92567913943218..0ee2a46050a6d347cc237133b6c3a2497bbd5630 100644 --- a/runtime/compiler/ecmascript_runtime_interface.cpp +++ b/runtime/compiler/ecmascript_runtime_interface.cpp @@ -52,7 +52,7 @@ uint32_t EcmaRuntimeInterface::GetFunctionTargetOffset([[maybe_unused]] Arch arc return cross_values::GetJsfunctionMethodOffset(arch); } -uintptr_t EcmaRuntimeInterface::GetGlobalVarAddress(MethodPtr method, size_t id) +NO_OPTIMIZE uintptr_t EcmaRuntimeInterface::GetGlobalVarAddress(MethodPtr method, size_t id) { if (ecma_vm_ == nullptr) { return 0; @@ -62,36 +62,56 @@ uintptr_t EcmaRuntimeInterface::GetGlobalVarAddress(MethodPtr method, size_t id) if (thread == nullptr || !thread->IsThreadAlive()) { return 0; } + std::cerr << "1\n"; auto panda_file = JsMethodCast(method)->GetPandaFile(); JSTaggedValue constant_pool(JSTaggedValue::VALUE_HOLE); + ScopedMutatorLock lock; + auto func = [&](Program *p) { constant_pool = p->GetConstantPool(); }; ecma_vm_->EnumerateProgram(func, panda_file->GetFilename()); if (constant_pool.IsUndefined()) { return 0; } + // std::cerr << "CONSTANT POOL\n"; + // constant_pool.Dump(thread, std::cerr); + + std::cerr << "2\n"; ASSERT(!constant_pool.IsHole()); JSTaggedValue key = ConstantPool::Cast(constant_pool.GetHeapObject())->GetObjectFromCache(id); + // std::cerr << "1 key = " << key.GetRawData() << "\n"; auto global_obj = thread->GetGlobalObject(); + // std::cerr << "1 global_obj = " << global_obj.GetRawData() << "\n"; auto js_obj = JSObject::Cast(global_obj.GetTaggedObject()); TaggedArray *array = TaggedArray::Cast(js_obj->GetProperties().GetTaggedObject()); if (array->GetLength() == 0) { return 0; } - + // std::cerr << "3\n"; + // std::cerr << "2 key = " << ConstantPool::Cast(constant_pool.GetHeapObject())->GetObjectFromCache(id).GetRawData() << "\n"; + // std::cerr << "2 global_obj = " << thread->GetGlobalObject().GetRawData() << "\n"; + + // std::cerr << "GLOBAL\n"; + // global_obj.Dump(thread, std::cerr); + // std::cerr << "KEY\n"; + // key.Dump(thread, std::cerr); GlobalDictionary *dict = GlobalDictionary::Cast(array); + // std::cerr << "3 key = " << ConstantPool::Cast(constant_pool.GetHeapObject())->GetObjectFromCache(id).GetRawData() << "\n"; + // std::cerr << "3 global_obj = " << thread->GetGlobalObject().GetRawData() << "\n"; int entry = dict->FindEntry(key); if (entry == -1) { return 0; } + std::cerr << "4\n"; JSTaggedValue res(dict->GetSafeBox(entry)); // we can't set an attribute in compiler thread. if (res.IsUndefined() || res.IsHole() || !res.IsPropertyBox()) { return 0; } + std::cerr << "5\n"; ASSERT(res.IsPropertyBox()); return reinterpret_cast(res.GetHeapObject()); diff --git a/runtime/dump.cpp b/runtime/dump.cpp index d28a3129e9cdeb3ae4e32fe5e2eb4b9792cff79c..e3ad89018bccedad992a09ec463c14842dbd3172 100644 --- a/runtime/dump.cpp +++ b/runtime/dump.cpp @@ -717,9 +717,9 @@ void JSTaggedValue::Dump(JSThread *thread, std::ostream &os) const } } -void JSTaggedValue::D() const +void JSTaggedValue::D(JSThread *thread) const { - Dump(nullptr, std::cout); + Dump(thread, std::cout); } void JSTaggedValue::DV(JSTaggedType val) diff --git a/runtime/js_tagged_value.h b/runtime/js_tagged_value.h index 970bd94faf4cb1c51b3e7651ff25bdf1324703bc..6d7f831f86dd50ceb04c59d1491b964f43d25fab 100644 --- a/runtime/js_tagged_value.h +++ b/runtime/js_tagged_value.h @@ -344,7 +344,7 @@ public: void DumpTaggedValue(JSThread *thread, std::ostream &os) const DUMP_API_ATTR; void Dump(JSThread *thread, std::ostream &os) const DUMP_API_ATTR; - void D() const DUMP_API_ATTR; + void D(JSThread *thread = nullptr) const DUMP_API_ATTR; void DumpForSnapshot(JSThread *thread, std::vector> &vec, bool is_vm_mode = true) const; static void DV(JSTaggedType val) DUMP_API_ATTR; diff --git a/runtime/tagged_hash_table-inl.h b/runtime/tagged_hash_table-inl.h index 9c25878a62b554c5fc107631685955acf1945eef..e25ffab2b257967daacff5cc09ee6a23edd8cff7 100644 --- a/runtime/tagged_hash_table-inl.h +++ b/runtime/tagged_hash_table-inl.h @@ -91,6 +91,7 @@ template int TaggedHashTable::FindEntry(const JSTaggedValue &key) { size_t size = Size(); + int count = 1; JSTaggedValue key_value; int hash = Derived::Hash(key);