arai-a / smoosh-sync

Automation to make jsparagus and SpiderMonkey bytecode in sync
2 stars 0 forks source link

/js/src/frontend/Stencil.cpp and 4 more files have been updated (e22b9fd8) #338

Open github-actions[bot] opened 1 year ago

github-actions[bot] commented 1 year ago

Files

Changesets

Diffs

/js/src/frontend/Stencil.cpp

--- 6f4e49448f1c68b2a749e5461b60a2a0d153eb42/js/src/frontend/Stencil.cpp
+++ 7d89a3d4f78eaa57e2990bd0bbd0dbb81a07e3b4/js/src/frontend/Stencil.cpp
@@ -3639,21 +3639,21 @@ void frontend::DumpTaggedParserAtomIndex
     }
     return;
   }

   if (taggedIndex.isWellKnownAtomId()) {
     json.property("tag", "WellKnown");
     auto index = taggedIndex.toWellKnownAtomId();
     switch (index) {
-      case WellKnownAtomId::empty:
+      case WellKnownAtomId::empty_:
         json.property("atom", "");
         break;

-#  define CASE_(_, name, _2) case WellKnownAtomId::name:
+#  define CASE_(name, _) case WellKnownAtomId::name:
         FOR_EACH_NONTINY_COMMON_PROPERTYNAME(CASE_)
 #  undef CASE_

 #  define CASE_(name, _) case WellKnownAtomId::name:
         JS_FOR_EACH_PROTOTYPE(CASE_)
 #  undef CASE_

 #  define CASE_(name) case WellKnownAtomId::name:
@@ -3717,21 +3717,21 @@ void frontend::DumpTaggedParserAtomIndex
       out.printf("AtomIndex#%zu", size_t(index));
     }
     return;
   }

   if (taggedIndex.isWellKnownAtomId()) {
     auto index = taggedIndex.toWellKnownAtomId();
     switch (index) {
-      case WellKnownAtomId::empty:
+      case WellKnownAtomId::empty_:
         out.put("#<zero-length name>");
         break;

-#  define CASE_(_, name, _2) case WellKnownAtomId::name:
+#  define CASE_(name, _) case WellKnownAtomId::name:
         FOR_EACH_NONTINY_COMMON_PROPERTYNAME(CASE_)
 #  undef CASE_

 #  define CASE_(name, _) case WellKnownAtomId::name:
         JS_FOR_EACH_PROTOTYPE(CASE_)
 #  undef CASE_

 #  define CASE_(name) case WellKnownAtomId::name:
@@ -4416,17 +4416,17 @@ void ScriptStencilExtra::dumpFields(js::
   json.endList();

   json.beginObjectProperty("extent");
   json.property("sourceStart", extent.sourceStart);
   json.property("sourceEnd", extent.sourceEnd);
   json.property("toStringStart", extent.toStringStart);
   json.property("toStringEnd", extent.toStringEnd);
   json.property("lineno", extent.lineno);
-  json.property("column", extent.column);
+  json.property("column", extent.column.zeroOriginValue());
   json.endObject();

   json.property("memberInitializers", memberInitializers_);

   json.property("nargs", nargs);
 }

 void SharedDataContainer::dump() const {
@@ -4579,17 +4579,17 @@ static void DumpInputScriptFields(js::JS
   json.beginObjectProperty("extent");
   {
     SourceExtent extent = script.extent();
     json.property("sourceStart", extent.sourceStart);
     json.property("sourceEnd", extent.sourceEnd);
     json.property("toStringStart", extent.toStringStart);
     json.property("toStringEnd", extent.toStringEnd);
     json.property("lineno", extent.lineno);
-    json.property("column", extent.column);
+    json.property("column", extent.column.zeroOriginValue());
   }
   json.endObject();

   json.beginListProperty("immutableFlags");
   DumpImmutableScriptFlags(json, script.immutableFlags());
   json.endList();

   json.beginListProperty("functionFlags");

/js/src/frontend/Stencil.h

--- b4cb88d106bd62b949ef92204c648c9379e065ca/js/src/frontend/Stencil.h
+++ 1cee58fb35ca417bee3746b02b30f848dea2395b/js/src/frontend/Stencil.h
@@ -16,16 +16,17 @@
 #include <stdint.h>  // char16_t, uint8_t, uint16_t, uint32_t

 #include "frontend/AbstractScopePtr.h"  // AbstractScopePtr, ScopeIndex
 #include "frontend/ObjLiteral.h"        // ObjLiteralStencil
 #include "frontend/ParserAtom.h"        // TaggedParserAtomIndex
 #include "frontend/ScriptIndex.h"       // ScriptIndex
 #include "frontend/TypedIndex.h"        // TypedIndex
 #include "js/AllocPolicy.h"             // SystemAllocPolicy
+#include "js/ColumnNumber.h"            // JS::ColumnNumberZeroOrigin
 #include "js/RefCounted.h"              // AtomicRefCounted
 #include "js/RegExpFlags.h"             // JS::RegExpFlags
 #include "js/RootingAPI.h"              // Handle
 #include "js/TypeDecls.h"               // JSContext
 #include "js/UniquePtr.h"               // js::UniquePtr
 #include "js/Utility.h"                 // UniqueTwoByteChars
 #include "js/Vector.h"                  // js::Vector
 #include "vm/FunctionFlags.h"           // FunctionFlags
@@ -606,21 +607,21 @@ class StencilModuleEntry {
   // Location used for error messages. If this is for a module request entry
   // then it is the module specifier string, otherwise the import/export spec
   // that failed. Exports may not fill these fields if an error cannot be
   // generated such as `export let x;`.

   // Line number (1-origin).
   uint32_t lineno = 0;

-  // Column number in UTF-16 code units (0-origin).
-  uint32_t column = 0;
+  // Column number in UTF-16 code units.
+  JS::ColumnNumberZeroOrigin column;

  private:
-  StencilModuleEntry(uint32_t lineno, uint32_t column)
+  StencilModuleEntry(uint32_t lineno, JS::ColumnNumberZeroOrigin column)
       : lineno(lineno), column(column) {}

  public:
   // For XDR only.
   StencilModuleEntry() = default;

   StencilModuleEntry(const StencilModuleEntry& other)
       : moduleRequest(other.moduleRequest),
@@ -654,82 +655,87 @@ class StencilModuleEntry {
     importName = other.importName;
     exportName = other.exportName;
     lineno = other.lineno;
     column = other.column;
     return *this;
   }

   static StencilModuleEntry requestedModule(
-      MaybeModuleRequestIndex moduleRequest, uint32_t lineno, uint32_t column) {
+      MaybeModuleRequestIndex moduleRequest, uint32_t lineno,
+      JS::ColumnNumberZeroOrigin column) {
     MOZ_ASSERT(moduleRequest.isSome());
     StencilModuleEntry entry(lineno, column);
     entry.moduleRequest = moduleRequest;
     return entry;
   }

   static StencilModuleEntry importEntry(MaybeModuleRequestIndex moduleRequest,
                                         TaggedParserAtomIndex localName,
                                         TaggedParserAtomIndex importName,
-                                        uint32_t lineno, uint32_t column) {
+                                        uint32_t lineno,
+                                        JS::ColumnNumberZeroOrigin column) {
     MOZ_ASSERT(moduleRequest.isSome());
     MOZ_ASSERT(localName && importName);
     StencilModuleEntry entry(lineno, column);
     entry.moduleRequest = moduleRequest;
     entry.localName = localName;
     entry.importName = importName;
     return entry;
   }

   static StencilModuleEntry importNamespaceEntry(
       MaybeModuleRequestIndex moduleRequest, TaggedParserAtomIndex localName,
-      uint32_t lineno, uint32_t column) {
+      uint32_t lineno, JS::ColumnNumberZeroOrigin column) {
     MOZ_ASSERT(moduleRequest.isSome());
     MOZ_ASSERT(localName);
     StencilModuleEntry entry(lineno, column);
     entry.moduleRequest = moduleRequest;
     entry.localName = localName;
     return entry;
   }

   static StencilModuleEntry exportAsEntry(TaggedParserAtomIndex localName,
                                           TaggedParserAtomIndex exportName,
-                                          uint32_t lineno, uint32_t column) {
+                                          uint32_t lineno,
+                                          JS::ColumnNumberZeroOrigin column) {
     MOZ_ASSERT(localName && exportName);
     StencilModuleEntry entry(lineno, column);
     entry.localName = localName;
     entry.exportName = exportName;
     return entry;
   }

   static StencilModuleEntry exportFromEntry(
       MaybeModuleRequestIndex moduleRequest, TaggedParserAtomIndex importName,
-      TaggedParserAtomIndex exportName, uint32_t lineno, uint32_t column) {
+      TaggedParserAtomIndex exportName, uint32_t lineno,
+      JS::ColumnNumberZeroOrigin column) {
     MOZ_ASSERT(moduleRequest.isSome());
     MOZ_ASSERT(importName && exportName);
     StencilModuleEntry entry(lineno, column);
     entry.moduleRequest = moduleRequest;
     entry.importName = importName;
     entry.exportName = exportName;
     return entry;
   }

   static StencilModuleEntry exportNamespaceFromEntry(
       MaybeModuleRequestIndex moduleRequest, TaggedParserAtomIndex exportName,
-      uint32_t lineno, uint32_t column) {
+      uint32_t lineno, JS::ColumnNumberZeroOrigin column) {
     MOZ_ASSERT(moduleRequest.isSome());
     MOZ_ASSERT(exportName);
     StencilModuleEntry entry(lineno, column);
     entry.moduleRequest = MaybeModuleRequestIndex(moduleRequest);
     entry.exportName = exportName;
     return entry;
   }

   static StencilModuleEntry exportBatchFromEntry(
-      MaybeModuleRequestIndex moduleRequest, uint32_t lineno, uint32_t column) {
+      MaybeModuleRequestIndex moduleRequest, uint32_t lineno,
+      JS::ColumnNumberZeroOrigin column) {
     MOZ_ASSERT(moduleRequest.isSome());
     StencilModuleEntry entry(lineno, column);
     entry.moduleRequest = MaybeModuleRequestIndex(moduleRequest);
     return entry;
   }
 };

 // Metadata generated by parsing module scripts, including import/export tables.

/js/src/vm/BytecodeUtil-inl.h

--- b4cb88d106bd62b949ef92204c648c9379e065ca/js/src/vm/BytecodeUtil-inl.h
+++ 72a25c44626aa5468c0d8613573e62ff97af0af0/js/src/vm/BytecodeUtil-inl.h
@@ -5,16 +5,17 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */

 #ifndef vm_BytecodeUtil_inl_h
 #define vm_BytecodeUtil_inl_h

 #include "vm/BytecodeUtil.h"

 #include "frontend/SourceNotes.h"  // SrcNote, SrcNoteType, SrcNoteIterator
+#include "js/ColumnNumber.h"  // JS::LimitedColumnNumberZeroOrigin, JS::ColumnNumberOffset
 #include "vm/JSScript.h"

 namespace js {

 static inline unsigned GetDefCount(jsbytecode* pc) {
   /*
    * Add an extra pushed value for Or/And opcodes, so that they are included
    * in the pushed array of stack values for type inference.
@@ -157,18 +158,18 @@ class BytecodeRangeWithPosition : privat
     }

     if (isEntryPoint && frontOpcode() == JSOp::JumpTarget) {
       wasArtifactEntryPoint = isEntryPoint;
       isEntryPoint = false;
     }
   }

-  size_t frontLineNumber() const { return lineno; }
-  size_t frontColumnNumber() const { return column; }
+  uint32_t frontLineNumber() const { return lineno; }
+  JS::LimitedColumnNumberZeroOrigin frontColumnNumber() const { return column; }

   // Entry points are restricted to bytecode offsets that have an
   // explicit mention in the line table.  This restriction avoids a
   // number of failing cases caused by some instructions not having
   // sensible (to the user) line numbers, and it is one way to
   // implement the idea that the bytecode emitter should tell the
   // debugger exactly which offsets represent "interesting" (to the
   // user) places to stop.
@@ -196,48 +197,46 @@ class BytecodeRangeWithPosition : privat
     jsbytecode* lastLinePC = nullptr;
     SrcNoteIterator iter(sn);
     for (; !iter.atEnd() && snpc <= frontPC();
          ++iter, snpc += (*iter)->delta()) {
       auto sn = *iter;

       SrcNoteType type = sn->type();
       if (type == SrcNoteType::ColSpan) {
-        ptrdiff_t colspan = SrcNote::ColSpan::getSpan(sn);
-        MOZ_ASSERT(ptrdiff_t(column) + colspan >= 0);
-        column += colspan;
+        column += SrcNote::ColSpan::getSpan(sn);
         lastLinePC = snpc;
       } else if (type == SrcNoteType::SetLine) {
         lineno = SrcNote::SetLine::getLine(sn, initialLine);
-        column = 0;
+        column = JS::LimitedColumnNumberZeroOrigin::zero();
         lastLinePC = snpc;
       } else if (type == SrcNoteType::NewLine) {
         lineno++;
-        column = 0;
+        column = JS::LimitedColumnNumberZeroOrigin::zero();
         lastLinePC = snpc;
       } else if (type == SrcNoteType::Breakpoint) {
         isBreakpoint = true;
         lastLinePC = snpc;
       } else if (type == SrcNoteType::StepSep) {
         seenStepSeparator = true;
         lastLinePC = snpc;
       }
     }

     sn = *iter;
     isEntryPoint = lastLinePC == frontPC();
   }

-  size_t initialLine;
+  uint32_t initialLine;

   // Line number (1-origin).
-  size_t lineno;
+  uint32_t lineno;

-  // Column number in UTF-16 code units (0-origin).
-  size_t column;
+  // Column number in UTF-16 code units.
+  JS::LimitedColumnNumberZeroOrigin column;

   const SrcNote* sn;
   jsbytecode* snpc;
   bool isEntryPoint;
   bool isBreakpoint;
   bool seenStepSeparator;
   bool wasArtifactEntryPoint;
 };

/js/src/vm/BytecodeUtil.cpp

--- 09397da6273aba1cbc94f88577a1a600f77a0b1b/js/src/vm/BytecodeUtil.cpp
+++ c902ce08d1708a62697dc47fca31ffe879fec040/js/src/vm/BytecodeUtil.cpp
@@ -22,16 +22,17 @@

 #include "jsapi.h"
 #include "jstypes.h"

 #include "frontend/SourceNotes.h"  // SrcNote, SrcNoteType, SrcNoteIterator
 #include "gc/PublicIterators.h"
 #include "jit/IonScript.h"  // IonBlockCounts
 #include "js/CharacterEncoding.h"
+#include "js/ColumnNumber.h"  // JS::LimitedColumnNumberZeroOrigin
 #include "js/experimental/CodeCoverage.h"
 #include "js/experimental/PCCountProfiling.h"  // JS::{Start,Stop}PCCountProfiling, JS::PurgePCCounts, JS::GetPCCountScript{Count,Summary,Contents}
 #include "js/friend/DumpFunctions.h"           // js::DumpPC, js::DumpScript
 #include "js/friend/ErrorMessages.h"           // js::GetErrorMessage, JSMSG_*
 #include "js/Printer.h"
 #include "js/Printf.h"
 #include "js/Symbol.h"
 #include "util/DifferentialTesting.h"
@@ -48,18 +49,17 @@
 #include "vm/JSContext.h"
 #include "vm/JSFunction.h"
 #include "vm/JSObject.h"
 #include "vm/JSONPrinter.h"
 #include "vm/JSScript.h"
 #include "vm/Opcodes.h"
 #include "vm/Realm.h"
 #include "vm/Shape.h"
-#include "vm/ToSource.h"       // js::ValueToSource
-#include "vm/WellKnownAtom.h"  // js_*_str
+#include "vm/ToSource.h"  // js::ValueToSource

 #include "gc/GC-inl.h"
 #include "vm/BytecodeIterator-inl.h"
 #include "vm/JSContext-inl.h"
 #include "vm/JSScript-inl.h"
 #include "vm/Realm-inl.h"

 using namespace js;
@@ -106,21 +106,23 @@ static bool DecompileArgumentFromStack(J
 [[nodiscard]] static bool DumpIonScriptCounts(Sprinter* sp, HandleScript script,
                                               jit::IonScriptCounts* ionCounts) {
   if (!sp->jsprintf("IonScript [%zu blocks]:\n", ionCounts->numBlocks())) {
     return false;
   }

   for (size_t i = 0; i < ionCounts->numBlocks(); i++) {
     const jit::IonBlockCounts& block = ionCounts->block(i);
-    unsigned lineNumber = 0, columnNumber = 0;
+    unsigned lineNumber = 0;
+    JS::LimitedColumnNumberZeroOrigin columnNumber;
     lineNumber = PCToLineNumber(script, script->offsetToPC(block.offset()),
                                 &columnNumber);
     if (!sp->jsprintf("BB #%" PRIu32 " [%05u,%u,%u]", block.id(),
-                      block.offset(), lineNumber, columnNumber)) {
+                      block.offset(), lineNumber,
+                      columnNumber.zeroOriginValue())) {
       return false;
     }
     if (block.description()) {
       if (!sp->jsprintf(" [inlined %s]", block.description())) {
         return false;
       }
     }
     for (size_t j = 0; j < block.numSuccessors(); j++) {
@@ -1919,21 +1921,21 @@ bool ExpressionDecompiler::decompilePC(j
              decompilePCForStackOperand(pc, -1) && write("]") &&
              (hasDelete ? write(")") : true);
     }

     case JSOp::GetElemSuper:
       return write("super[") && decompilePCForStackOperand(pc, -2) &&
              write("]");
     case JSOp::Null:
-      return write(js_null_str);
+      return write("null");
     case JSOp::True:
-      return write(js_true_str);
+      return write("true");
     case JSOp::False:
-      return write(js_false_str);
+      return write("false");
     case JSOp::Zero:
     case JSOp::One:
     case JSOp::Int8:
     case JSOp::Uint16:
     case JSOp::Uint24:
     case JSOp::Int32:
       return sprinter.printf("%d", GetBytecodeInteger(pc));
     case JSOp::String:
@@ -1942,22 +1944,22 @@ bool ExpressionDecompiler::decompilePC(j
       unsigned i = uint8_t(pc[1]);
       MOZ_ASSERT(i < JS::WellKnownSymbolLimit);
       if (i < JS::WellKnownSymbolLimit) {
         return write(cx->names().wellKnownSymbolDescriptions()[i]);
       }
       break;
     }
     case JSOp::Undefined:
-      return write(js_undefined_str);
+      return write("undefined");
     case JSOp::GlobalThis:
     case JSOp::NonSyntacticGlobalThis:
       // |this| could convert to a very long object initialiser, so cite it by
       // its keyword name.
-      return write(js_this_str);
+      return write("this");
     case JSOp::NewTarget:
       return write("new.target");
     case JSOp::ImportMeta:
       return write("import.meta");
     case JSOp::Call:
     case JSOp::CallContent:
     case JSOp::CallIgnoresRv:
     case JSOp::CallIter:
@@ -2297,20 +2299,20 @@ bool ExpressionDecompiler::decompilePC(
 bool ExpressionDecompiler::init() {
   cx->check(script);
   return sprinter.init();
 }

 bool ExpressionDecompiler::write(const char* s) { return sprinter.put(s); }

 bool ExpressionDecompiler::write(JSString* str) {
-  if (str == cx->names().dotThis) {
+  if (str == cx->names().dot_this_) {
     return write("this");
   }
-  if (str == cx->names().dotNewTarget) {
+  if (str == cx->names().dot_newTarget_) {
     return write("new.target");
   }
   return sprinter.putString(str);
 }

 bool ExpressionDecompiler::quote(JSString* s, char quote) {
   return QuoteString(&sprinter, s, quote);
 }
@@ -2516,18 +2518,18 @@ UniqueChars js::DecompileValueGenerator(
       return nullptr;
     }
     if (result && strcmp(result.get(), "(intermediate value)")) {
       return result;
     }
   }
   if (!fallback) {
     if (v.isUndefined()) {
-      return DuplicateString(
-          cx, js_undefined_str);  // Prevent users from seeing "(void 0)"
+      return DuplicateString(cx, "undefined");  // Prevent users from seeing
+                                                // "(void 0)"
     }
     fallback = ValueToSource(cx, v);
     if (!fallback) {
       return nullptr;
     }
   }

   return StringToNewUTF8CharsZ(cx, *fallback);

/js/src/vm/SharedStencil.h

--- b4cb88d106bd62b949ef92204c648c9379e065ca/js/src/vm/SharedStencil.h
+++ 7d89a3d4f78eaa57e2990bd0bbd0dbb81a07e3b4/js/src/vm/SharedStencil.h
@@ -18,16 +18,17 @@

 #include <stddef.h>  // size_t
 #include <stdint.h>  // uint8_t, uint16_t, uint32_t

 #include "frontend/SourceNotes.h"  // js::SrcNote
 #include "frontend/TypedIndex.h"   // js::frontend::TypedIndex

 #include "js/AllocPolicy.h"            // js::SystemAllocPolicy
+#include "js/ColumnNumber.h"           // JS::LimitedColumnNumberZeroOrigin
 #include "js/TypeDecls.h"              // JSContext,jsbytecode
 #include "js/UniquePtr.h"              // js::UniquePtr
 #include "js/Vector.h"                 // js::Vector
 #include "util/EnumFlags.h"            // js::EnumFlags
 #include "util/TrailingArray.h"        // js::TrailingArray
 #include "vm/GeneratorAndAsyncKind.h"  // GeneratorKind, FunctionAsyncKind
 #include "vm/StencilEnums.h"  // js::{TryNoteKind,ImmutableScriptFlagsEnum,MutableScriptFlagsEnum}

@@ -186,48 +187,50 @@ struct ScopeNote {
 // sourceStart position. Compilation options may specify the initial line and
 // column number.
 //
 // NOTE: Column number may saturate and must not be used as unique identifier.
 struct SourceExtent {
   SourceExtent() = default;

   SourceExtent(uint32_t sourceStart, uint32_t sourceEnd, uint32_t toStringStart,
-               uint32_t toStringEnd, uint32_t lineno, uint32_t column)
+               uint32_t toStringEnd, uint32_t lineno,
+               JS::LimitedColumnNumberZeroOrigin column)
       : sourceStart(sourceStart),
         sourceEnd(sourceEnd),
         toStringStart(toStringStart),
         toStringEnd(toStringEnd),
         lineno(lineno),
         column(column) {}

   static SourceExtent makeGlobalExtent(uint32_t len) {
-    return SourceExtent(0, len, 0, len, 1, 0);
+    return SourceExtent(0, len, 0, len, 1,
+                        JS::LimitedColumnNumberZeroOrigin::zero());
   }

-  static SourceExtent makeGlobalExtent(uint32_t len, uint32_t lineno,
-                                       uint32_t column) {
+  static SourceExtent makeGlobalExtent(
+      uint32_t len, uint32_t lineno, JS::LimitedColumnNumberZeroOrigin column) {
     return SourceExtent(0, len, 0, len, lineno, column);
   }

   // FunctionKey is an encoded position of a function within the source text
   // that is unique and reproducible.
   using FunctionKey = uint32_t;
   static constexpr FunctionKey NullFunctionKey = 0;

   uint32_t sourceStart = 0;
   uint32_t sourceEnd = 0;
   uint32_t toStringStart = 0;
   uint32_t toStringEnd = 0;

   // Line and column of |sourceStart_| position.
   // Line number (1-origin).
   uint32_t lineno = 1;
-  // Column number in UTF-16 code units (0-origin).
-  uint32_t column = 0;
+  // Column number in UTF-16 code units.
+  JS::LimitedColumnNumberZeroOrigin column;

   FunctionKey toFunctionKey() const {
     // In eval("x=>1"), the arrow function will have a sourceStart of 0 which
     // conflicts with the NullFunctionKey, so shift all keys by 1 instead.
     auto result = sourceStart + 1;
     MOZ_ASSERT(result != NullFunctionKey);
     return result;
   }