Bug 1521141 - Part 3: Use js::Throw helper in a few more places. r=jorendorff
authorAndré Bargull <andre.bargull@gmail.com>
Fri, 18 Jan 2019 11:06:13 -0800
changeset 515373 e166c6ae9e1e65e3b05906e03e1af9d02227c140
parent 515372 a6d3f60fc17231cc3d7f2d3a48134669c05df809
child 515374 250c2923583de86eb9afd4e47ddc0a1ad242d5d4
push id1953
push userffxbld-merge
push dateMon, 11 Mar 2019 12:10:20 +0000
treeherdermozilla-release@9c35dcbaa899 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjorendorff
bugs1521141
milestone66.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1521141 - Part 3: Use js::Throw helper in a few more places. r=jorendorff
js/src/builtin/TypedObject.cpp
js/src/proxy/Proxy.cpp
js/src/proxy/ScriptedProxyHandler.cpp
js/src/proxy/SecurityWrapper.cpp
js/src/vm/EnvironmentObject.cpp
js/src/vm/SelfHosting.cpp
--- a/js/src/builtin/TypedObject.cpp
+++ b/js/src/builtin/TypedObject.cpp
@@ -13,16 +13,17 @@
 
 #include "gc/Marking.h"
 #include "js/CharacterEncoding.h"
 #include "js/PropertySpec.h"
 #include "js/Vector.h"
 #include "util/StringBuffer.h"
 #include "vm/GlobalObject.h"
 #include "vm/JSFunction.h"
+#include "vm/JSObject.h"
 #include "vm/Realm.h"
 #include "vm/SelfHosting.h"
 #include "vm/StringType.h"
 #include "vm/TypedArrayObject.h"
 
 #include "gc/Nursery-inl.h"
 #include "gc/StoreBuffer-inl.h"
 #include "vm/JSAtom-inl.h"
