OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "src/v8.h" | 5 #include "src/v8.h" |
6 | 6 |
7 #include "src/api.h" | 7 #include "src/api.h" |
8 #include "src/bootstrapper.h" | 8 #include "src/bootstrapper.h" |
9 #include "src/debug.h" | 9 #include "src/debug.h" |
10 #include "src/execution.h" | 10 #include "src/execution.h" |
(...skipping 19 matching lines...) Expand all Loading... |
30 has_lock_= false; | 30 has_lock_= false; |
31 top_level_ = true; | 31 top_level_ = true; |
32 isolate_ = reinterpret_cast<i::Isolate*>(isolate); | 32 isolate_ = reinterpret_cast<i::Isolate*>(isolate); |
33 // Record that the Locker has been used at least once. | 33 // Record that the Locker has been used at least once. |
34 base::NoBarrier_Store(&g_locker_was_ever_used_, 1); | 34 base::NoBarrier_Store(&g_locker_was_ever_used_, 1); |
35 // Get the big lock if necessary. | 35 // Get the big lock if necessary. |
36 if (!isolate_->thread_manager()->IsLockedByCurrentThread()) { | 36 if (!isolate_->thread_manager()->IsLockedByCurrentThread()) { |
37 isolate_->thread_manager()->Lock(); | 37 isolate_->thread_manager()->Lock(); |
38 has_lock_ = true; | 38 has_lock_ = true; |
39 | 39 |
40 // Make sure that V8 is initialized. Archiving of threads interferes | |
41 // with deserialization by adding additional root pointers, so we must | |
42 // initialize here, before anyone can call ~Locker() or Unlocker(). | |
43 if (!isolate_->IsInitialized()) { | |
44 isolate_->Enter(); | |
45 V8::Initialize(); | |
46 isolate_->Exit(); | |
47 } | |
48 | |
49 // This may be a locker within an unlocker in which case we have to | 40 // This may be a locker within an unlocker in which case we have to |
50 // get the saved state for this thread and restore it. | 41 // get the saved state for this thread and restore it. |
51 if (isolate_->thread_manager()->RestoreThread()) { | 42 if (isolate_->thread_manager()->RestoreThread()) { |
52 top_level_ = false; | 43 top_level_ = false; |
53 } else { | 44 } else { |
54 internal::ExecutionAccess access(isolate_); | 45 internal::ExecutionAccess access(isolate_); |
55 isolate_->stack_guard()->ClearThread(access); | 46 isolate_->stack_guard()->ClearThread(access); |
56 isolate_->stack_guard()->InitThread(access); | 47 isolate_->stack_guard()->InitThread(access); |
57 } | 48 } |
58 } | 49 } |
(...skipping 306 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
365 state = state->Next()) { | 356 state = state->Next()) { |
366 if (thread_id.Equals(state->id())) { | 357 if (thread_id.Equals(state->id())) { |
367 state->set_terminate_on_restore(true); | 358 state->set_terminate_on_restore(true); |
368 } | 359 } |
369 } | 360 } |
370 } | 361 } |
371 | 362 |
372 | 363 |
373 } // namespace internal | 364 } // namespace internal |
374 } // namespace v8 | 365 } // namespace v8 |
OLD | NEW |