v8
V8 is Google’s open source high-performance JavaScript and WebAssembly engine, written in C++.
Loading...
Searching...
No Matches
constants-table-builder.h
Go to the documentation of this file.
1
// Copyright 2018 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_BUILTINS_CONSTANTS_TABLE_BUILDER_H_
6
#define V8_BUILTINS_CONSTANTS_TABLE_BUILDER_H_
7
8
#include "
src/base/macros.h
"
9
#include "
src/utils/allocation.h
"
10
#include "
src/utils/identity-map.h
"
11
#include "
src/handles/handles.h
"
12
13
namespace
v8
{
14
namespace
internal
{
15
16
class
Isolate;
17
class
Object;
18
class
ByteArray;
19
20
// Utility class to build the builtins constants table and store it on the root
21
// list. The constants table contains constants used by builtins, and is there
22
// to avoid directly embedding them into code objects, which would not be
23
// possible for off-heap (and thus immutable) code objects.
24
class
BuiltinsConstantsTableBuilder
final {
25
public
:
26
explicit
BuiltinsConstantsTableBuilder
(
Isolate
* isolate);
27
28
BuiltinsConstantsTableBuilder
(
const
BuiltinsConstantsTableBuilder
&) =
delete
;
29
BuiltinsConstantsTableBuilder
&
operator=
(
30
const
BuiltinsConstantsTableBuilder
&) =
delete
;
31
32
// Returns the index within the builtins constants table for the given
33
// object, possibly adding the object to the table. Objects are deduplicated.
34
uint32_t
AddObject
(
Handle<Object>
object
);
35
36
// Self-references during code generation start out by referencing a handle
37
// with a temporary dummy object. Once the final InstructionStream object
38
// exists, such entries in the constants map must be patched up.
39
void
PatchSelfReference
(
DirectHandle<Object>
self_reference,
40
Handle<InstructionStream>
code_object);
41
42
// References to the array that stores basic block usage counters start out as
43
// references to a unique oddball. Once the actual array has been allocated,
44
// such entries in the constants map must be patched up.
45
void
PatchBasicBlockCountersReference
(
Handle<ByteArray>
counters);
46
47
// Should be called after all affected code (e.g. builtins and bytecode
48
// handlers) has been generated.
49
void
Finalize
();
50
51
private
:
52
Isolate
*
isolate_
;
53
54
// Maps objects to corresponding indices within the constants list.
55
using
ConstantsMap
=
IdentityMap<uint32_t, FreeStoreAllocationPolicy>
;
56
ConstantsMap
map_
;
57
58
// Protects accesses to map_, which is concurrently accessed when generating
59
// builtins off-main-thread.
60
base::Mutex
mutex_
;
61
};
62
63
}
// namespace internal
64
}
// namespace v8
65
66
#endif
// V8_BUILTINS_CONSTANTS_TABLE_BUILDER_H_
v8::base::Mutex
Definition
mutex.h:36
v8::internal::BuiltinsConstantsTableBuilder
Definition
constants-table-builder.h:24
v8::internal::BuiltinsConstantsTableBuilder::PatchBasicBlockCountersReference
void PatchBasicBlockCountersReference(Handle< ByteArray > counters)
Definition
constants-table-builder.cc:100
v8::internal::BuiltinsConstantsTableBuilder::BuiltinsConstantsTableBuilder
BuiltinsConstantsTableBuilder(Isolate *isolate)
Definition
constants-table-builder.cc:16
v8::internal::BuiltinsConstantsTableBuilder::Finalize
void Finalize()
Definition
constants-table-builder.cc:111
v8::internal::BuiltinsConstantsTableBuilder::map_
ConstantsMap map_
Definition
constants-table-builder.h:56
v8::internal::BuiltinsConstantsTableBuilder::PatchSelfReference
void PatchSelfReference(DirectHandle< Object > self_reference, Handle< InstructionStream > code_object)
Definition
constants-table-builder.cc:87
v8::internal::BuiltinsConstantsTableBuilder::operator=
BuiltinsConstantsTableBuilder & operator=(const BuiltinsConstantsTableBuilder &)=delete
v8::internal::BuiltinsConstantsTableBuilder::isolate_
Isolate * isolate_
Definition
constants-table-builder.h:52
v8::internal::BuiltinsConstantsTableBuilder::mutex_
base::Mutex mutex_
Definition
constants-table-builder.h:60
v8::internal::BuiltinsConstantsTableBuilder::AddObject
uint32_t AddObject(Handle< Object > object)
Definition
constants-table-builder.cc:28
v8::internal::BuiltinsConstantsTableBuilder::BuiltinsConstantsTableBuilder
BuiltinsConstantsTableBuilder(const BuiltinsConstantsTableBuilder &)=delete
v8::internal::DirectHandle
Definition
handles.h:659
v8::internal::Handle
Definition
handles.h:149
v8::internal::IdentityMap< uint32_t, FreeStoreAllocationPolicy >
v8::internal::Isolate
Definition
isolate.h:586
handles.h
identity-map.h
v8::internal::internal
internal
Definition
wasm-objects-inl.h:458
v8
Definition
api-arguments-inl.h:19
macros.h
allocation.h
src
builtins
constants-table-builder.h
Generated on Sun Apr 6 2025 21:08:50 for v8 by
1.12.0