V8 Project
v8::internal::ScopeInfo Class Reference

#include <objects.h>

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

Classes

class  AsmFunctionField
 
class  AsmModuleField
 
class  CallsEvalField
 
class  ContextLocalInitFlag
 
class  ContextLocalMaybeAssignedFlag
 
class  ContextLocalMode
 
class  FunctionVariableField
 
class  FunctionVariableMode
 
class  ScopeTypeField
 
class  StrictModeField
 

Public Member Functions

ScopeType scope_type ()
 
bool CallsEval ()
 
StrictMode strict_mode ()
 
bool CallsSloppyEval ()
 
int LocalCount ()
 
int StackSlotCount ()
 
int ContextLength ()
 
bool HasFunctionName ()
 
bool HasHeapAllocatedLocals ()
 
bool HasContext ()
 
bool IsAsmModule ()
 
bool IsAsmFunction ()
 
StringFunctionName ()
 
StringParameterName (int var)
 
StringLocalName (int var)
 
StringStackLocalName (int var)
 
StringContextLocalName (int var)
 
VariableMode ContextLocalMode (int var)
 
InitializationFlag ContextLocalInitFlag (int var)
 
MaybeAssignedFlag ContextLocalMaybeAssignedFlag (int var)
 
bool LocalIsSynthetic (int var)
 
int StackSlotIndex (String *name)
 
int ParameterIndex (String *name)
 
int FunctionContextSlotIndex (String *name, VariableMode *mode)
 
- Public Member Functions inherited from v8::internal::FixedArray
Objectget (int index)
 
void set (int index, Object *value)
 
bool is_the_hole (int index)
 
void set (int index, Smi *value)
 
void set (int index, Object *value, WriteBarrierMode mode)
 
void set_undefined (int index)
 
void set_null (int index)
 
void set_the_hole (int index)
 
Object ** GetFirstElementAddress ()
 
bool ContainsOnlySmisOrHoles ()
 
Object ** data_start ()
 
void FillWithHoles (int from, int to)
 
void Shrink (int length)
 
void CopyTo (int pos, FixedArray *dest, int dest_pos, int len)
 
Object ** RawFieldOfElementAt (int index)
 
void SwapPairs (FixedArray *numbers, int i, int j)
 
void SortPairs (FixedArray *numbers, uint32_t len)
 
- Public Member Functions inherited from v8::internal::FixedArrayBase
int length () const
 
void set_length (int value)
 
int synchronized_length () const
 
void synchronized_set_length (int value)
 
- Public Member Functions inherited from v8::internal::HeapObject
Mapmap () const
 
void set_map (Map *value)
 
void set_map_no_write_barrier (Map *value)
 
Mapsynchronized_map ()
 
MapWord synchronized_map_word () const
 
void synchronized_set_map (Map *value)
 
void synchronized_set_map_no_write_barrier (Map *value)
 
void synchronized_set_map_word (MapWord map_word)
 
MapWord map_word () const
 
void set_map_word (MapWord map_word)
 
HeapGetHeap () const
 
IsolateGetIsolate () const
 
Address address ()
 
void Iterate (ObjectVisitor *v)
 
void IterateBody (InstanceType type, int object_size, ObjectVisitor *v)
 
int Size ()
 
bool MayContainRawValues ()
 
int SizeFromMap (Map *map)
 
WriteBarrierMode GetWriteBarrierMode (const DisallowHeapAllocation &promise)
 
void HeapObjectShortPrint (OStream &os)
 
 STATIC_ASSERT (kMapOffset==Internals::kHeapObjectMapOffset)
 
- Public Member Functions inherited from v8::internal::Object
bool IsObject () const
 
 INLINE (bool IsFixedArrayBase() const)
 
 INLINE (bool IsExternal() const)
 
 INLINE (bool IsAccessorInfo() const)
 
 INLINE (bool IsStruct() const)
 
 INLINE (bool IsSpecObject()) const
 
 INLINE (bool IsSpecFunction()) const
 
 INLINE (bool IsTemplateInfo()) const
 
 INLINE (bool IsNameDictionary() const)
 
 INLINE (bool IsSeededNumberDictionary() const)
 
 INLINE (bool IsUnseededNumberDictionary() const)
 
 INLINE (bool IsOrderedHashSet() const)
 
 INLINE (bool IsOrderedHashMap() const)
 
bool IsCallable () const
 
 INLINE (bool IsUndefined() const)
 
 INLINE (bool IsNull() const)
 
 INLINE (bool IsTheHole() const)
 
 INLINE (bool IsException() const)
 
 INLINE (bool IsUninitialized() const)
 
 INLINE (bool IsTrue() const)
 
 INLINE (bool IsFalse() const)
 
 INLINE (bool IsArgumentsMarker() const)
 
 INLINE (bool IsFiller() const)
 
double Number ()
 
 INLINE (bool IsNaN() const)
 
 INLINE (bool IsMinusZero() const)
 
bool ToInt32 (int32_t *value)
 
bool ToUint32 (uint32_t *value)
 
Representation OptimalRepresentation ()
 
bool FitsRepresentation (Representation representation)
 
Handle< HeapTypeOptimalType (Isolate *isolate, Representation representation)
 
bool HasValidElements ()
 
