Skip to content

Commit fe201c3

Browse files
thibaudmichaudCommit Bot
authored andcommitted
[wasm] Add use counters for anyref, bulk memory and multi value
R=clemensb@chromium.org Bug: v8:10549 Change-Id: I516d35b0810ce147b568c1b8e32eb084753614e8 Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2235697 Commit-Queue: Thibaud Michaud <thibaudm@chromium.org> Reviewed-by: Ulan Degenbaev <ulan@chromium.org> Reviewed-by: Clemens Backes <clemensb@chromium.org> Cr-Commit-Position: refs/heads/master@{#68294}
1 parent 5f07216 commit fe201c3

3 files changed

Lines changed: 25 additions & 5 deletions

File tree

include/v8.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8447,6 +8447,9 @@ class V8_EXPORT Isolate {
84478447
kInvalidatedTypedArraySpeciesLookupChainProtector = 105,
84488448
kWasmSimdOpcodes = 106,
84498449
kVarRedeclaredCatchBinding = 107,
8450+
kWasmRefTypes = 108,
8451+
kWasmBulkMemory = 109,
8452+
kWasmMultiValue = 110,
84508453

84518454
// If you add new values here, you'll also need to update Chromium's:
84528455
// web_feature.mojom, use_counter_callback.cc, and enums.xml. V8 changes to

src/wasm/function-body-decoder-impl.h

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1191,6 +1191,9 @@ class WasmDecoder : public Decoder {
11911191
inline bool Complete(const byte* pc, CallFunctionImmediate<validate>& imm) {
11921192
if (!VALIDATE(imm.index < module_->functions.size())) return false;
11931193
imm.sig = module_->functions[imm.index].sig;
1194+
if (imm.sig->return_count() > 1) {
1195+
this->detected_->Add(kFeature_mv);
1196+
}
11941197
return true;
11951198
}
11961199

@@ -1205,6 +1208,9 @@ class WasmDecoder : public Decoder {
12051208
inline bool Complete(const byte* pc, CallIndirectImmediate<validate>& imm) {
12061209
if (!VALIDATE(module_->has_signature(imm.sig_index))) return false;
12071210
imm.sig = module_->signature(imm.sig_index);
1211+
if (imm.sig->return_count() > 1) {
1212+
this->detected_->Add(kFeature_mv);
1213+
}
12081214
return true;
12091215
}
12101216

@@ -1299,6 +1305,9 @@ class WasmDecoder : public Decoder {
12991305
if (imm.type != kWasmBottom) return true;
13001306
if (!VALIDATE(module_->has_signature(imm.sig_index))) return false;
13011307
imm.sig = module_->signature(imm.sig_index);
1308+
if (imm.sig->return_count() > 1) {
1309+
this->detected_->Add(kFeature_mv);
1310+
}
13021311
return true;
13031312
}
13041313

@@ -3539,6 +3548,9 @@ class WasmFullDecoder : public WasmDecoder<validate> {
35393548

35403549
void DoReturn() {
35413550
size_t return_count = this->sig_->return_count();
3551+
if (return_count > 1) {
3552+
this->detected_->Add(kFeature_mv);
3553+
}
35423554
DCHECK_GE(stack_.size(), return_count);
35433555
Vector<Value> return_values =
35443556
return_count == 0

src/wasm/module-compiler.cc

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -634,11 +634,16 @@ void BackgroundCompileToken::PublishCode(
634634
}
635635

636636
void UpdateFeatureUseCounts(Isolate* isolate, const WasmFeatures& detected) {
637-
if (detected.has_threads()) {
638-
isolate->CountUsage(v8::Isolate::UseCounterFeature::kWasmThreadOpcodes);
639-
}
640-
if (detected.has_simd()) {
641-
isolate->CountUsage(v8::Isolate::UseCounterFeature::kWasmSimdOpcodes);
637+
using Feature = v8::Isolate::UseCounterFeature;
638+
constexpr static std::pair<WasmFeature, Feature> kUseCounters[] = {
639+
{kFeature_reftypes, Feature::kWasmRefTypes},
640+
{kFeature_bulk_memory, Feature::kWasmBulkMemory},
641+
{kFeature_mv, Feature::kWasmMultiValue},
642+
{kFeature_simd, Feature::kWasmSimdOpcodes},
643+
{kFeature_threads, Feature::kWasmThreadOpcodes}};
644+
645+
for (auto& feature : kUseCounters) {
646+
if (detected.contains(feature.first)) isolate->CountUsage(feature.second);
642647
}
643648
}
644649

0 commit comments

Comments
 (0)