v8
V8 is Google’s open source high-performance JavaScript and WebAssembly engine, written in C++.
Loading...
Searching...
No Matches
pending-optimization-table.cc
Go to the documentation of this file.
1// Copyright 2019 the V8 project authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
6
7#include "src/base/flags.h"
9#include "src/heap/heap-inl.h"
12
13namespace v8 {
14namespace internal {
15
17 Isolate* isolate, DirectHandle<JSFunction> function,
18 IsCompiledScope* is_compiled_scope) {
19 DCHECK(v8_flags.testing_d8_test_runner || v8_flags.allow_natives_syntax);
20 DCHECK(is_compiled_scope->is_compiled());
21 DCHECK(function->has_feedback_vector());
22
23 DirectHandle<SharedFunctionInfo> shared_info(function->shared(), isolate);
24
26 IsUndefined(isolate->heap()->functions_marked_for_manual_optimization())
27 ? ObjectHashTable::New(isolate, 1)
29 isolate->heap()
30 ->functions_marked_for_manual_optimization()),
31 isolate);
32 // We want to keep the function's BytecodeArray alive as bytecode flushing
33 // may otherwise delete it. However, we can't directly store a reference to
34 // the BytecodeArray inside the hash table as the BytecodeArray lives in
35 // trusted space (outside of the main pointer compression cage) when the
36 // sandbox is enabled. So instead, we reference the BytecodeArray's
37 // in-sandbox wrapper object.
38 table = ObjectHashTable::Put(
39 table, shared_info,
40 direct_handle(shared_info->GetBytecodeArray(isolate)->wrapper(),
41 isolate));
42 isolate->heap()->SetFunctionsMarkedForManualOptimization(*table);
43}
44
46 Isolate* isolate, Tagged<JSFunction> function) {
47 DCHECK(v8_flags.testing_d8_test_runner || v8_flags.allow_natives_syntax);
48
50 isolate->heap()->functions_marked_for_manual_optimization(), isolate);
52 IsUndefined(*table) ? ReadOnlyRoots(isolate).the_hole_value()
53 : Cast<ObjectHashTable>(table)->Lookup(
54 direct_handle(function->shared(), isolate)),
55 isolate);
56
57 return !IsTheHole(*entry);
58}
59
60} // namespace internal
61} // namespace v8
static void MarkFunctionForManualOptimization(Isolate *isolate, DirectHandle< JSFunction > function, IsCompiledScope *is_compiled_scope)
static bool IsMarkedForManualOptimization(Isolate *isolate, Tagged< JSFunction > function)
V8_INLINE IndirectHandle< T > handle(Tagged< T > object, Isolate *isolate)
Definition handles-inl.h:72
V8_INLINE DirectHandle< T > direct_handle(Tagged< T > object, Isolate *isolate)
V8_EXPORT_PRIVATE FlagValues v8_flags
Tagged< To > Cast(Tagged< From > value, const v8::SourceLocation &loc=INIT_SOURCE_LOCATION_IN_DEBUG)
Definition casting.h:150
#define DCHECK(condition)
Definition logging.h:482