Bug 927782 - Part 1: Expose JSScript::getBlockScope(jsbytecode *). r=luke
☠☠ backed out by 94cdaced90bf ☠ ☠
authorAndy Wingo <wingo@igalia.com>
Fri, 06 Dec 2013 17:56:20 +0100
changeset 173964 9d99e9ca7b325fb7a3cf9e5b4d3f970e4b2077da
parent 173963 fa482552d1aab4944b35362a05533fc5070d3a54
child 173965 c8304ccf88e90c17beed5c26fbae1782704c3cd6
push id3224
push userlsblakk@mozilla.com
push dateTue, 04 Feb 2014 01:06:49 +0000
treeherdermozilla-beta@60c04d0987f1 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersluke
bugs927782
milestone28.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 927782 - Part 1: Expose JSScript::getBlockScope(jsbytecode *). r=luke
js/src/jsopcode.cpp
js/src/jsscript.cpp
js/src/jsscript.h
--- a/js/src/jsopcode.cpp
+++ b/js/src/jsopcode.cpp
@@ -1427,40 +1427,16 @@ js_QuoteString(ExclusiveContext *cx, JSS
     char *bytes = QuoteString(&sprinter, str, quote);
     if (!bytes)
         return nullptr;
     return js_NewStringCopyZ<CanGC>(cx, bytes);
 }
 
 /************************************************************************/
 
-static JSObject *
-GetBlockChainAtPC(JSContext *cx, JSScript *script, jsbytecode *pc)
-{
-    JS_ASSERT(script->containsPC(pc));
-    JS_ASSERT(pc >= script->main());
-
-    ptrdiff_t offset = pc - script->main();
-
-    if (!script->hasBlockScopes())
-        return nullptr;
-
-    BlockScopeArray *blockScopes = script->blockScopes();
-    JSObject *blockChain = nullptr;
-    for (uint32_t n = 0; n < blockScopes->length; n++) {
-        const BlockScopeNote *note = &blockScopes->vector[n];
-        if (note->start > offset)
-            break;
-        if (offset <= note->start + note->length)
-            blockChain = script->getObject(note->index);
-    }
-
-    return blockChain;
-}
-
 namespace {
 /*
  * The expression decompiler is invoked by error handling code to produce a
  * string representation of the erroring expression. As it's only a debugging
  * tool, it only supports basic expressions. For anything complicated, it simply
  * puts "(intermediate value)" into the error result.
  *
  * Here's the basic algorithm:
@@ -1711,17 +1687,17 @@ ExpressionDecompiler::loadAtom(jsbytecod
 {
     return script->getAtom(GET_UINT32_INDEX(pc));
 }
 
 JSAtom *
 ExpressionDecompiler::findLetVar(jsbytecode *pc, unsigned depth)
 {
     if (script->hasObjects()) {
-        JSObject *chain = GetBlockChainAtPC(cx, script, pc);
+        JSObject *chain = script->getBlockScope(pc);
         if (!chain)
             return nullptr;
         JS_ASSERT(chain->is<BlockObject>());
         do {
             BlockObject &block = chain->as<BlockObject>();
             uint32_t blockDepth = block.stackDepth();
             uint32_t blockCount = block.slotCount();
             if (uint32_t(depth - blockDepth) < uint32_t(blockCount)) {
--- a/js/src/jsscript.cpp
+++ b/js/src/jsscript.cpp
@@ -2888,16 +2888,40 @@ LazyScript::markChildren(JSTracer *trc)
 
 void
 LazyScript::finalize(FreeOp *fop)
 {
     if (table_)
         fop->free_(table_);
 }
 
+JSObject *
+JSScript::getBlockScope(jsbytecode *pc)
+{
+    JS_ASSERT(containsPC(pc));
+    JS_ASSERT(pc >= main());
+
+    ptrdiff_t offset = pc - main();
+
+    if (!hasBlockScopes())
+        return nullptr;
+
+    BlockScopeArray *scopeArray = blockScopes();
+    JSObject *blockChain = nullptr;
+    for (uint32_t n = 0; n < scopeArray->length; n++) {
+        const BlockScopeNote *note = &scopeArray->vector[n];
+        if (note->start > offset)
+            break;
+        if (offset <= note->start + note->length)
+            blockChain = getObject(note->index);
+    }
+
+    return blockChain;
+}
+
 void
 JSScript::setArgumentsHasVarBinding()
 {
     argsHasVarBinding_ = true;
     needsArgsAnalysis_ = true;
 }
 
 void
--- a/js/src/jsscript.h
+++ b/js/src/jsscript.h
@@ -1081,16 +1081,18 @@ class JSScript : public js::gc::Barriere
     inline js::RegExpObject *getRegExp(size_t index);
 
     const js::Value &getConst(size_t index) {
         js::ConstArray *arr = consts();
         JS_ASSERT(index < arr->length);
         return arr->vector[index];
     }
 
+    JSObject *getBlockScope(jsbytecode *pc);
+
     /*
      * The isEmpty method tells whether this script has code that computes any
      * result (not return value, result AKA normal completion value) other than
      * JSVAL_VOID, or any other effects.
      */
     bool isEmpty() const {
         if (length() > 3)
             return false;