v8
V8 is Google’s open source high-performance JavaScript and WebAssembly engine, written in C++.
Loading...
Searching...
No Matches
baseline.cc
Go to the documentation of this file.
1// Copyright 2020 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
9
10#ifdef V8_ENABLE_SPARKPLUG
11
14#include "src/debug/debug.h"
18
19namespace v8 {
20namespace internal {
21
22bool CanCompileWithBaseline(Isolate* isolate,
25
26 // Check that baseline compiler is enabled.
27 if (!v8_flags.sparkplug) return false;
28
29 // Check that short builtin calls are enabled if needed.
30 if (v8_flags.sparkplug_needs_short_builtins &&
31 !isolate->is_short_builtin_calls_enabled()) {
32 return false;
33 }
34
35 // Check if we actually have bytecode.
36 if (!shared->HasBytecodeArray()) return false;
37
38 // Do not optimize when debugger needs to hook into every call.
39 if (isolate->debug()->needs_check_on_function_call()) return false;
40
41 if (auto debug_info = shared->TryGetDebugInfo(isolate)) {
42 // Functions with breakpoints have to stay interpreted.
43 if (debug_info.value()->HasBreakInfo()) return false;
44
45 // Functions with instrumented bytecode can't be baseline compiled since the
46 // baseline code's bytecode array pointer is immutable.
47 if (debug_info.value()->HasInstrumentedBytecodeArray()) return false;
48 }
49
50 // Do not baseline compile if function doesn't pass sparkplug_filter.
51 if (!shared->PassesFilter(v8_flags.sparkplug_filter)) return false;
52
53 return true;
54}
55
56MaybeDirectHandle<Code> GenerateBaselineCode(
57 Isolate* isolate, Handle<SharedFunctionInfo> shared) {
58 RCS_SCOPE(isolate, RuntimeCallCounterId::kCompileBaseline);
59 Handle<BytecodeArray> bytecode(shared->GetBytecodeArray(isolate), isolate);
60 LocalIsolate* local_isolate = isolate->main_thread_local_isolate();
61 baseline::BaselineCompiler compiler(local_isolate, shared, bytecode);
62 compiler.GenerateCode();
63 MaybeDirectHandle<Code> code = compiler.Build();
64 if (v8_flags.print_code && !code.is_null()) {
65 Print(*code.ToHandleChecked());
66 }
67 return code;
68}
69
70void EmitReturnBaseline(MacroAssembler* masm) {
72}
73
74} // namespace internal
75} // namespace v8
76
77#else
78
79namespace v8 {
80namespace internal {
81
84 return false;
85}
86
91
93
94} // namespace internal
95} // namespace v8
96
97#endif
interpreter::Bytecode bytecode
Definition builtins.cc:43
Handle< Code > code
PerThreadAssertScopeDebugOnly< false, SAFEPOINTS_ASSERT, HEAP_ALLOCATION_ASSERT > DisallowGarbageCollection
Tagged(T object) -> Tagged< T >
MaybeDirectHandle< Code > GenerateBaselineCode(Isolate *isolate, Handle< SharedFunctionInfo > shared)
Definition baseline.cc:87
void Print(Tagged< Object > obj)
Definition objects.h:774
void EmitReturnBaseline(MacroAssembler *masm)
Definition baseline.cc:92
V8_EXPORT_PRIVATE FlagValues v8_flags
bool CanCompileWithBaseline(Isolate *isolate, Tagged< SharedFunctionInfo > shared)
Definition baseline.cc:82
Local< T > Handle
#define RCS_SCOPE(...)