41 static const int kScriptGenerations = 5;
42 static const int kEvalGlobalGenerations = 2;
43 static const int kEvalContextualGenerations = 2;
44 static const int kRegExpGenerations = 2;
47 static const int kInitialCacheSize = 64;
50 CompilationCache::CompilationCache(Isolate* isolate)
52 script_(isolate, kScriptGenerations),
53 eval_global_(isolate, kEvalGlobalGenerations),
54 eval_contextual_(isolate, kEvalContextualGenerations),
55 reg_exp_(isolate, kRegExpGenerations),
57 CompilationSubCache* subcaches[kSubCacheCount] =
58 {&script_, &eval_global_, &eval_contextual_, ®_exp_};
59 for (
int i = 0; i < kSubCacheCount; ++i) {
60 subcaches_[i] = subcaches[i];
65 CompilationCache::~CompilationCache() {}
68 static Handle<CompilationCacheTable> AllocateTable(Isolate* isolate,
int size) {
71 CompilationCacheTable);
76 ASSERT(generation < generations_);
78 if (tables_[generation]->IsUndefined()) {
79 result = AllocateTable(
isolate(), kInitialCacheSize);
92 for (
int i = generations_ - 1; i > 0; i--) {
93 tables_[i] = tables_[i - 1];
103 for (
int i = 0; i < generations_; i++) {
104 if (tables_[i] != undefined) {
112 v->VisitPointers(&tables_[0], &tables_[generations_]);
127 table->Remove(*function_info);
136 script_histogram_(
NULL),
137 script_histogram_initialized_(
false) { }
143 bool CompilationCacheScript::HasOrigin(
148 bool is_shared_cross_origin) {
153 if (name.is_null()) {
154 return script->name()->IsUndefined();
157 if (line_offset != script->line_offset()->value())
return false;
158 if (column_offset != script->column_offset()->value())
return false;
160 if (!name->
IsString() || !script->name()->IsString())
return false;
162 if (is_shared_cross_origin != script->is_shared_cross_origin())
return false;
177 bool is_shared_cross_origin,
185 for (generation = 0; generation <
generations(); generation++) {
188 if (probe->IsSharedFunctionInfo()) {
193 if (HasOrigin(function_info,
197 is_shared_cross_origin)) {
198 result = *function_info;
205 if (!script_histogram_initialized_) {
210 kScriptGenerations + 1);
211 script_histogram_initialized_ =
true;
214 if (script_histogram_ !=
NULL) {
222 if (result !=
NULL) {
229 is_shared_cross_origin));
232 if (generation != 0)
Put(source, context, shared);
242 MaybeObject* CompilationCacheScript::TryTablePut(
247 return table->Put(*source, *context, *function_info);
256 TryTablePut(source, context, function_info),
257 CompilationCacheTable);
273 int scope_position) {
280 for (generation = 0; generation <
generations(); generation++) {
282 result = table->LookupEval(
283 *source, *context, strict_mode, scope_position);
284 if (result->IsSharedFunctionInfo()) {
289 if (result->IsSharedFunctionInfo()) {
292 if (generation != 0) {
293 Put(source, context, function_info, scope_position);
296 return function_info;
304 MaybeObject* CompilationCacheEval::TryTablePut(
308 int scope_position) {
310 return table->PutEval(*source, *context, *function_info, scope_position);
318 int scope_position) {
321 source, context, function_info, scope_position),
322 CompilationCacheTable);
329 int scope_position) {
331 SetFirstTable(TablePut(source, context, function_info, scope_position));
343 for (generation = 0; generation <
generations(); generation++) {
345 result = table->LookupRegExp(*source, flags);
346 if (result->IsFixedArray()) {
351 if (result->IsFixedArray()) {
353 if (generation != 0) {
354 Put(source, flags, data);
365 MaybeObject* CompilationCacheRegExp::TryTablePut(
370 return table->PutRegExp(*source, flags, *data);
376 JSRegExp::Flags flags,
379 TryTablePut(source, flags, data),
380 CompilationCacheTable);
393 if (!IsEnabled())
return;
395 eval_global_.
Remove(function_info);
396 eval_contextual_.
Remove(function_info);
397 script_.
Remove(function_info);
406 bool is_shared_cross_origin,
412 return script_.
Lookup(source,
416 is_shared_cross_origin,
425 int scope_position) {
431 if (context->IsNativeContext()) {
432 result = eval_global_.
Lookup(
433 source, context, strict_mode, scope_position);
435 ASSERT(scope_position != RelocInfo::kNoPosition);
436 result = eval_contextual_.
Lookup(
437 source, context, strict_mode, scope_position);
449 return reg_exp_.
Lookup(source, flags);
456 if (!IsEnabled())
return;
458 script_.
Put(source, context, function_info);
465 int scope_position) {
466 if (!IsEnabled())
return;
469 if (context->IsNativeContext()) {
470 eval_global_.
Put(source, context, function_info, scope_position);
472 ASSERT(scope_position != RelocInfo::kNoPosition);
473 eval_contextual_.
Put(source, context, function_info, scope_position);
486 reg_exp_.
Put(source, flags, data);
491 for (
int i = 0; i < kSubCacheCount; i++) {
492 subcaches_[i]->
Clear();
498 for (
int i = 0; i < kSubCacheCount; i++) {
505 for (
int i = 0; i < kSubCacheCount; i++) {
512 for (
int i = 0; i < kSubCacheCount; i++) {
513 subcaches_[i]->
Age();
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
void Put(Handle< String > source, Handle< Context > context, Handle< SharedFunctionInfo > function_info, int scope_position)
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 true
void Put(Handle< String > source, Handle< Context > context, Handle< SharedFunctionInfo > function_info)
static String * cast(Object *obj)
StatsTable * stats_table()
static CompilationCacheTable * cast(Object *obj)
static Handle< T > cast(Handle< S > that)
Handle< SharedFunctionInfo > LookupScript(Handle< String > source, Handle< Object > name, int line_offset, int column_offset, bool is_shared_cross_origin, Handle< Context > context)
Handle< FixedArray > LookupRegExp(Handle< String > source, JSRegExp::Flags flags)
Handle< SharedFunctionInfo > LookupEval(Handle< String > source, Handle< Context > context, StrictMode strict_mode, int scope_position)
#define ASSERT(condition)
static Script * cast(Object *obj)
static SharedFunctionInfo * cast(Object *obj)
void SetFirstTable(Handle< CompilationCacheTable > value)
Handle< CompilationCacheTable > GetTable(int generation)
void PutScript(Handle< String > source, Handle< Context > context, Handle< SharedFunctionInfo > function_info)
bool Equals(String *other)
Handle< SharedFunctionInfo > Lookup(Handle< String > source, Handle< Context > context, StrictMode strict_mode, int scope_position)
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 size
void PutEval(Handle< String > source, Handle< Context > context, Handle< SharedFunctionInfo > function_info, int scope_position)
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
void Iterate(ObjectVisitor *v)
#define CALL_HEAP_FUNCTION(ISOLATE, FUNCTION_CALL, TYPE)
void MarkCompactPrologue()
void Iterate(ObjectVisitor *v)
Handle< SharedFunctionInfo > Lookup(Handle< String > source, Handle< Object > name, int line_offset, int column_offset, bool is_shared_cross_origin, Handle< Context > context)
void PutRegExp(Handle< String > source, JSRegExp::Flags flags, Handle< FixedArray > data)
V8_INLINE bool IsString() const
Handle< FixedArray > Lookup(Handle< String > source, JSRegExp::Flags flags)
static MUST_USE_RESULT MaybeObject * Allocate(Heap *heap, int at_least_space_for, MinimumCapacity capacity_option=USE_DEFAULT_MINIMUM_CAPACITY, PretenureFlag pretenure=NOT_TENURED)
Handle< CompilationCacheTable > GetFirstTable()
static Handle< T > null()
void MemsetPointer(T **dest, U *value, int counter)
void IterateFunctions(ObjectVisitor *v)
static FixedArray * cast(Object *obj)
CompilationCacheScript(Isolate *isolate, int generations)
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 generation(in kBytes)") DEFINE_int(max_old_space_size
void Remove(Handle< SharedFunctionInfo > function_info)
void * CreateHistogram(const char *name, int min, int max, size_t buckets)
void AddHistogramSample(void *histogram, int sample)
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
void Remove(Handle< SharedFunctionInfo > function_info)
void IterateFunctions(ObjectVisitor *v)
void Put(Handle< String > source, JSRegExp::Flags flags, Handle< FixedArray > data)