44 const int stack_local_count = stack_locals.length();
45 const int context_local_count = context_locals.length();
51 FunctionVariableInfo function_name_info;
56 function_name_info = UNUSED;
58 function_name_info = CONTEXT;
61 function_name_info = STACK;
63 function_variable_mode = var->
mode();
65 function_name_info = NONE;
66 function_variable_mode =
VAR;
69 const bool has_function_name = function_name_info != NONE;
71 const int length = kVariablePartIndex
72 + parameter_count + stack_local_count + 2 * context_local_count
73 + (has_function_name ? 2 : 0);
82 FunctionVariableField::encode(function_name_info) |
83 FunctionVariableMode::encode(function_variable_mode);
84 scope_info->SetFlags(flags);
85 scope_info->SetParameterCount(parameter_count);
86 scope_info->SetStackLocalCount(stack_local_count);
87 scope_info->SetContextLocalCount(context_local_count);
89 int index = kVariablePartIndex;
91 ASSERT(index == scope_info->ParameterEntriesIndex());
92 for (
int i = 0; i < parameter_count; ++i) {
99 ASSERT(index == scope_info->StackLocalEntriesIndex());
100 for (
int i = 0; i < stack_local_count; ++i) {
101 ASSERT(stack_locals[i]->index() == i);
102 scope_info->set(index++, *stack_locals[i]->
name());
114 ASSERT(index == scope_info->ContextLocalNameEntriesIndex());
115 for (
int i = 0; i < context_local_count; ++i) {
116 scope_info->set(index++, *context_locals[i]->
name());
120 ASSERT(index == scope_info->ContextLocalInfoEntriesIndex());
121 for (
int i = 0; i < context_local_count; ++i) {
123 uint32_t value = ContextLocalMode::encode(var->
mode()) |
129 ASSERT(index == scope_info->FunctionNameEntryIndex());
130 if (has_function_name) {
131 int var_index = scope->
function()->proxy()->var()->index();
132 scope_info->set(index++, *scope->
function()->proxy()->name());
134 ASSERT(function_name_info != STACK ||
135 (var_index == scope_info->StackLocalCount() &&
136 var_index == scope_info->StackSlotCount() - 1));
137 ASSERT(function_name_info != CONTEXT ||
138 var_index == scope_info->ContextLength() - 1);
141 ASSERT(index == scope_info->length());
146 scope_info->ContextLength() == 0));
152 return reinterpret_cast<ScopeInfo*
>(isolate->
heap()->empty_fixed_array());
158 return ScopeTypeField::decode(Flags());
163 return length() > 0 && CallsEvalField::decode(Flags());
168 return length() > 0 ? StrictModeField::decode(Flags()) :
SLOPPY;
173 return StackLocalCount() + ContextLocalCount();
179 bool function_name_stack_slot =
180 FunctionVariableField::decode(Flags()) == STACK;
181 return StackLocalCount() + (function_name_stack_slot ? 1 : 0);
189 int context_locals = ContextLocalCount();
190 bool function_name_context_slot =
191 FunctionVariableField::decode(Flags()) == CONTEXT;
192 bool has_context = context_locals > 0 ||
193 function_name_context_slot ||
199 (function_name_context_slot ? 1 : 0);
208 return NONE != FunctionVariableField::decode(Flags());
217 return ContextLocalCount() > 0;
236 ASSERT(0 <= var && var < ParameterCount());
237 int info_index = ParameterEntriesIndex() + var;
244 ASSERT(StackLocalEntriesIndex() + StackLocalCount() ==
245 ContextLocalNameEntriesIndex());
246 int info_index = StackLocalEntriesIndex() + var;
252 ASSERT(0 <= var && var < StackLocalCount());
253 int info_index = StackLocalEntriesIndex() + var;
259 ASSERT(0 <= var && var < ContextLocalCount());
260 int info_index = ContextLocalNameEntriesIndex() + var;
266 ASSERT(0 <= var && var < ContextLocalCount());
267 int info_index = ContextLocalInfoEntriesIndex() + var;
269 return ContextLocalMode::decode(value);
274 ASSERT(0 <= var && var < ContextLocalCount());
275 int info_index = ContextLocalInfoEntriesIndex() + var;
277 return ContextLocalInitFlag::decode(value);
282 ASSERT(name->IsInternalizedString());
284 int start = StackLocalEntriesIndex();
285 int end = StackLocalEntriesIndex() + StackLocalCount();
286 for (
int i = start; i < end; ++i) {
287 if (name ==
get(i)) {
299 ASSERT(name->IsInternalizedString());
304 int result = context_slot_cache->
Lookup(
this, name, mode, init_flag);
310 int start = ContextLocalNameEntriesIndex();
311 int end = ContextLocalNameEntriesIndex() + ContextLocalCount();
312 for (
int i = start; i < end; ++i) {
313 if (name ==
get(i)) {
318 context_slot_cache->
Update(
this, name, *mode, *init_flag, result);
331 ASSERT(name->IsInternalizedString());
338 int start = ParameterEntriesIndex();
339 int end = ParameterEntriesIndex() + ParameterCount();
340 for (
int i = end - 1; i >= start; --i) {
341 if (name ==
get(i)) {
351 ASSERT(name->IsInternalizedString());
354 if (FunctionVariableField::decode(Flags()) == CONTEXT &&
356 *mode = FunctionVariableMode::decode(Flags());
367 Isolate* isolate = scope_info->GetIsolate();
368 int local_count = scope_info->ContextLocalCount();
369 if (local_count == 0)
return true;
371 int start = scope_info->ContextLocalNameEntriesIndex();
372 int end = start + local_count;
373 for (
int i = start; i < end; ++i) {
388 int ScopeInfo::ParameterEntriesIndex() {
390 return kVariablePartIndex;
394 int ScopeInfo::StackLocalEntriesIndex() {
395 return ParameterEntriesIndex() + ParameterCount();
399 int ScopeInfo::ContextLocalNameEntriesIndex() {
400 return StackLocalEntriesIndex() + StackLocalCount();
404 int ScopeInfo::ContextLocalInfoEntriesIndex() {
405 return ContextLocalNameEntriesIndex() + ContextLocalCount();
409 int ScopeInfo::FunctionNameEntryIndex() {
410 return ContextLocalInfoEntriesIndex() + ContextLocalCount();
414 int ContextSlotCache::Hash(
Object* data, String*
name) {
416 uintptr_t addr_hash =
417 static_cast<uint32_t
>(
reinterpret_cast<uintptr_t
>(data)) >> 2;
418 return static_cast<int>((addr_hash ^ name->Hash()) % kLength);
426 int index = Hash(data, name);
427 Key& key = keys_[index];
428 if ((key.data == data) && key.name->Equals(name)) {
429 Value result(values_[index]);
430 if (mode !=
NULL) *mode = result.mode();
431 if (init_flag !=
NULL) *init_flag = result.initialization_flag();
443 String* internalized_name;
446 name, &internalized_name)) {
447 int index = Hash(data, internalized_name);
448 Key& key = keys_[index];
450 key.name = internalized_name;
452 values_[index] = Value(mode, init_flag, slot_index -
kNotFound).raw();
454 ValidateEntry(data, name, mode, init_flag, slot_index);
461 for (
int index = 0; index < kLength; index++) keys_[index].data =
NULL;
467 void ContextSlotCache::ValidateEntry(
Object* data,
472 String* internalized_name;
474 name, &internalized_name)) {
475 int index = Hash(data, name);
476 Key& key = keys_[index];
478 ASSERT(key.name->Equals(name));
479 Value result(values_[index]);
481 ASSERT(result.initialization_flag() == init_flag);
487 static void PrintList(
const char* list_name,
488 int nof_internal_slots,
491 ScopeInfo* scope_info) {
493 PrintF(
"\n // %s\n", list_name);
494 if (nof_internal_slots > 0) {
495 PrintF(
" %2d - %2d [internal slots]\n", 0 , nof_internal_slots - 1);
497 for (
int i = nof_internal_slots; start < end; ++i, ++start) {
511 PrintF(
"/* no function name */");
515 PrintList(
"parameters", 0,
516 ParameterEntriesIndex(),
517 ParameterEntriesIndex() + ParameterCount(),
519 PrintList(
"stack slots", 0,
520 StackLocalEntriesIndex(),
521 StackLocalEntriesIndex() + StackLocalCount(),
523 PrintList(
"context slots",
525 ContextLocalNameEntriesIndex(),
526 ContextLocalNameEntriesIndex() + ContextLocalCount(),
540 info->set_host_index(interface->
Index());
543 !it.
done(); it.Advance(), ++i) {
545 info->set_name(i, *it.name());
546 info->set_mode(i, var->
mode());
549 ASSERT(it.interface()->IsFrozen());
550 ASSERT(it.interface()->Index() >= 0);
551 info->set_index(i, it.interface()->Index());
554 info->set_index(i, var->
index());
557 ASSERT(i == info->length());
int StackSlotIndex(String *name)
ContextSlotCache * context_slot_cache()
enable upcoming ES6 features enable harmony block scoping enable harmony enable harmony proxies enable harmony generators enable harmony numeric enable harmony string enable harmony math functions harmony_scoping harmony_symbols harmony_collections harmony_iteration harmony_strings harmony_scoping harmony_maths tracks arrays with only smi values Optimize object Array DOM strings and string pretenure call new trace pretenuring decisions of HAllocate instructions track fields with only smi values track fields with heap values track_fields track_fields Enables optimizations which favor memory size over execution speed use string slices optimization filter maximum number of GVN fix point iterations use function inlining use allocation folding eliminate write barriers targeting allocations in optimized code maximum source size in bytes considered for a single inlining maximum cumulative number of AST nodes considered for inlining crankshaft harvests type feedback from stub cache trace check elimination phase hydrogen tracing filter NULL
VariableDeclaration * function() const
void PrintF(const char *format,...)
static String * cast(Object *obj)
static Smi * FromInt(int value)
void CollectStackAndContextLocals(ZoneList< Variable * > *stack_locals, ZoneList< Variable * > *context_locals)
int ContextSlotIndex(String *name, VariableMode *mode, InitializationFlag *init_flag)
int ParameterIndex(String *name)
int Lookup(Object *data, String *name, VariableMode *mode, InitializationFlag *init_flag)
kSerializedDataOffset Object
static ScopeInfo * Empty(Isolate *isolate)
static const int kNotFound
InitializationFlag initialization_flag() const
#define ASSERT(condition)
InitializationFlag ContextLocalInitFlag(int var)
enable upcoming ES6 features enable harmony block scoping enable harmony enable harmony proxies enable harmony generators enable harmony numeric enable harmony string enable harmony math functions harmony_scoping harmony_symbols harmony_collections harmony_iteration harmony_strings harmony_scoping harmony_maths tracks arrays with only smi values Optimize object Array DOM strings and string pretenure call new trace pretenuring decisions of HAllocate instructions track fields with only smi values track fields with heap values track_fields track_fields Enables optimizations which favor memory size over execution speed use string slices optimization filter maximum number of GVN fix point iterations use function inlining use allocation folding eliminate write barriers targeting allocations in optimized code maximum source size in bytes considered for a single inlining maximum cumulative number of AST nodes considered for inlining crankshaft harvests type feedback from stub cache trace check elimination phase hydrogen tracing filter trace hydrogen to given file name trace inlining decisions trace store elimination trace all use positions trace global value numbering trace hydrogen escape analysis trace the tracking of allocation sites trace map generalization environment for every instruction deoptimize every n garbage collections put a break point before deoptimizing deoptimize uncommon cases use on stack replacement trace array bounds check elimination perform array index dehoisting use load elimination use store elimination use constant folding eliminate unreachable code number of stress runs when picking a function to watch for shared function not JSFunction itself flushes the cache of optimized code for closures on every GC functions with arguments object maximum number of escape analysis fix point iterations allow uint32 values on optimize frames if they are used only in safe operations track concurrent recompilation artificial compilation delay in ms concurrent on stack replacement do not emit check maps for constant values that have a leaf deoptimize the optimized code if the layout of the maps changes number of stack frames inspected by the profiler percentage of ICs that must have type info to allow optimization extra verbose compilation tracing generate extra emit comments in code disassembly enable use of SSE3 instructions if available enable use of CMOV instruction if available enable use of VFP3 instructions if available enable use of NEON instructions if enable use of SDIV and UDIV 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 expose natives in global object expose freeBuffer extension expose gc extension under the specified name expose externalize string extension number of stack frames to capture disable builtin natives files print name of functions for which code is generated use random jit cookie to mask large constants trace lazy optimization use adaptive optimizations always try to OSR functions trace optimize function deoptimization minimum length for automatic enable preparsing maximum number of optimization attempts before giving up cache prototype transitions trace debugging JSON request response trace out of bounds accesses to external arrays trace_js_array_abuse automatically set the debug break flag when debugger commands are in the queue abort by crashing maximum length of function source code printed in a stack trace max size of the new max size of the old max size of executable always perform global GCs print one trace line following each garbage collection do not print trace line after scavenger collection print statistics of the maximum memory committed for the heap in only print modified registers Don t break for ASM_UNIMPLEMENTED_BREAK macros print stack trace when an illegal exception is thrown randomize hashes to avoid predictable hash Fixed seed to use to hash property Print the time it takes to deserialize the snapshot testing_bool_flag testing_int_flag string flag tmp file in which to serialize heap Print the time it takes to lazily compile hydrogen code stubs concurrent_recompilation concurrent_sweeping Print usage including on console Map counters to a file Enable debugger compile events enable GDBJIT interface(disables compacting GC)") DEFINE_bool(gdbjit_full
Variable * parameter(int index) const
StrictMode strict_mode() const
Handle< String > name() const
#define RETURN_IF_EMPTY_HANDLE_VALUE(isolate, call, value)
static Smi * cast(Object *object)
static Handle< ScopeInfo > Create(Scope *scope, Zone *zone)
Iterator iterator() const
static bool CopyContextLocalsToScopeObject(Handle< ScopeInfo > scope_info, Handle< Context > context, Handle< JSObject > scope_object)
enable upcoming ES6 features enable harmony block scoping enable harmony enable harmony proxies enable harmony generators enable harmony numeric enable harmony string enable harmony math functions harmony_scoping harmony_symbols harmony_collections harmony_iteration harmony_strings harmony_scoping harmony_maths tracks arrays with only smi values Optimize object Array DOM strings and string pretenure call new trace pretenuring decisions of HAllocate instructions track fields with only smi values track fields with heap values track_fields track_fields Enables optimizations which favor memory size over execution speed use string slices optimization filter maximum number of GVN fix point iterations use function inlining use allocation folding eliminate write barriers targeting allocations in optimized code maximum source size in bytes considered for a single inlining maximum cumulative number of AST nodes considered for inlining crankshaft harvests type feedback from stub cache trace check elimination phase hydrogen tracing filter trace hydrogen to given file name trace inlining decisions trace store elimination trace all use positions trace global value numbering trace hydrogen escape analysis trace the tracking of allocation sites trace map generalization environment for every instruction deoptimize every n garbage collections put a break point before deoptimizing deoptimize uncommon cases use on stack replacement trace array bounds check elimination perform array index dehoisting use load elimination use store elimination use constant folding eliminate unreachable code number of stress runs when picking a function to watch for shared function not JSFunction itself flushes the cache of optimized code for closures on every GC functions with arguments object maximum number of escape analysis fix point iterations allow uint32 values on optimize frames if they are used only in safe operations track concurrent recompilation artificial compilation delay in ms concurrent on stack replacement do not emit check maps for constant values that have a leaf deoptimize the optimized code if the layout of the maps changes number of stack frames inspected by the profiler percentage of ICs that must have type info to allow optimization extra verbose compilation tracing generate extra emit comments in code disassembly enable use of SSE3 instructions if available enable use of CMOV instruction if available enable use of VFP3 instructions if available enable use of NEON instructions if enable use of SDIV and UDIV 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_string(expose_natives_as
VariableMode mode() const
enable upcoming ES6 features enable harmony block scoping enable harmony enable harmony proxies enable harmony generators enable harmony numeric enable harmony string enable harmony math functions harmony_scoping harmony_symbols harmony_collections harmony_iteration harmony_strings harmony_scoping harmony_maths tracks arrays with only smi values Optimize object Array DOM strings and string pretenure call new trace pretenuring decisions of HAllocate instructions track fields with only smi values track fields with heap values track_fields track_fields Enables optimizations which favor memory size over execution speed use string slices optimization filter maximum number of GVN fix point iterations use function inlining use allocation folding eliminate write barriers targeting allocations in optimized code maximum source size in bytes considered for a single inlining maximum cumulative number of AST nodes considered for inlining crankshaft harvests type feedback from stub cache trace check elimination phase hydrogen tracing filter trace hydrogen to given file name trace inlining decisions trace store elimination trace all use positions trace global value numbering trace hydrogen escape analysis trace the tracking of allocation sites trace map generalization environment for every instruction deoptimize every n garbage collections put a break point before deoptimizing deoptimize uncommon cases use on stack replacement trace array bounds check elimination perform array index dehoisting use load elimination use store elimination use constant folding eliminate unreachable code number of stress runs when picking a function to watch for shared function not JSFunction itself flushes the cache of optimized code for closures on every GC functions with arguments object maximum number of escape analysis fix point iterations allow uint32 values on optimize frames if they are used only in safe operations track concurrent recompilation artificial compilation delay in ms concurrent on stack replacement do not emit check maps for constant values that have a leaf deoptimize the optimized code if the layout of the maps changes number of stack frames inspected by the profiler percentage of ICs that must have type info to allow optimization extra verbose compilation tracing generate extra emit comments in code disassembly enable use of SSE3 instructions if available enable use of CMOV instruction if available enable use of VFP3 instructions if available enable use of NEON instructions if enable use of SDIV and UDIV 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 expose natives in global object expose freeBuffer extension expose gc extension under the specified name expose externalize string extension number of stack frames to capture disable builtin natives files print name of functions for which code is generated use random jit cookie to mask large constants trace lazy optimization use adaptive optimizations always try to OSR functions trace optimize function deoptimization minimum length for automatic enable preparsing maximum number of optimization attempts before giving up cache prototype transitions trace debugging JSON request response trace out of bounds accesses to external arrays trace_js_array_abuse automatically set the debug break flag when debugger commands are in the queue abort by crashing maximum length of function source code printed in a stack trace max size of the new max size of the old max size of executable always perform global GCs print one trace line following each garbage collection do not print trace line after scavenger collection print statistics of the maximum memory committed for the heap in only print modified registers Don t break for ASM_UNIMPLEMENTED_BREAK macros print stack trace when an illegal exception is thrown randomize hashes to avoid predictable hash Fixed seed to use to hash property Print the time it takes to deserialize the snapshot testing_bool_flag testing_int_flag string flag tmp file in which to serialize heap Print the time it takes to lazily compile hydrogen code stubs concurrent_recompilation concurrent_sweeping Print usage including flags
int num_stack_slots() const
ScopeType scope_type() const
static int CompareIndex(Variable *const *v, Variable *const *w)
static Handle< ModuleInfo > Create(Isolate *isolate, Interface *interface, Scope *scope)
void Update(Object *data, String *name, VariableMode mode, InitializationFlag init_flag, int slot_index)
bool IsContextSlot() const
bool HasHeapAllocatedLocals()
int num_parameters() const
Variable * LocalLookup(Handle< String > name)
int FunctionContextSlotIndex(String *name, VariableMode *mode)
bool IsStackLocal() const
int StackLocalCount() const
int num_heap_slots() const
String * StackLocalName(int var)
VariableMode ContextLocalMode(int var)
enable upcoming ES6 features enable harmony block scoping enable harmony enable harmony proxies enable harmony generators enable harmony numeric enable harmony string enable harmony math functions harmony_scoping harmony_symbols harmony_collections harmony_iteration harmony_strings harmony_scoping harmony_maths tracks arrays with only smi values Optimize object Array DOM strings and string pretenure call new trace pretenuring decisions of HAllocate instructions track fields with only smi values track fields with heap values track_fields track_fields Enables optimizations which favor memory size over execution speed use string slices optimization filter maximum number of GVN fix point iterations use function inlining use allocation folding eliminate write barriers targeting allocations in optimized code maximum source size in bytes considered for a single inlining maximum cumulative number of AST nodes considered for inlining crankshaft harvests type feedback from stub cache trace check elimination phase hydrogen tracing filter trace hydrogen to given file name trace inlining decisions trace store elimination trace all use positions trace global value numbering trace hydrogen escape analysis trace the tracking of allocation sites trace map generalization environment for every instruction deoptimize every n garbage collections put a break point before deoptimizing deoptimize uncommon cases use on stack replacement trace array bounds check elimination perform array index dehoisting use load elimination use store elimination use constant folding eliminate unreachable code number of stress runs when picking a function to watch for shared function info
String * LocalName(int var)
void ShortPrint(FILE *out=stdout)
String * ContextLocalName(int var)
int ContextLocalCount() const
String * ParameterName(int var)
void Print(const v8::FunctionCallbackInfo< v8::Value > &args)
static Handle< Object > SetObjectProperty(Isolate *isolate, Handle< Object > object, Handle< Object > key, Handle< Object > value, PropertyAttributes attr, StrictMode strict_mode)
bool is_function_scope() const
enable upcoming ES6 features enable harmony block scoping enable harmony enable harmony proxies enable harmony generators enable harmony numeric enable harmony string enable harmony math functions harmony_scoping harmony_symbols harmony_collections harmony_iteration harmony_strings harmony_scoping harmony_maths tracks arrays with only smi values Optimize object Array DOM strings and string pretenure call new trace pretenuring decisions of HAllocate instructions track fields with only smi values track fields with heap values track_fields track_fields Enables optimizations which favor memory size over execution speed use string slices optimization filter maximum number of GVN fix point iterations use function inlining use allocation folding eliminate write barriers targeting allocations in optimized code maximum source size in bytes considered for a single inlining maximum cumulative number of AST nodes considered for inlining crankshaft harvests type feedback from stub cache trace check elimination phase hydrogen tracing filter trace hydrogen to given file name trace inlining decisions trace store elimination trace all use positions trace global value numbering trace hydrogen escape analysis trace the tracking of allocation sites trace map generalization environment for every instruction deoptimize every n garbage collections put a break point before deoptimizing deoptimize uncommon cases use on stack replacement trace array bounds check elimination perform array index dehoisting use load elimination use store elimination use constant folding eliminate unreachable code number of stress runs when picking a function to watch for shared function not JSFunction itself flushes the cache of optimized code for closures on every GC functions with arguments object maximum number of escape analysis fix point iterations allow uint32 values on optimize frames if they are used only in safe operations track concurrent recompilation artificial compilation delay in ms concurrent on stack replacement do not emit check maps for constant values that have a leaf deoptimize the optimized code if the layout of the maps changes number of stack frames inspected by the profiler percentage of ICs that must have type info to allow optimization extra verbose compilation tracing generate extra emit comments in code disassembly enable use of SSE3 instructions if available enable use of CMOV instruction if available enable use of VFP3 instructions if available enable use of NEON instructions if enable use of SDIV and UDIV 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 expose natives in global object expose freeBuffer extension expose gc extension under the specified name expose externalize string extension number of stack frames to capture disable builtin natives files print name of functions for which code is generated use random jit cookie to mask large constants trace lazy optimization use adaptive optimizations always try to OSR functions trace optimize function deoptimization minimum length for automatic enable preparsing maximum number of optimization attempts before giving up cache prototype transitions trace debugging JSON request response trace out of bounds accesses to external arrays trace_js_array_abuse automatically set the debug break flag when debugger commands are in the queue abort by crashing maximum length of function source code printed in a stack trace max size of the new max size of the old max size of executable always perform global GCs print one trace line following each garbage collection do not print trace line after scavenger collection print statistics of the maximum memory committed for the heap in name
bool InternalizeStringIfExists(String *str, String **result)