Backed out changeset 45ff6c2d30e5 (bug 1548729) for SpiderMonkey failure at build/src/js/src/vm/SourceHook.cpp
authorCoroiu Cristina <ccoroiu@mozilla.com>
Sat, 11 May 2019 02:15:15 +0300
changeset 532306 a4b14e656ad8ab0dea0fde5970cf97fd301334e1
parent 532305 03329e7c7f4f44818d2aa4a3be12ad04106245d9
child 532307 776f4df8561d0d4d106aa803e246ad33884493f3
push id11265
push userffxbld-merge
push dateMon, 13 May 2019 10:53:39 +0000
treeherdermozilla-beta@77e0fe8dbdd3 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs1548729
milestone68.0a1
backs out45ff6c2d30e505ca7f6d1060f119ed3e713fc244
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
Backed out changeset 45ff6c2d30e5 (bug 1548729) for SpiderMonkey failure at build/src/js/src/vm/SourceHook.cpp
js/public/experimental/SourceHook.h
js/src/jsfriendapi.cpp
js/src/jsfriendapi.h
js/src/moz.build
js/src/shell/js.cpp
js/src/vm/Runtime.h
js/src/vm/SourceHook.cpp
js/xpconnect/src/XPCJSRuntime.cpp
deleted file mode 100644
--- a/js/public/experimental/SourceHook.h
+++ /dev/null
@@ -1,99 +0,0 @@
-/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*-
- * vim: set ts=8 sts=2 et sw=2 tw=80:
- * This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-/*
- * The context-wide source hook allows the source of scripts/functions to be
- * discarded, if that source is constant and readily-reloadable if it's needed
- * in the future.
- *
- * Ordinarily, functions and scripts store a copy of their underlying source, to
- * support |Function.prototype.toString| and debuggers.  Some scripts, however,
- * might be constant and retrievable on demand -- perhaps burned into the binary
- * or in a readonly file provided by the embedding.  Why not just ask the
- * embedding for a copy of the source?
- *
- * The context-wide |SourceHook| gives embedders a way to respond to these
- * requests.  The source of scripts/functions compiled with the compile option
- * |JS::CompileOptions::setSourceIsLazy(true)| is eligible to be discarded.
- * (The exact conditions under which source is discarded are unspecified.)  *If*
- * source is discarded, performing an operation that requires source uses the
- * source hook to load the source.
- *
- * The source hook must return the *exact* same source for every call.  (This is
- * why the source hook is unsuitable for use with scripts loaded from the web:
- * in general, their contents can change over time.)  If the source hook doesn't
- * return the exact same source, Very Bad Things may happen.  (For example,
- * previously-valid indexes into the source will no longer be coherent: they
- * might index out of bounds, into the middle of multi-unit code points, &c.)
- *
- * These APIs are experimental because they shouldn't provide a per-*context*
- * mechanism, rather something that's per-compilation.
- */
-
-#ifndef js_experimental_SourceHook_h
-#define js_experimental_SourceHook_h
-
-#include "mozilla/UniquePtr.h"  // mozilla::UniquePtr
-
-#include <stddef.h>  // size_t
-
-#include "jstypes.h"  // JS_FRIEND_API
-
-struct JSContext;
-
-namespace js {
-
-/**
- * A class of objects that return source code on demand.
- *
- * When code is compiled with setSourceIsLazy(true), SpiderMonkey doesn't
- * retain the source code (and doesn't do lazy bytecode generation). If we ever
- * need the source code, say, in response to a call to Function.prototype.
- * toSource or Debugger.Source.prototype.text, then we call the 'load' member
- * function of the instance of this class that has hopefully been registered
- * with the runtime, passing the code's URL, and hope that it will be able to
- * find the source.
- */
-class SourceHook {
- public:
-  virtual ~SourceHook() {}
-
-  /**
-   * Attempt to load the source for |filename|.
-   *
-   * On success, return true and store an owning pointer to the UTF-8 or UTF-16
-   * contents of the file in whichever of |twoByteSource| or |utf8Source| is
-   * non-null.  (Exactly one of these will be non-null.)  If the stored pointer
-   * is non-null, source was loaded and must be |js_free|'d when it's no longer
-   * needed.  If the stored pointer is null, the JS engine will simply act as if
-   * source was unavailable, and users like |Function.prototype.toString| will
-   * produce fallback results, e.g. "[native code]".
-   *
-   * On failure, return false.  The contents of whichever of |twoByteSource| or
-   * |utf8Source| was initially non-null are unspecified and must not be
-   * |js_free|'d.
-   */
-  virtual bool load(JSContext* cx, const char* filename,
-                    char16_t** twoByteSource, char** utf8Source,
-                    size_t* length) = 0;
-};
-
-/**
- * Have |cx| use |hook| to retrieve lazily-retrieved source code. See the
- * comments for SourceHook. The context takes ownership of the hook, and
- * will delete it when the context itself is deleted, or when a new hook is
- * set.
- */
-extern JS_FRIEND_API void SetSourceHook(JSContext* cx,
-                                        mozilla::UniquePtr<SourceHook> hook);
-
-/** Remove |cx|'s source hook, and return it. The caller now owns the hook. */
-extern JS_FRIEND_API mozilla::UniquePtr<SourceHook> ForgetSourceHook(
-    JSContext* cx);
-
-} // namespace js
-
-#endif // js_experimental_SourceHook_h
--- a/js/src/jsfriendapi.cpp
+++ b/js/src/jsfriendapi.cpp
@@ -52,16 +52,26 @@ JS::RootingContext::RootingContext()
   PodArrayZero(nativeStackLimit);
 #if JS_STACK_GROWTH_DIRECTION > 0
   for (int i = 0; i < StackKindCount; i++) {
     nativeStackLimit[i] = UINTPTR_MAX;
   }
 #endif
 }
 
