V8 Project
v8::internal::Interface Class Reference

#include <interface.h>

+ Inheritance diagram for v8::internal::Interface:
+ Collaboration diagram for v8::internal::Interface:

Classes

class  Iterator
 

Public Member Functions

void Add (const AstRawString *name, Interface *interface, Zone *zone, bool *ok)
 
void Unify (Interface *that, Zone *zone, bool *ok)
 
void MakeValue (bool *ok)
 
void MakeConst (bool *ok)
 
void MakeModule (bool *ok)
 
void Freeze (bool *ok)
 
void Allocate (int index)
 
bool IsUnknown ()
 
bool IsValue ()
 
bool IsConst ()
 
bool IsModule ()
 
bool IsFrozen ()
 
bool IsUnified (Interface *that)
 
int Length ()
 
int Index ()
 
InterfaceLookup (Handle< String > name, Zone *zone)
 
Iterator iterator () const
 
- Public Member Functions inherited from v8::internal::ZoneObject
 INLINE (void *operator new(size_t size, Zone *zone))
 
void operator delete (void *, size_t)
 
void operator delete (void *pointer, Zone *zone)
 

Static Public Member Functions

static InterfaceNewUnknown (Zone *zone)
 
static InterfaceNewValue ()
 
static InterfaceNewConst ()
 
static InterfaceNewModule (Zone *zone)
 

Private Types

enum  Flags {
  NONE = 0 , VALUE = 1 , CONST = 2 , MODULE = 4 ,
  FROZEN = 8
}
 

Private Member Functions

 Interface (int flags)
 
InterfaceChase ()
 
void DoAdd (const void *name, uint32_t hash, Interface *interface, Zone *zone, bool *ok)
 
void DoUnify (Interface *that, bool *ok, Zone *zone)
 

Private Attributes

int flags_
 
Interfaceforward_
 
ZoneHashMapexports_
 
int index_
 

Detailed Description

Definition at line 35 of file interface.h.

Member Enumeration Documentation

◆ Flags

Enumerator
NONE 
VALUE 
CONST 
MODULE 
FROZEN 

Definition at line 181 of file interface.h.

181  { // All flags are monotonic
182  NONE = 0,
183  VALUE = 1, // This type describes a value
184  CONST = 2, // This type describes a constant
185  MODULE = 4, // This type describes a module
186  FROZEN = 8 // This type is fully determined
187  };

Constructor & Destructor Documentation

◆ Interface()

v8::internal::Interface::Interface ( int  flags)
inlineexplicitprivate

Definition at line 194 of file interface.h.

195  : flags_(flags),
196  forward_(NULL),
197  exports_(NULL),
198  index_(-1) {
199 #ifdef DEBUG
200  if (FLAG_print_interface_details)
201  PrintF("# Creating %p\n", static_cast<void*>(this));
202 #endif
203  }
ZoneHashMap * exports_
Definition: interface.h:191
Interface * forward_
Definition: interface.h:190
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
void PrintF(const char *format,...)
Definition: utils.cc:80

References v8::internal::PrintF().

Referenced by NewModule(), and NewUnknown().

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

Member Function Documentation

◆ Add()

void v8::internal::Interface::Add ( const AstRawString name,
Interface interface,
Zone zone,
bool ok 
)
inline

Definition at line 63 of file interface.h.

64  {
65  DoAdd(name, name->hash(), interface, zone, ok);
66  }
void DoAdd(const void *name, uint32_t hash, Interface *interface, Zone *zone, bool *ok)
Definition: interface.cc: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 expose gc extension under the specified name show built in functions in stack traces use random jit cookie to mask large constants minimum length for automatic enable preparsing CPU profiler sampling interval in microseconds trace out of bounds accesses to external arrays default size of stack region v8 is allowed to maximum length of function source code printed in a stack trace min size of a semi the new space consists of two semi spaces print one trace line following each garbage collection do not print trace line after scavenger collection print cumulative GC statistics in name

References DoAdd(), and name.

Referenced by v8::internal::Parser::ParseImportDeclaration(), and v8::internal::Parser::ParseModulePath().

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

