Bug 1031881: Remove unused elements of JSDebugHooks, and their supporting code. r=sfink
authorJim Blandy <jimb@mozilla.com>
Sat, 19 Jul 2014 18:07:05 -0700
changeset 215987 9a19c530f3d094b8debffb36e0c7a745f29a8eb9
parent 215986 94e4e5751af2e6a3ab12b99a23c6cfd14a9c238d
child 215988 9520f63174d0c98a7a65d658068a289c07799231
push idunknown
push userunknown
push dateunknown
reviewerssfink
bugs1031881
milestone33.0a1
Bug 1031881: Remove unused elements of JSDebugHooks, and their supporting code. r=sfink
js/public/OldDebugAPI.h
js/src/builtin/Eval.cpp
js/src/frontend/BytecodeCompiler.cpp
js/src/frontend/BytecodeCompiler.h
js/src/frontend/BytecodeEmitter.cpp
js/src/jit-test/tests/jaeger/bug563000/test-throwhook-1.js
js/src/jit-test/tests/jaeger/bug563000/test-throwhook-2.js
js/src/jit/BaselineFrame.cpp
js/src/jit/BaselineFrame.h
js/src/jit/BaselineJIT.cpp
js/src/jit/VMFunctions.cpp
js/src/jsapi-tests/testDebugger.cpp
js/src/jsapi-tests/testSourcePolicy.cpp
js/src/jscntxt.cpp
js/src/jsfun.cpp
js/src/jsscript.cpp
js/src/jsscript.h
js/src/shell/js.cpp
js/src/vm/HelperThreads.cpp
js/src/vm/Interpreter.cpp
js/src/vm/OldDebugAPI.cpp
js/src/vm/Stack-inl.h
js/src/vm/Stack.cpp
js/src/vm/Stack.h
--- a/js/public/OldDebugAPI.h
+++ b/js/public/OldDebugAPI.h
@@ -59,50 +59,23 @@ typedef enum JSTrapStatus {
     JSTRAP_LIMIT
 } JSTrapStatus;
 
 typedef JSTrapStatus
 (* JSTrapHandler)(JSContext *cx, JSScript *script, jsbytecode *pc, JS::Value *rval,
                   JS::Value closure);
 
 typedef JSTrapStatus
-(* JSInterruptHook)(JSContext *cx, JSScript *script, jsbytecode *pc, JS::Value *rval,
-                    void *closure);
-
-typedef JSTrapStatus
 (* JSDebuggerHandler)(JSContext *cx, JSScript *script, jsbytecode *pc, JS::Value *rval,
                       void *closure);
 
-typedef JSTrapStatus
-(* JSThrowHook)(JSContext *cx, JSScript *script, jsbytecode *pc, JS::Value *rval,
-                void *closure);
-
 typedef bool
 (* JSWatchPointHandler)(JSContext *cx, JSObject *obj, jsid id, JS::Value old,
                         JS::Value *newp, void *closure);
 
-/* called just after script creation */
-typedef void
-(* JSNewScriptHook)(JSContext  *cx,
-                    const char *filename,  /* URL of script */
-                    unsigned   lineno,     /* first line */
-                    JSScript   *script,
-                    JSFunction *fun,
-                    void       *callerdata);
-
-/* called just before script destruction */
-typedef void
-(* JSDestroyScriptHook)(JSFreeOp *fop,
-                        JSScript *script,
-                        void     *callerdata);
-
-typedef void
-(* JSSourceHandler)(const char *filename, unsigned lineno, const jschar *str,
-                    size_t length, void **listenerTSData, void *closure);
-
 
 
 extern JS_PUBLIC_API(JSCompartment *)
 JS_EnterCompartmentOfScript(JSContext *cx, JSScript *target);
 
 extern JS_PUBLIC_API(JSString *)
 JS_DecompileScript(JSContext *cx, JS::HandleScript script, const char *name, unsigned indent);
 
@@ -162,22 +135,16 @@ JS_ClearTrap(JSContext *cx, JSScript *sc
              JSTrapHandler *handlerp, JS::Value *closurep);
 
 extern JS_PUBLIC_API(void)
 JS_ClearScriptTraps(JSRuntime *rt, JSScript *script);
 
 extern JS_PUBLIC_API(void)
 JS_ClearAllTrapsForCompartment(JSContext *cx);
 
-extern JS_PUBLIC_API(bool)
-JS_SetInterrupt(JSRuntime *rt, JSInterruptHook handler, void *closure);
-
-extern JS_PUBLIC_API(bool)
-JS_ClearInterrupt(JSRuntime *rt, JSInterruptHook *handlerp, void **closurep);
-
 /************************************************************************/
 
 extern JS_PUBLIC_API(bool)
 JS_SetWatchPoint(JSContext *cx, JS::HandleObject obj, JS::HandleId id,
                  JSWatchPointHandler handler, JS::HandleObject closure);
 
 extern JS_PUBLIC_API(bool)
 JS_ClearWatchPoint(JSContext *cx, JSObject *obj, jsid id,
@@ -259,32 +226,16 @@ JS_GetScriptLineExtent(JSContext *cx, JS
 extern JS_PUBLIC_API(JSVersion)
 JS_GetScriptVersion(JSContext *cx, JSScript *script);
 
 extern JS_PUBLIC_API(bool)
 JS_GetScriptIsSelfHosted(JSScript *script);
 
 /************************************************************************/
 
-/*
- * Hook setters for script creation and destruction.  These macros provide
- * binary compatibility and newer, shorter synonyms.
- */
-#define JS_SetNewScriptHook     JS_SetNewScriptHookProc
-#define JS_SetDestroyScriptHook JS_SetDestroyScriptHookProc
-
-extern JS_PUBLIC_API(void)
-JS_SetNewScriptHook(JSRuntime *rt, JSNewScriptHook hook, void *callerdata);
-
-extern JS_PUBLIC_API(void)
-JS_SetDestroyScriptHook(JSRuntime *rt, JSDestroyScriptHook hook,
-                        void *callerdata);
-
-/************************************************************************/
-
 typedef struct JSPropertyDesc {
     JS::Value       id;         /* primary id, atomized string, or int */
     JS::Value       value;      /* property value */
     uint8_t         flags;      /* flags, see below */
     uint8_t         spare;      /* unused */
     JS::Value       alias;      /* alias id if JSPD_ALIAS flag */
 } JSPropertyDesc;
 
@@ -382,90 +333,30 @@ class JS_PUBLIC_API(JSBrokenFrameIterato
     JSBrokenFrameIterator& operator++();
 
     JSAbstractFramePtr abstractFramePtr() const;
     jsbytecode *pc() const;
 
     bool isConstructing() const;
 };
 
-/*
- * This hook captures high level script execution and function calls (JS or
- * native).  It is used by JS_SetExecuteHook to hook top level scripts and by
- * JS_SetCallHook to hook function calls.  It will get called twice per script
- * or function call: just before execution begins and just after it finishes.
- * In both cases the 'current' frame is that of the executing code.
- *
- * The 'before' param is true for the hook invocation before the execution
- * and false for the invocation after the code has run.
- *
- * The 'ok' param is significant only on the post execution invocation to
- * signify whether or not the code completed 'normally'.
- *
- * The 'closure' param is as passed to JS_SetExecuteHook or JS_SetCallHook
- * for the 'before'invocation, but is whatever value is returned from that
- * invocation for the 'after' invocation. Thus, the hook implementor *could*
- * allocate a structure in the 'before' invocation and return a pointer to that
- * structure. The pointer would then be handed to the hook for the 'after'
- * invocation. Alternately, the 'before' could just return the same value as
- * in 'closure' to cause the 'after' invocation to be called with the same
- * 'closure' value as the 'before'.
- *
- * Returning nullptr in the 'before' hook will cause the 'after' hook *not* to
- * be called.
- */
-typedef void *
-(* JSInterpreterHook)(JSContext *cx, JSAbstractFramePtr frame, bool isConstructing,
-                      bool before, bool *ok, void *closure);
-
 typedef bool
 (* JSDebugErrorHook)(JSContext *cx, const char *message, JSErrorReport *report,
                      void *closure);
 
 typedef struct JSDebugHooks {
-    JSInterruptHook     interruptHook;
-    void                *interruptHookData;
-    JSNewScriptHook     newScriptHook;
-    void                *newScriptHookData;
-    JSDestroyScriptHook destroyScriptHook;
-    void                *destroyScriptHookData;
     JSDebuggerHandler   debuggerHandler;
     void                *debuggerHandlerData;
-    JSSourceHandler     sourceHandler;
-    void                *sourceHandlerData;
-    JSInterpreterHook   executeHook;
-    void                *executeHookData;
-    JSInterpreterHook   callHook;
-    void                *callHookData;
-    JSThrowHook         throwHook;
-    void                *throwHookData;
-    JSDebugErrorHook    debugErrorHook;
-    void                *debugErrorHookData;
 } JSDebugHooks;
 
 /************************************************************************/
 
 extern JS_PUBLIC_API(bool)
 JS_SetDebuggerHandler(JSRuntime *rt, JSDebuggerHandler hook, void *closure);
 
-extern JS_PUBLIC_API(bool)
-JS_SetSourceHandler(JSRuntime *rt, JSSourceHandler handler, void *closure);
-
-extern JS_PUBLIC_API(bool)
-JS_SetExecuteHook(JSRuntime *rt, JSInterpreterHook hook, void *closure);
-
-extern JS_PUBLIC_API(bool)
-JS_SetCallHook(JSRuntime *rt, JSInterpreterHook hook, void *closure);
-
-extern JS_PUBLIC_API(bool)
-JS_SetThrowHook(JSRuntime *rt, JSThrowHook hook, void *closure);
-
-extern JS_PUBLIC_API(bool)
-JS_SetDebugErrorHook(JSRuntime *rt, JSDebugErrorHook hook, void *closure);
-
 /************************************************************************/
 
 extern JS_PUBLIC_API(const JSDebugHooks *)
 JS_GetGlobalDebugHooks(JSRuntime *rt);
 
 /**
  * Add various profiling-related functions as properties of the given object.
  */
--- a/js/src/builtin/Eval.cpp
+++ b/js/src/builtin/Eval.cpp
@@ -95,17 +95,17 @@ class EvalScriptGuard
     RootedLinearString lookupStr_;
 
   public:
     explicit EvalScriptGuard(JSContext *cx)
         : cx_(cx), script_(cx), lookup_(cx), lookupStr_(cx) {}
 
     ~EvalScriptGuard() {
         if (script_) {
-            CallDestroyScriptHook(cx_->runtime()->defaultFreeOp(), script_);
+            script_->clearTraps(cx_->runtime()->defaultFreeOp());
             script_->cacheForEval();
             EvalCacheEntry cacheEntry = {script_, lookup_.callerScript, lookup_.pc};
             lookup_.str = lookupStr_;
             if (lookup_.str && IsEvalCacheCandidate(script_))
                 cx_->runtime()->evalCache.relookupOrAdd(p_, lookup_, cacheEntry);
         }
     }
 
@@ -115,17 +115,16 @@ class EvalScriptGuard
         lookup_.str = str;
         lookup_.callerScript = callerScript;
         lookup_.version = cx_->findVersion();
         lookup_.pc = pc;
         p_ = cx_->runtime()->evalCache.lookupForAdd(lookup_);
         if (p_) {
             script_ = p_->script;
             cx_->runtime()->evalCache.remove(p_);
-            CallNewScriptHook(cx_, script_, NullPtr());
             script_->uncacheForEval();
         }
     }
 
     void setNewScript(JSScript *script) {
         // JSScript::initFromEmitter has already called js_CallNewScriptHook.
         JS_ASSERT(!script_ && script);
         script_ = script;
--- a/js/src/frontend/BytecodeCompiler.cpp
+++ b/js/src/frontend/BytecodeCompiler.cpp
@@ -142,19 +142,17 @@ MaybeCheckEvalFreeVariables(ExclusiveCon
 }
 
 static inline bool
 CanLazilyParse(ExclusiveContext *cx, const ReadOnlyCompileOptions &options)
 {
     return options.canLazilyParse &&
         options.compileAndGo &&
         !cx->compartment()->options().discardSource() &&
-        !options.sourceIsLazy &&
-        !(cx->compartment()->debugMode() &&
-          cx->compartment()->runtimeFromAnyThread()->debugHooks.newScriptHook);
+        !options.sourceIsLazy;
 }
 
 static void
 MarkFunctionsWithinEvalScript(JSScript *script)
 {
     // Mark top level functions in an eval script as being within an eval and,
     // if applicable, inside a with statement.
 
@@ -171,30 +169,16 @@ MarkFunctionsWithinEvalScript(JSScript *
             if (fun->hasScript())
                 fun->nonLazyScript()->setDirectlyInsideEval();
             else if (fun->isInterpretedLazy())
                 fun->lazyScript()->setDirectlyInsideEval();
         }
     }
 }
 
-void
-frontend::MaybeCallSourceHandler(JSContext *cx, const ReadOnlyCompileOptions &options,
-                                 SourceBufferHolder &srcBuf)
-{
-    JSSourceHandler listener = cx->runtime()->debugHooks.sourceHandler;
-    void *listenerData = cx->runtime()->debugHooks.sourceHandlerData;
-
-    if (listener) {
-        void *listenerTSData;
-        listener(options.filename(), options.lineno, srcBuf.get(), srcBuf.length(),
-                 &listenerTSData, listenerData);
-    }
-}
-
 ScriptSourceObject *
 frontend::CreateScriptSourceObject(ExclusiveContext *cx, const ReadOnlyCompileOptions &options)
 {
     ScriptSource *ss = cx->new_<ScriptSource>();
     if (!ss)
         return nullptr;
     ScriptSourceHolder ssHolder(ss);
 
@@ -237,19 +221,16 @@ frontend::CompileScript(ExclusiveContext
     if (cx->isJSContext())
         logger = TraceLoggerForMainThread(cx->asJSContext()->runtime());
     else
         logger = TraceLoggerForCurrentThread();
     uint32_t logId = js::TraceLogCreateTextId(logger, options);
     js::AutoTraceLog scriptLogger(logger, logId);
     js::AutoTraceLog typeLogger(logger, TraceLogger::ParserCompileScript);
 
-    if (cx->isJSContext())
-        MaybeCallSourceHandler(cx->asJSContext(), options, srcBuf);
-
     /*
      * The scripted callerFrame can only be given for compile-and-go scripts
      * and non-zero static level requires callerFrame.
      */
     JS_ASSERT_IF(evalCaller, options.compileAndGo);
     JS_ASSERT_IF(evalCaller, options.forEval);
     JS_ASSERT_IF(staticLevel != 0, evalCaller);
 
@@ -548,18 +529,16 @@ CompileFunctionBody(JSContext *cx, Mutab
     js::TraceLogger *logger = js::TraceLoggerForMainThread(cx->runtime());
     uint32_t logId = js::TraceLogCreateTextId(logger, options);
     js::AutoTraceLog scriptLogger(logger, logId);
     js::AutoTraceLog typeLogger(logger, TraceLogger::ParserCompileFunction);
 
     // FIXME: make Function pass in two strings and parse them as arguments and
     // ProgramElements respectively.
 
-    MaybeCallSourceHandler(cx, options, srcBuf);
-
     if (!CheckLength(cx, srcBuf))
         return false;
 
     RootedScriptSource sourceObject(cx, CreateScriptSourceObject(cx, options));
     if (!sourceObject)
         return false;
     ScriptSource *ss = sourceObject->source();
 
--- a/js/src/frontend/BytecodeCompiler.h
+++ b/js/src/frontend/BytecodeCompiler.h
@@ -38,24 +38,16 @@ bool
 CompileStarGeneratorBody(JSContext *cx, MutableHandleFunction fun,
                          const ReadOnlyCompileOptions &options,
                          const AutoNameVector &formals, JS::SourceBufferHolder &srcBuf);
 
 ScriptSourceObject *
 CreateScriptSourceObject(ExclusiveContext *cx, const ReadOnlyCompileOptions &options);
 
 /*
- * This should be called while still on the main thread if compilation will
- * occur on a worker thread.
- */
-void
-MaybeCallSourceHandler(JSContext *cx, const ReadOnlyCompileOptions &options,
-                       JS::SourceBufferHolder &srcBuf);
-
-/*
  * True if str consists of an IdentifierStart character, followed by one or
  * more IdentifierPart characters, i.e. it matches the IdentifierName production
  * in the language spec.
  *
  * This returns true even if str is a keyword like "if".
  *
  * Defined in TokenStream.cpp.
  */
--- a/js/src/frontend/BytecodeEmitter.cpp
+++ b/js/src/frontend/BytecodeEmitter.cpp
@@ -1998,18 +1998,16 @@ BytecodeEmitter::needsImplicitThis()
 void
 BytecodeEmitter::tellDebuggerAboutCompiledScript(ExclusiveContext *cx)
 {
     // Note: when parsing off thread the resulting scripts need to be handed to
     // the debugger after rejoining to the main thread.
     if (!cx->isJSContext())
         return;
 
-    RootedFunction function(cx, script->functionNonDelazifying());
-    CallNewScriptHook(cx->asJSContext(), script, function);
     // Lazy scripts are never top level (despite always being invoked with a
     // nullptr parent), and so the hook should never be fired.
     if (emitterMode != LazyFunction && !parent) {
         GlobalObject *compileAndGoGlobal = nullptr;
         if (script->compileAndGo())
             compileAndGoGlobal = &script->global();
         Debugger::onNewScript(cx->asJSContext(), script, compileAndGoGlobal);
     }
deleted file mode 100644
--- a/js/src/jit-test/tests/jaeger/bug563000/test-throwhook-1.js
+++ /dev/null
@@ -1,19 +0,0 @@
-// |jit-test| debug
-var result1 = "unset";
-var result2 = "failure";
-function main() {
-  result1 = "failure";
-  try {
-    throw "something";
-  } catch(e) {
-    result2 = "success";
-  }
-}
-function nop() { }
-
-setDebug(true);
-setThrowHook("result1 = 'success'; nop()");
-
-main();
-assertEq(result1, "success");
-assertEq(result2, "success");
deleted file mode 100644
--- a/js/src/jit-test/tests/jaeger/bug563000/test-throwhook-2.js
+++ /dev/null
@@ -1,14 +0,0 @@
-// |jit-test| debug
-function main() {
-  try {
-    throw "something";
-  } catch(e) {
-    return "failure";
-  }
-  return "unset";
-}
-
-setDebug(true);
-setThrowHook("'success'");
-
-assertEq(main(), "success");
--- a/js/src/jit/BaselineFrame.cpp
+++ b/js/src/jit/BaselineFrame.cpp
@@ -165,21 +165,16 @@ BaselineFrame::initForOsr(InterpreterFra
         evalScript_ = fp->script();
     }
 
     if (fp->script()->needsArgsObj() && fp->hasArgsObj()) {
         flags_ |= BaselineFrame::HAS_ARGS_OBJ;
         argsObj_ = &fp->argsObj();
     }
 
-    if (fp->hasHookData()) {
-        flags_ |= BaselineFrame::HAS_HOOK_DATA;
-        hookData_ = fp->hookData();
-    }
-
     if (fp->hasReturnValue())
         setReturnValue(fp->returnValue());
 
     // If the interpreter pushed an SPS frame when it entered the function, the
     // interpreter will pop it after the OSR trampoline returns.  In order for
     // the Baseline frame to have its SPS flag set, it must have its own SPS
     // frame, which the Baseline code will pop on return.  Note that the
     // profiler may have been enabled or disabled after the function was entered
--- a/js/src/jit/BaselineFrame.h
+++ b/js/src/jit/BaselineFrame.h
@@ -47,19 +47,16 @@ class BaselineFrame
         HAS_ARGS_OBJ     = 1 << 4,
 
         // See InterpreterFrame::PREV_UP_TO_DATE.
         PREV_UP_TO_DATE  = 1 << 5,
 
         // Eval frame, see the "eval frames" comment.
         EVAL             = 1 << 6,
 
-        // Frame has hookData_ set.
-        HAS_HOOK_DATA    = 1 << 7,
-
         // Frame has profiler entry pushed.
         HAS_PUSHED_SPS_FRAME = 1 << 8,
 
         // Frame has over-recursed on an early check.
         OVER_RECURSED    = 1 << 9,
 
         // Frame has a BaselineRecompileInfo stashed in the scratch value
         // slot. See PatchBaselineFramesForDebugMOde.
@@ -87,17 +84,17 @@ class BaselineFrame
         BaselineDebugModeOSRInfo *debugModeOSRInfo_;
     };
     uint32_t loReturnValue_;              // If HAS_RVAL, the frame's return value.
     uint32_t hiReturnValue_;
     uint32_t frameSize_;
     JSObject *scopeChain_;                // Scope chain (always initialized).
     JSScript *evalScript_;                // If isEvalFrame(), the current eval script.
     ArgumentsObject *argsObj_;            // If HAS_ARGS_OBJ, the arguments object.
-    void *hookData_;                      // If HAS_HOOK_DATA, debugger call hook data.
+    void *unused;                         // See static assertion re: sizeof, below.
     uint32_t unwoundScopeOverrideOffset_; // If HAS_UNWOUND_SCOPE_OVERRIDE_PC.
     uint32_t flags_;
 
   public:
     // Distance between the frame pointer and the frame header (return address).
     // This is the old frame pointer saved in the prologue.
     static const uint32_t FramePointerOffset = sizeof(void *);
 
@@ -279,29 +276,16 @@ class BaselineFrame
         flags_ |= PREV_UP_TO_DATE;
     }
 
     JSScript *evalScript() const {
         JS_ASSERT(isEvalFrame());
         return evalScript_;
     }
 
-    bool hasHookData() const {
-        return flags_ & HAS_HOOK_DATA;
-    }
-
-    void *maybeHookData() const {
-        return hasHookData() ? hookData_ : nullptr;
-    }
-
-    void setHookData(void *v) {
-        hookData_ = v;
-        flags_ |= HAS_HOOK_DATA;
-    }
-
     bool hasPushedSPSFrame() const {
         return flags_ & HAS_PUSHED_SPS_FRAME;
     }
 
     void setPushedSPSFrame() {
         flags_ |= HAS_PUSHED_SPS_FRAME;
     }
 
--- a/js/src/jit/BaselineJIT.cpp
+++ b/js/src/jit/BaselineJIT.cpp
@@ -77,22 +77,16 @@ CheckFrame(InterpreterFrame *fp)
         // Fall back to the interpreter to avoid running out of stack space.
         IonSpew(IonSpew_BaselineAbort, "Too many arguments (%u)", fp->numActualArgs());
         return false;
     }
 
     return true;
 }
 
-static bool
-IsJSDEnabled(JSContext *cx)
-{
-    return cx->compartment()->debugMode() && cx->runtime()->debugHooks.callHook;
-}
-
 static IonExecStatus
 EnterBaseline(JSContext *cx, EnterJitData &data)
 {
     if (data.osrFrame) {
         // Check for potential stack overflow before OSR-ing.
         uint8_t spDummy;
         uint32_t extra = BaselineFrame::Size() + (data.osrNumStackValues * sizeof(Value));
         uint8_t *checkSp = (&spDummy) - extra;
@@ -112,18 +106,16 @@ EnterBaseline(JSContext *cx, EnterJitDat
     data.result.setInt32(data.numActualArgs);
     {
         AssertCompartmentUnchanged pcc(cx);
         JitActivation activation(cx, data.constructing);
 
         if (data.osrFrame)
             data.osrFrame->setRunningInJit();
 
-        JS_ASSERT_IF(data.osrFrame, !IsJSDEnabled(cx));
-
         // Single transition point from Interpreter to Baseline.
         CALL_GENERATED_CODE(enter, data.jitcode, data.maxArgc, data.maxArgv, data.osrFrame, data.calleeToken,
                             data.scopeChain.get(), data.osrNumStackValues, data.result.address());
 
         if (data.osrFrame)
             data.osrFrame->clearRunningInJit();
     }
 
@@ -261,26 +253,24 @@ CanEnterBaselineJIT(JSContext *cx, Handl
         return Method_CantCompile;
 
     if (!cx->compartment()->ensureJitCompartmentExists(cx))
         return Method_Error;
 
     if (script->hasBaselineScript())
         return Method_Compiled;
 
-    // Check script use count. However, always eagerly compile scripts if JSD
-    // is enabled, so that we don't have to OSR and don't have to update the
-    // frame pointer stored in JSD's frames list.
+    // Check script use count.
     //
     // Also eagerly compile if we are in parallel warmup, the point of which
     // is to gather type information so that the script may be compiled for
     // parallel execution. We want to avoid the situation of OSRing during
     // warmup and only gathering type information for the loop, and not the
     // rest of the function.
-    if (IsJSDEnabled(cx) || cx->runtime()->forkJoinWarmup > 0) {
+    if (cx->runtime()->forkJoinWarmup > 0) {
         if (osr)
             return Method_Skipped;
     } else if (script->incUseCount() <= js_JitOptions.baselineUsesBeforeCompile) {
         return Method_Skipped;
     }
 
     if (script->isCallsiteClone()) {
         // Ensure the original function is compiled too, so that bailouts from
--- a/js/src/jit/VMFunctions.cpp
+++ b/js/src/jit/VMFunctions.cpp
@@ -883,24 +883,19 @@ HandleDebugTrap(JSContext *cx, BaselineF
     RootedScript script(cx, frame->script());
     jsbytecode *pc = script->baselineScript()->icEntryFromReturnAddress(retAddr).pc(script);
 
     JS_ASSERT(cx->compartment()->debugMode());
     JS_ASSERT(script->stepModeEnabled() || script->hasBreakpointsAt(pc));
 
     RootedValue rval(cx);
     JSTrapStatus status = JSTRAP_CONTINUE;
-    JSInterruptHook hook = cx->runtime()->debugHooks.interruptHook;
 
-    if (hook || script->stepModeEnabled()) {
-        if (hook)
-            status = hook(cx, script, pc, rval.address(), cx->runtime()->debugHooks.interruptHookData);
-        if (status == JSTRAP_CONTINUE && script->stepModeEnabled())
-            status = Debugger::onSingleStep(cx, &rval);
-    }
+    if (script->stepModeEnabled())
+        status = Debugger::onSingleStep(cx, &rval);
 
     if (status == JSTRAP_CONTINUE && script->hasBreakpointsAt(pc))
         status = Debugger::onTrap(cx, &rval);
 
     switch (status) {
       case JSTRAP_CONTINUE:
         break;
 
--- a/js/src/jsapi-tests/testDebugger.cpp
+++ b/js/src/jsapi-tests/testDebugger.cpp
@@ -7,152 +7,16 @@
 
 #include "jscntxt.h"
 
 #include "js/OldDebugAPI.h"
 #include "jsapi-tests/tests.h"
 
 using namespace js;
 
-static int callCounts[2] = {0, 0};
-
-static void *
-callCountHook(JSContext *cx, JSAbstractFramePtr frame, bool isConstructing, bool before,
-              bool *ok, void *closure)
-{
-    callCounts[before]++;
-
-    JS::RootedValue thisv(cx);
-    frame.getThisValue(cx, &thisv); // assert if fp is incomplete
-
-    return cx;  // any non-null value causes the hook to be called again after
-}
-
-BEGIN_TEST(testDebugger_bug519719)
-{
-    CHECK(JS_SetDebugMode(cx, true));
-    JS_SetCallHook(rt, callCountHook, nullptr);
-    EXEC("function call(fn) { fn(0); }\n"
-         "function f(g) { for (var i = 0; i < 9; i++) call(g); }\n"
-         "f(Math.sin);\n"    // record loop, starting in f
-         "f(Math.cos);\n");  // side exit in f -> call
-    CHECK_EQUAL(callCounts[0], 20);
-    CHECK_EQUAL(callCounts[1], 20);
-    return true;
-}
-END_TEST(testDebugger_bug519719)
-
-static void *
-nonStrictThisHook(JSContext *cx, JSAbstractFramePtr frame, bool isConstructing, bool before,
-                  bool *ok, void *closure)
-{
-    if (before) {
-        bool *allWrapped = (bool *) closure;
-        JS::RootedValue thisv(cx);
-        frame.getThisValue(cx, &thisv);
-        *allWrapped = *allWrapped && !thisv.isPrimitive();
-    }
-    return nullptr;
-}
-
-BEGIN_TEST(testDebugger_getThisNonStrict)
-{
-    bool allWrapped = true;
-    CHECK(JS_SetDebugMode(cx, true));
-    JS_SetCallHook(rt, nonStrictThisHook, (void *) &allWrapped);
-    EXEC("function nonstrict() { }\n"
-         "Boolean.prototype.nonstrict = nonstrict;\n"
-         "String.prototype.nonstrict = nonstrict;\n"
-         "Number.prototype.nonstrict = nonstrict;\n"
-         "Object.prototype.nonstrict = nonstrict;\n"
-         "nonstrict.call(true);\n"
-         "true.nonstrict();\n"
-         "nonstrict.call('');\n"
-         "''.nonstrict();\n"
-         "nonstrict.call(42);\n"
-         "(42).nonstrict();\n"
-         // The below don't really get 'wrapped', but it's okay.
-         "nonstrict.call(undefined);\n"
-         "nonstrict.call(null);\n"
-         "nonstrict.call({});\n"
-         "({}).nonstrict();\n");
-    CHECK(allWrapped);
-    return true;
-}
-END_TEST(testDebugger_getThisNonStrict)
-
-static void *
-strictThisHook(JSContext *cx, JSAbstractFramePtr frame, bool isConstructing, bool before,
-               bool *ok, void *closure)
-{
-    if (before) {
-        bool *anyWrapped = (bool *) closure;
-        JS::RootedValue thisv(cx);
-        frame.getThisValue(cx, &thisv);
-        *anyWrapped = *anyWrapped || !thisv.isPrimitive();
-    }
-    return nullptr;
-}
-
-BEGIN_TEST(testDebugger_getThisStrict)
-{
-    bool anyWrapped = false;
-    CHECK(JS_SetDebugMode(cx, true));
-    JS_SetCallHook(rt, strictThisHook, (void *) &anyWrapped);
-    EXEC("function strict() { 'use strict'; }\n"
-         "Boolean.prototype.strict = strict;\n"
-         "String.prototype.strict = strict;\n"
-         "Number.prototype.strict = strict;\n"
-         "strict.call(true);\n"
-         "true.strict();\n"
-         "strict.call('');\n"
-         "''.strict();\n"
-         "strict.call(42);\n"
-         "(42).strict();\n"
-         "strict.call(undefined);\n"
-         "strict.call(null);\n");
-    CHECK(!anyWrapped);
-    return true;
-}
-END_TEST(testDebugger_getThisStrict)
-
-static bool calledThrowHook = false;
-
-static JSTrapStatus
-ThrowHook(JSContext *cx, JSScript *, jsbytecode *, jsval *rval, void *closure)
-{
-    JS_ASSERT(!closure);
-    calledThrowHook = true;
-
-    JS::RootedObject global(cx, JS::CurrentGlobalOrNull(cx));
-
-    char text[] = "new Error()";
-    JS::RootedValue _(cx);
-    JS_EvaluateScript(cx, global, text, strlen(text), "", 0, &_);
-
-    return JSTRAP_CONTINUE;
-}
-
-BEGIN_TEST(testDebugger_throwHook)
-{
-    CHECK(JS_SetDebugMode(cx, true));
-    CHECK(JS_SetThrowHook(rt, ThrowHook, nullptr));
-    EXEC("function foo() { throw 3 };\n"
-         "for (var i = 0; i < 10; ++i) { \n"
-         "  var x = {}\n"
-         "  try {\n"
-         "    foo(); \n"
-         "  } catch(e) {}\n"
-         "}\n");
-    CHECK(calledThrowHook);
-    CHECK(JS_SetThrowHook(rt, nullptr, nullptr));
-    return true;
-}
-END_TEST(testDebugger_throwHook)
-
 BEGIN_TEST(testDebugger_debuggerObjectVsDebugMode)
 {
     CHECK(JS_DefineDebuggerObject(cx, global));
     JS::RootedObject debuggee(cx, JS_NewGlobalObject(cx, getGlobalClass(), nullptr, JS::FireOnNewGlobalHook));
     CHECK(debuggee);
 
     {
         JSAutoCompartment ae(cx, debuggee);
@@ -232,43 +96,8 @@ bool testIndirectEval(JS::HandleObject s
     }
 
     JS::RootedValue hitsv(cx);
     EVAL("hits", &hitsv);
     CHECK_SAME(hitsv, INT_TO_JSVAL(1));
     return true;
 }
 END_TEST(testDebugger_newScriptHook)
-
-BEGIN_TEST(testDebugger_singleStepThrow)
-    {
-        CHECK(JS_SetDebugModeForCompartment(cx, cx->compartment(), true));
-        CHECK(JS_SetInterrupt(rt, onStep, nullptr));
-
-        CHECK(JS_DefineFunction(cx, global, "setStepMode", setStepMode, 0, 0));
-        EXEC("var e;\n"
-             "setStepMode();\n"
-             "function f() { throw 0; }\n"
-             "try { f(); }\n"
-             "catch (x) { e = x; }\n");
-        return true;
-    }
-
-    static bool
-    setStepMode(JSContext *cx, unsigned argc, jsval *vp)
-    {
-        CallArgs args = CallArgsFromVp(argc, vp);
-
-        NonBuiltinScriptFrameIter iter(cx);
-        JS::RootedScript script(cx, iter.script());
-        if (!JS_SetSingleStepMode(cx, script, true))
-            return false;
-
-        args.rval().set(UndefinedValue());
-        return true;
-    }
-
-    static JSTrapStatus
-    onStep(JSContext *cx, JSScript *script, jsbytecode *pc, jsval *rval, void *closure)
-    {
-        return JSTRAP_CONTINUE;
-    }
-END_TEST(testDebugger_singleStepThrow)
--- a/js/src/jsapi-tests/testSourcePolicy.cpp
+++ b/js/src/jsapi-tests/testSourcePolicy.cpp
@@ -20,31 +20,8 @@ BEGIN_TEST(testBug795104)
     JS::RootedFunction fun(cx);
     CHECK(JS::CompileFunction(cx, global, opts, "f", 0, nullptr, s, strLen, &fun));
     CHECK(fun);
     JS_free(cx, s);
 
     return true;
 }
 END_TEST(testBug795104)
-
-static const char *const simpleSource = "var x = 4;";
-
-BEGIN_TEST(testScriptSourceReentrant)
-{
-    JS::CompileOptions opts(cx);
-    bool match = false;
-    JS_SetNewScriptHook(rt, NewScriptHook, &match);
-    CHECK(JS::Evaluate(cx, global, opts, simpleSource, strlen(simpleSource)));
-    CHECK(match);
-    JS_SetNewScriptHook(rt, nullptr, nullptr);
-
-    return true;
-}
-
-static void
-NewScriptHook(JSContext *cx, const char *fn, unsigned lineno,
-              JSScript *script, JSFunction *fun, void *data)
-{
-    if (!JS_StringEqualsAscii(cx, script->sourceData(cx), simpleSource, (bool *)data))
-        *((bool *)data) = false;
-}
-END_TEST(testScriptSourceReentrant)
--- a/js/src/jscntxt.cpp
+++ b/js/src/jscntxt.cpp
@@ -298,37 +298,20 @@ ReportError(JSContext *cx, const char *m
     if ((!callback || callback == js_GetErrorMessage) &&
         reportp->errorNumber == JSMSG_UNCAUGHT_EXCEPTION)
     {
         reportp->flags |= JSREPORT_EXCEPTION;
     }
 
     /*
      * Call the error reporter only if an exception wasn't raised.
-     *
-     * If an exception was raised, then we call the debugErrorHook
-     * (if present) to give it a chance to see the error before it
-     * propagates out of scope.  This is needed for compatibility
-     * with the old scheme.
      */
     if (!JS_IsRunning(cx) || !js_ErrorToException(cx, message, reportp, callback, userRef)) {
         if (message)
             CallErrorReporter(cx, message, reportp);
-    } else if (JSDebugErrorHook hook = cx->runtime()->debugHooks.debugErrorHook) {
-        /*
-         * If we've already chewed up all the C stack, don't call into the
-         * error reporter since this may trigger an infinite recursion where
-         * the reporter triggers an over-recursion.
-         */
-        int stackDummy;
-        if (!JS_CHECK_STACK_SIZE(GetNativeStackLimit(cx), &stackDummy))
-            return;
-
-        if (cx->errorReporter)
-            hook(cx, message, reportp, cx->runtime()->debugHooks.debugErrorHookData);
     }
 }
 
 /*
  * The given JSErrorReport object have been zeroed and must not outlive
  * cx->fp() (otherwise report->originPrincipals may become invalid).
  */
 static void
@@ -897,24 +880,16 @@ js_ReportErrorNumberUCArray(JSContext *c
 }
 
 void
 js::CallErrorReporter(JSContext *cx, const char *message, JSErrorReport *reportp)
 {
     JS_ASSERT(message);
     JS_ASSERT(reportp);
 
-    // If debugErrorHook is present, give it a chance to veto sending the error
-    // on to the regular ErrorReporter.
-    if (cx->errorReporter) {
-        JSDebugErrorHook hook = cx->runtime()->debugHooks.debugErrorHook;
-        if (hook && !hook(cx, message, reportp, cx->runtime()->debugHooks.debugErrorHookData))
-            return;
-    }
-
     if (JSErrorReporter onError = cx->errorReporter)
         onError(cx, message, reportp);
 }
 
 void
 js_ReportIsNotDefined(JSContext *cx, const char *name)
 {
     JS_ReportErrorNumber(cx, js_GetErrorMessage, nullptr, JSMSG_NOT_DEFINED, name);
--- a/js/src/jsfun.cpp
+++ b/js/src/jsfun.cpp
@@ -510,17 +510,16 @@ js::CloneFunctionAndScript(JSContext *cx
     clone->setFlags(srcFun->flags());
     clone->initAtom(srcFun->displayAtom());
     clone->initScript(clonedScript);
     clonedScript->setFunction(clone);
     if (!JSFunction::setTypeForScriptedFunction(cx, clone))
         return nullptr;
 
     RootedScript cloneScript(cx, clone->nonLazyScript());
-    CallNewScriptHook(cx, cloneScript, clone);
     return clone;
 }
 
 /*
  * [[HasInstance]] internal method for Function objects: fetch the .prototype
  * property of its 'this' parameter, and walks the prototype chain of v (only
  * if v is an object) returning true if .prototype is found.
  */
@@ -696,30 +695,16 @@ CreateFunctionPrototype(JSContext *cx, J
      * CloneFunctionObject.
      */
     if (!JSObject::setNewTypeUnknown(cx, &JSFunction::class_, functionProto))
         return nullptr;
 
     return functionProto;
 }
 
-static bool
-FinishFunctionClassInit(JSContext *cx, JS::HandleObject ctor, JS::HandleObject proto)
-{
-    /*
-     * Notify any debuggers about the creation of the script for
-     * |Function.prototype| -- after all initialization, for simplicity.
-     */
-    RootedFunction functionProto(cx, &proto->as<JSFunction>());
-    RootedScript functionProtoScript(cx, functionProto->nonLazyScript());
-    CallNewScriptHook(cx, functionProtoScript, functionProto);
-    return true;
-}
-
-
 const Class JSFunction::class_ = {
     js_Function_str,
     JSCLASS_NEW_RESOLVE | JSCLASS_IMPLEMENTS_BARRIERS |
     JSCLASS_HAS_CACHED_PROTO(JSProto_Function),
     JS_PropertyStub,         /* addProperty */
     JS_DeletePropertyStub,   /* delProperty */
     JS_PropertyStub,         /* getProperty */
     JS_StrictPropertyStub,   /* setProperty */
@@ -730,19 +715,17 @@ const Class JSFunction::class_ = {
     nullptr,                 /* call        */
     fun_hasInstance,
     nullptr,                 /* construct   */
     fun_trace,
     {
         CreateFunctionConstructor,
         CreateFunctionPrototype,
         nullptr,
-        function_methods,
-        nullptr,
-        FinishFunctionClassInit
+        function_methods
     }
 };
 
 const Class* const js::FunctionClassPtr = &JSFunction::class_;
 
 /* Find the body of a function (not including braces). */
 bool
 js::FindBody(JSContext *cx, HandleFunction fun, HandleLinearString src, size_t *bodyStart,
@@ -1264,18 +1247,16 @@ JSFunction::createScriptForLazilyInterpr
 
             clonedScript->setSourceObject(lazy->sourceObject());
 
             fun->initAtom(script->functionNonDelazifying()->displayAtom());
             clonedScript->setFunction(fun);
 
             fun->setUnlazifiedScript(clonedScript);
 
-            CallNewScriptHook(cx, clonedScript, fun);
-
             if (!lazy->maybeScript())
                 lazy->initScript(clonedScript);
             return true;
         }
 
         JS_ASSERT(lazy->source()->hasSourceData());
 
         // Parse and compile the script from source.
--- a/js/src/jsscript.cpp
+++ b/js/src/jsscript.cpp
@@ -1012,17 +1012,16 @@ js::XDRScript(XDRState<mode> *xdr, Handl
         if (mode == XDR_DECODE)
             script->setLazyScript(lazy);
     }
 
     if (mode == XDR_DECODE) {
         scriptp.set(script);
 
         /* see BytecodeEmitter::tellDebuggerAboutCompiledScript */
-        CallNewScriptHook(cx, script, fun);
         if (!fun) {
             RootedGlobalObject global(cx, script->compileAndGo() ? &script->global() : nullptr);
             Debugger::onNewScript(cx, script, global);
         }
     }
 
     return true;
 }
@@ -2617,50 +2616,24 @@ JSScript::numNotes()
 
 js::GlobalObject&
 JSScript::uninlinedGlobal() const
 {
     return global();
 }
 
 void
-js::CallNewScriptHook(JSContext *cx, HandleScript script, HandleFunction fun)
-{
-    if (script->selfHosted())
-        return;
-
-    JS_ASSERT(!script->isActiveEval());
-    if (JSNewScriptHook hook = cx->runtime()->debugHooks.newScriptHook) {
-        AutoKeepAtoms keepAtoms(cx->perThreadData);
-        hook(cx, script->filename(), script->lineno(), script, fun,
-             cx->runtime()->debugHooks.newScriptHookData);
-    }
-}
-
-void
-js::CallDestroyScriptHook(FreeOp *fop, JSScript *script)
-{
-    if (script->selfHosted())
-        return;
-
-    // The hook will only call into JS if a GC is not running.
-    if (JSDestroyScriptHook hook = fop->runtime()->debugHooks.destroyScriptHook)
-        hook(fop, script, fop->runtime()->debugHooks.destroyScriptHookData);
-    script->clearTraps(fop);
-}
-
-void
 JSScript::finalize(FreeOp *fop)
 {
     // NOTE: this JSScript may be partially initialized at this point.  E.g. we
     // may have created it and partially initialized it with
     // JSScript::Create(), but not yet finished initializing it with
     // fullyInitFromEmitter() or fullyInitTrivial().
 
-    CallDestroyScriptHook(fop, this);
+    clearTraps(fop);
     fop->runtime()->spsProfiler.onScriptFinalized(this);
 
     if (types)
         types->destroy();
 
 #ifdef JS_ION
     jit::DestroyIonScripts(fop, this);
 #endif
@@ -3132,17 +3105,16 @@ js::CloneFunctionScript(JSContext *cx, H
     JSScript *cscript = CloneScript(cx, scope, clone, script, newKind);
     if (!cscript)
         return false;
 
     clone->setScript(cscript);
     cscript->setFunction(clone);
 
     script = clone->nonLazyScript();
-    CallNewScriptHook(cx, script, clone);
     RootedGlobalObject global(cx, script->compileAndGo() ? &script->global() : nullptr);
     Debugger::onNewScript(cx, script, global);
 
     return true;
 }
 
 DebugScript *
 JSScript::debugScript()
--- a/js/src/jsscript.h
+++ b/js/src/jsscript.h
@@ -1908,29 +1908,16 @@ class LazyScript : public gc::BarrieredC
     uint64_t packedFields() const {
         return packedFields_;
     }
 };
 
 /* If this fails, add/remove padding within LazyScript. */
 JS_STATIC_ASSERT(sizeof(LazyScript) % js::gc::CellSize == 0);
 
-/*
- * New-script-hook calling is factored from JSScript::fullyInitFromEmitter() so
- * that it and callers of XDRScript() can share this code.  In the case of
- * callers of XDRScript(), the hook should be invoked only after successful
- * decode of any owning function (the fun parameter) or script object (null
- * fun).
- */
-extern void
-CallNewScriptHook(JSContext *cx, JS::HandleScript script, JS::HandleFunction fun);
-
-extern void
-CallDestroyScriptHook(FreeOp *fop, JSScript *script);
-
 struct SharedScriptData
 {
     uint32_t length;
     uint32_t natoms;
     bool marked;
     jsbytecode data[1];
 
     static SharedScriptData *new_(ExclusiveContext *cx, uint32_t codeLength,
--- a/js/src/shell/js.cpp
+++ b/js/src/shell/js.cpp
@@ -1882,36 +1882,16 @@ SetDebuggerHandler(JSContext *cx, unsign
         return false;
 
     JS_SetDebuggerHandler(cx->runtime(), DebuggerAndThrowHandler, str);
     args.rval().setUndefined();
     return true;
 }
 
 static bool
-SetThrowHook(JSContext *cx, unsigned argc, jsval *vp)
-{
-    CallArgs args = CallArgsFromVp(argc, vp);
-    JSString *str;
-    if (args.length() == 0) {
-        JS_ReportErrorNumber(cx, my_GetErrorMessage, nullptr,
-                             JSSMSG_NOT_ENOUGH_ARGS, "setThrowHook");
-        return false;
-    }
-
-    str = JS::ToString(cx, args[0]);
-    if (!str)
-        return false;
-
-    JS_SetThrowHook(cx->runtime(), DebuggerAndThrowHandler, str);
-    args.rval().setUndefined();
-    return true;
-}
-
-static bool
 LineToPC(JSContext *cx, unsigned argc, jsval *vp)
 {
     CallArgs args = CallArgsFromVp(argc, vp);
 
     if (args.length() == 0) {
         JS_ReportErrorNumber(cx, my_GetErrorMessage, nullptr, JSSMSG_LINE2PC_USAGE);
         return false;
     }
@@ -4880,20 +4860,16 @@ static const JSFunctionSpecWithHelp fuzz
 "pc2line(fun[, pc])",
 "  Map PC to line number."),
 
     JS_FN_HELP("redirect", RedirectOutput, 2, 0,
 "redirect(stdoutFilename[, stderrFilename])",
 "  Redirect stdout and/or stderr to the named file. Pass undefined to avoid\n"
 "   redirecting. Filenames are relative to the current working directory."),
 
-    JS_FN_HELP("setThrowHook", SetThrowHook, 1, 0,
-"setThrowHook(f)",
-"  Set throw hook to f."),
-
     JS_FN_HELP("system", System, 1, 0,
 "system(command)",
 "  Execute command on the current host, returning result code."),
 
     JS_FN_HELP("nestedShell", NestedShell, 0, 0,
 "nestedShell(shellArgs...)",
 "  Execute the given code in a new JS shell process, passing this nested shell\n"
 "  the arguments passed to nestedShell. argv[0] of the nested shell will be argv[0]\n"
--- a/js/src/vm/HelperThreads.cpp
+++ b/js/src/vm/HelperThreads.cpp
@@ -293,19 +293,16 @@ bool
 js::StartOffThreadParseScript(JSContext *cx, const ReadOnlyCompileOptions &options,
                               const jschar *chars, size_t length,
                               JS::OffThreadCompileCallback callback, void *callbackData)
 {
     // Suppress GC so that calls below do not trigger a new incremental GC
     // which could require barriers on the atoms compartment.
     gc::AutoSuppressGC suppress(cx);
 
-    SourceBufferHolder srcBuf(chars, length, SourceBufferHolder::NoOwnership);
-    frontend::MaybeCallSourceHandler(cx, options, srcBuf);
-
     EnsureHelperThreadsInitialized(cx);
 
     JS::CompartmentOptions compartmentOptions(cx->compartment()->options());
     compartmentOptions.setZone(JS::FreshZone);
     compartmentOptions.setInvisibleToDebugger(true);
     compartmentOptions.setMergeable(true);
 
     // Don't falsely inherit the host's global trace hook.
@@ -696,43 +693,16 @@ GlobalHelperThreadState::canStartCompres
 }
 
 bool
 GlobalHelperThreadState::canStartGCHelperTask()
 {
     return !gcHelperWorklist().empty();
 }
 
-static void
-CallNewScriptHookForAllScripts(JSContext *cx, HandleScript script)
-{
-    // We should never hit this, since nested scripts are also constructed via
-    // BytecodeEmitter instances on the stack.
-    JS_CHECK_RECURSION(cx, return);
-
-    // Recurse to any nested scripts.
-    if (script->hasObjects()) {
-        ObjectArray *objects = script->objects();
-        for (size_t i = 0; i < objects->length; i++) {
-            JSObject *obj = objects->vector[i];
-            if (obj->is<JSFunction>()) {
-                JSFunction *fun = &obj->as<JSFunction>();
-                if (fun->hasScript()) {
-                    RootedScript nested(cx, fun->nonLazyScript());
-                    CallNewScriptHookForAllScripts(cx, nested);
-                }
-            }
-        }
-    }
-
-    // The global new script hook is called on every script that was compiled.
-    RootedFunction function(cx, script->functionNonDelazifying());
-    CallNewScriptHook(cx, script, function);
-}
-
 JSScript *
 GlobalHelperThreadState::finishParseTask(JSContext *maybecx, JSRuntime *rt, void *token)
 {
     ScopedJSDeletePtr<ParseTask> parseTask;
 
     // The token is a ParseTask* which should be in the finished list.
     // Find and remove its entry.
     {
@@ -813,19 +783,16 @@ GlobalHelperThreadState::finishParseTask
 
     if (script) {
         // The Debugger only needs to be told about the topmost script that was compiled.
         GlobalObject *compileAndGoGlobal = nullptr;
         if (script->compileAndGo())
             compileAndGoGlobal = &script->global();
         Debugger::onNewScript(cx, script, compileAndGoGlobal);
 
-        // The NewScript hook needs to be called for all compiled scripts.
-        CallNewScriptHookForAllScripts(cx, script);
-
         // Update the compressed source table with the result. This is normally
         // called by setCompressedSource when compilation occurs on the main thread.
         if (script->scriptSource()->hasCompressedSource())
             script->scriptSource()->updateCompressedSourceSet(rt);
     }
 
     return script;
 }
--- a/js/src/vm/Interpreter.cpp
+++ b/js/src/vm/Interpreter.cpp
@@ -1500,17 +1500,17 @@ Interpret(JSContext *cx, RunState &state
           case JSTRAP_THROW:
           case JSTRAP_ERROR:
             goto error;
           default:
             MOZ_CRASH("bad ScriptDebugPrologue status");
         }
     }
 
-    if (cx->runtime()->profilingScripts || cx->runtime()->debugHooks.interruptHook)
+    if (cx->runtime()->profilingScripts)
         activation.enableInterruptsUnconditionally();
 
     // Enter the interpreter loop starting at the current pc.
     ADVANCE_AND_DISPATCH(0);
 
 INTERPRETER_LOOP() {
 
 CASE(EnableInterruptsPseudoOpcode)
@@ -1526,25 +1526,20 @@ CASE(EnableInterruptsPseudoOpcode)
 
     if (script->hasScriptCounts()) {
         PCCounts counts = script->getPCCounts(REGS.pc);
         counts.get(PCCounts::BASE_INTERP)++;
         moreInterrupts = true;
     }
 
     if (cx->compartment()->debugMode()) {
-        JSInterruptHook hook = cx->runtime()->debugHooks.interruptHook;
-        if (hook || script->stepModeEnabled()) {
+        if (script->stepModeEnabled()) {
             RootedValue rval(cx);
             JSTrapStatus status = JSTRAP_CONTINUE;
-            if (hook)
-                status = hook(cx, script, REGS.pc, rval.address(),
-                              cx->runtime()->debugHooks.interruptHookData);
-            if (status == JSTRAP_CONTINUE && script->stepModeEnabled())
-                status = Debugger::onSingleStep(cx, &rval);
+            status = Debugger::onSingleStep(cx, &rval);
             switch (status) {
               case JSTRAP_ERROR:
                 goto error;
               case JSTRAP_CONTINUE:
                 break;
               case JSTRAP_RETURN:
                 REGS.fp()->setReturnValue(rval);
                 ForcedReturn(cx, REGS);
--- a/js/src/vm/OldDebugAPI.cpp
+++ b/js/src/vm/OldDebugAPI.cpp
@@ -54,42 +54,21 @@ JS_SetDebugMode(JSContext *cx, bool debu
 }
 
 JS_PUBLIC_API(void)
 JS_SetRuntimeDebugMode(JSRuntime *rt, bool debug)
 {
     rt->debugMode = !!debug;
 }
 
-static bool
-IsTopFrameConstructing(JSContext *cx, AbstractFramePtr frame)
-{
-    ScriptFrameIter iter(cx);
-    JS_ASSERT(iter.abstractFramePtr() == frame);
-    return iter.isConstructing();
-}
-
 JSTrapStatus
 js::ScriptDebugPrologue(JSContext *cx, AbstractFramePtr frame, jsbytecode *pc)
 {
     JS_ASSERT_IF(frame.isInterpreterFrame(), frame.asInterpreterFrame() == cx->interpreterFrame());
 
-    if (!frame.script()->selfHosted()) {
-        JSAbstractFramePtr jsframe(frame.raw(), pc);
-        if (frame.isFramePushedByExecute()) {
-            if (JSInterpreterHook hook = cx->runtime()->debugHooks.executeHook)
-                frame.setHookData(hook(cx, jsframe, IsTopFrameConstructing(cx, frame),
-                                       true, 0, cx->runtime()->debugHooks.executeHookData));
-        } else {
-            if (JSInterpreterHook hook = cx->runtime()->debugHooks.callHook)
-                frame.setHookData(hook(cx, jsframe, IsTopFrameConstructing(cx, frame),
-                                       true, 0, cx->runtime()->debugHooks.callHookData));
-        }
-    }
-
     RootedValue rval(cx);
     JSTrapStatus status = Debugger::onEnterFrame(cx, frame, &rval);
     switch (status) {
       case JSTRAP_CONTINUE:
         break;
       case JSTRAP_THROW:
         cx->setPendingException(rval);
         break;
@@ -107,48 +86,30 @@ js::ScriptDebugPrologue(JSContext *cx, A
 
 bool
 js::ScriptDebugEpilogue(JSContext *cx, AbstractFramePtr frame, jsbytecode *pc, bool okArg)
 {
     JS_ASSERT_IF(frame.isInterpreterFrame(), frame.asInterpreterFrame() == cx->interpreterFrame());
 
     bool ok = okArg;
 
-    // We don't add hook data for self-hosted scripts, so we don't need to check for them, here.
-    if (void *hookData = frame.maybeHookData()) {
-        JSAbstractFramePtr jsframe(frame.raw(), pc);
-        if (frame.isFramePushedByExecute()) {
-            if (JSInterpreterHook hook = cx->runtime()->debugHooks.executeHook)
-                hook(cx, jsframe, IsTopFrameConstructing(cx, frame), false, &ok, hookData);
-        } else {
-            if (JSInterpreterHook hook = cx->runtime()->debugHooks.callHook)
-                hook(cx, jsframe, IsTopFrameConstructing(cx, frame), false, &ok, hookData);
-        }
-    }
-
     return Debugger::onLeaveFrame(cx, frame, ok);
 }
 
 JSTrapStatus
 js::DebugExceptionUnwind(JSContext *cx, AbstractFramePtr frame, jsbytecode *pc)
 {
     JS_ASSERT(cx->compartment()->debugMode());
 
-    if (!cx->runtime()->debugHooks.throwHook && cx->compartment()->getDebuggees().empty())
+    if (cx->compartment()->getDebuggees().empty())
         return JSTRAP_CONTINUE;
 
     /* Call debugger throw hook if set. */
     RootedValue rval(cx);
     JSTrapStatus status = Debugger::onExceptionUnwind(cx, &rval);
-    if (status == JSTRAP_CONTINUE) {
-        if (JSThrowHook handler = cx->runtime()->debugHooks.throwHook) {
-            RootedScript script(cx, frame.script());
-            status = handler(cx, script, pc, rval.address(), cx->runtime()->debugHooks.throwHookData);
-        }
-    }
 
     switch (status) {
       case JSTRAP_ERROR:
         cx->clearPendingException();
         break;
 
       case JSTRAP_RETURN:
         cx->clearPendingException();
@@ -258,42 +219,16 @@ JS_ClearScriptTraps(JSRuntime *rt, JSScr
 }
 
 JS_PUBLIC_API(void)
 JS_ClearAllTrapsForCompartment(JSContext *cx)
 {
     cx->compartment()->clearTraps(cx->runtime()->defaultFreeOp());
 }
 
-JS_PUBLIC_API(bool)
-JS_SetInterrupt(JSRuntime *rt, JSInterruptHook hook, void *closure)
-{
-    rt->debugHooks.interruptHook = hook;
-    rt->debugHooks.interruptHookData = closure;
-
-    for (ActivationIterator iter(rt); !iter.done(); ++iter) {
-        if (iter->isInterpreter())
-            iter->asInterpreter()->enableInterruptsUnconditionally();
-    }
-
-    return true;
-}
-
-JS_PUBLIC_API(bool)
-JS_ClearInterrupt(JSRuntime *rt, JSInterruptHook *hoop, void **closurep)
-{
-    if (hoop)
-        *hoop = rt->debugHooks.interruptHook;
-    if (closurep)
-        *closurep = rt->debugHooks.interruptHookData;
-    rt->debugHooks.interruptHook = 0;
-    rt->debugHooks.interruptHookData = 0;
-    return true;
-}
-
 /************************************************************************/
 
 JS_PUBLIC_API(bool)
 JS_SetWatchPoint(JSContext *cx, HandleObject origobj, HandleId id,
                  JSWatchPointHandler handler, HandleObject closure)
 {
     assertSameCompartment(cx, origobj);
 
@@ -559,33 +494,16 @@ JS_GetScriptVersion(JSContext *cx, JSScr
 JS_PUBLIC_API(bool)
 JS_GetScriptIsSelfHosted(JSScript *script)
 {
     return script->selfHosted();
 }
 
 /***************************************************************************/
 
-JS_PUBLIC_API(void)
-JS_SetNewScriptHook(JSRuntime *rt, JSNewScriptHook hook, void *callerdata)
-{
-    rt->debugHooks.newScriptHook = hook;
-    rt->debugHooks.newScriptHookData = callerdata;
-}
-
-JS_PUBLIC_API(void)
-JS_SetDestroyScriptHook(JSRuntime *rt, JSDestroyScriptHook hook,
-                        void *callerdata)
-{
-    rt->debugHooks.destroyScriptHook = hook;
-    rt->debugHooks.destroyScriptHookData = callerdata;
-}
-
-/***************************************************************************/
-
 /* This all should be reworked to avoid requiring JSScopeProperty types. */
 
 static bool
 GetPropertyDesc(JSContext *cx, JSObject *obj_, HandleShape shape, JSPropertyDesc *pd)
 {
     assertSameCompartment(cx, obj_);
     pd->id = IdToValue(shape->propid());
 
@@ -737,56 +655,16 @@ JS_PutPropertyDescArray(JSContext *cx, J
 JS_PUBLIC_API(bool)
 JS_SetDebuggerHandler(JSRuntime *rt, JSDebuggerHandler handler, void *closure)
 {
     rt->debugHooks.debuggerHandler = handler;
     rt->debugHooks.debuggerHandlerData = closure;
     return true;
 }
 
-JS_PUBLIC_API(bool)
-JS_SetSourceHandler(JSRuntime *rt, JSSourceHandler handler, void *closure)
-{
-    rt->debugHooks.sourceHandler = handler;
-    rt->debugHooks.sourceHandlerData = closure;
-    return true;
-}
-
-JS_PUBLIC_API(bool)
-JS_SetExecuteHook(JSRuntime *rt, JSInterpreterHook hook, void *closure)
-{
-    rt->debugHooks.executeHook = hook;
-    rt->debugHooks.executeHookData = closure;
-    return true;
-}
-
-JS_PUBLIC_API(bool)
-JS_SetCallHook(JSRuntime *rt, JSInterpreterHook hook, void *closure)
-{
-    rt->debugHooks.callHook = hook;
-    rt->debugHooks.callHookData = closure;
-    return true;
-}
-
-JS_PUBLIC_API(bool)
-JS_SetThrowHook(JSRuntime *rt, JSThrowHook hook, void *closure)
-{
-    rt->debugHooks.throwHook = hook;
-    rt->debugHooks.throwHookData = closure;
-    return true;
-}
-
-JS_PUBLIC_API(bool)
-JS_SetDebugErrorHook(JSRuntime *rt, JSDebugErrorHook hook, void *closure)
-{
-    rt->debugHooks.debugErrorHook = hook;
-    rt->debugHooks.debugErrorHookData = closure;
-    return true;
-}
-
 /************************************************************************/
 
 JS_PUBLIC_API(const JSDebugHooks *)
 JS_GetGlobalDebugHooks(JSRuntime *rt)
 {
     return &rt->debugHooks;
 }
 
--- a/js/src/vm/Stack-inl.h
+++ b/js/src/vm/Stack-inl.h
@@ -82,17 +82,16 @@ InterpreterFrame::initCallFrame(JSContex
     flags_ = FUNCTION | HAS_SCOPECHAIN | flagsArg;
     argv_ = argv;
     exec.fun = &callee;
     u.nactual = nactual;
     scopeChain_ = callee.environment();
     prev_ = prev;
     prevpc_ = prevpc;
     prevsp_ = prevsp;
-    JS_ASSERT(!hasHookData());
 
     initVarsToUndefined();
 }
 
 inline void
 InterpreterFrame::initVarsToUndefined()
 {
     SetValueRangeToUndefined(slots(), script()->nfixed());
@@ -348,42 +347,16 @@ FrameIter::unaliasedForEachActual(JSCont
         return;
 #else
         break;
 #endif
     }
     MOZ_CRASH("Unexpected state");
 }
 
-inline void *
-AbstractFramePtr::maybeHookData() const
-{
-    if (isInterpreterFrame())
-        return asInterpreterFrame()->maybeHookData();
-#ifdef JS_ION
-    return asBaselineFrame()->maybeHookData();
-#else
-    MOZ_CRASH("Invalid frame");
-#endif
-}
-
-inline void
-AbstractFramePtr::setHookData(void *data) const
-{
-    if (isInterpreterFrame()) {
-        asInterpreterFrame()->setHookData(data);
-        return;
-    }
-#ifdef JS_ION
-    asBaselineFrame()->setHookData(data);
-#else
-    MOZ_CRASH("Invalid frame");
-#endif
-}
-
 inline HandleValue
 AbstractFramePtr::returnValue() const
 {
     if (isInterpreterFrame())
         return asInterpreterFrame()->returnValue();
 #ifdef JS_ION
     return asBaselineFrame()->returnValue();
 #else
@@ -624,23 +597,16 @@ AbstractFramePtr::isEvalFrame() const
     if (isBaselineFrame())
         return asBaselineFrame()->isEvalFrame();
     MOZ_ASSERT(isRematerializedFrame());
     return false;
 #else
     MOZ_CRASH("Invalid frame");
 #endif
 }
-
-inline bool
-AbstractFramePtr::isFramePushedByExecute() const
-{
-    return isGlobalFrame() || isEvalFrame();
-}
-
 inline bool
 AbstractFramePtr::isDebuggerFrame() const
 {
     if (isInterpreterFrame())
         return asInterpreterFrame()->isDebuggerFrame();
 #ifdef JS_ION
     if (isBaselineFrame())
         return asBaselineFrame()->isDebuggerFrame();
--- a/js/src/vm/Stack.cpp
+++ b/js/src/vm/Stack.cpp
@@ -85,17 +85,16 @@ InterpreterFrame::initExecuteFrame(JSCon
     prevpc_ = nullptr;
     prevsp_ = nullptr;
 
     JS_ASSERT_IF(evalInFramePrev, isDebuggerFrame());
     evalInFramePrev_ = evalInFramePrev;
 
 #ifdef DEBUG
     Debug_SetValueRangeToCrashOnTouch(&rval_, 1);
-    hookData_ = (void *)0xbad;
 #endif
 }
 
 template <InterpreterFrame::TriggerPostBarriers doPostBarrier>
 void
 InterpreterFrame::copyFrameAndValues(JSContext *cx, Value *vp, InterpreterFrame *otherfp,
                                      const Value *othervp, Value *othersp)
 {
--- a/js/src/vm/Stack.h
+++ b/js/src/vm/Stack.h
@@ -192,17 +192,16 @@ class AbstractFramePtr
     inline JSCompartment *compartment() const;
 
     inline bool hasCallObj() const;
     inline bool isGeneratorFrame() const;
     inline bool isYielding() const;
     inline bool isFunctionFrame() const;
     inline bool isGlobalFrame() const;
     inline bool isEvalFrame() const;
-    inline bool isFramePushedByExecute() const;
     inline bool isDebuggerFrame() const;
 
     inline JSScript *script() const;
     inline JSFunction *fun() const;
     inline JSFunction *maybeFun() const;
     inline JSFunction *callee() const;
     inline Value calleev() const;
     inline Value &thisValue() const;
@@ -230,18 +229,16 @@ class AbstractFramePtr
     inline Value &unaliasedActual(unsigned i, MaybeCheckAliasing checkAliasing = CHECK_ALIASING);
     template <class Op> inline void unaliasedForEachActual(JSContext *cx, Op op);
 
     inline bool prevUpToDate() const;
     inline void setPrevUpToDate() const;
 
     JSObject *evalPrevScopeChain(JSContext *cx) const;
 
-    inline void *maybeHookData() const;
-    inline void setHookData(void *data) const;
     inline HandleValue returnValue() const;
     inline void setReturnValue(const Value &rval) const;
 
     bool hasPushedSPSFrame() const;
 
     inline void popBlock(JSContext *cx) const;
     inline void popWith(JSContext *cx) const;
 };
@@ -313,17 +310,16 @@ class InterpreterFrame
         YIELDING           =       0x40,  /* Interpret dispatched JSOP_YIELD */
         SUSPENDED          =       0x80,  /* Generator is not running. */
 
         /* Function prologue state */
         HAS_CALL_OBJ       =      0x100,  /* CallObject created for heavyweight fun */
         HAS_ARGS_OBJ       =      0x200,  /* ArgumentsObject created for needsArgsObj script */
 
         /* Lazy frame initialization */
-        HAS_HOOK_DATA      =      0x400,  /* frame has hookData_ set */
         HAS_RVAL           =      0x800,  /* frame has rval_ set */
         HAS_SCOPECHAIN     =     0x1000,  /* frame has scopeChain_ set */
 
         /* Debugger state */
         PREV_UP_TO_DATE    =     0x4000,  /* see DebugScopes::updateLiveScopes */
 
         /* Used in tracking calls and profiling (see vm/SPSProfiler.cpp) */
         HAS_PUSHED_SPS_FRAME =   0x8000,  /* SPS was notified of enty */
@@ -356,17 +352,17 @@ class InterpreterFrame
      * Previous frame and its pc and sp. Always nullptr for
      * InterpreterActivation's entry frame, always non-nullptr for inline
      * frames.
      */
     InterpreterFrame    *prev_;
     jsbytecode          *prevpc_;
     Value               *prevsp_;
 
-    void                *hookData_;     /* if HAS_HOOK_DATA, closure returned by call hook */
+    void                *unused;
 
     /*
      * For an eval-in-frame DEBUGGER frame, the frame in whose scope we're
      * evaluating code. Iteration treats this as our previous frame.
      */
     AbstractFramePtr    evalInFramePrev_;
 
     Value               *argv_;         /* If hasArgs(), points to frame's arguments. */
@@ -737,35 +733,17 @@ class InterpreterFrame
      * Frame compartment
      *
      * A stack frame's compartment is the frame's containing context's
      * compartment when the frame was pushed.
      */
 
     inline JSCompartment *compartment() const;
 
-    /* Debugger hook data */
-
-    bool hasHookData() const {
-        return !!(flags_ & HAS_HOOK_DATA);
-    }
-
-    void* hookData() const {
-        JS_ASSERT(hasHookData());
-        return hookData_;
-    }
-
-    void* maybeHookData() const {
-        return hasHookData() ? hookData_ : nullptr;
-    }
-
-    void setHookData(void *v) {
-        hookData_ = v;
-        flags_ |= HAS_HOOK_DATA;
-    }
+    /* Profiler flags */
 
     bool hasPushedSPSFrame() {
         return !!(flags_ & HAS_PUSHED_SPS_FRAME);
     }
 
     void setPushedSPSFrame() {
         flags_ |= HAS_PUSHED_SPS_FRAME;
     }
@@ -843,27 +821,16 @@ class InterpreterFrame
         DoPostBarrier = true,
         NoPostBarrier = false
     };
     template <TriggerPostBarriers doPostBarrier>
     void copyFrameAndValues(JSContext *cx, Value *vp, InterpreterFrame *otherfp,
                             const Value *othervp, Value *othersp);
 
     /*
-     * js::Execute pushes both global and function frames (since eval() in a
-     * function pushes a frame with isFunctionFrame() && isEvalFrame()). Most
-     * code should not care where a frame was pushed, but if it is necessary to
-     * pick out frames pushed by js::Execute, this is the right query:
-     */
-
-    bool isFramePushedByExecute() const {
-        return !!(flags_ & (GLOBAL | EVAL));
-    }
-
-    /*
      * Other flags
      */
 
     InitialFrameFlags initialFlags() const {
         JS_STATIC_ASSERT((int)INITIAL_NONE == 0);
         JS_STATIC_ASSERT((int)INITIAL_CONSTRUCT == (int)CONSTRUCTING);
         uint32_t mask = CONSTRUCTING;
         JS_ASSERT((flags_ & mask) != mask);