46 const int stack_local_count = stack_locals.length();
47 const int context_local_count = context_locals.length();
53 FunctionVariableInfo function_name_info;
58 function_name_info = UNUSED;
60 function_name_info = CONTEXT;
63 function_name_info = STACK;
65 function_variable_mode = var->
mode();
67 function_name_info = NONE;
68 function_variable_mode =
VAR;
71 const bool has_function_name = function_name_info != NONE;
73 const int length = kVariablePartIndex
74 + parameter_count + stack_local_count + 2 * context_local_count
75 + (has_function_name ? 2 : 0);
80 int flags = TypeField::encode(scope->
type()) |
83 FunctionVariableField::encode(function_name_info) |
84 FunctionVariableMode::encode(function_variable_mode);
85 scope_info->SetFlags(flags);
86 scope_info->SetParameterCount(parameter_count);
87 scope_info->SetStackLocalCount(stack_local_count);
88 scope_info->SetContextLocalCount(context_local_count);
90 int index = kVariablePartIndex;
92 ASSERT(index == scope_info->ParameterEntriesIndex());
93 for (
int i = 0; i < parameter_count; ++i) {
100 ASSERT(index == scope_info->StackLocalEntriesIndex());
101 for (
int i = 0; i < stack_local_count; ++i) {
102 ASSERT(stack_locals[i]->index() == i);
103 scope_info->set(index++, *stack_locals[i]->name());
115 ASSERT(index == scope_info->ContextLocalNameEntriesIndex());
116 for (
int i = 0; i < context_local_count; ++i) {
117 scope_info->set(index++, *context_locals[i]->name());
121 ASSERT(index == scope_info->ContextLocalInfoEntriesIndex());
122 for (
int i = 0; i < context_local_count; ++i) {
124 uint32_t value = ContextLocalMode::encode(var->
mode()) |
130 ASSERT(index == scope_info->FunctionNameEntryIndex());
131 if (has_function_name) {
135 ASSERT(function_name_info != STACK ||
136 (var_index == scope_info->StackLocalCount() &&
137 var_index == scope_info->StackSlotCount() - 1));
138 ASSERT(function_name_info != CONTEXT ||
139 var_index == scope_info->ContextLength() - 1);
142 ASSERT(index == scope_info->length());
147 scope_info->ContextLength() == 0));
153 return reinterpret_cast<ScopeInfo*
>(
HEAP->empty_fixed_array());
159 return TypeField::decode(Flags());
164 return length() > 0 && CallsEvalField::decode(Flags());
174 return StackLocalCount() + ContextLocalCount();
180 bool function_name_stack_slot =
181 FunctionVariableField::decode(Flags()) == STACK;
182 return StackLocalCount() + (function_name_stack_slot ? 1 : 0);
190 int context_locals = ContextLocalCount();
191 bool function_name_context_slot =
192 FunctionVariableField::decode(Flags()) == CONTEXT;
193 bool has_context = context_locals > 0 ||
194 function_name_context_slot ||
200 (function_name_context_slot ? 1 : 0);
209 return NONE != FunctionVariableField::decode(Flags());
218 return ContextLocalCount() > 0;
237 ASSERT(0 <= var && var < ParameterCount());
238 int info_index = ParameterEntriesIndex() + var;
245 ASSERT(StackLocalEntriesIndex() + StackLocalCount() ==
246 ContextLocalNameEntriesIndex());
247 int info_index = StackLocalEntriesIndex() + var;
253 ASSERT(0 <= var && var < StackLocalCount());
254 int info_index = StackLocalEntriesIndex() + var;
260 ASSERT(0 <= var && var < ContextLocalCount());
261 int info_index = ContextLocalNameEntriesIndex() + var;
267 ASSERT(0 <= var && var < ContextLocalCount());
268 int info_index = ContextLocalInfoEntriesIndex() + var;
270 return ContextLocalMode::decode(value);
275 ASSERT(0 <= var && var < ContextLocalCount());
276 int info_index = ContextLocalInfoEntriesIndex() + var;
278 return ContextLocalInitFlag::decode(value);
285 int start = StackLocalEntriesIndex();
286 int end = StackLocalEntriesIndex() + StackLocalCount();
287 for (
int i = start; i < end; ++i) {
288 if (name ==
get(i)) {
305 int result = context_slot_cache->
Lookup(
this, name, mode, init_flag);
311 int start = ContextLocalNameEntriesIndex();
312 int end = ContextLocalNameEntriesIndex() + ContextLocalCount();
313 for (
int i = start; i < end; ++i) {
314 if (name ==
get(i)) {
319 context_slot_cache->
Update(
this, name, *mode, *init_flag, result);
338 int start = ParameterEntriesIndex();
339 int end = ParameterEntriesIndex() + ParameterCount();
340 for (
int i = end - 1; i >= start; --i) {
341 if (name ==
get(i)) {
354 if (FunctionVariableField::decode(Flags()) == CONTEXT &&
356 *mode = FunctionVariableMode::decode(Flags());
364 int ScopeInfo::ParameterEntriesIndex() {
366 return kVariablePartIndex;
370 int ScopeInfo::StackLocalEntriesIndex() {
371 return ParameterEntriesIndex() + ParameterCount();
375 int ScopeInfo::ContextLocalNameEntriesIndex() {
376 return StackLocalEntriesIndex() + StackLocalCount();
380 int ScopeInfo::ContextLocalInfoEntriesIndex() {
381 return ContextLocalNameEntriesIndex() + ContextLocalCount();
385 int ScopeInfo::FunctionNameEntryIndex() {
386 return ContextLocalInfoEntriesIndex() + ContextLocalCount();
390 int ContextSlotCache::Hash(
Object* data, String* name) {
392 uintptr_t addr_hash =
393 static_cast<uint32_t
>(
reinterpret_cast<uintptr_t
>(data)) >> 2;
394 return static_cast<int>((addr_hash ^ name->Hash()) % kLength);
402 int index = Hash(data, name);
403 Key& key = keys_[index];
404 if ((key.data == data) && key.name->Equals(name)) {
405 Value result(values_[index]);
406 if (mode !=
NULL) *mode = result.mode();
407 if (init_flag !=
NULL) *init_flag = result.initialization_flag();
421 if (
HEAP->LookupSymbolIfExists(name, &symbol)) {
422 int index = Hash(data, symbol);
423 Key& key = keys_[index];
427 values_[index] = Value(mode, init_flag, slot_index -
kNotFound).raw();
429 ValidateEntry(data, name, mode, init_flag, slot_index);
436 for (
int index = 0; index < kLength; index++) keys_[index].data =
NULL;
442 void ContextSlotCache::ValidateEntry(
Object* data,
448 if (
HEAP->LookupSymbolIfExists(name, &symbol)) {
449 int index = Hash(data, name);
450 Key& key = keys_[index];
452 ASSERT(key.name->Equals(name));
453 Value result(values_[index]);
454 ASSERT(result.mode() == mode);
455 ASSERT(result.initialization_flag() == init_flag);
461 static void PrintList(
const char* list_name,
462 int nof_internal_slots,
465 ScopeInfo* scope_info) {
467 PrintF(
"\n // %s\n", list_name);
468 if (nof_internal_slots > 0) {
469 PrintF(
" %2d - %2d [internal slots]\n", 0 , nof_internal_slots - 1);
471 for (
int i = nof_internal_slots; start < end; ++i, ++start) {
485 PrintF(
"/* no function name */");
489 PrintList(
"parameters", 0,
490 ParameterEntriesIndex(),
491 ParameterEntriesIndex() + ParameterCount(),
493 PrintList(
"stack slots", 0,
494 StackLocalEntriesIndex(),
495 StackLocalEntriesIndex() + StackLocalCount(),
497 PrintList(
"context slots",
499 ContextLocalNameEntriesIndex(),
500 ContextLocalNameEntriesIndex() + ContextLocalCount(),
int StackSlotIndex(String *name)
ContextSlotCache * context_slot_cache()
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)
static const int kNotFound
InitializationFlag initialization_flag() const
#define ASSERT(condition)
v8::Handle< v8::Value > Print(const v8::Arguments &args)
InitializationFlag ContextLocalInitFlag(int var)
Variable * parameter(int index) const
Handle< String > name() const
Handle< String > name() const
static Smi * cast(Object *object)
static Handle< ScopeInfo > Create(Scope *scope, Zone *zone)
VariableProxy * proxy() const
VariableMode mode() const
int num_stack_slots() const
static int CompareIndex(Variable *const *v, Variable *const *w)
void Update(Object *data, String *name, VariableMode mode, InitializationFlag init_flag, int slot_index)
bool IsContextSlot() const
bool HasHeapAllocatedLocals()
int num_parameters() const
static ScopeInfo * Empty()
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)
String * LocalName(int var)
String * ContextLocalName(int var)
int ContextLocalCount() const
String * ParameterName(int var)
activate correct semantics for inheriting readonliness enable harmony semantics for typeof enable harmony enable harmony proxies enable all harmony harmony_scoping harmony_proxies harmony_scoping tracks arrays with only smi values automatically unbox arrays of doubles use crankshaft use hydrogen range analysis use hydrogen global value numbering use function inlining maximum number of AST nodes considered for a single inlining loop invariant code motion print statistics for hydrogen trace generated IR for specified phases trace register allocator trace range analysis trace representation types environment for every instruction put a break point before deoptimizing polymorphic inlining perform array bounds checks elimination use dead code elimination trace on stack replacement optimize closures cache optimized code for closures functions with arguments object loop weight for representation inference allow uint32 values on optimize frames if they are used only in safe operations track parallel recompilation enable all profiler experiments number of stack frames inspected by the profiler call recompile stub directly when self optimizing trigger profiler ticks based on counting instead of timing weight back edges by jump distance for interrupt triggering percentage of ICs that must have type info to allow optimization watch_ic_patching retry_self_opt interrupt_at_exit 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 SAHF instruction if enable use of VFP3 instructions if available this implies enabling ARMv7 and VFP2 enable use of VFP2 instructions if available 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 MIPS FPU instructions if NULL
LanguageMode language_mode() const
bool is_function_scope() const
activate correct semantics for inheriting readonliness enable harmony semantics for typeof enable harmony enable harmony proxies enable all harmony harmony_scoping harmony_proxies harmony_scoping tracks arrays with only smi values automatically unbox arrays of doubles use crankshaft use hydrogen range analysis use hydrogen global value numbering use function inlining maximum number of AST nodes considered for a single inlining loop invariant code motion print statistics for hydrogen trace generated IR for specified phases trace register allocator trace range analysis trace representation types environment for every instruction put a break point before deoptimizing polymorphic inlining perform array bounds checks elimination use dead code elimination trace on stack replacement optimize closures cache optimized code for closures functions with arguments object loop weight for representation inference allow uint32 values on optimize frames if they are used only in safe operations track parallel recompilation enable all profiler experiments number of stack frames inspected by the profiler call recompile stub directly when self optimizing trigger profiler ticks based on counting instead of timing weight back edges by jump distance for interrupt triggering percentage of ICs that must have type info to allow optimization watch_ic_patching retry_self_opt interrupt_at_exit 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 SAHF instruction if enable use of VFP3 instructions if available this implies enabling ARMv7 and VFP2 enable use of VFP2 instructions if available 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 MIPS FPU instructions if expose natives in global object expose gc extension number of stack frames to capture disable builtin natives files print a stack trace if an assertion failure occurs use random jit cookie to mask large constants trace lazy optimization use adaptive optimizations prepare for turning on always opt minimum length for automatic enable preparsing maximum number of optimization attempts before giving up cache prototype transitions automatically set the debug break flag when debugger commands are in the queue always cause a debug break before aborting 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 more details following each garbage collection print amount of external allocated memory after each time it is adjusted flush code that we expect not to use again before full gc do incremental marking steps track object counts and memory usage use caching Perform compaction on every full GC Never perform compaction on full GC testing only Compact code space on full incremental collections Default seed for initializing random allows verbose printing trace parsing and preparsing Check icache flushes in ARM and MIPS simulator Stack alingment in bytes in print stack trace when throwing exceptions randomize hashes to avoid predictable hash Fixed seed to use to hash property activate a timer that switches between V8 threads testing_bool_flag float flag Seed used for threading test randomness A filename with extra code to be included in the Print usage including flags
LanguageMode language_mode()