◆ Allocate()

void v8::internal::Interface::Allocate ( int  index)
inline

Definition at line 97 of file interface.h.

97  {
98  DCHECK(IsModule() && IsFrozen() && Chase()->index_ == -1);
99  Chase()->index_ = index;
100  }
Interface * Chase()
Definition: interface.h:205
#define DCHECK(condition)
Definition: logging.h:205

References Chase(), DCHECK, index_, IsFrozen(), and IsModule().

+ Here is the call graph for this function:

◆ Chase()

Interface* v8::internal::Interface::Chase ( )
inlineprivate

Definition at line 205 of file interface.h.

205  {
206  Interface* result = this;
207  while (result->forward_ != NULL) result = result->forward_;
208  if (result != this) forward_ = result; // On-the-fly path compression.
209  return result;
210  }

References forward_, and NULL.

Referenced by Allocate(), DoAdd(), Freeze(), Index(), IsConst(), IsFrozen(), IsModule(), IsUnified(), IsUnknown(), IsValue(), Length(), Lookup(), MakeConst(), MakeModule(), MakeValue(), and Unify().

+ Here is the caller graph for this function:

◆ DoAdd()

void v8::internal::Interface::DoAdd ( const void *  name,
uint32_t  hash,
Interface interface,
Zone zone,
bool ok 
)
private

Definition at line 41 of file interface.cc.

42  {
43  MakeModule(ok);
44  if (!*ok) return;
45 
46 #ifdef DEBUG
47  if (FLAG_print_interface_details) {
48  PrintF("%*s# Adding...\n", Nesting::current(), "");
49  PrintF("%*sthis = ", Nesting::current(), "");
50  this->Print(Nesting::current());
51  const AstRawString* symbol = static_cast<const AstRawString*>(name);
52  PrintF("%*s%.*s : ", Nesting::current(), "", symbol->length(),
53  symbol->raw_data());
54  interface->Print(Nesting::current());
55  }
56 #endif
57 
58  ZoneHashMap** map = &Chase()->exports_;
59  ZoneAllocationPolicy allocator(zone);
60 
61  if (*map == NULL) {
62  *map = new(zone->New(sizeof(ZoneHashMap)))
65  }
66 
67  ZoneHashMap::Entry* p =
68  (*map)->Lookup(const_cast<void*>(name), hash, !IsFrozen(), allocator);
69  if (p == NULL) {
70  // This didn't have name but was frozen already, that's an error.
71  *ok = false;
72  } else if (p->value == NULL) {
73  p->value = interface;
74  } else {
75 #ifdef DEBUG
76  Nesting nested;
77 #endif
78  static_cast<Interface*>(p->value)->Unify(interface, zone, ok);
79  }
80 
81 #ifdef DEBUG
82  if (FLAG_print_interface_details) {
83  PrintF("%*sthis' = ", Nesting::current(), "");
84  this->Print(Nesting::current());
85  PrintF("%*s# Added.\n", Nesting::current(), "");
86  }
87 #endif
88 }
void Unify(Interface *that, Zone *zone, bool *ok)
Definition: interface.cc:91
void MakeModule(bool *ok)
Definition: interface.h:85
Entry * Lookup(void *key, uint32_t hash, bool insert, AllocationPolicy allocator=AllocationPolicy())
Definition: hashmap.h:114
static bool PointersMatch(void *key1, void *key2)
Definition: hashmap.h:80
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
TemplateHashMapImpl< ZoneAllocationPolicy > ZoneHashMap
Definition: zone.h:245

References Chase(), exports_, IsFrozen(), v8::internal::TemplateHashMapImpl< ZoneAllocationPolicy >::kDefaultHashMapCapacity, v8::internal::AstRawString::length(), v8::internal::TemplateHashMapImpl< AllocationPolicy >::Lookup(), MakeModule(), map, name, v8::internal::Zone::New(), NULL, v8::internal::TemplateHashMapImpl< ZoneAllocationPolicy >::PointersMatch(), v8::internal::PrintF(), v8::internal::AstRawString::raw_data(), and Unify().

Referenced by Add(), and DoUnify().

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

