Commit 45c878a6 authored by Clemens Backes's avatar Clemens Backes Committed by V8 LUCI CQ

[wasm] Refactor TransitiveTypeFeedbackProcessor

A minor refactoring to call a static method instead of just creating an
instance in order to do the work.
This also makes it easier to later add methods to process all feedback
before dumping profile information.

R=jkummerow@chromium.org

Bug: v8:13209
Change-Id: I157357753b3a1cff83df426660501c43959937b9
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3870468
Commit-Queue: Clemens Backes <clemensb@chromium.org>
Reviewed-by: 's avatarJakob Kummerow <jkummerow@chromium.org>
Cr-Commit-Position: refs/heads/main@{#82949}
parent e69fa726
...@@ -1284,21 +1284,30 @@ void ThrowLazyCompilationError(Isolate* isolate, ...@@ -1284,21 +1284,30 @@ void ThrowLazyCompilationError(Isolate* isolate,
class TransitiveTypeFeedbackProcessor { class TransitiveTypeFeedbackProcessor {
public: public:
static void Process(WasmInstanceObject instance, int func_index) {
TransitiveTypeFeedbackProcessor{instance, func_index}.ProcessQueue();
}
private:
TransitiveTypeFeedbackProcessor(WasmInstanceObject instance, int func_index) TransitiveTypeFeedbackProcessor(WasmInstanceObject instance, int func_index)
: instance_(instance), : instance_(instance),
module_(instance.module()), module_(instance.module()),
mutex_guard(&module_->type_feedback.mutex), mutex_guard(&module_->type_feedback.mutex),
feedback_for_function_(module_->type_feedback.feedback_for_function) { feedback_for_function_(module_->type_feedback.feedback_for_function) {
queue_.insert(func_index); queue_.insert(func_index);
}
~TransitiveTypeFeedbackProcessor() { DCHECK(queue_.empty()); }
void ProcessQueue() {
while (!queue_.empty()) { while (!queue_.empty()) {
auto next = queue_.cbegin(); auto next = queue_.cbegin();
Process(*next); ProcessFunction(*next);
queue_.erase(next); queue_.erase(next);
} }
} }
private: void ProcessFunction(int func_index);
void Process(int func_index);
void EnqueueCallees(const std::vector<CallSiteFeedback>& feedback) { void EnqueueCallees(const std::vector<CallSiteFeedback>& feedback) {
for (size_t i = 0; i < feedback.size(); i++) { for (size_t i = 0; i < feedback.size(); i++) {
...@@ -1405,7 +1414,7 @@ class FeedbackMaker { ...@@ -1405,7 +1414,7 @@ class FeedbackMaker {
int counts_cache_[kMaxPolymorphism]; int counts_cache_[kMaxPolymorphism];
}; };
void TransitiveTypeFeedbackProcessor::Process(int func_index) { void TransitiveTypeFeedbackProcessor::ProcessFunction(int func_index) {
int which_vector = declared_function_index(module_, func_index); int which_vector = declared_function_index(module_, func_index);
Object maybe_feedback = instance_.feedback_vectors().get(which_vector); Object maybe_feedback = instance_.feedback_vectors().get(which_vector);
if (!maybe_feedback.IsFixedArray()) return; if (!maybe_feedback.IsFixedArray()) return;
...@@ -1480,7 +1489,7 @@ void TriggerTierUp(WasmInstanceObject instance, int func_index) { ...@@ -1480,7 +1489,7 @@ void TriggerTierUp(WasmInstanceObject instance, int func_index) {
// TODO(jkummerow): we could have collisions here if different instances // TODO(jkummerow): we could have collisions here if different instances
// of the same module have collected different feedback. If that ever // of the same module have collected different feedback. If that ever
// becomes a problem, figure out a solution. // becomes a problem, figure out a solution.
TransitiveTypeFeedbackProcessor process(instance, func_index); TransitiveTypeFeedbackProcessor::Process(instance, func_index);
} }
compilation_state->AddTopTierPriorityCompilationUnit(tiering_unit, priority); compilation_state->AddTopTierPriorityCompilationUnit(tiering_unit, priority);
...@@ -1489,7 +1498,7 @@ void TriggerTierUp(WasmInstanceObject instance, int func_index) { ...@@ -1489,7 +1498,7 @@ void TriggerTierUp(WasmInstanceObject instance, int func_index) {
void TierUpNowForTesting(Isolate* isolate, WasmInstanceObject instance, void TierUpNowForTesting(Isolate* isolate, WasmInstanceObject instance,
int func_index) { int func_index) {
if (v8_flags.wasm_speculative_inlining) { if (v8_flags.wasm_speculative_inlining) {
TransitiveTypeFeedbackProcessor process(instance, func_index); TransitiveTypeFeedbackProcessor::Process(instance, func_index);
} }
auto* native_module = instance.module_object().native_module(); auto* native_module = instance.module_object().native_module();
wasm::GetWasmEngine()->CompileFunction(isolate, native_module, func_index, wasm::GetWasmEngine()->CompileFunction(isolate, native_module, func_index,
......
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