Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(55)

Side by Side Diff: src/deoptimizer.h

Issue 10910161: Partial ia32 implementation of optimized try/catch (by Kevin Millikin) (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Fixed build. Created 8 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/compiler.cc ('k') | src/deoptimizer.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
69 69
70 // Function which is called after iteration of all optimized functions 70 // Function which is called after iteration of all optimized functions
71 // from given native context. 71 // from given native context.
72 virtual void LeaveContext(Context* context) = 0; 72 virtual void LeaveContext(Context* context) = 0;
73 }; 73 };
74 74
75 75
76 class Deoptimizer; 76 class Deoptimizer;
77 77
78 78
79 // Linked list holding deoptimizing code objects. The deoptimizing code objects
80 // are kept as weak handles until they are no longer activated on the stack.
81 class DeoptimizingCodeListNode : public Malloced {
82 public:
83 explicit DeoptimizingCodeListNode(Code* code);
84 ~DeoptimizingCodeListNode();
85
86 DeoptimizingCodeListNode* next() const { return next_; }
87 void set_next(DeoptimizingCodeListNode* next) { next_ = next; }
88 Handle<Code> code() const { return code_; }
89
90 private:
91 // Global (weak) handle to the deoptimizing code object.
92 Handle<Code> code_;
93
94 // Next pointer for linked list.
95 DeoptimizingCodeListNode* next_;
96 };
97
98
79 class DeoptimizerData { 99 class DeoptimizerData {
80 public: 100 public:
81 DeoptimizerData(); 101 DeoptimizerData();
82 ~DeoptimizerData(); 102 ~DeoptimizerData();
83 103
84 #ifdef ENABLE_DEBUGGER_SUPPORT 104 #ifdef ENABLE_DEBUGGER_SUPPORT
85 void Iterate(ObjectVisitor* v); 105 void Iterate(ObjectVisitor* v);
86 #endif 106 #endif
87 107
108 void append_deoptimizing_code(Code* code) {
109 DeoptimizingCodeListNode* head = new DeoptimizingCodeListNode(code);
110 head->set_next(deoptimizing_code_list_);
111 deoptimizing_code_list_ = head;
112 }
113
88 private: 114 private:
89 MemoryChunk* eager_deoptimization_entry_code_; 115 MemoryChunk* eager_deoptimization_entry_code_;
90 MemoryChunk* lazy_deoptimization_entry_code_; 116 MemoryChunk* lazy_deoptimization_entry_code_;
91 Deoptimizer* current_; 117 Deoptimizer* current_;
92 118
93 #ifdef ENABLE_DEBUGGER_SUPPORT 119 #ifdef ENABLE_DEBUGGER_SUPPORT
94 DeoptimizedFrameInfo* deoptimized_frame_info_; 120 DeoptimizedFrameInfo* deoptimized_frame_info_;
95 #endif 121 #endif
96 122
97 // List of deoptimized code which still have references from active stack 123 // List of deoptimized code which still have references from active stack
98 // frames. These code objects are needed by the deoptimizer when deoptimizing 124 // frames. These code objects are needed by the deoptimizer when deoptimizing
99 // a frame for which the code object for the function function has been 125 // a frame for which the code object for the function function has been
100 // changed from the code present when deoptimizing was done. 126 // changed from the code present when deoptimizing was done.
101 DeoptimizingCodeListNode* deoptimizing_code_list_; 127 DeoptimizingCodeListNode* deoptimizing_code_list_;
102 128
103 friend class Deoptimizer; 129 friend class Deoptimizer;
130 friend class Isolate;
104 131
105 DISALLOW_COPY_AND_ASSIGN(DeoptimizerData); 132 DISALLOW_COPY_AND_ASSIGN(DeoptimizerData);
106 }; 133 };
107 134
108 135
109 class Deoptimizer : public Malloced { 136 class Deoptimizer : public Malloced {
110 public: 137 public:
111 enum BailoutType { 138 enum BailoutType {
112 EAGER, 139 EAGER,
113 LAZY, 140 LAZY,
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after
258 virtual void GeneratePrologue(); 285 virtual void GeneratePrologue();
259 286
260 private: 287 private:
261 int count() const { return count_; } 288 int count() const { return count_; }
262 289
263 int count_; 290 int count_;
264 }; 291 };
265 292
266 int ConvertJSFrameIndexToFrameIndex(int jsframe_index); 293 int ConvertJSFrameIndexToFrameIndex(int jsframe_index);
267 294
295 // Unregister a code object from lazy deoptimization.
296 static void RemoveDeoptimizingCode(Code* code);
297
268 private: 298 private:
269 static const int kNumberOfEntries = 16384; 299 static const int kNumberOfEntries = 16384;
270 300
271 Deoptimizer(Isolate* isolate, 301 Deoptimizer(Isolate* isolate,
272 JSFunction* function, 302 JSFunction* function,
273 BailoutType type, 303 BailoutType type,
274 unsigned bailout_id, 304 unsigned bailout_id,
275 Address from, 305 Address from,
276 int fp_to_sp_delta, 306 int fp_to_sp_delta,
277 Code* optimized_code); 307 Code* optimized_code);
(...skipping 17 matching lines...) Expand all
295 // (e.g., a number conversion failed) and may or may not have updated the 325 // (e.g., a number conversion failed) and may or may not have updated the
296 // input offset. 326 // input offset.
297 bool DoOsrTranslateCommand(TranslationIterator* iterator, 327 bool DoOsrTranslateCommand(TranslationIterator* iterator,
298 int* input_offset); 328 int* input_offset);
299 329
300 unsigned ComputeInputFrameSize() const; 330 unsigned ComputeInputFrameSize() const;
301 unsigned ComputeFixedSize(JSFunction* function) const; 331 unsigned ComputeFixedSize(JSFunction* function) const;
302 332
303 unsigned ComputeIncomingArgumentSize(JSFunction* function) const; 333 unsigned ComputeIncomingArgumentSize(JSFunction* function) const;
304 unsigned ComputeOutgoingArgumentSize() const; 334 unsigned ComputeOutgoingArgumentSize() const;
335 unsigned ComputeHandlersSize() const;
305 336
306 Object* ComputeLiteral(int index) const; 337 Object* ComputeLiteral(int index) const;
307 338
308 void AddDoubleValue(intptr_t slot_address, double value); 339 void AddDoubleValue(intptr_t slot_address, double value);
309 340
310 static MemoryChunk* CreateCode(BailoutType type); 341 static MemoryChunk* CreateCode(BailoutType type);
311 static void GenerateDeoptimizationEntries( 342 static void GenerateDeoptimizationEntries(
312 MacroAssembler* masm, int count, BailoutType type); 343 MacroAssembler* masm, int count, BailoutType type);
313 344
314 // Weak handle callback for deoptimizing code objects. 345 // Weak handle callback for deoptimizing code objects.
315 static void HandleWeakDeoptimizedCode( 346 static void HandleWeakDeoptimizedCode(
316 v8::Persistent<v8::Value> obj, void* data); 347 v8::Persistent<v8::Value> obj, void* data);
317 static Code* FindDeoptimizingCodeFromAddress(Address addr); 348 static Code* FindDeoptimizingCodeFromAddress(Address addr);
318 static void RemoveDeoptimizingCode(Code* code);
319 349
320 // Fill the input from from a JavaScript frame. This is used when 350 // Fill the input from from a JavaScript frame. This is used when
321 // the debugger needs to inspect an optimized frame. For normal 351 // the debugger needs to inspect an optimized frame. For normal
322 // deoptimizations the input frame is filled in generated code. 352 // deoptimizations the input frame is filled in generated code.
323 void FillInputFrame(Address tos, JavaScriptFrame* frame); 353 void FillInputFrame(Address tos, JavaScriptFrame* frame);
324 354
325 Isolate* isolate_; 355 Isolate* isolate_;
326 JSFunction* function_; 356 JSFunction* function_;
327 Code* optimized_code_; 357 Code* optimized_code_;
328 unsigned bailout_id_; 358 unsigned bailout_id_;
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after
476 } 506 }
477 507
478 static int continuation_offset() { 508 static int continuation_offset() {
479 return OFFSET_OF(FrameDescription, continuation_); 509 return OFFSET_OF(FrameDescription, continuation_);
480 } 510 }
481 511
482 static int frame_content_offset() { 512 static int frame_content_offset() {
483 return OFFSET_OF(FrameDescription, frame_content_); 513 return OFFSET_OF(FrameDescription, frame_content_);
484 } 514 }
485 515
516 unsigned frame_size() { return static_cast<unsigned>(frame_size_); }
517
486 private: 518 private:
487 static const uint32_t kZapUint32 = 0xbeeddead; 519 static const uint32_t kZapUint32 = 0xbeeddead;
488 520
489 // Frame_size_ must hold a uint32_t value. It is only a uintptr_t to 521 // Frame_size_ must hold a uint32_t value. It is only a uintptr_t to
490 // keep the variable-size array frame_content_ of type intptr_t at 522 // keep the variable-size array frame_content_ of type intptr_t at
491 // the end of the structure aligned. 523 // the end of the structure aligned.
492 uintptr_t frame_size_; // Number of bytes. 524 uintptr_t frame_size_; // Number of bytes.
493 JSFunction* function_; 525 JSFunction* function_;
494 intptr_t registers_[Register::kNumRegisters]; 526 intptr_t registers_[Register::kNumRegisters];
495 double double_registers_[DoubleRegister::kNumAllocatableRegisters]; 527 double double_registers_[DoubleRegister::kNumAllocatableRegisters];
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
587 index_(buffer->CurrentIndex()), 619 index_(buffer->CurrentIndex()),
588 zone_(zone) { 620 zone_(zone) {
589 buffer_->Add(BEGIN, zone); 621 buffer_->Add(BEGIN, zone);
590 buffer_->Add(frame_count, zone); 622 buffer_->Add(frame_count, zone);
591 buffer_->Add(jsframe_count, zone); 623 buffer_->Add(jsframe_count, zone);
592 } 624 }
593 625
594 int index() const { return index_; } 626 int index() const { return index_; }
595 627
596 // Commands. 628 // Commands.
597 void BeginJSFrame(BailoutId node_id, int literal_id, unsigned height); 629 void BeginJSFrame(BailoutId node_id,
630 int literal_id,
631 unsigned height,
632 int handler_count);
598 void BeginArgumentsAdaptorFrame(int literal_id, unsigned height); 633 void BeginArgumentsAdaptorFrame(int literal_id, unsigned height);
599 void BeginConstructStubFrame(int literal_id, unsigned height); 634 void BeginConstructStubFrame(int literal_id, unsigned height);
600 void BeginGetterStubFrame(int literal_id); 635 void BeginGetterStubFrame(int literal_id);
601 void BeginSetterStubFrame(int literal_id); 636 void BeginSetterStubFrame(int literal_id);
602 void StoreRegister(Register reg); 637 void StoreRegister(Register reg);
603 void StoreInt32Register(Register reg); 638 void StoreInt32Register(Register reg);
604 void StoreUint32Register(Register reg); 639 void StoreUint32Register(Register reg);
605 void StoreDoubleRegister(DoubleRegister reg); 640 void StoreDoubleRegister(DoubleRegister reg);
606 void StoreStackSlot(int index); 641 void StoreStackSlot(int index);
607 void StoreInt32StackSlot(int index); 642 void StoreInt32StackSlot(int index);
(...skipping 14 matching lines...) Expand all
622 // A literal id which refers to the JSFunction itself. 657 // A literal id which refers to the JSFunction itself.
623 static const int kSelfLiteralId = -239; 658 static const int kSelfLiteralId = -239;
624 659
625 private: 660 private:
626 TranslationBuffer* buffer_; 661 TranslationBuffer* buffer_;
627 int index_; 662 int index_;
628 Zone* zone_; 663 Zone* zone_;
629 }; 664 };
630 665
631 666
632 // Linked list holding deoptimizing code objects. The deoptimizing code objects
633 // are kept as weak handles until they are no longer activated on the stack.
634 class DeoptimizingCodeListNode : public Malloced {
635 public:
636 explicit DeoptimizingCodeListNode(Code* code);
637 ~DeoptimizingCodeListNode();
638
639 DeoptimizingCodeListNode* next() const { return next_; }
640 void set_next(DeoptimizingCodeListNode* next) { next_ = next; }
641 Handle<Code> code() const { return code_; }
642
643 private:
644 // Global (weak) handle to the deoptimizing code object.
645 Handle<Code> code_;
646
647 // Next pointer for linked list.
648 DeoptimizingCodeListNode* next_;
649 };
650
651
652 class SlotRef BASE_EMBEDDED { 667 class SlotRef BASE_EMBEDDED {
653 public: 668 public:
654 enum SlotRepresentation { 669 enum SlotRepresentation {
655 UNKNOWN, 670 UNKNOWN,
656 TAGGED, 671 TAGGED,
657 INT32, 672 INT32,
658 UINT32, 673 UINT32,
659 DOUBLE, 674 DOUBLE,
660 LITERAL 675 LITERAL
661 }; 676 };
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after
811 Object** expression_stack_; 826 Object** expression_stack_;
812 int source_position_; 827 int source_position_;
813 828
814 friend class Deoptimizer; 829 friend class Deoptimizer;
815 }; 830 };
816 #endif 831 #endif
817 832
818 } } // namespace v8::internal 833 } } // namespace v8::internal
819 834
820 #endif // V8_DEOPTIMIZER_H_ 835 #endif // V8_DEOPTIMIZER_H_
OLDNEW
« no previous file with comments | « src/compiler.cc ('k') | src/deoptimizer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698