◆ DoUnify()

void v8::internal::Interface::DoUnify ( Interface that,
bool ok,
Zone zone 
)
private

Definition at line 140 of file interface.cc.

140  {
141  DCHECK(this->forward_ == NULL);
142  DCHECK(that->forward_ == NULL);
143  DCHECK(!this->IsValue());
144  DCHECK(!that->IsValue());
145  DCHECK(this->index_ == -1);
146  DCHECK(that->index_ == -1);
147  DCHECK(*ok);
148 
149 #ifdef DEBUG
150  Nesting nested;
151 #endif
152 
153  // Try to merge all members from that into this.
154  ZoneHashMap* map = that->exports_;
155  if (map != NULL) {
156  for (ZoneHashMap::Entry* p = map->Start(); p != NULL; p = map->Next(p)) {
157  this->DoAdd(p->key, p->hash, static_cast<Interface*>(p->value), zone, ok);
158  if (!*ok) return;
159  }
160  }
161 
162  // If the new interface is larger than that's, then there were members in
163  // 'this' which 'that' didn't have. If 'that' was frozen that is an error.
164  int this_size = this->exports_ == NULL ? 0 : this->exports_->occupancy();
165  int that_size = map == NULL ? 0 : map->occupancy();
166  if (that->IsFrozen() && this_size > that_size) {
167  *ok = false;
168  return;
169  }
170 
171  // Merge interfaces.
172  this->flags_ |= that->flags_;
173  that->forward_ = this;
174 }
uint32_t occupancy() const
Definition: hashmap.h:61

References DCHECK, DoAdd(), exports_, flags_, forward_, index_, IsFrozen(), IsValue(), map, NULL, and v8::internal::TemplateHashMapImpl< AllocationPolicy >::occupancy().

Referenced by Unify().

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

◆ Freeze()

void v8::internal::Interface::Freeze ( bool ok)
inline

Definition at line 91 of file interface.h.

91  {
92  *ok = IsValue() || IsModule();
93  if (*ok) Chase()->flags_ |= FROZEN;
94  }

References Chase(), flags_, FROZEN, IsModule(), and IsValue().

+ Here is the call graph for this function:

◆ Index()

int v8::internal::Interface::Index ( )
inline

Definition at line 133 of file interface.h.

133  {
134  DCHECK(IsModule() && IsFrozen());
135  return Chase()->index_;
136  }

References Chase(), DCHECK, index_, IsFrozen(), and IsModule().

Referenced by v8::internal::FullCodeGenerator::AllocateModules(), and v8::internal::ModuleInfo::Create().

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

◆ IsConst()

bool v8::internal::Interface::IsConst ( )
inline

Definition at line 112 of file interface.h.

112 { return Chase()->flags_ & CONST; }

References Chase(), CONST, and flags_.

Referenced by IsUnified(), MakeConst(), and Unify().

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

◆ IsFrozen()

bool v8::internal::Interface::IsFrozen ( )
inline

Definition at line 118 of file interface.h.

118 { return Chase()->flags_ & FROZEN; }

References Chase(), flags_, and FROZEN.

Referenced by Allocate(), v8::internal::Scope::AllocateModulesRecursively(), DoAdd(), DoUnify(), Index(), Length(), and MakeConst().

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

◆ IsModule()

bool v8::internal::Interface::IsModule ( )
inline

Definition at line 115 of file interface.h.

115 { return Chase()->flags_ & MODULE; }

References Chase(), flags_, and MODULE.

Referenced by Allocate(), Freeze(), Index(), Length(), Lookup(), MakeConst(), and MakeValue().

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

◆ IsUnified()

bool v8::internal::Interface::IsUnified ( Interface that)
inline

Definition at line 120 of file interface.h.

120  {
121  return Chase() == that->Chase()
122  || (this->IsValue() == that->IsValue() &&
123  this->IsConst() == that->IsConst());
124  }

References Chase(), IsConst(), and IsValue().

+ Here is the call graph for this function:

◆ IsUnknown()

bool v8::internal::Interface::IsUnknown ( )
inline

