Bug 1323108 - Check own flags property in RegExpPrototypeOptimizableRaw. r=h4writer

This commit is contained in:
Tooru Fujisawa 2016-12-17 12:42:57 +09:00
parent 0f903d3990
commit 2ccc49f471
4 changed files with 43 additions and 4 deletions

View File

@ -1605,7 +1605,7 @@ js::RegExpPrototypeOptimizableRaw(JSContext* cx, JSObject* proto, uint8_t* resul
} }
JSFunction* flagsGetter; JSFunction* flagsGetter;
if (!GetGetterPure(cx, proto, NameToId(cx->names().flags), &flagsGetter)) if (!GetOwnGetterPure(cx, proto, NameToId(cx->names().flags), &flagsGetter))
return false; return false;
if (!flagsGetter) { if (!flagsGetter) {

View File

@ -2387,7 +2387,7 @@ js::GetPropertyPure(ExclusiveContext* cx, JSObject* obj, jsid id, Value* vp)
} }
static inline bool static inline bool
NativeGetGetterPureInline(NativeObject* pobj, Shape* shape, JSFunction** fp) NativeGetGetterPureInline(Shape* shape, JSFunction** fp)
{ {
if (shape->hasGetterObject()) { if (shape->hasGetterObject()) {
if (shape->getterObject()->is<JSFunction>()) { if (shape->getterObject()->is<JSFunction>()) {
@ -2415,8 +2415,23 @@ js::GetGetterPure(ExclusiveContext* cx, JSObject* obj, jsid id, JSFunction** fp)
return true; return true;
} }
return pobj->isNative() && return pobj->isNative() && NativeGetGetterPureInline(shape, fp);
NativeGetGetterPureInline(&pobj->as<NativeObject>(), shape, fp); }
bool
js::GetOwnGetterPure(ExclusiveContext* cx, JSObject* obj, jsid id, JSFunction** fp)
{
JS::AutoCheckCannotGC nogc;
Shape* shape;
if (!LookupOwnPropertyPure(cx, obj, id, &shape))
return false;
if (!shape) {
*fp = nullptr;
return true;
}
return NativeGetGetterPureInline(shape, fp);
} }
bool bool

View File

@ -1261,6 +1261,9 @@ GetPropertyPure(ExclusiveContext* cx, JSObject* obj, jsid id, Value* vp);
bool bool
GetGetterPure(ExclusiveContext* cx, JSObject* obj, jsid id, JSFunction** fp); GetGetterPure(ExclusiveContext* cx, JSObject* obj, jsid id, JSFunction** fp);
bool
GetOwnGetterPure(ExclusiveContext* cx, JSObject* obj, jsid id, JSFunction** fp);
bool bool
GetOwnNativeGetterPure(JSContext* cx, JSObject* obj, jsid id, JSNative* native); GetOwnNativeGetterPure(JSContext* cx, JSObject* obj, jsid id, JSNative* native);

View File

@ -0,0 +1,21 @@
var BUGNUMBER = 0;
var summary = "RegExp.prototype.split should reflect the change to Object.prototype.flags.";
print(BUGNUMBER + ": " + summary);
Object.defineProperty(Object.prototype, "flags", Object.getOwnPropertyDescriptor(RegExp.prototype, "flags"));
delete RegExp.prototype.flags;
let re = /a/i;
let a = re[Symbol.split]("1a2A3a4A5");
assertDeepEq(a, ["1", "2", "3", "4", "5"]);
delete Object.prototype.flags;
Object.prototype.flags = "";
a = re[Symbol.split]("1a2A3a4A5");
assertDeepEq(a, ["1", "2A3", "4A5"]);
if (typeof reportCompare === "function")
reportCompare(true, true);