setup-isolate.h 1.88 KB
Newer Older
1 2 3 4
// 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.

5 6
#ifndef V8_INIT_SETUP_ISOLATE_H_
#define V8_INIT_SETUP_ISOLATE_H_
7

8 9
#include "src/base/macros.h"

10 11 12 13 14
namespace v8 {
namespace internal {

class Builtins;
class Code;
15
class Heap;
16 17 18 19 20
class Isolate;

// 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.
21
// There are two implementations to choose from at link time:
22
// - setup-isolate-deserialize.cc: always loads things from snapshot.
23 24 25 26
// - 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.
27 28 29 30
//
// 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.
31
class V8_EXPORT_PRIVATE SetupIsolateDelegate {
32
 public:
33 34
  explicit SetupIsolateDelegate(bool create_heap_objects)
      : create_heap_objects_(create_heap_objects) {}
35
  virtual ~SetupIsolateDelegate() = default;
36

37
  virtual void SetupBuiltins(Isolate* isolate);
38

39
  virtual bool SetupHeap(Heap* heap);
40 41 42

 protected:
  static void SetupBuiltinsInternal(Isolate* isolate);
43
  static void AddBuiltin(Builtins* builtins, int index, Code code);
44 45
  static void PopulateWithPlaceholders(Isolate* isolate);
  static void ReplacePlaceholders(Isolate* isolate);
46 47 48 49

  static bool SetupHeapInternal(Heap* heap);

  const bool create_heap_objects_;
50 51 52 53
};

}  // namespace internal
}  // namespace v8
54

55
#endif  // V8_INIT_SETUP_ISOLATE_H_