[api] V8::Initialize cleanup

- V8::Deprecate ShutdownPlatform in favor of V8::DisposePlatform
- Rename i::V8::TearDown to i::V8::Dispose
- Clean up i::V8::Initialize
- Remove needless V8::Initialize() calls in cctests
- Remove CcTest::DisableAutomaticDispose()
- Add checks to Isolate::Allocate and Isolate::Dispose that there is
  and active platform

Change-Id: Iac84f9ade9d1781e9e8b8c88ea8fe74013f51c4a
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3306482
Commit-Queue: Camillo Bruni <cbruni@chromium.org>
Reviewed-by: Jakob Gruber <jgruber@chromium.org>
Reviewed-by: Manos Koukoutos <manoskouk@chromium.org>
Reviewed-by: Michael Lippautz <mlippautz@chromium.org>
Cr-Commit-Position: refs/heads/main@{#78162}
This commit is contained in:
Camillo Bruni 2021-11-30 14:38:10 +01:00 committed by V8 LUCI CQ
parent a421ac639d
commit 44166c6091
24 changed files with 31 additions and 118 deletions

View File

@ -180,7 +180,9 @@ class V8_EXPORT V8 {
* Clears all references to the v8::Platform. This should be invoked after
* V8 was disposed.
*/
static void ShutdownPlatform();
static void DisposePlatform();
V8_DEPRECATE_SOON("Use DisposePlatform()")
static void ShutdownPlatform() { DisposePlatform(); }
#ifdef V8_VIRTUAL_MEMORY_CAGE
//

View File

@ -98,7 +98,7 @@ int main(int argc, char* argv[]) {
// Dispose the isolate and tear down V8.
isolate->Dispose();
v8::V8::Dispose();
v8::V8::ShutdownPlatform();
v8::V8::DisposePlatform();
delete create_params.array_buffer_allocator;
return 0;
}

View File

@ -95,7 +95,7 @@ int main(int argc, char* argv[]) {
}
isolate->Dispose();
v8::V8::Dispose();
v8::V8::ShutdownPlatform();
v8::V8::DisposePlatform();
delete create_params.array_buffer_allocator;
return result;
}

View File

@ -6059,7 +6059,7 @@ bool v8::V8::InitializeVirtualMemoryCage() {
}
#endif
void v8::V8::ShutdownPlatform() { i::V8::ShutdownPlatform(); }
void v8::V8::DisposePlatform() { i::V8::DisposePlatform(); }
bool v8::V8::Initialize(const int build_config) {
const bool kEmbedderPointerCompression =
@ -6154,7 +6154,7 @@ void v8::V8::SetReturnAddressLocationResolver(
}
bool v8::V8::Dispose() {
i::V8::TearDown();
i::V8::Dispose();
return true;
}

View File

@ -5377,7 +5377,7 @@ int Shell::Main(int argc, char* argv[]) {
OnExit(isolate);
V8::Dispose();
V8::ShutdownPlatform();
V8::DisposePlatform();
// Delete the platform explicitly here to write the tracing output to the
// tracing file.

View File

@ -2979,6 +2979,8 @@ Isolate* Isolate::NewShared(const v8::Isolate::CreateParams& params) {
// static
Isolate* Isolate::Allocate(bool is_shared) {
// v8::V8::Initialize() must be called before creating any isolates.
DCHECK_NOT_NULL(V8::GetCurrentPlatform());
// IsolateAllocator allocates the memory for the Isolate object according to
// the given allocation mode.
std::unique_ptr<IsolateAllocator> isolate_allocator =
@ -3002,6 +3004,8 @@ Isolate* Isolate::Allocate(bool is_shared) {
// static
void Isolate::Delete(Isolate* isolate) {
DCHECK_NOT_NULL(isolate);
// v8::V8::Dispose() must only be called after deleting all isolates.
DCHECK_NOT_NULL(V8::GetCurrentPlatform());
// Temporarily set this isolate as current so that various parts of
// the isolate can access it in their destructors without having a
// direct pointer. We don't use Enter/Exit here to avoid

View File

@ -48,12 +48,9 @@ V8_DECLARE_ONCE(init_snapshot_once);
v8::Platform* V8::platform_ = nullptr;
bool V8::Initialize() {
InitializeOncePerProcess();
return true;
}
void V8::Initialize() { base::CallOnce(&init_once, &InitializeOncePerProcess); }
void V8::TearDown() {
void V8::Dispose() {
#if V8_ENABLE_WEBASSEMBLY
wasm::WasmEngine::GlobalTearDown();
#endif // V8_ENABLE_WEBASSEMBLY
@ -73,7 +70,7 @@ void V8::TearDown() {
FLAG_##flag = false; \
}
void V8::InitializeOncePerProcessImpl() {
void V8::InitializeOncePerProcess() {
CHECK(platform_);
#ifdef V8_VIRTUAL_MEMORY_CAGE
@ -206,10 +203,6 @@ void V8::InitializeOncePerProcessImpl() {
ExternalReferenceTable::InitializeOncePerProcess();
}
void V8::InitializeOncePerProcess() {
base::CallOnce(&init_once, &InitializeOncePerProcessImpl);
}
void V8::InitializePlatform(v8::Platform* platform) {
CHECK(!platform_);
CHECK(platform);
@ -233,7 +226,7 @@ bool V8::InitializeVirtualMemoryCage() {
}
#endif
void V8::ShutdownPlatform() {
void V8::DisposePlatform() {
CHECK(platform_);
#if defined(V8_OS_WIN) && defined(V8_ENABLE_SYSTEM_INSTRUMENTATION)
if (FLAG_enable_system_instrumentation) {

View File

@ -20,8 +20,8 @@ class V8 : public AllStatic {
public:
// Global actions.
static bool Initialize();
static void TearDown();
static void Initialize();
static void Dispose();
// Report process out of memory. Implementation found in api.cc.
// This function will not return, but will terminate the execution.
@ -34,7 +34,7 @@ class V8 : public AllStatic {
#endif
static void InitializePlatform(v8::Platform* platform);
static void ShutdownPlatform();
static void DisposePlatform();
V8_EXPORT_PRIVATE static v8::Platform* GetCurrentPlatform();
// Replaces the current platform with the given platform.
// Should be used only for testing.

View File

@ -308,6 +308,6 @@ int main(int argc, char** argv) {
i::FreeCurrentEmbeddedBlob();
v8::V8::Dispose();
v8::V8::ShutdownPlatform();
v8::V8::DisposePlatform();
return 0;
}

View File

@ -370,7 +370,7 @@ struct EngineImpl {
delete counter_map_;
#endif
v8::V8::Dispose();
v8::V8::ShutdownPlatform();
v8::V8::DisposePlatform();
}
};

View File

@ -60,7 +60,6 @@
enum InitializationState { kUnset, kUninitialized, kInitialized };
static InitializationState initialization_state_ = kUnset;
static bool disable_automatic_dispose_ = false;
CcTest* CcTest::last_ = nullptr;
bool CcTest::initialize_called_ = false;
@ -216,11 +215,6 @@ v8::Local<v8::Context> CcTest::NewContext(CcTestExtensionFlags extension_flags,
return context;
}
void CcTest::DisableAutomaticDispose() {
CHECK_EQ(kUninitialized, initialization_state_);
disable_automatic_dispose_ = true;
}
LocalContext::~LocalContext() {
v8::HandleScope scope(isolate_);
v8::Local<v8::Context>::New(isolate_, context_)->Exit();
@ -408,11 +402,12 @@ int main(int argc, char* argv[]) {
v8::internal::DeleteArray<char>(arg_copy);
}
}
if (print_run_count && tests_run != 1)
if (print_run_count && tests_run != 1) {
printf("Ran %i tests.\n", tests_run);
}
CcTest::TearDown();
if (!disable_automatic_dispose_) v8::V8::Dispose();
v8::V8::ShutdownPlatform();
v8::V8::Dispose();
v8::V8::DisposePlatform();
return 0;
}

View File

@ -1559,7 +1559,6 @@ int CountNativeContexts() {
TEST(TestInternalWeakLists) {
FLAG_always_opt = false;
FLAG_allow_natives_syntax = true;
v8::V8::Initialize();
// Some flags turn Scavenge collections into Mark-sweep collections
// and hence are incompatible with this test case.
@ -1656,8 +1655,6 @@ TEST(TestSizeOfRegExpCode) {
if (!FLAG_regexp_optimization) return;
FLAG_stress_concurrent_allocation = false;
v8::V8::Initialize();
Isolate* isolate = CcTest::i_isolate();
HandleScope scope(isolate);
@ -1713,7 +1710,6 @@ TEST(TestSizeOfRegExpCode) {
HEAP_TEST(TestSizeOfObjects) {
FLAG_stress_concurrent_allocation = false;
v8::V8::Initialize();
Isolate* isolate = CcTest::i_isolate();
Heap* heap = CcTest::heap();
// Disable LAB, such that calculations with SizeOfObjects() and object size

View File

@ -312,7 +312,6 @@ TEST(OldLargeObjectSpace) {
// incremental marker.
FLAG_incremental_marking = false;
FLAG_max_heap_size = 20;
v8::V8::Initialize();
OldLargeObjectSpace* lo = CcTest::heap()->lo_space();
CHECK_NOT_NULL(lo);

View File

@ -362,7 +362,7 @@ V8InitializationScope::V8InitializationScope(const char* exec_path)
V8InitializationScope::~V8InitializationScope() {
isolate_->Dispose();
v8::V8::Dispose();
v8::V8::ShutdownPlatform();
v8::V8::DisposePlatform();
}
std::string ReadRawJSSnippet(std::istream* stream) {

View File

@ -168,7 +168,6 @@ static void Returns42(const v8::FunctionCallbackInfo<v8::Value>& info) {
info.GetReturnValue().Set(42);
}
// Tests that call v8::V8::Dispose() cannot be threaded.
UNINITIALIZED_TEST(InitializeAndDisposeOnce) {
CHECK(v8::V8::Initialize());
@ -6169,9 +6168,7 @@ static void TryCatchNested2Helper(int depth) {
}
}
TEST(TryCatchNested) {
v8::V8::Initialize();
LocalContext context;
v8::HandleScope scope(context->GetIsolate());
@ -6196,7 +6193,6 @@ TEST(TryCatchNested) {
}
}
void TryCatchMixedNestingCheck(v8::TryCatch* try_catch) {
CHECK(try_catch->HasCaught());
Local<Message> message = try_catch->Message();
@ -6231,7 +6227,6 @@ void TryCatchMixedNestingHelper(
TEST(TryCatchMixedNesting) {
v8::Isolate* isolate = CcTest::isolate();
v8::HandleScope scope(isolate);
v8::V8::Initialize();
v8::TryCatch try_catch(isolate);
Local<ObjectTemplate> templ = ObjectTemplate::New(isolate);
templ->Set(isolate, "TryCatchMixedNestingHelper",
@ -6253,7 +6248,6 @@ void TryCatchNativeHelper(const v8::FunctionCallbackInfo<v8::Value>& args) {
TEST(TryCatchNative) {
v8::Isolate* isolate = CcTest::isolate();
v8::HandleScope scope(isolate);
v8::V8::Initialize();
v8::TryCatch try_catch(isolate);
Local<ObjectTemplate> templ = ObjectTemplate::New(isolate);
templ->Set(isolate, "TryCatchNativeHelper",
@ -6278,7 +6272,6 @@ void TryCatchNativeResetHelper(
TEST(TryCatchNativeReset) {
v8::Isolate* isolate = CcTest::isolate();
v8::HandleScope scope(isolate);
v8::V8::Initialize();
v8::TryCatch try_catch(isolate);
Local<ObjectTemplate> templ = ObjectTemplate::New(isolate);
templ->Set(isolate, "TryCatchNativeResetHelper",
@ -13491,9 +13484,7 @@ static void CheckSurvivingGlobalObjectsCount(int expected) {
TEST(DontLeakGlobalObjects) {
// Regression test for issues 1139850 and 1174891.
i::FLAG_expose_gc = true;
v8::V8::Initialize();
for (int i = 0; i < 5; i++) {
{ v8::HandleScope scope(CcTest::isolate());
@ -13698,10 +13689,7 @@ THREADED_TEST(NoGlobalHandlesOrphaningDueToWeakCallback) {
EmptyMessageQueues(isolate);
}
THREADED_TEST(CheckForCrossContextObjectLiterals) {
v8::V8::Initialize();
const int nof = 2;
const char* sources[nof] = {
"try { [ 2, 3, 4 ].forEach(5); } catch(e) { e.toString(); }",
@ -13721,7 +13709,6 @@ THREADED_TEST(CheckForCrossContextObjectLiterals) {
}
}
static v8::Local<Value> NestedScope(v8::Local<Context> env) {
v8::EscapableHandleScope inner(env->GetIsolate());
env->Enter();
@ -17332,7 +17319,6 @@ THREADED_TEST(SpaghettiStackReThrow) {
TEST(Regress528) {
ManualGCScope manual_gc_scope;
v8::V8::Initialize();
v8::Isolate* isolate = CcTest::isolate();
i::FLAG_retain_maps_for_n_gc = 0;
v8::HandleScope scope(isolate);
@ -18278,9 +18264,7 @@ THREADED_TEST(TwoByteStringInOneByteCons) {
->SetResource(i_isolate, nullptr);
}
TEST(ContainsOnlyOneByte) {
v8::V8::Initialize();
v8::Isolate* isolate = CcTest::isolate();
v8::HandleScope scope(isolate);
// Make a buffer long enough that it won't automatically be converted.
@ -18352,7 +18336,6 @@ TEST(ContainsOnlyOneByte) {
}
}
// Failed access check callback that performs a GC on each invocation.
void FailedAccessCheckCallbackGC(Local<v8::Object> target,
v8::AccessType type,
@ -18366,8 +18349,6 @@ void FailedAccessCheckCallbackGC(Local<v8::Object> target,
TEST(GCInFailedAccessCheckCallback) {
// Install a failed access check callback that performs a GC on each
// invocation. Then force the callback to be called from va
v8::V8::Initialize();
v8::Isolate* isolate = CcTest::isolate();
isolate->SetFailedAccessCheckCallbackFunction(&FailedAccessCheckCallbackGC);
@ -20694,9 +20675,7 @@ TEST(StaticGetters) {
CHECK(*v8::Utils::OpenHandle(*v8::False(isolate)) == *false_value);
}
UNINITIALIZED_TEST(IsolateEmbedderData) {
CcTest::DisableAutomaticDispose();
v8::Isolate::CreateParams create_params;
create_params.array_buffer_allocator = CcTest::array_buffer_allocator();
v8::Isolate* isolate = v8::Isolate::New(create_params);
@ -20728,7 +20707,6 @@ UNINITIALIZED_TEST(IsolateEmbedderData) {
isolate->Dispose();
}
TEST(StringEmpty) {
LocalContext context;
i::Factory* factory = CcTest::i_isolate()->factory();
@ -21419,9 +21397,7 @@ void UnreachableCallback(const v8::FunctionCallbackInfo<v8::Value>& args) {
UNREACHABLE();
}
TEST(JSONStringifyAccessCheck) {
v8::V8::Initialize();
v8::Isolate* isolate = CcTest::isolate();
v8::HandleScope scope(isolate);
@ -21460,7 +21436,6 @@ TEST(JSONStringifyAccessCheck) {
}
}
bool access_check_fail_thrown = false;
bool catch_callback_called = false;
@ -21517,7 +21492,6 @@ void CheckCorrectThrow(const char* script) {
TEST(AccessCheckThrows) {
i::FLAG_allow_natives_syntax = true;
v8::V8::Initialize();
v8::Isolate* isolate = CcTest::isolate();
isolate->SetFailedAccessCheckCallbackFunction(&FailedAccessCheckThrows);
v8::HandleScope scope(isolate);
@ -24972,7 +24946,6 @@ TEST(CodeCacheScriptModuleMismatch) {
// Tests that compilation can handle a garbled cache.
TEST(InvalidCodeCacheDataInCompileModule) {
v8::V8::Initialize();
v8::Isolate* isolate = CcTest::isolate();
v8::HandleScope scope(isolate);
LocalContext local_context;
@ -25027,17 +25000,13 @@ void TestInvalidCacheData(v8::ScriptCompiler::CompileOptions option) {
script->Run(context).ToLocalChecked()->Int32Value(context).FromJust());
}
TEST(InvalidCodeCacheData) {
v8::V8::Initialize();
v8::HandleScope scope(CcTest::isolate());
LocalContext context;
TestInvalidCacheData(v8::ScriptCompiler::kConsumeCodeCache);
}
TEST(StringConcatOverflow) {
v8::V8::Initialize();
v8::Isolate* isolate = CcTest::isolate();
v8::HandleScope scope(isolate);
RandomLengthOneByteResource* r =
@ -25056,7 +25025,6 @@ TEST(TurboAsmDisablesDetach) {
#ifndef V8_LITE_MODE
i::FLAG_opt = true;
i::FLAG_allow_natives_syntax = true;
v8::V8::Initialize();
v8::HandleScope scope(CcTest::isolate());
LocalContext context;
const char* load =

View File

@ -227,7 +227,6 @@ v8::Local<Integer> DeclarationContext::Query(Local<Name> key) {
// about and doesn't handle.
TEST(Unknown) {
HandleScope scope(CcTest::isolate());
v8::V8::Initialize();
{ DeclarationContext context;
context.Check("var x; x",
@ -260,7 +259,6 @@ class AbsentPropertyContext: public DeclarationContext {
TEST(Absent) {
v8::Isolate* isolate = CcTest::isolate();
v8::V8::Initialize();
HandleScope scope(isolate);
{ AbsentPropertyContext context;
@ -326,9 +324,7 @@ class AppearingPropertyContext: public DeclarationContext {
State state_;
};
TEST(Appearing) {
v8::V8::Initialize();
HandleScope scope(CcTest::isolate());
{ AppearingPropertyContext context;
@ -351,8 +347,6 @@ TEST(Appearing) {
}
}
class ExistsInPrototypeContext: public DeclarationContext {
public:
ExistsInPrototypeContext() { InitializeIfNeeded(); }
@ -411,9 +405,7 @@ class AbsentInPrototypeContext: public DeclarationContext {
}
};
TEST(AbsentInPrototype) {
v8::V8::Initialize();
HandleScope scope(CcTest::isolate());
{ AbsentInPrototypeContext context;
@ -425,8 +417,6 @@ TEST(AbsentInPrototype) {
}
}
class SimpleContext {
public:
SimpleContext()

View File

@ -443,7 +443,6 @@ void TestSmiIndex(MacroAssembler* masm, Label* exit, int id, int x) {
TEST(EmbeddedObj) {
#ifdef V8_COMPRESS_POINTERS
FLAG_compact_on_every_full_gc = true;
v8::V8::Initialize();
Isolate* isolate = CcTest::i_isolate();
HandleScope handles(isolate);

View File

@ -610,9 +610,7 @@ TEST(ScanKeywords) {
}
}
TEST(ScanHTMLEndComments) {
v8::V8::Initialize();
v8::Isolate* isolate = CcTest::isolate();
i::Isolate* i_isolate = CcTest::i_isolate();
v8::HandleScope handles(isolate);
@ -746,9 +744,7 @@ class ScriptResource : public v8::String::ExternalOneByteStringResource {
size_t length_;
};
TEST(StandAlonePreParser) {
v8::V8::Initialize();
i::Isolate* i_isolate = CcTest::i_isolate();
i::UnoptimizedCompileFlags flags =
i::UnoptimizedCompileFlags::ForTest(i_isolate);
@ -785,9 +781,7 @@ TEST(StandAlonePreParser) {
}
}
TEST(StandAlonePreParserNoNatives) {
v8::V8::Initialize();
i::Isolate* isolate = CcTest::i_isolate();
i::UnoptimizedCompileFlags flags =
i::UnoptimizedCompileFlags::ForTest(isolate);
@ -820,9 +814,7 @@ TEST(StandAlonePreParserNoNatives) {
}
}
TEST(RegressChromium62639) {
v8::V8::Initialize();
i::Isolate* isolate = CcTest::i_isolate();
i::UnoptimizedCompileFlags flags =
i::UnoptimizedCompileFlags::ForTest(isolate);
@ -855,9 +847,7 @@ TEST(RegressChromium62639) {
pending_error_handler.has_error_unidentifiable_by_preparser());
}
TEST(PreParseOverflow) {
v8::V8::Initialize();
i::Isolate* isolate = CcTest::i_isolate();
i::UnoptimizedCompileFlags flags =
i::UnoptimizedCompileFlags::ForTest(isolate);
@ -909,9 +899,7 @@ void TestStreamScanner(i::Utf16CharacterStream* stream,
} while (expected_tokens[i] != i::Token::ILLEGAL);
}
TEST(StreamScanner) {
v8::V8::Initialize();
const char* str1 = "{ foo get for : */ <- \n\n /*foo*/ bib";
std::unique_ptr<i::Utf16CharacterStream> stream1(
i::ScannerStream::ForTesting(str1));
@ -989,10 +977,7 @@ void TestScanRegExp(const char* re_source, const char* expected) {
}
}
TEST(RegExpScanning) {
v8::V8::Initialize();
// RegExp token with added garbage at the end. The scanner should only
// scan the RegExp until the terminating slash just before "flipperwald".
TestScanRegExp("/b/flipperwald", "b");
@ -1175,7 +1160,6 @@ TEST(ScopeUsesArgumentsSuperThis) {
}
static void CheckParsesToNumber(const char* source) {
v8::V8::Initialize();
HandleAndZoneScope handles;
i::Isolate* isolate = CcTest::i_isolate();
@ -1210,7 +1194,6 @@ static void CheckParsesToNumber(const char* source) {
CHECK(lit->IsNumberLiteral());
}
TEST(ParseNumbers) {
CheckParsesToNumber("1.");
CheckParsesToNumber("1.34");
@ -1866,7 +1849,6 @@ TEST(ParserSync) {
TEST(StrictOctal) {
// Test that syntax error caused by octal literal is reported correctly as
// such (issue 2220).
v8::V8::Initialize();
v8::Isolate* isolate = CcTest::isolate();
v8::HandleScope scope(isolate);
v8::Context::Scope context_scope(v8::Context::New(isolate));

View File

@ -666,7 +666,6 @@ static ArchRegExpMacroAssembler::Result Execute(JSRegExp regexp, String input,
}
TEST(MacroAssemblerNativeSuccess) {
v8::V8::Initialize();
ContextInitializer initializer;
Isolate* isolate = CcTest::i_isolate();
Factory* factory = isolate->factory();
@ -698,7 +697,6 @@ TEST(MacroAssemblerNativeSuccess) {
}
TEST(MacroAssemblerNativeSimple) {
v8::V8::Initialize();
ContextInitializer initializer;
Isolate* isolate = CcTest::i_isolate();
Factory* factory = isolate->factory();
@ -756,7 +754,6 @@ TEST(MacroAssemblerNativeSimple) {
}
TEST(MacroAssemblerNativeSimpleUC16) {
v8::V8::Initialize();
ContextInitializer initializer;
Isolate* isolate = CcTest::i_isolate();
Factory* factory = isolate->factory();
@ -824,7 +821,6 @@ TEST(MacroAssemblerNativeSimpleUC16) {
}
TEST(MacroAssemblerNativeBacktrack) {
v8::V8::Initialize();
ContextInitializer initializer;
Isolate* isolate = CcTest::i_isolate();
Factory* factory = isolate->factory();
@ -860,7 +856,6 @@ TEST(MacroAssemblerNativeBacktrack) {
}
TEST(MacroAssemblerNativeBackReferenceLATIN1) {
v8::V8::Initialize();
ContextInitializer initializer;
Isolate* isolate = CcTest::i_isolate();
Factory* factory = isolate->factory();
@ -905,7 +900,6 @@ TEST(MacroAssemblerNativeBackReferenceLATIN1) {
}
TEST(MacroAssemblerNativeBackReferenceUC16) {
v8::V8::Initialize();
ContextInitializer initializer;
Isolate* isolate = CcTest::i_isolate();
Factory* factory = isolate->factory();
@ -954,7 +948,6 @@ TEST(MacroAssemblerNativeBackReferenceUC16) {
}
TEST(MacroAssemblernativeAtStart) {
v8::V8::Initialize();
ContextInitializer initializer;
Isolate* isolate = CcTest::i_isolate();
Factory* factory = isolate->factory();
@ -1005,7 +998,6 @@ TEST(MacroAssemblernativeAtStart) {
}
TEST(MacroAssemblerNativeBackRefNoCase) {
v8::V8::Initialize();
ContextInitializer initializer;
Isolate* isolate = CcTest::i_isolate();
Factory* factory = isolate->factory();
@ -1058,7 +1050,6 @@ TEST(MacroAssemblerNativeBackRefNoCase) {
}
TEST(MacroAssemblerNativeRegisters) {
v8::V8::Initialize();
ContextInitializer initializer;
Isolate* isolate = CcTest::i_isolate();
Factory* factory = isolate->factory();
@ -1155,7 +1146,6 @@ TEST(MacroAssemblerNativeRegisters) {
}
TEST(MacroAssemblerStackOverflow) {
v8::V8::Initialize();
ContextInitializer initializer;
Isolate* isolate = CcTest::i_isolate();
Factory* factory = isolate->factory();
@ -1189,7 +1179,6 @@ TEST(MacroAssemblerStackOverflow) {
}
TEST(MacroAssemblerNativeLotsOfRegisters) {
v8::V8::Initialize();
ContextInitializer initializer;
Isolate* isolate = CcTest::i_isolate();
Factory* factory = isolate->factory();

View File

@ -1891,7 +1891,6 @@ TEST(HashArrayIndexStrings) {
}
TEST(StringEquals) {
v8::V8::Initialize();
v8::Isolate* isolate = CcTest::isolate();
v8::HandleScope scope(isolate);
@ -1928,7 +1927,6 @@ class OneByteStringResource : public v8::String::ExternalOneByteStringResource {
TEST(Regress876759) {
// Thin strings are used in conjunction with young gen
if (FLAG_single_generation) return;
v8::V8::Initialize();
Isolate* isolate = CcTest::i_isolate();
Factory* factory = isolate->factory();

View File

@ -174,9 +174,7 @@ void TestMemMove(byte* area1,
}
}
TEST(MemMove) {
v8::V8::Initialize();
byte* area1 = new byte[kAreaSize];
byte* area2 = new byte[kAreaSize];
@ -196,7 +194,6 @@ TEST(MemMove) {
delete[] area2;
}
TEST(Collector) {
Collector<int> collector(8);
const int kLoops = 5;

View File

@ -62,7 +62,7 @@ FuzzerSupport::~FuzzerSupport() {
allocator_ = nullptr;
v8::V8::Dispose();
v8::V8::ShutdownPlatform();
v8::V8::DisposePlatform();
}
std::unique_ptr<FuzzerSupport> FuzzerSupport::fuzzer_support_;

View File

@ -224,7 +224,8 @@ static int DumpHeapConstants(FILE* out, const char* argv0) {
// Teardown.
isolate->Dispose();
v8::V8::ShutdownPlatform();
v8::V8::Dispose();
v8::V8::DisposePlatform();
return 0;
}

View File

@ -25,13 +25,13 @@ class DefaultPlatformEnvironment final : public ::testing::Environment {
ASSERT_TRUE(v8::V8::InitializeVirtualMemoryCage());
#endif
cppgc::InitializeProcess(platform_->GetPageAllocator());
ASSERT_TRUE(v8::V8::Initialize());
v8::V8::Initialize();
}
void TearDown() override {
ASSERT_TRUE(platform_.get() != nullptr);
v8::V8::Dispose();
v8::V8::ShutdownPlatform();
v8::V8::DisposePlatform();
}
private: