OLD | NEW |
1 // Copyright 2015 the V8 project authors. All rights reserved. | 1 // Copyright 2015 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 <iosfwd> | 8 #include <iosfwd> |
9 | 9 |
10 #include "src/allocation.h" | 10 #include "src/allocation.h" |
(...skipping 4728 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4739 inline void set(int index, Smi* value); | 4739 inline void set(int index, Smi* value); |
4740 inline void set(int index, Object* value, WriteBarrierMode mode); | 4740 inline void set(int index, Object* value, WriteBarrierMode mode); |
4741 }; | 4741 }; |
4742 | 4742 |
4743 | 4743 |
4744 // HandlerTable is a fixed array containing entries for exception handlers in | 4744 // HandlerTable is a fixed array containing entries for exception handlers in |
4745 // the code object it is associated with. The tables comes in two flavors: | 4745 // the code object it is associated with. The tables comes in two flavors: |
4746 // 1) Based on ranges: Used for unoptimized code. Contains one entry per | 4746 // 1) Based on ranges: Used for unoptimized code. Contains one entry per |
4747 // exception handler and a range representing the try-block covered by that | 4747 // exception handler and a range representing the try-block covered by that |
4748 // handler. Layout looks as follows: | 4748 // handler. Layout looks as follows: |
4749 // [ range-start , range-end , handler-offset , stack-depth ] | 4749 // [ range-start , range-end , handler-offset , handler-data ] |
4750 // 2) Based on return addresses: Used for turbofanned code. Contains one entry | 4750 // 2) Based on return addresses: Used for turbofanned code. Contains one entry |
4751 // per call-site that could throw an exception. Layout looks as follows: | 4751 // per call-site that could throw an exception. Layout looks as follows: |
4752 // [ return-address-offset , handler-offset ] | 4752 // [ return-address-offset , handler-offset ] |
4753 class HandlerTable : public FixedArray { | 4753 class HandlerTable : public FixedArray { |
4754 public: | 4754 public: |
4755 // Conservative prediction whether a given handler will locally catch an | 4755 // Conservative prediction whether a given handler will locally catch an |
4756 // exception or cause a re-throw to outside the code boundary. Since this is | 4756 // exception or cause a re-throw to outside the code boundary. Since this is |
4757 // undecidable it is merely an approximation (e.g. useful for debugger). | 4757 // undecidable it is merely an approximation (e.g. useful for debugger). |
4758 enum CatchPrediction { UNCAUGHT, CAUGHT }; | 4758 enum CatchPrediction { UNCAUGHT, CAUGHT }; |
4759 | 4759 |
4760 // Getters for handler table based on ranges. | 4760 // Getters for handler table based on ranges. |
4761 inline int GetRangeStart(int index) const; | 4761 inline int GetRangeStart(int index) const; |
4762 inline int GetRangeEnd(int index) const; | 4762 inline int GetRangeEnd(int index) const; |
4763 inline int GetRangeHandler(int index) const; | 4763 inline int GetRangeHandler(int index) const; |
4764 inline int GetRangeDepth(int index) const; | 4764 inline int GetRangeData(int index) const; |
4765 | 4765 |
4766 // Setters for handler table based on ranges. | 4766 // Setters for handler table based on ranges. |
4767 inline void SetRangeStart(int index, int value); | 4767 inline void SetRangeStart(int index, int value); |
4768 inline void SetRangeEnd(int index, int value); | 4768 inline void SetRangeEnd(int index, int value); |
4769 inline void SetRangeHandler(int index, int offset, CatchPrediction pred); | 4769 inline void SetRangeHandler(int index, int offset, CatchPrediction pred); |
4770 inline void SetRangeDepth(int index, int value); | 4770 inline void SetRangeData(int index, int value); |
4771 | 4771 |
4772 // Setters for handler table based on return addresses. | 4772 // Setters for handler table based on return addresses. |
4773 inline void SetReturnOffset(int index, int value); | 4773 inline void SetReturnOffset(int index, int value); |
4774 inline void SetReturnHandler(int index, int offset, CatchPrediction pred); | 4774 inline void SetReturnHandler(int index, int offset, CatchPrediction pred); |
4775 | 4775 |
4776 // Lookup handler in a table based on ranges. | 4776 // Lookup handler in a table based on ranges. |
4777 int LookupRange(int pc_offset, int* stack_depth, CatchPrediction* prediction); | 4777 int LookupRange(int pc_offset, int* data, CatchPrediction* prediction); |
4778 | 4778 |
4779 // Lookup handler in a table based on return addresses. | 4779 // Lookup handler in a table based on return addresses. |
4780 int LookupReturn(int pc_offset, CatchPrediction* prediction); | 4780 int LookupReturn(int pc_offset, CatchPrediction* prediction); |
4781 | 4781 |
4782 // Returns the number of entries in the table. | 4782 // Returns the number of entries in the table. |
4783 inline int NumberOfRangeEntries() const; | 4783 inline int NumberOfRangeEntries() const; |
4784 | 4784 |
4785 // Returns the required length of the underlying fixed array. | 4785 // Returns the required length of the underlying fixed array. |
4786 static int LengthForRange(int entries) { return entries * kRangeEntrySize; } | 4786 static int LengthForRange(int entries) { return entries * kRangeEntrySize; } |
4787 static int LengthForReturn(int entries) { return entries * kReturnEntrySize; } | 4787 static int LengthForReturn(int entries) { return entries * kReturnEntrySize; } |
4788 | 4788 |
4789 DECLARE_CAST(HandlerTable) | 4789 DECLARE_CAST(HandlerTable) |
4790 | 4790 |
4791 #ifdef ENABLE_DISASSEMBLER | 4791 #ifdef ENABLE_DISASSEMBLER |
4792 void HandlerTableRangePrint(std::ostream& os); // NOLINT | 4792 void HandlerTableRangePrint(std::ostream& os); // NOLINT |
4793 void HandlerTableReturnPrint(std::ostream& os); // NOLINT | 4793 void HandlerTableReturnPrint(std::ostream& os); // NOLINT |
4794 #endif | 4794 #endif |
4795 | 4795 |
4796 private: | 4796 private: |
4797 // Layout description for handler table based on ranges. | 4797 // Layout description for handler table based on ranges. |
4798 static const int kRangeStartIndex = 0; | 4798 static const int kRangeStartIndex = 0; |
4799 static const int kRangeEndIndex = 1; | 4799 static const int kRangeEndIndex = 1; |
4800 static const int kRangeHandlerIndex = 2; | 4800 static const int kRangeHandlerIndex = 2; |
4801 static const int kRangeDepthIndex = 3; | 4801 static const int kRangeDataIndex = 3; |
4802 static const int kRangeEntrySize = 4; | 4802 static const int kRangeEntrySize = 4; |
4803 | 4803 |
4804 // Layout description for handler table based on return addresses. | 4804 // Layout description for handler table based on return addresses. |
4805 static const int kReturnOffsetIndex = 0; | 4805 static const int kReturnOffsetIndex = 0; |
4806 static const int kReturnHandlerIndex = 1; | 4806 static const int kReturnHandlerIndex = 1; |
4807 static const int kReturnEntrySize = 2; | 4807 static const int kReturnEntrySize = 2; |
4808 | 4808 |
4809 // Encoding of the {handler} field. | 4809 // Encoding of the {handler} field. |
4810 class HandlerPredictionField : public BitField<CatchPrediction, 0, 1> {}; | 4810 class HandlerPredictionField : public BitField<CatchPrediction, 0, 1> {}; |
4811 class HandlerOffsetField : public BitField<int, 1, 30> {}; | 4811 class HandlerOffsetField : public BitField<int, 1, 30> {}; |
(...skipping 5997 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
10809 } | 10809 } |
10810 return value; | 10810 return value; |
10811 } | 10811 } |
10812 }; | 10812 }; |
10813 | 10813 |
10814 | 10814 |
10815 } // NOLINT, false-positive due to second-order macros. | 10815 } // NOLINT, false-positive due to second-order macros. |
10816 } // NOLINT, false-positive due to second-order macros. | 10816 } // NOLINT, false-positive due to second-order macros. |
10817 | 10817 |
10818 #endif // V8_OBJECTS_H_ | 10818 #endif // V8_OBJECTS_H_ |
OLD | NEW |