bool HasSpecificClassOf (String *name)
 
bool BooleanValue ()
 
ObjectGetHash ()
 
bool SameValue (Object *other)
 
bool SameValueZero (Object *other)
 
bool ToArrayIndex (uint32_t *index)
 
bool IsStringObjectWithCharacterAt (uint32_t index)
 
void VerifyApiCallResultType ()
 
void ShortPrint (FILE *out=stdout)
 
void ShortPrint (StringStream *accumulator)
 

Static Public Member Functions

static int ContextSlotIndex (Handle< ScopeInfo > scope_info, Handle< String > name, VariableMode *mode, InitializationFlag *init_flag, MaybeAssignedFlag *maybe_assigned_flag)
 
static bool CopyContextLocalsToScopeObject (Handle< ScopeInfo > scope_info, Handle< Context > context, Handle< JSObject > scope_object)
 
static Handle< ScopeInfoCreate (Scope *scope, Zone *zone)
 
static ScopeInfoEmpty (Isolate *isolate)
 
- Static Public Member Functions inherited from v8::internal::FixedArray
static Handle< Objectget (Handle< FixedArray > array, int index)
 
static Handle< FixedArrayCopySize (Handle< FixedArray > array, int new_length, PretenureFlag pretenure=NOT_TENURED)
 
static MUST_USE_RESULT MaybeHandle< FixedArrayAddKeysFromArrayLike (Handle< FixedArray > content, Handle< JSObject > array)
 
static MUST_USE_RESULT MaybeHandle< FixedArrayUnionOfKeys (Handle< FixedArray > first, Handle< FixedArray > second)
 
static int SizeFor (int length)
 
static int OffsetOfElementAt (int index)
 
- Static Public Member Functions inherited from v8::internal::HeapObject
static HeapObjectFromAddress (Address address)
 
static Object ** RawField (HeapObject *obj, int offset)
 
static void UpdateMapCodeCache (Handle< HeapObject > object, Handle< Name > name, Handle< Code > code)
 
- Static Public Member Functions inherited from v8::internal::Object
static Handle< ObjectNewStorageFor (Isolate *isolate, Handle< Object > object, Representation representation)
 
static Handle< ObjectWrapForRead (Isolate *isolate, Handle< Object > object, Representation representation)
 
static MaybeHandle< JSReceiverToObject (Isolate *isolate, Handle< Object > object)
 
static MaybeHandle< JSReceiverToObject (Isolate *isolate, Handle< Object > object, Handle< Context > context)
 
static MUST_USE_RESULT MaybeHandle< SmiToSmi (Isolate *isolate, Handle< Object > object)
 
static MUST_USE_RESULT MaybeHandle< ObjectGetProperty (LookupIterator *it)
 
static MUST_USE_RESULT MaybeHandle< ObjectSetProperty (Handle< Object > object, Handle< Name > key, Handle< Object > value, StrictMode strict_mode, StoreFromKeyed store_mode=MAY_BE_STORE_FROM_KEYED)
 
static MUST_USE_RESULT MaybeHandle< ObjectSetProperty (LookupIterator *it, Handle< Object > value, StrictMode strict_mode, StoreFromKeyed store_mode, StorePropertyMode data_store_mode=NORMAL_PROPERTY)
 
static MUST_USE_RESULT MaybeHandle< ObjectWriteToReadOnlyProperty (LookupIterator *it, Handle< Object > value, StrictMode strict_mode)
 
static Handle< ObjectSetDataProperty (LookupIterator *it, Handle< Object > value)
 
static MUST_USE_RESULT MaybeHandle< ObjectAddDataProperty (LookupIterator *it, Handle< Object > value, PropertyAttributes attributes, StrictMode strict_mode, StoreFromKeyed store_mode)
 
static MUST_USE_RESULT MaybeHandle< ObjectGetPropertyOrElement (Handle< Object > object, Handle< Name > key)
 
static MUST_USE_RESULT MaybeHandle< ObjectGetProperty (Isolate *isolate, Handle< Object > object, const char *key)
 
static MUST_USE_RESULT MaybeHandle< ObjectGetProperty (Handle< Object > object, Handle< Name > key)
 
static MUST_USE_RESULT MaybeHandle< ObjectGetPropertyWithAccessor (Handle< Object > receiver, Handle< Name > name, Handle< JSObject > holder, Handle< Object > structure)
 
static MUST_USE_RESULT MaybeHandle< ObjectSetPropertyWithAccessor (Handle< Object > receiver, Handle< Name > name, Handle< Object > value, Handle< JSObject > holder, Handle< Object > structure, StrictMode strict_mode)
 
static MUST_USE_RESULT MaybeHandle< ObjectGetPropertyWithDefinedGetter (Handle< Object > receiver, Handle< JSReceiver > getter)
 
static MUST_USE_RESULT MaybeHandle< ObjectSetPropertyWithDefinedSetter (Handle< Object > receiver, Handle< JSReceiver > setter, Handle< Object > value)
 
static MUST_USE_RESULT MaybeHandle< ObjectGetElement (Isolate *isolate, Handle< Object > object, uint32_t index)
 
