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_FRAMES_H_ | 5 #ifndef V8_FRAMES_H_ |
6 #define V8_FRAMES_H_ | 6 #define V8_FRAMES_H_ |
7 | 7 |
8 #include "src/allocation.h" | 8 #include "src/allocation.h" |
9 #include "src/handles.h" | 9 #include "src/handles.h" |
10 #include "src/safepoint-table.h" | 10 #include "src/safepoint-table.h" |
(...skipping 12 matching lines...) Expand all Loading... |
23 | 23 |
24 void SetUpJSCallerSavedCodeData(); | 24 void SetUpJSCallerSavedCodeData(); |
25 | 25 |
26 // Return the code of the n-th saved register available to JavaScript. | 26 // Return the code of the n-th saved register available to JavaScript. |
27 int JSCallerSavedCode(int n); | 27 int JSCallerSavedCode(int n); |
28 | 28 |
29 | 29 |
30 // Forward declarations. | 30 // Forward declarations. |
31 class ExternalCallbackScope; | 31 class ExternalCallbackScope; |
32 class Isolate; | 32 class Isolate; |
| 33 class RootVisitor; |
33 class StackFrameIteratorBase; | 34 class StackFrameIteratorBase; |
34 class ThreadLocalTop; | 35 class ThreadLocalTop; |
35 class WasmInstanceObject; | 36 class WasmInstanceObject; |
36 | 37 |
37 class InnerPointerToCodeCache { | 38 class InnerPointerToCodeCache { |
38 public: | 39 public: |
39 struct InnerPointerToCodeCacheEntry { | 40 struct InnerPointerToCodeCacheEntry { |
40 Address inner_pointer; | 41 Address inner_pointer; |
41 Code* code; | 42 Code* code; |
42 SafepointEntry safepoint_entry; | 43 SafepointEntry safepoint_entry; |
(...skipping 539 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
582 static inline Code* GetContainingCode(Isolate* isolate, Address pc); | 583 static inline Code* GetContainingCode(Isolate* isolate, Address pc); |
583 | 584 |
584 // Get the code object containing the given pc and fill in the | 585 // Get the code object containing the given pc and fill in the |
585 // safepoint entry and the number of stack slots. The pc must be at | 586 // safepoint entry and the number of stack slots. The pc must be at |
586 // a safepoint. | 587 // a safepoint. |
587 static Code* GetSafepointData(Isolate* isolate, | 588 static Code* GetSafepointData(Isolate* isolate, |
588 Address pc, | 589 Address pc, |
589 SafepointEntry* safepoint_entry, | 590 SafepointEntry* safepoint_entry, |
590 unsigned* stack_slots); | 591 unsigned* stack_slots); |
591 | 592 |
592 virtual void Iterate(ObjectVisitor* v) const = 0; | 593 virtual void Iterate(RootVisitor* v) const = 0; |
593 static void IteratePc(ObjectVisitor* v, Address* pc_address, | 594 static void IteratePc(RootVisitor* v, Address* pc_address, |
594 Address* constant_pool_address, Code* holder); | 595 Address* constant_pool_address, Code* holder); |
595 | 596 |
596 // Sets a callback function for return-address rewriting profilers | 597 // Sets a callback function for return-address rewriting profilers |
597 // to resolve the location of a return address to the location of the | 598 // to resolve the location of a return address to the location of the |
598 // profiler's stashed return address. | 599 // profiler's stashed return address. |
599 static void SetReturnAddressLocationResolver( | 600 static void SetReturnAddressLocationResolver( |
600 ReturnAddressLocationResolver resolver); | 601 ReturnAddressLocationResolver resolver); |
601 | 602 |
602 // Resolves pc_address through the resolution address function if one is set. | 603 // Resolves pc_address through the resolution address function if one is set. |
603 static inline Address* ResolveReturnAddressLocation(Address* pc_address); | 604 static inline Address* ResolveReturnAddressLocation(Address* pc_address); |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
654 | 655 |
655 | 656 |
656 // Entry frames are used to enter JavaScript execution from C. | 657 // Entry frames are used to enter JavaScript execution from C. |
657 class EntryFrame: public StackFrame { | 658 class EntryFrame: public StackFrame { |
658 public: | 659 public: |
659 Type type() const override { return ENTRY; } | 660 Type type() const override { return ENTRY; } |
660 | 661 |
661 Code* unchecked_code() const override; | 662 Code* unchecked_code() const override; |
662 | 663 |
663 // Garbage collection support. | 664 // Garbage collection support. |
664 void Iterate(ObjectVisitor* v) const override; | 665 void Iterate(RootVisitor* v) const override; |
665 | 666 |
666 static EntryFrame* cast(StackFrame* frame) { | 667 static EntryFrame* cast(StackFrame* frame) { |
667 DCHECK(frame->is_entry()); | 668 DCHECK(frame->is_entry()); |
668 return static_cast<EntryFrame*>(frame); | 669 return static_cast<EntryFrame*>(frame); |
669 } | 670 } |
670 void SetCallerFp(Address caller_fp) override; | 671 void SetCallerFp(Address caller_fp) override; |
671 | 672 |
672 protected: | 673 protected: |
673 inline explicit EntryFrame(StackFrameIteratorBase* iterator); | 674 inline explicit EntryFrame(StackFrameIteratorBase* iterator); |
674 | 675 |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
707 // Exit frames are used to exit JavaScript execution and go to C. | 708 // Exit frames are used to exit JavaScript execution and go to C. |
708 class ExitFrame: public StackFrame { | 709 class ExitFrame: public StackFrame { |
709 public: | 710 public: |
710 Type type() const override { return EXIT; } | 711 Type type() const override { return EXIT; } |
711 | 712 |
712 Code* unchecked_code() const override; | 713 Code* unchecked_code() const override; |
713 | 714 |
714 Object*& code_slot() const; | 715 Object*& code_slot() const; |
715 | 716 |
716 // Garbage collection support. | 717 // Garbage collection support. |
717 void Iterate(ObjectVisitor* v) const override; | 718 void Iterate(RootVisitor* v) const override; |
718 | 719 |
719 void SetCallerFp(Address caller_fp) override; | 720 void SetCallerFp(Address caller_fp) override; |
720 | 721 |
721 static ExitFrame* cast(StackFrame* frame) { | 722 static ExitFrame* cast(StackFrame* frame) { |
722 DCHECK(frame->is_exit()); | 723 DCHECK(frame->is_exit()); |
723 return static_cast<ExitFrame*>(frame); | 724 return static_cast<ExitFrame*>(frame); |
724 } | 725 } |
725 | 726 |
726 // Compute the state and type of an exit frame given a frame | 727 // Compute the state and type of an exit frame given a frame |
727 // pointer. Used when constructing the first stack frame seen by an | 728 // pointer. Used when constructing the first stack frame seen by an |
(...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
986 // Computes the address of the PC field in the standard frame given | 987 // Computes the address of the PC field in the standard frame given |
987 // by the provided frame pointer. | 988 // by the provided frame pointer. |
988 static inline Address ComputePCAddress(Address fp); | 989 static inline Address ComputePCAddress(Address fp); |
989 | 990 |
990 // Computes the address of the constant pool field in the standard | 991 // Computes the address of the constant pool field in the standard |
991 // frame given by the provided frame pointer. | 992 // frame given by the provided frame pointer. |
992 static inline Address ComputeConstantPoolAddress(Address fp); | 993 static inline Address ComputeConstantPoolAddress(Address fp); |
993 | 994 |
994 // Iterate over expression stack including stack handlers, locals, | 995 // Iterate over expression stack including stack handlers, locals, |
995 // and parts of the fixed part including context and code fields. | 996 // and parts of the fixed part including context and code fields. |
996 void IterateExpressions(ObjectVisitor* v) const; | 997 void IterateExpressions(RootVisitor* v) const; |
997 | 998 |
998 // Returns the address of the n'th expression stack element. | 999 // Returns the address of the n'th expression stack element. |
999 virtual Address GetExpressionAddress(int n) const; | 1000 virtual Address GetExpressionAddress(int n) const; |
1000 | 1001 |
1001 // Determines if the standard frame for the given frame pointer is | 1002 // Determines if the standard frame for the given frame pointer is |
1002 // an arguments adaptor frame. | 1003 // an arguments adaptor frame. |
1003 static inline bool IsArgumentsAdaptorFrame(Address fp); | 1004 static inline bool IsArgumentsAdaptorFrame(Address fp); |
1004 | 1005 |
1005 // Determines if the standard frame for the given frame pointer is a | 1006 // Determines if the standard frame for the given frame pointer is a |
1006 // construct frame. | 1007 // construct frame. |
1007 static inline bool IsConstructFrame(Address fp); | 1008 static inline bool IsConstructFrame(Address fp); |
1008 | 1009 |
1009 // Used by OptimizedFrames and StubFrames. | 1010 // Used by OptimizedFrames and StubFrames. |
1010 void IterateCompiledFrame(ObjectVisitor* v) const; | 1011 void IterateCompiledFrame(RootVisitor* v) const; |
1011 | 1012 |
1012 private: | 1013 private: |
1013 friend class StackFrame; | 1014 friend class StackFrame; |
1014 friend class SafeStackFrameIterator; | 1015 friend class SafeStackFrameIterator; |
1015 }; | 1016 }; |
1016 | 1017 |
1017 class JavaScriptFrame : public StandardFrame { | 1018 class JavaScriptFrame : public StandardFrame { |
1018 public: | 1019 public: |
1019 Type type() const override { return JAVA_SCRIPT; } | 1020 Type type() const override { return JAVA_SCRIPT; } |
1020 | 1021 |
(...skipping 29 matching lines...) Expand all Loading... |
1050 // about the inlined frames use {GetFunctions} and {Summarize}. | 1051 // about the inlined frames use {GetFunctions} and {Summarize}. |
1051 bool HasInlinedFrames() const; | 1052 bool HasInlinedFrames() const; |
1052 | 1053 |
1053 // Check if this frame has "adapted" arguments in the sense that the | 1054 // Check if this frame has "adapted" arguments in the sense that the |
1054 // actual passed arguments are available in an arguments adaptor | 1055 // actual passed arguments are available in an arguments adaptor |
1055 // frame below it on the stack. | 1056 // frame below it on the stack. |
1056 inline bool has_adapted_arguments() const; | 1057 inline bool has_adapted_arguments() const; |
1057 int GetArgumentsLength() const; | 1058 int GetArgumentsLength() const; |
1058 | 1059 |
1059 // Garbage collection support. | 1060 // Garbage collection support. |
1060 void Iterate(ObjectVisitor* v) const override; | 1061 void Iterate(RootVisitor* v) const override; |
1061 | 1062 |
1062 // Printing support. | 1063 // Printing support. |
1063 void Print(StringStream* accumulator, PrintMode mode, | 1064 void Print(StringStream* accumulator, PrintMode mode, |
1064 int index) const override; | 1065 int index) const override; |
1065 | 1066 |
1066 // Determine the code for the frame. | 1067 // Determine the code for the frame. |
1067 Code* unchecked_code() const override; | 1068 Code* unchecked_code() const override; |
1068 | 1069 |
1069 // Return a list with {SharedFunctionInfo} objects of this frame. | 1070 // Return a list with {SharedFunctionInfo} objects of this frame. |
1070 virtual void GetFunctions(List<SharedFunctionInfo*>* functions) const; | 1071 virtual void GetFunctions(List<SharedFunctionInfo*>* functions) const; |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1102 | 1103 |
1103 protected: | 1104 protected: |
1104 inline explicit JavaScriptFrame(StackFrameIteratorBase* iterator); | 1105 inline explicit JavaScriptFrame(StackFrameIteratorBase* iterator); |
1105 | 1106 |
1106 Address GetCallerStackPointer() const override; | 1107 Address GetCallerStackPointer() const override; |
1107 | 1108 |
1108 virtual int GetNumberOfIncomingArguments() const; | 1109 virtual int GetNumberOfIncomingArguments() const; |
1109 | 1110 |
1110 // Garbage collection support. Iterates over incoming arguments, | 1111 // Garbage collection support. Iterates over incoming arguments, |
1111 // receiver, and any callee-saved registers. | 1112 // receiver, and any callee-saved registers. |
1112 void IterateArguments(ObjectVisitor* v) const; | 1113 void IterateArguments(RootVisitor* v) const; |
1113 | 1114 |
1114 virtual void PrintFrameKind(StringStream* accumulator) const {} | 1115 virtual void PrintFrameKind(StringStream* accumulator) const {} |
1115 | 1116 |
1116 private: | 1117 private: |
1117 inline Object* function_slot_object() const; | 1118 inline Object* function_slot_object() const; |
1118 | 1119 |
1119 friend class StackFrameIteratorBase; | 1120 friend class StackFrameIteratorBase; |
1120 }; | 1121 }; |
1121 | 1122 |
1122 | 1123 |
1123 class StubFrame : public StandardFrame { | 1124 class StubFrame : public StandardFrame { |
1124 public: | 1125 public: |
1125 Type type() const override { return STUB; } | 1126 Type type() const override { return STUB; } |
1126 | 1127 |
1127 // GC support. | 1128 // GC support. |
1128 void Iterate(ObjectVisitor* v) const override; | 1129 void Iterate(RootVisitor* v) const override; |
1129 | 1130 |
1130 // Determine the code for the frame. | 1131 // Determine the code for the frame. |
1131 Code* unchecked_code() const override; | 1132 Code* unchecked_code() const override; |
1132 | 1133 |
1133 // Lookup exception handler for current {pc}, returns -1 if none found. Only | 1134 // Lookup exception handler for current {pc}, returns -1 if none found. Only |
1134 // TurboFan stub frames are supported. Also returns data associated with the | 1135 // TurboFan stub frames are supported. Also returns data associated with the |
1135 // handler site: | 1136 // handler site: |
1136 // - TurboFan stub: Data is the stack slot count of the entire frame. | 1137 // - TurboFan stub: Data is the stack slot count of the entire frame. |
1137 int LookupExceptionHandlerInTable(int* data); | 1138 int LookupExceptionHandlerInTable(int* data); |
1138 | 1139 |
1139 protected: | 1140 protected: |
1140 inline explicit StubFrame(StackFrameIteratorBase* iterator); | 1141 inline explicit StubFrame(StackFrameIteratorBase* iterator); |
1141 | 1142 |
1142 Address GetCallerStackPointer() const override; | 1143 Address GetCallerStackPointer() const override; |
1143 | 1144 |
1144 virtual int GetNumberOfIncomingArguments() const; | 1145 virtual int GetNumberOfIncomingArguments() const; |
1145 | 1146 |
1146 friend class StackFrameIteratorBase; | 1147 friend class StackFrameIteratorBase; |
1147 }; | 1148 }; |
1148 | 1149 |
1149 | 1150 |
1150 class OptimizedFrame : public JavaScriptFrame { | 1151 class OptimizedFrame : public JavaScriptFrame { |
1151 public: | 1152 public: |
1152 Type type() const override { return OPTIMIZED; } | 1153 Type type() const override { return OPTIMIZED; } |
1153 | 1154 |
1154 // GC support. | 1155 // GC support. |
1155 void Iterate(ObjectVisitor* v) const override; | 1156 void Iterate(RootVisitor* v) const override; |
1156 | 1157 |
1157 // Return a list with {SharedFunctionInfo} objects of this frame. | 1158 // Return a list with {SharedFunctionInfo} objects of this frame. |
1158 // The functions are ordered bottom-to-top (i.e. functions.last() | 1159 // The functions are ordered bottom-to-top (i.e. functions.last() |
1159 // is the top-most activation) | 1160 // is the top-most activation) |
1160 void GetFunctions(List<SharedFunctionInfo*>* functions) const override; | 1161 void GetFunctions(List<SharedFunctionInfo*>* functions) const override; |
1161 | 1162 |
1162 void Summarize( | 1163 void Summarize( |
1163 List<FrameSummary>* frames, | 1164 List<FrameSummary>* frames, |
1164 FrameSummary::Mode mode = FrameSummary::kExactSummary) const override; | 1165 FrameSummary::Mode mode = FrameSummary::kExactSummary) const override; |
1165 | 1166 |
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1278 | 1279 |
1279 private: | 1280 private: |
1280 friend class StackFrameIteratorBase; | 1281 friend class StackFrameIteratorBase; |
1281 }; | 1282 }; |
1282 | 1283 |
1283 class WasmCompiledFrame final : public StandardFrame { | 1284 class WasmCompiledFrame final : public StandardFrame { |
1284 public: | 1285 public: |
1285 Type type() const override { return WASM_COMPILED; } | 1286 Type type() const override { return WASM_COMPILED; } |
1286 | 1287 |
1287 // GC support. | 1288 // GC support. |
1288 void Iterate(ObjectVisitor* v) const override; | 1289 void Iterate(RootVisitor* v) const override; |
1289 | 1290 |
1290 // Printing support. | 1291 // Printing support. |
1291 void Print(StringStream* accumulator, PrintMode mode, | 1292 void Print(StringStream* accumulator, PrintMode mode, |
1292 int index) const override; | 1293 int index) const override; |
1293 | 1294 |
1294 // Lookup exception handler for current {pc}, returns -1 if none found. Also | 1295 // Lookup exception handler for current {pc}, returns -1 if none found. Also |
1295 // returns the stack slot count of the entire frame. | 1296 // returns the stack slot count of the entire frame. |
1296 int LookupExceptionHandlerInTable(int* data); | 1297 int LookupExceptionHandlerInTable(int* data); |
1297 | 1298 |
1298 // Determine the code for the frame. | 1299 // Determine the code for the frame. |
(...skipping 21 matching lines...) Expand all Loading... |
1320 | 1321 |
1321 private: | 1322 private: |
1322 friend class StackFrameIteratorBase; | 1323 friend class StackFrameIteratorBase; |
1323 }; | 1324 }; |
1324 | 1325 |
1325 class WasmInterpreterEntryFrame final : public StandardFrame { | 1326 class WasmInterpreterEntryFrame final : public StandardFrame { |
1326 public: | 1327 public: |
1327 Type type() const override { return WASM_INTERPRETER_ENTRY; } | 1328 Type type() const override { return WASM_INTERPRETER_ENTRY; } |
1328 | 1329 |
1329 // GC support. | 1330 // GC support. |
1330 void Iterate(ObjectVisitor* v) const override; | 1331 void Iterate(RootVisitor* v) const override; |
1331 | 1332 |
1332 // Printing support. | 1333 // Printing support. |
1333 void Print(StringStream* accumulator, PrintMode mode, | 1334 void Print(StringStream* accumulator, PrintMode mode, |
1334 int index) const override; | 1335 int index) const override; |
1335 | 1336 |
1336 void Summarize( | 1337 void Summarize( |
1337 List<FrameSummary>* frames, | 1338 List<FrameSummary>* frames, |
1338 FrameSummary::Mode mode = FrameSummary::kExactSummary) const override; | 1339 FrameSummary::Mode mode = FrameSummary::kExactSummary) const override; |
1339 | 1340 |
1340 // Determine the code for the frame. | 1341 // Determine the code for the frame. |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1379 | 1380 |
1380 private: | 1381 private: |
1381 friend class StackFrameIteratorBase; | 1382 friend class StackFrameIteratorBase; |
1382 }; | 1383 }; |
1383 | 1384 |
1384 class InternalFrame: public StandardFrame { | 1385 class InternalFrame: public StandardFrame { |
1385 public: | 1386 public: |
1386 Type type() const override { return INTERNAL; } | 1387 Type type() const override { return INTERNAL; } |
1387 | 1388 |
1388 // Garbage collection support. | 1389 // Garbage collection support. |
1389 void Iterate(ObjectVisitor* v) const override; | 1390 void Iterate(RootVisitor* v) const override; |
1390 | 1391 |
1391 // Determine the code for the frame. | 1392 // Determine the code for the frame. |
1392 Code* unchecked_code() const override; | 1393 Code* unchecked_code() const override; |
1393 | 1394 |
1394 static InternalFrame* cast(StackFrame* frame) { | 1395 static InternalFrame* cast(StackFrame* frame) { |
1395 DCHECK(frame->is_internal()); | 1396 DCHECK(frame->is_internal()); |
1396 return static_cast<InternalFrame*>(frame); | 1397 return static_cast<InternalFrame*>(frame); |
1397 } | 1398 } |
1398 | 1399 |
1399 protected: | 1400 protected: |
1400 inline explicit InternalFrame(StackFrameIteratorBase* iterator); | 1401 inline explicit InternalFrame(StackFrameIteratorBase* iterator); |
1401 | 1402 |
1402 Address GetCallerStackPointer() const override; | 1403 Address GetCallerStackPointer() const override; |
1403 | 1404 |
1404 private: | 1405 private: |
1405 friend class StackFrameIteratorBase; | 1406 friend class StackFrameIteratorBase; |
1406 }; | 1407 }; |
1407 | 1408 |
1408 | 1409 |
1409 class StubFailureTrampolineFrame: public StandardFrame { | 1410 class StubFailureTrampolineFrame: public StandardFrame { |
1410 public: | 1411 public: |
1411 Type type() const override { return STUB_FAILURE_TRAMPOLINE; } | 1412 Type type() const override { return STUB_FAILURE_TRAMPOLINE; } |
1412 | 1413 |
1413 // Get the code associated with this frame. | 1414 // Get the code associated with this frame. |
1414 // This method could be called during marking phase of GC. | 1415 // This method could be called during marking phase of GC. |
1415 Code* unchecked_code() const override; | 1416 Code* unchecked_code() const override; |
1416 | 1417 |
1417 void Iterate(ObjectVisitor* v) const override; | 1418 void Iterate(RootVisitor* v) const override; |
1418 | 1419 |
1419 // Architecture-specific register description. | 1420 // Architecture-specific register description. |
1420 static Register fp_register(); | 1421 static Register fp_register(); |
1421 static Register context_register(); | 1422 static Register context_register(); |
1422 static Register constant_pool_pointer_register(); | 1423 static Register constant_pool_pointer_register(); |
1423 | 1424 |
1424 protected: | 1425 protected: |
1425 inline explicit StubFailureTrampolineFrame( | 1426 inline explicit StubFailureTrampolineFrame( |
1426 StackFrameIteratorBase* iterator); | 1427 StackFrameIteratorBase* iterator); |
1427 | 1428 |
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1596 | 1597 |
1597 | 1598 |
1598 // Reads all frames on the current stack and copies them into the current | 1599 // Reads all frames on the current stack and copies them into the current |
1599 // zone memory. | 1600 // zone memory. |
1600 Vector<StackFrame*> CreateStackMap(Isolate* isolate, Zone* zone); | 1601 Vector<StackFrame*> CreateStackMap(Isolate* isolate, Zone* zone); |
1601 | 1602 |
1602 } // namespace internal | 1603 } // namespace internal |
1603 } // namespace v8 | 1604 } // namespace v8 |
1604 | 1605 |
1605 #endif // V8_FRAMES_H_ | 1606 #endif // V8_FRAMES_H_ |
OLD | NEW |