Bug 911216 - Part 29: Don't unwrap in JS::IsPromiseObject and JS::GetPromiseState. r=efaust
authorTill Schneidereit <till@tillschneidereit.net>
Sat, 16 Jul 2016 12:00:41 +0200
changeset 330277 ccb0ca7468c1524ae532d70c1ca3380d296f097c
parent 330276 1001701a7952b6b6869628d496e778b59462119f
child 330278 eabda35065c18c345b1e4d66fca6cd6c2fbae74d
push id9858
push userjlund@mozilla.com
push dateMon, 01 Aug 2016 14:37:10 +0000
treeherdermozilla-aurora@203106ef6cb6 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersefaust
bugs911216
milestone50.0a1
Bug 911216 - Part 29: Don't unwrap in JS::IsPromiseObject and JS::GetPromiseState. r=efaust
js/src/jsapi.cpp
js/src/vm/SelfHosting.cpp
--- a/js/src/jsapi.cpp
+++ b/js/src/jsapi.cpp
@@ -4672,18 +4672,17 @@ JS::NewPromiseObject(JSContext* cx, Hand
     CHECK_REQUEST(cx);
 
     return PromiseObject::create(cx, executor, proto);
 }
 
 JS_PUBLIC_API(bool)
 JS::IsPromiseObject(JS::HandleObject obj)
 {
-    JSObject* object = CheckedUnwrap(obj);
-    return object && object->is<PromiseObject>();
+    return obj->is<PromiseObject>();
 }
 
 JS_PUBLIC_API(JSObject*)
 JS::GetPromiseConstructor(JSContext* cx)
 {
     CHECK_REQUEST(cx);
     Rooted<GlobalObject*> global(cx, cx->global());
     return GlobalObject::getOrCreatePromiseConstructor(cx, global);
@@ -4693,19 +4692,18 @@ JS_PUBLIC_API(JSObject*)
 JS::GetPromisePrototype(JSContext* cx)
 {
     CHECK_REQUEST(cx);
     Rooted<GlobalObject*> global(cx, cx->global());
     return GlobalObject::getOrCreatePromisePrototype(cx, global);
 }
 
 JS_PUBLIC_API(JS::PromiseState)
-JS::GetPromiseState(JS::HandleObject obj)
-{
-    JSObject* promise = CheckedUnwrap(obj);
+JS::GetPromiseState(JS::HandleObject promise)
+{
     return promise->as<PromiseObject>().state();
 }
 
 JS_PUBLIC_API(uint64_t)
 JS::GetPromiseID(JS::HandleObject promise)
 {
     return promise->as<PromiseObject>().getID();
 }
--- a/js/src/vm/SelfHosting.cpp
+++ b/js/src/vm/SelfHosting.cpp
@@ -2089,17 +2089,17 @@ static bool
 intrinsic_IsWrappedPromiseObject(JSContext* cx, unsigned argc, Value* vp)
 {
     CallArgs args = CallArgsFromVp(argc, vp);
     MOZ_ASSERT(args.length() == 1);
 
     RootedObject obj(cx, &args[0].toObject());
     MOZ_ASSERT(!obj->is<PromiseObject>(),
                "Unwrapped promises should be filtered out in inlineable code");
-    args.rval().setBoolean(JS::IsPromiseObject(obj));
+    args.rval().setBoolean(CheckedUnwrap(obj)->is<PromiseObject>());
     return true;
 }
 
 static bool
 intrinsic_HostResolveImportedModule(JSContext* cx, unsigned argc, Value* vp)
 {
     CallArgs args = CallArgsFromVp(argc, vp);
     MOZ_ASSERT(args.length() == 2);