static MUST_USE_RESULT MaybeHandle< ObjectGetElementWithReceiver (Isolate *isolate, Handle< Object > object, Handle< Object > receiver, uint32_t index)
 
static Handle< SmiGetOrCreateHash (Isolate *isolate, Handle< Object > object)
 

Private Types

enum  { kVariablePartIndex }
 
enum  FunctionVariableInfo { NONE , STACK , CONTEXT , UNUSED }
 

Private Member Functions

int ParameterEntriesIndex ()
 
int StackLocalEntriesIndex ()
 
int ContextLocalNameEntriesIndex ()
 
int ContextLocalInfoEntriesIndex ()
 
int FunctionNameEntryIndex ()
 

Additional Inherited Members

- Public Types inherited from v8::internal::Object
enum  StoreFromKeyed { MAY_BE_STORE_FROM_KEYED , CERTAINLY_NOT_STORE_FROM_KEYED }
 
enum  StorePropertyMode { NORMAL_PROPERTY , SUPER_PROPERTY }
 
- Static Public Attributes inherited from v8::internal::FixedArray
static const int kMaxSize = 128 * MB * kPointerSize
 
static const int kMaxLength = (kMaxSize - kHeaderSize) / kPointerSize
 
- Static Public Attributes inherited from v8::internal::FixedArrayBase
static const int kLengthOffset = HeapObject::kHeaderSize
 
static const int kHeaderSize = kLengthOffset + kPointerSize
 
- Static Public Attributes inherited from v8::internal::HeapObject
static const int kMapOffset = Object::kHeaderSize
 
static const int kHeaderSize = kMapOffset + kPointerSize
 
- Static Public Attributes inherited from v8::internal::Object
static const int kHeaderSize = 0
 
- Protected Member Functions inherited from v8::internal::HeapObject
void IteratePointers (ObjectVisitor *v, int start, int end)
 
void IteratePointer (ObjectVisitor *v, int offset)
 
void IterateNextCodeLink (ObjectVisitor *v, int offset)
 
- Static Protected Member Functions inherited from v8::internal::FixedArray
static void NoWriteBarrierSet (FixedArray *array, int index, Object *value)
 
static void NoIncrementalWriteBarrierSet (FixedArray *array, int index, Object *value)
 

Detailed Description

Definition at line 4102 of file objects.h.

Member Enumeration Documentation

◆ anonymous enum

anonymous enum
private
Enumerator
kVariablePartIndex 

Definition at line 4251 of file objects.h.

4251  {
4252 #define DECL_INDEX(name) k##name,
4254 #undef DECL_INDEX
4255 #undef FOR_EACH_NUMERIC_FIELD
4257  };
#define DECL_INDEX(name)
Definition: objects.h:4252
#define FOR_EACH_NUMERIC_FIELD(V)
Definition: objects.h:4230

◆ FunctionVariableInfo

Enumerator
NONE 
STACK 
CONTEXT 
UNUSED 

Definition at line 4293 of file objects.h.

4293  {
4294  NONE, // No function name present.
4295  STACK, // Function
4296  CONTEXT,
4297  UNUSED
4298  };

Member Function Documentation

◆ CallsEval()

bool v8::internal::ScopeInfo::CallsEval ( )

Definition at line 143 of file scopeinfo.cc.

143  {
144  return length() > 0 && CallsEvalField::decode(Flags());
145 }
static T decode(U value)
Definition: utils.h:228

References v8::internal::BitFieldBase< T, shift, size, U >::decode(), and v8::internal::FixedArrayBase::length().

Referenced by ContextLength().

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

◆ CallsSloppyEval()

bool v8::internal::ScopeInfo::CallsSloppyEval ( )
inline

Definition at line 4116 of file objects.h.

4116 { return CallsEval() && strict_mode() == SLOPPY; }
StrictMode strict_mode()
Definition: scopeinfo.cc:148

References v8::internal::SLOPPY.

◆ ContextLength()

int v8::internal::ScopeInfo::ContextLength ( )

Definition at line 168 of file scopeinfo.cc.

168  {
169  if (length() > 0) {
170  int context_locals = ContextLocalCount();
171  bool function_name_context_slot =
173  bool has_context = context_locals > 0 ||
174  function_name_context_slot ||
175  scope_type() == WITH_SCOPE ||
176  (scope_type() == FUNCTION_SCOPE && CallsEval()) ||
178  if (has_context) {
179  return Context::MIN_CONTEXT_SLOTS + context_locals +
180  (function_name_context_slot ? 1 : 0);
181  }
182  }
183  return 0;
184 }
ScopeType scope_type()
Definition: scopeinfo.cc:137
@ FUNCTION_SCOPE
Definition: globals.h:647
@ MODULE_SCOPE
Definition: globals.h:648

References CallsEval(), CONTEXT, v8::internal::BitFieldBase< T, shift, size, U >::decode(), v8::internal::FUNCTION_SCOPE, v8::internal::FixedArrayBase::length(), v8::internal::Context::MIN_CONTEXT_SLOTS, v8::internal::MODULE_SCOPE, scope_type(), and v8::internal::WITH_SCOPE.

Referenced by ContextSlotIndex(), and HasContext().

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

◆ ContextLocalInfoEntriesIndex()

int v8::internal::ScopeInfo::ContextLocalInfoEntriesIndex ( )
private

