Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/tools/wasm-metadce.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -389,7 +389,7 @@ struct MetaDCEGraph {
}

// A debug utility, prints out the graph
void dump() {
void dump() const {
std::cout << "=== graph ===\n";
for (auto root : roots) {
std::cout << "root: " << root << '\n';
Expand Down
6 changes: 3 additions & 3 deletions src/wasm-type.h
Original file line number Diff line number Diff line change
Expand Up @@ -768,7 +768,7 @@ struct TypeBuilder {
void grow(size_t n);

// The number of HeapType slots in the TypeBuilder.
size_t size();
size_t size() const;

// Sets the heap type at index `i`. May only be called before `build`.
void setHeapType(size_t i, Signature signature);
Expand Down Expand Up @@ -850,7 +850,7 @@ struct TypeBuilder {

// Gets the temporary HeapType at index `i`. This HeapType should only be used
// to construct temporary Types using the methods below.
HeapType getTempHeapType(size_t i);
HeapType getTempHeapType(size_t i) const;

// Gets a temporary type or heap type for use in initializing the
// TypeBuilder's HeapTypes. For Ref types, the HeapType may be a temporary
Expand Down Expand Up @@ -987,7 +987,7 @@ struct TypeBuilder {

Entry operator[](size_t i) { return Entry{*this, i}; }

void dump();
void dump() const;
};

// An iterable providing access to a heap type's descriptor chain, starting from
Expand Down
2 changes: 1 addition & 1 deletion src/wasm.h
Original file line number Diff line number Diff line change
Expand Up @@ -2283,7 +2283,7 @@ class Function : public Importable {
? columnNumber < other.columnNumber
: symbolNameIndex < other.symbolNameIndex;
}
void dump() {
void dump() const {
std::cerr << (symbolNameIndex ? symbolNameIndex.value() : -1) << " @ "
<< fileIndex << ":" << lineNumber << ":" << columnNumber
<< "\n";
Expand Down
10 changes: 5 additions & 5 deletions src/wasm/wasm-type.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2250,7 +2250,7 @@ struct TypeBuilder::Impl {
}
initialized = true;
}
HeapType get() { return HeapType(TypeID(info.get())); }
HeapType get() const { return HeapType(TypeID(info.get())); }
};

std::vector<Entry> entries;
Expand Down Expand Up @@ -2287,7 +2287,7 @@ void TypeBuilder::grow(size_t n) {
impl->entries.resize(size() + n);
}

size_t TypeBuilder::size() { return impl->entries.size(); }
size_t TypeBuilder::size() const { return impl->entries.size(); }

void TypeBuilder::setHeapType(size_t i, Signature signature) {
assert(i < size() && "index out of bounds");
Expand All @@ -2314,7 +2314,7 @@ void TypeBuilder::setHeapType(size_t i, Array array) {
impl->entries[i].set(array);
}

HeapType TypeBuilder::getTempHeapType(size_t i) {
HeapType TypeBuilder::getTempHeapType(size_t i) const {
assert(i < size() && "index out of bounds");
return impl->entries[i].get();
}
Expand Down Expand Up @@ -2719,10 +2719,10 @@ TypeBuilder::BuildResult TypeBuilder::build() {
return {results};
}

void TypeBuilder::dump() {
void TypeBuilder::dump() const {
std::vector<HeapType> types;
for (size_t i = 0; i < size(); ++i) {
types.push_back((*this)[i]);
types.push_back(getTempHeapType(i));
Copy link
Member

@kripken kripken Feb 10, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like this might be doing the same thing right now, but @tlively is the abstraction in the old code not preferable for some reason?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess operator[] is probably not const because you can mutate the TypeBuilder through the Entry it returns? Normally I would prefer using the Entry API (i.e. using the old code here), but I don't think it's worth the effort to add a whole new ConstEntry. This change LGTM.

}
IndexedTypeNameGenerator<DefaultTypeNameGenerator> print(types);

Expand Down
Loading