35 template<
typename K,
typename V>
39 typedef std::map<K, PersistentContainerValue>
Impl;
42 static bool Empty(
Impl* impl) {
return impl->empty(); }
43 static size_t Size(
Impl* impl) {
return impl->size(); }
51 std::pair<Iterator, bool> res = impl->insert(std::make_pair(key, value));
54 old_value = res.first->second;
55 res.first->second = value;
82 template<
typename K,
typename V>
118 template<
typename K,
typename V,
typename Traits>
199 typedef typename Traits::Iterator It;
202 while (!Traits::Empty(&
impl_)) {
203 typename Traits::Impl impl;
204 Traits::Swap(
impl_, impl);
205 for (It
i = Traits::Begin(&impl);
i != Traits::End(&impl); ++
i) {
272 *reference =
Leak(&value);
285 if (Traits::kCallbackType !=
kNotWeak) {
287 persistent->template SetWeak<typename Traits::WeakCallbackDataType>(
288 Traits::WeakCallbackParameter(
this, key, value),
WeakCallback);
292 return Release(old_value).Pass();
297 if (Traits::kCallbackType !=
kNotWeak) {
299 Traits::MapFromWeakCallbackData(data);
300 K key = Traits::KeyFromWeakCallbackData(data);
302 persistentValueMap->
Remove(key).Pass(), key);
308 return reinterpret_cast<V*
>(v);
323 V* v = persistent->
val_;
324 persistent->
val_ = 0;
342 Traits::DisposeCallbackData(
343 p.template ClearWeak<typename Traits::WeakCallbackDataType>());
360 template<
typename K,
typename V,
371 typedef std::vector<PersistentContainerValue>
Impl;
374 impl->push_back(value);
377 return impl->empty();
386 impl->reserve(capacity);
404 template<
typename V,
typename Traits = DefaultPersistentValueVectorTraits>
432 return Traits::IsEmpty(&
impl_);
439 return Traits::Size(&
impl_);
453 size_t length = Traits::Size(&
impl_);
454 for (
size_t i = 0;
i < length;
i++) {
458 Traits::Clear(&
impl_);
466 Traits::ReserveCapacity(&
impl_, capacity);
472 V* v = persistent->
val_;
473 persistent->
val_ = 0;
478 return reinterpret_cast<V*
>(v);
A default trait implementation for PersistentValueMap, which inherits a std:map backing map from StdM...
PersistentValueMap< K, V, DefaultPersistentValueMapTraits< K, V > > MapType
static const PersistentContainerCallbackType kCallbackType
void WeakCallbackDataType
static WeakCallbackDataType * WeakCallbackParameter(MapType *map, const K &key, Local< V > value)
static MapType * MapFromWeakCallbackData(const WeakCallbackData< V, WeakCallbackDataType > &data)
static void DisposeCallbackData(WeakCallbackDataType *data)
static K KeyFromWeakCallbackData(const WeakCallbackData< V, WeakCallbackDataType > &data)
static void Dispose(Isolate *isolate, UniquePersistent< V > value, K key)
static size_t Size(const Impl *impl)
static bool IsEmpty(const Impl *impl)
static void Clear(Impl *impl)
static PersistentContainerValue Get(const Impl *impl, size_t i)
static void Append(Impl *impl, PersistentContainerValue value)
std::vector< PersistentContainerValue > Impl
static void ReserveCapacity(Impl *impl, size_t capacity)
A stack-allocated class that governs a number of local handles.
Isolate represents an isolated instance of the V8 engine.
void SetReference(const Persistent< T > &parent, const Persistent< S > &child)
Allows the host application to declare implicit references from an object to another object.
A light-weight stack-allocated object handle.
static Local< T > New(Isolate *isolate, Handle< T > that)
Create a local handle for the content of another handle.
bool IsWeak() const
Returns true if the handle's reference is weak.
Helper class for GetReference/SetWithReference.
void operator=(PersistentContainerValue value)
bool SetReturnValue(ReturnValue< T > returnValue)
PersistentValueReference(const PersistentValueReference &other)
PersistentValueReference(PersistentContainerValue value)
void operator=(const PersistentValueReference &other)
Local< V > NewLocal(Isolate *isolate) const
PersistentContainerValue value_
PersistentValueReference()
A map wrapper that allows using UniquePersistent as a mapped value.
size_t Size()
Return size of the map.
static PersistentContainerValue Leak(UniquePersistent< V > *persistent)
Local< V > Get(const K &key)
Get value stored in map.
bool IsWeak()
Return whether the map holds weak persistents.
void SetReference(const K &key, const Persistent< Object > &parent)
Call Isolate::SetReference with the given parent and the map value.
UniquePersistent< V > Set(const K &key, UniquePersistent< V > value)
Put value into map, like Set(const K&, Local<V>).
bool Contains(const K &key)
Check whether a value is contained in the map.
static void WeakCallback(const WeakCallbackData< V, typename Traits::WeakCallbackDataType > &data)
UniquePersistent< V > Remove(const K &key)
Return value for key and remove it from the map.
UniquePersistent< V > Set(const K &key, UniquePersistent< V > value, PersistentValueReference *reference)
Put a value into the map and update the reference.
bool SetReturnValue(const K &key, ReturnValue< Value > returnValue)
Get value stored in map and set it in returnValue.
PersistentValueReference GetReference(const K &key)
Get a reference to a map value.
static PersistentContainerValue ClearAndLeak(UniquePersistent< V > *persistent)
PersistentValueMap(PersistentValueMap &)
static UniquePersistent< V > Release(PersistentContainerValue v)
Return a container value as UniquePersistent and make sure the weak callback is properly disposed of.
static V * FromVal(PersistentContainerValue v)
void Clear()
Traverses the map repeatedly, in case side effects of disposal cause insertions.
UniquePersistent< V > SetUnique(const K &key, UniquePersistent< V > *persistent)
Put the value into the map, and set the 'weak' callback when demanded by the Traits class.
void operator=(PersistentValueMap &)
static bool SetReturnValueFromVal(ReturnValue< Value > *returnValue, PersistentContainerValue value)
UniquePersistent< V > Set(const K &key, Local< V > value)
Put value into map.
PersistentValueMap(Isolate *isolate)
A vector wrapper that safely stores UniquePersistent values.
void Append(Local< V > value)
Append a value to the vector.
Local< V > Get(size_t index) const
Retrieve the i-th value in the vector.
static PersistentContainerValue ClearAndLeak(UniquePersistent< V > *persistent)
static V * FromVal(PersistentContainerValue v)
bool IsEmpty() const
Are there any values in the vector?
PersistentValueVector(Isolate *isolate)
void Clear()
Remove all elements from the vector.
void ReserveCapacity(size_t capacity)
Reserve capacity in the vector.
size_t Size() const
How many elements are in the vector?
void Append(UniquePersistent< V > persistent)
Append a persistent's value to the vector.
A PersistentBase which allows copy and assignment.
void SetInternal(internal::Object *value)
A default trait implemenation for PersistentValueMap which uses std::map as a backing map.
static PersistentContainerValue Set(Impl *impl, K key, PersistentContainerValue value)
static Iterator End(Impl *impl)
static size_t Size(Impl *impl)
static bool Empty(Impl *impl)
static PersistentContainerValue Get(Impl *impl, K key)
static K Key(Iterator it)
static Iterator Begin(Impl *impl)
std::map< K, PersistentContainerValue > Impl
static PersistentContainerValue Remove(Impl *impl, K key)
static PersistentContainerValue Value(Iterator it)
static void Swap(Impl &a, Impl &b)
A map that uses UniquePersistent as value and std::map as the backing implementation.
StdPersistentValueMap(Isolate *isolate)
A PersistentBase which has move semantics.
UniquePersistent Pass()
Pass allows returning uniques from functions, etc.
Isolate * GetIsolate() const
#define V(NAME, Name, id)
enable harmony numeric enable harmony object literal extensions Optimize object Array DOM strings and string trace pretenuring decisions of HAllocate instructions Enables optimizations which favor memory size over execution speed maximum source size in bytes considered for a single inlining maximum cumulative number of AST nodes considered for inlining trace the tracking of allocation sites deoptimize every n garbage collections perform array bounds checks elimination analyze liveness of environment slots and zap dead values flushes the cache of optimized code for closures on every GC allow uint32 values on optimize frames if they are used only in safe operations track concurrent recompilation artificial compilation delay in ms do not emit check maps for constant values that have a leaf map
enable harmony numeric enable harmony object literal extensions Optimize object size
enable harmony numeric enable harmony object literal extensions Optimize object Array DOM strings and string trace pretenuring decisions of HAllocate instructions Enables optimizations which favor memory size over execution speed maximum source size in bytes considered for a single inlining maximum cumulative number of AST nodes considered for inlining trace the tracking of allocation sites deoptimize every n garbage collections perform array bounds checks elimination analyze liveness of environment slots and zap dead values flushes the cache of optimized code for closures on every GC allow uint32 values on optimize frames if they are used only in safe operations track concurrent recompilation artificial compilation delay in ms do not emit check maps for constant values that have a leaf deoptimize the optimized code if the layout of the maps changes enable context specialization in TurboFan execution budget before interrupt is triggered max percentage of megamorphic generic ICs to allow optimization enable use of SAHF instruction if enable use of VFP3 instructions if available enable use of NEON instructions if enable use of SDIV and UDIV instructions if enable use of MLS instructions if enable loading bit constant by means of movw movt instruction enable unaligned accesses for enable use of d16 d31 registers on ARM this requires VFP3 force all emitted branches to be in long enable alignment of csp to bytes on platforms which prefer the register to always be NULL
Debugger support for the V8 JavaScript engine.
PersistentContainerCallbackType
static const uintptr_t kPersistentContainerNotFound
uintptr_t PersistentContainerValue