| 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 #ifndef V8_UTIL_H_ | 5 #ifndef V8_UTIL_H_ |
| 6 #define V8_UTIL_H_ | 6 #define V8_UTIL_H_ |
| 7 | 7 |
| 8 #include "v8.h" // NOLINT(build/include) | 8 #include "v8.h" // NOLINT(build/include) |
| 9 #include <map> | 9 #include <map> |
| 10 #include <vector> | 10 #include <vector> |
| (...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 199 * Call Isolate::SetReference with the given parent and the map value. | 199 * Call Isolate::SetReference with the given parent and the map value. |
| 200 */ | 200 */ |
| 201 void SetReference(const K& key, | 201 void SetReference(const K& key, |
| 202 const Persistent<Object>& parent) { | 202 const Persistent<Object>& parent) { |
| 203 GetIsolate()->SetReference( | 203 GetIsolate()->SetReference( |
| 204 reinterpret_cast<internal::Object**>(parent.val_), | 204 reinterpret_cast<internal::Object**>(parent.val_), |
| 205 reinterpret_cast<internal::Object**>(FromVal(Traits::Get(&impl_, key)))); | 205 reinterpret_cast<internal::Object**>(FromVal(Traits::Get(&impl_, key)))); |
| 206 } | 206 } |
| 207 | 207 |
| 208 /** | 208 /** |
| 209 * Call V8::RegisterExternallyReferencedObject with the map value for given | 209 * Deprecated. Call V8::RegisterExternallyReferencedObject with the map value |
| 210 * key. | 210 * for given key. |
| 211 * TODO(hlopko) Remove once migration to reporter is finished. |
| 211 */ | 212 */ |
| 212 void RegisterExternallyReferencedObject(K& key) { | 213 void RegisterExternallyReferencedObject(K& key) {} |
| 214 |
| 215 /** |
| 216 * Use EmbedderReachableReferenceReporter with the map value for given key. |
| 217 */ |
| 218 void RegisterExternallyReferencedObject( |
| 219 EmbedderReachableReferenceReporter* reporter, K& key) { |
| 213 DCHECK(Contains(key)); | 220 DCHECK(Contains(key)); |
| 214 V8::RegisterExternallyReferencedObject( | 221 reporter->ReportExternalReference(FromVal(Traits::Get(&impl_, key))); |
| 215 reinterpret_cast<internal::Object**>(FromVal(Traits::Get(&impl_, key))), | |
| 216 reinterpret_cast<internal::Isolate*>(GetIsolate())); | |
| 217 } | 222 } |
| 218 | 223 |
| 219 /** | 224 /** |
| 220 * Return value for key and remove it from the map. | 225 * Return value for key and remove it from the map. |
| 221 */ | 226 */ |
| 222 Global<V> Remove(const K& key) { | 227 Global<V> Remove(const K& key) { |
| 223 return Release(Traits::Remove(&impl_, key)).Pass(); | 228 return Release(Traits::Remove(&impl_, key)).Pass(); |
| 224 } | 229 } |
| 225 | 230 |
| 226 /** | 231 /** |
| (...skipping 418 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 645 return reinterpret_cast<V*>(v); | 650 return reinterpret_cast<V*>(v); |
| 646 } | 651 } |
| 647 | 652 |
| 648 Isolate* isolate_; | 653 Isolate* isolate_; |
| 649 typename Traits::Impl impl_; | 654 typename Traits::Impl impl_; |
| 650 }; | 655 }; |
| 651 | 656 |
| 652 } // namespace v8 | 657 } // namespace v8 |
| 653 | 658 |
| 654 #endif // V8_UTIL_H | 659 #endif // V8_UTIL_H |
| OLD | NEW |