| OLD | NEW |
| 1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 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 24 matching lines...) Expand all Loading... |
| 35 | 35 |
| 36 | 36 |
| 37 namespace v8 { | 37 namespace v8 { |
| 38 namespace internal { | 38 namespace internal { |
| 39 | 39 |
| 40 class FrameDescription; | 40 class FrameDescription; |
| 41 class TranslationIterator; | 41 class TranslationIterator; |
| 42 class DeoptimizingCodeListNode; | 42 class DeoptimizingCodeListNode; |
| 43 | 43 |
| 44 | 44 |
| 45 class ValueDescription BASE_EMBEDDED { | 45 class HeapNumberMaterializationDescriptor BASE_EMBEDDED { |
| 46 public: | 46 public: |
| 47 explicit ValueDescription(int index) : stack_index_(index) { } | 47 HeapNumberMaterializationDescriptor(Address slot_address, double val) |
| 48 int stack_index() const { return stack_index_; } | 48 : slot_address_(slot_address), val_(val) { } |
| 49 |
| 50 Address slot_address() const { return slot_address_; } |
| 51 double value() const { return val_; } |
| 49 | 52 |
| 50 private: | 53 private: |
| 51 // Offset relative to the top of the stack. | 54 Address slot_address_; |
| 52 int stack_index_; | 55 double val_; |
| 53 }; | 56 }; |
| 54 | 57 |
| 55 | 58 |
| 56 class ValueDescriptionInteger32: public ValueDescription { | |
| 57 public: | |
| 58 ValueDescriptionInteger32(int index, int32_t value) | |
| 59 : ValueDescription(index), int32_value_(value) { } | |
| 60 int32_t int32_value() const { return int32_value_; } | |
| 61 | |
| 62 private: | |
| 63 // Raw value. | |
| 64 int32_t int32_value_; | |
| 65 }; | |
| 66 | |
| 67 | |
| 68 class ValueDescriptionDouble: public ValueDescription { | |
| 69 public: | |
| 70 ValueDescriptionDouble(int index, double value) | |
| 71 : ValueDescription(index), double_value_(value) { } | |
| 72 double double_value() const { return double_value_; } | |
| 73 | |
| 74 private: | |
| 75 // Raw value. | |
| 76 double double_value_; | |
| 77 }; | |
| 78 | |
| 79 | |
| 80 class OptimizedFunctionVisitor BASE_EMBEDDED { | 59 class OptimizedFunctionVisitor BASE_EMBEDDED { |
| 81 public: | 60 public: |
| 82 virtual ~OptimizedFunctionVisitor() {} | 61 virtual ~OptimizedFunctionVisitor() {} |
| 83 | 62 |
| 84 // Function which is called before iteration of any optimized functions | 63 // Function which is called before iteration of any optimized functions |
| 85 // from given global context. | 64 // from given global context. |
| 86 virtual void EnterContext(Context* context) = 0; | 65 virtual void EnterContext(Context* context) = 0; |
| 87 | 66 |
| 88 virtual void VisitFunction(JSFunction* function) = 0; | 67 virtual void VisitFunction(JSFunction* function) = 0; |
| 89 | 68 |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 183 Code* replacement_code); | 162 Code* replacement_code); |
| 184 | 163 |
| 185 // Change all patched stack guard checks in the unoptimized code | 164 // Change all patched stack guard checks in the unoptimized code |
| 186 // back to a normal stack guard check. | 165 // back to a normal stack guard check. |
| 187 static void RevertStackCheckCodeAt(Address pc_after, | 166 static void RevertStackCheckCodeAt(Address pc_after, |
| 188 Code* check_code, | 167 Code* check_code, |
| 189 Code* replacement_code); | 168 Code* replacement_code); |
| 190 | 169 |
| 191 ~Deoptimizer(); | 170 ~Deoptimizer(); |
| 192 | 171 |
| 193 void InsertHeapNumberValues(int index, JavaScriptFrame* frame); | 172 void MaterializeHeapNumbers(); |
| 194 | 173 |
| 195 static void ComputeOutputFrames(Deoptimizer* deoptimizer); | 174 static void ComputeOutputFrames(Deoptimizer* deoptimizer); |
| 196 | 175 |
| 197 static Address GetDeoptimizationEntry(int id, BailoutType type); | 176 static Address GetDeoptimizationEntry(int id, BailoutType type); |
| 198 static int GetDeoptimizationId(Address addr, BailoutType type); | 177 static int GetDeoptimizationId(Address addr, BailoutType type); |
| 199 static int GetOutputInfo(DeoptimizationOutputData* data, | 178 static int GetOutputInfo(DeoptimizationOutputData* data, |
| 200 unsigned node_id, | 179 unsigned node_id, |
| 201 SharedFunctionInfo* shared); | 180 SharedFunctionInfo* shared); |
| 202 | 181 |
| 203 // Code generation support. | 182 // Code generation support. |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 270 int* input_offset); | 249 int* input_offset); |
| 271 | 250 |
| 272 unsigned ComputeInputFrameSize() const; | 251 unsigned ComputeInputFrameSize() const; |
| 273 unsigned ComputeFixedSize(JSFunction* function) const; | 252 unsigned ComputeFixedSize(JSFunction* function) const; |
| 274 | 253 |
| 275 unsigned ComputeIncomingArgumentSize(JSFunction* function) const; | 254 unsigned ComputeIncomingArgumentSize(JSFunction* function) const; |
| 276 unsigned ComputeOutgoingArgumentSize() const; | 255 unsigned ComputeOutgoingArgumentSize() const; |
| 277 | 256 |
| 278 Object* ComputeLiteral(int index) const; | 257 Object* ComputeLiteral(int index) const; |
| 279 | 258 |
| 280 void InsertHeapNumberValue(JavaScriptFrame* frame, | 259 void AddDoubleValue(intptr_t slot_address, double value); |
| 281 int stack_index, | |
| 282 double val, | |
| 283 int extra_slot_count); | |
| 284 | |
| 285 void AddInteger32Value(int frame_index, int slot_index, int32_t value); | |
| 286 void AddDoubleValue(int frame_index, int slot_index, double value); | |
| 287 | 260 |
| 288 static LargeObjectChunk* CreateCode(BailoutType type); | 261 static LargeObjectChunk* CreateCode(BailoutType type); |
| 289 static void GenerateDeoptimizationEntries( | 262 static void GenerateDeoptimizationEntries( |
| 290 MacroAssembler* masm, int count, BailoutType type); | 263 MacroAssembler* masm, int count, BailoutType type); |
| 291 | 264 |
| 292 // Weak handle callback for deoptimizing code objects. | 265 // Weak handle callback for deoptimizing code objects. |
| 293 static void HandleWeakDeoptimizedCode( | 266 static void HandleWeakDeoptimizedCode( |
| 294 v8::Persistent<v8::Value> obj, void* data); | 267 v8::Persistent<v8::Value> obj, void* data); |
| 295 static Code* FindDeoptimizingCodeFromAddress(Address addr); | 268 static Code* FindDeoptimizingCodeFromAddress(Address addr); |
| 296 static void RemoveDeoptimizingCode(Code* code); | 269 static void RemoveDeoptimizingCode(Code* code); |
| 297 | 270 |
| 298 Isolate* isolate_; | 271 Isolate* isolate_; |
| 299 JSFunction* function_; | 272 JSFunction* function_; |
| 300 Code* optimized_code_; | 273 Code* optimized_code_; |
| 301 unsigned bailout_id_; | 274 unsigned bailout_id_; |
| 302 BailoutType bailout_type_; | 275 BailoutType bailout_type_; |
| 303 Address from_; | 276 Address from_; |
| 304 int fp_to_sp_delta_; | 277 int fp_to_sp_delta_; |
| 305 | 278 |
| 306 // Input frame description. | 279 // Input frame description. |
| 307 FrameDescription* input_; | 280 FrameDescription* input_; |
| 308 // Number of output frames. | 281 // Number of output frames. |
| 309 int output_count_; | 282 int output_count_; |
| 310 // Array of output frame descriptions. | 283 // Array of output frame descriptions. |
| 311 FrameDescription** output_; | 284 FrameDescription** output_; |
| 312 | 285 |
| 313 List<ValueDescriptionInteger32>* integer32_values_; | 286 List<HeapNumberMaterializationDescriptor> deferred_heap_numbers_; |
| 314 List<ValueDescriptionDouble>* double_values_; | |
| 315 | 287 |
| 316 static int table_entry_size_; | 288 static int table_entry_size_; |
| 317 | 289 |
| 318 friend class FrameDescription; | 290 friend class FrameDescription; |
| 319 friend class DeoptimizingCodeListNode; | 291 friend class DeoptimizingCodeListNode; |
| 320 }; | 292 }; |
| 321 | 293 |
| 322 | 294 |
| 323 class FrameDescription { | 295 class FrameDescription { |
| 324 public: | 296 public: |
| (...skipping 295 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 620 | 592 |
| 621 static SlotRef ComputeSlotForNextArgument(TranslationIterator* iterator, | 593 static SlotRef ComputeSlotForNextArgument(TranslationIterator* iterator, |
| 622 DeoptimizationInputData* data, | 594 DeoptimizationInputData* data, |
| 623 JavaScriptFrame* frame); | 595 JavaScriptFrame* frame); |
| 624 }; | 596 }; |
| 625 | 597 |
| 626 | 598 |
| 627 } } // namespace v8::internal | 599 } } // namespace v8::internal |
| 628 | 600 |
| 629 #endif // V8_DEOPTIMIZER_H_ | 601 #endif // V8_DEOPTIMIZER_H_ |
| OLD | NEW |