OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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 5141 matching lines...) Loading... |
5152 // the code object it is associated with. The tables comes in two flavors: | 5152 // the code object it is associated with. The tables comes in two flavors: |
5153 // 1) Based on ranges: Used for unoptimized code. Contains one entry per | 5153 // 1) Based on ranges: Used for unoptimized code. Contains one entry per |
5154 // exception handler and a range representing the try-block covered by that | 5154 // exception handler and a range representing the try-block covered by that |
5155 // handler. Layout looks as follows: | 5155 // handler. Layout looks as follows: |
5156 // [ range-start , range-end , handler-offset , stack-depth ] | 5156 // [ range-start , range-end , handler-offset , stack-depth ] |
5157 // 2) Based on return addresses: Used for turbofanned code. Contains one entry | 5157 // 2) Based on return addresses: Used for turbofanned code. Contains one entry |
5158 // per call-site that could throw an exception. Layout looks as follows: | 5158 // per call-site that could throw an exception. Layout looks as follows: |
5159 // [ return-address-offset , handler-offset ] | 5159 // [ return-address-offset , handler-offset ] |
5160 class HandlerTable : public FixedArray { | 5160 class HandlerTable : public FixedArray { |
5161 public: | 5161 public: |
| 5162 // Conservative prediction whether a given handler will locally catch an |
| 5163 // exception or cause a re-throw to outside the code boundary. Since this is |
| 5164 // undecidable it is merely an approximation (e.g. useful for debugger). |
| 5165 enum CatchPrediction { UNCAUGHT, CAUGHT }; |
| 5166 |
5162 // Accessors for handler table based on ranges. | 5167 // Accessors for handler table based on ranges. |
5163 void SetRangeStart(int index, int value) { | 5168 void SetRangeStart(int index, int value) { |
5164 set(index * kRangeEntrySize + kRangeStartIndex, Smi::FromInt(value)); | 5169 set(index * kRangeEntrySize + kRangeStartIndex, Smi::FromInt(value)); |
5165 } | 5170 } |
5166 void SetRangeEnd(int index, int value) { | 5171 void SetRangeEnd(int index, int value) { |
5167 set(index * kRangeEntrySize + kRangeEndIndex, Smi::FromInt(value)); | 5172 set(index * kRangeEntrySize + kRangeEndIndex, Smi::FromInt(value)); |
5168 } | 5173 } |
5169 void SetRangeHandler(int index, int value) { | 5174 void SetRangeHandler(int index, int value) { |
5170 set(index * kRangeEntrySize + kRangeHandlerIndex, Smi::FromInt(value)); | 5175 set(index * kRangeEntrySize + kRangeHandlerIndex, Smi::FromInt(value)); |
5171 } | 5176 } |
5172 void SetRangeDepth(int index, int value) { | 5177 void SetRangeDepth(int index, int value) { |
5173 set(index * kRangeEntrySize + kRangeDepthIndex, Smi::FromInt(value)); | 5178 set(index * kRangeEntrySize + kRangeDepthIndex, Smi::FromInt(value)); |
5174 } | 5179 } |
5175 | 5180 |
5176 // Accessors for handler table based on return addresses. | 5181 // Accessors for handler table based on return addresses. |
5177 void SetReturnOffset(int index, int value) { | 5182 void SetReturnOffset(int index, int value) { |
5178 set(index * kReturnEntrySize + kReturnOffsetIndex, Smi::FromInt(value)); | 5183 set(index * kReturnEntrySize + kReturnOffsetIndex, Smi::FromInt(value)); |
5179 } | 5184 } |
5180 void SetReturnHandler(int index, int value) { | 5185 void SetReturnHandler(int index, int offset, CatchPrediction prediction) { |
| 5186 int value = HandlerOffsetField::encode(offset) | |
| 5187 HandlerPredictionField::encode(prediction); |
5181 set(index * kReturnEntrySize + kReturnHandlerIndex, Smi::FromInt(value)); | 5188 set(index * kReturnEntrySize + kReturnHandlerIndex, Smi::FromInt(value)); |
5182 } | 5189 } |
5183 | 5190 |
5184 // Lookup handler in a table based on ranges. | 5191 // Lookup handler in a table based on ranges. |
5185 int LookupRange(int pc_offset, int* stack_depth); | 5192 int LookupRange(int pc_offset, int* stack_depth); |
5186 | 5193 |
5187 // Lookup handler in a table based on return addresses. | 5194 // Lookup handler in a table based on return addresses. |
5188 int LookupReturn(int pc_offset); | 5195 int LookupReturn(int pc_offset, CatchPrediction* prediction); |
5189 | 5196 |
5190 // Returns the required length of the underlying fixed array. | 5197 // Returns the required length of the underlying fixed array. |
5191 static int LengthForRange(int entries) { return entries * kRangeEntrySize; } | 5198 static int LengthForRange(int entries) { return entries * kRangeEntrySize; } |
5192 static int LengthForReturn(int entries) { return entries * kReturnEntrySize; } | 5199 static int LengthForReturn(int entries) { return entries * kReturnEntrySize; } |
5193 | 5200 |
5194 DECLARE_CAST(HandlerTable) | 5201 DECLARE_CAST(HandlerTable) |
5195 | 5202 |
5196 #if defined(OBJECT_PRINT) || defined(ENABLE_DISASSEMBLER) | 5203 #if defined(OBJECT_PRINT) || defined(ENABLE_DISASSEMBLER) |
5197 void HandlerTableRangePrint(std::ostream& os); // NOLINT | 5204 void HandlerTableRangePrint(std::ostream& os); // NOLINT |
5198 void HandlerTableReturnPrint(std::ostream& os); // NOLINT | 5205 void HandlerTableReturnPrint(std::ostream& os); // NOLINT |
5199 #endif | 5206 #endif |
5200 | 5207 |
5201 private: | 5208 private: |
5202 // Layout description for handler table based on ranges. | 5209 // Layout description for handler table based on ranges. |
5203 static const int kRangeStartIndex = 0; | 5210 static const int kRangeStartIndex = 0; |
5204 static const int kRangeEndIndex = 1; | 5211 static const int kRangeEndIndex = 1; |
5205 static const int kRangeHandlerIndex = 2; | 5212 static const int kRangeHandlerIndex = 2; |
5206 static const int kRangeDepthIndex = 3; | 5213 static const int kRangeDepthIndex = 3; |
5207 static const int kRangeEntrySize = 4; | 5214 static const int kRangeEntrySize = 4; |
5208 | 5215 |
5209 // Layout description for handler table based on return addresses. | 5216 // Layout description for handler table based on return addresses. |
5210 static const int kReturnOffsetIndex = 0; | 5217 static const int kReturnOffsetIndex = 0; |
5211 static const int kReturnHandlerIndex = 1; | 5218 static const int kReturnHandlerIndex = 1; |
5212 static const int kReturnEntrySize = 2; | 5219 static const int kReturnEntrySize = 2; |
| 5220 |
| 5221 // Encoding of the {handler} field. |
| 5222 class HandlerPredictionField : public BitField<CatchPrediction, 0, 1> {}; |
| 5223 class HandlerOffsetField : public BitField<int, 1, 30> {}; |
5213 }; | 5224 }; |
5214 | 5225 |
5215 | 5226 |
5216 // Forward declaration. | 5227 // Forward declaration. |
5217 class Cell; | 5228 class Cell; |
5218 class PropertyCell; | 5229 class PropertyCell; |
5219 class SafepointEntry; | 5230 class SafepointEntry; |
5220 class TypeFeedbackInfo; | 5231 class TypeFeedbackInfo; |
5221 | 5232 |
5222 // Code describes objects with on-the-fly generated machine code. | 5233 // Code describes objects with on-the-fly generated machine code. |
(...skipping 5954 matching lines...) Loading... |
11177 } else { | 11188 } else { |
11178 value &= ~(1 << bit_position); | 11189 value &= ~(1 << bit_position); |
11179 } | 11190 } |
11180 return value; | 11191 return value; |
11181 } | 11192 } |
11182 }; | 11193 }; |
11183 | 11194 |
11184 } } // namespace v8::internal | 11195 } } // namespace v8::internal |
11185 | 11196 |
11186 #endif // V8_OBJECTS_H_ | 11197 #endif // V8_OBJECTS_H_ |
OLD | NEW |