Bug 1544882 - Rename JSScript::tryLoadSource back to JSScript::loadSource now that all users have recognized the semantics change. r=arai
authorJeff Walden <jwalden@mit.edu>
Mon, 15 Apr 2019 14:57:24 -0700
changeset 471435 74774a7f1a4dd13925354df4e3963068fc4cd28d
parent 471434 2af8656bd3c0362939cda478005e9eb2238ed9b5
child 471436 8509f60299dfdb085a8a64ea45522bacb82b16c5
push id35917
push userrmaries@mozilla.com
push dateFri, 26 Apr 2019 09:49:13 +0000
treeherdermozilla-central@7d47e7fa2489 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersarai
bugs1544882
milestone68.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 1544882 - Rename JSScript::tryLoadSource back to JSScript::loadSource now that all users have recognized the semantics change. r=arai Differential Revision: https://phabricator.services.mozilla.com/D27767
js/src/jsapi.cpp
js/src/vm/Debugger.cpp
js/src/vm/JSFunction.cpp
js/src/vm/JSScript.cpp
js/src/vm/JSScript.h
js/src/wasm/AsmJS.cpp
--- a/js/src/jsapi.cpp
+++ b/js/src/jsapi.cpp
@@ -3655,17 +3655,17 @@ JS_PUBLIC_API JSString* JS_DecompileScri
   AssertHeapIsIdle();
   CHECK_THREAD(cx);
   script->ensureNonLazyCanonicalFunction();
   RootedFunction fun(cx, script->functionNonDelazifying());
   if (fun) {
     return JS_DecompileFunction(cx, fun);
   }
   bool haveSource;
