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 920 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
931 V(JSGeneratorObject) \ | 931 V(JSGeneratorObject) \ |
932 V(JSModule) \ | 932 V(JSModule) \ |
933 V(LayoutDescriptor) \ | 933 V(LayoutDescriptor) \ |
934 V(Map) \ | 934 V(Map) \ |
935 V(DescriptorArray) \ | 935 V(DescriptorArray) \ |
936 V(TransitionArray) \ | 936 V(TransitionArray) \ |
937 V(TypeFeedbackVector) \ | 937 V(TypeFeedbackVector) \ |
938 V(DeoptimizationInputData) \ | 938 V(DeoptimizationInputData) \ |
939 V(DeoptimizationOutputData) \ | 939 V(DeoptimizationOutputData) \ |
940 V(DependentCode) \ | 940 V(DependentCode) \ |
| 941 V(HandlerTable) \ |
941 V(FixedArray) \ | 942 V(FixedArray) \ |
942 V(FixedDoubleArray) \ | 943 V(FixedDoubleArray) \ |
943 V(WeakFixedArray) \ | 944 V(WeakFixedArray) \ |
944 V(ArrayList) \ | 945 V(ArrayList) \ |
945 V(ConstantPoolArray) \ | 946 V(ConstantPoolArray) \ |
946 V(Context) \ | 947 V(Context) \ |
947 V(ScriptContextTable) \ | 948 V(ScriptContextTable) \ |
948 V(NativeContext) \ | 949 V(NativeContext) \ |
949 V(ScopeInfo) \ | 950 V(ScopeInfo) \ |
950 V(JSFunction) \ | 951 V(JSFunction) \ |
(...skipping 4040 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4991 PretenureFlag pretenure); | 4992 PretenureFlag pretenure); |
4992 | 4993 |
4993 DECLARE_CAST(DeoptimizationOutputData) | 4994 DECLARE_CAST(DeoptimizationOutputData) |
4994 | 4995 |
4995 #if defined(OBJECT_PRINT) || defined(ENABLE_DISASSEMBLER) | 4996 #if defined(OBJECT_PRINT) || defined(ENABLE_DISASSEMBLER) |
4996 void DeoptimizationOutputDataPrint(std::ostream& os); // NOLINT | 4997 void DeoptimizationOutputDataPrint(std::ostream& os); // NOLINT |
4997 #endif | 4998 #endif |
4998 }; | 4999 }; |
4999 | 5000 |
5000 | 5001 |
| 5002 // HandlerTable is a fixed array containing entries for exception handlers in |
| 5003 // the code object it is associated with. The tables comes in two flavors: |
| 5004 // 1) Based on ranges: Used for unoptimized code. Contains one entry per |
| 5005 // exception handler and a range representing the try-block covered by that |
| 5006 // handler. Layout looks as follows: |
| 5007 // [ range-start , range-end , handler-offset , stack-depth ] |
| 5008 // 2) Based on return addresses: Used for turbofanned code. Contains one entry |
| 5009 // per call-site that could throw an exception. Layout looks as follows: |
| 5010 // [ return-address-offset , handler-offset ] |
| 5011 class HandlerTable : public FixedArray { |
| 5012 public: |
| 5013 // Accessors for handler table based on ranges. |
| 5014 void SetRangeStart(int index, int value) { |
| 5015 set(index * kRangeEntrySize + kRangeStartIndex, Smi::FromInt(value)); |
| 5016 } |
| 5017 void SetRangeEnd(int index, int value) { |
| 5018 set(index * kRangeEntrySize + kRangeEndIndex, Smi::FromInt(value)); |
| 5019 } |
| 5020 void SetRangeHandler(int index, int value) { |
| 5021 set(index * kRangeEntrySize + kRangeHandlerIndex, Smi::FromInt(value)); |
| 5022 } |
| 5023 void SetRangeDepth(int index, int value) { |
| 5024 set(index * kRangeEntrySize + kRangeDepthIndex, Smi::FromInt(value)); |
| 5025 } |
| 5026 |
| 5027 // Accessors for handler table based on return addresses. |
| 5028 void SetReturnOffset(int index, int value) { |
| 5029 set(index * kReturnEntrySize + kReturnOffsetIndex, Smi::FromInt(value)); |
| 5030 } |
| 5031 void SetReturnHandler(int index, int value) { |
| 5032 set(index * kReturnEntrySize + kReturnHandlerIndex, Smi::FromInt(value)); |
| 5033 } |
| 5034 |
| 5035 // Lookup handler in a table based on ranges. |
| 5036 int LookupRange(int pc_offset, int* stack_depth); |
| 5037 |
| 5038 // Lookup handler in a table based on return addresses. |
| 5039 int LookupReturn(int pc_offset); |
| 5040 |
| 5041 // Returns the required length of the underlying fixed array. |
| 5042 static int LengthForRange(int entries) { return entries * kRangeEntrySize; } |
| 5043 static int LengthForReturn(int entries) { return entries * kReturnEntrySize; } |
| 5044 |
| 5045 DECLARE_CAST(HandlerTable) |
| 5046 |
| 5047 #if defined(OBJECT_PRINT) || defined(ENABLE_DISASSEMBLER) |
| 5048 void HandlerTableRangePrint(std::ostream& os); // NOLINT |
| 5049 void HandlerTableReturnPrint(std::ostream& os); // NOLINT |
| 5050 #endif |
| 5051 |
| 5052 private: |
| 5053 // Layout description for handler table based on ranges. |
| 5054 static const int kRangeStartIndex = 0; |
| 5055 static const int kRangeEndIndex = 1; |
| 5056 static const int kRangeHandlerIndex = 2; |
| 5057 static const int kRangeDepthIndex = 3; |
| 5058 static const int kRangeEntrySize = 4; |
| 5059 |
| 5060 // Layout description for handler table based on return addresses. |
| 5061 static const int kReturnOffsetIndex = 0; |
| 5062 static const int kReturnHandlerIndex = 1; |
| 5063 static const int kReturnEntrySize = 2; |
| 5064 }; |
| 5065 |
| 5066 |
5001 // Forward declaration. | 5067 // Forward declaration. |
5002 class Cell; | 5068 class Cell; |
5003 class PropertyCell; | 5069 class PropertyCell; |
5004 class SafepointEntry; | 5070 class SafepointEntry; |
5005 class TypeFeedbackInfo; | 5071 class TypeFeedbackInfo; |
5006 | 5072 |
5007 // Code describes objects with on-the-fly generated machine code. | 5073 // Code describes objects with on-the-fly generated machine code. |
5008 class Code: public HeapObject { | 5074 class Code: public HeapObject { |
5009 public: | 5075 public: |
5010 // Opaque data type for encapsulating code flags like kind, inline | 5076 // Opaque data type for encapsulating code flags like kind, inline |
(...skipping 2262 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7273 // cannot be resumed. | 7339 // cannot be resumed. |
7274 inline int continuation() const; | 7340 inline int continuation() const; |
7275 inline void set_continuation(int continuation); | 7341 inline void set_continuation(int continuation); |
7276 inline bool is_closed(); | 7342 inline bool is_closed(); |
7277 inline bool is_executing(); | 7343 inline bool is_executing(); |
7278 inline bool is_suspended(); | 7344 inline bool is_suspended(); |
7279 | 7345 |
7280 // [operand_stack]: Saved operand stack. | 7346 // [operand_stack]: Saved operand stack. |
7281 DECL_ACCESSORS(operand_stack, FixedArray) | 7347 DECL_ACCESSORS(operand_stack, FixedArray) |
7282 | 7348 |
7283 // [stack_handler_index]: Index of first stack handler in operand_stack, or -1 | |
7284 // if the captured activation had no stack handler. | |
7285 inline int stack_handler_index() const; | |
7286 inline void set_stack_handler_index(int stack_handler_index); | |
7287 | |
7288 DECLARE_CAST(JSGeneratorObject) | 7349 DECLARE_CAST(JSGeneratorObject) |
7289 | 7350 |
7290 // Dispatched behavior. | 7351 // Dispatched behavior. |
7291 DECLARE_PRINTER(JSGeneratorObject) | 7352 DECLARE_PRINTER(JSGeneratorObject) |
7292 DECLARE_VERIFIER(JSGeneratorObject) | 7353 DECLARE_VERIFIER(JSGeneratorObject) |
7293 | 7354 |
7294 // Magic sentinel values for the continuation. | 7355 // Magic sentinel values for the continuation. |
7295 static const int kGeneratorExecuting = -1; | 7356 static const int kGeneratorExecuting = -1; |
7296 static const int kGeneratorClosed = 0; | 7357 static const int kGeneratorClosed = 0; |
7297 | 7358 |
7298 // Layout description. | 7359 // Layout description. |
7299 static const int kFunctionOffset = JSObject::kHeaderSize; | 7360 static const int kFunctionOffset = JSObject::kHeaderSize; |
7300 static const int kContextOffset = kFunctionOffset + kPointerSize; | 7361 static const int kContextOffset = kFunctionOffset + kPointerSize; |
7301 static const int kReceiverOffset = kContextOffset + kPointerSize; | 7362 static const int kReceiverOffset = kContextOffset + kPointerSize; |
7302 static const int kContinuationOffset = kReceiverOffset + kPointerSize; | 7363 static const int kContinuationOffset = kReceiverOffset + kPointerSize; |
7303 static const int kOperandStackOffset = kContinuationOffset + kPointerSize; | 7364 static const int kOperandStackOffset = kContinuationOffset + kPointerSize; |
7304 static const int kStackHandlerIndexOffset = | 7365 static const int kSize = kOperandStackOffset + kPointerSize; |
7305 kOperandStackOffset + kPointerSize; | |
7306 static const int kSize = kStackHandlerIndexOffset + kPointerSize; | |
7307 | 7366 |
7308 // Resume mode, for use by runtime functions. | 7367 // Resume mode, for use by runtime functions. |
7309 enum ResumeMode { NEXT, THROW }; | 7368 enum ResumeMode { NEXT, THROW }; |
7310 | 7369 |
7311 // Yielding from a generator returns an object with the following inobject | 7370 // Yielding from a generator returns an object with the following inobject |
7312 // properties. See Context::iterator_result_map() for the map. | 7371 // properties. See Context::iterator_result_map() for the map. |
7313 static const int kResultValuePropertyIndex = 0; | 7372 static const int kResultValuePropertyIndex = 0; |
7314 static const int kResultDonePropertyIndex = 1; | 7373 static const int kResultDonePropertyIndex = 1; |
7315 static const int kResultPropertyCount = 2; | 7374 static const int kResultPropertyCount = 2; |
7316 | 7375 |
(...skipping 3614 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
10931 } else { | 10990 } else { |
10932 value &= ~(1 << bit_position); | 10991 value &= ~(1 << bit_position); |
10933 } | 10992 } |
10934 return value; | 10993 return value; |
10935 } | 10994 } |
10936 }; | 10995 }; |
10937 | 10996 |
10938 } } // namespace v8::internal | 10997 } } // namespace v8::internal |
10939 | 10998 |
10940 #endif // V8_OBJECTS_H_ | 10999 #endif // V8_OBJECTS_H_ |
OLD | NEW |