chromium/third_party/blink/renderer/bindings/core/v8/v8_compile_hints_producer.h

// Copyright 2023 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef THIRD_PARTY_BLINK_RENDERER_BINDINGS_CORE_V8_V8_COMPILE_HINTS_PRODUCER_H_
#define THIRD_PARTY_BLINK_RENDERER_BINDINGS_CORE_V8_V8_COMPILE_HINTS_PRODUCER_H_

#include "third_party/blink/renderer/bindings/buildflags.h"
#include "third_party/blink/renderer/platform/heap/garbage_collected.h"

#if BUILDFLAG(PRODUCE_V8_COMPILE_HINTS)

#include "third_party/blink/renderer/platform/heap/collection_support/heap_vector.h"
#include "third_party/blink/renderer/platform/heap/member.h"
#include "third_party/blink/renderer/platform/wtf/vector.h"
#include "v8/include/v8-traced-handle.h"
#include "v8/include/v8.h"

namespace blink {

class ExecutionContext;
class Frame;
class Page;
class ScriptState;

namespace v8_compile_hints {

/*
V8CrowdsourcedCompileHintsProducer gathers data about which JavaScript functions
are compiled and uploads it to UKM. On the server side, we construct a model
from this data and deliver it back to the users via OptimizationGuide (not yet
implemented).
*/
class V8CrowdsourcedCompileHintsProducer
    : public GarbageCollected<V8CrowdsourcedCompileHintsProducer> {};

}  // namespace v8_compile_hints
}  // namespace blink

#else

namespace blink {

class Page;

namespace v8_compile_hints {

// A minimal implementation for platforms which don't enable compile hints.
class V8CrowdsourcedCompileHintsProducer
    : public GarbageCollected<V8CrowdsourcedCompileHintsProducer> {
 public:
  explicit V8CrowdsourcedCompileHintsProducer(Page* page) {}

  V8CrowdsourcedCompileHintsProducer(
      const V8CrowdsourcedCompileHintsProducer&) = delete;
  V8CrowdsourcedCompileHintsProducer& operator=(
      const V8CrowdsourcedCompileHintsProducer&) = delete;

  void GenerateData() {}

  void Trace(Visitor* visitor) const {}

  bool MightGenerateData() const { return false; }

  void ClearData() {}
};

}  // namespace v8_compile_hints
}  // namespace blink

#endif  // BUILDFLAG(PRODUCE_V8_COMPILE_HINTS)

#endif  // THIRD_PARTY_BLINK_RENDERER_BINDINGS_CORE_V8_V8_COMPILE_HINTS_PRODUCER_H_