| OLD | NEW |
| 1 // Copyright 2013 the V8 project authors. All rights reserved. | 1 // Copyright 2013 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 #ifndef V8_HYDROGEN_UNIQUE_H_ | 5 #ifndef V8_HYDROGEN_UNIQUE_H_ |
| 6 #define V8_HYDROGEN_UNIQUE_H_ | 6 #define V8_HYDROGEN_UNIQUE_H_ |
| 7 | 7 |
| 8 #include <ostream> // NOLINT(readability/streams) | 8 #include <ostream> // NOLINT(readability/streams) |
| 9 | 9 |
| 10 #include "src/base/functional.h" | 10 #include "src/base/functional.h" |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 101 inline bool IsKnownGlobal(void* global) const { | 101 inline bool IsKnownGlobal(void* global) const { |
| 102 DCHECK(IsInitialized()); | 102 DCHECK(IsInitialized()); |
| 103 return raw_address_ == reinterpret_cast<Address>(global); | 103 return raw_address_ == reinterpret_cast<Address>(global); |
| 104 } | 104 } |
| 105 | 105 |
| 106 inline Handle<T> handle() const { | 106 inline Handle<T> handle() const { |
| 107 return handle_; | 107 return handle_; |
| 108 } | 108 } |
| 109 | 109 |
| 110 template <class S> static Unique<T> cast(Unique<S> that) { | 110 template <class S> static Unique<T> cast(Unique<S> that) { |
| 111 return Unique<T>(that.raw_address_, Handle<T>::cast(that.handle_)); | 111 // Allow fetching location() to unsafe-cast the handle. This is necessary |
| 112 // since we can't concurrently safe-cast. Safe-casting requires looking at |
| 113 // the heap which may be moving concurrently to the compiler thread. |
| 114 AllowHandleDereference allow_deref; |
| 115 return Unique<T>(that.raw_address_, |
| 116 Handle<T>(reinterpret_cast<T**>(that.handle_.location()))); |
| 112 } | 117 } |
| 113 | 118 |
| 114 inline bool IsInitialized() const { | 119 inline bool IsInitialized() const { |
| 115 return raw_address_ != NULL || handle_.is_null(); | 120 return raw_address_ != NULL || handle_.is_null(); |
| 116 } | 121 } |
| 117 | 122 |
| 118 // TODO(titzer): this is a hack to migrate to Unique<T> incrementally. | 123 // TODO(titzer): this is a hack to migrate to Unique<T> incrementally. |
| 119 static Unique<T> CreateUninitialized(Handle<T> handle) { | 124 static Unique<T> CreateUninitialized(Handle<T> handle) { |
| 120 return Unique<T>(NULL, handle); | 125 return Unique<T>(NULL, handle); |
| 121 } | 126 } |
| (...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 350 } | 355 } |
| 351 capacity_ = new_capacity; | 356 capacity_ = new_capacity; |
| 352 array_ = new_array; | 357 array_ = new_array; |
| 353 } | 358 } |
| 354 } | 359 } |
| 355 }; | 360 }; |
| 356 | 361 |
| 357 } } // namespace v8::internal | 362 } } // namespace v8::internal |
| 358 | 363 |
| 359 #endif // V8_HYDROGEN_UNIQUE_H_ | 364 #endif // V8_HYDROGEN_UNIQUE_H_ |
| OLD | NEW |