Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(12)

Side by Side Diff: src/runtime-profiler.cc

Issue 9866030: Move profiler_ticks to Code object, don't walk the stack when patching ICs (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 8 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« src/objects-inl.h ('K') | « src/runtime.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 243 matching lines...) Expand 10 before | Expand all | Expand 10 after
254 // modify and reset the ticks until next adjustment. 254 // modify and reset the ticks until next adjustment.
255 if (sampler_threshold_ > kSamplerThresholdMin) { 255 if (sampler_threshold_ > kSamplerThresholdMin) {
256 sampler_threshold_ -= kSamplerThresholdDelta; 256 sampler_threshold_ -= kSamplerThresholdDelta;
257 sampler_ticks_until_threshold_adjustment_ = 257 sampler_ticks_until_threshold_adjustment_ =
258 kSamplerTicksBetweenThresholdAdjustment; 258 kSamplerTicksBetweenThresholdAdjustment;
259 } 259 }
260 } 260 }
261 } 261 }
262 } 262 }
263 263
264 if (function->IsMarkedForLazyRecompilation() && 264 Code* shared_code = function->shared()->code();
265 function->shared()->code()->kind() == Code::FUNCTION) { 265 if (shared_code->kind() != Code::FUNCTION) continue;
266 Code* unoptimized = function->shared()->code(); 266
267 int nesting = unoptimized->allow_osr_at_loop_nesting_level(); 267 if (function->IsMarkedForLazyRecompilation()) {
268 int nesting = shared_code->allow_osr_at_loop_nesting_level();
268 if (nesting == 0) AttemptOnStackReplacement(function); 269 if (nesting == 0) AttemptOnStackReplacement(function);
269 int new_nesting = Min(nesting + 1, Code::kMaxLoopNestingMarker); 270 int new_nesting = Min(nesting + 1, Code::kMaxLoopNestingMarker);
270 unoptimized->set_allow_osr_at_loop_nesting_level(new_nesting); 271 shared_code->set_allow_osr_at_loop_nesting_level(new_nesting);
271 } 272 }
272 273
273 // Do not record non-optimizable functions. 274 // Do not record non-optimizable functions.
274 if (!function->IsOptimizable()) continue; 275 if (!function->IsOptimizable()) continue;
275 if (function->shared()->optimization_disabled()) continue; 276 if (function->shared()->optimization_disabled()) continue;
276 277
277 // Only record top-level code on top of the execution stack and 278 // Only record top-level code on top of the execution stack and
278 // avoid optimizing excessively large scripts since top-level code 279 // avoid optimizing excessively large scripts since top-level code
279 // will be executed only once. 280 // will be executed only once.
280 const int kMaxToplevelSourceSize = 10 * 1024; 281 const int kMaxToplevelSourceSize = 10 * 1024;
281 if (function->shared()->is_toplevel() 282 if (function->shared()->is_toplevel()
282 && (frame_count > 1 283 && (frame_count > 1
283 || function->shared()->SourceSize() > kMaxToplevelSourceSize)) { 284 || function->shared()->SourceSize() > kMaxToplevelSourceSize)) {
284 continue; 285 continue;
285 } 286 }
286 287
287 if (FLAG_watch_ic_patching) { 288 if (FLAG_watch_ic_patching) {
288 int ticks = function->shared()->profiler_ticks(); 289 int ticks = shared_code->profiler_ticks();
289 290
290 if (ticks >= kProfilerTicksBeforeOptimization) { 291 if (ticks >= kProfilerTicksBeforeOptimization) {
291 int typeinfo, total, percentage; 292 int typeinfo, total, percentage;
292 GetICCounts(function, &typeinfo, &total, &percentage); 293 GetICCounts(function, &typeinfo, &total, &percentage);
293 if (percentage >= FLAG_type_info_threshold) { 294 if (percentage >= FLAG_type_info_threshold) {
294 // If this particular function hasn't had any ICs patched for enough 295 // If this particular function hasn't had any ICs patched for enough
295 // ticks, optimize it now. 296 // ticks, optimize it now.
296 Optimize(function, "hot and stable"); 297 Optimize(function, "hot and stable");
297 } else if (ticks >= 100) { 298 } else if (ticks >= 100) {
ulan 2012/03/27 11:40:58 I think 100 should be a named constant with a stat
Jakob Kummerow 2012/03/27 12:19:10 Done.
298 // If this function does not have enough type info, but has 299 // If this function does not have enough type info, but has
299 // seen a huge number of ticks, optimize it as it is. 300 // seen a huge number of ticks, optimize it as it is.
300 Optimize(function, "not much type info but very hot"); 301 Optimize(function, "not much type info but very hot");
301 } else { 302 } else {
302 function->shared()->set_profiler_ticks(ticks + 1); 303 shared_code->set_profiler_ticks(ticks + 1);
303 if (FLAG_trace_opt_verbose) { 304 if (FLAG_trace_opt_verbose) {
304 PrintF("[not yet optimizing "); 305 PrintF("[not yet optimizing ");
305 function->PrintName(); 306 function->PrintName();
306 PrintF(", not enough type info: %d/%d (%d%%)]\n", 307 PrintF(", not enough type info: %d/%d (%d%%)]\n",
307 typeinfo, total, percentage); 308 typeinfo, total, percentage);
308 } 309 }
309 } 310 }
310 } else if (!any_ic_changed_ && 311 } else if (!any_ic_changed_ &&
311 function->shared()->code()->instruction_size() < kMaxSizeEarlyOpt) { 312 shared_code->instruction_size() < kMaxSizeEarlyOpt) {
312 // If no IC was patched since the last tick and this function is very 313 // If no IC was patched since the last tick and this function is very
313 // small, optimistically optimize it now. 314 // small, optimistically optimize it now.
314 Optimize(function, "small function"); 315 Optimize(function, "small function");
315 } else if (!code_generated_ && 316 } else if (!code_generated_ &&
316 !any_ic_changed_ && 317 !any_ic_changed_ &&
317 total_code_generated_ > 0 && 318 total_code_generated_ > 0 &&
318 total_code_generated_ < 2000) { 319 total_code_generated_ < 2000) {
319 // If no code was generated and no IC was patched since the last tick, 320 // If no code was generated and no IC was patched since the last tick,
320 // but a little code has already been generated since last Reset(), 321 // but a little code has already been generated since last Reset(),
321 // then type info might already be stable and we can optimize now. 322 // then type info might already be stable and we can optimize now.
322 Optimize(function, "stable on startup"); 323 Optimize(function, "stable on startup");
323 } else { 324 } else {
324 function->shared()->set_profiler_ticks(ticks + 1); 325 shared_code->set_profiler_ticks(ticks + 1);
325 } 326 }
326 } else { // !FLAG_watch_ic_patching 327 } else { // !FLAG_watch_ic_patching
327 samples[sample_count++] = function; 328 samples[sample_count++] = function;
328 329
329 int function_size = function->shared()->SourceSize(); 330 int function_size = function->shared()->SourceSize();
330 int threshold_size_factor = (function_size > kSizeLimit) 331 int threshold_size_factor = (function_size > kSizeLimit)
331 ? sampler_threshold_size_factor_ 332 ? sampler_threshold_size_factor_
332 : 1; 333 : 1;
333 334
334 int threshold = sampler_threshold_ * threshold_size_factor; 335 int threshold = sampler_threshold_ * threshold_size_factor;
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after
478 479
479 bool RuntimeProfilerRateLimiter::SuspendIfNecessary() { 480 bool RuntimeProfilerRateLimiter::SuspendIfNecessary() {
480 if (!RuntimeProfiler::IsSomeIsolateInJS()) { 481 if (!RuntimeProfiler::IsSomeIsolateInJS()) {
481 return RuntimeProfiler::WaitForSomeIsolateToEnterJS(); 482 return RuntimeProfiler::WaitForSomeIsolateToEnterJS();
482 } 483 }
483 return false; 484 return false;
484 } 485 }
485 486
486 487
487 } } // namespace v8::internal 488 } } // namespace v8::internal
OLDNEW
« src/objects-inl.h ('K') | « src/runtime.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698