@@ -2069,25 +2070,17 @@ static bool IsOwnId(JSContext* cx, Handl
   }
 
   return false;
 }
 
 bool TypedObject::obj_deleteProperty(JSContext* cx, HandleObject obj,
                                      HandleId id, ObjectOpResult& result) {
   if (IsOwnId(cx, obj, id)) {
-    UniqueChars propName =
-        IdToPrintableUTF8(cx, id, IdToPrintableBehavior::IdIsPropertyKey);
-    if (!propName) {
-      return false;
-    }
-
-    JS_ReportErrorNumberUTF8(cx, GetErrorMessage, nullptr, JSMSG_CANT_DELETE,
-                             propName.get());
-    return false;
+    return Throw(cx, id, JSMSG_CANT_DELETE);
   }
 
   RootedObject proto(cx, obj->staticPrototype());
   if (!proto) {
     return result.succeed();
   }
 
   return DeleteProperty(cx, proto, id, result);
--- a/js/src/proxy/Proxy.cpp
+++ b/js/src/proxy/Proxy.cpp
@@ -14,16 +14,17 @@
 
 #include "js/PropertySpec.h"
 #include "js/StableStringChars.h"
 #include "js/Wrapper.h"
 #include "proxy/DeadObjectProxy.h"
 #include "proxy/ScriptedProxyHandler.h"
 #include "vm/JSContext.h"
 #include "vm/JSFunction.h"
+#include "vm/JSObject.h"
 #include "vm/WrapperObject.h"
 
 #include "gc/Marking-inl.h"
 #include "vm/JSAtom-inl.h"
 #include "vm/JSObject-inl.h"
 #include "vm/NativeObject-inl.h"
 
 using namespace js;
@@ -32,24 +33,17 @@ void js::AutoEnterPolicy::reportErrorIfE
                                                              HandleId id) {
   if (JS_IsExceptionPending(cx)) {
     return;
   }
 
   if (JSID_IS_VOID(id)) {
     ReportAccessDenied(cx);
   } else {
-    UniqueChars prop =
-        IdToPrintableUTF8(cx, id, IdToPrintableBehavior::IdIsPropertyKey);
-    if (!prop) {
-      return;
-    }
-
-    JS_ReportErrorNumberUTF8(cx, GetErrorMessage, nullptr,
-                             JSMSG_PROPERTY_ACCESS_DENIED, prop.get());
+    Throw(cx, id, JSMSG_PROPERTY_ACCESS_DENIED);
   }
 }
 
 #ifdef DEBUG
 void js::AutoEnterPolicy::recordEnter(JSContext* cx, HandleObject proxy,
                                       HandleId id, Action act) {
   if (allowed()) {
     context = cx;
--- a/js/src/proxy/ScriptedProxyHandler.cpp
+++ b/js/src/proxy/ScriptedProxyHandler.cpp
@@ -6,16 +6,17 @@
 
 #include "proxy/ScriptedProxyHandler.h"
 
 #include "jsapi.h"
 
 #include "js/CharacterEncoding.h"
 #include "js/PropertyDescriptor.h"  // JS::FromPropertyDescriptor
 #include "vm/EqualityOperations.h"  // js::SameValue
+#include "vm/JSObject.h"
 
 #include "vm/JSObject-inl.h"
 #include "vm/NativeObject-inl.h"
 
 using namespace js;
 
 using JS::IsArrayAnswer;
 
@@ -987,25 +988,17 @@ bool ScriptedProxyHandler::delete_(JSCon
   // Step 10.
   Rooted<PropertyDescriptor> desc(cx);
   if (!GetOwnPropertyDescriptor(cx, target, id, &desc)) {
     return false;
   }
 
   // Step 12.
   if (desc.object() && !desc.configurable()) {
-    UniqueChars bytes =
-        IdToPrintableUTF8(cx, id, IdToPrintableBehavior::IdIsPropertyKey);
-    if (!bytes) {
-      return false;
-    }
-
-    JS_ReportErrorNumberUTF8(cx, GetErrorMessage, nullptr, JSMSG_CANT_DELETE,
-                             bytes.get());
-    return false;
+    return Throw(cx, id, JSMSG_CANT_DELETE);
   }
 
   // Steps 11,13.
   return result.succeed();
 }
 
 // ES8 rev 0c1bd3004329336774cbc90de727cd0cf5f11e93
 // 9.5.7 Proxy.[[HasProperty]](P)
--- a/js/src/proxy/SecurityWrapper.cpp
+++ b/js/src/proxy/SecurityWrapper.cpp
@@ -5,16 +5,17 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "jsapi.h"
 #include "jsfriendapi.h"
 #include "NamespaceImports.h"
 
 #include "js/StableStringChars.h"
 #include "js/Wrapper.h"
+#include "vm/JSObject.h"
 #include "vm/StringType.h"
 
 using namespace js;
 
 using JS::AutoStableStringChars;
 
 template <class Base>
 bool SecurityWrapper<Base>::enter(JSContext* cx, HandleObject wrapper,
@@ -96,24 +97,16 @@ bool SecurityWrapper<Base>::boxedValue_u
 }
 
 template <class Base>
 bool SecurityWrapper<Base>::defineProperty(JSContext* cx, HandleObject wrapper,
                                            HandleId id,
                                            Handle<PropertyDescriptor> desc,
                                            ObjectOpResult& result) const {
   if (desc.getter() || desc.setter()) {
-    UniqueChars prop =
-        IdToPrintableUTF8(cx, id, IdToPrintableBehavior::IdIsPropertyKey);
-    if (!prop) {
-      return false;
-    }
-
-    JS_ReportErrorNumberUTF8(cx, GetErrorMessage, nullptr,
-                             JSMSG_ACCESSOR_DEF_DENIED, prop.get());
-    return false;
+    return Throw(cx, id, JSMSG_ACCESSOR_DEF_DENIED);
   }
 
   return Base::defineProperty(cx, wrapper, id, desc, result);
 }
 
 template class js::SecurityWrapper<Wrapper>;
 template class js::SecurityWrapper<CrossCompartmentWrapper>;
--- a/js/src/vm/EnvironmentObject.cpp
+++ b/js/src/vm/EnvironmentObject.cpp
@@ -7,16 +7,17 @@
 #include "vm/EnvironmentObject-inl.h"
 
 #include "builtin/ModuleObject.h"
 #include "gc/Policy.h"
 #include "vm/ArgumentsObject.h"
 #include "vm/AsyncFunction.h"
 #include "vm/GlobalObject.h"
 #include "vm/Iteration.h"
+#include "vm/JSObject.h"
 #include "vm/ProxyObject.h"
 #include "vm/Realm.h"
 #include "vm/Shape.h"
 #include "vm/Xdr.h"
 #include "wasm/WasmInstance.h"
 
 #include "gc/Marking-inl.h"
 #include "vm/JSAtom-inl.h"
--- a/js/src/vm/SelfHosting.cpp
+++ b/js/src/vm/SelfHosting.cpp
@@ -44,16 +44,17 @@
 #include "util/StringBuffer.h"
 #include "vm/ArgumentsObject.h"
 #include "vm/Compression.h"
 #include "vm/GeneratorObject.h"
 #include "vm/Interpreter.h"
 #include "vm/Iteration.h"
 #include "vm/JSContext.h"
 #include "vm/JSFunction.h"
+#include "vm/JSObject.h"
 #include "vm/Printer.h"
 #include "vm/Realm.h"
 #include "vm/RegExpObject.h"
 #include "vm/StringType.h"
 #include "vm/TypedArrayObject.h"
 #include "vm/WrapperObject.h"
 
 #include "gc/PrivateIterators-inl.h"
@@ -2953,25 +2954,17 @@ static bool VerifyGlobalNames(JSContext*
           nameMissing = true;
           break;
         }
       }
     }
   }
 
   if (nameMissing) {
-    UniqueChars bytes =
-        IdToPrintableUTF8(cx, id, IdToPrintableBehavior::IdIsPropertyKey);
-    if (!bytes) {
-      return false;
-    }
-
-    JS_ReportErrorNumberUTF8(cx, GetErrorMessage, nullptr,
-                             JSMSG_NO_SUCH_SELF_HOSTED_PROP, bytes.get());
-    return false;
+    return Throw(cx, id, JSMSG_NO_SUCH_SELF_HOSTED_PROP);
   }
 #endif  // DEBUG
 
   return true;
 }
 
 bool JSRuntime::initSelfHosting(JSContext* cx) {
   MOZ_ASSERT(!selfHostingGlobal_);