Definition at line 106 of file interface.h.

106 { return Chase()->flags_ == NONE; }

References Chase(), flags_, and NONE.

+ Here is the call graph for this function:

◆ IsValue()

bool v8::internal::Interface::IsValue ( )
inline

Definition at line 109 of file interface.h.

109 { return Chase()->flags_ & VALUE; }

References Chase(), flags_, and VALUE.

Referenced by DoUnify(), Freeze(), IsUnified(), MakeModule(), and Unify().

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

◆ iterator()

Iterator v8::internal::Interface::iterator ( ) const
inline

Definition at line 170 of file interface.h.

170 { return Iterator(this->exports_); }

References exports_.

Referenced by v8::internal::ModuleInfo::Create().

+ Here is the caller graph for this function:

◆ Length()

int v8::internal::Interface::Length ( )
inline

Definition at line 126 of file interface.h.

126  {
127  DCHECK(IsModule() && IsFrozen());
128  ZoneHashMap* exports = Chase()->exports_;
129  return exports ? exports->occupancy() : 0;
130  }

References Chase(), DCHECK, exports_, IsFrozen(), IsModule(), and v8::internal::TemplateHashMapImpl< AllocationPolicy >::occupancy().

Referenced by v8::internal::ModuleInfo::Create().

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

◆ Lookup()

Interface * v8::internal::Interface::Lookup ( Handle< String name,
Zone zone 
)

Definition at line 12 of file interface.cc.

12  {
13  DCHECK(IsModule());
15  if (map == NULL) return NULL;
16  ZoneAllocationPolicy allocator(zone);
17  ZoneHashMap::Entry* p = map->Lookup(name.location(), name->Hash(), false,
18  allocator);
19  if (p == NULL) return NULL;
20  DCHECK(*static_cast<String**>(p->key) == *name);
21  DCHECK(p->value != NULL);
22  return static_cast<Interface*>(p->value);
23 }

References Chase(), DCHECK, exports_, IsModule(), map, name, and NULL.

+ Here is the call graph for this function:

◆ MakeConst()

void v8::internal::Interface::MakeConst ( bool ok)
inline

Definition at line 79 of file interface.h.

79  {
80  *ok = !IsModule() && (IsConst() || !IsFrozen());
81  if (*ok) Chase()->flags_ |= VALUE + CONST;
82  }

References Chase(), CONST, flags_, IsConst(), IsFrozen(), IsModule(), and VALUE.

Referenced by Unify().

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

◆ MakeModule()

void v8::internal::Interface::MakeModule ( bool ok)
inline

Definition at line 85 of file interface.h.

85  {
86  *ok = !IsValue();
87  if (*ok) Chase()->flags_ |= MODULE;
88  }

References Chase(), flags_, IsValue(), and MODULE.

Referenced by DoAdd().

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

◆ MakeValue()

void v8::internal::Interface::MakeValue ( bool ok)
inline

Definition at line 73 of file interface.h.

73  {
74  *ok = !IsModule();
75  if (*ok) Chase()->flags_ |= VALUE;
76  }

References Chase(), flags_, IsModule(), and VALUE.

Referenced by Unify().

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

◆ NewConst()

static Interface* v8::internal::Interface::NewConst ( )
inlinestatic

Definition at line 49 of file interface.h.

49  {
50  static Interface value_interface(VALUE + CONST + FROZEN); // Cached.
51  return &value_interface;
52  }

References CONST, FROZEN, and VALUE.

Referenced by v8::internal::Parser::ParseEagerFunctionBody(), and v8::internal::Parser::ParseFunctionLiteral().

+ Here is the caller graph for this function:

◆ NewModule()

static Interface* v8::internal::Interface::NewModule ( Zone zone)
inlinestatic

Definition at line 54 of file interface.h.

54  {
55  return new(zone) Interface(MODULE);
56  }

References Interface(), and MODULE.

Referenced by v8::internal::Parser::ParseModuleVariable().

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

◆ NewUnknown()

static Interface* v8::internal::Interface::NewUnknown ( Zone zone)
inlinestatic

Definition at line 40 of file interface.h.

