Skip to content

Commit

Permalink
Bug 1646378: Refactor CallFlags constructors r=jandem
Browse files Browse the repository at this point in the history
In a later patch it will be useful to be able to declare a CallFlags and give it a value later.

Differential Revision: https://phabricator.services.mozilla.com/D81798
  • Loading branch information
iainireland committed Jul 2, 2020
1 parent 607a7c8 commit 20a99e4
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions js/src/jit/CacheIR.h
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,7 @@ class StubField {
class CallFlags {
public:
enum ArgFormat : uint8_t {
Unknown,
Standard,
Spread,
FunCall,
Expand All @@ -277,12 +278,12 @@ class CallFlags {
LastArgFormat = FunApplyArray
};

CallFlags() = default;
explicit CallFlags(ArgFormat format) : argFormat_(format) {}
CallFlags(bool isConstructing, bool isSpread, bool isSameRealm = false)
: argFormat_(isSpread ? Spread : Standard),
isConstructing_(isConstructing),
isSameRealm_(isSameRealm) {}
explicit CallFlags(ArgFormat format)
: argFormat_(format), isConstructing_(false), isSameRealm_(false) {}

ArgFormat getArgFormat() const { return argFormat_; }
bool isConstructing() const {
Expand All @@ -294,6 +295,7 @@ class CallFlags {

uint8_t toByte() const {
// See CacheIRReader::callFlags()
MOZ_ASSERT(argFormat_ != ArgFormat::Unknown);
uint8_t value = getArgFormat();
if (isConstructing()) {
value |= CallFlags::IsConstructing;
Expand All @@ -305,9 +307,9 @@ class CallFlags {
}

private:
ArgFormat argFormat_;
bool isConstructing_;
bool isSameRealm_;
ArgFormat argFormat_ = ArgFormat::Unknown;
bool isConstructing_ = false;
bool isSameRealm_ = false;

// Used for encoding/decoding
static const uint8_t ArgFormatBits = 4;
Expand Down Expand Up @@ -385,6 +387,7 @@ inline int32_t GetIndexOfArgument(ArgumentKind kind, CallFlags flags,
MOZ_ASSERT(kind <= ArgumentKind::Arg0);
*addArgc = false;
break;
case CallFlags::Unknown:
case CallFlags::FunCall:
case CallFlags::FunApplyArgs:
case CallFlags::FunApplyArray:
Expand Down Expand Up @@ -977,6 +980,8 @@ class MOZ_RAII CacheIRReader {
bool isConstructing = encoded & CallFlags::IsConstructing;
bool isSameRealm = encoded & CallFlags::IsSameRealm;
switch (format) {
case CallFlags::Unknown:
MOZ_CRASH("Unexpected call flags");
case CallFlags::Standard:
return CallFlags(isConstructing, /*isSpread =*/false, isSameRealm);
case CallFlags::Spread:
Expand Down

0 comments on commit 20a99e4

Please sign in to comment.