Bug 1913085 - Enable json_parse_with_source by default and outside of nightly r=dminor

Differential Revision: https://phabricator.services.mozilla.com/D220473
This commit is contained in:
Bryan Thrall 2024-09-03 15:58:03 +00:00
Родитель e78c6ae67b
Коммит fdf38e9e57
9 изменённых файлов: 4 добавлений и 55 удалений

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

@ -192,18 +192,6 @@ set_config("ENABLE_EXPLICIT_RESOURCE_MANAGEMENT", enable_explicit_resource_manag
set_define("ENABLE_EXPLICIT_RESOURCE_MANAGEMENT", enable_explicit_resource_management)
# Enable JSON.parse with source
# ===================================================
@depends(milestone.is_nightly)
def enable_json_parse_with_source(is_nightly):
if is_nightly:
return True
set_config("ENABLE_JSON_PARSE_WITH_SOURCE", enable_json_parse_with_source)
set_define("ENABLE_JSON_PARSE_WITH_SOURCE", enable_json_parse_with_source)
# Portable Baseline Intepreter
# =======================================================
option(

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

@ -1769,7 +1769,6 @@ static bool InternalizeJSONProperty(
return false;
}
#ifdef ENABLE_JSON_PARSE_WITH_SOURCE
RootedObject context(cx);
Rooted<UniquePtr<ParseRecordObject::EntryMap>> entries(cx);
if (JS::Prefs::experimental_json_parse_with_source()) {
@ -1802,7 +1801,6 @@ static bool InternalizeJSONProperty(
}
}
}
#endif
/* Step 2. */
if (val.isObject()) {
@ -1834,13 +1832,11 @@ static bool InternalizeJSONProperty(
/* Step 2a(iii)(1). */
Rooted<ParseRecordObject> elementRecord(cx);
#ifdef ENABLE_JSON_PARSE_WITH_SOURCE
if (entries) {
if (auto entry = entries->lookup(id)) {
elementRecord = std::move(entry->value());
}
}
#endif
if (!InternalizeJSONProperty(cx, obj, id, reviver, &elementRecord,
&newElement)) {
return false;
@ -1882,13 +1878,11 @@ static bool InternalizeJSONProperty(
/* Step 2c(ii)(1). */
id = keys[i];
Rooted<ParseRecordObject> entryRecord(cx);
#ifdef ENABLE_JSON_PARSE_WITH_SOURCE
if (entries) {
if (auto entry = entries->lookup(id)) {
entryRecord = std::move(entry->value());
}
}
#endif
if (!InternalizeJSONProperty(cx, obj, id, reviver, &entryRecord,
&newElement)) {
return false;
@ -1922,12 +1916,10 @@ static bool InternalizeJSONProperty(
}
RootedValue keyVal(cx, StringValue(key));
#ifdef ENABLE_JSON_PARSE_WITH_SOURCE
if (JS::Prefs::experimental_json_parse_with_source()) {
RootedValue contextVal(cx, ObjectValue(*context));
return js::Call(cx, reviver, holder, keyVal, val, contextVal, vp);
}
#endif
return js::Call(cx, reviver, holder, keyVal, val, vp);
}
@ -1943,10 +1935,8 @@ static bool Revive(JSContext* cx, HandleValue reviver,
return false;
}
#ifdef ENABLE_JSON_PARSE_WITH_SOURCE
MOZ_ASSERT_IF(JS::Prefs::experimental_json_parse_with_source(),
pro.get().value == vp.get());
#endif
Rooted<jsid> id(cx, NameToId(cx->names().empty_));
return InternalizeJSONProperty(cx, obj, id, reviver, pro, vp);
}
@ -1967,15 +1957,12 @@ bool js::ParseJSONWithReviver(JSContext* cx,
JS::ProfilingCategoryPair::JS_Parsing);
/* https://262.ecma-international.org/14.0/#sec-json.parse steps 2-10. */
Rooted<ParseRecordObject> pro(cx);
#ifdef ENABLE_JSON_PARSE_WITH_SOURCE
if (JS::Prefs::experimental_json_parse_with_source() && IsCallable(reviver)) {
Rooted<JSONReviveParser<CharT>> parser(cx, cx, chars);
if (!parser.get().parse(vp, &pro)) {
return false;
}
} else
#endif
if (!ParseJSON(cx, chars, vp)) {
} else if (!ParseJSON(cx, chars, vp)) {
return false;
}
@ -2189,7 +2176,6 @@ static bool json_parseImmutable(JSContext* cx, unsigned argc, Value* vp) {
}
#endif
#ifdef ENABLE_JSON_PARSE_WITH_SOURCE
/* https://tc39.es/proposal-json-parse-with-source/#sec-json.israwjson */
static bool json_isRawJSON(JSContext* cx, unsigned argc, Value* vp) {
AutoJSMethodProfilerEntry pseudoFrame(cx, "JSON", "isRawJSON");
@ -2198,14 +2184,14 @@ static bool json_isRawJSON(JSContext* cx, unsigned argc, Value* vp) {
/* Step 1. */
if (args.get(0).isObject()) {
Rooted<JSObject*> obj(cx, &args[0].toObject());
# ifdef DEBUG
#ifdef DEBUG
if (obj->is<RawJSONObject>()) {
bool objIsFrozen = false;
MOZ_ASSERT(js::TestIntegrityLevel(cx, obj, IntegrityLevel::Frozen,
&objIsFrozen));
MOZ_ASSERT(objIsFrozen);
}
# endif // DEBUG
#endif // DEBUG
args.rval().setBoolean(obj->is<RawJSONObject>() ||
obj->canUnwrapAs<RawJSONObject>());
return true;
@ -2286,7 +2272,6 @@ static bool json_rawJSON(JSContext* cx, unsigned argc, Value* vp) {
args.rval().setObject(*obj);
return true;
}
#endif // ENABLE_JSON_PARSE_WITH_SOURCE
/* https://262.ecma-international.org/14.0/#sec-json.stringify */
bool json_stringify(JSContext* cx, unsigned argc, Value* vp) {
@ -2332,10 +2317,8 @@ static const JSFunctionSpec json_static_methods[] = {
#ifdef ENABLE_RECORD_TUPLE
JS_FN("parseImmutable", json_parseImmutable, 2, 0),
#endif
#ifdef ENABLE_JSON_PARSE_WITH_SOURCE
JS_FN("isRawJSON", json_isRawJSON, 1, 0),
JS_FN("rawJSON", json_rawJSON, 1, 0),
#endif
JS_FS_END,
};

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

@ -12738,15 +12738,9 @@ bool SetGlobalOptionsPreJSInit(const OptionParser& op) {
JS::Prefs::setAtStartup_experimental_regexp_escape(true);
}
#endif
#ifdef ENABLE_JSON_PARSE_WITH_SOURCE
if (op.getBoolOption("enable-json-parse-with-source")) {
JS::Prefs::set_experimental_json_parse_with_source(true);
}
#else
if (op.getBoolOption("enable-json-parse-with-source")) {
fprintf(stderr, "JSON.parse with source is not enabled on this build.\n");
}
#endif
if (op.getBoolOption("disable-weak-refs")) {
JS::Prefs::setAtStartup_weakrefs(false);

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

@ -1069,12 +1069,10 @@ template class js::JSONPerHandlerParser<Latin1Char,
template class js::JSONPerHandlerParser<char16_t,
js::JSONFullParseHandler<char16_t>>;
#ifdef ENABLE_JSON_PARSE_WITH_SOURCE
template class js::JSONPerHandlerParser<Latin1Char,
js::JSONReviveHandler<Latin1Char>>;
template class js::JSONPerHandlerParser<char16_t,
js::JSONReviveHandler<char16_t>>;
#endif
template class js::JSONPerHandlerParser<Latin1Char,
js::JSONSyntaxParseHandler<Latin1Char>>;
@ -1107,7 +1105,6 @@ void JSONParser<CharT>::trace(JSTracer* trc) {
template class js::JSONParser<Latin1Char>;
template class js::JSONParser<char16_t>;
#ifdef ENABLE_JSON_PARSE_WITH_SOURCE
template <typename CharT>
inline bool JSONReviveHandler<CharT>::objectOpen(Vector<StackEntry, 10>& stack,
PropertyVector** properties) {
@ -1247,7 +1244,6 @@ void JSONReviveParser<CharT>::trace(JSTracer* trc) {
template class js::JSONReviveParser<Latin1Char>;
template class js::JSONReviveParser<char16_t>;
#endif // ENABLE_JSON_PARSE_WITH_SOURCE
template <typename CharT>
inline bool JSONSyntaxParseHandler<CharT>::objectOpen(

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

@ -329,7 +329,6 @@ class MOZ_STACK_CLASS JSONFullParseHandler
void reportError(const char* msg, uint32_t line, uint32_t column);
};
#ifdef ENABLE_JSON_PARSE_WITH_SOURCE
template <typename CharT>
class MOZ_STACK_CLASS JSONReviveHandler : public JSONFullParseHandler<CharT> {
using CharPtr = mozilla::RangedPtr<const CharT>;
@ -421,7 +420,6 @@ class MOZ_STACK_CLASS JSONReviveHandler : public JSONFullParseHandler<CharT> {
public:
ParseRecordObject parseRecord;
};
#endif // ENABLE_JSON_PARSE_WITH_SOURCE
template <typename CharT>
class MOZ_STACK_CLASS JSONSyntaxParseHandler {
@ -618,7 +616,6 @@ class MOZ_STACK_CLASS JSONParser
void trace(JSTracer* trc);
};
#ifdef ENABLE_JSON_PARSE_WITH_SOURCE
template <typename CharT>
class MOZ_STACK_CLASS JSONReviveParser
: JSONPerHandlerParser<CharT, JSONReviveHandler<CharT>> {
@ -659,7 +656,6 @@ class MOZ_STACK_CLASS JSONReviveParser
void trace(JSTracer* trc);
};
#endif // ENABLE_JSON_PARSE_WITH_SOURCE
template <typename CharT, typename Wrapper>
class MutableWrappedPtrOperations<JSONParser<CharT>, Wrapper>

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

@ -2269,14 +2269,12 @@ JS_PUBLIC_API bool js::ShouldIgnorePropertyDefinition(JSContext* cx,
}
#endif
#ifdef ENABLE_JSON_PARSE_WITH_SOURCE
if (key == JSProto_JSON &&
!JS::Prefs::experimental_json_parse_with_source() &&
(id == NameToId(cx->names().isRawJSON) ||
id == NameToId(cx->names().rawJSON))) {
return true;
}
#endif
if (key == JSProto_Math && !JS::Prefs::experimental_float16array() &&
(id == NameToId(cx->names().f16round))) {

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

@ -261,7 +261,6 @@ skip-if = ["!debug"]
["test_isRemoteProxy.html"]
["test_json_parse_with_source_worker.html"]
skip-if = ["!nightly_build"]
["test_nukeContentWindow.html"]

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

@ -303,9 +303,6 @@ skip-if = [
prefs = [
"javascript.options.experimental.json_parse_with_source=true",
]
skip-if = [
"!nightly_build",
]
["test_loadedESModules.js"]

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

@ -8073,13 +8073,11 @@
set_spidermonkey_pref: startup
#endif // NIGHTLY_BUILD
#ifdef ENABLE_JSON_PARSE_WITH_SOURCE
- name: javascript.options.experimental.json_parse_with_source
type: bool
value: false
value: true
mirror: always
set_spidermonkey_pref: always
#endif // ENABLE_JSON_PARSE_WITH_SOURCE
- name: javascript.options.wasm_caching
type: bool