40  {
41  return new(zone) Interface(NONE);
42  }

References Interface(), and NONE.

Referenced by v8::internal::ParserTraits::ExpressionFromIdentifier(), v8::internal::Parser::ParseExportDeclaration(), and v8::internal::Parser::ParseImportDeclaration().

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

◆ NewValue()

static Interface* v8::internal::Interface::NewValue ( )
inlinestatic

Definition at line 44 of file interface.h.

44  {
45  static Interface value_interface(VALUE + FROZEN); // Cached.
46  return &value_interface;
47  }

References FROZEN, and VALUE.

Referenced by v8::internal::Parser::DesugarLetBindingsInForStatement(), v8::internal::Parser::ParseClassDeclaration(), v8::internal::Parser::ParseForStatement(), v8::internal::Parser::ParseFunctionDeclaration(), v8::internal::Parser::ParseNativeDeclaration(), and v8::internal::Parser::ParseVariableDeclarations().

+ Here is the caller graph for this function:

◆ Unify()

void v8::internal::Interface::Unify ( Interface that,
Zone zone,
bool ok 
)

Definition at line 91 of file interface.cc.

91  {
92  if (this->forward_) return this->Chase()->Unify(that, zone, ok);
93  if (that->forward_) return this->Unify(that->Chase(), zone, ok);
94  DCHECK(this->forward_ == NULL);
95  DCHECK(that->forward_ == NULL);
96 
97  *ok = true;
98  if (this == that) return;
99  if (this->IsValue()) {
100  that->MakeValue(ok);
101  if (*ok && this->IsConst()) that->MakeConst(ok);
102  return;
103  }
104  if (that->IsValue()) {
105  this->MakeValue(ok);
106  if (*ok && that->IsConst()) this->MakeConst(ok);
107  return;
108  }
109 
110 #ifdef DEBUG
111  if (FLAG_print_interface_details) {
112  PrintF("%*s# Unifying...\n", Nesting::current(), "");
113  PrintF("%*sthis = ", Nesting::current(), "");
114  this->Print(Nesting::current());
115  PrintF("%*sthat = ", Nesting::current(), "");
116  that->Print(Nesting::current());
117  }
118 #endif
119 
120  // Merge the smaller interface into the larger, for performance.
121  if (this->exports_ != NULL && (that->exports_ == NULL ||
122  this->exports_->occupancy() >= that->exports_->occupancy())) {
123  this->DoUnify(that, ok, zone);
124  } else {
125  that->DoUnify(this, ok, zone);
126  }
127 
128 #ifdef DEBUG
129  if (FLAG_print_interface_details) {
130  PrintF("%*sthis' = ", Nesting::current(), "");
131  this->Print(Nesting::current());
132  PrintF("%*sthat' = ", Nesting::current(), "");
133  that->Print(Nesting::current());
134  PrintF("%*s# Unified.\n", Nesting::current(), "");
135  }
136 #endif
137 }
void MakeValue(bool *ok)
Definition: interface.h:73
void MakeConst(bool *ok)
Definition: interface.h:79
void DoUnify(Interface *that, bool *ok, Zone *zone)
Definition: interface.cc:140

References Chase(), DCHECK, DoUnify(), exports_, forward_, IsConst(), IsValue(), MakeConst(), MakeValue(), NULL, v8::internal::TemplateHashMapImpl< AllocationPolicy >::occupancy(), v8::internal::PrintF(), and Unify().

Referenced by DoAdd(), and Unify().

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

Member Data Documentation

◆ exports_

ZoneHashMap* v8::internal::Interface::exports_
private

Definition at line 191 of file interface.h.

Referenced by DoAdd(), DoUnify(), iterator(), Length(), Lookup(), and Unify().

◆ flags_

int v8::internal::Interface::flags_
private

◆ forward_

Interface* v8::internal::Interface::forward_
private

Definition at line 190 of file interface.h.

Referenced by Chase(), DoUnify(), and Unify().

◆ index_

int v8::internal::Interface::index_
private

Definition at line 192 of file interface.h.

Referenced by Allocate(), DoUnify(), and Index().


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