v8
V8 is Google’s open source high-performance JavaScript and WebAssembly engine, written in C++.
Loading...
Searching...
No Matches
abstract-code.h
Go to the documentation of this file.
1// Copyright 2023 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
5#ifndef V8_OBJECTS_ABSTRACT_CODE_H_
6#define V8_OBJECTS_ABSTRACT_CODE_H_
7
10
11// Has to be the last include (doesn't have include guards):
13
14namespace v8 {
15namespace internal {
16
17enum class Builtin;
18class BytecodeArray;
19class Code;
20
21// AbstractCode is a helper wrapper around {Code|BytecodeArray}.
22// TODO(jgruber): Consider removing this wrapper as it's mainly used for
23// profiling. Perhaps methods should be specialized instead of this wrapper
24// class?
25class AbstractCode : public HeapObject {
26 public:
27 int SourcePosition(Isolate* isolate, int offset);
28 int SourceStatementPosition(Isolate* isolate, int offset);
29
31 inline Address InstructionEnd(PtrComprCageBase cage_base);
32 inline int InstructionSize(PtrComprCageBase cage_base);
33
34 // Return the source position table for interpreter code.
37
39
40 // Returns the size of instructions and the metadata.
41 inline int SizeIncludingMetadata(PtrComprCageBase cage_base);
42
43 // Returns true if pc is inside this object's instructions.
44 inline bool contains(Isolate* isolate, Address pc);
45
46 // Returns the kind of the code.
47 inline CodeKind kind(PtrComprCageBase cage_base);
48
49 inline Builtin builtin_id(PtrComprCageBase cage_base);
50
51 inline bool has_instruction_stream(PtrComprCageBase cage_base);
52
53 inline Tagged<Code> GetCode();
55
56 private:
58};
59
60// Currently we must use full-pointer comparisons (instead of
61// compressed-pointer comparisons) when comparing AbstractCode. This is because
62// AbstractCode is either a Code or a BytecodeArray, and the latter lives in
63// trusted space (outside of the main pointer compression cage) while the
64// former still lives inside of the sandbox.
66constexpr bool operator==(const Tagged<AbstractCode> lhs,
67 const Tagged<AbstractCode> rhs) {
68 return lhs->ptr() == rhs->ptr();
69}
70
71} // namespace internal
72} // namespace v8
73
75
76#endif // V8_OBJECTS_ABSTRACT_CODE_H_
Builtins::Kind kind
Definition builtins.cc:40
Builtin builtin_id(PtrComprCageBase cage_base)
OBJECT_CONSTRUCTORS(AbstractCode, HeapObject)
int SourcePosition(Isolate *isolate, int offset)
Address InstructionEnd(PtrComprCageBase cage_base)
void DropStackFrameCache(PtrComprCageBase cage_base)
bool contains(Isolate *isolate, Address pc)
Address InstructionStart(PtrComprCageBase cage_base)
Tagged< BytecodeArray > GetBytecodeArray()
bool has_instruction_stream(PtrComprCageBase cage_base)
int SourceStatementPosition(Isolate *isolate, int offset)
int InstructionSize(PtrComprCageBase cage_base)
Tagged< TrustedByteArray > SourcePositionTable(Isolate *isolate, Tagged< SharedFunctionInfo > sfi)
int SizeIncludingMetadata(PtrComprCageBase cage_base)
V8_INLINE constexpr StorageType ptr() const
int32_t offset
bool operator==(ExternalReference lhs, ExternalReference rhs)
constexpr bool kAllCodeObjectsLiveInTrustedSpace