Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(301)

Side by Side Diff: src/v8.cc

Issue 24999002: lazy instantiation of the default isolate (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: nit Created 7 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/v8.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
72 i::Isolate::Current()); 72 i::Isolate::Current());
73 73
74 Isolate* isolate = Isolate::Current(); 74 Isolate* isolate = Isolate::Current();
75 if (isolate->IsDead()) return false; 75 if (isolate->IsDead()) return false;
76 if (isolate->IsInitialized()) return true; 76 if (isolate->IsInitialized()) return true;
77 77
78 return isolate->Init(des); 78 return isolate->Init(des);
79 } 79 }
80 80
81 81
82 void V8::TearDown() { 82 bool V8::TearDown() {
83 Isolate* isolate = Isolate::Current(); 83 Isolate* isolate = Isolate::UncheckedCurrent();
84 ASSERT(isolate->IsDefaultIsolate()); 84 if (isolate != NULL) {
85 if (!isolate->IsInitialized()) return; 85 ASSERT(isolate->IsDefaultIsolate());
86 if (isolate->IsInitialized()) isolate->TearDown();
87 delete isolate;
88 }
86 89
87 // The isolate has to be torn down before clearing the LOperand 90 // V8 was never initialized, nothing to do.
91 if (Acquire_Load(&init_once) == ONCE_STATE_UNINITIALIZED) return true;
92
93 // TODO(dcarney): Everything below this should be in some sort of mutex...
94 Atomic32 living_isolates = Isolate::GetLivingIsolates();
95
96 // All isolates have to be torn down before clearing the LOperand
88 // caches so that the optimizing compiler thread (if running) 97 // caches so that the optimizing compiler thread (if running)
89 // doesn't see an inconsistent view of the lithium instructions. 98 // doesn't see an inconsistent view of the lithium instructions.
90 isolate->TearDown(); 99 if (living_isolates != 0) return false;
91 delete isolate;
92 100
93 ElementsAccessor::TearDown(); 101 ElementsAccessor::TearDown();
94 LOperand::TearDownCaches(); 102 LOperand::TearDownCaches();
95 ExternalReference::TearDownMathExpData(); 103 ExternalReference::TearDownMathExpData();
96 RegisteredExtension::UnregisterAll(); 104 RegisteredExtension::UnregisterAll();
97 Isolate::GlobalTearDown(); 105 Isolate::GlobalTearDown();
98 106
99 delete call_completed_callbacks_; 107 delete call_completed_callbacks_;
100 call_completed_callbacks_ = NULL; 108 call_completed_callbacks_ = NULL;
101 109
102 Sampler::TearDown(); 110 Sampler::TearDown();
111 return true;
103 } 112 }
104 113
105 114
106 void V8::SetReturnAddressLocationResolver( 115 void V8::SetReturnAddressLocationResolver(
107 ReturnAddressLocationResolver resolver) { 116 ReturnAddressLocationResolver resolver) {
108 StackFrame::SetReturnAddressLocationResolver(resolver); 117 StackFrame::SetReturnAddressLocationResolver(resolver);
109 } 118 }
110 119
111 120
112 // Used by JavaScript APIs 121 // Used by JavaScript APIs
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after
242 ExternalReference::SetUp(); 251 ExternalReference::SetUp();
243 Bootstrapper::InitializeOncePerProcess(); 252 Bootstrapper::InitializeOncePerProcess();
244 } 253 }
245 254
246 255
247 void V8::InitializeOncePerProcess() { 256 void V8::InitializeOncePerProcess() {
248 CallOnce(&init_once, &InitializeOncePerProcessImpl); 257 CallOnce(&init_once, &InitializeOncePerProcessImpl);
249 } 258 }
250 259
251 } } // namespace v8::internal 260 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/v8.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698