44 static const uintptr_t kPersistentContainerNotFound = 0;
53 template<
typename K,
typename V>
57 typedef std::map<K, PersistentContainerValue>
Impl;
60 static bool Empty(
Impl* impl) {
return impl->empty(); }
61 static size_t Size(
Impl* impl) {
return impl->size(); }
69 std::pair<Iterator, bool> res = impl->insert(std::make_pair(key, value));
72 old_value = res.first->second;
73 res.first->second = value;
79 if (it == impl->end())
return kPersistentContainerNotFound;
84 if (it == impl->end())
return kPersistentContainerNotFound;
99 template<
typename K,
typename V>
121 template<
typename K,
typename V>
126 Impl* impl, K key) { }
140 template<
typename K,
typename V,
typename Traits>
163 return Local<V>::New(isolate_, FromVal(Traits::Get(&impl_, key)));
170 return Traits::Get(&impl_, key) != 0;
180 bool hasValue = value != 0;
182 returnValue.SetInternal(
183 *reinterpret_cast<internal::Object**>(FromVal(value)));
194 reinterpret_cast<internal::Object**>(parent.val_),
195 reinterpret_cast<internal::Object**>(FromVal(Traits::Get(&impl_, key))));
205 return SetUnique(key, &persistent);
212 return SetUnique(key, &value);
219 return Release(Traits::Remove(&impl_, key)).Pass();
227 typedef typename Traits::Iterator It;
230 while (!Traits::Empty(&impl_)) {
231 typename Traits::Impl impl;
232 Traits::Swap(impl_, impl);
233 for (It i = Traits::Begin(&impl); i != Traits::End(&impl); ++i) {
234 Traits::Dispose(isolate_, Release(Traits::Value(i)).Pass(), &impl,
249 if (Traits::kIsWeak) {
251 persistent->template SetWeak<typename Traits::WeakCallbackDataType>(
252 Traits::WeakCallbackParameter(&impl_, key, value), WeakCallback);
255 Traits::Set(&impl_, key, ClearAndLeak(persistent));
256 return Release(old_value).Pass();
259 static void WeakCallback(
260 const WeakCallbackData<V, typename Traits::WeakCallbackDataType>& data) {
261 if (Traits::kIsWeak) {
262 typename Traits::Impl* impl = Traits::ImplFromWeakCallbackData(data);
263 K key = Traits::KeyFromWeakCallbackData(data);
265 Traits::Dispose(data.GetIsolate(), Release(value).Pass(), impl, key);
270 return reinterpret_cast<V*
>(v);
274 UniquePersistent<V>* persistent) {
275 V* v = persistent->val_;
276 persistent->val_ = 0;
286 UniquePersistent<V> p;
288 if (Traits::kIsWeak && !p.IsEmpty()) {
289 Traits::DisposeCallbackData(
290 p.template ClearWeak<typename Traits::WeakCallbackDataType>());
296 typename Traits::Impl impl_;
307 template<
typename K,
typename V,
308 typename Traits = DefaultPersistentValueMapTraits<K, V> >
326 template<
typename K,
typename V>
327 typename StrongMapTraits<K, V>::WeakCallbackDataType*
334 template<
typename K,
typename V>
342 template<
typename K,
typename V>
349 template<
typename K,
typename V>
enable upcoming ES6 features enable harmony block scoping enable harmony enable harmony proxies enable harmony generators enable harmony numeric enable harmony string enable harmony math functions harmony_scoping harmony_symbols harmony_collections harmony_iteration harmony_strings harmony_scoping harmony_maths tracks arrays with only smi values Optimize object Array DOM strings and string pretenure call new trace pretenuring decisions of HAllocate instructions track fields with only smi values track fields with heap values track_fields track_fields Enables optimizations which favor memory size over execution speed use string slices optimization filter maximum number of GVN fix point iterations use function inlining use allocation folding eliminate write barriers targeting allocations in optimized code maximum source size in bytes considered for a single inlining maximum cumulative number of AST nodes considered for inlining crankshaft harvests type feedback from stub cache trace check elimination phase hydrogen tracing filter NULL
static V8_INLINE Local< T > New(Isolate *isolate, Handle< T > that)
V8_INLINE bool SetReturnValue(const K &key, ReturnValue< Value > &returnValue)
UniquePersistent< V > Set(const K &key, UniquePersistent< V > value)
static PersistentContainerValue Remove(Impl *impl, K key)
static size_t Size(Impl *impl)
static WeakCallbackDataType * WeakCallbackParameter(Impl *impl, const K &key, Local< V > value)
V8_INLINE ~PersistentValueMap()
V8_INLINE Local< V > Get(const K &key)
static void Dispose(Isolate *isolate, UniquePersistent< V > value, Impl *impl, K key)
static bool Empty(Impl *impl)
uintptr_t PersistentContainerValue
V8_INLINE void SetReference(const K &key, const Persistent< Object > &parent)
static K Key(Iterator it)
static Iterator Begin(Impl *impl)
static Iterator End(Impl *impl)
V8_INLINE UniquePersistent< V > Remove(const K &key)
UniquePersistent< V > Set(const K &key, Local< V > value)
V8_INLINE Isolate * GetIsolate()
static Impl * ImplFromWeakCallbackData(const WeakCallbackData< V, WeakCallbackDataType > &data)
void WeakCallbackDataType
StdPersistentValueMap(Isolate *isolate)
static K KeyFromWeakCallbackData(const WeakCallbackData< V, WeakCallbackDataType > &data)
V8_INLINE bool Contains(const K &key)
void SetReference(const Persistent< T > &parent, const Persistent< S > &child)
StrongMapTraits< K, V >::Impl Impl
static PersistentContainerValue Value(Iterator it)
static const bool kIsWeak
static PersistentContainerValue Set(Impl *impl, K key, PersistentContainerValue value)
V8_INLINE PersistentValueMap(Isolate *isolate)
std::map< K, PersistentContainerValue > Impl
static void Swap(Impl &a, Impl &b)
static void DisposeCallbackData(WeakCallbackDataType *data)
static PersistentContainerValue Get(Impl *impl, K key)
StdMapTraits< K, V >::Impl Impl