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 109 matching lines...) Loading... |
120 // - Bool32x4 | 120 // - Bool32x4 |
121 // - Int16x8 | 121 // - Int16x8 |
122 // - Uint16x8 | 122 // - Uint16x8 |
123 // - Bool16x8 | 123 // - Bool16x8 |
124 // - Int8x16 | 124 // - Int8x16 |
125 // - Uint8x16 | 125 // - Uint8x16 |
126 // - Bool8x16 | 126 // - Bool8x16 |
127 // - Cell | 127 // - Cell |
128 // - PropertyCell | 128 // - PropertyCell |
129 // - Code | 129 // - Code |
| 130 // - AbstractCode, a wrapper around Code or BytecodeArray |
130 // - Map | 131 // - Map |
131 // - Oddball | 132 // - Oddball |
132 // - Foreign | 133 // - Foreign |
133 // - SharedFunctionInfo | 134 // - SharedFunctionInfo |
134 // - Struct | 135 // - Struct |
135 // - Box | 136 // - Box |
136 // - AccessorInfo | 137 // - AccessorInfo |
137 // - AccessorPair | 138 // - AccessorPair |
138 // - AccessCheckInfo | 139 // - AccessCheckInfo |
139 // - InterceptorInfo | 140 // - InterceptorInfo |
(...skipping 800 matching lines...) Loading... |
940 V(FixedDoubleArray) \ | 941 V(FixedDoubleArray) \ |
941 V(WeakFixedArray) \ | 942 V(WeakFixedArray) \ |
942 V(ArrayList) \ | 943 V(ArrayList) \ |
943 V(Context) \ | 944 V(Context) \ |
944 V(ScriptContextTable) \ | 945 V(ScriptContextTable) \ |
945 V(NativeContext) \ | 946 V(NativeContext) \ |
946 V(ScopeInfo) \ | 947 V(ScopeInfo) \ |
947 V(JSBoundFunction) \ | 948 V(JSBoundFunction) \ |
948 V(JSFunction) \ | 949 V(JSFunction) \ |
949 V(Code) \ | 950 V(Code) \ |
| 951 V(AbstractCode) \ |
950 V(Oddball) \ | 952 V(Oddball) \ |
951 V(SharedFunctionInfo) \ | 953 V(SharedFunctionInfo) \ |
952 V(JSValue) \ | 954 V(JSValue) \ |
953 V(JSDate) \ | 955 V(JSDate) \ |
954 V(JSMessageObject) \ | 956 V(JSMessageObject) \ |
955 V(StringWrapper) \ | 957 V(StringWrapper) \ |
956 V(Foreign) \ | 958 V(Foreign) \ |
957 V(Boolean) \ | 959 V(Boolean) \ |
958 V(JSArray) \ | 960 V(JSArray) \ |
959 V(JSArrayBuffer) \ | 961 V(JSArrayBuffer) \ |
(...skipping 3464 matching lines...) Loading... |
4424 | 4426 |
4425 // Accessors for source position table containing mappings between byte code | 4427 // Accessors for source position table containing mappings between byte code |
4426 // offset and source position. | 4428 // offset and source position. |
4427 DECL_ACCESSORS(source_position_table, FixedArray) | 4429 DECL_ACCESSORS(source_position_table, FixedArray) |
4428 | 4430 |
4429 DECLARE_CAST(BytecodeArray) | 4431 DECLARE_CAST(BytecodeArray) |
4430 | 4432 |
4431 // Dispatched behavior. | 4433 // Dispatched behavior. |
4432 inline int BytecodeArraySize(); | 4434 inline int BytecodeArraySize(); |
4433 | 4435 |
| 4436 inline int instruction_size(); |
| 4437 |
| 4438 int SourcePosition(int offset); |
| 4439 |
4434 DECLARE_PRINTER(BytecodeArray) | 4440 DECLARE_PRINTER(BytecodeArray) |
4435 DECLARE_VERIFIER(BytecodeArray) | 4441 DECLARE_VERIFIER(BytecodeArray) |
4436 | 4442 |
4437 void Disassemble(std::ostream& os); | 4443 void Disassemble(std::ostream& os); |
4438 | 4444 |
4439 // Layout description. | 4445 // Layout description. |
4440 static const int kFrameSizeOffset = FixedArrayBase::kHeaderSize; | 4446 static const int kFrameSizeOffset = FixedArrayBase::kHeaderSize; |
4441 static const int kParameterSizeOffset = kFrameSizeOffset + kIntSize; | 4447 static const int kParameterSizeOffset = kFrameSizeOffset + kIntSize; |
4442 static const int kConstantPoolOffset = kParameterSizeOffset + kIntSize; | 4448 static const int kConstantPoolOffset = kParameterSizeOffset + kIntSize; |
4443 static const int kHandlerTableOffset = kConstantPoolOffset + kPointerSize; | 4449 static const int kHandlerTableOffset = kConstantPoolOffset + kPointerSize; |
(...skipping 893 matching lines...) Loading... |
5337 | 5343 |
5338 // Code aging -- platform-specific | 5344 // Code aging -- platform-specific |
5339 static void PatchPlatformCodeAge(Isolate* isolate, | 5345 static void PatchPlatformCodeAge(Isolate* isolate, |
5340 byte* sequence, Age age, | 5346 byte* sequence, Age age, |
5341 MarkingParity parity); | 5347 MarkingParity parity); |
5342 | 5348 |
5343 DISALLOW_IMPLICIT_CONSTRUCTORS(Code); | 5349 DISALLOW_IMPLICIT_CONSTRUCTORS(Code); |
5344 }; | 5350 }; |
5345 | 5351 |
5346 | 5352 |
| 5353 class AbstractCode : public HeapObject { |
| 5354 public: |
| 5355 int SourcePosition(int offset); |
| 5356 |
| 5357 DECLARE_CAST(AbstractCode) |
| 5358 inline Code* GetCode(); |
| 5359 inline BytecodeArray* GetBytecodeArray(); |
| 5360 }; |
| 5361 |
| 5362 |
5347 // Dependent code is a singly linked list of fixed arrays. Each array contains | 5363 // Dependent code is a singly linked list of fixed arrays. Each array contains |
5348 // code objects in weak cells for one dependent group. The suffix of the array | 5364 // code objects in weak cells for one dependent group. The suffix of the array |
5349 // can be filled with the undefined value if the number of codes is less than | 5365 // can be filled with the undefined value if the number of codes is less than |
5350 // the length of the array. | 5366 // the length of the array. |
5351 // | 5367 // |
5352 // +------+-----------------+--------+--------+-----+--------+-----------+-----+ | 5368 // +------+-----------------+--------+--------+-----+--------+-----------+-----+ |
5353 // | next | count & group 1 | code 1 | code 2 | ... | code n | undefined | ... | | 5369 // | next | count & group 1 | code 1 | code 2 | ... | code n | undefined | ... | |
5354 // +------+-----------------+--------+--------+-----+--------+-----------+-----+ | 5370 // +------+-----------------+--------+--------+-----+--------+-----------+-----+ |
5355 // | | 5371 // | |
5356 // V | 5372 // V |
(...skipping 1020 matching lines...) Loading... |
6377 // this through. Encoded in the 'flags' field. | 6393 // this through. Encoded in the 'flags' field. |
6378 inline v8::ScriptOriginOptions origin_options(); | 6394 inline v8::ScriptOriginOptions origin_options(); |
6379 inline void set_origin_options(ScriptOriginOptions origin_options); | 6395 inline void set_origin_options(ScriptOriginOptions origin_options); |
6380 | 6396 |
6381 DECLARE_CAST(Script) | 6397 DECLARE_CAST(Script) |
6382 | 6398 |
6383 // If script source is an external string, check that the underlying | 6399 // If script source is an external string, check that the underlying |
6384 // resource is accessible. Otherwise, always return true. | 6400 // resource is accessible. Otherwise, always return true. |
6385 inline bool HasValidSource(); | 6401 inline bool HasValidSource(); |
6386 | 6402 |
6387 // Convert code position into column number. | 6403 // Convert code offset into column number. |
6388 static int GetColumnNumber(Handle<Script> script, int code_pos); | 6404 static int GetColumnNumber(Handle<Script> script, int code_offset); |
6389 | 6405 |
6390 // Convert code position into (zero-based) line number. | 6406 // Convert code offset into (zero-based) line number. |
6391 // The non-handlified version does not allocate, but may be much slower. | 6407 // The non-handlified version does not allocate, but may be much slower. |
6392 static int GetLineNumber(Handle<Script> script, int code_pos); | 6408 static int GetLineNumber(Handle<Script> script, int code_offset); |
6393 int GetLineNumber(int code_pos); | 6409 int GetLineNumber(int code_pos); |
6394 | 6410 |
6395 static Handle<Object> GetNameOrSourceURL(Handle<Script> script); | 6411 static Handle<Object> GetNameOrSourceURL(Handle<Script> script); |
6396 | 6412 |
6397 // Init line_ends array with code positions of line ends inside script source. | 6413 // Init line_ends array with source code positions of line ends. |
6398 static void InitLineEnds(Handle<Script> script); | 6414 static void InitLineEnds(Handle<Script> script); |
6399 | 6415 |
6400 // Get the JS object wrapping the given script; create it if none exists. | 6416 // Get the JS object wrapping the given script; create it if none exists. |
6401 static Handle<JSObject> GetWrapper(Handle<Script> script); | 6417 static Handle<JSObject> GetWrapper(Handle<Script> script); |
6402 | 6418 |
6403 // Look through the list of existing shared function infos to find one | 6419 // Look through the list of existing shared function infos to find one |
6404 // that matches the function literal. Return empty handle if not found. | 6420 // that matches the function literal. Return empty handle if not found. |
6405 MaybeHandle<SharedFunctionInfo> FindSharedFunctionInfo(FunctionLiteral* fun); | 6421 MaybeHandle<SharedFunctionInfo> FindSharedFunctionInfo(FunctionLiteral* fun); |
6406 | 6422 |
6407 // Iterate over all script objects on the heap. | 6423 // Iterate over all script objects on the heap. |
(...skipping 115 matching lines...) Loading... |
6523 | 6539 |
6524 // SharedFunctionInfo describes the JSFunction information that can be | 6540 // SharedFunctionInfo describes the JSFunction information that can be |
6525 // shared by multiple instances of the function. | 6541 // shared by multiple instances of the function. |
6526 class SharedFunctionInfo: public HeapObject { | 6542 class SharedFunctionInfo: public HeapObject { |
6527 public: | 6543 public: |
6528 // [name]: Function name. | 6544 // [name]: Function name. |
6529 DECL_ACCESSORS(name, Object) | 6545 DECL_ACCESSORS(name, Object) |
6530 | 6546 |
6531 // [code]: Function code. | 6547 // [code]: Function code. |
6532 DECL_ACCESSORS(code, Code) | 6548 DECL_ACCESSORS(code, Code) |
| 6549 |
| 6550 // Retrieve interpreter bytecode or unoptimized function code. |
| 6551 inline AbstractCode* AbstractCode(); |
| 6552 |
6533 inline void ReplaceCode(Code* code); | 6553 inline void ReplaceCode(Code* code); |
6534 | 6554 |
6535 // [optimized_code_map]: Map from native context to optimized code | 6555 // [optimized_code_map]: Map from native context to optimized code |
6536 // and a shared literals array. | 6556 // and a shared literals array. |
6537 DECL_ACCESSORS(optimized_code_map, FixedArray) | 6557 DECL_ACCESSORS(optimized_code_map, FixedArray) |
6538 | 6558 |
6539 // Returns entry from optimized code map for specified context and OSR entry. | 6559 // Returns entry from optimized code map for specified context and OSR entry. |
6540 // Note that {code == nullptr, literals == nullptr} indicates no matching | 6560 // Note that {code == nullptr, literals == nullptr} indicates no matching |
6541 // entry has been found, whereas {code, literals == nullptr} indicates that | 6561 // entry has been found, whereas {code, literals == nullptr} indicates that |
6542 // code is context-independent. | 6562 // code is context-independent. |
(...skipping 4027 matching lines...) Loading... |
10570 class DebugInfo: public Struct { | 10590 class DebugInfo: public Struct { |
10571 public: | 10591 public: |
10572 // The shared function info for the source being debugged. | 10592 // The shared function info for the source being debugged. |
10573 DECL_ACCESSORS(shared, SharedFunctionInfo) | 10593 DECL_ACCESSORS(shared, SharedFunctionInfo) |
10574 // Code object for the patched code. This code object is the code object | 10594 // Code object for the patched code. This code object is the code object |
10575 // currently active for the function. | 10595 // currently active for the function. |
10576 DECL_ACCESSORS(code, Code) | 10596 DECL_ACCESSORS(code, Code) |
10577 // Fixed array holding status information for each active break point. | 10597 // Fixed array holding status information for each active break point. |
10578 DECL_ACCESSORS(break_points, FixedArray) | 10598 DECL_ACCESSORS(break_points, FixedArray) |
10579 | 10599 |
10580 // Check if there is a break point at a code position. | 10600 // Check if there is a break point at a code offset. |
10581 bool HasBreakPoint(int code_position); | 10601 bool HasBreakPoint(int code_offset); |
10582 // Get the break point info object for a code position. | 10602 // Get the break point info object for a code offset. |
10583 Object* GetBreakPointInfo(int code_position); | 10603 Object* GetBreakPointInfo(int code_offset); |
10584 // Clear a break point. | 10604 // Clear a break point. |
10585 static void ClearBreakPoint(Handle<DebugInfo> debug_info, | 10605 static void ClearBreakPoint(Handle<DebugInfo> debug_info, int code_offset, |
10586 int code_position, | |
10587 Handle<Object> break_point_object); | 10606 Handle<Object> break_point_object); |
10588 // Set a break point. | 10607 // Set a break point. |
10589 static void SetBreakPoint(Handle<DebugInfo> debug_info, int code_position, | 10608 static void SetBreakPoint(Handle<DebugInfo> debug_info, int code_offset, |
10590 int source_position, int statement_position, | 10609 int source_position, int statement_position, |
10591 Handle<Object> break_point_object); | 10610 Handle<Object> break_point_object); |
10592 // Get the break point objects for a code position. | 10611 // Get the break point objects for a code offset. |
10593 Handle<Object> GetBreakPointObjects(int code_position); | 10612 Handle<Object> GetBreakPointObjects(int code_offset); |
10594 // Find the break point info holding this break point object. | 10613 // Find the break point info holding this break point object. |
10595 static Handle<Object> FindBreakPointInfo(Handle<DebugInfo> debug_info, | 10614 static Handle<Object> FindBreakPointInfo(Handle<DebugInfo> debug_info, |
10596 Handle<Object> break_point_object); | 10615 Handle<Object> break_point_object); |
10597 // Get the number of break points for this function. | 10616 // Get the number of break points for this function. |
10598 int GetBreakPointCount(); | 10617 int GetBreakPointCount(); |
10599 | 10618 |
10600 DECLARE_CAST(DebugInfo) | 10619 DECLARE_CAST(DebugInfo) |
10601 | 10620 |
10602 // Dispatched behavior. | 10621 // Dispatched behavior. |
10603 DECLARE_PRINTER(DebugInfo) | 10622 DECLARE_PRINTER(DebugInfo) |
10604 DECLARE_VERIFIER(DebugInfo) | 10623 DECLARE_VERIFIER(DebugInfo) |
10605 | 10624 |
10606 static const int kSharedFunctionInfoIndex = Struct::kHeaderSize; | 10625 static const int kSharedFunctionInfoIndex = Struct::kHeaderSize; |
10607 static const int kCodeIndex = kSharedFunctionInfoIndex + kPointerSize; | 10626 static const int kCodeIndex = kSharedFunctionInfoIndex + kPointerSize; |
10608 static const int kBreakPointsStateIndex = kCodeIndex + kPointerSize; | 10627 static const int kBreakPointsStateIndex = kCodeIndex + kPointerSize; |
10609 static const int kSize = kBreakPointsStateIndex + kPointerSize; | 10628 static const int kSize = kBreakPointsStateIndex + kPointerSize; |
10610 | 10629 |
10611 static const int kEstimatedNofBreakPointsInFunction = 16; | 10630 static const int kEstimatedNofBreakPointsInFunction = 16; |
10612 | 10631 |
10613 private: | 10632 private: |
10614 static const int kNoBreakPointInfo = -1; | 10633 static const int kNoBreakPointInfo = -1; |
10615 | 10634 |
10616 // Lookup the index in the break_points array for a code position. | 10635 // Lookup the index in the break_points array for a code offset. |
10617 int GetBreakPointInfoIndex(int code_position); | 10636 int GetBreakPointInfoIndex(int code_offset); |
10618 | 10637 |
10619 DISALLOW_IMPLICIT_CONSTRUCTORS(DebugInfo); | 10638 DISALLOW_IMPLICIT_CONSTRUCTORS(DebugInfo); |
10620 }; | 10639 }; |
10621 | 10640 |
10622 | 10641 |
10623 // The BreakPointInfo class holds information for break points set in a | 10642 // The BreakPointInfo class holds information for break points set in a |
10624 // function. The DebugInfo object holds a BreakPointInfo object for each code | 10643 // function. The DebugInfo object holds a BreakPointInfo object for each code |
10625 // position with one or more break points. | 10644 // position with one or more break points. |
10626 class BreakPointInfo: public Struct { | 10645 class BreakPointInfo: public Struct { |
10627 public: | 10646 public: |
10628 // The position in the code for the break point. | 10647 // The code offset for the break point. |
10629 DECL_INT_ACCESSORS(code_position) | 10648 DECL_INT_ACCESSORS(code_offset) |
10630 // The position in the source for the break position. | 10649 // The position in the source for the break position. |
10631 DECL_INT_ACCESSORS(source_position) | 10650 DECL_INT_ACCESSORS(source_position) |
10632 // The position in the source for the last statement before this break | 10651 // The position in the source for the last statement before this break |
10633 // position. | 10652 // position. |
10634 DECL_INT_ACCESSORS(statement_position) | 10653 DECL_INT_ACCESSORS(statement_position) |
10635 // List of related JavaScript break points. | 10654 // List of related JavaScript break points. |
10636 DECL_ACCESSORS(break_point_objects, Object) | 10655 DECL_ACCESSORS(break_point_objects, Object) |
10637 | 10656 |
10638 // Removes a break point. | 10657 // Removes a break point. |
10639 static void ClearBreakPoint(Handle<BreakPointInfo> info, | 10658 static void ClearBreakPoint(Handle<BreakPointInfo> info, |
10640 Handle<Object> break_point_object); | 10659 Handle<Object> break_point_object); |
10641 // Set a break point. | 10660 // Set a break point. |
10642 static void SetBreakPoint(Handle<BreakPointInfo> info, | 10661 static void SetBreakPoint(Handle<BreakPointInfo> info, |
10643 Handle<Object> break_point_object); | 10662 Handle<Object> break_point_object); |
10644 // Check if break point info has this break point object. | 10663 // Check if break point info has this break point object. |
10645 static bool HasBreakPointObject(Handle<BreakPointInfo> info, | 10664 static bool HasBreakPointObject(Handle<BreakPointInfo> info, |
10646 Handle<Object> break_point_object); | 10665 Handle<Object> break_point_object); |
10647 // Get the number of break points for this code position. | 10666 // Get the number of break points for this code offset. |
10648 int GetBreakPointCount(); | 10667 int GetBreakPointCount(); |
10649 | 10668 |
10650 DECLARE_CAST(BreakPointInfo) | 10669 DECLARE_CAST(BreakPointInfo) |
10651 | 10670 |
10652 // Dispatched behavior. | 10671 // Dispatched behavior. |
10653 DECLARE_PRINTER(BreakPointInfo) | 10672 DECLARE_PRINTER(BreakPointInfo) |
10654 DECLARE_VERIFIER(BreakPointInfo) | 10673 DECLARE_VERIFIER(BreakPointInfo) |
10655 | 10674 |
10656 static const int kCodePositionIndex = Struct::kHeaderSize; | 10675 static const int kCodeOffsetIndex = Struct::kHeaderSize; |
10657 static const int kSourcePositionIndex = kCodePositionIndex + kPointerSize; | 10676 static const int kSourcePositionIndex = kCodeOffsetIndex + kPointerSize; |
10658 static const int kStatementPositionIndex = | 10677 static const int kStatementPositionIndex = |
10659 kSourcePositionIndex + kPointerSize; | 10678 kSourcePositionIndex + kPointerSize; |
10660 static const int kBreakPointObjectsIndex = | 10679 static const int kBreakPointObjectsIndex = |
10661 kStatementPositionIndex + kPointerSize; | 10680 kStatementPositionIndex + kPointerSize; |
10662 static const int kSize = kBreakPointObjectsIndex + kPointerSize; | 10681 static const int kSize = kBreakPointObjectsIndex + kPointerSize; |
10663 | 10682 |
10664 private: | 10683 private: |
10665 DISALLOW_IMPLICIT_CONSTRUCTORS(BreakPointInfo); | 10684 DISALLOW_IMPLICIT_CONSTRUCTORS(BreakPointInfo); |
10666 }; | 10685 }; |
10667 | 10686 |
(...skipping 115 matching lines...) Loading... |
10783 } | 10802 } |
10784 return value; | 10803 return value; |
10785 } | 10804 } |
10786 }; | 10805 }; |
10787 | 10806 |
10788 | 10807 |
10789 } // NOLINT, false-positive due to second-order macros. | 10808 } // NOLINT, false-positive due to second-order macros. |
10790 } // NOLINT, false-positive due to second-order macros. | 10809 } // NOLINT, false-positive due to second-order macros. |
10791 | 10810 |
10792 #endif // V8_OBJECTS_H_ | 10811 #endif // V8_OBJECTS_H_ |
OLD | NEW |