Bug 1293551 - Part 2: Add debug-only function to dump Promise allocation site and resolution site. r=till

This commit is contained in:
Tooru Fujisawa 2016-08-10 22:26:08 +09:00
Родитель aad6e47f0d
Коммит fd6bb53cea
2 изменённых файлов: 28 добавлений и 0 удалений

Просмотреть файл

@ -4760,6 +4760,26 @@ JS::GetPromiseResolutionSite(JS::HandleObject promise)
return promise->as<PromiseObject>().resolutionSite();
}
#ifdef DEBUG
JS_PUBLIC_API(void)
JS::DumpPromiseAllocationSite(JSContext* cx, JS::HandleObject promise)
{
RootedObject stack(cx, promise->as<PromiseObject>().allocationSite());
UniqueChars stackStr(reinterpret_cast<char*>(BuildUTF8StackString(cx, stack).get()));
if (stackStr.get())
fputs(stackStr.get(), stderr);
}
JS_PUBLIC_API(void)
JS::DumpPromiseResolutionSite(JSContext* cx, JS::HandleObject promise)
{
RootedObject stack(cx, promise->as<PromiseObject>().resolutionSite());
UniqueChars stackStr(reinterpret_cast<char*>(BuildUTF8StackString(cx, stack).get()));
if (stackStr.get())
fputs(stackStr.get(), stderr);
}
#endif
JS_PUBLIC_API(JSObject*)
JS::CallOriginalPromiseResolve(JSContext* cx, JS::HandleValue resolutionValue)
{

Просмотреть файл

@ -4436,6 +4436,14 @@ GetPromiseAllocationSite(JS::HandleObject promise);
extern JS_PUBLIC_API(JSObject*)
GetPromiseResolutionSite(JS::HandleObject promise);
#ifdef DEBUG
extern JS_PUBLIC_API(void)
DumpPromiseAllocationSite(JSContext* cx, JS::HandleObject promise);
extern JS_PUBLIC_API(void)
DumpPromiseResolutionSite(JSContext* cx, JS::HandleObject promise);
#endif
/**
* Calls the current compartment's original Promise.resolve on the original
* Promise constructor, with `resolutionValue` passed as an argument.