Bug 1541684, part 4 - Remove nsXPCWrappedJSClass:mDescriptors. r=nika

This field now just caches the IsReflectable() field from the method
info, so get rid of it.

Differential Revision: https://phabricator.services.mozilla.com/D26071

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Andrew McCreight 2019-04-04 21:01:26 +00:00
parent 98dd357c68
commit 1a6c8f3740
2 changed files with 6 additions and 43 deletions

View File

@ -33,9 +33,6 @@ using namespace mozilla::dom;
NS_IMPL_ISUPPORTS(nsXPCWrappedJSClass, nsIXPCWrappedJSClass)
// the value of this variable is never used - we use its address as a sentinel
static uint32_t zero_methods_descriptor;
bool AutoScriptEvaluate::StartEvaluating(HandleObject scope) {
MOZ_ASSERT(!mEvaluated,
"AutoScriptEvaluate::Evaluate should only be called once");
@ -112,9 +109,6 @@ already_AddRefed<nsXPCWrappedJSClass> nsXPCWrappedJSClass::GetNewOrUsed(
if (info) {
if (!info->IsBuiltinClass() && nsXPConnect::IsISupportsDescendant(info)) {
clasp = new nsXPCWrappedJSClass(info);
if (!clasp->mDescriptors) {
clasp = nullptr;
}
}
}
}
@ -122,32 +116,11 @@ already_AddRefed<nsXPCWrappedJSClass> nsXPCWrappedJSClass::GetNewOrUsed(
}
nsXPCWrappedJSClass::nsXPCWrappedJSClass(const nsXPTInterfaceInfo* aInfo)
: mInfo(aInfo), mDescriptors(nullptr) {
: mInfo(aInfo) {
XPCJSRuntime::Get()->GetWrappedJSClassMap()->Add(this);
uint16_t methodCount = mInfo->MethodCount();
if (methodCount) {
int wordCount = (methodCount / 32) + 1;
if (nullptr != (mDescriptors = new uint32_t[wordCount])) {
int i;
// init flags to 0;
for (i = wordCount - 1; i >= 0; i--) {
mDescriptors[i] = 0;
}
for (i = 0; i < methodCount; i++) {
SetReflectable(i, mInfo->Method(i).IsReflectable());
}
}
} else {
mDescriptors = &zero_methods_descriptor;
}
}
nsXPCWrappedJSClass::~nsXPCWrappedJSClass() {
if (mDescriptors && mDescriptors != &zero_methods_descriptor) {
delete[] mDescriptors;
}
XPCJSRuntime::Get()->GetWrappedJSClassMap()->Remove(this);
}
@ -799,7 +772,7 @@ nsXPCWrappedJSClass::CallMethod(nsXPCWrappedJS* wrapper, uint16_t methodIndex,
JSContext* cx = ccx.GetJSContext();
if (!cx || !IsReflectable(methodIndex)) {
if (!cx || !info->IsReflectable()) {
return NS_ERROR_FAILURE;
}
@ -1153,12 +1126,13 @@ nsXPCWrappedJSClass::DebugDump(int16_t depth) {
XPC_LOG_ALWAYS(("ConstantCount = %d", mInfo->ConstantCount()));
XPC_LOG_OUTDENT();
}
XPC_LOG_ALWAYS(("mDescriptors @ %p count = %d", mDescriptors, methodCount));
if (depth && mDescriptors && methodCount) {
XPC_LOG_ALWAYS(("method count = %d", methodCount));
if (depth && methodCount) {
depth--;
XPC_LOG_INDENT();
for (uint16_t i = 0; i < methodCount; i++) {
XPC_LOG_ALWAYS(("Method %d is %s%s", i, IsReflectable(i) ? "" : " NOT ",
XPC_LOG_ALWAYS(("Method %d is %s%s", i,
mInfo->Method(i).IsReflectable() ? "" : " NOT ",
"reflectable"));
}
XPC_LOG_OUTDENT();

View File

@ -1646,16 +1646,6 @@ class nsXPCWrappedJSClass final : public nsIXPCWrappedJSClass {
nsXPCWrappedJSClass() = delete;
nsXPCWrappedJSClass(const nsXPTInterfaceInfo* aInfo);
bool IsReflectable(uint16_t i) const {
return (bool)(mDescriptors[i / 32] & (1U << (i % 32)));
}
void SetReflectable(uint16_t i, bool b) {
if (b)
mDescriptors[i / 32] |= (1U << (i % 32));
else
mDescriptors[i / 32] &= ~(1U << (i % 32));
}
bool GetArraySizeFromParam(const nsXPTMethodInfo* method,
const nsXPTType& type, nsXPTCMiniVariant* params,
uint32_t* result) const;
@ -1670,7 +1660,6 @@ class nsXPCWrappedJSClass final : public nsIXPCWrappedJSClass {
private:
const nsXPTInterfaceInfo* mInfo;
uint32_t* mDescriptors;
};
/*************************/