V8 Project
v8::internal::PrototypeIterator Class Reference

A class to uniformly access the prototype of any Object and walk its prototype chain. More...

#include <prototype.h>

+ Collaboration diagram for v8::internal::PrototypeIterator:

Public Types

enum  WhereToStart { START_AT_RECEIVER , START_AT_PROTOTYPE }
 
enum  WhereToEnd { END_AT_NULL , END_AT_NON_HIDDEN }
 

Public Member Functions

 PrototypeIterator (Isolate *isolate, Handle< Object > receiver, WhereToStart where_to_start=START_AT_PROTOTYPE)
 
 PrototypeIterator (Isolate *isolate, Object *receiver, WhereToStart where_to_start=START_AT_PROTOTYPE)
 
 PrototypeIterator (Map *receiver_map)
 
 PrototypeIterator (Handle< Map > receiver_map)
 
 ~PrototypeIterator ()
 
ObjectGetCurrent () const
 
void Advance ()
 
void AdvanceIgnoringProxies ()
 
bool IsAtEnd (WhereToEnd where_to_end=END_AT_NULL) const
 
bool IsAtEnd (Object *final_object)
 
bool IsAtEnd (Handle< Object > final_object)
 

Static Public Member Functions

static Handle< ObjectGetCurrent (const PrototypeIterator &iterator)
 

Private Member Functions

 DISALLOW_COPY_AND_ASSIGN (PrototypeIterator)
 

Private Attributes

bool did_jump_to_prototype_chain_
 
Objectobject_
 
Handle< Objecthandle_
 
Isolateisolate_
 

Detailed Description

A class to uniformly access the prototype of any Object and walk its prototype chain.

The PrototypeIterator can either start at the prototype (default), or include the receiver itself. If a PrototypeIterator is constructed for a Map, it will always start at the prototype.

The PrototypeIterator can either run to the null_value(), the first non-hidden prototype, or a given object.

Definition at line 25 of file prototype.h.

Member Enumeration Documentation

◆ WhereToEnd

Enumerator
END_AT_NULL 
END_AT_NON_HIDDEN 

Definition at line 29 of file prototype.h.

◆ WhereToStart

Enumerator
START_AT_RECEIVER 
START_AT_PROTOTYPE 

Definition at line 27 of file prototype.h.

Constructor & Destructor Documentation

◆ PrototypeIterator() [1/4]

v8::internal::PrototypeIterator::PrototypeIterator ( Isolate isolate,
Handle< Object receiver,
WhereToStart  where_to_start = START_AT_PROTOTYPE 
)
inline

Definition at line 31 of file prototype.h.

34  object_(NULL),
35  handle_(receiver),
36  isolate_(isolate) {
37  CHECK(!handle_.is_null());
38  if (where_to_start == START_AT_PROTOTYPE) {
39  Advance();
40  }
41  }
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
#define CHECK(condition)
Definition: logging.h:36

References Advance(), CHECK, handle_, and START_AT_PROTOTYPE.

+ Here is the call graph for this function:

◆ PrototypeIterator() [2/4]

v8::internal::PrototypeIterator::PrototypeIterator ( Isolate isolate,
Object receiver,
WhereToStart  where_to_start = START_AT_PROTOTYPE 
)
inline

Definition at line 42 of file prototype.h.

45  object_(receiver),
46  isolate_(isolate) {
47  if (where_to_start == START_AT_PROTOTYPE) {
48  Advance();
49  }
50  }

References Advance(), and START_AT_PROTOTYPE.

+ Here is the call graph for this function:

◆ PrototypeIterator() [3/4]

v8::internal::PrototypeIterator::PrototypeIterator ( Map receiver_map)
inlineexplicit

Definition at line 51 of file prototype.h.

53  object_(receiver_map->prototype()),
54  isolate_(receiver_map->GetIsolate()) {}

◆ PrototypeIterator() [4/4]

v8::internal::PrototypeIterator::PrototypeIterator ( Handle< Map receiver_map)
inlineexplicit

Definition at line 55 of file prototype.h.

57  object_(NULL),
58  handle_(handle(receiver_map->prototype(), receiver_map->GetIsolate())),
59  isolate_(receiver_map->GetIsolate()) {}
Handle< T > handle(T *t, Isolate *isolate)
Definition: handles.h:146

◆ ~PrototypeIterator()

v8::internal::PrototypeIterator::~PrototypeIterator ( )
inline

Definition at line 60 of file prototype.h.

60 {}

Member Function Documentation

◆ Advance()

void v8::internal::PrototypeIterator::Advance ( )
inline

Definition at line 70 of file prototype.h.

70  {
71  if (handle_.is_null() && object_->IsJSProxy()) {
73  object_ = isolate_->heap()->null_value();
74  return;
75  } else if (!handle_.is_null() && handle_->IsJSProxy()) {
77  handle_ = handle(isolate_->heap()->null_value(), isolate_);
78  return;
79  }
81  }

