Bug 1454207 - Part 1: Changes js::ReportIsNotDefined from a value-returning function to a Non-value-returning function r?arai draft
authorZhang Junzhi <zjz@zjz.name>
Sun, 15 Apr 2018 12:49:23 +0800
changeset 782452 51141aeb3880cf889e1c9bafd406d03310f07976
parent 782281 a79d460bf2a33fd79c6646236f9c4df78e66e7b7
child 782453 ea833b6e508f38dae42920feb5585770ac264e42
push id106540
push userbmo:zjz@zjz.name
push dateMon, 16 Apr 2018 05:23:38 +0000
reviewersarai
bugs1454207
milestone61.0a1
Bug 1454207 - Part 1: Changes js::ReportIsNotDefined from a value-returning function to a Non-value-returning function r?arai MozReview-Commit-ID: Gzb6k0PchNw
js/src/vm/Interpreter-inl.h
js/src/vm/JSContext.cpp
js/src/vm/JSContext.h
js/src/vm/NativeObject.cpp
--- a/js/src/vm/Interpreter-inl.h
+++ b/js/src/vm/Interpreter-inl.h
@@ -175,17 +175,18 @@ enum class GetNameMode { Normal, TypeOf 
 template <GetNameMode mode>
 inline bool
 FetchName(JSContext* cx, HandleObject receiver, HandleObject holder, HandlePropertyName name,
           Handle<PropertyResult> prop, MutableHandleValue vp)
 {
     if (!prop) {
         switch (mode) {
           case GetNameMode::Normal:
-            return ReportIsNotDefined(cx, name);
+            ReportIsNotDefined(cx, name);
+            return false;
           case GetNameMode::TypeOf:
             vp.setUndefined();
             return true;
         }
     }
 
     /* Take the slow path if shape was not found in a native object. */
     if (!receiver->isNative() || !holder->isNative()) {
--- a/js/src/vm/JSContext.cpp
+++ b/js/src/vm/JSContext.cpp
@@ -875,32 +875,30 @@ js::ReportErrorNumberUCArray(JSContext* 
         return false;
     }
 
     ReportError(cx, &report, callback, userRef);
 
     return warning;
 }
 
-bool
+void
 js::ReportIsNotDefined(JSContext* cx, HandleId id)
 {
     JSAutoByteString printable;
-    if (ValueToPrintable(cx, IdToValue(id), &printable)) {
-        JS_ReportErrorNumberLatin1(cx, GetErrorMessage, nullptr, JSMSG_NOT_DEFINED,
-                                   printable.ptr());
-    }
-    return false;
+    if (!ValueToPrintable(cx, IdToValue(id), &printable))
+        return;
+    JS_ReportErrorNumberLatin1(cx, GetErrorMessage, nullptr, JSMSG_NOT_DEFINED, printable.ptr());
 }
 
-bool
+void
 js::ReportIsNotDefined(JSContext* cx, HandlePropertyName name)
 {
     RootedId id(cx, NameToId(name));
-    return ReportIsNotDefined(cx, id);
+    ReportIsNotDefined(cx, id);
 }
 
 bool
 js::ReportIsNullOrUndefined(JSContext* cx, int spindex, HandleValue v,
                             HandleString fallback)
 {
     bool ok;
 
--- a/js/src/vm/JSContext.h
+++ b/js/src/vm/JSContext.h
@@ -1023,20 +1023,20 @@ ReportUsageErrorASCII(JSContext* cx, Han
  * and the report doesn't have the JSREPORT_WARNING flag set or reportWarnings
  * is true.
  * Returns false otherwise.
  */
 extern bool
 PrintError(JSContext* cx, FILE* file, JS::ConstUTF8CharsZ toStringResult,
            JSErrorReport* report, bool reportWarnings);
 
-extern bool
+extern void
 ReportIsNotDefined(JSContext* cx, HandlePropertyName name);
 
-extern bool
+extern void
 ReportIsNotDefined(JSContext* cx, HandleId id);
 
 /*
  * Report an attempt to access the property of a null or undefined value (v).
  */
 extern bool
 ReportIsNullOrUndefined(JSContext* cx, int spindex, HandleValue v, HandleString fallback);
 
--- a/js/src/vm/NativeObject.cpp
+++ b/js/src/vm/NativeObject.cpp
@@ -2306,18 +2306,20 @@ enum IsNameLookup { NotNameLookup = fals
  *     Gecko code.)
  */
 static bool
 GetNonexistentProperty(JSContext* cx, HandleId id, IsNameLookup nameLookup, MutableHandleValue vp)
 {
     vp.setUndefined();
 
     // If we are doing a name lookup, this is a ReferenceError.
-    if (nameLookup)
-        return ReportIsNotDefined(cx, id);
+    if (nameLookup) {
+        ReportIsNotDefined(cx, id);
+        return false;
+    }
 
     // Give a strict warning if foo.bar is evaluated by a script for an object
     // foo with no property named 'bar'.
     //
     // Don't warn if extra warnings not enabled or for random getprop
     // operations.
     if (MOZ_LIKELY(!cx->compartment()->behaviors().extraWarnings(cx)))
         return true;
@@ -2376,18 +2378,20 @@ GeneralizedGetProperty(JSContext* cx, Ha
         //
         // If we get here, we've reached a non-native object. Fall back on the
         // algorithm as specified, with two separate lookups. (Note that we
         // throw ReferenceErrors regardless of strictness, technically a bug.)
 
         bool found;
         if (!HasProperty(cx, obj, id, &found))
             return false;
-        if (!found)
-            return ReportIsNotDefined(cx, id);
+        if (!found) {
+            ReportIsNotDefined(cx, id);
+            return false;
+        }
     }
 
     return GetProperty(cx, obj, receiver, id, vp);
 }
 
 static inline bool
 GeneralizedGetProperty(JSContext* cx, JSObject* obj, jsid id, const Value& receiver,
                        IsNameLookup nameLookup, FakeMutableHandle<Value> vp)