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"
11#include "src/handles/handles.h"
12
13namespace v8 {
14namespace internal {
15
16class Isolate;
17class Object;
18class 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.
25 public:
26 explicit BuiltinsConstantsTableBuilder(Isolate* isolate);
27
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.
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:
53
54 // Maps objects to corresponding indices within the constants list.
57
58 // Protects accesses to map_, which is concurrently accessed when generating
59 // builtins off-main-thread.
61};
62
63} // namespace internal
64} // namespace v8
65
66#endif // V8_BUILTINS_CONSTANTS_TABLE_BUILDER_H_
void PatchBasicBlockCountersReference(Handle< ByteArray > counters)
void PatchSelfReference(DirectHandle< Object > self_reference, Handle< InstructionStream > code_object)
BuiltinsConstantsTableBuilder & operator=(const BuiltinsConstantsTableBuilder &)=delete
BuiltinsConstantsTableBuilder(const BuiltinsConstantsTableBuilder &)=delete