Simplify v8/Isolate teardown.

This implies that one better has a v8::V8::Initialize when v8::V8::Dispose is used.

BUG=359977
LOG=y
R=jochen@chromium.org

Review URL: https://codereview.chromium.org/238353015

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@20876 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent 2a941b2e
......@@ -328,6 +328,7 @@ bool RunCppCycle(v8::Handle<v8::Script> script,
int main(int argc, char* argv[]) {
v8::V8::InitializeICU();
v8::V8::Initialize();
int result = RunMain(argc, argv);
v8::V8::Dispose();
return result;
......
......@@ -644,6 +644,7 @@ void PrintMap(map<string, string>* m) {
int main(int argc, char* argv[]) {
v8::V8::InitializeICU();
v8::V8::Initialize();
map<string, string> options;
string file;
ParseOptions(argc, argv, options, &file);
......
......@@ -67,6 +67,7 @@ static bool run_shell;
int main(int argc, char* argv[]) {
v8::V8::InitializeICU();
v8::V8::Initialize();
v8::V8::SetFlagsFromCommandLine(&argc, argv, true);
v8::Isolate* isolate = v8::Isolate::GetCurrent();
run_shell = (argc == 1);
......
......@@ -4995,12 +4995,6 @@ void v8::V8::SetArrayBufferAllocator(
bool v8::V8::Dispose() {
i::Isolate* isolate = i::Isolate::Current();
if (!Utils::ApiCheck(isolate != NULL && isolate->IsDefaultIsolate(),
"v8::V8::Dispose()",
"Use v8::Isolate::Dispose() for non-default isolate.")) {
return false;
}
i::V8::TearDown();
return true;
}
......
......@@ -1678,6 +1678,7 @@ class MockArrayBufferAllocator : public v8::ArrayBuffer::Allocator {
int Shell::Main(int argc, char* argv[]) {
if (!SetOptions(argc, argv)) return 1;
v8::V8::InitializeICU(options.icu_data_file);
v8::V8::Initialize();
#ifndef V8_SHARED
i::FLAG_trace_hydrogen_file = "hydrogen.cfg";
i::FLAG_redirect_code_traces_to = "code.asm";
......@@ -1692,7 +1693,7 @@ int Shell::Main(int argc, char* argv[]) {
v8::V8::SetArrayBufferAllocator(&array_buffer_allocator);
}
int result = 0;
Isolate* isolate = Isolate::GetCurrent();
Isolate* isolate = Isolate::New();
#ifndef V8_SHARED
v8::ResourceConstraints constraints;
constraints.ConfigureDefaults(i::OS::TotalPhysicalMemory(),
......@@ -1703,6 +1704,7 @@ int Shell::Main(int argc, char* argv[]) {
DumbLineEditor dumb_line_editor(isolate);
{
Initialize(isolate);
Isolate::Scope isolate_scope(isolate);
#ifdef ENABLE_VTUNE_JIT_INTERFACE
vTune::InitializeVtuneForV8();
#endif
......@@ -1765,6 +1767,7 @@ int Shell::Main(int argc, char* argv[]) {
RunShell(isolate);
}
}
isolate->Dispose();
V8::Dispose();
OnExit();
......
......@@ -1551,9 +1551,7 @@ void Isolate::TearDown() {
serialize_partial_snapshot_cache_ = NULL;
}
if (!IsDefaultIsolate()) {
delete this;
}
delete this;
// Restore the previous current isolate.
SetIsolateThreadLocals(saved_isolate, saved_data);
......
......@@ -271,6 +271,8 @@ void DumpException(Handle<Message> message) {
int main(int argc, char** argv) {
V8::InitializeICU();
// TODO(svenpanne) We can't do this here currently, although we should!
// v8::V8::Initialize();
i::Isolate::SetCrashIfDefaultIsolateInitialized();
// By default, log code create information in the snapshot.
......@@ -410,6 +412,7 @@ int main(int argc, char** argv) {
ser.CurrentAllocationAddress(i::CELL_SPACE),
ser.CurrentAllocationAddress(i::PROPERTY_CELL_SPACE));
isolate->Exit();
i::Serializer::TearDown();
isolate->Dispose();
V8::Dispose();
return 0;
......
......@@ -785,9 +785,6 @@ void Serializer::InitializeOncePerProcess() {
void Serializer::TearDown() {
// TearDown is called by V8::TearDown() for the default isolate. It's safe
// to shut down the serializer by that point. Just to be safe, we restore
// serialization_state_ to uninitialized.
ASSERT(NoBarrier_Load(&serialization_state_) !=
SERIALIZER_STATE_UNINITIALIZED);
if (code_address_map_) {
......
......@@ -77,16 +77,6 @@ bool V8::Initialize(Deserializer* des) {
void V8::TearDown() {
Isolate* isolate = Isolate::Current();
ASSERT(isolate->IsDefaultIsolate());
if (!isolate->IsInitialized()) return;
// The isolate has to be torn down before clearing the LOperand
// caches so that the optimizing compiler thread (if running)
// doesn't see an inconsistent view of the lithium instructions.
isolate->TearDown();
delete isolate;
Bootstrapper::TearDownExtensions();
ElementsAccessor::TearDown();
LOperand::TearDownCaches();
......@@ -98,7 +88,6 @@ void V8::TearDown() {
call_completed_callbacks_ = NULL;
Sampler::TearDown();
Serializer::TearDown();
#ifdef V8_USE_DEFAULT_PLATFORM
DefaultPlatform* platform = static_cast<DefaultPlatform*>(platform_);
......
......@@ -138,6 +138,7 @@ static void SuggestTestHarness(int tests) {
int main(int argc, char* argv[]) {
v8::V8::InitializeICU();
v8::V8::Initialize();
i::Isolate::SetCrashIfDefaultIsolateInitialized();
v8::internal::FlagList::SetFlagsFromCommandLine(&argc, argv, true);
......
......@@ -22313,6 +22313,7 @@ TEST(EventLogging) {
TEST(Promises) {
i::FLAG_harmony_promises = true;
i::FlagList::EnforceFlagImplications();
LocalContext context;
v8::Isolate* isolate = context->GetIsolate();
......
......@@ -37,6 +37,7 @@ class HarmonyIsolate {
public:
HarmonyIsolate() {
i::FLAG_harmony_promises = true;
i::FlagList::EnforceFlagImplications();
isolate_ = Isolate::New();
isolate_->Enter();
}
......
......@@ -182,6 +182,7 @@ TimeDelta ProcessFile(
int main(int argc, char* argv[]) {
v8::V8::InitializeICU();
v8::V8::Initialize();
v8::V8::SetFlagsFromCommandLine(&argc, argv, true);
Encoding encoding = LATIN1;
bool print_tokens = false;
......
......@@ -107,6 +107,7 @@ std::pair<TimeDelta, TimeDelta> RunBaselineParser(
int main(int argc, char* argv[]) {
v8::V8::InitializeICU();
v8::V8::Initialize();
v8::V8::SetFlagsFromCommandLine(&argc, argv, true);
Encoding encoding = LATIN1;
std::vector<std::string> fnames;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment