chromium/third_party/blink/renderer/bindings/core/v8/v8_code_cache.cc

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

#include "third_party/blink/renderer/bindings/core/v8/v8_code_cache.h"

#include <optional>

#include "base/feature_list.h"
#include "base/metrics/histogram_functions.h"
#include "build/build_config.h"
#include "components/miracle_parameter/common/public/miracle_parameter.h"
#include "third_party/blink/public/common/features.h"
#include "third_party/blink/public/mojom/v8_cache_options.mojom-blink.h"
#include "third_party/blink/public/web/web_settings.h"
#include "third_party/blink/renderer/bindings/core/v8/module_record.h"
#include "third_party/blink/renderer/bindings/core/v8/referrer_script_info.h"
#include "third_party/blink/renderer/bindings/core/v8/v8_binding_for_core.h"
#include "third_party/blink/renderer/bindings/core/v8/v8_initializer.h"
#include "third_party/blink/renderer/core/inspector/inspector_trace_events.h"
#include "third_party/blink/renderer/core/probe/core_probes.h"
#include "third_party/blink/renderer/core/script/classic_script.h"
#include "third_party/blink/renderer/platform/bindings/script_state.h"
#include "third_party/blink/renderer/platform/instrumentation/histogram.h"
#include "third_party/blink/renderer/platform/instrumentation/tracing/trace_event.h"
#include "third_party/blink/renderer/platform/loader/fetch/cached_metadata.h"
#include "third_party/blink/renderer/platform/loader/fetch/code_cache_host.h"
#include "third_party/blink/renderer/platform/wtf/text/text_encoding.h"

namespace blink {

namespace {

BASE_FEATURE();

MIRACLE_PARAMETER_FOR_INT(GetV8CodeCacheHotHours,
                          kConfigurableV8CodeCacheHotHours,
                          "HotHours",
                          72)

enum CacheTagKind {};

static const int kCacheTagKindSize =;

static_assert;

uint32_t CacheTag(CacheTagKind kind, const String& encoding) {}

bool TimestampIsRecent(const CachedMetadata* cached_metadata) {}

// Flags that can be set in the CacheMetadata header, describing how the code
// cache data was produced so that the consumer can generate better trace
// messages.
enum class DetailFlags : uint64_t {};

V8CodeCache::GetMetadataType ReadGetMetadataType(
    const CachedMetadataHandler* cache_handler) {}

V8CodeCache::GetMetadataType ReadGetMetadataType(
    const CachedMetadata* cached_metadata,
    const String& encoding) {}

constexpr const char* kCacheGetHistogram =;
constexpr const char* kCacheSetHistogram =;

}  // namespace

// Check previously stored timestamp (either from the code cache or compile
// hints cache).
bool V8CodeCache::HasHotTimestamp(const CachedMetadataHandler* cache_handler) {}

bool V8CodeCache::HasHotTimestamp(const CachedMetadata& data,
                                  const String& encoding) {}

bool V8CodeCache::HasCodeCache(
    const CachedMetadataHandler* cache_handler,
    CachedMetadataHandler::GetCachedMetadataBehavior behavior) {}

bool V8CodeCache::HasCodeCache(const CachedMetadata& data,
                               const String& encoding) {}

bool V8CodeCache::HasCompileHints(
    const CachedMetadataHandler* cache_handler,
    CachedMetadataHandler::GetCachedMetadataBehavior behavior) {}

bool V8CodeCache::HasHotCompileHints(const CachedMetadata& data,
                                     const String& encoding) {}

std::unique_ptr<v8::ScriptCompiler::CachedData> V8CodeCache::CreateCachedData(
    const CachedMetadataHandler* cache_handler) {}

std::unique_ptr<v8::ScriptCompiler::CachedData> V8CodeCache::CreateCachedData(
    scoped_refptr<CachedMetadata> cached_metadata) {}

scoped_refptr<CachedMetadata> V8CodeCache::GetCachedMetadata(
    const CachedMetadataHandler* cache_handler,
    CachedMetadataHandler::GetCachedMetadataBehavior behavior) {}

scoped_refptr<CachedMetadata> V8CodeCache::GetCachedMetadataForCompileHints(
    const CachedMetadataHandler* cache_handler,
    CachedMetadataHandler::GetCachedMetadataBehavior behavior) {}

std::tuple<v8::ScriptCompiler::CompileOptions,
           V8CodeCache::ProduceCacheOptions,
           v8::ScriptCompiler::NoCacheReason>
V8CodeCache::GetCompileOptions(
    mojom::blink::V8CacheOptions cache_options,
    const ClassicScript& classic_script,
    bool might_generate_crowdsourced_compile_hints,
    bool can_use_crowdsourced_compile_hints,
    bool v8_compile_hints_magic_comment_runtime_enabled) {}

namespace {
v8::ScriptCompiler::CompileOptions MaybeAddCompileHintsMagic(
    v8::ScriptCompiler::CompileOptions compile_options,
    bool v8_compile_hints_magic_comment_runtime_enabled) {}

}  // namespace

std::tuple<v8::ScriptCompiler::CompileOptions,
           V8CodeCache::ProduceCacheOptions,
           v8::ScriptCompiler::NoCacheReason>
V8CodeCache::GetCompileOptions(
    mojom::blink::V8CacheOptions cache_options,
    const CachedMetadataHandler* cache_handler,
    size_t source_text_length,
    ScriptSourceLocationType source_location_type,
    const KURL& url,
    bool might_generate_crowdsourced_compile_hints,
    bool can_use_crowdsourced_compile_hints,
    bool v8_compile_hints_magic_comment_runtime_enabled) {}

bool V8CodeCache::IsFull(const CachedMetadata* metadata) {}

template <typename UnboundScript>
static void ProduceCacheInternal(
    v8::Isolate* isolate,
    CodeCacheHost* code_cache_host,
    v8::Local<UnboundScript> unbound_script,
    CachedMetadataHandler* cache_handler,
    size_t source_text_length,
    const KURL& source_url,
    const TextPosition& source_start_position,
    const char* trace_name,
    V8CodeCache::ProduceCacheOptions produce_cache_options) {}

void V8CodeCache::ProduceCache(v8::Isolate* isolate,
                               CodeCacheHost* code_cache_host,
                               v8::Local<v8::Script> script,
                               CachedMetadataHandler* cache_handler,
                               size_t source_text_length,
                               const KURL& source_url,
                               const TextPosition& source_start_position,
                               ProduceCacheOptions produce_cache_options) {}

void V8CodeCache::ProduceCache(v8::Isolate* isolate,
                               CodeCacheHost* code_cache_host,
                               ModuleRecordProduceCacheData* produce_cache_data,
                               size_t source_text_length,
                               const KURL& source_url,
                               const TextPosition& source_start_position) {}

uint32_t V8CodeCache::TagForCodeCache(
    const CachedMetadataHandler* cache_handler) {}

uint32_t V8CodeCache::TagForTimeStamp(
    const CachedMetadataHandler* cache_handler) {}

uint32_t V8CodeCache::TagForCompileHints(
    const CachedMetadataHandler* cache_handler) {}

// Store a timestamp to the cache as hint.
void V8CodeCache::SetCacheTimeStamp(CodeCacheHost* code_cache_host,
                                    CachedMetadataHandler* cache_handler) {}

uint64_t V8CodeCache::GetTimestamp() {}

// static
scoped_refptr<CachedMetadata> V8CodeCache::GenerateFullCodeCache(
    ScriptState* script_state,
    const String& script_string,
    const KURL& source_url,
    const WTF::TextEncoding& encoding,
    OpaqueMode opaque_mode) {}

void V8CodeCache::RecordCacheGetStatistics(
    const CachedMetadataHandler* cache_handler) {}

void V8CodeCache::RecordCacheGetStatistics(
    const CachedMetadata* cached_metadata,
    const String& encoding) {}

void V8CodeCache::RecordCacheGetStatistics(
    V8CodeCache::GetMetadataType metadata_type) {}

void V8CodeCache::RecordCacheSetStatistics(
    V8CodeCache::SetMetadataType metadata_type) {}

}  // namespace blink