Skip to content

Commit

Permalink
Bug 1836489 - Remove code and fieldTypes pointers from CacheIRStubInf…
Browse files Browse the repository at this point in the history
…o. r=iain

The CacheIR ops and stub field types are stored as trailing arrays, so we can
just compute these values.

Differential Revision: https://phabricator.services.mozilla.com/D179825
  • Loading branch information
jandem committed Jun 3, 2023
1 parent f43db44 commit 9421030
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 13 deletions.
2 changes: 1 addition & 1 deletion js/src/jit/CacheIRCompiler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1358,7 +1358,7 @@ CacheIRStubInfo* CacheIRStubInfo::New(CacheKind kind, ICStubEngine engine,
fieldTypes[numStubFields] = uint8_t(StubField::Type::Limit);

return new (p) CacheIRStubInfo(kind, engine, makesGCCalls, stubDataOffset,
codeStart, writer.codeLength(), fieldTypes);
writer.codeLength());
}

bool OperandLocation::operator==(const OperandLocation& other) const {
Expand Down
33 changes: 21 additions & 12 deletions js/src/jit/CacheIRCompiler.h
Original file line number Diff line number Diff line change
Expand Up @@ -1227,22 +1227,27 @@ class MOZ_RAII AutoAvailableFloatRegister {

// See the 'Sharing Baseline stub code' comment in CacheIR.h for a description
// of this class.
//
// CacheIRStubInfo has a trailing variable-length array of bytes. The memory
// layout is as follows:
//
// Item | Offset
// -----------------+--------------------------------------
// CacheIRStubInfo | 0
// CacheIR bytecode | sizeof(CacheIRStubInfo)
// Stub field types | sizeof(CacheIRStubInfo) + codeLength_
//
// The array of stub field types is terminated by StubField::Type::Limit.
class CacheIRStubInfo {
const uint8_t* code_;
const uint8_t* fieldTypes_;
uint32_t length_;

uint32_t codeLength_;
CacheKind kind_;
ICStubEngine engine_;
uint8_t stubDataOffset_;
bool makesGCCalls_;

CacheIRStubInfo(CacheKind kind, ICStubEngine engine, bool makesGCCalls,
uint32_t stubDataOffset, const uint8_t* code,
uint32_t codeLength, const uint8_t* fieldTypes)
: code_(code),
fieldTypes_(fieldTypes),
length_(codeLength),
uint32_t stubDataOffset, uint32_t codeLength)
: codeLength_(codeLength),
kind_(kind),
engine_(engine),
stubDataOffset_(stubDataOffset),
Expand All @@ -1261,14 +1266,18 @@ class CacheIRStubInfo {
ICStubEngine engine() const { return engine_; }
bool makesGCCalls() const { return makesGCCalls_; }

const uint8_t* code() const { return code_; }
uint32_t codeLength() const { return length_; }
const uint8_t* code() const {
return reinterpret_cast<const uint8_t*>(this) + sizeof(CacheIRStubInfo);
}
uint32_t codeLength() const { return codeLength_; }
uint32_t stubDataOffset() const { return stubDataOffset_; }

size_t stubDataSize() const;

StubField::Type fieldType(uint32_t i) const {
return (StubField::Type)fieldTypes_[i];
static_assert(sizeof(StubField::Type) == sizeof(uint8_t));
const uint8_t* fieldTypes = code() + codeLength_;
return static_cast<StubField::Type>(fieldTypes[i]);
}

static CacheIRStubInfo* New(CacheKind kind, ICStubEngine engine,
Expand Down

0 comments on commit 9421030

Please sign in to comment.