V8 Project
v8::internal::Variable Class Reference

#include <variables.h>

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

Public Types

enum  Kind { NORMAL , THIS , ARGUMENTS }
 
enum  Location {
  UNALLOCATED , PARAMETER , LOCAL , CONTEXT ,
  LOOKUP
}
 

Public Member Functions

 Variable (Scope *scope, const AstRawString *name, VariableMode mode, bool is_valid_ref, Kind kind, InitializationFlag initialization_flag, MaybeAssignedFlag maybe_assigned_flag=kNotAssigned, Interface *interface=Interface::NewValue())
 
bool IsValidReference ()
 
Scopescope () const
 
Handle< Stringname () const
 
const AstRawStringraw_name () const
 
VariableMode mode () const
 
bool has_forced_context_allocation () const
 
void ForceContextAllocation ()
 
bool is_used ()
 
void set_is_used ()
 
MaybeAssignedFlag maybe_assigned () const
 
void set_maybe_assigned ()
 
int initializer_position ()
 
void set_initializer_position (int pos)
 
bool IsVariable (Handle< String > n) const
 
bool IsUnallocated () const
 
bool IsParameter () const
 
bool IsStackLocal () const
 
bool IsStackAllocated () const
 
bool IsContextSlot () const
 
bool IsLookupSlot () const
 
bool IsGlobalObjectProperty () const
 
bool is_dynamic () const
 
bool is_const_mode () const
 
bool binding_needs_init () const
 
bool is_this () const
 
bool is_arguments () const
 
bool is_possibly_eval (Isolate *isolate) const
 
Variablelocal_if_not_shadowed () const
 
void set_local_if_not_shadowed (Variable *local)
 
Location location () const
 
int index () const
 
InitializationFlag initialization_flag () const
 
Interfaceinterface () const
 
void AllocateTo (Location location, int index)
 
- 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 const char * Mode2String (VariableMode mode)
 
static int CompareIndex (Variable *const *v, Variable *const *w)
 

Private Attributes

Scopescope_
 
const AstRawStringname_
 
VariableMode mode_
 
Kind kind_
 
Location location_
 
int index_
 
int initializer_position_
 
Variablelocal_if_not_shadowed_
 
bool is_valid_ref_
 
bool force_context_allocation_
 
bool is_used_
 
InitializationFlag initialization_flag_
 
MaybeAssignedFlag maybe_assigned_
 
Interfaceinterface_
 

Detailed Description

Definition at line 20 of file variables.h.

Member Enumeration Documentation

◆ Kind

Enumerator
NORMAL 
THIS 
ARGUMENTS 

Definition at line 22 of file variables.h.

◆ Location

Enumerator
UNALLOCATED 
PARAMETER 
LOCAL 
CONTEXT 
LOOKUP 

Definition at line 28 of file variables.h.

28  {
29  // Before and during variable allocation, a variable whose location is
30  // not yet determined. After allocation, a variable looked up as a
31  // property on the global object (and possibly absent). name() is the
32  // variable name, index() is invalid.
34 
35  // A slot in the parameter section on the stack. index() is the
36  // parameter index, counting left-to-right. The receiver is index -1;
37  // the first parameter is index 0.
38  PARAMETER,
39 
40  // A slot in the local section on the stack. index() is the variable
41  // index in the stack frame, starting at 0.
42  LOCAL,
43 
44  // An indexed slot in a heap context. index() is the variable index in
45  // the context object on the heap, starting at 0. scope() is the
46  // corresponding scope.
47  CONTEXT,
48 
49  // A named slot in a heap context. name() is the variable name in the
50  // context object on the heap, with lookup starting at the current
51  // context. index() is invalid.
52  LOOKUP
53  };

Constructor & Destructor Documentation

◆ Variable()

v8::internal::Variable::Variable ( Scope scope,
const AstRawString name,
VariableMode  mode,
bool  is_valid_ref,
Kind  kind,
InitializationFlag  initialization_flag,
MaybeAssignedFlag  maybe_assigned_flag = kNotAssigned,
Interface interface = Interface::NewValue() 
)

Definition at line 35 of file variables.cc.

39  : scope_(scope),
40  name_(name),
41  mode_(mode),
42  kind_(kind),
44  index_(-1),
47  is_valid_ref_(is_valid_ref),
49  is_used_(false),
51  maybe_assigned_(maybe_assigned_flag),
53  // Var declared variables never need initialization.
55 }
static const int kNoPosition
Definition: assembler.h:317
Handle< String > name() const
Definition: variables.h:71
MaybeAssignedFlag maybe_assigned_
Definition: variables.h:160
VariableMode mode() const
Definition: variables.h:73
const AstRawString * name_
Definition: variables.h:140
Interface * interface() const
Definition: variables.h:129
Interface * interface_
Definition: variables.h:163
Scope * scope() const
Definition: variables.h:69
Variable * local_if_not_shadowed_
Definition: variables.h:151
InitializationFlag initialization_flag() const
Definition: variables.h:126
InitializationFlag initialization_flag_
Definition: variables.h:159
VariableMode mode_
Definition: variables.h:141
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 DCHECK(condition)
Definition: logging.h:205
@ kNeedsInitialization
Definition: globals.h:752

References DCHECK, initialization_flag(), v8::internal::kNeedsInitialization, mode(), and v8::internal::VAR.

+ Here is the call graph for this function:

Member Function Documentation

◆ AllocateTo()

void v8::internal::Variable::AllocateTo ( Location  location,
int  index 
)
inline

Definition at line 131 of file variables.h.

131  {
133  index_ = index;
134  }
Location location() const
Definition: variables.h:124

References index(), index_, location(), and location_.

Referenced by v8::internal::Scope::AllocateHeapSlot(), v8::internal::Scope::AllocateParameterLocals(), v8::internal::Scope::AllocateStackSlot(), v8::internal::Parser::Declare(), v8::internal::Scope::Initialize(), v8::internal::Scope::LookupFunctionVar(), v8::internal::Scope::LookupLocal(), and v8::internal::Scope::NonLocal().

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

◆ binding_needs_init()

bool v8::internal::Variable::binding_needs_init ( ) const
inline

Definition at line 103 of file variables.h.

103  {
105  }

References initialization_flag_, and v8::internal::kNeedsInitialization.

◆ CompareIndex()

int v8::internal::Variable::CompareIndex ( Variable *const *  v,
Variable *const *  w 
)
static

Definition at line 67 of file variables.cc.

67  {
68  int x = (*v)->index();
69  int y = (*w)->index();
70  // Consider sorting them according to type as well?
71  return x - y;
72 }

References v8::base::internal::y.

Referenced by v8::internal::ScopeInfo::Create(), and v8::internal::FunctionInfoListener::SerializeFunctionScope().

+ Here is the caller graph for this function:

◆ ForceContextAllocation()

void v8::internal::Variable::ForceContextAllocation ( )
inline

Definition at line 77 of file variables.h.

77  {
80  }

References DCHECK, force_context_allocation_, mode_, and v8::internal::TEMPORARY.

Referenced by v8::internal::Scope::AllocateParameterLocals(), and v8::internal::Scope::LookupRecursive().

+ Here is the caller graph for this function:

◆ has_forced_context_allocation()

bool v8::internal::Variable::has_forced_context_allocation ( ) const
inline

Definition at line 74 of file variables.h.

74  {
76  }

References force_context_allocation_.

Referenced by v8::internal::Scope::MustAllocate(), and v8::internal::Scope::MustAllocateInContext().

+ Here is the caller graph for this function:

◆ index()

◆ initialization_flag()

InitializationFlag v8::internal::Variable::initialization_flag ( ) const
inline

Definition at line 126 of file variables.h.

126  {
127  return initialization_flag_;
128  }

References initialization_flag_.

Referenced by v8::internal::ScopeInfo::Create(), and Variable().

+ Here is the caller graph for this function:

◆ initializer_position()

int v8::internal::Variable::initializer_position ( )
inline

Definition at line 86 of file variables.h.

86 { return initializer_position_; }

References initializer_position_.

◆ interface()

Interface* v8::internal::Variable::interface ( ) const
inline

Definition at line 129 of file variables.h.

129 { return interface_; }

References interface_.

Referenced by v8::internal::Parser::Declare(), v8::internal::Scope::ResolveVariable(), and v8::internal::Rewriter::Rewrite().

+ Here is the caller graph for this function:

◆ is_arguments()

bool v8::internal::Variable::is_arguments ( ) const
inline

Definition at line 108 of file variables.h.

108 { return kind_ == ARGUMENTS; }

References ARGUMENTS, and kind_.

Referenced by v8::internal::HOptimizedGraphBuilder::IsEligibleForEnvironmentLivenessAnalysis().

+ Here is the caller graph for this function:

◆ is_const_mode()

bool v8::internal::Variable::is_const_mode ( ) const
inline

Definition at line 102 of file variables.h.