References AdvanceIgnoringProxies(), did_jump_to_prototype_chain_, v8::internal::handle(), handle_, v8::internal::Isolate::heap(), isolate_, and object_.

Referenced by v8::internal::ArrayPrototypeHasNoElements(), v8::internal::HGraphBuilder::BuildCheckPrototypeMaps(), v8::internal::HOptimizedGraphBuilder::BuildMonomorphicElementAccess(), v8::internal::NamedStoreHandlerCompiler::CompileStoreTransition(), v8::Object::FindInstanceInPrototypeChain(), v8::internal::GetPrototypeSkipHiddenPrototypes(), v8::internal::Isolate::IsFastArrayConstructorPrototypeChainIntact(), PrototypeIterator(), v8::internal::RUNTIME_FUNCTION(), and v8::internal::JSObject::SetPrototype().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ AdvanceIgnoringProxies()

void v8::internal::PrototypeIterator::AdvanceIgnoringProxies ( )
inline

Definition at line 82 of file prototype.h.

82  {
85  if (handle_.is_null()) {
86  object_ = object_->GetRootMap(isolate_)->prototype();
87  } else {
88  handle_ = handle(handle_->GetRootMap(isolate_)->prototype(), isolate_);
89  }
90  } else {
91  if (handle_.is_null()) {
92  object_ = HeapObject::cast(object_)->map()->prototype();
93  } else {
94  handle_ =
95  handle(HeapObject::cast(*handle_)->map()->prototype(), isolate_);
96  }
97  }
98  }
Map * GetRootMap(Isolate *isolate)
Definition: objects.cc:803

References did_jump_to_prototype_chain_, v8::internal::Object::GetRootMap(), v8::internal::handle(), handle_, isolate_, and object_.

Referenced by Advance(), and v8::internal::RUNTIME_FUNCTION().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ DISALLOW_COPY_AND_ASSIGN()

v8::internal::PrototypeIterator::DISALLOW_COPY_AND_ASSIGN ( PrototypeIterator  )
private

◆ GetCurrent() [1/2]

Object* v8::internal::PrototypeIterator::GetCurrent ( ) const
inline

Definition at line 62 of file prototype.h.

62  {
63  DCHECK(handle_.is_null());
64  return object_;
65  }
#define DCHECK(condition)
Definition: logging.h:205

References DCHECK, handle_, and object_.

Referenced by v8::internal::ArrayPrototypeHasNoElements(), v8::internal::HGraphBuilder::BuildCheckPrototypeMaps(), v8::internal::HOptimizedGraphBuilder::BuildMonomorphicElementAccess(), v8::internal::BUILTIN(), v8::internal::CollectElementIndices(), v8::internal::NamedStoreHandlerCompiler::CompileStoreTransition(), v8::internal::DebugEvaluate(), v8::internal::JSObject::DefineAccessor(), v8::internal::JSObject::DeleteElement(), v8::internal::JSObject::DeleteHiddenProperty(), v8::internal::Deoptimizer::DeoptimizeGlobalObject(), v8::internal::V8HeapExplorer::ExtractJSObjectReferences(), v8::Object::FindInstanceInPrototypeChain(), v8::internal::JSObject::Freeze(), v8::internal::JSObject::GetAccessor(), v8::internal::JSObject::GetElementAttributeWithoutInterceptor(), v8::internal::JSObject::GetElementAttributeWithReceiver(), v8::internal::Runtime::GetElementOrCharAt(), v8::internal::JSObject::GetElementWithInterceptor(), v8::internal::Object::GetElementWithReceiver(), v8::internal::JSObject::GetHiddenProperty(), v8::internal::JSReceiver::GetKeys(), v8::internal::JSObject::GetOwnElementAccessorPair(), v8::Object::GetPrototype(), v8::internal::GetPrototypeSkipHiddenPrototypes(), v8::Object::GetRealNamedPropertyInPrototypeChain(), v8::internal::HasOwnPropertyImplementation(), v8::internal::JSObject::HasRealElementProperty(), v8::internal::JSGlobalProxy::IsDetachedFrom(), v8::internal::Isolate::IsFastArrayConstructorPrototypeChainIntact(), v8::internal::IsJSArrayFastElementMovingAllowed(), v8::internal::StoreIC::LookupForWrite(), v8::internal::JSObject::PreventExtensions(), v8::internal::RUNTIME_FUNCTION(), v8::internal::JSObject::SetAccessor(), v8::internal::JSObject::SetElement(), v8::internal::JSObject::SetElementWithCallbackSetterInPrototypes(), v8::internal::JSObject::SetHiddenProperty(), v8::internal::JSObject::SetPrototype(), and v8::internal::StoreToSuper().

+ Here is the caller graph for this function:

◆ GetCurrent() [2/2]

static Handle<Object> v8::internal::PrototypeIterator::GetCurrent ( const PrototypeIterator iterator)
inlinestatic

