Bug 1482846 - Part 4: Remove unused code from BytecodeUtil. r=tcampbell
authorAndré Bargull <andre.bargull@gmail.com>
Mon, 13 Aug 2018 04:37:21 -0700
changeset 486478 056806c8edf31cb3db1a95c8e5206d8089a262e9
parent 486477 88384f2cacf9e087cb9f4903ab3e9cd62c4d180d
child 486479 c7536967b2f93ab4d4a4cfa2b24d198c680dfc43
push id9719
push userffxbld-merge
push dateFri, 24 Aug 2018 17:49:46 +0000
treeherdermozilla-beta@719ec98fba77 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerstcampbell
bugs1482846
milestone63.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 1482846 - Part 4: Remove unused code from BytecodeUtil. r=tcampbell
js/src/vm/BytecodeUtil.cpp
js/src/vm/BytecodeUtil.h
--- a/js/src/vm/BytecodeUtil.cpp
+++ b/js/src/vm/BytecodeUtil.cpp
@@ -7,17 +7,16 @@
 /*
  * JS bytecode descriptors, disassemblers, and (expression) decompilers.
  */
 
 #include "vm/BytecodeUtil-inl.h"
 
 #define __STDC_FORMAT_MACROS
 
-#include "mozilla/ArrayUtils.h"
 #include "mozilla/Attributes.h"
 #include "mozilla/Sprintf.h"
 #include "mozilla/Vector.h"
 
 #include <algorithm>
 #include <ctype.h>
 #include <inttypes.h>
 #include <stdio.h>
@@ -65,18 +64,16 @@ using js::frontend::IsIdentifier;
 JS_STATIC_ASSERT(sizeof(uint32_t) * CHAR_BIT >= INDEX_LIMIT_LOG2 + 1);
 
 const JSCodeSpec js::CodeSpec[] = {
 #define MAKE_CODESPEC(op,val,name,token,length,nuses,ndefs,format)  {length,nuses,ndefs,format},
     FOR_EACH_OPCODE(MAKE_CODESPEC)
 #undef MAKE_CODESPEC
 };
 
-const unsigned js::NumCodeSpecs = mozilla::ArrayLength(CodeSpec);
-
 /*
  * Each element of the array is either a source literal associated with JS
  * bytecode or null.
  */
 static const char * const CodeToken[] = {
 #define TOKEN(op, val, name, token, ...)  token,
     FOR_EACH_OPCODE(TOKEN)
 #undef TOKEN
@@ -953,17 +950,19 @@ BytecodeParser::parse()
             // Case instructions do not push the lvalue back when branching.
             uint32_t newStackDepth = stackDepth;
             if (op == JSOP_CASE)
                 newStackDepth--;
 
             uint32_t targetOffset = offset + GET_JUMP_OFFSET(pc);
             if (!addJump(targetOffset, &nextOffset, newStackDepth, offsetStack,
                          pc, JumpKind::Simple))
+            {
                 return false;
+            }
         }
 
         // Handle any fallthrough from this opcode.
         if (BytecodeFallsThrough(op)) {
             if (!recordBytecode(successorOffset, offsetStack, stackDepth))
                 return false;
         }
     }
@@ -2408,46 +2407,16 @@ js::DecompileArgument(JSContext* cx, int
 
     RootedString fallback(cx, ValueToSource(cx, v));
     if (!fallback)
         return nullptr;
 
     return UniqueChars(JS_EncodeString(cx, fallback));
 }
 
-bool
-js::CallResultEscapes(jsbytecode* pc)
-{
-    /*
-     * If we see any of these sequences, the result is unused:
-     * - call / pop
-     *
-     * If we see any of these sequences, the result is only tested for nullness:
-     * - call / ifeq
-     * - call / not / ifeq
-     */
-
-    if (*pc == JSOP_CALL)
-        pc += JSOP_CALL_LENGTH;
-    else if (*pc == JSOP_CALL_IGNORES_RV)
-        pc += JSOP_CALL_IGNORES_RV_LENGTH;
-    else if (*pc == JSOP_SPREADCALL)
-        pc += JSOP_SPREADCALL_LENGTH;
-    else
-        return true;
-
-    if (*pc == JSOP_POP)
-        return false;
-
-    if (*pc == JSOP_NOT)
-        pc += JSOP_NOT_LENGTH;
-
-    return *pc != JSOP_IFEQ;
-}
-
 extern bool
 js::IsValidBytecodeOffset(JSContext* cx, JSScript* script, size_t offset)
 {
     // This could be faster (by following jump instructions if the target is <= offset).
     for (BytecodeRange r(cx, script); !r.empty(); r.popFront()) {
         size_t here = r.frontOffset();
         if (here >= offset)
             return here == offset;
--- a/js/src/vm/BytecodeUtil.h
+++ b/js/src/vm/BytecodeUtil.h
@@ -389,18 +389,17 @@ struct JSCodeSpec {
     uint32_t            format;         /* immediate operand format */
 
     uint32_t type() const { return JOF_TYPE(format); }
 };
 
 namespace js {
 
 extern const JSCodeSpec CodeSpec[];
-extern const unsigned   NumCodeSpecs;
-extern const char       * const CodeName[];
+extern const char* const CodeName[];
 
 /* Shorthand for type from opcode. */
 
 static inline uint32_t
 JOF_OPTYPE(JSOp op)
 {
     return JOF_TYPE(CodeSpec[op].format);
 }
@@ -531,30 +530,16 @@ DecompileValueGenerator(JSContext* cx, i
 
 /*
  * Decompile the formal argument at formalIndex in the nearest non-builtin
  * stack frame, falling back with converting v to source.
  */
 UniqueChars
 DecompileArgument(JSContext* cx, int formalIndex, HandleValue v);
 
-extern bool
-CallResultEscapes(jsbytecode* pc);
-
-static inline unsigned
-GetDecomposeLength(jsbytecode* pc, size_t len)
-{
-    /*
-     * The last byte of a DECOMPOSE op stores the decomposed length.  This is a
-     * constant: perhaps we should just hardcode values instead?
-     */
-    MOZ_ASSERT(size_t(CodeSpec[*pc].length) == len);
-    return (unsigned) pc[len - 1];
-}
-
 static inline unsigned
 GetBytecodeLength(jsbytecode* pc)
 {
     JSOp op = (JSOp)*pc;
     MOZ_ASSERT(op < JSOP_LIMIT);
 
     if (CodeSpec[op].length != -1)
         return CodeSpec[op].length;