Bug 1760627 - Strengthen assertions, remove dead code, fix comments. r=yury

Differential Revision: https://phabricator.services.mozilla.com/D141748
This commit is contained in:
Lars T Hansen 2022-03-31 06:23:16 +00:00
parent 3658a9b9b0
commit 2d6e3e7034
5 changed files with 12 additions and 24 deletions

View File

@ -41,7 +41,8 @@ DebugState::DebugState(const Code& code, const Module& module)
module_(&module),
enterFrameTrapsEnabled_(false),
enterAndLeaveFrameTrapsCounter_(0) {
MOZ_ASSERT(code.metadata().debugEnabled);
MOZ_RELEASE_ASSERT(code.metadata().debugEnabled);
MOZ_RELEASE_ASSERT(code.hasTier(Tier::Debug));
}
void DebugState::trace(JSTracer* trc) {

View File

@ -84,9 +84,7 @@ class DebugState {
const SharedCode code_;
const SharedModule module_;
// State maintained when debugging is enabled. In this case, the Code is
// not actually shared, but is referenced uniquely by the instance that is
// being debugged.
// State maintained when debugging is enabled.
bool enterFrameTrapsEnabled_;
uint32_t enterAndLeaveFrameTrapsCounter_;

View File

@ -56,9 +56,7 @@ struct TagDesc;
// direct reference to its source Module which allows a Module to be destroyed
// while it still has live Instances.
//
// The instance's code may be shared among multiple instances provided none of
// those instances are being debugged. Instances that are being debugged own
// their code.
// The instance's code may be shared among multiple instances.
//
// An Instance is also known as a 'TlsData'. They used to be separate objects,
// but have now been unified. Extant references to 'TlsData' will be cleaned

View File

@ -300,14 +300,10 @@ void Module::serialize(const LinkData& linkData, uint8_t* begin,
}
/* static */
MutableModule Module::deserialize(const uint8_t* begin, size_t size,
Metadata* maybeMetadata) {
MutableMetadata metadata(maybeMetadata);
MutableModule Module::deserialize(const uint8_t* begin, size_t size) {
MutableMetadata metadata = js_new<Metadata>();
if (!metadata) {
metadata = js_new<Metadata>();
if (!metadata) {
return nullptr;
}
return nullptr;
}
const uint8_t* cursor = begin;
@ -368,7 +364,7 @@ MutableModule Module::deserialize(const uint8_t* begin, size_t size,
}
MOZ_RELEASE_ASSERT(cursor == begin + size);
MOZ_RELEASE_ASSERT(!!maybeMetadata == code->metadata().isAsmJS());
MOZ_RELEASE_ASSERT(!code->metadata().isAsmJS());
if (metadata->nameCustomSectionIndex) {
metadata->namePayload =

View File

@ -72,16 +72,12 @@ struct ImportValues {
// operations: instantiation, tiered compilation, serialization. A Module can be
// instantiated any number of times to produce new Instance objects. A Module
// can have a single tier-2 task initiated to augment a Module's code with a
// higher tier. A Module can have its optimized code serialized at any point
// higher tier. A Module can have its optimized code serialized at any point
// where the LinkData is also available, which is primarily (1) at the end of
// module generation, (2) at the end of tier-2 compilation.
//
// Fully linked-and-instantiated code (represented by Code and its owned
// ModuleSegment) can be shared between instances, provided none of those
// instances are being debugged. If patchable code is needed then each instance
// must have its own Code. Module eagerly creates a new Code and gives it to the
// first instance; it then instantiates new Code objects from a copy of the
// unlinked code that it keeps around for that purpose.
// Fully linked-and-instantiated code (represented by SharedCode and its owned
// ModuleSegment) can be shared between instances.
class Module : public JS::WasmModule {
const SharedCode code_;
@ -194,8 +190,7 @@ class Module : public JS::WasmModule {
void serialize(const LinkData& linkData, uint8_t* begin, size_t size) const;
void serialize(const LinkData& linkData,
JS::OptimizedEncodingListener& listener) const;
static RefPtr<Module> deserialize(const uint8_t* begin, size_t size,
Metadata* maybeMetadata = nullptr);
static RefPtr<Module> deserialize(const uint8_t* begin, size_t size);
bool loggingDeserialized() const { return loggingDeserialized_; }
// JS API and JS::WasmModule implementation: