V8 Project
variables.cc
Go to the documentation of this file.
1 // Copyright 2011 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 
5 #include "src/v8.h"
6 
7 #include "src/ast.h"
8 #include "src/scopes.h"
9 #include "src/variables.h"
10 
11 namespace v8 {
12 namespace internal {
13 
14 // ----------------------------------------------------------------------------
15 // Implementation Variable.
16 
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 }
33 
34 
36  bool is_valid_ref, Kind kind,
37  InitializationFlag initialization_flag,
38  MaybeAssignedFlag maybe_assigned_flag, Interface* interface)
39  : scope_(scope),
40  name_(name),
41  mode_(mode),
42  kind_(kind),
43  location_(UNALLOCATED),
44  index_(-1),
45  initializer_position_(RelocInfo::kNoPosition),
46  local_if_not_shadowed_(NULL),
47  is_valid_ref_(is_valid_ref),
48  force_context_allocation_(false),
49  is_used_(false),
50  initialization_flag_(initialization_flag),
51  maybe_assigned_(maybe_assigned_flag),
52  interface_(interface) {
53  // Var declared variables never need initialization.
55 }
56 
57 
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 }
65 
66 
67 int Variable::CompareIndex(Variable* const* v, Variable* const* w) {
68  int x = (*v)->index();
69  int y = (*w)->index();
70  // Consider sorting them according to type as well?
71  return x - y;
72 }
73 
74 } } // namespace v8::internal
bool is_global_scope() const
Definition: scopes.h:267
static const char * Mode2String(VariableMode mode)
Definition: variables.cc:17
VariableMode mode() const
Definition: variables.h:73
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: variables.cc:35
InitializationFlag initialization_flag() const
Definition: variables.h:126
bool IsGlobalObjectProperty() const
Definition: variables.cc:58
VariableMode mode_
Definition: variables.h:141
static int CompareIndex(Variable *const *v, Variable *const *w)
Definition: variables.cc:67
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
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 mode(MIPS only)") DEFINE_BOOL(enable_always_align_csp
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 UNREACHABLE()
Definition: logging.h:30
#define DCHECK(condition)
Definition: logging.h:205
InitializationFlag
Definition: globals.h:751
@ kNeedsInitialization
Definition: globals.h:752
bool IsLexicalVariableMode(VariableMode mode)
Definition: globals.h:710
bool IsDeclaredVariableMode(VariableMode mode)
Definition: globals.h:705
@ DYNAMIC_GLOBAL
Definition: globals.h:689
@ DYNAMIC_LOCAL
Definition: globals.h:693
@ CONST_LEGACY
Definition: globals.h:671
bool IsDynamicVariableMode(VariableMode mode)
Definition: globals.h:700
Debugger support for the V8 JavaScript engine.
Definition: accessors.cc:20