-  if (!JSScript::tryLoadSource(cx, script->scriptSource(), &haveSource)) {
+  if (!JSScript::loadSource(cx, script->scriptSource(), &haveSource)) {
     return nullptr;
   }
   return haveSource ? JSScript::sourceData(cx, script)
                     : NewStringCopyZ<CanGC>(cx, "[no source]");
 }
 
 JS_PUBLIC_API JSString* JS_DecompileFunction(JSContext* cx,
                                              HandleFunction fun) {
--- a/js/src/vm/Debugger.cpp
+++ b/js/src/vm/Debugger.cpp
@@ -8407,17 +8407,17 @@ class DebuggerSourceGetTextMatcher {
  public:
   explicit DebuggerSourceGetTextMatcher(JSContext* cx) : cx_(cx) {}
 
   using ReturnType = JSString*;
 
   ReturnType match(HandleScriptSourceObject sourceObject) {
     ScriptSource* ss = sourceObject->source();
     bool hasSourceText;
-    if (!JSScript::tryLoadSource(cx_, ss, &hasSourceText)) {
+    if (!JSScript::loadSource(cx_, ss, &hasSourceText)) {
       return nullptr;
     }
     if (!hasSourceText) {
       return NewStringCopyZ<CanGC>(cx_, "[no source]");
     }
 
     if (ss->isFunctionBody()) {
       return ss->functionBodyString(cx_);
--- a/js/src/vm/JSFunction.cpp
+++ b/js/src/vm/JSFunction.cpp
@@ -865,17 +865,17 @@ JSString* js::FunctionToString(JSContext
                     (fun->isClassConstructor() || !fun->isSelfHostedBuiltin());
 
   // If we're in toSource mode, put parentheses around lambda functions so
   // that eval returns lambda, not function statement.
   bool addParentheses =
       haveSource && isToSource && (fun->isLambda() && !fun->isArrow());
 
   if (haveSource) {
-    if (!JSScript::tryLoadSource(cx, script->scriptSource(), &haveSource)) {
+    if (!JSScript::loadSource(cx, script->scriptSource(), &haveSource)) {
       return nullptr;
     }
   }
 
   // Fast path for the common case, to avoid StringBuffer overhead.
   if (!addParentheses && haveSource) {
     FunctionToStringCache& cache = cx->zone()->functionToStringCache();
     if (JSString* str = cache.lookup(script)) {
--- a/js/src/vm/JSScript.cpp
+++ b/js/src/vm/JSScript.cpp
@@ -1648,17 +1648,17 @@ void ScriptSourceObject::setPrivate(JSRu
   JS::AutoSuppressGCAnalysis nogc;
   Value prevValue = getReservedSlot(PRIVATE_SLOT);
   rt->releaseScriptPrivate(prevValue);
   setReservedSlot(PRIVATE_SLOT, value);
   rt->addRefScriptPrivate(value);
 }
 
 /* static */
-bool JSScript::tryLoadSource(JSContext* cx, ScriptSource* ss, bool* loaded) {
+bool JSScript::loadSource(JSContext* cx, ScriptSource* ss, bool* loaded) {
   *loaded = ss->hasSourceText();
   if (*loaded) {
     return true;
   }
 
   if (!cx->runtime()->sourceHook.ref() || !ss->sourceRetrievable()) {
     return true;
   }
--- a/js/src/vm/JSScript.h
+++ b/js/src/vm/JSScript.h
@@ -2489,17 +2489,21 @@ class JSScript : public js::gc::TenuredC
   // directly, via lazy arguments or a rest parameter.
   bool mayReadFrameArgsDirectly();
 
   static JSFlatString* sourceData(JSContext* cx, JS::HandleScript script);
 
   MOZ_MUST_USE bool appendSourceDataForToString(JSContext* cx,
                                                 js::StringBuffer& buf);
 
-  static bool tryLoadSource(JSContext* cx, js::ScriptSource* ss, bool* loaded);
+  // Attempt to load usable source for |ss| -- source text on which substring
+  // operations and the like can be performed.  On success return true and set
+  // |*loaded| to indicate whether usable source could be loaded; otherwise
+  // return false.
+  static bool loadSource(JSContext* cx, js::ScriptSource* ss, bool* loaded);
 
   void setSourceObject(js::ScriptSourceObject* object);
   js::ScriptSourceObject* sourceObject() const { return sourceObject_; }
   js::ScriptSource* scriptSource() const;
   js::ScriptSource* maybeForwardedScriptSource() const;
 
   void setDefaultClassConstructorSpan(js::ScriptSourceObject* sourceObject,
                                       uint32_t start, uint32_t end,
--- a/js/src/wasm/AsmJS.cpp
+++ b/js/src/wasm/AsmJS.cpp
@@ -6882,17 +6882,17 @@ static bool HandleInstantiationFailure(J
     return false;
   }
 
   ScriptSource* source = metadata.scriptSource.get();
 
   // Source discarding is allowed to affect JS semantics because it is never
   // enabled for normal JS content.
   bool haveSource;
-  if (!JSScript::tryLoadSource(cx, source, &haveSource)) {
+  if (!JSScript::loadSource(cx, source, &haveSource)) {
     return false;
   }
   if (!haveSource) {
     JS_ReportErrorASCII(cx,
                         "asm.js link failure with source discarding enabled");
     return false;
   }
 
@@ -7214,17 +7214,17 @@ JSString* js::AsmJSModuleToString(JSCont
 
   JSStringBuilder out(cx);
 
   if (isToSource && fun->isLambda() && !out.append("(")) {
     return nullptr;
   }
 
   bool haveSource;
-  if (!JSScript::tryLoadSource(cx, source, &haveSource)) {
+  if (!JSScript::loadSource(cx, source, &haveSource)) {
     return nullptr;
   }
 
   if (!haveSource) {
     if (!out.append("function ")) {
       return nullptr;
     }
     if (fun->explicitName() && !out.append(fun->explicitName())) {
@@ -7265,17 +7265,17 @@ JSString* js::AsmJSFunctionToString(JSCo
   ScriptSource* source = metadata.scriptSource.get();
   JSStringBuilder out(cx);
 
   if (!out.append("function ")) {
     return nullptr;
   }
 
   bool haveSource;
-  if (!JSScript::tryLoadSource(cx, source, &haveSource)) {
+  if (!JSScript::loadSource(cx, source, &haveSource)) {
     return nullptr;
   }
 
   if (!haveSource) {
     // asm.js functions can't be anonymous
     MOZ_ASSERT(fun->explicitName());
     if (!out.append(fun->explicitName())) {
       return nullptr;