| OLD | NEW |
| 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 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 93 | 93 |
| 94 virtual bool TakeFunction(JSFunction* function) = 0; | 94 virtual bool TakeFunction(JSFunction* function) = 0; |
| 95 }; | 95 }; |
| 96 | 96 |
| 97 | 97 |
| 98 class Deoptimizer; | 98 class Deoptimizer; |
| 99 | 99 |
| 100 | 100 |
| 101 class DeoptimizerData { | 101 class DeoptimizerData { |
| 102 public: | 102 public: |
| 103 DeoptimizerData(); | 103 explicit DeoptimizerData(MemoryAllocator* allocator); |
| 104 ~DeoptimizerData(); | 104 ~DeoptimizerData(); |
| 105 | 105 |
| 106 #ifdef ENABLE_DEBUGGER_SUPPORT | 106 #ifdef ENABLE_DEBUGGER_SUPPORT |
| 107 void Iterate(ObjectVisitor* v); | 107 void Iterate(ObjectVisitor* v); |
| 108 #endif | 108 #endif |
| 109 | 109 |
| 110 Code* FindDeoptimizingCode(Address addr); | 110 Code* FindDeoptimizingCode(Address addr); |
| 111 void RemoveDeoptimizingCode(Code* code); | 111 void RemoveDeoptimizingCode(Code* code); |
| 112 | 112 |
| 113 private: | 113 private: |
| 114 MemoryAllocator* allocator_; |
| 114 int eager_deoptimization_entry_code_entries_; | 115 int eager_deoptimization_entry_code_entries_; |
| 115 int lazy_deoptimization_entry_code_entries_; | 116 int lazy_deoptimization_entry_code_entries_; |
| 116 MemoryChunk* eager_deoptimization_entry_code_; | 117 MemoryChunk* eager_deoptimization_entry_code_; |
| 117 MemoryChunk* lazy_deoptimization_entry_code_; | 118 MemoryChunk* lazy_deoptimization_entry_code_; |
| 118 Deoptimizer* current_; | 119 Deoptimizer* current_; |
| 119 | 120 |
| 120 #ifdef ENABLE_DEBUGGER_SUPPORT | 121 #ifdef ENABLE_DEBUGGER_SUPPORT |
| 121 DeoptimizedFrameInfo* deoptimized_frame_info_; | 122 DeoptimizedFrameInfo* deoptimized_frame_info_; |
| 122 #endif | 123 #endif |
| 123 | 124 |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 183 // Deoptimize the function now. Its current optimized code will never be run | 184 // Deoptimize the function now. Its current optimized code will never be run |
| 184 // again and any activations of the optimized code will get deoptimized when | 185 // again and any activations of the optimized code will get deoptimized when |
| 185 // execution returns. | 186 // execution returns. |
| 186 static void DeoptimizeFunction(JSFunction* function); | 187 static void DeoptimizeFunction(JSFunction* function); |
| 187 | 188 |
| 188 // Iterate over all the functions which share the same code object | 189 // Iterate over all the functions which share the same code object |
| 189 // and make them use unoptimized version. | 190 // and make them use unoptimized version. |
| 190 static void ReplaceCodeForRelatedFunctions(JSFunction* function, Code* code); | 191 static void ReplaceCodeForRelatedFunctions(JSFunction* function, Code* code); |
| 191 | 192 |
| 192 // Deoptimize all functions in the heap. | 193 // Deoptimize all functions in the heap. |
| 193 static void DeoptimizeAll(); | 194 static void DeoptimizeAll(Isolate* isolate); |
| 194 | 195 |
| 195 static void DeoptimizeGlobalObject(JSObject* object); | 196 static void DeoptimizeGlobalObject(JSObject* object); |
| 196 | 197 |
| 197 static void DeoptimizeAllFunctionsWith(OptimizedFunctionFilter* filter); | 198 static void DeoptimizeAllFunctionsWith(Isolate* isolate, |
| 199 OptimizedFunctionFilter* filter); |
| 198 | 200 |
| 199 static void DeoptimizeAllFunctionsForContext( | 201 static void DeoptimizeAllFunctionsForContext( |
| 200 Context* context, OptimizedFunctionFilter* filter); | 202 Context* context, OptimizedFunctionFilter* filter); |
| 201 | 203 |
| 202 static void VisitAllOptimizedFunctionsForContext( | 204 static void VisitAllOptimizedFunctionsForContext( |
| 203 Context* context, OptimizedFunctionVisitor* visitor); | 205 Context* context, OptimizedFunctionVisitor* visitor); |
| 204 | 206 |
| 205 static void VisitAllOptimizedFunctions(OptimizedFunctionVisitor* visitor); | 207 static void VisitAllOptimizedFunctions(Isolate* isolate, |
| 208 OptimizedFunctionVisitor* visitor); |
| 206 | 209 |
| 207 // The size in bytes of the code required at a lazy deopt patch site. | 210 // The size in bytes of the code required at a lazy deopt patch site. |
| 208 static int patch_size(); | 211 static int patch_size(); |
| 209 | 212 |
| 210 // Patch all stack guard checks in the unoptimized code to | 213 // Patch all stack guard checks in the unoptimized code to |
| 211 // unconditionally call replacement_code. | 214 // unconditionally call replacement_code. |
| 212 static void PatchStackCheckCode(Code* unoptimized_code, | 215 static void PatchStackCheckCode(Code* unoptimized_code, |
| 213 Code* check_code, | 216 Code* check_code, |
| 214 Code* replacement_code); | 217 Code* replacement_code); |
| 215 | 218 |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 252 CALCULATE_ENTRY_ADDRESS, | 255 CALCULATE_ENTRY_ADDRESS, |
| 253 ENSURE_ENTRY_CODE | 256 ENSURE_ENTRY_CODE |
| 254 }; | 257 }; |
| 255 | 258 |
| 256 | 259 |
| 257 static Address GetDeoptimizationEntry( | 260 static Address GetDeoptimizationEntry( |
| 258 Isolate* isolate, | 261 Isolate* isolate, |
| 259 int id, | 262 int id, |
| 260 BailoutType type, | 263 BailoutType type, |
| 261 GetEntryMode mode = ENSURE_ENTRY_CODE); | 264 GetEntryMode mode = ENSURE_ENTRY_CODE); |
| 262 static int GetDeoptimizationId(Address addr, BailoutType type); | 265 static int GetDeoptimizationId(Isolate* isolate, |
| 266 Address addr, |
| 267 BailoutType type); |
| 263 static int GetOutputInfo(DeoptimizationOutputData* data, | 268 static int GetOutputInfo(DeoptimizationOutputData* data, |
| 264 BailoutId node_id, | 269 BailoutId node_id, |
| 265 SharedFunctionInfo* shared); | 270 SharedFunctionInfo* shared); |
| 266 | 271 |
| 267 // Code generation support. | 272 // Code generation support. |
| 268 static int input_offset() { return OFFSET_OF(Deoptimizer, input_); } | 273 static int input_offset() { return OFFSET_OF(Deoptimizer, input_); } |
| 269 static int output_count_offset() { | 274 static int output_count_offset() { |
| 270 return OFFSET_OF(Deoptimizer, output_count_); | 275 return OFFSET_OF(Deoptimizer, output_count_); |
| 271 } | 276 } |
| 272 static int output_offset() { return OFFSET_OF(Deoptimizer, output_); } | 277 static int output_offset() { return OFFSET_OF(Deoptimizer, output_); } |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 314 }; | 319 }; |
| 315 | 320 |
| 316 int ConvertJSFrameIndexToFrameIndex(int jsframe_index); | 321 int ConvertJSFrameIndexToFrameIndex(int jsframe_index); |
| 317 | 322 |
| 318 static size_t GetMaxDeoptTableSize(); | 323 static size_t GetMaxDeoptTableSize(); |
| 319 | 324 |
| 320 static void EnsureCodeForDeoptimizationEntry(Isolate* isolate, | 325 static void EnsureCodeForDeoptimizationEntry(Isolate* isolate, |
| 321 BailoutType type, | 326 BailoutType type, |
| 322 int max_entry_id); | 327 int max_entry_id); |
| 323 | 328 |
| 329 Isolate* isolate() const { return isolate_; } |
| 330 |
| 324 private: | 331 private: |
| 325 static const int kMinNumberOfEntries = 64; | 332 static const int kMinNumberOfEntries = 64; |
| 326 static const int kMaxNumberOfEntries = 16384; | 333 static const int kMaxNumberOfEntries = 16384; |
| 327 | 334 |
| 328 Deoptimizer(Isolate* isolate, | 335 Deoptimizer(Isolate* isolate, |
| 329 JSFunction* function, | 336 JSFunction* function, |
| 330 BailoutType type, | 337 BailoutType type, |
| 331 unsigned bailout_id, | 338 unsigned bailout_id, |
| 332 Address from, | 339 Address from, |
| 333 int fp_to_sp_delta, | 340 int fp_to_sp_delta, |
| (...skipping 263 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 597 }; | 604 }; |
| 598 | 605 |
| 599 | 606 |
| 600 class TranslationBuffer BASE_EMBEDDED { | 607 class TranslationBuffer BASE_EMBEDDED { |
| 601 public: | 608 public: |
| 602 explicit TranslationBuffer(Zone* zone) : contents_(256, zone) { } | 609 explicit TranslationBuffer(Zone* zone) : contents_(256, zone) { } |
| 603 | 610 |
| 604 int CurrentIndex() const { return contents_.length(); } | 611 int CurrentIndex() const { return contents_.length(); } |
| 605 void Add(int32_t value, Zone* zone); | 612 void Add(int32_t value, Zone* zone); |
| 606 | 613 |
| 607 Handle<ByteArray> CreateByteArray(); | 614 Handle<ByteArray> CreateByteArray(Factory* factory); |
| 608 | 615 |
| 609 private: | 616 private: |
| 610 ZoneList<uint8_t> contents_; | 617 ZoneList<uint8_t> contents_; |
| 611 }; | 618 }; |
| 612 | 619 |
| 613 | 620 |
| 614 class TranslationIterator BASE_EMBEDDED { | 621 class TranslationIterator BASE_EMBEDDED { |
| 615 public: | 622 public: |
| 616 TranslationIterator(ByteArray* buffer, int index) | 623 TranslationIterator(ByteArray* buffer, int index) |
| 617 : buffer_(buffer), index_(index) { | 624 : buffer_(buffer), index_(index) { |
| (...skipping 270 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 888 Object** expression_stack_; | 895 Object** expression_stack_; |
| 889 int source_position_; | 896 int source_position_; |
| 890 | 897 |
| 891 friend class Deoptimizer; | 898 friend class Deoptimizer; |
| 892 }; | 899 }; |
| 893 #endif | 900 #endif |
| 894 | 901 |
| 895 } } // namespace v8::internal | 902 } } // namespace v8::internal |
| 896 | 903 |
| 897 #endif // V8_DEOPTIMIZER_H_ | 904 #endif // V8_DEOPTIMIZER_H_ |
| OLD | NEW |