Definition at line 412 of file scopeinfo.cc.

412  {
413  return ContextLocalNameEntriesIndex() + ContextLocalCount();
414 }
int ContextLocalNameEntriesIndex()
Definition: scopeinfo.cc:407

References ContextLocalNameEntriesIndex().

Referenced by ContextLocalInitFlag(), ContextLocalMaybeAssignedFlag(), ContextLocalMode(), and FunctionNameEntryIndex().

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

◆ ContextLocalInitFlag()

Definition at line 254 of file scopeinfo.cc.

254  {
255  DCHECK(0 <= var && var < ContextLocalCount());
256  int info_index = ContextLocalInfoEntriesIndex() + var;
257  int value = Smi::cast(get(info_index))->value();
258  return ContextLocalInitFlag::decode(value);
259 }
Object * get(int index)
Definition: objects-inl.h:2165
int ContextLocalInfoEntriesIndex()
Definition: scopeinfo.cc:412
#define DCHECK(condition)
Definition: logging.h:205

References ContextLocalInfoEntriesIndex(), DCHECK, v8::internal::BitFieldBase< T, shift, size, U >::decode(), and v8::internal::FixedArray::get().

+ Here is the call graph for this function:

◆ ContextLocalMaybeAssignedFlag()

Definition at line 262 of file scopeinfo.cc.

262  {
263  DCHECK(0 <= var && var < ContextLocalCount());
264  int info_index = ContextLocalInfoEntriesIndex() + var;
265  int value = Smi::cast(get(info_index))->value();
267 }

References ContextLocalInfoEntriesIndex(), DCHECK, v8::internal::BitFieldBase< T, shift, size, U >::decode(), and v8::internal::FixedArray::get().

+ Here is the call graph for this function:

◆ ContextLocalMode()

Definition at line 246 of file scopeinfo.cc.

246  {
247  DCHECK(0 <= var && var < ContextLocalCount());
248  int info_index = ContextLocalInfoEntriesIndex() + var;
249  int value = Smi::cast(get(info_index))->value();
250  return ContextLocalMode::decode(value);
251 }

References ContextLocalInfoEntriesIndex(), DCHECK, v8::internal::BitFieldBase< T, shift, size, U >::decode(), and v8::internal::FixedArray::get().

+ Here is the call graph for this function:

◆ ContextLocalName()

String * v8::internal::ScopeInfo::ContextLocalName ( int  var)

Definition at line 239 of file scopeinfo.cc.

239  {
240  DCHECK(0 <= var && var < ContextLocalCount());
241  int info_index = ContextLocalNameEntriesIndex() + var;
242  return String::cast(get(info_index));
243 }

References ContextLocalNameEntriesIndex(), DCHECK, and v8::internal::FixedArray::get().

Referenced by v8::internal::V8HeapExplorer::ExtractContextReferences(), and v8::internal::JavaScriptFrame::Print().

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

◆ ContextLocalNameEntriesIndex()

int v8::internal::ScopeInfo::ContextLocalNameEntriesIndex ( )
private

Definition at line 407 of file scopeinfo.cc.

407  {
408  return StackLocalEntriesIndex() + StackLocalCount();
409 }

References StackLocalEntriesIndex().

Referenced by ContextLocalInfoEntriesIndex(), ContextLocalName(), and LocalName().

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

◆ ContextSlotIndex()

int v8::internal::ScopeInfo::ContextSlotIndex ( Handle< ScopeInfo scope_info,
Handle< String name,
VariableMode mode,
InitializationFlag init_flag,
MaybeAssignedFlag maybe_assigned_flag 
)
static

Definition at line 296 of file scopeinfo.cc.

299  {
300  DCHECK(name->IsInternalizedString());
301  DCHECK(mode != NULL);
302  DCHECK(init_flag != NULL);
303  if (scope_info->length() > 0) {
304  ContextSlotCache* context_slot_cache =
305  scope_info->GetIsolate()->context_slot_cache();
306  int result = context_slot_cache->Lookup(*scope_info, *name, mode, init_flag,
307  maybe_assigned_flag);
308  if (result != ContextSlotCache::kNotFound) {
309  DCHECK(result < scope_info->ContextLength());
310  return result;
311  }
312 
313  int start = scope_info->ContextLocalNameEntriesIndex();
314  int end = scope_info->ContextLocalNameEntriesIndex() +
315  scope_info->ContextLocalCount();
316  for (int i = start; i < end; ++i) {
317  if (*name == scope_info->get(i)) {
318  int var = i - start;
319  *mode = scope_info->ContextLocalMode(var);
320  *init_flag = scope_info->ContextLocalInitFlag(var);
321  *maybe_assigned_flag = scope_info->ContextLocalMaybeAssignedFlag(var);
322  result = Context::MIN_CONTEXT_SLOTS + var;
323  context_slot_cache->Update(scope_info, name, *mode, *init_flag,
324  *maybe_assigned_flag, result);
325  DCHECK(result < scope_info->ContextLength());
326  return result;
327  }
328  }
329  // Cache as not found. Mode, init flag and maybe assigned flag don't matter.
330  context_slot_cache->Update(scope_info, name, INTERNAL, kNeedsInitialization,
331  kNotAssigned, -1);
332  }
333  return -1;
334 }
static const int kNotFound
Definition: scopeinfo.h:35
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
@ kNeedsInitialization
Definition: globals.h:752
@ kNotAssigned
Definition: globals.h:757

References ContextLength(), DCHECK, v8::internal::INTERNAL, v8::internal::kNeedsInitialization, v8::internal::kNotAssigned, v8::internal::ContextSlotCache::kNotFound, v8::internal::ContextSlotCache::Lookup(), v8::internal::Context::MIN_CONTEXT_SLOTS, mode(), name, NULL, and v8::internal::ContextSlotCache::Update().

Referenced by v8::internal::Context::Lookup(), v8::internal::Scope::LookupLocal(), v8::internal::ParameterIsShadowedByContextLocal(), v8::internal::RUNTIME_FUNCTION(), and v8::internal::SetContextLocalValue().

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

◆ CopyContextLocalsToScopeObject()

bool v8::internal::ScopeInfo::CopyContextLocalsToScopeObject ( Handle< ScopeInfo scope_info,
Handle< Context context,
Handle< JSObject scope_object 
)
static

Definition at line 371 of file scopeinfo.cc.

373  {
374  Isolate* isolate = scope_info->GetIsolate();
375  int local_count = scope_info->ContextLocalCount();
376  if (local_count == 0) return true;
377  // Fill all context locals to the context extension.
378  int first_context_var = scope_info->StackLocalCount();
379  int start = scope_info->ContextLocalNameEntriesIndex();
380  for (int i = 0; i < local_count; ++i) {
381  if (scope_info->LocalIsSynthetic(first_context_var + i)) continue;
382  int context_index = Context::MIN_CONTEXT_SLOTS + i;
384  isolate,
386  scope_object,
387  Handle<String>(String::cast(scope_info->get(i + start))),
388  Handle<Object>(context->get(context_index), isolate),
389  ::NONE),
390  false);
391  }
392  return true;
393 }
static MUST_USE_RESULT MaybeHandle< Object > DefineObjectProperty(Handle< JSObject > object, Handle< Object > key, Handle< Object > value, PropertyAttributes attr)
Definition: runtime.cc:2277
#define RETURN_ON_EXCEPTION_VALUE(isolate, call, value)
Definition: isolate.h:154

References v8::internal::Runtime::DefineObjectProperty(), v8::internal::Context::MIN_CONTEXT_SLOTS, NONE, and RETURN_ON_EXCEPTION_VALUE.

Referenced by v8::internal::MaterializeBlockScope(), v8::internal::MaterializeClosure(), v8::internal::MaterializeLocalContext(), and v8::internal::MaterializeModuleScope().

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

◆ Create()

Handle< ScopeInfo > v8::internal::ScopeInfo::Create ( Scope scope,
Zone zone 
)
static

Definition at line 16 of file scopeinfo.cc.

