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 one more file have been updated (a58e820e) #311

Closed github-actions[bot] closed 1 year ago

github-actions[bot] commented 1 year ago

Files

Changesets

Diffs

/js/src/frontend/Stencil.cpp

--- ae1a4276e5d8927d106e0b300452044e39cd8c9d/js/src/frontend/Stencil.cpp
+++ 634f0d65b4adaa0cab542e211489728afb07d9ce/js/src/frontend/Stencil.cpp
@@ -4058,30 +4058,27 @@ void js::DumpFunctionFlagsItems(js::JSON
           json.value("BASESCRIPT");
           break;
         case FunctionFlags::Flags::SELFHOSTLAZY:
           json.value("SELFHOSTLAZY");
           break;
         case FunctionFlags::Flags::CONSTRUCTOR:
           json.value("CONSTRUCTOR");
           break;
-        case FunctionFlags::Flags::BOUND_FUN:
-          json.value("BOUND_FUN");
-          break;
         case FunctionFlags::Flags::LAMBDA:
           json.value("LAMBDA");
           break;
         case FunctionFlags::Flags::WASM_JIT_ENTRY:
           json.value("WASM_JIT_ENTRY");
           break;
         case FunctionFlags::Flags::HAS_INFERRED_NAME:
           json.value("HAS_INFERRED_NAME");
           break;
-        case FunctionFlags::Flags::ATOM_EXTRA_FLAG:
-          json.value("ATOM_EXTRA_FLAG");
+        case FunctionFlags::Flags::HAS_GUESSED_ATOM:
+          json.value("HAS_GUESSED_ATOM");
           break;
         case FunctionFlags::Flags::RESOLVED_NAME:
           json.value("RESOLVED_NAME");
           break;
         case FunctionFlags::Flags::RESOLVED_LENGTH:
           json.value("RESOLVED_LENGTH");
           break;
         case FunctionFlags::Flags::GHOST_FUNCTION:

/js/src/vm/SharedStencil.h

--- 868c43822c86c2edb307c0b3559627647e7b585d/js/src/vm/SharedStencil.h
+++ a58e820e6e401801eb89b64a661c36f51f56ac92/js/src/vm/SharedStencil.h
@@ -629,61 +629,72 @@ class alignas(uint32_t) ImmutableScriptD
 // Note: This is distinct from ImmutableScriptData because it contains a mutable
 //       ref-count while the ImmutableScriptData may live in read-only memory.
 //
 // Note: This is *not* directly inlined into the SharedImmutableScriptDataTable
 //       because scripts point directly to object and table resizing moves
 //       entries. This allows for fast finalization by decrementing the
 //       ref-count directly without doing a hash-table lookup.
 class SharedImmutableScriptData {
+  static constexpr uint32_t IsExternalFlag = 0x80000000;
+  static constexpr uint32_t RefCountBits = 0x7FFFFFFF;
+
   // This class is reference counted as follows: each pointer from a JSScript
   // counts as one reference plus there may be one reference from the shared
   // script data table.
-  mozilla::Atomic<uint32_t, mozilla::SequentiallyConsistent> refCount_ = {};
-
- public:
-  bool isExternal = false;
+  mozilla::Atomic<uint32_t, mozilla::SequentiallyConsistent>
+      refCountAndExternalFlags_ = {};

- private:
-  ImmutableScriptData* isd_ = nullptr;
   mozilla::HashNumber hash_;
+  ImmutableScriptData* isd_ = nullptr;

   // End of fields.

   friend class ::JSScript;
   friend class js::frontend::StencilXDR;

  public:
   SharedImmutableScriptData() = default;

   ~SharedImmutableScriptData() { reset(); }

  private:
+  bool isExternal() const { return refCountAndExternalFlags_ & IsExternalFlag; }
+  void setIsExternal() { refCountAndExternalFlags_ |= IsExternalFlag; }
+  void unsetIsExternal() { refCountAndExternalFlags_ &= RefCountBits; }
+
   void reset() {
-    if (isd_ && !isExternal) {
+    if (isd_ && !isExternal()) {
       js_delete(isd_);
     }
     isd_ = nullptr;
   }

   mozilla::HashNumber calculateHash() const {
     mozilla::Span<const uint8_t> immutableData = isd_->immutableData();
     return mozilla::HashBytes(immutableData.data(), immutableData.size());
   }

  public:
   // Hash over the contents of SharedImmutableScriptData and its
   // ImmutableScriptData.
   struct Hasher;

-  uint32_t refCount() const { return refCount_; }
-  void AddRef() { refCount_++; }
+  uint32_t refCount() const { return refCountAndExternalFlags_ & RefCountBits; }
+  void AddRef() { refCountAndExternalFlags_++; }
+
+ private:
+  uint32_t decrementRef() {
+    MOZ_ASSERT(refCount() != 0);
+    return --refCountAndExternalFlags_ & RefCountBits;
+  }
+
+ public:
   void Release() {
-    MOZ_ASSERT(refCount_ != 0);
-    uint32_t remain = --refCount_;
+    uint32_t remain = decrementRef();
     if (remain == 0) {
       reset();
       js_free(this);
     }
   }

   static constexpr size_t offsetOfISD() {
     return offsetof(SharedImmutableScriptData, isd_);
@@ -692,17 +703,17 @@ class SharedImmutableScriptData {
  private:
   static SharedImmutableScriptData* create(FrontendContext* fc);

  public:
   static SharedImmutableScriptData* createWith(
       FrontendContext* fc, js::UniquePtr<ImmutableScriptData>&& isd);

   size_t sizeOfIncludingThis(mozilla::MallocSizeOf mallocSizeOf) {
-    size_t isdSize = isExternal ? 0 : mallocSizeOf(isd_);
+    size_t isdSize = isExternal() ? 0 : mallocSizeOf(isd_);
     return mallocSizeOf(this) + isdSize;
   }

   // SharedImmutableScriptData has trailing data so isn't copyable or movable.
   SharedImmutableScriptData(const SharedImmutableScriptData&) = delete;
   SharedImmutableScriptData& operator=(const SharedImmutableScriptData&) =
       delete;

@@ -713,43 +724,43 @@ class SharedImmutableScriptData {
   uint32_t nfixed() const { return isd_->nfixed; }

   ImmutableScriptData* get() { return isd_; }
   mozilla::HashNumber hash() const { return hash_; }

   void setOwn(js::UniquePtr<ImmutableScriptData>&& isd) {
     MOZ_ASSERT(!isd_);
     isd_ = isd.release();
-    isExternal = false;
+    unsetIsExternal();

     hash_ = calculateHash();
   }

   void setOwn(js::UniquePtr<ImmutableScriptData>&& isd,
               mozilla::HashNumber hash) {
     MOZ_ASSERT(!isd_);
     isd_ = isd.release();
-    isExternal = false;
+    unsetIsExternal();

     MOZ_ASSERT(hash == calculateHash());
     hash_ = hash;
   }

   void setExternal(ImmutableScriptData* isd) {
     MOZ_ASSERT(!isd_);
     isd_ = isd;
-    isExternal = true;
+    setIsExternal();

     hash_ = calculateHash();
   }

   void setExternal(ImmutableScriptData* isd, mozilla::HashNumber hash) {
     MOZ_ASSERT(!isd_);
     isd_ = isd;
-    isExternal = true;
+    setIsExternal();

     MOZ_ASSERT(hash == calculateHash());
     hash_ = hash;
   }
 };

 // Matches SharedImmutableScriptData objects that have the same atoms as well as
 // contain the same bytes in their ImmutableScriptData.