From 1331eb4e542835f7a774c39db7527d7dc90e9773 Mon Sep 17 00:00:00 2001 From: Jan de Mooij Date: Tue, 25 Apr 2017 15:08:42 +0200 Subject: [PATCH] Bug 1359093 - Inline the ToWindowProxyIfWindow is-global check. r=evilpie --HG-- extra : rebase_source : 5ea21a17fcb72114f6740f41343f2168ddede125 --- js/src/jsfriendapi.cpp | 6 +++--- js/src/jsfriendapi.h | 12 ++++++++++-- js/src/proxy/Proxy.cpp | 2 +- 3 files changed, 14 insertions(+), 6 deletions(-) diff --git a/js/src/jsfriendapi.cpp b/js/src/jsfriendapi.cpp index 356ff8597c66..058de0d8ee9c 100644 --- a/js/src/jsfriendapi.cpp +++ b/js/src/jsfriendapi.cpp @@ -1436,10 +1436,10 @@ js::ToWindowIfWindowProxy(JSObject* obj) } JS_FRIEND_API(JSObject*) -js::ToWindowProxyIfWindow(JSObject* obj) +js::detail::ToWindowProxyIfWindowSlow(JSObject* obj) { - if (IsWindow(obj)) - return obj->as().windowProxy(); + if (JSObject* windowProxy = obj->as().maybeWindowProxy()) + return windowProxy; return obj; } diff --git a/js/src/jsfriendapi.h b/js/src/jsfriendapi.h index ebb41b23de5d..46652d8647e9 100644 --- a/js/src/jsfriendapi.h +++ b/js/src/jsfriendapi.h @@ -2890,6 +2890,9 @@ namespace detail { JS_FRIEND_API(bool) IsWindowSlow(JSObject* obj); +JS_FRIEND_API(JSObject*) +ToWindowProxyIfWindowSlow(JSObject* obj); + } // namespace detail /** @@ -2915,8 +2918,13 @@ IsWindowProxy(JSObject* obj); * wrapper if the page was navigated away from), else return `obj`. This * function is infallible and never returns nullptr. */ -extern JS_FRIEND_API(JSObject*) -ToWindowProxyIfWindow(JSObject* obj); +MOZ_ALWAYS_INLINE JSObject* +ToWindowProxyIfWindow(JSObject* obj) +{ + if (GetObjectClass(obj)->flags & JSCLASS_IS_GLOBAL) + return detail::ToWindowProxyIfWindowSlow(obj); + return obj; +} /** * If `obj` is a WindowProxy, get its associated Window (the compartment's diff --git a/js/src/proxy/Proxy.cpp b/js/src/proxy/Proxy.cpp index 5d88c957ae35..db72cb6ca78a 100644 --- a/js/src/proxy/Proxy.cpp +++ b/js/src/proxy/Proxy.cpp @@ -299,7 +299,7 @@ js::ProxyHasOwn(JSContext* cx, HandleObject proxy, HandleValue idVal, MutableHan return true; } -static Value +static MOZ_ALWAYS_INLINE Value ValueToWindowProxyIfWindow(const Value& v) { if (v.isObject())