16  {
17  // Collect stack and context locals.
18  ZoneList<Variable*> stack_locals(scope->StackLocalCount(), zone);
19  ZoneList<Variable*> context_locals(scope->ContextLocalCount(), zone);
20  scope->CollectStackAndContextLocals(&stack_locals, &context_locals);
21  const int stack_local_count = stack_locals.length();
22  const int context_local_count = context_locals.length();
23  // Make sure we allocate the correct amount.
24  DCHECK(scope->StackLocalCount() == stack_local_count);
25  DCHECK(scope->ContextLocalCount() == context_local_count);
26 
27  // Determine use and location of the function variable if it is present.
28  FunctionVariableInfo function_name_info;
29  VariableMode function_variable_mode;
30  if (scope->is_function_scope() && scope->function() != NULL) {
31  Variable* var = scope->function()->proxy()->var();
32  if (!var->is_used()) {
33  function_name_info = UNUSED;
34  } else if (var->IsContextSlot()) {
35  function_name_info = CONTEXT;
36  } else {
37  DCHECK(var->IsStackLocal());
38  function_name_info = STACK;
39  }
40  function_variable_mode = var->mode();
41  } else {
42  function_name_info = NONE;
43  function_variable_mode = VAR;
44  }
45 
46  const bool has_function_name = function_name_info != NONE;
47  const int parameter_count = scope->num_parameters();
48  const int length = kVariablePartIndex
49  + parameter_count + stack_local_count + 2 * context_local_count
50  + (has_function_name ? 2 : 0);
51 
52  Factory* factory = zone->isolate()->factory();
53  Handle<ScopeInfo> scope_info = factory->NewScopeInfo(length);
54 
55  // Encode the flags.
56  int flags = ScopeTypeField::encode(scope->scope_type()) |
57  CallsEvalField::encode(scope->calls_eval()) |
58  StrictModeField::encode(scope->strict_mode()) |
59  FunctionVariableField::encode(function_name_info) |
60  FunctionVariableMode::encode(function_variable_mode) |
61  AsmModuleField::encode(scope->asm_module()) |
62  AsmFunctionField::encode(scope->asm_function());
63  scope_info->SetFlags(flags);
64  scope_info->SetParameterCount(parameter_count);
65  scope_info->SetStackLocalCount(stack_local_count);
66  scope_info->SetContextLocalCount(context_local_count);
67 
68  int index = kVariablePartIndex;
69  // Add parameters.
70  DCHECK(index == scope_info->ParameterEntriesIndex());
71  for (int i = 0; i < parameter_count; ++i) {
72  scope_info->set(index++, *scope->parameter(i)->name());
73  }
74 
75  // Add stack locals' names. We are assuming that the stack locals'
76  // slots are allocated in increasing order, so we can simply add
77  // them to the ScopeInfo object.
78  DCHECK(index == scope_info->StackLocalEntriesIndex());
79  for (int i = 0; i < stack_local_count; ++i) {
80  DCHECK(stack_locals[i]->index() == i);
81  scope_info->set(index++, *stack_locals[i]->name());
82  }
83 
84  // Due to usage analysis, context-allocated locals are not necessarily in
85  // increasing order: Some of them may be parameters which are allocated before
86  // the non-parameter locals. When the non-parameter locals are sorted
87  // according to usage, the allocated slot indices may not be in increasing
88  // order with the variable list anymore. Thus, we first need to sort them by
89  // context slot index before adding them to the ScopeInfo object.
90  context_locals.Sort(&Variable::CompareIndex);
91 
92  // Add context locals' names.
93  DCHECK(index == scope_info->ContextLocalNameEntriesIndex());
94  for (int i = 0; i < context_local_count; ++i) {
95  scope_info->set(index++, *context_locals[i]->name());
96  }
97 
98  // Add context locals' info.
99  DCHECK(index == scope_info->ContextLocalInfoEntriesIndex());
100  for (int i = 0; i < context_local_count; ++i) {
101  Variable* var = context_locals[i];
102  uint32_t value =
103  ContextLocalMode::encode(var->mode()) |
104  ContextLocalInitFlag::encode(var->initialization_flag()) |
105  ContextLocalMaybeAssignedFlag::encode(var->maybe_assigned());
106  scope_info->set(index++, Smi::FromInt(value));
107  }
108 
109  // If present, add the function variable name and its index.
110  DCHECK(index == scope_info->FunctionNameEntryIndex());
111  if (has_function_name) {
112  int var_index = scope->function()->proxy()->var()->index();
113  scope_info->set(index++, *scope->function()->proxy()->name());
114  scope_info->set(index++, Smi::FromInt(var_index));
115  DCHECK(function_name_info != STACK ||
116  (var_index == scope_info->StackLocalCount() &&
117  var_index == scope_info->StackSlotCount() - 1));
118  DCHECK(function_name_info != CONTEXT ||
119  var_index == scope_info->ContextLength() - 1);
120  }
121 
122  DCHECK(index == scope_info->length());
123  DCHECK(scope->num_parameters() == scope_info->ParameterCount());
124  DCHECK(scope->num_stack_slots() == scope_info->StackSlotCount());
125  DCHECK(scope->num_heap_slots() == scope_info->ContextLength() ||
126  (scope->num_heap_slots() == kVariablePartIndex &&
127  scope_info->ContextLength() == 0));
128  return scope_info;
129 }
static U encode(T value)
Definition: utils.h:217
static Smi * FromInt(int value)
Definition: objects-inl.h:1321
static int CompareIndex(Variable *const *v, Variable *const *w)
Definition: variables.cc:67

References v8::internal::Scope::asm_function(), v8::internal::Scope::asm_module(), v8::internal::Scope::calls_eval(), v8::internal::Scope::CollectStackAndContextLocals(), v8::internal::Variable::CompareIndex(), CONTEXT, v8::internal::Scope::ContextLocalCount(), DCHECK, v8::internal::BitFieldBase< T, shift, size, U >::encode(), v8::internal::Isolate::factory(), v8::internal::anonymous_namespace{flags.cc}::flags, v8::internal::Smi::FromInt(), v8::internal::Scope::function(), v8::internal::Variable::initialization_flag(), v8::internal::Scope::is_function_scope(), v8::internal::Variable::is_used(), v8::internal::Variable::IsContextSlot(), v8::internal::Zone::isolate(), v8::internal::Variable::IsStackLocal(), kVariablePartIndex, v8::internal::FixedArrayBase::length(), v8::internal::Variable::maybe_assigned(), v8::internal::Variable::mode(), name, v8::internal::Variable::name(), NONE, NULL, v8::internal::Scope::num_heap_slots(), v8::internal::Scope::num_parameters(), v8::internal::Scope::num_stack_slots(), v8::internal::Scope::parameter(), v8::internal::Scope::scope_type(), v8::internal::List< T, AllocationPolicy >::Sort(), STACK, v8::internal::Scope::StackLocalCount(), v8::internal::Scope::strict_mode(), UNUSED, and v8::internal::VAR.

Referenced by v8::internal::Compiler::BuildFunctionInfo(), v8::internal::Compiler::CompileForLiveEdit(), v8::internal::CompileToplevel(), v8::internal::Compiler::EnsureDeoptimizationSupport(), v8::internal::Scope::GetScopeInfo(), and v8::internal::GetUnoptimizedCodeCommon().

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

◆ Empty()

ScopeInfo * v8::internal::ScopeInfo::Empty ( Isolate isolate)
static

Definition at line 132 of file scopeinfo.cc.

