/* Lookup the string for the function/script, creating one if necessary */ const char* SPSProfiler::profileString(JSScript* script, JSFunction* maybeFun) { auto locked = strings.lock(); MOZ_ASSERT(locked->initialized()); ProfileStringMap::AddPtr s = locked->lookupForAdd(script); if (!s) { auto str = allocProfileString(script, maybeFun); if (!str || !locked->add(s, script, mozilla::Move(str))) return nullptr; } return s->value().get(); }
/* Lookup the string for the function/script, creating one if necessary */ const char* SPSProfiler::profileString(JSScript *script, JSFunction *maybeFun) { AutoSPSLock lock(lock_); MOZ_ASSERT(strings.initialized()); ProfileStringMap::AddPtr s = strings.lookupForAdd(script); if (s) return s->value(); const char *str = allocProfileString(script, maybeFun); if (str == nullptr) return nullptr; if (!strings.add(s, script, str)) { js_free(const_cast<char *>(str)); return nullptr; } return str; }