v8
V8 is Google’s open source high-performance JavaScript and WebAssembly engine, written in C++.
Loading...
Searching...
No Matches
local-factory.h
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
5#ifndef V8_HEAP_LOCAL_FACTORY_H_
6#define V8_HEAP_LOCAL_FACTORY_H_
7
8#include "src/base/logging.h"
10#include "src/handles/handles.h"
12#include "src/heap/heap.h"
14#include "src/heap/spaces.h"
15#include "src/roots/roots.h"
16
17namespace v8 {
18namespace internal {
19
20class AstValueFactory;
21class AstRawString;
22class AstConsString;
23class LocalIsolate;
24
25class V8_EXPORT_PRIVATE LocalFactory : public FactoryBase<LocalFactory> {
26 public:
27 explicit LocalFactory(Isolate* isolate);
28
29 ReadOnlyRoots read_only_roots() const { return roots_; }
30
31#define ROOT_ACCESSOR(Type, name, CamelName) inline DirectHandle<Type> name();
32 // AccessorInfos appear mutable, but they're actually not mutated once they
33 // finish initializing. In particular, the root accessors are not mutated and
34 // are safe to access (as long as the off-thread job doesn't try to mutate
35 // them).
37#undef ROOT_ACCESSOR
38
39 // The parser shouldn't allow the LocalFactory to get into a state where
40 // it generates errors.
45
46 // The LocalFactory does not have access to the number_string_cache (since
47 // it's a mutable root), but it still needs to define some cache-related
48 // method that are used by FactoryBase. Those method do basically nothing in
49 // the case of the LocalFactory.
50 int NumberToStringCacheHash(Tagged<Smi> number);
51 int NumberToStringCacheHash(double number);
52 void NumberToStringCacheSet(DirectHandle<Object> number, int hash,
53 DirectHandle<String> js_string);
54 Handle<Object> NumberToStringCacheGet(Tagged<Object> number, int hash);
55
56 private:
57 friend class FactoryBase<LocalFactory>;
58
59 // ------
60 // Customization points for FactoryBase.
61 Tagged<HeapObject> AllocateRaw(
62 int size, AllocationType allocation,
63 AllocationAlignment alignment = kTaggedAligned);
64
66 // Downcast to the privately inherited sub-class using c-style casts to
67 // avoid undefined behavior (as static_cast cannot cast across private
68 // bases).
69 // NOLINTNEXTLINE (google-readability-casting)
70 return (LocalIsolate*)this; // NOLINT(readability/casting)
71 }
72
73 inline bool CanAllocateInReadOnlySpace() { return false; }
74 inline bool EmptyStringRootIsInitialized() { return true; }
75 inline AllocationType AllocationTypeForInPlaceInternalizableString();
76 // ------
77
78 void ProcessNewScript(DirectHandle<Script> script,
79 ScriptEventType script_event_type);
80 // ------
81
83#ifdef DEBUG
84 bool a_script_was_added_to_the_script_list_ = false;
85#endif
86};
87
88} // namespace internal
89} // namespace v8
90
91#endif // V8_HEAP_LOCAL_FACTORY_H_
ReadOnlyRoots read_only_roots() const
DirectHandle< Object > NewInvalidStringLengthError()
DirectHandle< Object > NewRangeError(MessageTemplate template_index)
#define ROOT_ACCESSOR(Type, name, CamelName)
#define ACCESSOR_INFO_ROOT_LIST(V)
Definition roots.h:465
#define UNREACHABLE()
Definition logging.h:67
#define V8_EXPORT_PRIVATE
Definition macros.h:460