132  {
133  return reinterpret_cast<ScopeInfo*>(isolate->heap()->empty_fixed_array());
134 }

References v8::internal::Isolate::heap().

Referenced by v8::internal::Compiler::BuildFunctionInfo(), v8::internal::Compiler::EnsureDeoptimizationSupport(), v8::internal::Compiler::GetOptimizedCode(), and v8::internal::RUNTIME_FUNCTION().

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

◆ FunctionContextSlotIndex()

int v8::internal::ScopeInfo::FunctionContextSlotIndex ( String name,
VariableMode mode 
)

Definition at line 357 of file scopeinfo.cc.

357  {
358  DCHECK(name->IsInternalizedString());
359  DCHECK(mode != NULL);
360  if (length() > 0) {
361  if (FunctionVariableField::decode(Flags()) == CONTEXT &&
362  FunctionName() == name) {
364  return Smi::cast(get(FunctionNameEntryIndex() + 1))->value();
365  }
366  }
367  return -1;
368 }

References CONTEXT, DCHECK, v8::internal::BitFieldBase< T, shift, size, U >::decode(), FunctionName(), FunctionNameEntryIndex(), v8::internal::FixedArray::get(), v8::internal::FixedArrayBase::length(), mode(), name, and NULL.

Referenced by v8::internal::V8HeapExplorer::ExtractContextReferences().

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

◆ FunctionName()

String * v8::internal::ScopeInfo::FunctionName ( )

Definition at line 210 of file scopeinfo.cc.

210  {
212  return String::cast(get(FunctionNameEntryIndex()));
213 }

References DCHECK, FunctionNameEntryIndex(), v8::internal::FixedArray::get(), and HasFunctionName().

Referenced by v8::internal::V8HeapExplorer::ExtractContextReferences(), and FunctionContextSlotIndex().

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

◆ FunctionNameEntryIndex()

int v8::internal::ScopeInfo::FunctionNameEntryIndex ( )
private

Definition at line 417 of file scopeinfo.cc.

417  {
418  return ContextLocalInfoEntriesIndex() + ContextLocalCount();
419 }

References ContextLocalInfoEntriesIndex().

Referenced by FunctionContextSlotIndex(), and FunctionName().

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

◆ HasContext()

bool v8::internal::ScopeInfo::HasContext ( )

Definition at line 205 of file scopeinfo.cc.

205  {
206  return ContextLength() > 0;
207 }

References ContextLength().

+ Here is the call graph for this function:

◆ HasFunctionName()

bool v8::internal::ScopeInfo::HasFunctionName ( )

Definition at line 187 of file scopeinfo.cc.

187  {
188  if (length() > 0) {
189  return NONE != FunctionVariableField::decode(Flags());
190  } else {
191  return false;
192  }
193 }

References v8::internal::BitFieldBase< T, shift, size, U >::decode(), v8::internal::FixedArrayBase::length(), and NONE.

Referenced by v8::internal::V8HeapExplorer::ExtractContextReferences(), and FunctionName().

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

◆ HasHeapAllocatedLocals()

bool v8::internal::ScopeInfo::HasHeapAllocatedLocals ( )

Definition at line 196 of file scopeinfo.cc.

196  {
197  if (length() > 0) {
198  return ContextLocalCount() > 0;
199  } else {
200  return false;
201  }
202 }

References v8::internal::FixedArrayBase::length().

+ Here is the call graph for this function:

◆ IsAsmFunction()

bool v8::internal::ScopeInfo::IsAsmFunction ( )
inline

Definition at line 4150 of file objects.h.

4150 { return AsmFunctionField::decode(Flags()); }

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

+ Here is the caller graph for this function:

◆ IsAsmModule()

bool v8::internal::ScopeInfo::IsAsmModule ( )
inline

Definition at line 4147 of file objects.h.

4147 { return AsmModuleField::decode(Flags()); }

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

+ Here is the caller graph for this function:

◆ LocalCount()

int v8::internal::ScopeInfo::LocalCount ( )

Definition at line 153 of file scopeinfo.cc.

153  {
154  return StackLocalCount() + ContextLocalCount();
155 }

Referenced by LocalIsSynthetic(), and LocalName().

+ Here is the caller graph for this function:

◆ LocalIsSynthetic()

bool v8::internal::ScopeInfo::LocalIsSynthetic ( int  var)

Definition at line 270 of file scopeinfo.cc.

270  {
271  DCHECK(0 <= var && var < LocalCount());
272  // There's currently no flag stored on the ScopeInfo to indicate that a
273  // variable is a compiler-introduced temporary. However, to avoid conflict
274  // with user declarations, the current temporaries like .generator_object and
275  // .result start with a dot, so we can use that as a flag. It's a hack!
276  Handle<String> name(LocalName(var));
277  return name->length() > 0 && name->Get(0) == '.';
278 }
String * LocalName(int var)
Definition: scopeinfo.cc:223

References DCHECK, LocalCount(), LocalName(), and name.

+ Here is the call graph for this function:

◆ LocalName()

String * v8::internal::ScopeInfo::LocalName ( int  var)

Definition at line 223 of file scopeinfo.cc.

223  {
224  DCHECK(0 <= var && var < LocalCount());
225  DCHECK(StackLocalEntriesIndex() + StackLocalCount() ==
227  int info_index = StackLocalEntriesIndex() + var;
228  return String::cast(get(info_index));
229 }

References ContextLocalNameEntriesIndex(), DCHECK, v8::internal::FixedArray::get(), LocalCount(), and StackLocalEntriesIndex().

Referenced by LocalIsSynthetic().

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

◆ ParameterEntriesIndex()

int v8::internal::ScopeInfo::ParameterEntriesIndex ( )
private

Definition at line 396 of file scopeinfo.cc.

396  {
397  DCHECK(length() > 0);
398  return kVariablePartIndex;
399 }

References DCHECK, kVariablePartIndex, and v8::internal::FixedArrayBase::length().

Referenced by ParameterIndex(), ParameterName(), and StackLocalEntriesIndex().

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

◆ ParameterIndex()

int v8::internal::ScopeInfo::ParameterIndex ( String name)

Definition at line 337 of file scopeinfo.cc.

337  {
338  DCHECK(name->IsInternalizedString());
339  if (length() > 0) {
340  // We must read parameters from the end since for
341  // multiply declared parameters the value of the
342  // last declaration of that parameter is used
343  // inside a function (and thus we need to look
344  // at the last index). Was bug# 1110337.
345  int start = ParameterEntriesIndex();
346  int end = ParameterEntriesIndex() + ParameterCount();
347  for (int i = end - 1; i >= start; --i) {
348  if (name == get(i)) {
349  return i - start;
350  }
351  }
352  }
353  return -1;
354 }

References DCHECK, v8::internal::FixedArray::get(), v8::internal::FixedArrayBase::length(), name, and ParameterEntriesIndex().

+ Here is the call graph for this function:

◆ ParameterName()

String * v8::internal::ScopeInfo::ParameterName ( int  var)

Definition at line 216 of file scopeinfo.cc.

216  {
217  DCHECK(0 <= var && var < ParameterCount());
218  int info_index = ParameterEntriesIndex() + var;
219  return String::cast(get(info_index));
220 }

References DCHECK, v8::internal::FixedArray::get(), and ParameterEntriesIndex().

Referenced by v8::internal::JavaScriptFrame::Print().

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

◆ scope_type()

ScopeType v8::internal::ScopeInfo::scope_type ( )

Definition at line 137 of file scopeinfo.cc.

137  {
138  DCHECK(length() > 0);
139  return ScopeTypeField::decode(Flags());
140 }

References DCHECK, v8::internal::BitFieldBase< T, shift, size, U >::decode(), and v8::internal::FixedArrayBase::length().

Referenced by ContextLength().

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

◆ StackLocalEntriesIndex()

int v8::internal::ScopeInfo::StackLocalEntriesIndex ( )
private

Definition at line 402 of file scopeinfo.cc.

402  {
403  return ParameterEntriesIndex() + ParameterCount();
404 }

References ParameterEntriesIndex().

Referenced by ContextLocalNameEntriesIndex(), LocalName(), StackLocalName(), and StackSlotIndex().

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

◆ StackLocalName()

String * v8::internal::ScopeInfo::StackLocalName ( int  var)

Definition at line 232 of file scopeinfo.cc.

232  {
233  DCHECK(0 <= var && var < StackLocalCount());
234  int info_index = StackLocalEntriesIndex() + var;
235  return String::cast(get(info_index));
236 }

References DCHECK, v8::internal::FixedArray::get(), and StackLocalEntriesIndex().

Referenced by v8::internal::JavaScriptFrame::Print().

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

◆ StackSlotCount()

int v8::internal::ScopeInfo::StackSlotCount ( )

Definition at line 158 of file scopeinfo.cc.

158  {
159  if (length() > 0) {
160  bool function_name_stack_slot =
162  return StackLocalCount() + (function_name_stack_slot ? 1 : 0);
163  }
164  return 0;
165 }

References v8::internal::BitFieldBase< T, shift, size, U >::decode(), v8::internal::FixedArrayBase::length(), and STACK.

+ Here is the call graph for this function:

◆ StackSlotIndex()

int v8::internal::ScopeInfo::StackSlotIndex ( String name)

Definition at line 281 of file scopeinfo.cc.

281  {
282  DCHECK(name->IsInternalizedString());
283  if (length() > 0) {
284  int start = StackLocalEntriesIndex();
285  int end = StackLocalEntriesIndex() + StackLocalCount();
286  for (int i = start; i < end; ++i) {
287  if (name == get(i)) {
288  return i - start;
289  }
290  }
291  }
292  return -1;
293 }

References DCHECK, v8::internal::FixedArray::get(), v8::internal::FixedArrayBase::length(), name, and StackLocalEntriesIndex().

+ Here is the call graph for this function:

◆ strict_mode()

StrictMode v8::internal::ScopeInfo::strict_mode ( )

Definition at line 148 of file scopeinfo.cc.

148  {
149  return length() > 0 ? StrictModeField::decode(Flags()) : SLOPPY;
150 }

References v8::internal::BitFieldBase< T, shift, size, U >::decode(), v8::internal::FixedArrayBase::length(), and v8::internal::SLOPPY.

+ Here is the call graph for this function:

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