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 4104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5055 PretenureFlag pretenure); | 5056 PretenureFlag pretenure); |
5056 | 5057 |
5057 DECLARE_CAST(DeoptimizationOutputData) | 5058 DECLARE_CAST(DeoptimizationOutputData) |
5058 | 5059 |
5059 #if defined(OBJECT_PRINT) || defined(ENABLE_DISASSEMBLER) | 5060 #if defined(OBJECT_PRINT) || defined(ENABLE_DISASSEMBLER) |
5060 void DeoptimizationOutputDataPrint(std::ostream& os); // NOLINT | 5061 void DeoptimizationOutputDataPrint(std::ostream& os); // NOLINT |
5061 #endif | 5062 #endif |
5062 }; | 5063 }; |
5063 | 5064 |
5064 | 5065 |
| 5066 // HandlerTable is a fixed array containing entries for exception handlers in |
| 5067 // the code object it is associated with. The tables comes in two flavors: |
| 5068 // 1) Based on ranges: Used for unoptimized code. Contains one entry per |
| 5069 // exception handler and a range representing the try-block covered by that |
| 5070 // handler. Layout looks as follows: |
| 5071 // [ range-start , range-end , handler-offset , stack-depth ] |
| 5072 // 2) Based on return addresses: Used for turbofanned code. Contains one entry |
| 5073 // per call-site that could throw an exception. Layout looks as follows: |
| 5074 // [ return-address-offset , handler-offset ] |
| 5075 class HandlerTable : public FixedArray { |
| 5076 public: |
| 5077 // Accessors for handler table based on ranges. |
| 5078 void SetRangeStart(int index, int value) { |
| 5079 set(index * kRangeEntrySize + kRangeStartIndex, Smi::FromInt(value)); |
| 5080 } |
| 5081 void SetRangeEnd(int index, int value) { |
| 5082 set(index * kRangeEntrySize + kRangeEndIndex, Smi::FromInt(value)); |
| 5083 } |
| 5084 void SetRangeHandler(int index, int value) { |
| 5085 set(index * kRangeEntrySize + kRangeHandlerIndex, Smi::FromInt(value)); |
| 5086 } |
| 5087 void SetRangeDepth(int index, int value) { |
| 5088 set(index * kRangeEntrySize + kRangeDepthIndex, Smi::FromInt(value)); |
| 5089 } |
| 5090 |
| 5091 // Accessors for handler table based on return addresses. |
| 5092 void SetReturnOffset(int index, int value) { |
| 5093 set(index * kReturnEntrySize + kReturnOffsetIndex, Smi::FromInt(value)); |
| 5094 } |
| 5095 void SetReturnHandler(int index, int value) { |
| 5096 set(index * kReturnEntrySize + kReturnHandlerIndex, Smi::FromInt(value)); |
| 5097 } |
| 5098 |
| 5099 // Lookup handler in a table based on ranges. |
| 5100 int LookupRange(int pc_offset, int* stack_depth); |
| 5101 |
| 5102 // Lookup handler in a table based on return addresses. |
| 5103 int LookupReturn(int pc_offset); |
| 5104 |
| 5105 // Returns the required length of the underlying fixed array. |
| 5106 static int LengthForRange(int entries) { return entries * kRangeEntrySize; } |
| 5107 static int LengthForReturn(int entries) { return entries * kReturnEntrySize; } |
| 5108 |
| 5109 DECLARE_CAST(HandlerTable) |
| 5110 |
| 5111 #if defined(OBJECT_PRINT) || defined(ENABLE_DISASSEMBLER) |
| 5112 void HandlerTableRangePrint(std::ostream& os); // NOLINT |
| 5113 void HandlerTableReturnPrint(std::ostream& os); // NOLINT |
| 5114 #endif |
| 5115 |
| 5116 private: |
| 5117 // Layout description for handler table based on ranges. |
| 5118 static const int kRangeStartIndex = 0; |
| 5119 static const int kRangeEndIndex = 1; |
| 5120 static const int kRangeHandlerIndex = 2; |
| 5121 static const int kRangeDepthIndex = 3; |
| 5122 static const int kRangeEntrySize = 4; |
| 5123 |
| 5124 // Layout description for handler table based on return addresses. |
| 5125 static const int kReturnOffsetIndex = 0; |
| 5126 static const int kReturnHandlerIndex = 1; |
| 5127 static const int kReturnEntrySize = 2; |
| 5128 }; |
| 5129 |
| 5130 |
5065 // Forward declaration. | 5131 // Forward declaration. |
5066 class Cell; | 5132 class Cell; |
5067 class PropertyCell; | 5133 class PropertyCell; |
5068 class SafepointEntry; | 5134 class SafepointEntry; |
5069 class TypeFeedbackInfo; | 5135 class TypeFeedbackInfo; |
5070 | 5136 |
5071 // Code describes objects with on-the-fly generated machine code. | 5137 // Code describes objects with on-the-fly generated machine code. |
5072 class Code: public HeapObject { | 5138 class Code: public HeapObject { |
5073 public: | 5139 public: |
5074 // Opaque data type for encapsulating code flags like kind, inline | 5140 // Opaque data type for encapsulating code flags like kind, inline |
(...skipping 2262 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7337 // cannot be resumed. | 7403 // cannot be resumed. |
7338 inline int continuation() const; | 7404 inline int continuation() const; |
7339 inline void set_continuation(int continuation); | 7405 inline void set_continuation(int continuation); |
7340 inline bool is_closed(); | 7406 inline bool is_closed(); |
7341 inline bool is_executing(); | 7407 inline bool is_executing(); |
7342 inline bool is_suspended(); | 7408 inline bool is_suspended(); |
7343 | 7409 |
7344 // [operand_stack]: Saved operand stack. | 7410 // [operand_stack]: Saved operand stack. |
7345 DECL_ACCESSORS(operand_stack, FixedArray) | 7411 DECL_ACCESSORS(operand_stack, FixedArray) |
7346 | 7412 |
7347 // [stack_handler_index]: Index of first stack handler in operand_stack, or -1 | |
7348 // if the captured activation had no stack handler. | |
7349 inline int stack_handler_index() const; | |
7350 inline void set_stack_handler_index(int stack_handler_index); | |
7351 | |
7352 DECLARE_CAST(JSGeneratorObject) | 7413 DECLARE_CAST(JSGeneratorObject) |
7353 | 7414 |
7354 // Dispatched behavior. | 7415 // Dispatched behavior. |
7355 DECLARE_PRINTER(JSGeneratorObject) | 7416 DECLARE_PRINTER(JSGeneratorObject) |
7356 DECLARE_VERIFIER(JSGeneratorObject) | 7417 DECLARE_VERIFIER(JSGeneratorObject) |
7357 | 7418 |
7358 // Magic sentinel values for the continuation. | 7419 // Magic sentinel values for the continuation. |
7359 static const int kGeneratorExecuting = -1; | 7420 static const int kGeneratorExecuting = -1; |
7360 static const int kGeneratorClosed = 0; | 7421 static const int kGeneratorClosed = 0; |
7361 | 7422 |
7362 // Layout description. | 7423 // Layout description. |
7363 static const int kFunctionOffset = JSObject::kHeaderSize; | 7424 static const int kFunctionOffset = JSObject::kHeaderSize; |
7364 static const int kContextOffset = kFunctionOffset + kPointerSize; | 7425 static const int kContextOffset = kFunctionOffset + kPointerSize; |
7365 static const int kReceiverOffset = kContextOffset + kPointerSize; | 7426 static const int kReceiverOffset = kContextOffset + kPointerSize; |
7366 static const int kContinuationOffset = kReceiverOffset + kPointerSize; | 7427 static const int kContinuationOffset = kReceiverOffset + kPointerSize; |
7367 static const int kOperandStackOffset = kContinuationOffset + kPointerSize; | 7428 static const int kOperandStackOffset = kContinuationOffset + kPointerSize; |
7368 static const int kStackHandlerIndexOffset = | 7429 static const int kSize = kOperandStackOffset + kPointerSize; |
7369 kOperandStackOffset + kPointerSize; | |
7370 static const int kSize = kStackHandlerIndexOffset + kPointerSize; | |
7371 | 7430 |
7372 // Resume mode, for use by runtime functions. | 7431 // Resume mode, for use by runtime functions. |
7373 enum ResumeMode { NEXT, THROW }; | 7432 enum ResumeMode { NEXT, THROW }; |
7374 | 7433 |
7375 // Yielding from a generator returns an object with the following inobject | 7434 // Yielding from a generator returns an object with the following inobject |
7376 // properties. See Context::iterator_result_map() for the map. | 7435 // properties. See Context::iterator_result_map() for the map. |
7377 static const int kResultValuePropertyIndex = 0; | 7436 static const int kResultValuePropertyIndex = 0; |
7378 static const int kResultDonePropertyIndex = 1; | 7437 static const int kResultDonePropertyIndex = 1; |
7379 static const int kResultPropertyCount = 2; | 7438 static const int kResultPropertyCount = 2; |
7380 | 7439 |
(...skipping 3614 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
10995 } else { | 11054 } else { |
10996 value &= ~(1 << bit_position); | 11055 value &= ~(1 << bit_position); |
10997 } | 11056 } |
10998 return value; | 11057 return value; |
10999 } | 11058 } |
11000 }; | 11059 }; |
11001 | 11060 |
11002 } } // namespace v8::internal | 11061 } } // namespace v8::internal |
11003 | 11062 |
11004 #endif // V8_OBJECTS_H_ | 11063 #endif // V8_OBJECTS_H_ |
OLD | NEW |