| 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 #ifndef V8_OBJECTS_H_ | 5 #ifndef V8_OBJECTS_H_ |
| 6 #define V8_OBJECTS_H_ | 6 #define V8_OBJECTS_H_ |
| 7 | 7 |
| 8 #include "allocation.h" | 8 #include "allocation.h" |
| 9 #include "assert-scope.h" | 9 #include "assert-scope.h" |
| 10 #include "builtins.h" | 10 #include "builtins.h" |
| (...skipping 5207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5218 private: | 5218 private: |
| 5219 static int IndexForEntry(int i) { | 5219 static int IndexForEntry(int i) { |
| 5220 return kFirstDeoptEntryIndex + (i * kDeoptEntrySize); | 5220 return kFirstDeoptEntryIndex + (i * kDeoptEntrySize); |
| 5221 } | 5221 } |
| 5222 | 5222 |
| 5223 static int LengthFor(int entry_count) { | 5223 static int LengthFor(int entry_count) { |
| 5224 return IndexForEntry(entry_count); | 5224 return IndexForEntry(entry_count); |
| 5225 } | 5225 } |
| 5226 }; | 5226 }; |
| 5227 | 5227 |
| 5228 #if (defined(DEBUG) || defined(VERIFY_STACK_HEIGHT)) && V8_TARGET_ARCH_IA32 |
| 5229 #define COMPARE_OPT_STACK_HEIGHT |
| 5230 #endif |
| 5228 | 5231 |
| 5229 // DeoptimizationOutputData is a fixed array used to hold the deoptimization | 5232 // DeoptimizationOutputData is a fixed array used to hold the deoptimization |
| 5230 // data for code generated by the full compiler. | 5233 // data for code generated by the full compiler. |
| 5231 // The format of the these objects is | 5234 // The format of the these objects in release mode is |
| 5232 // [i * 2]: Ast ID for ith deoptimization. | 5235 // [i * 2]: Ast ID for ith deoptimization. |
| 5233 // [i * 2 + 1]: PC and state of ith deoptimization | 5236 // [i * 2 + 1]: PC and state of ith deoptimization |
| 5237 // In debug mode, we use 3 slots per deopt point, with the stack height |
| 5238 // information at [i * 3 + 2] slots |
| 5234 class DeoptimizationOutputData: public FixedArray { | 5239 class DeoptimizationOutputData: public FixedArray { |
| 5235 public: | 5240 public: |
| 5236 int DeoptPoints() { return length() / 2; } | 5241 #if defined(COMPARE_OPT_STACK_HEIGHT) |
| 5242 static const int kDeoptPointElementCount = 3; |
| 5243 |
| 5244 Smi* StackHeight(int index) { |
| 5245 return Smi::cast(get(2 + index * kDeoptPointElementCount)); |
| 5246 } |
| 5247 |
| 5248 void SetStackHeight(int index, Smi* stack_height) { |
| 5249 set(2 + index * kDeoptPointElementCount, stack_height); |
| 5250 } |
| 5251 |
| 5252 #else |
| 5253 static const int kDeoptPointElementCount = 2; |
| 5254 #endif |
| 5255 |
| 5256 int DeoptPoints() { return length() / kDeoptPointElementCount; } |
| 5237 | 5257 |
| 5238 BailoutId AstId(int index) { | 5258 BailoutId AstId(int index) { |
| 5239 return BailoutId(Smi::cast(get(index * 2))->value()); | 5259 return BailoutId(Smi::cast(get(index * kDeoptPointElementCount))->value()); |
| 5240 } | 5260 } |
| 5241 | 5261 |
| 5242 void SetAstId(int index, BailoutId id) { | 5262 void SetAstId(int index, BailoutId id) { |
| 5243 set(index * 2, Smi::FromInt(id.ToInt())); | 5263 set(index * kDeoptPointElementCount, Smi::FromInt(id.ToInt())); |
| 5244 } | 5264 } |
| 5245 | 5265 |
| 5246 Smi* PcAndState(int index) { return Smi::cast(get(1 + index * 2)); } | 5266 Smi* PcAndState(int index) { |
| 5247 void SetPcAndState(int index, Smi* offset) { set(1 + index * 2, offset); } | 5267 return Smi::cast(get(1 + index * kDeoptPointElementCount)); |
| 5268 } |
| 5269 |
| 5270 void SetPcAndState(int index, Smi* offset) { |
| 5271 set(1 + index * kDeoptPointElementCount, offset); |
| 5272 } |
| 5248 | 5273 |
| 5249 static int LengthOfFixedArray(int deopt_points) { | 5274 static int LengthOfFixedArray(int deopt_points) { |
| 5250 return deopt_points * 2; | 5275 return deopt_points * kDeoptPointElementCount; |
| 5251 } | 5276 } |
| 5252 | 5277 |
| 5253 // Allocates a DeoptimizationOutputData. | 5278 // Allocates a DeoptimizationOutputData. |
| 5254 static Handle<DeoptimizationOutputData> New(Isolate* isolate, | 5279 static Handle<DeoptimizationOutputData> New(Isolate* isolate, |
| 5255 int number_of_deopt_points, | 5280 int number_of_deopt_points, |
| 5256 PretenureFlag pretenure); | 5281 PretenureFlag pretenure); |
| 5257 | 5282 |
| 5258 // Casting. | 5283 // Casting. |
| 5259 static inline DeoptimizationOutputData* cast(Object* obj); | 5284 static inline DeoptimizationOutputData* cast(Object* obj); |
| 5260 | 5285 |
| (...skipping 1947 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7208 // shared function info. | 7233 // shared function info. |
| 7209 void DisableOptimization(BailoutReason reason); | 7234 void DisableOptimization(BailoutReason reason); |
| 7210 | 7235 |
| 7211 inline BailoutReason DisableOptimizationReason(); | 7236 inline BailoutReason DisableOptimizationReason(); |
| 7212 | 7237 |
| 7213 // Lookup the bailout ID and ASSERT that it exists in the non-optimized | 7238 // Lookup the bailout ID and ASSERT that it exists in the non-optimized |
| 7214 // code, returns whether it asserted (i.e., always true if assertions are | 7239 // code, returns whether it asserted (i.e., always true if assertions are |
| 7215 // disabled). | 7240 // disabled). |
| 7216 bool VerifyBailoutId(BailoutId id); | 7241 bool VerifyBailoutId(BailoutId id); |
| 7217 | 7242 |
| 7243 #if defined(COMPARE_OPT_STACK_HEIGHT) |
| 7244 // Get expected stack height after deoptimization |
| 7245 int GetExpectedStackHeight(BailoutId id); |
| 7246 #endif |
| 7247 |
| 7218 // [source code]: Source code for the function. | 7248 // [source code]: Source code for the function. |
| 7219 bool HasSourceCode(); | 7249 bool HasSourceCode(); |
| 7220 Handle<Object> GetSourceCode(); | 7250 Handle<Object> GetSourceCode(); |
| 7221 | 7251 |
| 7222 // Number of times the function was optimized. | 7252 // Number of times the function was optimized. |
| 7223 inline int opt_count(); | 7253 inline int opt_count(); |
| 7224 inline void set_opt_count(int opt_count); | 7254 inline void set_opt_count(int opt_count); |
| 7225 | 7255 |
| 7226 // Number of times the function was deoptimized. | 7256 // Number of times the function was deoptimized. |
| 7227 inline void set_deopt_count(int value); | 7257 inline void set_deopt_count(int value); |
| (...skipping 3882 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 11110 } else { | 11140 } else { |
| 11111 value &= ~(1 << bit_position); | 11141 value &= ~(1 << bit_position); |
| 11112 } | 11142 } |
| 11113 return value; | 11143 return value; |
| 11114 } | 11144 } |
| 11115 }; | 11145 }; |
| 11116 | 11146 |
| 11117 } } // namespace v8::internal | 11147 } } // namespace v8::internal |
| 11118 | 11148 |
| 11119 #endif // V8_OBJECTS_H_ | 11149 #endif // V8_OBJECTS_H_ |
| OLD | NEW |