Bug 1530745 - Part 6: Change JSOP_RESUME immediate back to UINT8. r=arai
authorAndré Bargull <andre.bargull@gmail.com>
Fri, 08 Mar 2019 12:38:47 +0000
changeset 521221 f6d4e1b012e6580cd2c857dafe12f540f7e87f8e
parent 521220 b499a1eec1b1169757cc93928f9c987df1884097
child 521222 7e6212df60755c483d031ef1bd30fa484ebb91ca
push id10862
push userffxbld-merge
push dateMon, 11 Mar 2019 13:01:11 +0000
treeherdermozilla-beta@a2e7f5c935da [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersarai
bugs1530745
milestone67.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 1530745 - Part 6: Change JSOP_RESUME immediate back to UINT8. r=arai And add more assertions to document implicit requirements about opcode lengths. Depends on D22670 Differential Revision: https://phabricator.services.mozilla.com/D22671
js/src/frontend/BytecodeEmitter.cpp
js/src/vm/GeneratorObject.cpp
js/src/vm/GeneratorObject.h
js/src/vm/Interpreter.cpp
js/src/vm/Opcodes.h
--- a/js/src/frontend/BytecodeEmitter.cpp
+++ b/js/src/frontend/BytecodeEmitter.cpp
@@ -7123,21 +7123,21 @@ bool BytecodeEmitter::emitSelfHostedResu
 
   ParseNode* valNode = genNode->pn_next;
   if (!emitTree(valNode)) {
     return false;
   }
 
   ParseNode* kindNode = valNode->pn_next;
   MOZ_ASSERT(kindNode->isKind(ParseNodeKind::StringExpr));
-  uint16_t operand = AbstractGeneratorObject::getResumeKind(
+  uint8_t operand = AbstractGeneratorObject::getResumeKind(
       cx, kindNode->as<NameNode>().atom());
   MOZ_ASSERT(!kindNode->pn_next);
 
-  if (!emitCall(JSOP_RESUME, operand)) {
+  if (!emit2(JSOP_RESUME, operand)) {
     return false;
   }
 
   return true;
 }
 
 bool BytecodeEmitter::emitSelfHostedForceInterpreter() {
   if (!emit1(JSOP_FORCEINTERPRETER)) {
--- a/js/src/vm/GeneratorObject.cpp
+++ b/js/src/vm/GeneratorObject.cpp
@@ -314,16 +314,21 @@ bool AbstractGeneratorObject::isAfterYie
 
   JSScript* script = callee().nonLazyScript();
   jsbytecode* code = script->code();
   uint32_t nextOffset = script->resumeOffsets()[resumeIndex()];
   if (code[nextOffset] != JSOP_DEBUGAFTERYIELD) {
     return false;
   }
 
+  static_assert(JSOP_YIELD_LENGTH == JSOP_INITIALYIELD_LENGTH,
+                "JSOP_YIELD and JSOP_INITIALYIELD must have the same length");
+  static_assert(JSOP_YIELD_LENGTH == JSOP_AWAIT_LENGTH,
+                "JSOP_YIELD and JSOP_AWAIT must have the same length");
+
   uint32_t offset = nextOffset - JSOP_YIELD_LENGTH;
   MOZ_ASSERT(code[offset] == JSOP_INITIALYIELD || code[offset] == JSOP_YIELD ||
              code[offset] == JSOP_AWAIT);
 
   return code[offset] == op;
 }
 
 template <>
--- a/js/src/vm/GeneratorObject.h
+++ b/js/src/vm/GeneratorObject.h
@@ -36,17 +36,17 @@ class AbstractGeneratorObject : public N
 
  private:
   static bool suspend(JSContext* cx, HandleObject obj, AbstractFramePtr frame,
                       jsbytecode* pc, Value* vp, unsigned nvalues);
 
  public:
   static inline ResumeKind getResumeKind(jsbytecode* pc) {
     MOZ_ASSERT(*pc == JSOP_RESUME);
-    unsigned arg = GET_UINT16(pc);
+    unsigned arg = GET_UINT8(pc);
     MOZ_ASSERT(arg <= RETURN);
     return static_cast<ResumeKind>(arg);
   }
 
   static inline ResumeKind getResumeKind(JSContext* cx, JSAtom* atom) {
     if (atom == cx->names().next) {
       return NEXT;
     }
--- a/js/src/vm/Interpreter.cpp
+++ b/js/src/vm/Interpreter.cpp
@@ -2106,16 +2106,20 @@ static MOZ_NEVER_INLINE JS_HAZ_JSNATIVE_
 
         MOZ_ASSERT(CodeSpec[*REGS.pc].format & JOF_INVOKE);
         MOZ_ASSERT(cx->realm() == script->realm());
 
         /* Resume execution in the calling frame. */
         if (MOZ_LIKELY(interpReturnOK)) {
           TypeScript::Monitor(cx, script, REGS.pc, REGS.sp[-1]);
 
+          if (JSOp(*REGS.pc) == JSOP_RESUME) {
+            ADVANCE_AND_DISPATCH(JSOP_RESUME_LENGTH);
+          }
+          MOZ_ASSERT(CodeSpec[*REGS.pc].length == JSOP_CALL_LENGTH);
           ADVANCE_AND_DISPATCH(JSOP_CALL_LENGTH);
         }
 
         goto error;
       } else {
         // Stack should be empty for the outer frame, unless we executed the
         // first |await| expression in an async function.
         MOZ_ASSERT(
@@ -3019,16 +3023,29 @@ static MOZ_NEVER_INLINE JS_HAZ_JSNATIVE_
     }
 
     CASE(JSOP_NEW)
     CASE(JSOP_CALL)
     CASE(JSOP_CALL_IGNORES_RV)
     CASE(JSOP_CALLITER)
     CASE(JSOP_SUPERCALL)
     CASE(JSOP_FUNCALL) {
+      static_assert(JSOP_CALL_LENGTH == JSOP_NEW_LENGTH,
+                    "call and new must be the same size");
+      static_assert(JSOP_CALL_LENGTH == JSOP_CALL_IGNORES_RV_LENGTH,
+                    "call and call-ignores-rv must be the same size");
+      static_assert(JSOP_CALL_LENGTH == JSOP_CALLITER_LENGTH,
+                    "call and calliter must be the same size");
+      static_assert(JSOP_CALL_LENGTH == JSOP_SUPERCALL_LENGTH,
+                    "call and supercall must be the same size");
+      static_assert(JSOP_CALL_LENGTH == JSOP_FUNCALL_LENGTH,
+                    "call and funcall must be the same size");
+      static_assert(JSOP_CALL_LENGTH == JSOP_FUNAPPLY_LENGTH,
+                    "call and funapply must be the same size");
+
       if (REGS.fp()->hasPushedGeckoProfilerFrame()) {
         cx->geckoProfiler().updatePC(cx, script, REGS.pc);
       }
 
       MaybeConstruct construct =
           MaybeConstruct(*REGS.pc == JSOP_NEW || *REGS.pc == JSOP_SUPERCALL);
       bool ignoresReturnValue = *REGS.pc == JSOP_CALL_IGNORES_RV;
       unsigned argStackSlots = GET_ARGC(REGS.pc) + construct;
--- a/js/src/vm/Opcodes.h
+++ b/js/src/vm/Opcodes.h
@@ -2215,17 +2215,17 @@
      * frame and resumes execution of it. Pushes the return value after the
      * generator yields.
      *
      *   Category: Statements
      *   Type: Generator
      *   Operands: resume kind (AbstractGeneratorObject::ResumeKind)
      *   Stack: gen, val => rval
      */ \
-    MACRO(JSOP_RESUME, 205, "resume", NULL, 3, 2, 1, JOF_UINT16|JOF_INVOKE) \
+    MACRO(JSOP_RESUME, 205, "resume", NULL, 2, 2, 1, JOF_UINT8|JOF_INVOKE) \
     /*
      * Load the callee stored in a CallObject on the environment chain. The
      * numHops operand is the number of environment objects to skip on the
      * environment chain.
      *
      *   Category: Variables and Scopes
      *   Type: Arguments
      *   Operands: uint8_t numHops