50 static const int kProfilerTicksBeforeOptimization = 2;
54 static const int kProfilerTicksBeforeReenablingOptimization = 250;
58 static const int kTicksWhenNotEnoughTypeInfo = 100;
61 STATIC_ASSERT(kProfilerTicksBeforeReenablingOptimization < 256);
65 static const int kOSRCodeSizeAllowanceBase =
66 100 * FullCodeGenerator::kCodeSizeMultiplier;
68 static const int kOSRCodeSizeAllowancePerTick =
69 4 * FullCodeGenerator::kCodeSizeMultiplier;
73 static const int kMaxSizeEarlyOpt =
74 5 * FullCodeGenerator::kCodeSizeMultiplier;
79 any_ic_changed_(
false) {
83 static void GetICCounts(
Code* shared_code,
84 int* ic_with_type_info_count,
88 *ic_with_type_info_count = 0;
90 if (raw_info->IsTypeFeedbackInfo()) {
95 *percentage = *ic_total_count > 0
96 ? 100 * *ic_with_type_info_count / *ic_total_count
101 void RuntimeProfiler::Optimize(JSFunction*
function,
const char* reason) {
102 ASSERT(function->IsOptimizable());
104 if (FLAG_trace_opt && function->PassesFilter(FLAG_hydrogen_filter)) {
106 function->ShortPrint();
107 PrintF(
" for recompilation, reason: %s", reason);
108 if (FLAG_type_info_threshold > 0) {
109 int typeinfo, total, percentage;
110 GetICCounts(function->shared()->code(), &typeinfo, &total, &percentage);
111 PrintF(
", ICs with typeinfo: %d/%d (%d%%)", typeinfo, total, percentage);
127 ASSERT(!function->IsInOptimizationQueue());
128 function->MarkForConcurrentOptimization();
131 function->MarkForOptimization();
141 function->IsBuiltin()) {
147 if (!shared->code()->optimizable())
return;
152 if (shared->uses_arguments())
return;
157 if (FLAG_trace_osr) {
158 PrintF(
"[OSR - patching back edges in ");
159 function->PrintName();
178 int frame_count_limit = FLAG_frame_count;
179 for (JavaScriptFrameIterator it(isolate_);
180 frame_count++ < frame_count_limit && !it.done();
186 Code* shared_code = shared->code();
188 if (shared_code->
kind() != Code::FUNCTION)
continue;
189 if (function->IsInOptimizationQueue())
continue;
191 if (FLAG_always_osr &&
200 }
else if (!frame->is_optimized() &&
201 (
function->IsMarkedForOptimization() ||
202 function->IsMarkedForConcurrentOptimization() ||
203 function->IsOptimized())) {
207 int allowance = kOSRCodeSizeAllowanceBase +
208 ticks * kOSRCodeSizeAllowancePerTick;
209 if (shared_code->
CodeSize() > allowance) {
214 int new_nesting = nesting + 1;
225 const int kMaxToplevelSourceSize = 10 * 1024;
226 if (shared->is_toplevel() &&
227 (frame_count > 1 || shared->
SourceSize() > kMaxToplevelSourceSize)) {
232 if (shared->optimization_disabled()) {
237 if (ticks >= kProfilerTicksBeforeReenablingOptimization) {
246 if (!function->IsOptimizable())
continue;
250 if (ticks >= kProfilerTicksBeforeOptimization) {
251 int typeinfo, total, percentage;
252 GetICCounts(shared_code, &typeinfo, &total, &percentage);
253 if (percentage >= FLAG_type_info_threshold) {
256 Optimize(
function,
"hot and stable");
257 }
else if (ticks >= kTicksWhenNotEnoughTypeInfo) {
258 Optimize(
function,
"not much type info but very hot");
261 if (FLAG_trace_opt_verbose) {
262 PrintF(
"[not yet optimizing ");
263 function->PrintName();
264 PrintF(
", not enough type info: %d/%d (%d%%)]\n",
265 typeinfo, total, percentage);
268 }
else if (!any_ic_changed_ &&
272 Optimize(
function,
"small function");
277 any_ic_changed_ =
false;
Object * type_feedback_info()
void TryReenableOptimization()
static void Patch(Isolate *isolate, Code *unoptimized_code)
int allow_osr_at_loop_nesting_level()
RuntimeProfiler(Isolate *isolate)
void PrintF(const char *format,...)
static TypeFeedbackInfo * cast(Object *obj)
bool concurrent_osr_enabled() const
Bootstrapper * bootstrapper()
#define ASSERT(condition)
void set_profiler_ticks(int ticks)
bool concurrent_recompilation_enabled()
STATIC_ASSERT(sizeof(CPURegister)==sizeof(Register))
static const int kMaxLoopNestingMarker
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
bool DebuggerHasBreakPoints()
int ic_with_type_info_count()
OptimizingCompilerThread * optimizing_compiler_thread()
void AttemptOnStackReplacement(JSFunction *function)
void set_allow_osr_at_loop_nesting_level(int level)
JSFunction * function() const
bool IsQueuedForOSR(Handle< JSFunction > function, BailoutId osr_ast_id)