Definition at line 66 of file prototype.h.

66  {
67  DCHECK(!iterator.handle_.is_null());
68  return iterator.handle_;
69  }

References DCHECK, and handle_.

◆ IsAtEnd() [1/3]

bool v8::internal::PrototypeIterator::IsAtEnd ( Handle< Object final_object)
inline

Definition at line 116 of file prototype.h.

116  {
117  DCHECK(!handle_.is_null());
118  return handle_->IsNull() || *handle_ == *final_object;
119  }

References DCHECK, and handle_.

◆ IsAtEnd() [2/3]

bool v8::internal::PrototypeIterator::IsAtEnd ( Object final_object)
inline

Definition at line 112 of file prototype.h.

112  {
113  DCHECK(handle_.is_null());
114  return object_->IsNull() || object_ == final_object;
115  }

References DCHECK, handle_, and object_.

◆ IsAtEnd() [3/3]

bool v8::internal::PrototypeIterator::IsAtEnd ( WhereToEnd  where_to_end = END_AT_NULL) const
inline

Definition at line 99 of file prototype.h.

99  {
100  if (handle_.is_null()) {
101  return object_->IsNull() ||
103  where_to_end == END_AT_NON_HIDDEN &&
104  !HeapObject::cast(object_)->map()->is_hidden_prototype());
105  } else {
106  return handle_->IsNull() ||
108  where_to_end == END_AT_NON_HIDDEN &&
109  !Handle<HeapObject>::cast(handle_)->map()->is_hidden_prototype());
110  }
111  }
static Handle< T > cast(Handle< S > that)
Definition: handles.h:116

References v8::internal::Handle< T >::cast(), did_jump_to_prototype_chain_, END_AT_NON_HIDDEN, handle_, and object_.

Referenced by v8::internal::ArrayPrototypeHasNoElements(), v8::internal::HGraphBuilder::BuildCheckPrototypeMaps(), v8::internal::HOptimizedGraphBuilder::BuildMonomorphicElementAccess(), v8::internal::CollectElementIndices(), v8::internal::NamedStoreHandlerCompiler::CompileStoreTransition(), v8::internal::DebugReferencedBy(), v8::internal::JSObject::DefineAccessor(), v8::internal::JSObject::DeleteElement(), v8::internal::JSObject::DeleteHiddenProperty(), v8::internal::Map::DictionaryElementsInPrototypeChainOnly(), v8::internal::FindHidden(), v8::Object::FindInstanceInPrototypeChain(), v8::internal::FindInstanceOf(), v8::internal::JSObject::Freeze(), v8::internal::JSObject::GetAccessor(), v8::internal::JSObject::GetElementAttributeWithoutInterceptor(), v8::internal::JSObject::GetElementAttributeWithReceiver(), v8::internal::JSObject::GetElementWithInterceptor(), v8::internal::Object::GetElementWithReceiver(), v8::internal::JSObject::GetHiddenProperty(), v8::internal::JSReceiver::GetKeys(), v8::internal::JSObject::GetOwnElementAccessorPair(), v8::internal::GetPrototypeSkipHiddenPrototypes(), v8::Object::GetRealNamedPropertyInPrototypeChain(), v8::internal::HasOwnPropertyImplementation(), v8::internal::JSObject::HasRealElementProperty(), v8::internal::Isolate::IsErrorObject(), v8::internal::Isolate::IsFastArrayConstructorPrototypeChainIntact(), v8::internal::JSReceiver::IsSimpleEnum(), v8::internal::OwnPrototypeChainLength(), v8::internal::JSObject::PreventExtensions(), v8::internal::RUNTIME_FUNCTION(), v8::internal::JSObject::SetAccessor(), v8::internal::JSObject::SetElement(), v8::internal::JSObject::SetElementWithCallbackSetterInPrototypes(), v8::internal::JSObject::SetHiddenProperty(), and v8::internal::JSObject::SetPrototype().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Member Data Documentation

◆ did_jump_to_prototype_chain_

bool v8::internal::PrototypeIterator::did_jump_to_prototype_chain_
private

Definition at line 122 of file prototype.h.

Referenced by Advance(), AdvanceIgnoringProxies(), and IsAtEnd().

◆ handle_

Handle<Object> v8::internal::PrototypeIterator::handle_
private

Definition at line 124 of file prototype.h.

Referenced by Advance(), AdvanceIgnoringProxies(), GetCurrent(), IsAtEnd(), and PrototypeIterator().

◆ isolate_

Isolate* v8::internal::PrototypeIterator::isolate_
private

Definition at line 125 of file prototype.h.

Referenced by Advance(), and AdvanceIgnoringProxies().

◆ object_

Object* v8::internal::PrototypeIterator::object_
private

Definition at line 123 of file prototype.h.

Referenced by Advance(), AdvanceIgnoringProxies(), GetCurrent(), and IsAtEnd().


The documentation for this class was generated from the following file: