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 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
128 EAGER, | 128 EAGER, |
129 LAZY, | 129 LAZY, |
130 OSR, | 130 OSR, |
131 // This last bailout type is not really a bailout, but used by the | 131 // This last bailout type is not really a bailout, but used by the |
132 // debugger to deoptimize stack frames to allow inspection. | 132 // debugger to deoptimize stack frames to allow inspection. |
133 DEBUGGER | 133 DEBUGGER |
134 }; | 134 }; |
135 | 135 |
136 int output_count() const { return output_count_; } | 136 int output_count() const { return output_count_; } |
137 | 137 |
| 138 Code::Kind compiled_code_kind() const { return compiled_code_->kind(); } |
| 139 |
138 // Number of created JS frames. Not all created frames are necessarily JS. | 140 // Number of created JS frames. Not all created frames are necessarily JS. |
139 int jsframe_count() const { return jsframe_count_; } | 141 int jsframe_count() const { return jsframe_count_; } |
140 | 142 |
141 static Deoptimizer* New(JSFunction* function, | 143 static Deoptimizer* New(JSFunction* function, |
142 BailoutType type, | 144 BailoutType type, |
143 unsigned bailout_id, | 145 unsigned bailout_id, |
144 Address from, | 146 Address from, |
145 int fp_to_sp_delta, | 147 int fp_to_sp_delta, |
146 Isolate* isolate); | 148 Isolate* isolate); |
147 static Deoptimizer* Grab(Isolate* isolate); | 149 static Deoptimizer* Grab(Isolate* isolate); |
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
290 private: | 292 private: |
291 int count() const { return count_; } | 293 int count() const { return count_; } |
292 | 294 |
293 int count_; | 295 int count_; |
294 }; | 296 }; |
295 | 297 |
296 int ConvertJSFrameIndexToFrameIndex(int jsframe_index); | 298 int ConvertJSFrameIndexToFrameIndex(int jsframe_index); |
297 | 299 |
298 static size_t GetMaxDeoptTableSize(); | 300 static size_t GetMaxDeoptTableSize(); |
299 | 301 |
| 302 static void EnsureCodeForDeoptimizationEntry(BailoutType type, |
| 303 int max_entry_id); |
| 304 |
300 private: | 305 private: |
301 static const int kMinNumberOfEntries = 64; | 306 static const int kMinNumberOfEntries = 64; |
302 static const int kMaxNumberOfEntries = 16384; | 307 static const int kMaxNumberOfEntries = 16384; |
303 | 308 |
304 Deoptimizer(Isolate* isolate, | 309 Deoptimizer(Isolate* isolate, |
305 JSFunction* function, | 310 JSFunction* function, |
306 BailoutType type, | 311 BailoutType type, |
307 unsigned bailout_id, | 312 unsigned bailout_id, |
308 Address from, | 313 Address from, |
309 int fp_to_sp_delta, | 314 int fp_to_sp_delta, |
310 Code* optimized_code); | 315 Code* optimized_code); |
311 void DeleteFrameDescriptions(); | 316 void DeleteFrameDescriptions(); |
312 | 317 |
313 void DoComputeOutputFrames(); | 318 void DoComputeOutputFrames(); |
314 void DoComputeOsrOutputFrame(); | 319 void DoComputeOsrOutputFrame(); |
315 void DoComputeJSFrame(TranslationIterator* iterator, int frame_index); | 320 void DoComputeJSFrame(TranslationIterator* iterator, int frame_index); |
316 void DoComputeArgumentsAdaptorFrame(TranslationIterator* iterator, | 321 void DoComputeArgumentsAdaptorFrame(TranslationIterator* iterator, |
317 int frame_index); | 322 int frame_index); |
318 void DoComputeConstructStubFrame(TranslationIterator* iterator, | 323 void DoComputeConstructStubFrame(TranslationIterator* iterator, |
319 int frame_index); | 324 int frame_index); |
320 void DoComputeAccessorStubFrame(TranslationIterator* iterator, | 325 void DoComputeAccessorStubFrame(TranslationIterator* iterator, |
321 int frame_index, | 326 int frame_index, |
322 bool is_setter_stub_frame); | 327 bool is_setter_stub_frame); |
| 328 void DoCompiledStubFrame(TranslationIterator* iterator, |
| 329 int frame_index); |
323 void DoTranslateCommand(TranslationIterator* iterator, | 330 void DoTranslateCommand(TranslationIterator* iterator, |
324 int frame_index, | 331 int frame_index, |
325 unsigned output_offset); | 332 unsigned output_offset); |
326 // Translate a command for OSR. Updates the input offset to be used for | 333 // Translate a command for OSR. Updates the input offset to be used for |
327 // the next command. Returns false if translation of the command failed | 334 // the next command. Returns false if translation of the command failed |
328 // (e.g., a number conversion failed) and may or may not have updated the | 335 // (e.g., a number conversion failed) and may or may not have updated the |
329 // input offset. | 336 // input offset. |
330 bool DoOsrTranslateCommand(TranslationIterator* iterator, | 337 bool DoOsrTranslateCommand(TranslationIterator* iterator, |
331 int* input_offset); | 338 int* input_offset); |
332 | 339 |
333 unsigned ComputeInputFrameSize() const; | 340 unsigned ComputeInputFrameSize() const; |
334 unsigned ComputeFixedSize(JSFunction* function) const; | 341 unsigned ComputeFixedSize(JSFunction* function) const; |
335 | 342 |
336 unsigned ComputeIncomingArgumentSize(JSFunction* function) const; | 343 unsigned ComputeIncomingArgumentSize(JSFunction* function) const; |
337 unsigned ComputeOutgoingArgumentSize() const; | 344 unsigned ComputeOutgoingArgumentSize() const; |
338 | 345 |
339 Object* ComputeLiteral(int index) const; | 346 Object* ComputeLiteral(int index) const; |
340 | 347 |
341 void AddArgumentsObject(intptr_t slot_address, int argc); | 348 void AddArgumentsObject(intptr_t slot_address, int argc); |
342 void AddArgumentsObjectValue(intptr_t value); | 349 void AddArgumentsObjectValue(intptr_t value); |
343 void AddDoubleValue(intptr_t slot_address, double value); | 350 void AddDoubleValue(intptr_t slot_address, double value); |
344 | 351 |
345 static void EnsureCodeForDeoptimizationEntry(BailoutType type, | |
346 int max_entry_id); | |
347 static void GenerateDeoptimizationEntries( | 352 static void GenerateDeoptimizationEntries( |
348 MacroAssembler* masm, int count, BailoutType type); | 353 MacroAssembler* masm, int count, BailoutType type); |
349 | 354 |
350 // Weak handle callback for deoptimizing code objects. | 355 // Weak handle callback for deoptimizing code objects. |
351 static void HandleWeakDeoptimizedCode( | 356 static void HandleWeakDeoptimizedCode( |
352 v8::Persistent<v8::Value> obj, void* data); | 357 v8::Persistent<v8::Value> obj, void* data); |
353 static Code* FindDeoptimizingCodeFromAddress(Address addr); | 358 static Code* FindDeoptimizingCodeFromAddress(Address addr); |
354 static void RemoveDeoptimizingCode(Code* code); | 359 static void RemoveDeoptimizingCode(Code* code); |
355 | 360 |
356 // Fill the input from from a JavaScript frame. This is used when | 361 // Fill the input from from a JavaScript frame. This is used when |
357 // the debugger needs to inspect an optimized frame. For normal | 362 // the debugger needs to inspect an optimized frame. For normal |
358 // deoptimizations the input frame is filled in generated code. | 363 // deoptimizations the input frame is filled in generated code. |
359 void FillInputFrame(Address tos, JavaScriptFrame* frame); | 364 void FillInputFrame(Address tos, JavaScriptFrame* frame); |
360 | 365 |
361 Isolate* isolate_; | 366 Isolate* isolate_; |
362 JSFunction* function_; | 367 JSFunction* function_; |
363 Code* optimized_code_; | 368 Code* compiled_code_; |
364 unsigned bailout_id_; | 369 unsigned bailout_id_; |
365 BailoutType bailout_type_; | 370 BailoutType bailout_type_; |
366 Address from_; | 371 Address from_; |
367 int fp_to_sp_delta_; | 372 int fp_to_sp_delta_; |
368 int has_alignment_padding_; | 373 int has_alignment_padding_; |
369 | 374 |
370 // Input frame description. | 375 // Input frame description. |
371 FrameDescription* input_; | 376 FrameDescription* input_; |
372 // Number of output frames. | 377 // Number of output frames. |
373 int output_count_; | 378 int output_count_; |
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
523 | 528 |
524 private: | 529 private: |
525 static const uint32_t kZapUint32 = 0xbeeddead; | 530 static const uint32_t kZapUint32 = 0xbeeddead; |
526 | 531 |
527 // Frame_size_ must hold a uint32_t value. It is only a uintptr_t to | 532 // Frame_size_ must hold a uint32_t value. It is only a uintptr_t to |
528 // keep the variable-size array frame_content_ of type intptr_t at | 533 // keep the variable-size array frame_content_ of type intptr_t at |
529 // the end of the structure aligned. | 534 // the end of the structure aligned. |
530 uintptr_t frame_size_; // Number of bytes. | 535 uintptr_t frame_size_; // Number of bytes. |
531 JSFunction* function_; | 536 JSFunction* function_; |
532 intptr_t registers_[Register::kNumRegisters]; | 537 intptr_t registers_[Register::kNumRegisters]; |
533 double double_registers_[DoubleRegister::kNumAllocatableRegisters]; | 538 double double_registers_[DoubleRegister::kMaxNumAllocatableRegisters]; |
534 intptr_t top_; | 539 intptr_t top_; |
535 intptr_t pc_; | 540 intptr_t pc_; |
536 intptr_t fp_; | 541 intptr_t fp_; |
537 intptr_t context_; | 542 intptr_t context_; |
538 StackFrame::Type type_; | 543 StackFrame::Type type_; |
539 Smi* state_; | 544 Smi* state_; |
540 #ifdef DEBUG | 545 #ifdef DEBUG |
541 Code::Kind kind_; | 546 Code::Kind kind_; |
542 #endif | 547 #endif |
543 | 548 |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
596 | 601 |
597 class Translation BASE_EMBEDDED { | 602 class Translation BASE_EMBEDDED { |
598 public: | 603 public: |
599 enum Opcode { | 604 enum Opcode { |
600 BEGIN, | 605 BEGIN, |
601 JS_FRAME, | 606 JS_FRAME, |
602 CONSTRUCT_STUB_FRAME, | 607 CONSTRUCT_STUB_FRAME, |
603 GETTER_STUB_FRAME, | 608 GETTER_STUB_FRAME, |
604 SETTER_STUB_FRAME, | 609 SETTER_STUB_FRAME, |
605 ARGUMENTS_ADAPTOR_FRAME, | 610 ARGUMENTS_ADAPTOR_FRAME, |
| 611 COMPILED_STUB_FRAME, |
606 REGISTER, | 612 REGISTER, |
607 INT32_REGISTER, | 613 INT32_REGISTER, |
608 UINT32_REGISTER, | 614 UINT32_REGISTER, |
609 DOUBLE_REGISTER, | 615 DOUBLE_REGISTER, |
610 STACK_SLOT, | 616 STACK_SLOT, |
611 INT32_STACK_SLOT, | 617 INT32_STACK_SLOT, |
612 UINT32_STACK_SLOT, | 618 UINT32_STACK_SLOT, |
613 DOUBLE_STACK_SLOT, | 619 DOUBLE_STACK_SLOT, |
614 LITERAL, | 620 LITERAL, |
615 ARGUMENTS_OBJECT, | 621 ARGUMENTS_OBJECT, |
(...skipping 10 matching lines...) Expand all Loading... |
626 zone_(zone) { | 632 zone_(zone) { |
627 buffer_->Add(BEGIN, zone); | 633 buffer_->Add(BEGIN, zone); |
628 buffer_->Add(frame_count, zone); | 634 buffer_->Add(frame_count, zone); |
629 buffer_->Add(jsframe_count, zone); | 635 buffer_->Add(jsframe_count, zone); |
630 } | 636 } |
631 | 637 |
632 int index() const { return index_; } | 638 int index() const { return index_; } |
633 | 639 |
634 // Commands. | 640 // Commands. |
635 void BeginJSFrame(BailoutId node_id, int literal_id, unsigned height); | 641 void BeginJSFrame(BailoutId node_id, int literal_id, unsigned height); |
| 642 void BeginCompiledStubFrame(); |
636 void BeginArgumentsAdaptorFrame(int literal_id, unsigned height); | 643 void BeginArgumentsAdaptorFrame(int literal_id, unsigned height); |
637 void BeginConstructStubFrame(int literal_id, unsigned height); | 644 void BeginConstructStubFrame(int literal_id, unsigned height); |
638 void BeginGetterStubFrame(int literal_id); | 645 void BeginGetterStubFrame(int literal_id); |
639 void BeginSetterStubFrame(int literal_id); | 646 void BeginSetterStubFrame(int literal_id); |
640 void StoreRegister(Register reg); | 647 void StoreRegister(Register reg); |
641 void StoreInt32Register(Register reg); | 648 void StoreInt32Register(Register reg); |
642 void StoreUint32Register(Register reg); | 649 void StoreUint32Register(Register reg); |
643 void StoreDoubleRegister(DoubleRegister reg); | 650 void StoreDoubleRegister(DoubleRegister reg); |
644 void StoreStackSlot(int index); | 651 void StoreStackSlot(int index); |
645 void StoreInt32StackSlot(int index); | 652 void StoreInt32StackSlot(int index); |
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
849 Object** expression_stack_; | 856 Object** expression_stack_; |
850 int source_position_; | 857 int source_position_; |
851 | 858 |
852 friend class Deoptimizer; | 859 friend class Deoptimizer; |
853 }; | 860 }; |
854 #endif | 861 #endif |
855 | 862 |
856 } } // namespace v8::internal | 863 } } // namespace v8::internal |
857 | 864 |
858 #endif // V8_DEOPTIMIZER_H_ | 865 #endif // V8_DEOPTIMIZER_H_ |
OLD | NEW |