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/handles.h" | 5 #include "src/handles.h" |
6 | 6 |
7 #include "src/address-map.h" | 7 #include "src/address-map.h" |
8 #include "src/base/logging.h" | 8 #include "src/base/logging.h" |
9 #include "src/identity-map.h" | 9 #include "src/identity-map.h" |
10 #include "src/objects-inl.h" | 10 #include "src/objects-inl.h" |
11 | 11 |
12 namespace v8 { | 12 namespace v8 { |
13 namespace internal { | 13 namespace internal { |
14 | 14 |
| 15 // Handles should be trivially copyable so that they can be efficiently passed |
| 16 // by value. If they are not trivially copyable, they cannot be passed in |
| 17 // registers. |
| 18 static_assert(std::is_trivially_copyable<HandleBase>::value, |
| 19 "HandleBase should be trivially copyable"); |
| 20 static_assert(std::is_trivially_copyable<Handle<Object>>::value, |
| 21 "Handle<Object> should be trivially copyable"); |
| 22 static_assert(std::is_trivially_copyable<MaybeHandle<Object>>::value, |
| 23 "MaybeHandle<Object> should be trivially copyable"); |
| 24 |
15 #ifdef DEBUG | 25 #ifdef DEBUG |
16 bool HandleBase::IsDereferenceAllowed(DereferenceCheckMode mode) const { | 26 bool HandleBase::IsDereferenceAllowed(DereferenceCheckMode mode) const { |
17 DCHECK_NOT_NULL(location_); | 27 DCHECK_NOT_NULL(location_); |
18 Object* object = *location_; | 28 Object* object = *location_; |
19 if (object->IsSmi()) return true; | 29 if (object->IsSmi()) return true; |
20 HeapObject* heap_object = HeapObject::cast(object); | 30 HeapObject* heap_object = HeapObject::cast(object); |
21 Heap* heap = heap_object->GetHeap(); | 31 Heap* heap = heap_object->GetHeap(); |
22 Object** roots_array_start = heap->roots_array_start(); | 32 Object** roots_array_start = heap->roots_array_start(); |
23 if (roots_array_start <= location_ && | 33 if (roots_array_start <= location_ && |
24 location_ < roots_array_start + Heap::kStrongRootListLength && | 34 location_ < roots_array_start + Heap::kStrongRootListLength && |
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
193 data->next = prev_next_; | 203 data->next = prev_next_; |
194 data->limit = prev_limit_; | 204 data->limit = prev_limit_; |
195 #ifdef DEBUG | 205 #ifdef DEBUG |
196 handles_detached_ = true; | 206 handles_detached_ = true; |
197 #endif | 207 #endif |
198 return deferred; | 208 return deferred; |
199 } | 209 } |
200 | 210 |
201 } // namespace internal | 211 } // namespace internal |
202 } // namespace v8 | 212 } // namespace v8 |
OLD | NEW |