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

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

Issue 10829009: Classify small functions platform-dependently. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 8 years, 5 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
« no previous file with comments | « src/mips/full-codegen-mips.cc ('k') | src/x64/full-codegen-x64.cc » ('j') | 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 16 matching lines...) Expand all
27 27
28 #include "v8.h" 28 #include "v8.h"
29 29
30 #include "runtime-profiler.h" 30 #include "runtime-profiler.h"
31 31
32 #include "assembler.h" 32 #include "assembler.h"
33 #include "code-stubs.h" 33 #include "code-stubs.h"
34 #include "compilation-cache.h" 34 #include "compilation-cache.h"
35 #include "deoptimizer.h" 35 #include "deoptimizer.h"
36 #include "execution.h" 36 #include "execution.h"
37 #include "full-codegen.h"
37 #include "global-handles.h" 38 #include "global-handles.h"
38 #include "isolate-inl.h" 39 #include "isolate-inl.h"
39 #include "mark-compact.h" 40 #include "mark-compact.h"
40 #include "platform.h" 41 #include "platform.h"
41 #include "scopeinfo.h" 42 #include "scopeinfo.h"
42 43
43 namespace v8 { 44 namespace v8 {
44 namespace internal { 45 namespace internal {
45 46
46 47
(...skipping 27 matching lines...) Expand all
74 // optimize it as it is. 75 // optimize it as it is.
75 static const int kTicksWhenNotEnoughTypeInfo = 100; 76 static const int kTicksWhenNotEnoughTypeInfo = 100;
76 // We only have one byte to store the number of ticks. 77 // We only have one byte to store the number of ticks.
77 STATIC_ASSERT(kProfilerTicksBeforeOptimization < 256); 78 STATIC_ASSERT(kProfilerTicksBeforeOptimization < 256);
78 STATIC_ASSERT(kProfilerTicksBeforeReenablingOptimization < 256); 79 STATIC_ASSERT(kProfilerTicksBeforeReenablingOptimization < 256);
79 STATIC_ASSERT(kTicksWhenNotEnoughTypeInfo < 256); 80 STATIC_ASSERT(kTicksWhenNotEnoughTypeInfo < 256);
80 81
81 82
82 // Maximum size in bytes of generated code for a function to be optimized 83 // Maximum size in bytes of generated code for a function to be optimized
83 // the very first time it is seen on the stack. 84 // the very first time it is seen on the stack.
84 static const int kMaxSizeEarlyOpt = 500; 85 static const int kMaxSizeEarlyOpt =
86 5 * FullCodeGenerator::kBackEdgeDistanceUnit;
85 87
86 88
87 Atomic32 RuntimeProfiler::state_ = 0; 89 Atomic32 RuntimeProfiler::state_ = 0;
88 90
89 // TODO(isolates): Clean up the semaphore when it is no longer required. 91 // TODO(isolates): Clean up the semaphore when it is no longer required.
90 static LazySemaphore<0>::type semaphore = LAZY_SEMAPHORE_INITIALIZER; 92 static LazySemaphore<0>::type semaphore = LAZY_SEMAPHORE_INITIALIZER;
91 93
92 #ifdef DEBUG 94 #ifdef DEBUG
93 bool RuntimeProfiler::has_been_globally_set_up_ = false; 95 bool RuntimeProfiler::has_been_globally_set_up_ = false;
94 #endif 96 #endif
(...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after
310 shared_code->set_profiler_ticks(0); 312 shared_code->set_profiler_ticks(0);
311 shared->TryReenableOptimization(); 313 shared->TryReenableOptimization();
312 } else { 314 } else {
313 shared_code->set_profiler_ticks(ticks + 1); 315 shared_code->set_profiler_ticks(ticks + 1);
314 } 316 }
315 } 317 }
316 continue; 318 continue;
317 } 319 }
318 if (!function->IsOptimizable()) continue; 320 if (!function->IsOptimizable()) continue;
319 321
320
321
322 if (FLAG_watch_ic_patching) { 322 if (FLAG_watch_ic_patching) {
323 int ticks = shared_code->profiler_ticks(); 323 int ticks = shared_code->profiler_ticks();
324 324
325 if (ticks >= kProfilerTicksBeforeOptimization) { 325 if (ticks >= kProfilerTicksBeforeOptimization) {
326 int typeinfo, total, percentage; 326 int typeinfo, total, percentage;
327 GetICCounts(function, &typeinfo, &total, &percentage); 327 GetICCounts(function, &typeinfo, &total, &percentage);
328 if (percentage >= FLAG_type_info_threshold) { 328 if (percentage >= FLAG_type_info_threshold) {
329 // If this particular function hasn't had any ICs patched for enough 329 // If this particular function hasn't had any ICs patched for enough
330 // ticks, optimize it now. 330 // ticks, optimize it now.
331 Optimize(function, "hot and stable"); 331 Optimize(function, "hot and stable");
332 } else if (ticks >= kTicksWhenNotEnoughTypeInfo) { 332 } else if (ticks >= kTicksWhenNotEnoughTypeInfo) {
333 Optimize(function, "not much type info but very hot"); 333 Optimize(function, "not much type info but very hot");
334 } else { 334 } else {
335 shared_code->set_profiler_ticks(ticks + 1); 335 shared_code->set_profiler_ticks(ticks + 1);
336 if (FLAG_trace_opt_verbose) { 336 if (FLAG_trace_opt_verbose) {
337 PrintF("[not yet optimizing "); 337 PrintF("[not yet optimizing ");
338 function->PrintName(); 338 function->PrintName();
339 PrintF(", not enough type info: %d/%d (%d%%)]\n", 339 PrintF(", not enough type info: %d/%d (%d%%)]\n",
340 typeinfo, total, percentage); 340 typeinfo, total, percentage);
341 } 341 }
342 } 342 }
343 } else if (!any_ic_changed_ && 343 } else if (!any_ic_changed_ &&
344 shared_code->instruction_size() < kMaxSizeEarlyOpt) { 344 shared_code->instruction_size() < kMaxSizeEarlyOpt) {
345 // If no IC was patched since the last tick and this function is very 345 // If no IC was patched since the last tick and this function is very
346 // small, optimistically optimize it now. 346 // small, optimistically optimize it now.
347 Optimize(function, "small function"); 347 Optimize(function, "small function");
348 } else { 348 } else {
349 shared_code->set_profiler_ticks(ticks + 1); 349 shared_code->set_profiler_ticks(ticks + 1);
350 } 350 }
351 } else { // !FLAG_watch_ic_patching 351 } else { // !FLAG_watch_ic_patching
352 samples[sample_count++] = function; 352 samples[sample_count++] = function;
353 353
354 int function_size = function->shared()->SourceSize(); 354 int function_size = function->shared()->SourceSize();
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after
496 496
497 bool RuntimeProfilerRateLimiter::SuspendIfNecessary() { 497 bool RuntimeProfilerRateLimiter::SuspendIfNecessary() {
498 if (!RuntimeProfiler::IsSomeIsolateInJS()) { 498 if (!RuntimeProfiler::IsSomeIsolateInJS()) {
499 return RuntimeProfiler::WaitForSomeIsolateToEnterJS(); 499 return RuntimeProfiler::WaitForSomeIsolateToEnterJS();
500 } 500 }
501 return false; 501 return false;
502 } 502 }
503 503
504 504
505 } } // namespace v8::internal 505 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/mips/full-codegen-mips.cc ('k') | src/x64/full-codegen-x64.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698