JSObject JSObject::FindJSObjectFromPrivateData(JSContext js_context, void* private_data) { HAL_JSOBJECT_LOCK_GUARD_STATIC; const auto key = reinterpret_cast<std::intptr_t>(private_data); const auto position = js_private_data_to_js_object_ref_map__.find(key); const bool found = position != js_private_data_to_js_object_ref_map__.end(); // This could happen when owner object is gargabe collected while executing async operation. // This Error object will be only used internally to see if object is found or not. if (!found) { return js_context.CreateError(); } JSObjectRef js_object_ref = reinterpret_cast<JSObjectRef>(position -> second); HAL_LOG_TRACE("JSObject::FindJSObjectFromPrivateData: found = ", found, " for data = ", key, ", JSObjectRef = ", js_object_ref); return FindJSObject(static_cast<JSContextRef>(js_context), js_object_ref); }