Skip to content

Commit 6bd147a

Browse files
committed
[Wasm] Ignore invalid value and provide warning in set_high_watermark() of hash tables.
1 parent 9cd21ef commit 6bd147a

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

src/backend/WasmAlgo.hpp

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -676,7 +676,11 @@ struct ChainedHashTable : HashTable
676676
/** Sets the high watermark, i.e. the fraction of occupied entries before growing the hash table is required, to
677677
* \p percentage. */
678678
void set_high_watermark(double percentage) override {
679-
M_insist(percentage >= 1.0, "using chained collisions the load factor should be at least 1");
679+
if (percentage < 1.0) {
680+
std::cerr << "warning: using chained collisions the load factor must be in [1,∞), ignore invalid value "
681+
<< percentage << std::endl;
682+
return;
683+
}
680684
high_watermark_percentage_ = percentage;
681685
update_high_watermark();
682686
}
@@ -812,7 +816,11 @@ struct OpenAddressingHashTableBase : HashTable
812816
/** Sets the high watermark, i.e. the fraction of occupied entries before growing the hash table is required, to
813817
* \p percentage. */
814818
void set_high_watermark(double percentage) override {
815-
M_insist(percentage >= 0.5 and percentage < 1.0, "using open addressing the load factor must be in [0.5,1)");
819+
if (percentage < 0.5 or percentage >= 1.0) {
820+
std::cerr << "warning: using open addressing the load factor must be in [0.5,1), ignore invalid value "
821+
<< percentage << std::endl;
822+
return;
823+
}
816824
high_watermark_percentage_ = percentage;
817825
update_high_watermark();
818826
}

0 commit comments

Comments
 (0)