| OLD | NEW |
| 1 // Copyright 2014 the V8 project authors. All rights reserved. | 1 // Copyright 2014 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/assert-scope.h" | 5 #include "src/assert-scope.h" |
| 6 | 6 |
| 7 #include "src/base/lazy-instance.h" | 7 #include "src/base/lazy-instance.h" |
| 8 #include "src/base/platform/platform.h" | 8 #include "src/base/platform/platform.h" |
| 9 #include "src/isolate-inl.h" | 9 #include "src/isolate-inl.h" |
| 10 #include "src/utils.h" | 10 #include "src/utils.h" |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 75 PerThreadAssertData::SetCurrent(data_); | 75 PerThreadAssertData::SetCurrent(data_); |
| 76 } | 76 } |
| 77 data_->IncrementLevel(); | 77 data_->IncrementLevel(); |
| 78 old_state_ = data_->Get(kType); | 78 old_state_ = data_->Get(kType); |
| 79 data_->Set(kType, kAllow); | 79 data_->Set(kType, kAllow); |
| 80 } | 80 } |
| 81 | 81 |
| 82 | 82 |
| 83 template <PerThreadAssertType kType, bool kAllow> | 83 template <PerThreadAssertType kType, bool kAllow> |
| 84 PerThreadAssertScope<kType, kAllow>::~PerThreadAssertScope() { | 84 PerThreadAssertScope<kType, kAllow>::~PerThreadAssertScope() { |
| 85 DCHECK_NOT_NULL(data_); | 85 DCHECK(data_); |
| 86 data_->Set(kType, old_state_); | 86 data_->Set(kType, old_state_); |
| 87 if (data_->DecrementLevel()) { | 87 if (data_->DecrementLevel()) { |
| 88 PerThreadAssertData::SetCurrent(NULL); | 88 PerThreadAssertData::SetCurrent(NULL); |
| 89 delete data_; | 89 delete data_; |
| 90 } | 90 } |
| 91 } | 91 } |
| 92 | 92 |
| 93 | 93 |
| 94 // static | 94 // static |
| 95 template <PerThreadAssertType kType, bool kAllow> | 95 template <PerThreadAssertType kType, bool kAllow> |
| 96 bool PerThreadAssertScope<kType, kAllow>::IsAllowed() { | 96 bool PerThreadAssertScope<kType, kAllow>::IsAllowed() { |
| 97 PerThreadAssertData* data = PerThreadAssertData::GetCurrent(); | 97 PerThreadAssertData* data = PerThreadAssertData::GetCurrent(); |
| 98 return data == NULL || data->Get(kType); | 98 return data == NULL || data->Get(kType); |
| 99 } | 99 } |
| 100 | 100 |
| 101 | 101 |
| 102 template <PerIsolateAssertType kType, bool kAllow> | 102 template <PerIsolateAssertType kType, bool kAllow> |
| 103 class PerIsolateAssertScope<kType, kAllow>::DataBit | 103 class PerIsolateAssertScope<kType, kAllow>::DataBit |
| 104 : public BitField<bool, kType, 1> {}; | 104 : public BitField<bool, kType, 1> {}; |
| 105 | 105 |
| 106 | 106 |
| 107 template <PerIsolateAssertType kType, bool kAllow> | 107 template <PerIsolateAssertType kType, bool kAllow> |
| 108 PerIsolateAssertScope<kType, kAllow>::PerIsolateAssertScope(Isolate* isolate) | 108 PerIsolateAssertScope<kType, kAllow>::PerIsolateAssertScope(Isolate* isolate) |
| 109 : isolate_(isolate), old_data_(isolate->per_isolate_assert_data()) { | 109 : isolate_(isolate), old_data_(isolate->per_isolate_assert_data()) { |
| 110 DCHECK_NOT_NULL(isolate); | 110 DCHECK(isolate); |
| 111 STATIC_ASSERT(kType < 32); | 111 STATIC_ASSERT(kType < 32); |
| 112 isolate_->set_per_isolate_assert_data(DataBit::update(old_data_, kAllow)); | 112 isolate_->set_per_isolate_assert_data(DataBit::update(old_data_, kAllow)); |
| 113 } | 113 } |
| 114 | 114 |
| 115 | 115 |
| 116 template <PerIsolateAssertType kType, bool kAllow> | 116 template <PerIsolateAssertType kType, bool kAllow> |
| 117 PerIsolateAssertScope<kType, kAllow>::~PerIsolateAssertScope() { | 117 PerIsolateAssertScope<kType, kAllow>::~PerIsolateAssertScope() { |
| 118 isolate_->set_per_isolate_assert_data(old_data_); | 118 isolate_->set_per_isolate_assert_data(old_data_); |
| 119 } | 119 } |
| 120 | 120 |
| (...skipping 25 matching lines...) Expand all Loading... |
| 146 template class PerIsolateAssertScope<JAVASCRIPT_EXECUTION_THROWS, true>; | 146 template class PerIsolateAssertScope<JAVASCRIPT_EXECUTION_THROWS, true>; |
| 147 template class PerIsolateAssertScope<ALLOCATION_FAILURE_ASSERT, false>; | 147 template class PerIsolateAssertScope<ALLOCATION_FAILURE_ASSERT, false>; |
| 148 template class PerIsolateAssertScope<ALLOCATION_FAILURE_ASSERT, true>; | 148 template class PerIsolateAssertScope<ALLOCATION_FAILURE_ASSERT, true>; |
| 149 template class PerIsolateAssertScope<DEOPTIMIZATION_ASSERT, false>; | 149 template class PerIsolateAssertScope<DEOPTIMIZATION_ASSERT, false>; |
| 150 template class PerIsolateAssertScope<DEOPTIMIZATION_ASSERT, true>; | 150 template class PerIsolateAssertScope<DEOPTIMIZATION_ASSERT, true>; |
| 151 template class PerIsolateAssertScope<COMPILATION_ASSERT, false>; | 151 template class PerIsolateAssertScope<COMPILATION_ASSERT, false>; |
| 152 template class PerIsolateAssertScope<COMPILATION_ASSERT, true>; | 152 template class PerIsolateAssertScope<COMPILATION_ASSERT, true>; |
| 153 | 153 |
| 154 } // namespace internal | 154 } // namespace internal |
| 155 } // namespace v8 | 155 } // namespace v8 |
| OLD | NEW |