Bug 1586439 - Use BytecodeLocation and BytecodeIterator in js::GetPredecessorBytecodes, r=mgaudet
authorAlok Nikhil <aloknnikhil@gmail.com>
Thu, 10 Oct 2019 16:30:38 +0000
changeset 497190 d03b24c67a28eac09121e097307897eeb0dec75a
parent 497189 b86bb62c23b1495ebfe4a2a78508408bfd1b722e
child 497191 a5dacb181633c6ff72a9378d41eeaabb425200fb
push id36679
push userdluca@mozilla.com
push dateFri, 11 Oct 2019 09:30:10 +0000
treeherdermozilla-central@a7ca5ad33f3d [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmgaudet
bugs1586439
milestone71.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 1586439 - Use BytecodeLocation and BytecodeIterator in js::GetPredecessorBytecodes, r=mgaudet Differential Revision: https://phabricator.services.mozilla.com/D48479
js/src/vm/BytecodeUtil.cpp
--- a/js/src/vm/BytecodeUtil.cpp
+++ b/js/src/vm/BytecodeUtil.cpp
@@ -31,28 +31,31 @@
 #include "frontend/SourceNotes.h"
 #include "gc/FreeOp.h"
 #include "gc/GCInternals.h"
 #include "js/CharacterEncoding.h"
 #include "js/Printf.h"
 #include "js/Symbol.h"
 #include "util/StringBuffer.h"
 #include "util/Text.h"
+#include "vm/BytecodeLocation.h"
 #include "vm/CodeCoverage.h"
 #include "vm/EnvironmentObject.h"
 #include "vm/JSAtom.h"
 #include "vm/JSContext.h"
 #include "vm/JSFunction.h"
 #include "vm/JSObject.h"
 #include "vm/JSScript.h"
 #include "vm/Opcodes.h"
 #include "vm/Realm.h"
 #include "vm/Shape.h"
 
 #include "gc/PrivateIterators-inl.h"
+#include "vm/BytecodeIterator-inl.h"
+#include "vm/BytecodeLocation-inl.h"
 #include "vm/JSContext-inl.h"
 #include "vm/JSObject-inl.h"
 #include "vm/JSScript-inl.h"
 #include "vm/Realm-inl.h"
 
 using namespace js;
 
 using js::frontend::IsIdentifier;
@@ -3023,26 +3026,26 @@ bool js::GetSuccessorBytecodes(JSScript*
     }
   }
 
   return true;
 }
 
 bool js::GetPredecessorBytecodes(JSScript* script, jsbytecode* pc,
                                  PcVector& predecessors) {
-  jsbytecode* end = script->code() + script->length();
-  MOZ_ASSERT(pc >= script->code() && pc < end);
-  for (jsbytecode* npc = script->code(); npc < end; npc = GetNextPc(npc)) {
+  MOZ_ASSERT(js::BytecodeLocation(script, pc).isInBounds(script));
+
+  for (const BytecodeLocation& loc : js::AllBytecodesIterable(script)) {
     PcVector successors;
-    if (!GetSuccessorBytecodes(script, npc, successors)) {
+    if (!GetSuccessorBytecodes(script, loc.toRawBytecode(), successors)) {
       return false;
     }
     for (size_t i = 0; i < successors.length(); i++) {
       if (successors[i] == pc) {
-        if (!predecessors.append(npc)) {
+        if (!predecessors.append(loc.toRawBytecode())) {
           return false;
         }
         break;
       }
     }
   }
   return true;
 }