зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1249123 - Add telemetry for __defineGetter__/__defineSetter__ |this| values. data-review=bsmedberg r=till
This commit is contained in:
Родитель
0a0e9612ba
Коммит
331e14186a
|
@ -62,10 +62,13 @@ function Object_toLocaleString() {
|
|||
|
||||
function ObjectDefineSetter(name, setter) {
|
||||
var object;
|
||||
if (this === null || this === undefined)
|
||||
if (this === null || this === undefined) {
|
||||
AddContentTelemetry(JS_TELEMETRY_DEFINE_GETTER_SETTER_THIS_NULL_UNDEFINED, 1);
|
||||
object = global;
|
||||
else
|
||||
} else {
|
||||
AddContentTelemetry(JS_TELEMETRY_DEFINE_GETTER_SETTER_THIS_NULL_UNDEFINED, 0);
|
||||
object = ToObject(this);
|
||||
}
|
||||
|
||||
if (!IsCallable(setter))
|
||||
ThrowTypeError(JSMSG_BAD_GETTER_OR_SETTER, "setter");
|
||||
|
@ -84,10 +87,13 @@ function ObjectDefineSetter(name, setter) {
|
|||
|
||||
function ObjectDefineGetter(name, getter) {
|
||||
var object;
|
||||
if (this === null || this === undefined)
|
||||
if (this === null || this === undefined) {
|
||||
AddContentTelemetry(JS_TELEMETRY_DEFINE_GETTER_SETTER_THIS_NULL_UNDEFINED, 1);
|
||||
object = global;
|
||||
else
|
||||
} else {
|
||||
AddContentTelemetry(JS_TELEMETRY_DEFINE_GETTER_SETTER_THIS_NULL_UNDEFINED, 0);
|
||||
object = ToObject(this);
|
||||
}
|
||||
|
||||
if (!IsCallable(getter))
|
||||
ThrowTypeError(JSMSG_BAD_GETTER_OR_SETTER, "getter");
|
||||
|
|
|
@ -63,4 +63,6 @@
|
|||
#define JSITER_SYMBOLS 0x20 /* also include symbol property keys */
|
||||
#define JSITER_SYMBOLSONLY 0x40 /* exclude string property keys */
|
||||
|
||||
#define JS_TELEMETRY_DEFINE_GETTER_SETTER_THIS_NULL_UNDEFINED 25
|
||||
|
||||
#endif
|
||||
|
|
|
@ -273,6 +273,14 @@ struct JSCompartment
|
|||
performanceMonitoring.unlink();
|
||||
isSystem_ = isSystem;
|
||||
}
|
||||
|
||||
// Used to approximate non-content code when reporting telemetry.
|
||||
inline bool isProbablySystemOrAddonCode() const {
|
||||
if (creationOptions_.addonIdOrNull())
|
||||
return true;
|
||||
|
||||
return isSystem_;
|
||||
}
|
||||
private:
|
||||
JSPrincipals* principals_;
|
||||
bool isSystem_;
|
||||
|
|
|
@ -131,9 +131,14 @@ enum {
|
|||
JS_TELEMETRY_GC_MINOR_US,
|
||||
JS_TELEMETRY_DEPRECATED_LANGUAGE_EXTENSIONS_IN_CONTENT,
|
||||
JS_TELEMETRY_DEPRECATED_LANGUAGE_EXTENSIONS_IN_ADDONS,
|
||||
JS_TELEMETRY_ADDON_EXCEPTIONS
|
||||
JS_TELEMETRY_ADDON_EXCEPTIONS,
|
||||
JS_TELEMETRY_DEFINE_GETTER_SETTER_THIS_NULL_UNDEFINED,
|
||||
JS_TELEMETRY_END
|
||||
};
|
||||
|
||||
static_assert(JS_TELEMETRY_DEFINE_GETTER_SETTER_THIS_NULL_UNDEFINED == 25,
|
||||
"This value needs to be kept in sync with SelfHostingDefines.h");
|
||||
|
||||
typedef void
|
||||
(*JSAccumulateTelemetryDataCallback)(int id, uint32_t sample, const char* key);
|
||||
|
||||
|
|
|
@ -1473,6 +1473,23 @@ intrinsic_LocalTZA(JSContext* cx, unsigned argc, Value* vp)
|
|||
return true;
|
||||
}
|
||||
|
||||
static bool
|
||||
intrinsic_AddContentTelemetry(JSContext* cx, unsigned argc, Value* vp)
|
||||
{
|
||||
CallArgs args = CallArgsFromVp(argc, vp);
|
||||
MOZ_ASSERT(args.length() == 2);
|
||||
|
||||
int id = args[0].toInt32();
|
||||
MOZ_ASSERT(id < JS_TELEMETRY_END);
|
||||
MOZ_ASSERT(id >= 0);
|
||||
|
||||
if (!cx->compartment()->isProbablySystemOrAddonCode())
|
||||
cx->runtime()->addTelemetry(id, args[1].toInt32());
|
||||
|
||||
args.rval().setUndefined();
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool
|
||||
intrinsic_ConstructFunction(JSContext* cx, unsigned argc, Value* vp)
|
||||
{
|
||||
|
@ -1804,6 +1821,7 @@ static const JSFunctionSpec intrinsic_functions[] = {
|
|||
JS_FN("_FinishBoundFunctionInit", intrinsic_FinishBoundFunctionInit, 4,0),
|
||||
JS_FN("RuntimeDefaultLocale", intrinsic_RuntimeDefaultLocale, 0,0),
|
||||
JS_FN("LocalTZA", intrinsic_LocalTZA, 0,0),
|
||||
JS_FN("AddContentTelemetry", intrinsic_AddContentTelemetry, 2,0),
|
||||
|
||||
JS_INLINABLE_FN("_IsConstructing", intrinsic_IsConstructing, 0,0,
|
||||
IntrinsicIsConstructing),
|
||||
|
|
|
@ -3207,6 +3207,10 @@ AccumulateTelemetryCallback(int id, uint32_t sample, const char* key)
|
|||
case JS_TELEMETRY_ADDON_EXCEPTIONS:
|
||||
Telemetry::Accumulate(Telemetry::JS_TELEMETRY_ADDON_EXCEPTIONS, nsDependentCString(key), sample);
|
||||
break;
|
||||
case JS_TELEMETRY_DEFINE_GETTER_SETTER_THIS_NULL_UNDEFINED:
|
||||
MOZ_ASSERT(sample == 0 || sample == 1);
|
||||
Telemetry::Accumulate(Telemetry::JS_DEFINE_GETTER_SETTER_THIS_NULL_UNDEFINED, sample);
|
||||
break;
|
||||
default:
|
||||
MOZ_ASSERT_UNREACHABLE("Unexpected JS_TELEMETRY id");
|
||||
}
|
||||
|
|
|
@ -524,6 +524,14 @@
|
|||
"n_values": 10,
|
||||
"description": "Use of SpiderMonkey's deprecated language extensions in add-ons: ForEach=0, DestructuringForIn=1 (obsolete), LegacyGenerator=2, ExpressionClosure=3, LetBlock=4 (obsolete), LetExpression=5 (obsolete), NoSuchMethod=6 (obsolete), FlagsArgument=7, RegExpSourceProp=8 (obsolete), RestoredRegExpStatics=9 (obsolete), BlockScopeFunRedecl=10"
|
||||
},
|
||||
"JS_DEFINE_GETTER_SETTER_THIS_NULL_UNDEFINED": {
|
||||
"alert_emails": ["jdemooij@mozilla.com"],
|
||||
"bug_numbers": [1249123],
|
||||
"expires_in_version": "55",
|
||||
"kind": "boolean",
|
||||
"releaseChannelCollection": "opt-out",
|
||||
"description": "__defineGetter__ or __defineSetter__ invoked with 1 = null/undefined or 0 = everything else as |this| value"
|
||||
},
|
||||
"XUL_CACHE_DISABLED": {
|
||||
"expires_in_version": "default",
|
||||
"kind": "flag",
|
||||
|
|
Загрузка…
Ссылка в новой задаче