Commit fe201c34 authored by Thibaud Michaud's avatar Thibaud Michaud Committed by Commit Bot

[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: 's avatarUlan Degenbaev <ulan@chromium.org>
Reviewed-by: 's avatarClemens Backes <clemensb@chromium.org>
Cr-Commit-Position: refs/heads/master@{#68294}
parent 5f072169
......@@ -8447,6 +8447,9 @@ class V8_EXPORT Isolate {
kInvalidatedTypedArraySpeciesLookupChainProtector = 105,
kWasmSimdOpcodes = 106,
kVarRedeclaredCatchBinding = 107,
kWasmRefTypes = 108,
kWasmBulkMemory = 109,
kWasmMultiValue = 110,
// If you add new values here, you'll also need to update Chromium's:
// web_feature.mojom, use_counter_callback.cc, and enums.xml. V8 changes to
......
......@@ -1191,6 +1191,9 @@ class WasmDecoder : public Decoder {
inline bool Complete(const byte* pc, CallFunctionImmediate<validate>& imm) {
if (!VALIDATE(imm.index < module_->functions.size())) return false;
imm.sig = module_->functions[imm.index].sig;
if (imm.sig->return_count() > 1) {
this->detected_->Add(kFeature_mv);
}
return true;
}
......@@ -1205,6 +1208,9 @@ class WasmDecoder : public Decoder {
inline bool Complete(const byte* pc, CallIndirectImmediate<validate>& imm) {
if (!VALIDATE(module_->has_signature(imm.sig_index))) return false;
imm.sig = module_->signature(imm.sig_index);
if (imm.sig->return_count() > 1) {
this->detected_->Add(kFeature_mv);
}
return true;
}
......@@ -1299,6 +1305,9 @@ class WasmDecoder : public Decoder {
if (imm.type != kWasmBottom) return true;
if (!VALIDATE(module_->has_signature(imm.sig_index))) return false;
imm.sig = module_->signature(imm.sig_index);
if (imm.sig->return_count() > 1) {
this->detected_->Add(kFeature_mv);
}
return true;
}
......@@ -3539,6 +3548,9 @@ class WasmFullDecoder : public WasmDecoder<validate> {
void DoReturn() {
size_t return_count = this->sig_->return_count();
if (return_count > 1) {
this->detected_->Add(kFeature_mv);
}
DCHECK_GE(stack_.size(), return_count);
Vector<Value> return_values =
return_count == 0
......
......@@ -634,11 +634,16 @@ void BackgroundCompileToken::PublishCode(
}
void UpdateFeatureUseCounts(Isolate* isolate, const WasmFeatures& detected) {
if (detected.has_threads()) {
isolate->CountUsage(v8::Isolate::UseCounterFeature::kWasmThreadOpcodes);
}
if (detected.has_simd()) {
isolate->CountUsage(v8::Isolate::UseCounterFeature::kWasmSimdOpcodes);
using Feature = v8::Isolate::UseCounterFeature;
constexpr static std::pair<WasmFeature, Feature> kUseCounters[] = {
{kFeature_reftypes, Feature::kWasmRefTypes},
{kFeature_bulk_memory, Feature::kWasmBulkMemory},
{kFeature_mv, Feature::kWasmMultiValue},
{kFeature_simd, Feature::kWasmSimdOpcodes},
{kFeature_threads, Feature::kWasmThreadOpcodes}};
for (auto& feature : kUseCounters) {
if (detected.contains(feature.first)) isolate->CountUsage(feature.second);
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment