21 const int stack_local_count = stack_locals.length();
22 const int context_local_count = context_locals.length();
33 function_name_info =
UNUSED;
38 function_name_info =
STACK;
40 function_variable_mode = var->
mode();
42 function_name_info =
NONE;
43 function_variable_mode =
VAR;
46 const bool has_function_name = function_name_info !=
NONE;
49 + parameter_count + stack_local_count + 2 * context_local_count
50 + (has_function_name ? 2 : 0);
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);
70 DCHECK(index == scope_info->ParameterEntriesIndex());
71 for (
int i = 0;
i < parameter_count; ++
i) {
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());
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());
99 DCHECK(index == scope_info->ContextLocalInfoEntriesIndex());
100 for (
int i = 0;
i < context_local_count; ++
i) {
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());
116 (var_index == scope_info->StackLocalCount() &&
117 var_index == scope_info->StackSlotCount() - 1));
119 var_index == scope_info->ContextLength() - 1);
122 DCHECK(index == scope_info->length());
127 scope_info->ContextLength() == 0));
133 return reinterpret_cast<ScopeInfo*
>(isolate->
heap()->empty_fixed_array());
154 return StackLocalCount() + ContextLocalCount();
160 bool function_name_stack_slot =
162 return StackLocalCount() + (function_name_stack_slot ? 1 : 0);
170 int context_locals = ContextLocalCount();
171 bool function_name_context_slot =
173 bool has_context = context_locals > 0 ||
174 function_name_context_slot ||
180 (function_name_context_slot ? 1 : 0);
198 return ContextLocalCount() > 0;
217 DCHECK(0 <= var && var < ParameterCount());
219 return String::cast(
get(info_index));
228 return String::cast(
get(info_index));
233 DCHECK(0 <= var && var < StackLocalCount());
235 return String::cast(
get(info_index));
240 DCHECK(0 <= var && var < ContextLocalCount());
242 return String::cast(
get(info_index));
247 DCHECK(0 <= var && var < ContextLocalCount());
249 int value = Smi::cast(
get(info_index))->value();
255 DCHECK(0 <= var && var < ContextLocalCount());
257 int value = Smi::cast(
get(info_index))->value();
263 DCHECK(0 <= var && var < ContextLocalCount());
265 int value = Smi::cast(
get(info_index))->value();
277 return name->length() > 0 &&
name->Get(0) ==
'.';
286 for (
int i = start;
i < end; ++
i) {
303 if (scope_info->length() > 0) {
305 scope_info->GetIsolate()->context_slot_cache();
306 int result = context_slot_cache->
Lookup(*scope_info, *
name,
mode, init_flag,
307 maybe_assigned_flag);
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)) {
319 *
mode = scope_info->ContextLocalMode(var);
320 *init_flag = scope_info->ContextLocalInitFlag(var);
321 *maybe_assigned_flag = scope_info->ContextLocalMaybeAssignedFlag(var);
324 *maybe_assigned_flag, result);
347 for (
int i = end - 1;
i >= start; --
i) {
374 Isolate* isolate = scope_info->GetIsolate();
375 int local_count = scope_info->ContextLocalCount();
376 if (local_count == 0)
return true;
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;
426 return static_cast<int>((addr_hash ^
name->Hash()) %
kLength);
439 if (maybe_assigned_flag !=
NULL)
455 ToHandle(&internalized_name)) {
456 int index =
Hash(*data, *internalized_name);
459 key.
name = *internalized_name;
464 ValidateEntry(data,
name,
mode, init_flag, maybe_assigned_flag, slot_index);
485 ToHandle(&internalized_name)) {
487 Key& key =
keys_[index];
488 DCHECK(key.data == *data);
492 DCHECK(result.initialization_flag() == init_flag);
493 DCHECK(result.maybe_assigned_flag() == maybe_assigned_flag);
499 static void PrintList(
const char* list_name,
500 int nof_internal_slots,
503 ScopeInfo* scope_info) {
505 PrintF(
"\n // %s\n", list_name);
506 if (nof_internal_slots > 0) {
507 PrintF(
" %2d - %2d [internal slots]\n", 0 , nof_internal_slots - 1);
509 for (
int i = nof_internal_slots; start < end; ++
i, ++start) {
511 String::cast(scope_info->get(start))->ShortPrint();
518 void ScopeInfo::Print() {
523 PrintF(
"/* no function name */");
527 PrintList(
"parameters", 0,
531 PrintList(
"stack slots", 0,
535 PrintList(
"context slots",
552 info->set_host_index(interface->
Index());
555 !it.
done(); it.Advance(), ++
i) {
557 info->set_name(
i, *(it.name()->string()));
558 info->set_mode(
i, var->
mode());
561 DCHECK(it.interface()->IsFrozen());
562 DCHECK(it.interface()->Index() >= 0);
563 info->set_index(
i, it.interface()->Index());
566 info->set_index(
i, var->
index());
The superclass of all JavaScript values and objects.
static int Hash(Object *data, String *name)
int Lookup(Object *data, String *name, VariableMode *mode, InitializationFlag *init_flag, MaybeAssignedFlag *maybe_assigned_flag)
static const int kNotFound
uint32_t values_[kLength]
void Update(Handle< Object > data, Handle< String > name, VariableMode mode, InitializationFlag init_flag, MaybeAssignedFlag maybe_assigned_flag, int slot_index)
Iterator iterator() const
void Sort(int(*cmp)(const T *x, const T *y))
static Handle< ModuleInfo > Create(Isolate *isolate, Interface *interface, Scope *scope)
static Handle< ModuleInfo > Allocate(Isolate *isolate, int length)
void ShortPrint(FILE *out=stdout)
static MUST_USE_RESULT MaybeHandle< Object > DefineObjectProperty(Handle< JSObject > object, Handle< Object > key, Handle< Object > value, PropertyAttributes attr)
int ParameterIndex(String *name)
InitializationFlag ContextLocalInitFlag(int var)
static int ContextSlotIndex(Handle< ScopeInfo > scope_info, Handle< String > name, VariableMode *mode, InitializationFlag *init_flag, MaybeAssignedFlag *maybe_assigned_flag)
bool HasHeapAllocatedLocals()
VariableMode ContextLocalMode(int var)
bool LocalIsSynthetic(int var)
int FunctionContextSlotIndex(String *name, VariableMode *mode)
int ContextLocalNameEntriesIndex()
static Handle< ScopeInfo > Create(Scope *scope, Zone *zone)
static bool CopyContextLocalsToScopeObject(Handle< ScopeInfo > scope_info, Handle< Context > context, Handle< JSObject > scope_object)
int StackSlotIndex(String *name)
int StackLocalEntriesIndex()
int ParameterEntriesIndex()
String * ContextLocalName(int var)
String * LocalName(int var)
String * ParameterName(int var)
int ContextLocalInfoEntriesIndex()
int FunctionNameEntryIndex()
String * StackLocalName(int var)
static ScopeInfo * Empty(Isolate *isolate)
MaybeAssignedFlag ContextLocalMaybeAssignedFlag(int var)
int ContextLocalCount() const
int num_heap_slots() const
bool asm_function() const
int num_parameters() const
VariableDeclaration * function() const
void CollectStackAndContextLocals(ZoneList< Variable * > *stack_locals, ZoneList< Variable * > *context_locals)
bool is_function_scope() const
ScopeType scope_type() const
int num_stack_slots() const
StrictMode strict_mode() const
Variable * parameter(int index) const
int StackLocalCount() const
Variable * LookupLocal(const AstRawString *name)
static Smi * FromInt(int value)
static MUST_USE_RESULT MaybeHandle< String > InternalizeStringIfExists(Isolate *isolate, Handle< String > string)
bool Equals(String *other)
Handle< String > name() const
VariableMode mode() const
MaybeAssignedFlag maybe_assigned() const
InitializationFlag initialization_flag() const
bool IsStackLocal() const
bool IsContextSlot() const
static int CompareIndex(Variable *const *v, Variable *const *w)
Isolate * isolate() const
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 RETURN_ON_EXCEPTION_VALUE(isolate, call, value)
#define DCHECK(condition)
void PrintF(const char *format,...)
Debugger support for the V8 JavaScript engine.
MaybeAssignedFlag maybe_assigned_flag()
InitializationFlag initialization_flag()