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

Side by Side Diff: src/v8.cc

Issue 23453030: Remove obsolete global V8::has_been_fooed flags. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 7 years, 3 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
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 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
43 #include "sampler.h" 43 #include "sampler.h"
44 #include "runtime-profiler.h" 44 #include "runtime-profiler.h"
45 #include "serialize.h" 45 #include "serialize.h"
46 #include "store-buffer.h" 46 #include "store-buffer.h"
47 47
48 namespace v8 { 48 namespace v8 {
49 namespace internal { 49 namespace internal {
50 50
51 V8_DECLARE_ONCE(init_once); 51 V8_DECLARE_ONCE(init_once);
52 52
53 bool V8::has_been_set_up_ = false;
54 bool V8::has_been_disposed_ = false;
55 List<CallCompletedCallback>* V8::call_completed_callbacks_ = NULL; 53 List<CallCompletedCallback>* V8::call_completed_callbacks_ = NULL;
56 v8::ArrayBuffer::Allocator* V8::array_buffer_allocator_ = NULL; 54 v8::ArrayBuffer::Allocator* V8::array_buffer_allocator_ = NULL;
57 55
58 static LazyMutex entropy_mutex = LAZY_MUTEX_INITIALIZER; 56 static LazyMutex entropy_mutex = LAZY_MUTEX_INITIALIZER;
59 57
60 static EntropySource entropy_source; 58 static EntropySource entropy_source;
61 59
62 60
63 bool V8::Initialize(Deserializer* des) { 61 bool V8::Initialize(Deserializer* des) {
64 InitializeOncePerProcess(); 62 InitializeOncePerProcess();
65 63
66 // The current thread may not yet had entered an isolate to run. 64 // The current thread may not yet had entered an isolate to run.
67 // Note the Isolate::Current() may be non-null because for various 65 // Note the Isolate::Current() may be non-null because for various
68 // initialization purposes an initializing thread may be assigned an isolate 66 // initialization purposes an initializing thread may be assigned an isolate
69 // but not actually enter it. 67 // but not actually enter it.
70 if (i::Isolate::CurrentPerIsolateThreadData() == NULL) { 68 if (i::Isolate::CurrentPerIsolateThreadData() == NULL) {
71 i::Isolate::EnterDefaultIsolate(); 69 i::Isolate::EnterDefaultIsolate();
72 } 70 }
73 71
74 ASSERT(i::Isolate::CurrentPerIsolateThreadData() != NULL); 72 ASSERT(i::Isolate::CurrentPerIsolateThreadData() != NULL);
75 ASSERT(i::Isolate::CurrentPerIsolateThreadData()->thread_id().Equals( 73 ASSERT(i::Isolate::CurrentPerIsolateThreadData()->thread_id().Equals(
76 i::ThreadId::Current())); 74 i::ThreadId::Current()));
77 ASSERT(i::Isolate::CurrentPerIsolateThreadData()->isolate() == 75 ASSERT(i::Isolate::CurrentPerIsolateThreadData()->isolate() ==
78 i::Isolate::Current()); 76 i::Isolate::Current());
79 77
80 Isolate* isolate = Isolate::Current(); 78 Isolate* isolate = Isolate::Current();
81 if (isolate->IsDead()) return false; 79 if (isolate->IsDead()) return false;
82 if (isolate->IsInitialized()) return true; 80 if (isolate->IsInitialized()) return true;
83 81
84 has_been_set_up_ = true;
85 has_been_disposed_ = false;
86
87 return isolate->Init(des); 82 return isolate->Init(des);
88 } 83 }
89 84
90 85
91 void V8::TearDown() { 86 void V8::TearDown() {
92 Isolate* isolate = Isolate::Current(); 87 Isolate* isolate = Isolate::Current();
93 ASSERT(isolate->IsDefaultIsolate()); 88 ASSERT(isolate->IsDefaultIsolate());
94 89 if (!isolate->IsInitialized()) return;
95 if (!has_been_set_up_ || has_been_disposed_) return;
96 90
97 // The isolate has to be torn down before clearing the LOperand 91 // The isolate has to be torn down before clearing the LOperand
98 // caches so that the optimizing compiler thread (if running) 92 // caches so that the optimizing compiler thread (if running)
99 // doesn't see an inconsistent view of the lithium instructions. 93 // doesn't see an inconsistent view of the lithium instructions.
100 isolate->TearDown(); 94 isolate->TearDown();
101 delete isolate; 95 delete isolate;
102 96
103 ElementsAccessor::TearDown(); 97 ElementsAccessor::TearDown();
104 LOperand::TearDownCaches(); 98 LOperand::TearDownCaches();
105 ExternalReference::TearDownMathExpData(); 99 ExternalReference::TearDownMathExpData();
106 RegisteredExtension::UnregisterAll(); 100 RegisteredExtension::UnregisterAll();
107 Isolate::GlobalTearDown(); 101 Isolate::GlobalTearDown();
108 102
109 has_been_disposed_ = true;
110
111 delete call_completed_callbacks_; 103 delete call_completed_callbacks_;
112 call_completed_callbacks_ = NULL; 104 call_completed_callbacks_ = NULL;
113 105
114 Sampler::TearDown(); 106 Sampler::TearDown();
115 OS::TearDown(); 107 OS::TearDown();
116 } 108 }
117 109
118 110
119 static void seed_random(uint32_t* state) { 111 static void seed_random(uint32_t* state) {
120 for (int i = 0; i < 2; ++i) { 112 for (int i = 0; i < 2; ++i) {
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after
302 ExternalReference::SetUp(); 294 ExternalReference::SetUp();
303 Bootstrapper::InitializeOncePerProcess(); 295 Bootstrapper::InitializeOncePerProcess();
304 } 296 }
305 297
306 298
307 void V8::InitializeOncePerProcess() { 299 void V8::InitializeOncePerProcess() {
308 CallOnce(&init_once, &InitializeOncePerProcessImpl); 300 CallOnce(&init_once, &InitializeOncePerProcessImpl);
309 } 301 }
310 302
311 } } // namespace v8::internal 303 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/v8.h ('k') | test/cctest/test-api.cc » ('j') | test/cctest/test-api.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698