Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(370)

Side by Side Diff: src/frames.h

Issue 2801073006: Decouple root visitors from object visitors. (Closed)
Patch Set: rebase Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/debug/debug.cc ('k') | src/frames.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/flags.h" 9 #include "src/flags.h"
10 #include "src/handles.h" 10 #include "src/handles.h"
(...skipping 18 matching lines...) Expand all
29 29
30 void SetUpJSCallerSavedCodeData(); 30 void SetUpJSCallerSavedCodeData();
31 31
32 // Return the code of the n-th saved register available to JavaScript. 32 // Return the code of the n-th saved register available to JavaScript.
33 int JSCallerSavedCode(int n); 33 int JSCallerSavedCode(int n);
34 34
35 35
36 // Forward declarations. 36 // Forward declarations.
37 class ExternalCallbackScope; 37 class ExternalCallbackScope;
38 class Isolate; 38 class Isolate;
39 class RootVisitor;
39 class StackFrameIteratorBase; 40 class StackFrameIteratorBase;
40 class ThreadLocalTop; 41 class ThreadLocalTop;
41 class WasmInstanceObject; 42 class WasmInstanceObject;
42 43
43 class InnerPointerToCodeCache { 44 class InnerPointerToCodeCache {
44 public: 45 public:
45 struct InnerPointerToCodeCacheEntry { 46 struct InnerPointerToCodeCacheEntry {
46 Address inner_pointer; 47 Address inner_pointer;
47 Code* code; 48 Code* code;
48 SafepointEntry safepoint_entry; 49 SafepointEntry safepoint_entry;
(...skipping 539 matching lines...) Expand 10 before | Expand all | Expand 10 after
588 static inline Code* GetContainingCode(Isolate* isolate, Address pc); 589 static inline Code* GetContainingCode(Isolate* isolate, Address pc);
589 590
590 // Get the code object containing the given pc and fill in the 591 // Get the code object containing the given pc and fill in the
591 // safepoint entry and the number of stack slots. The pc must be at 592 // safepoint entry and the number of stack slots. The pc must be at
592 // a safepoint. 593 // a safepoint.
593 static Code* GetSafepointData(Isolate* isolate, 594 static Code* GetSafepointData(Isolate* isolate,
594 Address pc, 595 Address pc,
595 SafepointEntry* safepoint_entry, 596 SafepointEntry* safepoint_entry,
596 unsigned* stack_slots); 597 unsigned* stack_slots);
597 598
598 virtual void Iterate(ObjectVisitor* v) const = 0; 599 virtual void Iterate(RootVisitor* v) const = 0;
599 static void IteratePc(ObjectVisitor* v, Address* pc_address, 600 static void IteratePc(RootVisitor* v, Address* pc_address,
600 Address* constant_pool_address, Code* holder); 601 Address* constant_pool_address, Code* holder);
601 602
602 // Sets a callback function for return-address rewriting profilers 603 // Sets a callback function for return-address rewriting profilers
603 // to resolve the location of a return address to the location of the 604 // to resolve the location of a return address to the location of the
604 // profiler's stashed return address. 605 // profiler's stashed return address.
605 static void SetReturnAddressLocationResolver( 606 static void SetReturnAddressLocationResolver(
606 ReturnAddressLocationResolver resolver); 607 ReturnAddressLocationResolver resolver);
607 608
608 // Resolves pc_address through the resolution address function if one is set. 609 // Resolves pc_address through the resolution address function if one is set.
609 static inline Address* ResolveReturnAddressLocation(Address* pc_address); 610 static inline Address* ResolveReturnAddressLocation(Address* pc_address);
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
660 661
661 662
662 // Entry frames are used to enter JavaScript execution from C. 663 // Entry frames are used to enter JavaScript execution from C.
663 class EntryFrame: public StackFrame { 664 class EntryFrame: public StackFrame {
664 public: 665 public:
665 Type type() const override { return ENTRY; } 666 Type type() const override { return ENTRY; }
666 667
667 Code* unchecked_code() const override; 668 Code* unchecked_code() const override;
668 669
669 // Garbage collection support. 670 // Garbage collection support.
670 void Iterate(ObjectVisitor* v) const override; 671 void Iterate(RootVisitor* v) const override;
671 672
672 static EntryFrame* cast(StackFrame* frame) { 673 static EntryFrame* cast(StackFrame* frame) {
673 DCHECK(frame->is_entry()); 674 DCHECK(frame->is_entry());
674 return static_cast<EntryFrame*>(frame); 675 return static_cast<EntryFrame*>(frame);
675 } 676 }
676 void SetCallerFp(Address caller_fp) override; 677 void SetCallerFp(Address caller_fp) override;
677 678
678 protected: 679 protected:
679 inline explicit EntryFrame(StackFrameIteratorBase* iterator); 680 inline explicit EntryFrame(StackFrameIteratorBase* iterator);
680 681
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
713 // Exit frames are used to exit JavaScript execution and go to C. 714 // Exit frames are used to exit JavaScript execution and go to C.
714 class ExitFrame: public StackFrame { 715 class ExitFrame: public StackFrame {
715 public: 716 public:
716 Type type() const override { return EXIT; } 717 Type type() const override { return EXIT; }
717 718
718 Code* unchecked_code() const override; 719 Code* unchecked_code() const override;
719 720
720 Object*& code_slot() const; 721 Object*& code_slot() const;
721 722
722 // Garbage collection support. 723 // Garbage collection support.
723 void Iterate(ObjectVisitor* v) const override; 724 void Iterate(RootVisitor* v) const override;
724 725
725 void SetCallerFp(Address caller_fp) override; 726 void SetCallerFp(Address caller_fp) override;
726 727
727 static ExitFrame* cast(StackFrame* frame) { 728 static ExitFrame* cast(StackFrame* frame) {
728 DCHECK(frame->is_exit()); 729 DCHECK(frame->is_exit());
729 return static_cast<ExitFrame*>(frame); 730 return static_cast<ExitFrame*>(frame);
730 } 731 }
731 732
732 // Compute the state and type of an exit frame given a frame 733 // Compute the state and type of an exit frame given a frame
733 // pointer. Used when constructing the first stack frame seen by an 734 // pointer. Used when constructing the first stack frame seen by an
(...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after
992 // Computes the address of the PC field in the standard frame given 993 // Computes the address of the PC field in the standard frame given
993 // by the provided frame pointer. 994 // by the provided frame pointer.
994 static inline Address ComputePCAddress(Address fp); 995 static inline Address ComputePCAddress(Address fp);
995 996
996 // Computes the address of the constant pool field in the standard 997 // Computes the address of the constant pool field in the standard
997 // frame given by the provided frame pointer. 998 // frame given by the provided frame pointer.
998 static inline Address ComputeConstantPoolAddress(Address fp); 999 static inline Address ComputeConstantPoolAddress(Address fp);
999 1000
1000 // Iterate over expression stack including stack handlers, locals, 1001 // Iterate over expression stack including stack handlers, locals,
1001 // and parts of the fixed part including context and code fields. 1002 // and parts of the fixed part including context and code fields.
1002 void IterateExpressions(ObjectVisitor* v) const; 1003 void IterateExpressions(RootVisitor* v) const;
1003 1004
1004 // Returns the address of the n'th expression stack element. 1005 // Returns the address of the n'th expression stack element.
1005 virtual Address GetExpressionAddress(int n) const; 1006 virtual Address GetExpressionAddress(int n) const;
1006 1007
1007 // Determines if the standard frame for the given frame pointer is 1008 // Determines if the standard frame for the given frame pointer is
1008 // an arguments adaptor frame. 1009 // an arguments adaptor frame.
1009 static inline bool IsArgumentsAdaptorFrame(Address fp); 1010 static inline bool IsArgumentsAdaptorFrame(Address fp);
1010 1011
1011 // Determines if the standard frame for the given frame pointer is a 1012 // Determines if the standard frame for the given frame pointer is a
1012 // construct frame. 1013 // construct frame.
1013 static inline bool IsConstructFrame(Address fp); 1014 static inline bool IsConstructFrame(Address fp);
1014 1015
1015 // Used by OptimizedFrames and StubFrames. 1016 // Used by OptimizedFrames and StubFrames.
1016 void IterateCompiledFrame(ObjectVisitor* v) const; 1017 void IterateCompiledFrame(RootVisitor* v) const;
1017 1018
1018 private: 1019 private:
1019 friend class StackFrame; 1020 friend class StackFrame;
1020 friend class SafeStackFrameIterator; 1021 friend class SafeStackFrameIterator;
1021 }; 1022 };
1022 1023
1023 class JavaScriptFrame : public StandardFrame { 1024 class JavaScriptFrame : public StandardFrame {
1024 public: 1025 public:
1025 Type type() const override { return JAVA_SCRIPT; } 1026 Type type() const override { return JAVA_SCRIPT; }
1026 1027
(...skipping 29 matching lines...) Expand all
1056 // about the inlined frames use {GetFunctions} and {Summarize}. 1057 // about the inlined frames use {GetFunctions} and {Summarize}.
1057 bool HasInlinedFrames() const; 1058 bool HasInlinedFrames() const;
1058 1059
1059 // Check if this frame has "adapted" arguments in the sense that the 1060 // Check if this frame has "adapted" arguments in the sense that the
1060 // actual passed arguments are available in an arguments adaptor 1061 // actual passed arguments are available in an arguments adaptor
1061 // frame below it on the stack. 1062 // frame below it on the stack.
1062 inline bool has_adapted_arguments() const; 1063 inline bool has_adapted_arguments() const;
1063 int GetArgumentsLength() const; 1064 int GetArgumentsLength() const;
1064 1065
1065 // Garbage collection support. 1066 // Garbage collection support.
1066 void Iterate(ObjectVisitor* v) const override; 1067 void Iterate(RootVisitor* v) const override;
1067 1068
1068 // Printing support. 1069 // Printing support.
1069 void Print(StringStream* accumulator, PrintMode mode, 1070 void Print(StringStream* accumulator, PrintMode mode,
1070 int index) const override; 1071 int index) const override;
1071 1072
1072 // Determine the code for the frame. 1073 // Determine the code for the frame.
1073 Code* unchecked_code() const override; 1074 Code* unchecked_code() const override;
1074 1075
1075 // Return a list with {SharedFunctionInfo} objects of this frame. 1076 // Return a list with {SharedFunctionInfo} objects of this frame.
1076 virtual void GetFunctions(List<SharedFunctionInfo*>* functions) const; 1077 virtual void GetFunctions(List<SharedFunctionInfo*>* functions) const;
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
1108 1109
1109 protected: 1110 protected:
1110 inline explicit JavaScriptFrame(StackFrameIteratorBase* iterator); 1111 inline explicit JavaScriptFrame(StackFrameIteratorBase* iterator);
1111 1112
1112 Address GetCallerStackPointer() const override; 1113 Address GetCallerStackPointer() const override;
1113 1114
1114 virtual int GetNumberOfIncomingArguments() const; 1115 virtual int GetNumberOfIncomingArguments() const;
1115 1116
1116 // Garbage collection support. Iterates over incoming arguments, 1117 // Garbage collection support. Iterates over incoming arguments,
1117 // receiver, and any callee-saved registers. 1118 // receiver, and any callee-saved registers.
1118 void IterateArguments(ObjectVisitor* v) const; 1119 void IterateArguments(RootVisitor* v) const;
1119 1120
1120 virtual void PrintFrameKind(StringStream* accumulator) const {} 1121 virtual void PrintFrameKind(StringStream* accumulator) const {}
1121 1122
1122 private: 1123 private:
1123 inline Object* function_slot_object() const; 1124 inline Object* function_slot_object() const;
1124 1125
1125 friend class StackFrameIteratorBase; 1126 friend class StackFrameIteratorBase;
1126 }; 1127 };
1127 1128
1128 1129
1129 class StubFrame : public StandardFrame { 1130 class StubFrame : public StandardFrame {
1130 public: 1131 public:
1131 Type type() const override { return STUB; } 1132 Type type() const override { return STUB; }
1132 1133
1133 // GC support. 1134 // GC support.
1134 void Iterate(ObjectVisitor* v) const override; 1135 void Iterate(RootVisitor* v) const override;
1135 1136
1136 // Determine the code for the frame. 1137 // Determine the code for the frame.
1137 Code* unchecked_code() const override; 1138 Code* unchecked_code() const override;
1138 1139
1139 // Lookup exception handler for current {pc}, returns -1 if none found. Only 1140 // Lookup exception handler for current {pc}, returns -1 if none found. Only
1140 // TurboFan stub frames are supported. Also returns data associated with the 1141 // TurboFan stub frames are supported. Also returns data associated with the
1141 // handler site: 1142 // handler site:
1142 // - TurboFan stub: Data is the stack slot count of the entire frame. 1143 // - TurboFan stub: Data is the stack slot count of the entire frame.
1143 int LookupExceptionHandlerInTable(int* data); 1144 int LookupExceptionHandlerInTable(int* data);
1144 1145
1145 protected: 1146 protected:
1146 inline explicit StubFrame(StackFrameIteratorBase* iterator); 1147 inline explicit StubFrame(StackFrameIteratorBase* iterator);
1147 1148
1148 Address GetCallerStackPointer() const override; 1149 Address GetCallerStackPointer() const override;
1149 1150
1150 virtual int GetNumberOfIncomingArguments() const; 1151 virtual int GetNumberOfIncomingArguments() const;
1151 1152
1152 friend class StackFrameIteratorBase; 1153 friend class StackFrameIteratorBase;
1153 }; 1154 };
1154 1155
1155 1156
1156 class OptimizedFrame : public JavaScriptFrame { 1157 class OptimizedFrame : public JavaScriptFrame {
1157 public: 1158 public:
1158 Type type() const override { return OPTIMIZED; } 1159 Type type() const override { return OPTIMIZED; }
1159 1160
1160 // GC support. 1161 // GC support.
1161 void Iterate(ObjectVisitor* v) const override; 1162 void Iterate(RootVisitor* v) const override;
1162 1163
1163 // Return a list with {SharedFunctionInfo} objects of this frame. 1164 // Return a list with {SharedFunctionInfo} objects of this frame.
1164 // The functions are ordered bottom-to-top (i.e. functions.last() 1165 // The functions are ordered bottom-to-top (i.e. functions.last()
1165 // is the top-most activation) 1166 // is the top-most activation)
1166 void GetFunctions(List<SharedFunctionInfo*>* functions) const override; 1167 void GetFunctions(List<SharedFunctionInfo*>* functions) const override;
1167 1168
1168 void Summarize( 1169 void Summarize(
1169 List<FrameSummary>* frames, 1170 List<FrameSummary>* frames,
1170 FrameSummary::Mode mode = FrameSummary::kExactSummary) const override; 1171 FrameSummary::Mode mode = FrameSummary::kExactSummary) const override;
1171 1172
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
1284 1285
1285 private: 1286 private:
1286 friend class StackFrameIteratorBase; 1287 friend class StackFrameIteratorBase;
1287 }; 1288 };
1288 1289
1289 class WasmCompiledFrame final : public StandardFrame { 1290 class WasmCompiledFrame final : public StandardFrame {
1290 public: 1291 public:
1291 Type type() const override { return WASM_COMPILED; } 1292 Type type() const override { return WASM_COMPILED; }
1292 1293
1293 // GC support. 1294 // GC support.
1294 void Iterate(ObjectVisitor* v) const override; 1295 void Iterate(RootVisitor* v) const override;
1295 1296
1296 // Printing support. 1297 // Printing support.
1297 void Print(StringStream* accumulator, PrintMode mode, 1298 void Print(StringStream* accumulator, PrintMode mode,
1298 int index) const override; 1299 int index) const override;
1299 1300
1300 // Lookup exception handler for current {pc}, returns -1 if none found. Also 1301 // Lookup exception handler for current {pc}, returns -1 if none found. Also
1301 // returns the stack slot count of the entire frame. 1302 // returns the stack slot count of the entire frame.
1302 int LookupExceptionHandlerInTable(int* data); 1303 int LookupExceptionHandlerInTable(int* data);
1303 1304
1304 // Determine the code for the frame. 1305 // Determine the code for the frame.
(...skipping 21 matching lines...) Expand all
1326 1327
1327 private: 1328 private:
1328 friend class StackFrameIteratorBase; 1329 friend class StackFrameIteratorBase;
1329 }; 1330 };
1330 1331
1331 class WasmInterpreterEntryFrame final : public StandardFrame { 1332 class WasmInterpreterEntryFrame final : public StandardFrame {
1332 public: 1333 public:
1333 Type type() const override { return WASM_INTERPRETER_ENTRY; } 1334 Type type() const override { return WASM_INTERPRETER_ENTRY; }
1334 1335
1335 // GC support. 1336 // GC support.
1336 void Iterate(ObjectVisitor* v) const override; 1337 void Iterate(RootVisitor* v) const override;
1337 1338
1338 // Printing support. 1339 // Printing support.
1339 void Print(StringStream* accumulator, PrintMode mode, 1340 void Print(StringStream* accumulator, PrintMode mode,
1340 int index) const override; 1341 int index) const override;
1341 1342
1342 void Summarize( 1343 void Summarize(
1343 List<FrameSummary>* frames, 1344 List<FrameSummary>* frames,
1344 FrameSummary::Mode mode = FrameSummary::kExactSummary) const override; 1345 FrameSummary::Mode mode = FrameSummary::kExactSummary) const override;
1345 1346
1346 // Determine the code for the frame. 1347 // Determine the code for the frame.
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
1386 1387
1387 private: 1388 private:
1388 friend class StackFrameIteratorBase; 1389 friend class StackFrameIteratorBase;
1389 }; 1390 };
1390 1391
1391 class InternalFrame: public StandardFrame { 1392 class InternalFrame: public StandardFrame {
1392 public: 1393 public:
1393 Type type() const override { return INTERNAL; } 1394 Type type() const override { return INTERNAL; }
1394 1395
1395 // Garbage collection support. 1396 // Garbage collection support.
1396 void Iterate(ObjectVisitor* v) const override; 1397 void Iterate(RootVisitor* v) const override;
1397 1398
1398 // Determine the code for the frame. 1399 // Determine the code for the frame.
1399 Code* unchecked_code() const override; 1400 Code* unchecked_code() const override;
1400 1401
1401 static InternalFrame* cast(StackFrame* frame) { 1402 static InternalFrame* cast(StackFrame* frame) {
1402 DCHECK(frame->is_internal()); 1403 DCHECK(frame->is_internal());
1403 return static_cast<InternalFrame*>(frame); 1404 return static_cast<InternalFrame*>(frame);
1404 } 1405 }
1405 1406
1406 protected: 1407 protected:
1407 inline explicit InternalFrame(StackFrameIteratorBase* iterator); 1408 inline explicit InternalFrame(StackFrameIteratorBase* iterator);
1408 1409
1409 Address GetCallerStackPointer() const override; 1410 Address GetCallerStackPointer() const override;
1410 1411
1411 private: 1412 private:
1412 friend class StackFrameIteratorBase; 1413 friend class StackFrameIteratorBase;
1413 }; 1414 };
1414 1415
1415 1416
1416 class StubFailureTrampolineFrame: public StandardFrame { 1417 class StubFailureTrampolineFrame: public StandardFrame {
1417 public: 1418 public:
1418 Type type() const override { return STUB_FAILURE_TRAMPOLINE; } 1419 Type type() const override { return STUB_FAILURE_TRAMPOLINE; }
1419 1420
1420 // Get the code associated with this frame. 1421 // Get the code associated with this frame.
1421 // This method could be called during marking phase of GC. 1422 // This method could be called during marking phase of GC.
1422 Code* unchecked_code() const override; 1423 Code* unchecked_code() const override;
1423 1424
1424 void Iterate(ObjectVisitor* v) const override; 1425 void Iterate(RootVisitor* v) const override;
1425 1426
1426 // Architecture-specific register description. 1427 // Architecture-specific register description.
1427 static Register fp_register(); 1428 static Register fp_register();
1428 static Register context_register(); 1429 static Register context_register();
1429 static Register constant_pool_pointer_register(); 1430 static Register constant_pool_pointer_register();
1430 1431
1431 protected: 1432 protected:
1432 inline explicit StubFailureTrampolineFrame( 1433 inline explicit StubFailureTrampolineFrame(
1433 StackFrameIteratorBase* iterator); 1434 StackFrameIteratorBase* iterator);
1434 1435
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after
1602 1603
1603 1604
1604 // Reads all frames on the current stack and copies them into the current 1605 // Reads all frames on the current stack and copies them into the current
1605 // zone memory. 1606 // zone memory.
1606 Vector<StackFrame*> CreateStackMap(Isolate* isolate, Zone* zone); 1607 Vector<StackFrame*> CreateStackMap(Isolate* isolate, Zone* zone);
1607 1608
1608 } // namespace internal 1609 } // namespace internal
1609 } // namespace v8 1610 } // namespace v8
1610 1611
1611 #endif // V8_FRAMES_H_ 1612 #endif // V8_FRAMES_H_
OLDNEW
« no previous file with comments | « src/debug/debug.cc ('k') | src/frames.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698