зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1552979 - Begin fleshing out off-thread script/module compilation support for UTF-8. r=arai
Differential Revision: https://phabricator.services.mozilla.com/D31896 --HG-- extra : rebase_source : dda3b1ae77361a5ab0a0ad52c0beaf7498553c20
This commit is contained in:
Родитель
e85889f5df
Коммит
3a69834cbc
|
@ -12,6 +12,7 @@
|
|||
#define js_OffThreadScriptCompilation_h
|
||||
|
||||
#include "mozilla/Range.h" // mozilla::Range
|
||||
#include "mozilla/Utf8.h" // mozilla::Utf8Unit
|
||||
#include "mozilla/Vector.h" // mozilla::Vector
|
||||
|
||||
#include <stddef.h> // size_t
|
||||
|
@ -67,6 +68,15 @@ extern JS_PUBLIC_API bool CompileOffThread(
|
|||
SourceText<char16_t>& srcBuf, OffThreadCompileCallback callback,
|
||||
void* callbackData);
|
||||
|
||||
// NOTE: Unlike for the normal sync compilation functions, this function NEVER
|
||||
// INFLATES TO UTF-16. Therefore, it is ALWAYS invoking experimental
|
||||
// UTF-8 support. Inflate to UTF-16 yourself and use the other overload
|
||||
// if you're unable to take a risk using unstable functionality.
|
||||
extern JS_PUBLIC_API bool CompileOffThread(
|
||||
JSContext* cx, const ReadOnlyCompileOptions& options,
|
||||
SourceText<mozilla::Utf8Unit>& srcBuf, OffThreadCompileCallback callback,
|
||||
void* callbackData);
|
||||
|
||||
extern JS_PUBLIC_API JSScript* FinishOffThreadScript(JSContext* cx,
|
||||
OffThreadToken* token);
|
||||
|
||||
|
@ -78,6 +88,15 @@ extern JS_PUBLIC_API bool CompileOffThreadModule(
|
|||
SourceText<char16_t>& srcBuf, OffThreadCompileCallback callback,
|
||||
void* callbackData);
|
||||
|
||||
// NOTE: Unlike for the normal sync compilation functions, this function NEVER
|
||||
// INFLATES TO UTF-16. Therefore, it is ALWAYS invoking experimental
|
||||
// UTF-8 support. Inflate to UTF-16 yourself and use the other overload
|
||||
// if you're unable to take a risk using unstable functionality.
|
||||
extern JS_PUBLIC_API bool CompileOffThreadModule(
|
||||
JSContext* cx, const ReadOnlyCompileOptions& options,
|
||||
SourceText<mozilla::Utf8Unit>& srcBuf, OffThreadCompileCallback callback,
|
||||
void* callbackData);
|
||||
|
||||
extern JS_PUBLIC_API JSObject* FinishOffThreadModule(JSContext* cx,
|
||||
OffThreadToken* token);
|
||||
|
||||
|
|
|
@ -901,13 +901,45 @@ static bool StartOffThreadParseTask(JSContext* cx, UniquePtr<ParseTask> task,
|
|||
return true;
|
||||
}
|
||||
|
||||
template <typename Unit>
|
||||
static bool StartOffThreadParseScriptInternal(
|
||||
JSContext* cx, const ReadOnlyCompileOptions& options,
|
||||
JS::SourceText<Unit>& srcBuf, JS::OffThreadCompileCallback callback,
|
||||
void* callbackData) {
|
||||
auto task = cx->make_unique<ScriptParseTask<Unit>>(cx, srcBuf, callback,
|
||||
callbackData);
|
||||
if (!task) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return StartOffThreadParseTask(cx, std::move(task), options);
|
||||
}
|
||||
|
||||
bool js::StartOffThreadParseScript(JSContext* cx,
|
||||
const ReadOnlyCompileOptions& options,
|
||||
JS::SourceText<char16_t>& srcBuf,
|
||||
JS::OffThreadCompileCallback callback,
|
||||
void* callbackData) {
|
||||
auto task = cx->make_unique<ScriptParseTask<char16_t>>(cx, srcBuf, callback,
|
||||
callbackData);
|
||||
return StartOffThreadParseScriptInternal(cx, options, srcBuf, callback,
|
||||
callbackData);
|
||||
}
|
||||
|
||||
bool js::StartOffThreadParseScript(JSContext* cx,
|
||||
const ReadOnlyCompileOptions& options,
|
||||
JS::SourceText<Utf8Unit>& srcBuf,
|
||||
JS::OffThreadCompileCallback callback,
|
||||
void* callbackData) {
|
||||
return StartOffThreadParseScriptInternal(cx, options, srcBuf, callback,
|
||||
callbackData);
|
||||
}
|
||||
|
||||
template <typename Unit>
|
||||
static bool StartOffThreadParseModuleInternal(
|
||||
JSContext* cx, const ReadOnlyCompileOptions& options,
|
||||
JS::SourceText<Unit>& srcBuf, JS::OffThreadCompileCallback callback,
|
||||
void* callbackData) {
|
||||
auto task = cx->make_unique<ModuleParseTask<Unit>>(cx, srcBuf, callback,
|
||||
callbackData);
|
||||
if (!task) {
|
||||
return false;
|
||||
}
|
||||
|
@ -920,13 +952,17 @@ bool js::StartOffThreadParseModule(JSContext* cx,
|
|||
JS::SourceText<char16_t>& srcBuf,
|
||||
JS::OffThreadCompileCallback callback,
|
||||
void* callbackData) {
|
||||
auto task = cx->make_unique<ModuleParseTask<char16_t>>(cx, srcBuf, callback,
|
||||
callbackData);
|
||||
if (!task) {
|
||||
return false;
|
||||
}
|
||||
return StartOffThreadParseModuleInternal(cx, options, srcBuf, callback,
|
||||
callbackData);
|
||||
}
|
||||
|
||||
return StartOffThreadParseTask(cx, std::move(task), options);
|
||||
bool js::StartOffThreadParseModule(JSContext* cx,
|
||||
const ReadOnlyCompileOptions& options,
|
||||
JS::SourceText<Utf8Unit>& srcBuf,
|
||||
JS::OffThreadCompileCallback callback,
|
||||
void* callbackData) {
|
||||
return StartOffThreadParseModuleInternal(cx, options, srcBuf, callback,
|
||||
callbackData);
|
||||
}
|
||||
|
||||
bool js::StartOffThreadDecodeScript(JSContext* cx,
|
||||
|
|
|
@ -18,6 +18,7 @@
|
|||
#include "mozilla/PodOperations.h"
|
||||
#include "mozilla/TimeStamp.h"
|
||||
#include "mozilla/TypeTraits.h"
|
||||
#include "mozilla/Utf8.h" // mozilla::Utf8Unit
|
||||
#include "mozilla/Variant.h"
|
||||
|
||||
#include "jsapi.h"
|
||||
|
@ -611,12 +612,22 @@ bool StartOffThreadParseScript(JSContext* cx,
|
|||
JS::SourceText<char16_t>& srcBuf,
|
||||
JS::OffThreadCompileCallback callback,
|
||||
void* callbackData);
|
||||
bool StartOffThreadParseScript(JSContext* cx,
|
||||
const JS::ReadOnlyCompileOptions& options,
|
||||
JS::SourceText<mozilla::Utf8Unit>& srcBuf,
|
||||
JS::OffThreadCompileCallback callback,
|
||||
void* callbackData);
|
||||
|
||||
bool StartOffThreadParseModule(JSContext* cx,
|
||||
const JS::ReadOnlyCompileOptions& options,
|
||||
JS::SourceText<char16_t>& srcBuf,
|
||||
JS::OffThreadCompileCallback callback,
|
||||
void* callbackData);
|
||||
bool StartOffThreadParseModule(JSContext* cx,
|
||||
const JS::ReadOnlyCompileOptions& options,
|
||||
JS::SourceText<mozilla::Utf8Unit>& srcBuf,
|
||||
JS::OffThreadCompileCallback callback,
|
||||
void* callbackData);
|
||||
|
||||
bool StartOffThreadDecodeScript(JSContext* cx,
|
||||
const JS::ReadOnlyCompileOptions& options,
|
||||
|
|
Загрузка…
Ссылка в новой задаче