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