1 // Copyright 2017 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_INIT_SETUP_ISOLATE_H_ 6 #define V8_INIT_SETUP_ISOLATE_H_ 7 8 #include "src/base/macros.h" 9 10 namespace v8 { 11 namespace internal { 12 13 class Builtins; 14 enum class Builtin : int32_t; 15 class Code; 16 class Heap; 17 class Isolate; 18 19 // This class is an abstraction layer around initialization of components 20 // that are either deserialized from the snapshot or generated from scratch. 21 // Currently this includes builtins and interpreter bytecode handlers. 22 // There are two implementations to choose from at link time: 23 // - setup-isolate-deserialize.cc: always loads things from snapshot. 24 // - setup-isolate-full.cc: loads from snapshot or bootstraps from scratch, 25 // controlled by the |create_heap_objects| flag. 26 // For testing, the implementation in setup-isolate-for-tests.cc can be chosen 27 // to force the behavior of setup-isolate-full.cc at runtime. 28 // 29 // The actual implementations of generation of builtins and handlers is in 30 // setup-builtins-internal.cc and setup-interpreter-internal.cc, and is 31 // linked in by the latter two Delegate implementations. 32 class V8_EXPORT_PRIVATE SetupIsolateDelegate { 33 public: SetupIsolateDelegate(bool create_heap_objects)34 explicit SetupIsolateDelegate(bool create_heap_objects) 35 : create_heap_objects_(create_heap_objects) {} 36 virtual ~SetupIsolateDelegate() = default; 37 38 virtual void SetupBuiltins(Isolate* isolate); 39 40 virtual bool SetupHeap(Heap* heap); 41 42 protected: 43 static void SetupBuiltinsInternal(Isolate* isolate); 44 static void AddBuiltin(Builtins* builtins, Builtin builtin, Code code); 45 static void PopulateWithPlaceholders(Isolate* isolate); 46 static void ReplacePlaceholders(Isolate* isolate); 47 48 static bool SetupHeapInternal(Heap* heap); 49 50 const bool create_heap_objects_; 51 }; 52 53 } // namespace internal 54 } // namespace v8 55 56 #endif // V8_INIT_SETUP_ISOLATE_H_ 57