102 { return IsImmutableVariableMode(mode_); }
bool IsImmutableVariableMode(VariableMode mode)
Definition: globals.h:715

References v8::internal::IsImmutableVariableMode(), and mode_.

Referenced by v8::internal::Scope::ResolveVariable().

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

◆ is_dynamic()

bool v8::internal::Variable::is_dynamic ( ) const
inline

Definition at line 101 of file variables.h.

101 { return IsDynamicVariableMode(mode_); }
bool IsDynamicVariableMode(VariableMode mode)
Definition: globals.h:700

References v8::internal::IsDynamicVariableMode(), and mode_.

Referenced by v8::internal::Scope::ResolveVariable().

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

◆ is_possibly_eval()

bool v8::internal::Variable::is_possibly_eval ( Isolate isolate) const
inline

Definition at line 111 of file variables.h.

111  {
112  return IsVariable(isolate->factory()->eval_string());
113  }
bool IsVariable(Handle< String > n) const
Definition: variables.h:89

References v8::internal::Isolate::factory(), and IsVariable().

+ Here is the call graph for this function:

◆ is_this()

bool v8::internal::Variable::is_this ( ) const
inline

◆ is_used()

bool v8::internal::Variable::is_used ( )
inline

Definition at line 81 of file variables.h.

81 { return is_used_; }

References is_used_.

Referenced by v8::internal::Scope::CollectStackAndContextLocals(), v8::internal::ScopeInfo::Create(), and v8::internal::Scope::MustAllocate().

+ Here is the caller graph for this function:

◆ IsContextSlot()

◆ IsGlobalObjectProperty()

bool v8::internal::Variable::IsGlobalObjectProperty ( ) const

Definition at line 58 of file variables.cc.

