Chromium Code Reviews| Index: src/objects.h | 
| diff --git a/src/objects.h b/src/objects.h | 
| index ea0ca9cc5bf61f20c157b8a1a6c2f94ce45a9e73..76d543790582f37d38fbd47479d20e96e08923ac 100644 | 
| --- a/src/objects.h | 
| +++ b/src/objects.h | 
| @@ -5357,8 +5357,8 @@ class SharedFunctionInfo: public HeapObject { | 
| // A counter used to determine when to stress the deoptimizer with a | 
| // deopt. | 
| - inline int deopt_counter(); | 
| - inline void set_deopt_counter(int counter); | 
| + inline int stress_deopt_counter(); | 
| + inline void set_stress_deopt_counter(int counter); | 
| inline int profiler_ticks(); | 
| @@ -5486,9 +5486,27 @@ class SharedFunctionInfo: public HeapObject { | 
| bool HasSourceCode(); | 
| Handle<Object> GetSourceCode(); | 
| + // Number of times the function was optimized. | 
| inline int opt_count(); | 
| inline void set_opt_count(int opt_count); | 
| + // Number of times the function was deoptimized. | 
| + inline void set_deopt_count(int value); | 
| + inline int deopt_count(); | 
| + inline void increment_deopt_count(); | 
| + | 
| + // Number of time we tried to re-enable optimization after it | 
| + // was disabled due to high number of deoptimizations. | 
| + inline void set_opt_reenable_tries(int value); | 
| + inline int opt_reenable_tries(); | 
| + | 
| + inline void TryReenableOptimization(); | 
| + | 
| + // Stores deopt_count, opt_reenable_tries and ic_age as bit-fields. | 
| + inline void set_counters(int value); | 
| + inline int counters(); | 
| + | 
| + | 
| // Source size of this function. | 
| int SourceSize(); | 
| @@ -5545,13 +5563,14 @@ class SharedFunctionInfo: public HeapObject { | 
| kInferredNameOffset + kPointerSize; | 
| static const int kThisPropertyAssignmentsOffset = | 
| 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; | 
| + // ast_node_count 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 kAstNodeCountOffset = | 
| + kThisPropertyAssignmentsOffset + kPointerSize; | 
| #if V8_HOST_ARCH_32_BIT | 
| // Smi fields. | 
| static const int kLengthOffset = | 
| - kICAgeOffset + kPointerSize; | 
| + kAstNodeCountOffset + kPointerSize; | 
| static const int kFormalParameterCountOffset = kLengthOffset + kPointerSize; | 
| static const int kExpectedNofPropertiesOffset = | 
| kFormalParameterCountOffset + kPointerSize; | 
| @@ -5569,12 +5588,11 @@ class SharedFunctionInfo: public HeapObject { | 
| kCompilerHintsOffset + kPointerSize; | 
| static const int kOptCountOffset = | 
| kThisPropertyAssignmentsCountOffset + kPointerSize; | 
| - static const int kAstNodeCountOffset = kOptCountOffset + kPointerSize; | 
| - static const int kDeoptCounterOffset = kAstNodeCountOffset + kPointerSize; | 
| - | 
| + static const int kCountersOffset = kOptCountOffset + kPointerSize; | 
| + static const int kStressDeoptCounterOffset = kCountersOffset + kPointerSize; | 
| // Total size. | 
| - static const int kSize = kDeoptCounterOffset + kPointerSize; | 
| + static const int kSize = kStressDeoptCounterOffset + kPointerSize; | 
| #else | 
| // The only reason to use smi fields instead of int fields | 
| // is to allow iteration without maps decoding during | 
| @@ -5586,7 +5604,7 @@ class SharedFunctionInfo: public HeapObject { | 
| // word is not set and thus this word cannot be treated as pointer | 
| // to HeapObject during old space traversal. | 
| static const int kLengthOffset = | 
| - kICAgeOffset + kPointerSize; | 
| + kAstNodeCountOffset + kPointerSize; | 
| static const int kFormalParameterCountOffset = | 
| kLengthOffset + kIntSize; | 
| @@ -5610,11 +5628,11 @@ class SharedFunctionInfo: public HeapObject { | 
| static const int kOptCountOffset = | 
| kThisPropertyAssignmentsCountOffset + kIntSize; | 
| - static const int kAstNodeCountOffset = kOptCountOffset + kIntSize; | 
| - static const int kDeoptCounterOffset = kAstNodeCountOffset + kIntSize; | 
| + static const int kCountersOffset = kOptCountOffset + kIntSize; | 
| + static const int kStressDeoptCounterOffset = kCountersOffset + kIntSize; | 
| // Total size. | 
| - static const int kSize = kDeoptCounterOffset + kIntSize; | 
| + static const int kSize = kStressDeoptCounterOffset + kIntSize; | 
| #endif | 
| @@ -5667,20 +5685,44 @@ class SharedFunctionInfo: public HeapObject { | 
| kCompilerHintsCount // Pseudo entry | 
| }; | 
| + static const int kDeoptCountSize = 4; | 
| + static const int kDeoptCountMask = (1 << kDeoptCountSize) - 1; | 
| + | 
| + static const int kOptReenableTriesSize = 18; | 
| + static const int kOptReenableTriesMask = (1 << kOptReenableTriesSize) - 1; | 
| + | 
| + static const int kICAgeSize = 8; | 
| + static const int kICAgeMask = (1 << kICAgeSize) - 1; | 
| + | 
| + enum Counters { | 
| + kDeoptCountShift, | 
| 
 
Jakob Kummerow
2012/06/11 12:13:59
Don't you want to set kDeoptCountShift = kCounters
 
ulan
2012/06/11 16:07:31
set_counters takes care of this, removed kCounters
 
 | 
| + kOptReenableTriesShift = kDeoptCountShift + kDeoptCountSize, | 
| + kICAgeShift = kOptReenableTriesShift + kOptReenableTriesSize, | 
| + kCountersSizeInBits = kICAgeShift + kICAgeSize // Pseudo entry | 
| + }; | 
| + | 
| private: | 
| #if V8_HOST_ARCH_32_BIT | 
| // On 32 bit platforms, compiler hints is a smi. | 
| static const int kCompilerHintsSmiTagSize = kSmiTagSize; | 
| static const int kCompilerHintsSize = kPointerSize; | 
| + | 
| + static const int kCountersSmiTagSize = kSmiTagSize; | 
| + static const int kCountersSize = kPointerSize; | 
| #else | 
| // On 64 bit platforms, compiler hints is not a smi, see comment above. | 
| static const int kCompilerHintsSmiTagSize = 0; | 
| static const int kCompilerHintsSize = kIntSize; | 
| + | 
| + static const int kCountersSmiTagSize = 0; | 
| + static const int kCountersSize = kIntSize; | 
| #endif | 
| STATIC_ASSERT(SharedFunctionInfo::kCompilerHintsCount <= | 
| SharedFunctionInfo::kCompilerHintsSize * kBitsPerByte); | 
| + STATIC_ASSERT(SharedFunctionInfo::kCountersSizeInBits <= | 
| + SharedFunctionInfo::kCountersSize * kBitsPerByte); | 
| public: | 
| // Constants for optimizing codegen for strict mode function and | 
| // native tests. |