blob: a1b18b20d6c05bb62dcc25eab20b07f19a4ae8bc [file] [log] [blame]
Ben Murdoch3fb3ca82011-12-02 17:19:32 +00001// Copyright 2011 the V8 project authors. All rights reserved.
Ben Murdochb8a8cc12014-11-26 15:28:44 +00002// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
Steve Blocka7e24c12009-10-30 11:49:00 +00004
Steve Blocka7e24c12009-10-30 11:49:00 +00005#ifndef V8_V8_H_
6#define V8_V8_H_
7
Ben Murdochb8a8cc12014-11-26 15:28:44 +00008#include "include/v8.h"
Ben Murdoch4a90d5f2016-03-22 12:00:34 +00009#include "src/allocation.h"
Steve Blocka7e24c12009-10-30 11:49:00 +000010
11namespace v8 {
12namespace internal {
13
14class V8 : public AllStatic {
15 public:
16 // Global actions.
17
Ben Murdochb8a8cc12014-11-26 15:28:44 +000018 static bool Initialize();
Steve Blocka7e24c12009-10-30 11:49:00 +000019 static void TearDown();
Steve Blocka7e24c12009-10-30 11:49:00 +000020
21 // Report process out of memory. Implementation found in api.cc.
Ben Murdoch4a90d5f2016-03-22 12:00:34 +000022 // This function will not return, but will terminate the execution.
Ben Murdochbb769b22010-08-11 14:56:33 +010023 static void FatalProcessOutOfMemory(const char* location,
Ben Murdochc5610432016-08-08 18:44:38 +010024 bool is_heap_oom = false);
Steve Blocka7e24c12009-10-30 11:49:00 +000025
Ben Murdochb8a8cc12014-11-26 15:28:44 +000026 static void InitializePlatform(v8::Platform* platform);
27 static void ShutdownPlatform();
28 static v8::Platform* GetCurrentPlatform();
Ben Murdoch4a90d5f2016-03-22 12:00:34 +000029 // Replaces the current platform with the given platform.
30 // Should be used only for testing.
31 static void SetPlatformForTesting(v8::Platform* platform);
Steve Blocka7e24c12009-10-30 11:49:00 +000032
Emily Bernierd0a1eb72015-03-24 16:35:39 -040033 static void SetNativesBlob(StartupData* natives_blob);
34 static void SetSnapshotBlob(StartupData* snapshot_blob);
35
Steve Blocka7e24c12009-10-30 11:49:00 +000036 private:
Ben Murdoch3ef787d2012-04-12 10:51:47 +010037 static void InitializeOncePerProcessImpl();
Ben Murdoch8b112d22011-06-08 16:22:53 +010038 static void InitializeOncePerProcess();
39
Ben Murdochb8a8cc12014-11-26 15:28:44 +000040 // v8::Platform to use.
41 static v8::Platform* platform_;
Steve Blocka7e24c12009-10-30 11:49:00 +000042};
43
Ben Murdoch4a90d5f2016-03-22 12:00:34 +000044} // namespace internal
45} // namespace v8
Steve Blocka7e24c12009-10-30 11:49:00 +000046
Steve Blocka7e24c12009-10-30 11:49:00 +000047#endif // V8_V8_H_