Commit 8768af54 authored by ulan@chromium.org's avatar ulan@chromium.org

Revert r11425 because of V8 benchmark performance regression.

Original CL: https://chromiumcodereview.appspot.com/10202007 "Re-enable optimization for hot functions that have optimization disabled due to many deopts."

Review URL: https://chromiumcodereview.appspot.com/10265008

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@11464 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent 347d28f2
...@@ -3015,6 +3015,7 @@ MaybeObject* Heap::AllocateSharedFunctionInfo(Object* name) { ...@@ -3015,6 +3015,7 @@ MaybeObject* Heap::AllocateSharedFunctionInfo(Object* name) {
share->set_this_property_assignments(undefined_value(), SKIP_WRITE_BARRIER); share->set_this_property_assignments(undefined_value(), SKIP_WRITE_BARRIER);
share->set_ast_node_count(0); share->set_ast_node_count(0);
share->set_deopt_counter(FLAG_deopt_every_n_times); share->set_deopt_counter(FLAG_deopt_every_n_times);
share->set_ic_age(0);
// Set integer fields (smi or int, depending on the architecture). // Set integer fields (smi or int, depending on the architecture).
share->set_length(0); share->set_length(0);
...@@ -3028,8 +3029,6 @@ MaybeObject* Heap::AllocateSharedFunctionInfo(Object* name) { ...@@ -3028,8 +3029,6 @@ MaybeObject* Heap::AllocateSharedFunctionInfo(Object* name) {
share->set_compiler_hints(0); share->set_compiler_hints(0);
share->set_this_property_assignments_count(0); share->set_this_property_assignments_count(0);
share->set_opt_count(0); share->set_opt_count(0);
share->set_ic_age(0);
share->set_opt_reenable_tries(0);
return share; return share;
} }
......
...@@ -3511,6 +3511,7 @@ ACCESSORS(SharedFunctionInfo, debug_info, Object, kDebugInfoOffset) ...@@ -3511,6 +3511,7 @@ ACCESSORS(SharedFunctionInfo, debug_info, Object, kDebugInfoOffset)
ACCESSORS(SharedFunctionInfo, inferred_name, String, kInferredNameOffset) ACCESSORS(SharedFunctionInfo, inferred_name, String, kInferredNameOffset)
ACCESSORS(SharedFunctionInfo, this_property_assignments, Object, ACCESSORS(SharedFunctionInfo, this_property_assignments, Object,
kThisPropertyAssignmentsOffset) kThisPropertyAssignmentsOffset)
SMI_ACCESSORS(SharedFunctionInfo, ic_age, kICAgeOffset)
BOOL_ACCESSORS(FunctionTemplateInfo, flag, hidden_prototype, BOOL_ACCESSORS(FunctionTemplateInfo, flag, hidden_prototype,
...@@ -3561,8 +3562,6 @@ SMI_ACCESSORS(SharedFunctionInfo, this_property_assignments_count, ...@@ -3561,8 +3562,6 @@ SMI_ACCESSORS(SharedFunctionInfo, this_property_assignments_count,
SMI_ACCESSORS(SharedFunctionInfo, opt_count, kOptCountOffset) SMI_ACCESSORS(SharedFunctionInfo, opt_count, kOptCountOffset)
SMI_ACCESSORS(SharedFunctionInfo, ast_node_count, kAstNodeCountOffset) SMI_ACCESSORS(SharedFunctionInfo, ast_node_count, kAstNodeCountOffset)
SMI_ACCESSORS(SharedFunctionInfo, deopt_counter, kDeoptCounterOffset) SMI_ACCESSORS(SharedFunctionInfo, deopt_counter, kDeoptCounterOffset)
SMI_ACCESSORS(SharedFunctionInfo, ic_age, kICAgeOffset)
SMI_ACCESSORS(SharedFunctionInfo, opt_reenable_tries, kOptReenableTriesOffset)
#else #else
#define PSEUDO_SMI_ACCESSORS_LO(holder, name, offset) \ #define PSEUDO_SMI_ACCESSORS_LO(holder, name, offset) \
...@@ -3616,11 +3615,6 @@ PSEUDO_SMI_ACCESSORS_HI(SharedFunctionInfo, opt_count, kOptCountOffset) ...@@ -3616,11 +3615,6 @@ PSEUDO_SMI_ACCESSORS_HI(SharedFunctionInfo, opt_count, kOptCountOffset)
PSEUDO_SMI_ACCESSORS_LO(SharedFunctionInfo, ast_node_count, kAstNodeCountOffset) PSEUDO_SMI_ACCESSORS_LO(SharedFunctionInfo, ast_node_count, kAstNodeCountOffset)
PSEUDO_SMI_ACCESSORS_HI(SharedFunctionInfo, deopt_counter, kDeoptCounterOffset) PSEUDO_SMI_ACCESSORS_HI(SharedFunctionInfo, deopt_counter, kDeoptCounterOffset)
PSEUDO_SMI_ACCESSORS_LO(SharedFunctionInfo, ic_age, kICAgeOffset)
PSEUDO_SMI_ACCESSORS_HI(SharedFunctionInfo,
opt_reenable_tries,
kOptReenableTriesOffset)
#endif #endif
...@@ -3660,7 +3654,6 @@ void SharedFunctionInfo::set_optimization_disabled(bool disable) { ...@@ -3660,7 +3654,6 @@ void SharedFunctionInfo::set_optimization_disabled(bool disable) {
// it will not be counted as optimizable code. // it will not be counted as optimizable code.
if ((code()->kind() == Code::FUNCTION) && disable) { if ((code()->kind() == Code::FUNCTION) && disable) {
code()->set_optimizable(false); code()->set_optimizable(false);
code()->set_profiler_ticks(0);
} }
} }
...@@ -3696,23 +3689,6 @@ bool SharedFunctionInfo::is_classic_mode() { ...@@ -3696,23 +3689,6 @@ bool SharedFunctionInfo::is_classic_mode() {
return !BooleanBit::get(compiler_hints(), kStrictModeFunction); return !BooleanBit::get(compiler_hints(), kStrictModeFunction);
} }
void SharedFunctionInfo::TryReenableOptimization() {
int tries = opt_reenable_tries();
if (tries == Smi::kMaxValue) {
tries = 0;
}
set_opt_reenable_tries(tries + 1);
// We reenable optimization whenever the number of tries is a large
// enough power of 2.
if (tries >= 4 && (((tries - 1) & tries) == 0)) {
set_optimization_disabled(false);
set_opt_count(0);
code()->set_optimizable(true);
}
}
BOOL_GETTER(SharedFunctionInfo, compiler_hints, is_extended_mode, BOOL_GETTER(SharedFunctionInfo, compiler_hints, is_extended_mode,
kExtendedModeFunction) kExtendedModeFunction)
BOOL_ACCESSORS(SharedFunctionInfo, compiler_hints, native, kNative) BOOL_ACCESSORS(SharedFunctionInfo, compiler_hints, native, kNative)
......
...@@ -7871,7 +7871,6 @@ void SharedFunctionInfo::ResetForNewContext(int new_ic_age) { ...@@ -7871,7 +7871,6 @@ void SharedFunctionInfo::ResetForNewContext(int new_ic_age) {
code()->set_optimizable(true); code()->set_optimizable(true);
} }
set_opt_count(0); set_opt_count(0);
set_opt_reenable_tries(0);
} }
} }
......
...@@ -5461,13 +5461,6 @@ class SharedFunctionInfo: public HeapObject { ...@@ -5461,13 +5461,6 @@ class SharedFunctionInfo: public HeapObject {
inline int opt_count(); inline int opt_count();
inline void set_opt_count(int opt_count); inline void set_opt_count(int opt_count);
// Number of times we tried to reenable optimization.
inline int opt_reenable_tries();
inline void set_opt_reenable_tries(int opt_reenable_tries);
inline void TryReenableOptimization();
// Source size of this function. // Source size of this function.
int SourceSize(); int SourceSize();
...@@ -5524,10 +5517,13 @@ class SharedFunctionInfo: public HeapObject { ...@@ -5524,10 +5517,13 @@ class SharedFunctionInfo: public HeapObject {
kInferredNameOffset + kPointerSize; kInferredNameOffset + kPointerSize;
static const int kThisPropertyAssignmentsOffset = static const int kThisPropertyAssignmentsOffset =
kInitialMapOffset + kPointerSize; kInitialMapOffset + kPointerSize;
// ic_age is a Smi field. It could be grouped with another Smi field into a
// PSEUDO_SMI_ACCESSORS pair (on x64), if one becomes available.
static const int kICAgeOffset = kThisPropertyAssignmentsOffset + kPointerSize;
#if V8_HOST_ARCH_32_BIT #if V8_HOST_ARCH_32_BIT
// Smi fields. // Smi fields.
static const int kLengthOffset = static const int kLengthOffset =
kThisPropertyAssignmentsOffset + kPointerSize; kICAgeOffset + kPointerSize;
static const int kFormalParameterCountOffset = kLengthOffset + kPointerSize; static const int kFormalParameterCountOffset = kLengthOffset + kPointerSize;
static const int kExpectedNofPropertiesOffset = static const int kExpectedNofPropertiesOffset =
kFormalParameterCountOffset + kPointerSize; kFormalParameterCountOffset + kPointerSize;
...@@ -5547,10 +5543,10 @@ class SharedFunctionInfo: public HeapObject { ...@@ -5547,10 +5543,10 @@ class SharedFunctionInfo: public HeapObject {
kThisPropertyAssignmentsCountOffset + kPointerSize; kThisPropertyAssignmentsCountOffset + kPointerSize;
static const int kAstNodeCountOffset = kOptCountOffset + kPointerSize; static const int kAstNodeCountOffset = kOptCountOffset + kPointerSize;
static const int kDeoptCounterOffset = kAstNodeCountOffset + kPointerSize; static const int kDeoptCounterOffset = kAstNodeCountOffset + kPointerSize;
static const int kICAgeOffset = kDeoptCounterOffset + kPointerSize;
static const int kOptReenableTriesOffset = kICAgeOffset + kPointerSize;
// Total size. // Total size.
static const int kSize = kOptReenableTriesOffset + kPointerSize; static const int kSize = kDeoptCounterOffset + kPointerSize;
#else #else
// The only reason to use smi fields instead of int fields // The only reason to use smi fields instead of int fields
// is to allow iteration without maps decoding during // is to allow iteration without maps decoding during
...@@ -5562,7 +5558,7 @@ class SharedFunctionInfo: public HeapObject { ...@@ -5562,7 +5558,7 @@ class SharedFunctionInfo: public HeapObject {
// word is not set and thus this word cannot be treated as pointer // word is not set and thus this word cannot be treated as pointer
// to HeapObject during old space traversal. // to HeapObject during old space traversal.
static const int kLengthOffset = static const int kLengthOffset =
kThisPropertyAssignmentsOffset + kPointerSize; kICAgeOffset + kPointerSize;
static const int kFormalParameterCountOffset = static const int kFormalParameterCountOffset =
kLengthOffset + kIntSize; kLengthOffset + kIntSize;
...@@ -5589,11 +5585,8 @@ class SharedFunctionInfo: public HeapObject { ...@@ -5589,11 +5585,8 @@ class SharedFunctionInfo: public HeapObject {
static const int kAstNodeCountOffset = kOptCountOffset + kIntSize; static const int kAstNodeCountOffset = kOptCountOffset + kIntSize;
static const int kDeoptCounterOffset = kAstNodeCountOffset + kIntSize; static const int kDeoptCounterOffset = kAstNodeCountOffset + kIntSize;
static const int kICAgeOffset = kDeoptCounterOffset + kIntSize;
static const int kOptReenableTriesOffset = kICAgeOffset + kIntSize;
// Total size. // Total size.
static const int kSize = kOptReenableTriesOffset + kIntSize; static const int kSize = kDeoptCounterOffset + kIntSize;
#endif #endif
......
...@@ -65,17 +65,11 @@ static const int kSizeLimit = 1500; ...@@ -65,17 +65,11 @@ static const int kSizeLimit = 1500;
// Number of times a function has to be seen on the stack before it is // Number of times a function has to be seen on the stack before it is
// optimized. // optimized.
static const int kProfilerTicksBeforeOptimization = 2; static const int kProfilerTicksBeforeOptimization = 2;
// If the function optimization was disabled due to high deoptimization count,
// but the function is hot and has been seen on the stack this number of times,
// then we try to reenable optimization for this function.
static const int kProfilerTicksBeforeReenablingOptimization = 250;
// If a function does not have enough type info (according to // If a function does not have enough type info (according to
// FLAG_type_info_threshold), but has seen a huge number of ticks, // FLAG_type_info_threshold), but has seen a huge number of ticks,
// optimize it as it is. // optimize it as it is.
static const int kTicksWhenNotEnoughTypeInfo = 100; static const int kTicksWhenNotEnoughTypeInfo = 100;
// We only have one byte to store the number of ticks. // We only have one byte to store the number of ticks.
STATIC_ASSERT(kProfilerTicksBeforeOptimization < 256);
STATIC_ASSERT(kProfilerTicksBeforeReenablingOptimization < 256);
STATIC_ASSERT(kTicksWhenNotEnoughTypeInfo < 256); STATIC_ASSERT(kTicksWhenNotEnoughTypeInfo < 256);
// Maximum size in bytes of generated code for a function to be optimized // Maximum size in bytes of generated code for a function to be optimized
...@@ -269,8 +263,7 @@ void RuntimeProfiler::OptimizeNow() { ...@@ -269,8 +263,7 @@ void RuntimeProfiler::OptimizeNow() {
} }
} }
SharedFunctionInfo* shared = function->shared(); Code* shared_code = function->shared()->code();
Code* shared_code = shared->code();
if (shared_code->kind() != Code::FUNCTION) continue; if (shared_code->kind() != Code::FUNCTION) continue;
if (function->IsMarkedForLazyRecompilation()) { if (function->IsMarkedForLazyRecompilation()) {
...@@ -280,31 +273,19 @@ void RuntimeProfiler::OptimizeNow() { ...@@ -280,31 +273,19 @@ void RuntimeProfiler::OptimizeNow() {
shared_code->set_allow_osr_at_loop_nesting_level(new_nesting); shared_code->set_allow_osr_at_loop_nesting_level(new_nesting);
} }
// Do not record non-optimizable functions.
if (!function->IsOptimizable()) continue;
if (function->shared()->optimization_disabled()) continue;
// Only record top-level code on top of the execution stack and // Only record top-level code on top of the execution stack and
// avoid optimizing excessively large scripts since top-level code // avoid optimizing excessively large scripts since top-level code
// will be executed only once. // will be executed only once.
const int kMaxToplevelSourceSize = 10 * 1024; const int kMaxToplevelSourceSize = 10 * 1024;
if (shared->is_toplevel() && if (function->shared()->is_toplevel()
(frame_count > 1 || shared->SourceSize() > kMaxToplevelSourceSize)) { && (frame_count > 1
continue; || function->shared()->SourceSize() > kMaxToplevelSourceSize)) {
}
// Do not record non-optimizable functions.
if (shared->optimization_disabled()) {
if (shared->opt_count() >= Compiler::kDefaultMaxOptCount) {
// If optimization was disabled due to many deoptimizations,
// then check if the function is hot and try to reenable optimization.
int ticks = shared_code->profiler_ticks();
if (ticks >= kProfilerTicksBeforeReenablingOptimization) {
shared_code->set_profiler_ticks(0);
shared->TryReenableOptimization();
} else {
shared_code->set_profiler_ticks(ticks + 1);
}
}
continue; continue;
} }
if (!function->IsOptimizable()) continue;
if (FLAG_watch_ic_patching) { if (FLAG_watch_ic_patching) {
int ticks = shared_code->profiler_ticks(); int ticks = shared_code->profiler_ticks();
...@@ -328,7 +309,7 @@ void RuntimeProfiler::OptimizeNow() { ...@@ -328,7 +309,7 @@ void RuntimeProfiler::OptimizeNow() {
} }
} }
} else if (!any_ic_changed_ && } else if (!any_ic_changed_ &&
shared_code->instruction_size() < kMaxSizeEarlyOpt) { shared_code->instruction_size() < kMaxSizeEarlyOpt) {
// If no IC was patched since the last tick and this function is very // If no IC was patched since the last tick and this function is very
// small, optimistically optimize it now. // small, optimistically optimize it now.
Optimize(function, "small function"); Optimize(function, "small function");
...@@ -338,7 +319,7 @@ void RuntimeProfiler::OptimizeNow() { ...@@ -338,7 +319,7 @@ void RuntimeProfiler::OptimizeNow() {
} else { // !FLAG_watch_ic_patching } else { // !FLAG_watch_ic_patching
samples[sample_count++] = function; samples[sample_count++] = function;
int function_size = shared->SourceSize(); int function_size = function->shared()->SourceSize();
int threshold_size_factor = (function_size > kSizeLimit) int threshold_size_factor = (function_size > kSizeLimit)
? sampler_threshold_size_factor_ ? sampler_threshold_size_factor_
: 1; : 1;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment