mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-01-27 07:34:20 +00:00
Bug 1626105 - Convert |JS::Compile| for UTF-8 to |JS::CompileDontInflate| semantics, and remove |JS::CompileDontInflate|. r=evilpie
Differential Revision: https://phabricator.services.mozilla.com/D68905 --HG-- extra : moz-landing-system : lando
This commit is contained in:
parent
92e68eba57
commit
6a774342a0
@ -216,10 +216,9 @@ static JSScript* CompileScript(
|
||||
// Once the UTF-8 overloads don't inflate, we can get rid of these two
|
||||
// |CompileScript| overloads and just call the JSAPI directly in the one
|
||||
// caller.
|
||||
return aScopeChain.length() == 0
|
||||
? JS::CompileDontInflate(aCx, aCompileOptions, aSrcBuf)
|
||||
: JS::CompileForNonSyntacticScopeDontInflate(aCx, aCompileOptions,
|
||||
aSrcBuf);
|
||||
return aScopeChain.length() == 0 ? JS::Compile(aCx, aCompileOptions, aSrcBuf)
|
||||
: JS::CompileForNonSyntacticScopeDontInflate(
|
||||
aCx, aCompileOptions, aSrcBuf);
|
||||
}
|
||||
|
||||
template <typename Unit>
|
||||
|
@ -287,7 +287,7 @@ void XPCShellEnvironment::ProcessFile(JSContext* cx, const char* filename,
|
||||
|
||||
if (srcBuf.init(cx, buffer, strlen(buffer),
|
||||
JS::SourceOwnership::Borrowed) &&
|
||||
(script = JS::CompileDontInflate(cx, options, srcBuf))) {
|
||||
(script = JS::Compile(cx, options, srcBuf))) {
|
||||
ok = JS_ExecuteScript(cx, script, &result);
|
||||
if (ok && !result.isUndefined()) {
|
||||
/* Suppress warnings from JS::ToString(). */
|
||||
|
@ -200,23 +200,6 @@ extern JS_PUBLIC_API JSScript* Compile(JSContext* cx,
|
||||
const ReadOnlyCompileOptions& options,
|
||||
SourceText<mozilla::Utf8Unit>& srcBuf);
|
||||
|
||||
/**
|
||||
* Identical to |JS::Compile| for UTF-8, except this function directly parses
|
||||
* its UTF-8 input without inflating it to UTF-16 and parsing that.
|
||||
*
|
||||
* The "DontInflate" suffix and (semantically unobservable) don't-inflate
|
||||
* characteristic are temporary while bugs in UTF-8 compilation are ironed out.
|
||||
* In the long term |JS::Compile| for UTF-8 will just never inflate, and this
|
||||
* separate function will die.
|
||||
*
|
||||
* NOTE: UTF-8 compilation is currently experimental, and it's possible it has
|
||||
* as-yet-undiscovered bugs that the UTF-16 compilation functions do not
|
||||
* have. Use only if you're willing to take a risk!
|
||||
*/
|
||||
extern JS_PUBLIC_API JSScript* CompileDontInflate(
|
||||
JSContext* cx, const ReadOnlyCompileOptions& options,
|
||||
SourceText<mozilla::Utf8Unit>& srcBuf);
|
||||
|
||||
/**
|
||||
* Compile the UTF-8 contents of the given file into a script. It is an error
|
||||
* if the file contains invalid UTF-8. Return the script on success, or return
|
||||
|
@ -23,7 +23,7 @@ FRAGMENT(jsbytecode, simple) {
|
||||
bool ok = srcBuf.init(cx, chars, mozilla::ArrayLength(chars) - 1,
|
||||
JS::SourceOwnership::Borrowed);
|
||||
|
||||
JSScript* script = JS::CompileDontInflate(cx, opts, srcBuf);
|
||||
JSScript* script = JS::Compile(cx, opts, srcBuf);
|
||||
jsbytecode* code = script->code();
|
||||
|
||||
breakpoint();
|
||||
|
@ -4,7 +4,7 @@
|
||||
|
||||
#include "mozilla/Utf8.h" // mozilla::Utf8Unit
|
||||
|
||||
#include "js/CompilationAndEvaluation.h" // JS::Compile{,ForNonSyntacticScope}{,DontInflate}
|
||||
#include "js/CompilationAndEvaluation.h" // JS::Compile{,ForNonSyntacticScope{,DontInflate}}
|
||||
#include "js/SourceText.h" // JS::Source{Ownership,Text}
|
||||
#include "jsapi-tests/tests.h"
|
||||
#include "vm/HelperThreads.h"
|
||||
@ -95,7 +95,7 @@ bool testCompile(bool nonSyntactic) {
|
||||
CHECK(script);
|
||||
CHECK_EQUAL(script->hasNonSyntacticScope(), nonSyntactic);
|
||||
|
||||
script = CompileDontInflate(cx, options, buf8);
|
||||
script = Compile(cx, options, buf8);
|
||||
CHECK(script);
|
||||
CHECK_EQUAL(script->hasNonSyntacticScope(), nonSyntactic);
|
||||
|
||||
|
@ -11,7 +11,7 @@
|
||||
#include "jsfriendapi.h"
|
||||
|
||||
#include "js/CharacterEncoding.h"
|
||||
#include "js/CompilationAndEvaluation.h" // JS::CompileDontInflate
|
||||
#include "js/CompilationAndEvaluation.h" // JS::Compile
|
||||
#include "js/SourceText.h"
|
||||
#include "jsapi-tests/tests.h"
|
||||
#include "vm/ErrorReporting.h"
|
||||
@ -190,7 +190,7 @@ bool testBadUtf8(const char (&chars)[N], unsigned errorNumber,
|
||||
JS::SourceText<mozilla::Utf8Unit> srcBuf;
|
||||
CHECK(srcBuf.init(cx, chars, N - 1, JS::SourceOwnership::Borrowed));
|
||||
|
||||
script = JS::CompileDontInflate(cx, options, srcBuf);
|
||||
script = JS::Compile(cx, options, srcBuf);
|
||||
CHECK(!script);
|
||||
}
|
||||
|
||||
@ -274,7 +274,7 @@ bool testContext(const char (&chars)[N],
|
||||
JS::SourceText<mozilla::Utf8Unit> srcBuf;
|
||||
CHECK(srcBuf.init(cx, chars, N - 1, JS::SourceOwnership::Borrowed));
|
||||
|
||||
script = JS::CompileDontInflate(cx, options, srcBuf);
|
||||
script = JS::Compile(cx, options, srcBuf);
|
||||
CHECK(!script);
|
||||
}
|
||||
|
||||
|
@ -11,7 +11,7 @@
|
||||
#include "jsfriendapi.h"
|
||||
|
||||
#include "js/CharacterEncoding.h"
|
||||
#include "js/CompilationAndEvaluation.h" // JS::Compile{,DontInflate}
|
||||
#include "js/CompilationAndEvaluation.h" // JS::Compile
|
||||
#include "js/SourceText.h"
|
||||
#include "jsapi-tests/tests.h"
|
||||
#include "vm/ErrorReporting.h"
|
||||
@ -100,7 +100,7 @@ JSScript* compile(const char* chars, size_t len) {
|
||||
source.init(cx, chars, len, JS::SourceOwnership::Borrowed));
|
||||
|
||||
JS::CompileOptions options(cx);
|
||||
return JS::CompileDontInflate(cx, options, source);
|
||||
return JS::Compile(cx, options, source);
|
||||
}
|
||||
|
||||
template <typename CharT, size_t N>
|
||||
|
@ -8,7 +8,7 @@
|
||||
#include "jsapi.h"
|
||||
#include "jspubtd.h"
|
||||
|
||||
#include "js/CompilationAndEvaluation.h" // JS::CompileDontInflate
|
||||
#include "js/CompilationAndEvaluation.h" // JS::Compile
|
||||
#include "js/SourceText.h" // JS::Source{Ownership,Text}
|
||||
#include "jsapi-tests/tests.h"
|
||||
|
||||
@ -28,7 +28,7 @@ BEGIN_TEST(testGCCellPtr) {
|
||||
JS::SourceText<mozilla::Utf8Unit> srcBuf;
|
||||
CHECK(srcBuf.init(cx, code, strlen(code), JS::SourceOwnership::Borrowed));
|
||||
|
||||
JS::RootedScript script(cx, JS::CompileDontInflate(cx, opts, srcBuf));
|
||||
JS::RootedScript script(cx, JS::Compile(cx, opts, srcBuf));
|
||||
CHECK(script);
|
||||
|
||||
CHECK(!JS::GCCellPtr(nullptr));
|
||||
|
@ -10,7 +10,7 @@
|
||||
|
||||
#include "jsapi.h"
|
||||
|
||||
#include "js/CompilationAndEvaluation.h" // JS::CompileDontInflate
|
||||
#include "js/CompilationAndEvaluation.h" // JS::Compile
|
||||
#include "js/HeapAPI.h"
|
||||
#include "js/SourceText.h" // JS::Source{Ownership,Text}
|
||||
#include "jsapi-tests/tests.h"
|
||||
@ -51,7 +51,7 @@ BEGIN_TEST(testPrivateGCThingValue) {
|
||||
CHECK(srcBuf.init(cx, code, mozilla::ArrayLength(code) - 1,
|
||||
JS::SourceOwnership::Borrowed));
|
||||
|
||||
JS::RootedScript script(cx, JS::CompileDontInflate(cx, options, srcBuf));
|
||||
JS::RootedScript script(cx, JS::Compile(cx, options, srcBuf));
|
||||
CHECK(script);
|
||||
JS_SetReservedSlot(obj, 0, PrivateGCThingValue(script));
|
||||
|
||||
|
@ -10,7 +10,7 @@
|
||||
|
||||
#include "jsapi.h"
|
||||
|
||||
#include "js/CompilationAndEvaluation.h" // JS::CompileDontInflate
|
||||
#include "js/CompilationAndEvaluation.h" // JS::Compile
|
||||
#include "js/SourceText.h" // JS::Source{Ownership,Text}
|
||||
#include "jsapi-tests/tests.h"
|
||||
|
||||
@ -38,7 +38,7 @@ BEGIN_TEST(testScriptInfo) {
|
||||
CHECK(srcBuf.init(cx, code, mozilla::ArrayLength(code) - 1,
|
||||
JS::SourceOwnership::Borrowed));
|
||||
|
||||
JS::RootedScript script(cx, JS::CompileDontInflate(cx, options, srcBuf));
|
||||
JS::RootedScript script(cx, JS::Compile(cx, options, srcBuf));
|
||||
CHECK(script);
|
||||
|
||||
CHECK_EQUAL(JS_GetScriptBaseLineNumber(cx, script), startLine);
|
||||
|
@ -48,7 +48,7 @@ BEGIN_FIXTURE_TEST(ScriptObjectFixture, bug438633_CompileScript) {
|
||||
JS::SourceText<mozilla::Utf8Unit> srcBuf;
|
||||
CHECK(srcBuf.init(cx, code, code_size, JS::SourceOwnership::Borrowed));
|
||||
|
||||
JS::RootedScript script(cx, JS::CompileDontInflate(cx, options, srcBuf));
|
||||
JS::RootedScript script(cx, JS::Compile(cx, options, srcBuf));
|
||||
CHECK(script);
|
||||
|
||||
return tryScript(script);
|
||||
@ -62,7 +62,7 @@ BEGIN_FIXTURE_TEST(ScriptObjectFixture, bug438633_CompileScript_empty) {
|
||||
JS::SourceText<mozilla::Utf8Unit> srcBuf;
|
||||
CHECK(srcBuf.init(cx, "", 0, JS::SourceOwnership::Borrowed));
|
||||
|
||||
JS::RootedScript script(cx, JS::CompileDontInflate(cx, options, srcBuf));
|
||||
JS::RootedScript script(cx, JS::Compile(cx, options, srcBuf));
|
||||
CHECK(script);
|
||||
|
||||
return tryScript(script);
|
||||
@ -76,7 +76,7 @@ BEGIN_FIXTURE_TEST(ScriptObjectFixture, bug438633_CompileScriptForPrincipals) {
|
||||
JS::SourceText<mozilla::Utf8Unit> srcBuf;
|
||||
CHECK(srcBuf.init(cx, code, code_size, JS::SourceOwnership::Borrowed));
|
||||
|
||||
JS::RootedScript script(cx, JS::CompileDontInflate(cx, options, srcBuf));
|
||||
JS::RootedScript script(cx, JS::Compile(cx, options, srcBuf));
|
||||
|
||||
return tryScript(script);
|
||||
}
|
||||
@ -226,7 +226,7 @@ BEGIN_FIXTURE_TEST(ScriptObjectFixture, CloneAndExecuteScript) {
|
||||
JS::SourceText<mozilla::Utf8Unit> srcBuf;
|
||||
CHECK(srcBuf.init(cx, "val", 3, JS::SourceOwnership::Borrowed));
|
||||
|
||||
JS::RootedScript script(cx, JS::CompileDontInflate(cx, options, srcBuf));
|
||||
JS::RootedScript script(cx, JS::Compile(cx, options, srcBuf));
|
||||
CHECK(script);
|
||||
|
||||
JS::RootedValue value(cx);
|
||||
|
@ -5,7 +5,7 @@
|
||||
#include "mozilla/Utf8.h" // mozilla::Utf8Unit
|
||||
|
||||
#include "builtin/TestingFunctions.h"
|
||||
#include "js/CompilationAndEvaluation.h" // JS::CompileDontInflate
|
||||
#include "js/CompilationAndEvaluation.h" // JS::Compile
|
||||
#include "js/SourceText.h" // JS::Source{Ownership,Text}
|
||||
#include "js/UbiNode.h"
|
||||
#include "js/UbiNodeDominatorTree.h"
|
||||
@ -98,7 +98,7 @@ BEGIN_TEST(test_ubiNodeZone) {
|
||||
JS::SourceText<mozilla::Utf8Unit> emptySrcBuf;
|
||||
CHECK(emptySrcBuf.init(cx, "", 0, JS::SourceOwnership::Borrowed));
|
||||
|
||||
RootedScript script1(cx, JS::CompileDontInflate(cx, options, emptySrcBuf));
|
||||
RootedScript script1(cx, JS::Compile(cx, options, emptySrcBuf));
|
||||
CHECK(script1);
|
||||
|
||||
{
|
||||
@ -109,7 +109,7 @@ BEGIN_TEST(test_ubiNodeZone) {
|
||||
RootedString string2(cx,
|
||||
JS_NewStringCopyZ(cx, "A million household uses!"));
|
||||
CHECK(string2);
|
||||
RootedScript script2(cx, JS::CompileDontInflate(cx, options, emptySrcBuf));
|
||||
RootedScript script2(cx, JS::Compile(cx, options, emptySrcBuf));
|
||||
CHECK(script2);
|
||||
|
||||
CHECK(JS::ubi::Node(string1).zone() == global1->zone());
|
||||
@ -147,7 +147,7 @@ BEGIN_TEST(test_ubiNodeCompartment) {
|
||||
CHECK(emptySrcBuf.init(cx, "", 0, JS::SourceOwnership::Borrowed));
|
||||
|
||||
// Create a script in the original realm...
|
||||
RootedScript script1(cx, JS::CompileDontInflate(cx, options, emptySrcBuf));
|
||||
RootedScript script1(cx, JS::Compile(cx, options, emptySrcBuf));
|
||||
CHECK(script1);
|
||||
|
||||
{
|
||||
@ -155,7 +155,7 @@ BEGIN_TEST(test_ubiNodeCompartment) {
|
||||
// there, too.
|
||||
JSAutoRealm ar(cx, global2);
|
||||
|
||||
RootedScript script2(cx, JS::CompileDontInflate(cx, options, emptySrcBuf));
|
||||
RootedScript script2(cx, JS::Compile(cx, options, emptySrcBuf));
|
||||
CHECK(script2);
|
||||
|
||||
CHECK(JS::ubi::Node(script1).compartment() == global1->compartment());
|
||||
|
@ -10,7 +10,7 @@
|
||||
#include "jsfriendapi.h"
|
||||
|
||||
#include "js/BuildId.h" // JS::BuildIdCharVector, JS::SetProcessBuildIdOp
|
||||
#include "js/CompilationAndEvaluation.h" // JS::CompileDontInflate
|
||||
#include "js/CompilationAndEvaluation.h" // JS::Compile
|
||||
#include "js/SourceText.h" // JS::Source{Ownership,Text}
|
||||
#include "js/Transcoding.h"
|
||||
#include "jsapi-tests/tests.h"
|
||||
@ -68,7 +68,7 @@ BEGIN_TEST(testXDR_bug506491) {
|
||||
CHECK(srcBuf.init(cx, s, mozilla::ArrayLength(s) - 1,
|
||||
JS::SourceOwnership::Borrowed));
|
||||
|
||||
JS::RootedScript script(cx, JS::CompileDontInflate(cx, options, srcBuf));
|
||||
JS::RootedScript script(cx, JS::Compile(cx, options, srcBuf));
|
||||
CHECK(script);
|
||||
|
||||
script = FreezeThaw(cx, script);
|
||||
@ -97,7 +97,7 @@ BEGIN_TEST(testXDR_bug516827) {
|
||||
JS::SourceText<mozilla::Utf8Unit> srcBuf;
|
||||
CHECK(srcBuf.init(cx, "", 0, JS::SourceOwnership::Borrowed));
|
||||
|
||||
JS::RootedScript script(cx, JS::CompileDontInflate(cx, options, srcBuf));
|
||||
JS::RootedScript script(cx, JS::Compile(cx, options, srcBuf));
|
||||
CHECK(script);
|
||||
|
||||
script = FreezeThaw(cx, script);
|
||||
@ -129,7 +129,7 @@ BEGIN_TEST(testXDR_source) {
|
||||
JS::SourceText<mozilla::Utf8Unit> srcBuf;
|
||||
CHECK(srcBuf.init(cx, *s, strlen(*s), JS::SourceOwnership::Borrowed));
|
||||
|
||||
JS::RootedScript script(cx, JS::CompileDontInflate(cx, options, srcBuf));
|
||||
JS::RootedScript script(cx, JS::Compile(cx, options, srcBuf));
|
||||
CHECK(script);
|
||||
|
||||
script = FreezeThaw(cx, script);
|
||||
@ -157,7 +157,7 @@ BEGIN_TEST(testXDR_sourceMap) {
|
||||
JS::SourceText<mozilla::Utf8Unit> srcBuf;
|
||||
CHECK(srcBuf.init(cx, "", 0, JS::SourceOwnership::Borrowed));
|
||||
|
||||
script = JS::CompileDontInflate(cx, options, srcBuf);
|
||||
script = JS::Compile(cx, options, srcBuf);
|
||||
CHECK(script);
|
||||
|
||||
size_t len = strlen(*sm);
|
||||
|
@ -1376,7 +1376,7 @@ static MOZ_MUST_USE bool EvalUtf8AndPrint(JSContext* cx, const char* bytes,
|
||||
return false;
|
||||
}
|
||||
|
||||
RootedScript script(cx, JS::CompileDontInflate(cx, options, srcBuf));
|
||||
RootedScript script(cx, JS::Compile(cx, options, srcBuf));
|
||||
if (!script) {
|
||||
return false;
|
||||
}
|
||||
|
@ -106,12 +106,6 @@ JSScript* JS::Compile(JSContext* cx, const ReadOnlyCompileOptions& options,
|
||||
|
||||
JSScript* JS::Compile(JSContext* cx, const ReadOnlyCompileOptions& options,
|
||||
SourceText<Utf8Unit>& srcBuf) {
|
||||
return CompileUtf8Inflating(cx, options, srcBuf);
|
||||
}
|
||||
|
||||
JSScript* JS::CompileDontInflate(JSContext* cx,
|
||||
const ReadOnlyCompileOptions& options,
|
||||
SourceText<Utf8Unit>& srcBuf) {
|
||||
return CompileSourceBuffer(cx, options, srcBuf);
|
||||
}
|
||||
|
||||
|
@ -861,7 +861,7 @@ nsresult mozJSComponentLoader::ObjectForLocation(
|
||||
JS::SourceOwnership::Borrowed)) {
|
||||
script = reuseGlobal ? CompileForNonSyntacticScopeDontInflate(
|
||||
cx, options, srcBuf)
|
||||
: CompileDontInflate(cx, options, srcBuf);
|
||||
: Compile(cx, options, srcBuf);
|
||||
} else {
|
||||
MOZ_ASSERT(!script);
|
||||
}
|
||||
@ -874,7 +874,7 @@ nsresult mozJSComponentLoader::ObjectForLocation(
|
||||
JS::SourceOwnership::Borrowed)) {
|
||||
script = reuseGlobal ? CompileForNonSyntacticScopeDontInflate(
|
||||
cx, options, srcBuf)
|
||||
: CompileDontInflate(cx, options, srcBuf);
|
||||
: Compile(cx, options, srcBuf);
|
||||
} else {
|
||||
MOZ_ASSERT(!script);
|
||||
}
|
||||
|
@ -18,7 +18,7 @@
|
||||
#include "jsapi.h"
|
||||
#include "jsfriendapi.h"
|
||||
#include "xpcprivate.h" // xpc::OptionsBase
|
||||
#include "js/CompilationAndEvaluation.h" // JS::Compile{,ForNonSyntacticScope}DontInflate
|
||||
#include "js/CompilationAndEvaluation.h" // JS::Compile{,ForNonSyntacticScopeDontInflate}
|
||||
#include "js/SourceText.h" // JS::Source{Ownership,Text}
|
||||
#include "js/Wrapper.h"
|
||||
|
||||
@ -145,7 +145,7 @@ static JSScript* PrepareScript(nsIURI* uri, JSContext* cx,
|
||||
}
|
||||
|
||||
if (wantGlobalScript) {
|
||||
return JS::CompileDontInflate(cx, options, srcBuf);
|
||||
return JS::Compile(cx, options, srcBuf);
|
||||
}
|
||||
return JS::CompileForNonSyntacticScopeDontInflate(cx, options, srcBuf);
|
||||
}
|
||||
|
@ -692,7 +692,7 @@ static bool ProcessUtf8Line(AutoJSAPI& jsapi, const char* buffer,
|
||||
return false;
|
||||
}
|
||||
|
||||
JS::RootedScript script(cx, JS::CompileDontInflate(cx, options, srcBuf));
|
||||
JS::RootedScript script(cx, JS::Compile(cx, options, srcBuf));
|
||||
if (!script) {
|
||||
return false;
|
||||
}
|
||||
|
@ -15,7 +15,7 @@
|
||||
#include "nsIURLParser.h"
|
||||
#include "nsJSUtils.h"
|
||||
#include "jsfriendapi.h"
|
||||
#include "js/CompilationAndEvaluation.h" // JS::Compile{,DontInflate}
|
||||
#include "js/CompilationAndEvaluation.h" // JS::Compile
|
||||
#include "js/ContextOptions.h"
|
||||
#include "js/PropertySpec.h"
|
||||
#include "js/SourceText.h" // JS::Source{Ownership,Text}
|
||||
@ -749,7 +749,7 @@ nsresult ProxyAutoConfig::SetupJS() {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
return JS::CompileDontInflate(cx, options, srcBuf);
|
||||
return JS::Compile(cx, options, srcBuf);
|
||||
}
|
||||
|
||||
// nsReadableUtils.h says that "ASCII" is a misnomer "for legacy reasons",
|
||||
|
Loading…
x
Reference in New Issue
Block a user