| OLD | NEW |
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "src/v8.h" | 5 #include "src/v8.h" |
| 6 | 6 |
| 7 #include "src/runtime-profiler.h" | 7 #include "src/runtime-profiler.h" |
| 8 | 8 |
| 9 #include "src/assembler.h" | 9 #include "src/assembler.h" |
| 10 #include "src/base/platform/platform.h" | 10 #include "src/base/platform/platform.h" |
| (...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 174 if (FLAG_always_osr) { | 174 if (FLAG_always_osr) { |
| 175 AttemptOnStackReplacement(function, Code::kMaxLoopNestingMarker); | 175 AttemptOnStackReplacement(function, Code::kMaxLoopNestingMarker); |
| 176 // Fall through and do a normal optimized compile as well. | 176 // Fall through and do a normal optimized compile as well. |
| 177 } else if (!frame->is_optimized() && | 177 } else if (!frame->is_optimized() && |
| 178 (function->IsMarkedForOptimization() || | 178 (function->IsMarkedForOptimization() || |
| 179 function->IsMarkedForConcurrentOptimization() || | 179 function->IsMarkedForConcurrentOptimization() || |
| 180 function->IsOptimized())) { | 180 function->IsOptimized())) { |
| 181 // Attempt OSR if we are still running unoptimized code even though the | 181 // Attempt OSR if we are still running unoptimized code even though the |
| 182 // the function has long been marked or even already been optimized. | 182 // the function has long been marked or even already been optimized. |
| 183 int ticks = shared_code->profiler_ticks(); | 183 int ticks = shared_code->profiler_ticks(); |
| 184 int allowance = kOSRCodeSizeAllowanceBase + | 184 int64_t allowance = |
| 185 ticks * kOSRCodeSizeAllowancePerTick; | 185 kOSRCodeSizeAllowanceBase + |
| 186 if (shared_code->CodeSize() > allowance) { | 186 static_cast<int64_t>(ticks) * kOSRCodeSizeAllowancePerTick; |
| 187 if (ticks < 255) shared_code->set_profiler_ticks(ticks + 1); | 187 if (shared_code->CodeSize() > allowance && |
| 188 ticks < Code::ProfilerTicksField::kMax) { |
| 189 shared_code->set_profiler_ticks(ticks + 1); |
| 188 } else { | 190 } else { |
| 189 AttemptOnStackReplacement(function); | 191 AttemptOnStackReplacement(function); |
| 190 } | 192 } |
| 191 continue; | 193 continue; |
| 192 } | 194 } |
| 193 | 195 |
| 194 // Only record top-level code on top of the execution stack and | 196 // Only record top-level code on top of the execution stack and |
| 195 // avoid optimizing excessively large scripts since top-level code | 197 // avoid optimizing excessively large scripts since top-level code |
| 196 // will be executed only once. | 198 // will be executed only once. |
| 197 const int kMaxToplevelSourceSize = 10 * 1024; | 199 const int kMaxToplevelSourceSize = 10 * 1024; |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 255 } else { | 257 } else { |
| 256 shared_code->set_profiler_ticks(ticks + 1); | 258 shared_code->set_profiler_ticks(ticks + 1); |
| 257 } | 259 } |
| 258 } | 260 } |
| 259 any_ic_changed_ = false; | 261 any_ic_changed_ = false; |
| 260 } | 262 } |
| 261 | 263 |
| 262 | 264 |
| 263 } // namespace internal | 265 } // namespace internal |
| 264 } // namespace v8 | 266 } // namespace v8 |
| OLD | NEW |