Bug 1153963 - Add telemetry for regexp.hasOwnProperty("source") and Object.getOwnPropertyDescriptor(regexp, "source") on non-release build. r=till

This commit is contained in:
Tooru Fujisawa 2015-04-21 20:04:38 +09:00
parent 7aeb354d1d
commit 13fa229bf4
3 changed files with 20 additions and 0 deletions

View File

@ -555,6 +555,16 @@ js::obj_hasOwnProperty(JSContext* cx, unsigned argc, Value* vp)
jsid id;
if (args.thisv().isObject() && ValueToId<NoGC>(cx, idValue, &id)) {
JSObject* obj = &args.thisv().toObject();
#ifndef RELEASE_BUILD
if (obj->is<RegExpObject>() && id == NameToId(cx->names().source)) {
if (JSScript* script = cx->currentScript()) {
const char* filename = script->filename();
cx->compartment()->addTelemetry(filename, JSCompartment::RegExpSourceProperty);
}
}
#endif
Shape* prop;
if (obj->isNative() &&
NativeLookupOwnProperty<NoGC>(cx, &obj->as<NativeObject>(), id, &prop))

View File

@ -591,6 +591,7 @@ struct JSCompartment
DeprecatedLetExpression = 5, // Added in JS 1.7
DeprecatedNoSuchMethod = 6, // JS 1.7+
DeprecatedFlagsArgument = 7, // JS 1.3 or older
RegExpSourceProperty = 8, // ES5
DeprecatedLanguageExtensionCount
};

View File

@ -3002,6 +3002,15 @@ js::GetOwnPropertyDescriptor(JSContext* cx, HandleObject obj, HandleId id,
return ok;
}
#ifndef RELEASE_BUILD
if (obj->is<RegExpObject>() && id == NameToId(cx->names().source)) {
if (JSScript* script = cx->currentScript()) {
const char* filename = script->filename();
cx->compartment()->addTelemetry(filename, JSCompartment::RegExpSourceProperty);
}
}
#endif
RootedShape shape(cx);
if (!NativeLookupOwnProperty<CanGC>(cx, obj.as<NativeObject>(), id, &shape))
return false;