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

Side by Side Diff: src/v8threads.cc

Issue 2912773002: Rename "NoBarrier" memory operations to "Relaxed". (Closed)
Patch Set: comment Created 3 years, 6 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
« no previous file with comments | « src/tracing/trace-event.h ('k') | src/zone/accounting-allocator.cc » ('j') | 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 // 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/v8threads.h" 5 #include "src/v8threads.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/debug.h" 9 #include "src/debug/debug.h"
10 #include "src/execution.h" 10 #include "src/execution.h"
(...skipping 14 matching lines...) Expand all
25 25
26 26
27 // Once the Locker is initialized, the current thread will be guaranteed to have 27 // Once the Locker is initialized, the current thread will be guaranteed to have
28 // the lock for a given isolate. 28 // the lock for a given isolate.
29 void Locker::Initialize(v8::Isolate* isolate) { 29 void Locker::Initialize(v8::Isolate* isolate) {
30 DCHECK(isolate != NULL); 30 DCHECK(isolate != NULL);
31 has_lock_ = false; 31 has_lock_ = false;
32 top_level_ = true; 32 top_level_ = true;
33 isolate_ = reinterpret_cast<i::Isolate*>(isolate); 33 isolate_ = reinterpret_cast<i::Isolate*>(isolate);
34 // Record that the Locker has been used at least once. 34 // Record that the Locker has been used at least once.
35 base::NoBarrier_Store(&g_locker_was_ever_used_, 1); 35 base::Relaxed_Store(&g_locker_was_ever_used_, 1);
36 // Get the big lock if necessary. 36 // Get the big lock if necessary.
37 if (!isolate_->thread_manager()->IsLockedByCurrentThread()) { 37 if (!isolate_->thread_manager()->IsLockedByCurrentThread()) {
38 isolate_->thread_manager()->Lock(); 38 isolate_->thread_manager()->Lock();
39 has_lock_ = true; 39 has_lock_ = true;
40 40
41 // This may be a locker within an unlocker in which case we have to 41 // This may be a locker within an unlocker in which case we have to
42 // get the saved state for this thread and restore it. 42 // get the saved state for this thread and restore it.
43 if (isolate_->thread_manager()->RestoreThread()) { 43 if (isolate_->thread_manager()->RestoreThread()) {
44 top_level_ = false; 44 top_level_ = false;
45 } else { 45 } else {
46 internal::ExecutionAccess access(isolate_); 46 internal::ExecutionAccess access(isolate_);
47 isolate_->stack_guard()->ClearThread(access); 47 isolate_->stack_guard()->ClearThread(access);
48 isolate_->stack_guard()->InitThread(access); 48 isolate_->stack_guard()->InitThread(access);
49 } 49 }
50 } 50 }
51 DCHECK(isolate_->thread_manager()->IsLockedByCurrentThread()); 51 DCHECK(isolate_->thread_manager()->IsLockedByCurrentThread());
52 } 52 }
53 53
54 54
55 bool Locker::IsLocked(v8::Isolate* isolate) { 55 bool Locker::IsLocked(v8::Isolate* isolate) {
56 DCHECK(isolate != NULL); 56 DCHECK(isolate != NULL);
57 i::Isolate* internal_isolate = reinterpret_cast<i::Isolate*>(isolate); 57 i::Isolate* internal_isolate = reinterpret_cast<i::Isolate*>(isolate);
58 return internal_isolate->thread_manager()->IsLockedByCurrentThread(); 58 return internal_isolate->thread_manager()->IsLockedByCurrentThread();
59 } 59 }
60 60
61 61
62 bool Locker::IsActive() { 62 bool Locker::IsActive() {
63 return !!base::NoBarrier_Load(&g_locker_was_ever_used_); 63 return !!base::Relaxed_Load(&g_locker_was_ever_used_);
64 } 64 }
65 65
66 66
67 Locker::~Locker() { 67 Locker::~Locker() {
68 DCHECK(isolate_->thread_manager()->IsLockedByCurrentThread()); 68 DCHECK(isolate_->thread_manager()->IsLockedByCurrentThread());
69 if (has_lock_) { 69 if (has_lock_) {
70 if (top_level_) { 70 if (top_level_) {
71 isolate_->thread_manager()->FreeThreadResources(); 71 isolate_->thread_manager()->FreeThreadResources();
72 } else { 72 } else {
73 isolate_->thread_manager()->ArchiveThread(); 73 isolate_->thread_manager()->ArchiveThread();
(...skipping 282 matching lines...) Expand 10 before | Expand all | Expand 10 after
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
OLDNEW
« no previous file with comments | « src/tracing/trace-event.h ('k') | src/zone/accounting-allocator.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698