58  {
59  // Temporaries are never global, they must always be allocated in the
60  // activation frame.
61  return (IsDynamicVariableMode(mode_) ||
63  && scope_ != NULL && scope_->is_global_scope();
64 }
bool is_global_scope() const
Definition: scopes.h:267
bool IsLexicalVariableMode(VariableMode mode)
Definition: globals.h:710
bool IsDeclaredVariableMode(VariableMode mode)
Definition: globals.h:705

References v8::internal::Scope::is_global_scope(), v8::internal::IsDeclaredVariableMode(), v8::internal::IsDynamicVariableMode(), v8::internal::IsLexicalVariableMode(), mode_, NULL, and scope_.

Referenced by v8::internal::Scope::MustAllocate(), and v8::internal::Scope::ResolveVariable().

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

◆ IsLookupSlot()

bool v8::internal::Variable::IsLookupSlot ( ) const
inline

Definition at line 98 of file variables.h.

98 { return location_ == LOOKUP; }

References location_, and LOOKUP.

◆ IsParameter()

bool v8::internal::Variable::IsParameter ( ) const
inline

Definition at line 94 of file variables.h.

94 { return location_ == PARAMETER; }

References location_, and PARAMETER.

Referenced by v8::internal::Scope::AllocateParameterLocals(), v8::internal::compiler::AstGraphBuilder::Environment::Bind(), v8::internal::FINAL< kOperandKind, kNumCachedOperands >::IndexFor(), IsStackAllocated(), v8::internal::compiler::AstGraphBuilder::Environment::Lookup(), and v8::internal::AstTyper::variable_index().

+ Here is the caller graph for this function:

◆ IsStackAllocated()

bool v8::internal::Variable::IsStackAllocated ( ) const
inline

Definition at line 96 of file variables.h.

96 { return IsParameter() || IsStackLocal(); }
bool IsParameter() const
Definition: variables.h:94
bool IsStackLocal() const
Definition: variables.h:95

References IsParameter(), and IsStackLocal().

Referenced by v8::internal::compiler::AstGraphBuilder::Environment::Bind(), v8::internal::compiler::AstGraphBuilder::BuildArgumentsObject(), v8::internal::FINAL< kOperandKind, kNumCachedOperands >::IndexFor(), v8::internal::compiler::AstGraphBuilder::Environment::Lookup(), v8::internal::HOptimizedGraphBuilder::SetUpScope(), and v8::internal::HOptimizedGraphBuilder::VisitDelete().

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

◆ IsStackLocal()

bool v8::internal::Variable::IsStackLocal ( ) const
inline

Definition at line 95 of file variables.h.

95 { return location_ == LOCAL; }

References LOCAL, and location_.

Referenced by v8::internal::Scope::AllocateNonParameterLocal(), v8::internal::compiler::AstGraphBuilder::Environment::Bind(), v8::internal::Scope::CollectStackAndContextLocals(), v8::internal::ScopeInfo::Create(), IsStackAllocated(), v8::internal::compiler::AstGraphBuilder::Environment::Lookup(), and v8::internal::AstTyper::variable_index().

+ Here is the caller graph for this function:

◆ IsUnallocated()

bool v8::internal::Variable::IsUnallocated ( ) const
inline

Definition at line 93 of file variables.h.

93 { return location_ == UNALLOCATED; }

References location_, and UNALLOCATED.

Referenced by v8::internal::Scope::AllocateNonParameterLocal(), v8::internal::Scope::AllocateParameterLocals(), and v8::internal::HOptimizedGraphBuilder::VisitDelete().

+ Here is the caller graph for this function:

◆ IsValidReference()

bool v8::internal::Variable::IsValidReference ( )
inline

Definition at line 63 of file variables.h.

63 { return is_valid_ref_; }

References is_valid_ref_.

◆ IsVariable()

bool v8::internal::Variable::IsVariable ( Handle< String n) const
inline

Definition at line 89 of file variables.h.

89  {
90  return !is_this() && name().is_identical_to(n);
91  }
bool is_this() const
Definition: variables.h:107

References is_this(), and name().

Referenced by v8::internal::Scope::AllocateNonParameterLocal(), and is_possibly_eval().

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

◆ local_if_not_shadowed()

Variable* v8::internal::Variable::local_if_not_shadowed ( ) const
inline

Definition at line 115 of file variables.h.

115  {
117  return local_if_not_shadowed_;
118  }
@ DYNAMIC_LOCAL
Definition: globals.h:693

References DCHECK, v8::internal::DYNAMIC_LOCAL, local_if_not_shadowed_, mode_, and NULL.

◆ location()

Location v8::internal::Variable::location ( ) const
inline

Definition at line 124 of file variables.h.

124 { return location_; }

References location_.

Referenced by AllocateTo(), v8::internal::compiler::AstGraphBuilder::BuildVariableAssignment(), v8::internal::compiler::AstGraphBuilder::BuildVariableDelete(), v8::internal::compiler::AstGraphBuilder::BuildVariableLoad(), v8::internal::HOptimizedGraphBuilder::HandleCompoundAssignment(), and v8::internal::Expression::IsUndefinedLiteral().

+ Here is the caller graph for this function:

◆ maybe_assigned()

MaybeAssignedFlag v8::internal::Variable::maybe_assigned ( ) const
inline

Definition at line 83 of file variables.h.

83 { return maybe_assigned_; }

References maybe_assigned_.

Referenced by v8::internal::compiler::AstGraphBuilder::BuildVariableLoad(), and v8::internal::ScopeInfo::Create().

+ Here is the caller graph for this function:

◆ mode()

◆ Mode2String()

const char * v8::internal::Variable::Mode2String ( VariableMode  mode)
static

Definition at line 17 of file variables.cc.

17  {
18  switch (mode) {
19  case VAR: return "VAR";
20  case CONST_LEGACY: return "CONST_LEGACY";
21  case LET: return "LET";
22  case CONST: return "CONST";
23  case MODULE: return "MODULE";
24  case DYNAMIC: return "DYNAMIC";
25  case DYNAMIC_GLOBAL: return "DYNAMIC_GLOBAL";
26  case DYNAMIC_LOCAL: return "DYNAMIC_LOCAL";
27  case INTERNAL: return "INTERNAL";
28  case TEMPORARY: return "TEMPORARY";
29  }
30  UNREACHABLE();
31  return NULL;
32 }
#define UNREACHABLE()
Definition: logging.h:30
@ DYNAMIC_GLOBAL
Definition: globals.h:689
@ CONST_LEGACY
Definition: globals.h:671

References v8::internal::CONST, v8::internal::CONST_LEGACY, v8::internal::DYNAMIC, v8::internal::DYNAMIC_GLOBAL, v8::internal::DYNAMIC_LOCAL, v8::internal::INTERNAL, v8::internal::LET, mode(), v8::internal::MODULE, NULL, v8::internal::TEMPORARY, UNREACHABLE, and v8::internal::VAR.

+ Here is the call graph for this function:

◆ name()

Handle<String> v8::internal::Variable::name ( ) const
inline

Definition at line 71 of file variables.h.

71 { return name_->string(); }
Handle< String > string() const

References name_, and v8::internal::AstString::string().

Referenced by v8::internal::compiler::AstGraphBuilder::BuildThrowReferenceError(), v8::internal::compiler::AstGraphBuilder::BuildVariableAssignment(), v8::internal::compiler::AstGraphBuilder::BuildVariableDelete(), v8::internal::compiler::AstGraphBuilder::BuildVariableLoad(), v8::internal::ScopeInfo::Create(), v8::internal::HOptimizedGraphBuilder::HandleGlobalVariableAssignment(), IsVariable(), v8::internal::Scope::ResolveVariable(), and v8::internal::Rewriter::Rewrite().

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

◆ raw_name()

const AstRawString* v8::internal::Variable::raw_name ( ) const
inline

Definition at line 72 of file variables.h.

72 { return name_; }

References name_.

Referenced by v8::internal::Parser::Declare(), v8::internal::Scope::MustAllocate(), v8::internal::Scope::ResolveVariable(), and v8::internal::Rewriter::Rewrite().

+ Here is the caller graph for this function:

◆ scope()

Scope* v8::internal::Variable::scope ( ) const
inline

◆ set_initializer_position()

void v8::internal::Variable::set_initializer_position ( int  pos)
inline

Definition at line 87 of file variables.h.

87 { initializer_position_ = pos; }

References initializer_position_.

◆ set_is_used()

void v8::internal::Variable::set_is_used ( )
inline

Definition at line 82 of file variables.h.

82 { is_used_ = true; }

References is_used_.

Referenced by v8::internal::Scope::MustAllocate().

+ Here is the caller graph for this function:

◆ set_local_if_not_shadowed()

void v8::internal::Variable::set_local_if_not_shadowed ( Variable local)
inline

Definition at line 120 of file variables.h.

120  {
121  local_if_not_shadowed_ = local;
122  }

References local_if_not_shadowed_.

Referenced by v8::internal::Scope::ResolveVariable().

+ Here is the caller graph for this function:

◆ set_maybe_assigned()

void v8::internal::Variable::set_maybe_assigned ( )
inline

Definition at line 84 of file variables.h.

References v8::internal::kMaybeAssigned, and maybe_assigned_.

Referenced by v8::internal::Parser::Declare(), v8::internal::Scope::LookupRecursive(), v8::internal::Scope::MustAllocate(), v8::internal::Parser::ParseExportDeclaration(), v8::internal::Parser::ParseFunctionLiteral(), and v8::internal::Scope::ResolveVariable().

+ Here is the caller graph for this function:

Member Data Documentation

◆ force_context_allocation_

bool v8::internal::Variable::force_context_allocation_
private

Definition at line 157 of file variables.h.

Referenced by ForceContextAllocation(), and has_forced_context_allocation().

◆ index_

int v8::internal::Variable::index_
private

Definition at line 144 of file variables.h.

Referenced by AllocateTo(), and index().

◆ initialization_flag_

InitializationFlag v8::internal::Variable::initialization_flag_
private

Definition at line 159 of file variables.h.

Referenced by binding_needs_init(), and initialization_flag().

◆ initializer_position_

int v8::internal::Variable::initializer_position_
private

Definition at line 145 of file variables.h.

Referenced by initializer_position(), and set_initializer_position().

◆ interface_

Interface* v8::internal::Variable::interface_
private

Definition at line 163 of file variables.h.

Referenced by interface().

◆ is_used_

bool v8::internal::Variable::is_used_
private

Definition at line 158 of file variables.h.

Referenced by is_used(), and set_is_used().

◆ is_valid_ref_

bool v8::internal::Variable::is_valid_ref_
private

Definition at line 154 of file variables.h.

Referenced by IsValidReference().

◆ kind_

Kind v8::internal::Variable::kind_
private

Definition at line 142 of file variables.h.

Referenced by is_arguments(), and is_this().

◆ local_if_not_shadowed_

Variable* v8::internal::Variable::local_if_not_shadowed_
private

Definition at line 151 of file variables.h.

Referenced by local_if_not_shadowed(), and set_local_if_not_shadowed().

◆ location_

Location v8::internal::Variable::location_
private

◆ maybe_assigned_

MaybeAssignedFlag v8::internal::Variable::maybe_assigned_
private

Definition at line 160 of file variables.h.

Referenced by maybe_assigned(), and set_maybe_assigned().

◆ mode_

VariableMode v8::internal::Variable::mode_
private

◆ name_

const AstRawString* v8::internal::Variable::name_
private

Definition at line 140 of file variables.h.

Referenced by name(), and raw_name().

◆ scope_

Scope* v8::internal::Variable::scope_
private

Definition at line 139 of file variables.h.

Referenced by IsGlobalObjectProperty(), and scope().


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