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" |
11 #include "src/regexp-stack.h" | 11 #include "src/regexp-stack.h" |
12 #include "src/v8threads.h" | 12 #include "src/v8threads.h" |
13 | 13 |
14 namespace v8 { | 14 namespace v8 { |
15 | 15 |
16 | 16 |
17 namespace { | 17 namespace { |
18 | 18 |
19 // Track whether this V8 instance has ever called v8::Locker. This allows the | 19 // Track whether this V8 instance has ever called v8::Locker. This allows the |
20 // API code to verify that the lock is always held when V8 is being entered. | 20 // API code to verify that the lock is always held when V8 is being entered. |
21 base::Atomic32 g_locker_was_ever_used_ = 0; | 21 base::Atomic32 g_locker_was_ever_used_ = 0; |
22 | 22 |
23 } // namespace | 23 } // namespace |
24 | 24 |
25 | 25 |
26 // Once the Locker is initialized, the current thread will be guaranteed to have | 26 // Once the Locker is initialized, the current thread will be guaranteed to have |
27 // the lock for a given isolate. | 27 // the lock for a given isolate. |
28 void Locker::Initialize(v8::Isolate* isolate) { | 28 void Locker::Initialize(v8::Isolate* isolate) { |
29 DCHECK(isolate != NULL); | 29 DCHECK(isolate != NULL); |
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 // 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 |
(...skipping 315 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
356 state = state->Next()) { | 356 state = state->Next()) { |
357 if (thread_id.Equals(state->id())) { | 357 if (thread_id.Equals(state->id())) { |
358 state->set_terminate_on_restore(true); | 358 state->set_terminate_on_restore(true); |
359 } | 359 } |
360 } | 360 } |
361 } | 361 } |
362 | 362 |
363 | 363 |
364 } // namespace internal | 364 } // namespace internal |
365 } // namespace v8 | 365 } // namespace v8 |
OLD | NEW |