mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-28 07:13:20 +00:00
Bug 1460341 - Give jsid a constructor that initializes it to a void id. r=jonco,bz
This commit is contained in:
parent
466626da16
commit
d660ad143b
@ -194,6 +194,10 @@ struct PropertyInfo {
|
||||
uint32_t prefIndex: NUM_BITS_PROPERTY_INFO_PREF_INDEX;
|
||||
// The index to the corresponding spec in Duo.mPrefables[prefIndex].specs[].
|
||||
uint32_t specIndex: NUM_BITS_PROPERTY_INFO_SPEC_INDEX;
|
||||
|
||||
// Note: the default constructor is not constexpr because of the bit fields,
|
||||
// so we need this one.
|
||||
constexpr PropertyInfo() : id(), type(0), prefIndex(0), specIndex(0) {}
|
||||
};
|
||||
|
||||
static_assert(ePropertyTypeCount <= 1ull << NUM_BITS_PROPERTY_INFO_TYPE,
|
||||
|
@ -27,20 +27,29 @@
|
||||
#include "js/TypeDecls.h"
|
||||
#include "js/Utility.h"
|
||||
|
||||
struct jsid
|
||||
{
|
||||
size_t asBits;
|
||||
bool operator==(const jsid& rhs) const { return asBits == rhs.asBits; }
|
||||
bool operator!=(const jsid& rhs) const { return asBits != rhs.asBits; }
|
||||
} JS_HAZ_GC_POINTER;
|
||||
#define JSID_BITS(id) (id.asBits)
|
||||
|
||||
#define JSID_TYPE_STRING 0x0
|
||||
#define JSID_TYPE_INT 0x1
|
||||
#define JSID_TYPE_VOID 0x2
|
||||
#define JSID_TYPE_SYMBOL 0x4
|
||||
#define JSID_TYPE_MASK 0x7
|
||||
|
||||
struct jsid
|
||||
{
|
||||
size_t asBits;
|
||||
|
||||
constexpr jsid() : asBits(JSID_TYPE_VOID) {}
|
||||
|
||||
static constexpr jsid fromRawBits(size_t bits) {
|
||||
jsid id;
|
||||
id.asBits = bits;
|
||||
return id;
|
||||
}
|
||||
|
||||
bool operator==(const jsid& rhs) const { return asBits == rhs.asBits; }
|
||||
bool operator!=(const jsid& rhs) const { return asBits != rhs.asBits; }
|
||||
} JS_HAZ_GC_POINTER;
|
||||
#define JSID_BITS(id) (id.asBits)
|
||||
|
||||
// Avoid using canonical 'id' for jsid parameters since this is a magic word in
|
||||
// Objective-C++ which, apparently, wants to be able to #include jsapi.h.
|
||||
#define id iden
|
||||
@ -156,7 +165,7 @@ JSID_IS_EMPTY(const jsid id)
|
||||
return (size_t)JSID_BITS(id) == JSID_TYPE_SYMBOL;
|
||||
}
|
||||
|
||||
constexpr const jsid JSID_VOID = { size_t(JSID_TYPE_VOID) };
|
||||
constexpr const jsid JSID_VOID;
|
||||
extern JS_PUBLIC_DATA(const jsid) JSID_EMPTY;
|
||||
|
||||
extern JS_PUBLIC_DATA(const JS::HandleId) JSID_VOIDHANDLE;
|
||||
|
@ -924,7 +924,7 @@ CacheIRWriter::copyStubData(uint8_t* dest) const
|
||||
InitGCPtr<JSString*>(destWords, field.asWord());
|
||||
break;
|
||||
case StubField::Type::Id:
|
||||
InitGCPtr<jsid>(destWords, field.asWord());
|
||||
AsGCPtr<jsid>(destWords)->init(jsid::fromRawBits(field.asWord()));
|
||||
break;
|
||||
case StubField::Type::RawInt64:
|
||||
case StubField::Type::DOMExpandoGeneration:
|
||||
|
@ -115,7 +115,7 @@ class MOZ_RAII IonCacheIRCompiler : public CacheIRCompiler
|
||||
return (const void*)readStubWord(offset, StubField::Type::RawWord);
|
||||
}
|
||||
jsid idStubField(uint32_t offset) {
|
||||
return mozilla::BitwiseCast<jsid>(readStubWord(offset, StubField::Type::Id));
|
||||
return jsid::fromRawBits(readStubWord(offset, StubField::Type::Id));
|
||||
}
|
||||
template <typename T>
|
||||
T rawWordStubField(uint32_t offset) {
|
||||
|
@ -7,10 +7,9 @@
|
||||
#include "js/Id.h"
|
||||
#include "js/RootingAPI.h"
|
||||
|
||||
const jsid JSID_EMPTY = { size_t(JSID_TYPE_SYMBOL) };
|
||||
const jsid JSID_EMPTY = jsid::fromRawBits(size_t(JSID_TYPE_SYMBOL));
|
||||
|
||||
static const jsid voidIdValue = JSID_VOID;
|
||||
static const jsid emptyIdValue = JSID_EMPTY;
|
||||
const JS::HandleId JSID_VOIDHANDLE = JS::HandleId::fromMarkedLocation(&voidIdValue);
|
||||
const JS::HandleId JSID_EMPTYHANDLE = JS::HandleId::fromMarkedLocation(&emptyIdValue);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user