lin
2025-07-30 fcd736bf35fd93b563e9bbf594f2aa7b62028cc9
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
// Copyright 2017 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
 
#ifndef V8_SETUP_ISOLATE_H_
#define V8_SETUP_ISOLATE_H_
 
namespace v8 {
namespace internal {
 
class Builtins;
class Code;
class Heap;
class Isolate;
 
namespace interpreter {
class Interpreter;
}  // namespace interpreter
 
// This class is an abstraction layer around initialization of components
// that are either deserialized from the snapshot or generated from scratch.
// Currently this includes builtins and interpreter bytecode handlers.
// There are two implementations to choose from at link time:
// - setup-isolate-deserialize.cc: always loads things from snapshot.
// - setup-isolate-full.cc: loads from snapshot or bootstraps from scratch,
//                          controlled by the |create_heap_objects| flag.
// For testing, the implementation in setup-isolate-for-tests.cc can be chosen
// to force the behavior of setup-isolate-full.cc at runtime.
//
// The actual implementations of generation of builtins and handlers is in
// setup-builtins-internal.cc and setup-interpreter-internal.cc, and is
// linked in by the latter two Delegate implementations.
class SetupIsolateDelegate {
 public:
  explicit SetupIsolateDelegate(bool create_heap_objects)
      : create_heap_objects_(create_heap_objects) {}
  virtual ~SetupIsolateDelegate() {}
 
  virtual void SetupBuiltins(Isolate* isolate);
 
  virtual void SetupInterpreter(interpreter::Interpreter* interpreter);
 
  virtual bool SetupHeap(Heap* heap);
 
 protected:
  static void SetupBuiltinsInternal(Isolate* isolate);
  static void AddBuiltin(Builtins* builtins, int index, Code* code);
  static void PopulateWithPlaceholders(Isolate* isolate);
  static void ReplacePlaceholders(Isolate* isolate);
 
  static bool SetupHeapInternal(Heap* heap);
 
  const bool create_heap_objects_;
};
 
}  // namespace internal
}  // namespace v8
 
#endif  // V8_SETUP_ISOLATE_H_