Skip to content

Commit 1b24ca2

Browse files
neildharfacebook-github-bot
authored andcommitted
Reduce number of JSObject direct slots to 5
Summary: The previous changes shave 4 bytes off the size of objects. However, due to heap alignment, we need to shrink `JSObject` by 8 bytes in order to decrease its actual size after alignment. We can do that by removing a direct property slot. Reviewed By: dulinriley Differential Revision: D28526281 fbshipit-source-id: 408d80cfebbf63c3112345099940e01cda450ae1
1 parent f926135 commit 1b24ca2

2 files changed

Lines changed: 6 additions & 3 deletions

File tree

include/hermes/VM/JSObject.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -390,7 +390,7 @@ class JSObject : public GCCell {
390390
static const PropStorage::size_type NAMED_PROPERTY_SLOTS = 0;
391391

392392
/// Number of property slots allocated directly inside the object.
393-
static const PropStorage::size_type DIRECT_PROPERTY_SLOTS = 6;
393+
static const PropStorage::size_type DIRECT_PROPERTY_SLOTS = 5;
394394

395395
static bool classof(const GCCell *cell) {
396396
return kindInRange(
@@ -1558,6 +1558,10 @@ constexpr size_t JSObject::cellSizeJSObject() {
15581558
directPropsOffset() +
15591559
sizeof(GCSmallHermesValue) * DIRECT_PROPERTY_SLOTS,
15601560
"unexpected padding");
1561+
static_assert(
1562+
heapAlignSize(sizeof(JSObjectAndDirectProps)) ==
1563+
sizeof(JSObjectAndDirectProps),
1564+
"Wasted direct slot due to alignment");
15611565
return sizeof(JSObjectAndDirectProps);
15621566
}
15631567

lib/VM/JSObject.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,7 @@ void ObjectBuildMeta(const GCCell *cell, Metadata::Builder &mb) {
6262
"directProp1",
6363
"directProp2",
6464
"directProp3",
65-
"directProp4",
66-
"directProp5"};
65+
"directProp4"};
6766
for (unsigned i = mb.getJSObjectOverlapSlots();
6867
i < JSObject::DIRECT_PROPERTY_SLOTS;
6968
++i) {

0 commit comments

Comments
 (0)