Bug 1485499 - Reduce size of js::Symbol r=sfink
authorTed Campbell <tcampbell@mozilla.com>
Thu, 23 Aug 2018 01:34:37 +0000
changeset 432950 2b2cc1983172a567ec81830d4cc530616eb2aa74
parent 432949 bb9759881cd75c2a0cba3510f35166d160074e79
child 432951 338526a054586a6e6b7c1ed4330c1029647a9572
child 432975 360245d5c4a8aca248ec13faf3647bf43d34fe11
push id34492
push usercbrindusan@mozilla.com
push dateThu, 23 Aug 2018 03:43:13 +0000
treeherdermozilla-central@338526a05458 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssfink
bugs1485499
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 1485499 - Reduce size of js::Symbol r=sfink MozReview-Commit-ID: 4mEHixUnUax Differential Revision: https://phabricator.services.mozilla.com/D4017
js/public/HeapAPI.h
js/src/jit-test/tests/heap-analysis/byteSize-of-symbol.js
js/src/vm/SymbolType.h
--- a/js/public/HeapAPI.h
+++ b/js/public/HeapAPI.h
@@ -234,17 +234,17 @@ struct String
 
     static bool isPermanentAtom(const js::gc::Cell* cell) {
         uint32_t flags = reinterpret_cast<const String*>(cell)->flags();
         return (flags & PERMANENT_ATOM_MASK) == PERMANENT_ATOM_FLAGS;
     }
 };
 
 struct Symbol {
-    uintptr_t reserved_;
+    void* _1;
     uint32_t code_;
     static const uint32_t WellKnownAPILimit = 0x80000000;
 
     static bool isWellKnownSymbol(const js::gc::Cell* cell) {
         return reinterpret_cast<const Symbol*>(cell)->code_ < WellKnownAPILimit;
     }
 };
 
--- a/js/src/jit-test/tests/heap-analysis/byteSize-of-symbol.js
+++ b/js/src/jit-test/tests/heap-analysis/byteSize-of-symbol.js
@@ -8,17 +8,17 @@
 
 // Run this test only if we're using jemalloc. Other malloc implementations
 // exhibit surprising behaviors. For example, 32-bit Fedora builds have
 // non-deterministic allocation sizes.
 var config = getBuildConfiguration();
 if (!config['moz-memory'])
   quit(0);
 
-const SIZE_OF_SYMBOL = config['pointer-byte-size'] == 4 ? 16 : 24;
+const SIZE_OF_SYMBOL = config['pointer-byte-size'] == 4 ? 16 : 16;
 
 // Without a description.
 assertEq(byteSize(Symbol()), SIZE_OF_SYMBOL);
 
 // With a description.
 assertEq(byteSize(Symbol("This is a relatively long description to be passed to "
                          + "Symbol() but it doesn't matter because it just gets "
                          + "interned as a JSAtom* anyways.")),
--- a/js/src/vm/SymbolType.h
+++ b/js/src/vm/SymbolType.h
@@ -27,44 +27,39 @@
 namespace js {
 class AutoAccessAtomsZone;
 } // namespace js
 
 namespace JS {
 
 class Symbol : public js::gc::TenuredCell
 {
-  protected:
-    // Reserved word for Cell GC invariants. This also ensures minimum
-    // structure size.
-    uintptr_t reserved_;
+  private:
+    // User description of symbol. Also meets gc::Cell requirements.
+    JSAtom* description_;
 
-  private:
     SymbolCode code_;
 
     // Each Symbol gets its own hash code so that we don't have to use
     // addresses as hash codes (a security hazard).
     js::HashNumber hash_;
 
-    JSAtom* description_;
 
     Symbol(SymbolCode code, js::HashNumber hash, JSAtom* desc)
-        : reserved_(0), code_(code), hash_(hash), description_(desc) { }
+        : description_(desc), code_(code), hash_(hash) { }
 
     Symbol(const Symbol&) = delete;
     void operator=(const Symbol&) = delete;
 
     static Symbol*
     newInternal(JSContext* cx, SymbolCode code, js::HashNumber hash, JSAtom* description);
 
     static void staticAsserts() {
         static_assert(uint32_t(SymbolCode::WellKnownAPILimit) == JS::shadow::Symbol::WellKnownAPILimit,
                       "JS::shadow::Symbol::WellKnownAPILimit must match SymbolCode::WellKnownAPILimit");
-        static_assert(offsetof(Symbol, reserved_) == offsetof(JS::shadow::Symbol, reserved_),
-                      "JS::shadow::Symbol::reserved_ offset must match SymbolCode::reserved_");
         static_assert(offsetof(Symbol, code_) == offsetof(JS::shadow::Symbol, code_),
                       "JS::shadow::Symbol::code_ offset must match SymbolCode::code_");
     }
 
   public:
     static Symbol* new_(JSContext* cx, SymbolCode code, JSString* description);
     static Symbol* for_(JSContext* cx, js::HandleString description);