+JS_FRIEND_API void js::SetSourceHook(JSContext* cx,
+                                     mozilla::UniquePtr<SourceHook> hook) {
+  cx->runtime()->sourceHook.ref() = std::move(hook);
+}
+
+JS_FRIEND_API mozilla::UniquePtr<SourceHook> js::ForgetSourceHook(
+    JSContext* cx) {
+  return std::move(cx->runtime()->sourceHook.ref());
+}
+
 JS_FRIEND_API void JS_SetGrayGCRootsTracer(JSContext* cx, JSTraceDataOp traceOp,
                                            void* data) {
   cx->runtime()->gc.setGrayRootsTracer(traceOp, data);
 }
 
 JS_FRIEND_API JSObject* JS_FindCompilationScope(JSContext* cx,
                                                 HandleObject objArg) {
   cx->check(objArg);
--- a/js/src/jsfriendapi.h
+++ b/js/src/jsfriendapi.h
@@ -381,16 +381,61 @@ struct JSFunctionSpecWithHelp {
   { nullptr, nullptr, 0, 0, nullptr, nullptr }
 
 extern JS_FRIEND_API bool JS_DefineFunctionsWithHelp(
     JSContext* cx, JS::HandleObject obj, const JSFunctionSpecWithHelp* fs);
 
 namespace js {
 
 /**
+ * A class of objects that return source code on demand.
+ *
+ * When code is compiled with setSourceIsLazy(true), SpiderMonkey doesn't
+ * retain the source code (and doesn't do lazy bytecode generation). If we ever
+ * need the source code, say, in response to a call to Function.prototype.
+ * toSource or Debugger.Source.prototype.text, then we call the 'load' member
+ * function of the instance of this class that has hopefully been registered
+ * with the runtime, passing the code's URL, and hope that it will be able to
+ * find the source.
+ */
+class SourceHook {
+ public:
+  virtual ~SourceHook() {}
+
+  /**
+   * Attempt to load the source for |filename|.
+   *
+   * On success, return true and store an owning pointer to the UTF-8 or UTF-16
+   * contents of the file in whichever of |twoByteSource| or |utf8Source| is
+   * non-null.  (Exactly one of these will be non-null.)  This pointer must be
+   * |js_free|'d when it is no longer needed.
+   *
+   * On failure, return false.  The contents of whichever of |twoByteSource| or
+   * |utf8Source| was initially non-null are unspecified and must not be
+   * |js_free|'d.
+   */
+  virtual bool load(JSContext* cx, const char* filename,
+                    char16_t** twoByteSource, char** utf8Source,
+                    size_t* length) = 0;
+};
+
+/**
+ * Have |cx| use |hook| to retrieve lazily-retrieved source code. See the
+ * comments for SourceHook. The context takes ownership of the hook, and
+ * will delete it when the context itself is deleted, or when a new hook is
+ * set.
+ */
+extern JS_FRIEND_API void SetSourceHook(JSContext* cx,
+                                        mozilla::UniquePtr<SourceHook> hook);
+
+/** Remove |cx|'s source hook, and return it. The caller now owns the hook. */
+extern JS_FRIEND_API mozilla::UniquePtr<SourceHook> ForgetSourceHook(
+    JSContext* cx);
+
+/**
  * Use the runtime's internal handling of job queues for Promise jobs.
  *
  * Most embeddings, notably web browsers, will have their own task scheduling
  * systems and need to integrate handling of Promise jobs into that, so they
  * will want to manage job queues themselves. For basic embeddings such as the
  * JS shell that don't have an event loop of their own, it's easier to have
  * SpiderMonkey handle job queues internally.
  *
--- a/js/src/moz.build
+++ b/js/src/moz.build
@@ -191,20 +191,16 @@ EXPORTS.js += [
     '../public/Utility.h',
     '../public/Value.h',
     '../public/Vector.h',
     '../public/Warnings.h',
     '../public/WeakMapPtr.h',
     '../public/Wrapper.h',
 ]
 
-EXPORTS.js.experimental += [
-    '../public/experimental/SourceHook.h',
-]
-
 UNIFIED_SOURCES += [
     'builtin/Array.cpp',
     'builtin/AtomicsObject.cpp',
     'builtin/BigInt.cpp',
     'builtin/Boolean.cpp',
     'builtin/DataViewObject.cpp',
     'builtin/Eval.cpp',
     'builtin/intl/Collator.cpp',
@@ -317,17 +313,16 @@ UNIFIED_SOURCES += [
     'vm/RegExpStatics.cpp',
     'vm/Runtime.cpp',
     'vm/SavedStacks.cpp',
     'vm/Scope.cpp',
     'vm/SelfHosting.cpp',
     'vm/Shape.cpp',
     'vm/SharedArrayObject.cpp',
     'vm/SharedImmutableStringsCache.cpp',
-    'vm/SourceHook.cpp',
     'vm/Stack.cpp',
     'vm/StringType.cpp',
     'vm/SymbolType.cpp',
     'vm/TaggedProto.cpp',
     'vm/Time.cpp',
     'vm/TypedArrayObject.cpp',
     'vm/TypeInference.cpp',
     'vm/UbiNode.cpp',
--- a/js/src/shell/js.cpp
+++ b/js/src/shell/js.cpp
@@ -88,17 +88,16 @@
 #include "js/ArrayBuffer.h"  // JS::{CreateMappedArrayBufferContents,NewMappedArrayBufferWithContents,IsArrayBufferObject,GetArrayBufferLengthAndData}
 #include "js/BuildId.h"      // JS::BuildIdCharVector, JS::SetProcessBuildIdOp
 #include "js/CharacterEncoding.h"
 #include "js/CompilationAndEvaluation.h"
 #include "js/CompileOptions.h"
 #include "js/ContextOptions.h"  // JS::ContextOptions{,Ref}
 #include "js/Debug.h"
 #include "js/Equality.h"  // JS::SameValue
-#include "js/experimental/SourceHook.h"  // js::{Set,Forget,}SourceHook
 #include "js/GCVector.h"
 #include "js/Initialization.h"
 #include "js/JSON.h"
 #include "js/MemoryFunctions.h"
 #include "js/Printf.h"
 #include "js/PropertySpec.h"
 #include "js/Realm.h"
 #include "js/RegExp.h"  // JS::ObjectIsRegExp
--- a/js/src/vm/Runtime.h
+++ b/js/src/vm/Runtime.h
@@ -26,17 +26,16 @@
 #include "builtin/Promise.h"
 #include "frontend/BinASTRuntimeSupport.h"
 #include "frontend/NameCollections.h"
 #include "gc/GCRuntime.h"
 #include "gc/Tracer.h"
 #include "irregexp/RegExpStack.h"
 #include "js/BuildId.h"  // JS::BuildIdOp
 #include "js/Debug.h"
-#include "js/experimental/SourceHook.h"  // js::SourceHook
 #include "js/GCVector.h"
 #include "js/HashTable.h"
 #ifdef DEBUG
 #  include "js/Proxy.h"  // For AutoEnterPolicy
 #endif
 #include "js/Stream.h"
 #include "js/Symbol.h"
 #include "js/UniquePtr.h"
deleted file mode 100644
--- a/js/src/vm/SourceHook.cpp
+++ /dev/null
@@ -1,24 +0,0 @@
-/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*-
- * vim: set ts=8 sts=2 et sw=2 tw=80:
- * This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-#include "mozilla/UniquePtr.h"  // mozilla::UniquePtr
-
-#include <utility>  // std::move
-
-#include "jstypes.h"  // JS_FRIEND_API
-
-#include "js/experimental/SourceHook.h"  // js::{Set,Forget,}SourceHook
-#include "vm/JSContext.h"
-
-JS_FRIEND_API void js::SetSourceHook(JSContext* cx,
-                                     mozilla::UniquePtr<SourceHook> hook) {
-  cx->runtime()->sourceHook.ref() = std::move(hook);
-}
-
-JS_FRIEND_API mozilla::UniquePtr<SourceHook> js::ForgetSourceHook(
-    JSContext* cx) {
-  return std::move(cx->runtime()->sourceHook.ref());
-}
--- a/js/xpconnect/src/XPCJSRuntime.cpp
+++ b/js/xpconnect/src/XPCJSRuntime.cpp
@@ -39,17 +39,16 @@
 #include "mozilla/dom/ScriptSettings.h"
 
 #include "nsContentUtils.h"
 #include "nsCCUncollectableMarker.h"
 #include "nsCycleCollectionNoteRootCallback.h"
 #include "nsCycleCollector.h"
 #include "jsapi.h"
 #include "js/BuildId.h"  // JS::BuildIdCharVector, JS::SetProcessBuildIdOp
-#include "js/experimental/SourceHook.h"  // js::{,Set}SourceHook
 #include "js/MemoryFunctions.h"
 #include "js/MemoryMetrics.h"
 #include "js/UbiNode.h"
 #include "js/UbiNodeUtils.h"
 #include "mozilla/dom/GeneratedAtomList.h"
 #include "mozilla/dom/BindingUtils.h"
 #include "mozilla/dom/Element.h"
 #include "mozilla/dom/WindowBinding.h"