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

Side by Side Diff: src/compiler/frame.h

Issue 1702593002: More simplification and unification of frame handling (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Fix arm64 Created 4 years, 10 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/compiler/code-generator.cc ('k') | src/compiler/ia32/code-generator-ia32.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 2014 the V8 project authors. All rights reserved. 1 // Copyright 2014 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_COMPILER_FRAME_H_ 5 #ifndef V8_COMPILER_FRAME_H_
6 #define V8_COMPILER_FRAME_H_ 6 #define V8_COMPILER_FRAME_H_
7 7
8 #include "src/bit-vector.h" 8 #include "src/bit-vector.h"
9 #include "src/frames.h" 9 #include "src/frames.h"
10 10
(...skipping 16 matching lines...) Expand all
27 // predicted before code generation begins depending on the type of code being 27 // predicted before code generation begins depending on the type of code being
28 // generated. 28 // generated.
29 // - The second is the region for spill slots, which is immediately below the 29 // - The second is the region for spill slots, which is immediately below the
30 // fixed header and grows as the register allocator needs to spill to the 30 // fixed header and grows as the register allocator needs to spill to the
31 // stack and asks the frame for more space. 31 // stack and asks the frame for more space.
32 // - The third region, which contains the callee-saved registers must be 32 // - The third region, which contains the callee-saved registers must be
33 // reserved after register allocation, since its size can only be precisely 33 // reserved after register allocation, since its size can only be precisely
34 // determined after register allocation once the number of used callee-saved 34 // determined after register allocation once the number of used callee-saved
35 // register is certain. 35 // register is certain.
36 // 36 //
37 // Every pointer in a frame has a slot id. On 32-bit platforms, doubles consume 37 // The frame region immediately below the fixed header contains spill slots
38 // two slots. 38 // starting at slot 4 for JSFunctions. The callee-saved frame region below that
39 // 39 // starts at 4+spill_slot_count_. Callee stack slots corresponding to
40 // Stack slot indices >= 0 access the callee stack with slot 0 corresponding to 40 // parameters are accessible through negative slot ids.
41 // the callee's saved return address and 1 corresponding to the saved frame
42 // pointer. Some frames have additional information stored in the fixed header,
43 // for example JSFunctions store the function context and marker in the fixed
44 // header, with slot index 2 corresponding to the current function context and 3
45 // corresponding to the frame marker/JSFunction. The frame region immediately
46 // below the fixed header contains spill slots starting at 4 for JsFunctions.
47 // The callee-saved frame region below that starts at 4+spill_slot_count_.
48 // Callee stack slots corresponding to parameters are accessible through
49 // negative slot ids.
50 // 41 //
51 // Every slot of a caller or callee frame is accessible by the register 42 // Every slot of a caller or callee frame is accessible by the register
52 // allocator and gap resolver with a SpillSlotOperand containing its 43 // allocator and gap resolver with a SpillSlotOperand containing its
53 // corresponding slot id. 44 // corresponding slot id.
54 // 45 //
55 // Below an example JSFunction Frame with slot ids, frame regions and contents: 46 // Below an example JSFunction Frame with slot ids, frame regions and contents:
56 // 47 //
57 // slot JS frame 48 // slot JS frame
58 // +-----------------+-------------------------------- 49 // +-----------------+--------------------------------
59 // -n-1 | parameter 0 | ^ 50 // -n-1 | parameter 0 | ^
60 // |- - - - - - - - -| | 51 // |- - - - - - - - -| |
61 // -n | | Caller 52 // -n | | Caller
62 // ... | ... | frame slots 53 // ... | ... | frame slots
63 // -2 | parameter n-1 | (slot < 0) 54 // -2 | parameter n-1 | (slot < 0)
64 // |- - - - - - - - -| | 55 // |- - - - - - - - -| |
65 // -1 | parameter n | v 56 // -1 | parameter n | v
66 // -----+-----------------+-------------------------------- 57 // -----+-----------------+--------------------------------
67 // 0 | return addr | ^ ^ 58 // 0 | return addr | ^ ^
68 // |- - - - - - - - -| | | 59 // |- - - - - - - - -| | |
69 // 1 | saved frame ptr | Fixed | 60 // 1 | saved frame ptr | Fixed |
70 // |- - - - - - - - -| Header <-- frame ptr | 61 // |- - - - - - - - -| Header <-- frame ptr |
71 // 2 | Context | | | 62 // 2 | Context | | |
72 // |- - - - - - - - -| | | 63 // |- - - - - - - - -| | |
73 // 3 |JSFunction/Marker| v | 64 // 3 |JSFunction/Marker| v |
74 // +-----------------+---- | 65 // +-----------------+---- |
75 // 4 | spill 1 | ^ Callee 66 // 4 | spill 1 | ^ Callee
76 // |- - - - - - - - -| | frame slots 67 // |- - - - - - - - -| | frame slots
77 // ... | ... | Spill slots (slot >= 0) 68 // ... | ... | Spill slots (slot >= 0)
78 // |- - - - - - - - -| | | 69 // |- - - - - - - - -| | |
79 // m+4 | spill m | v | 70 // m+3 | spill m | v |
80 // +-----------------+---- | 71 // +-----------------+---- |
81 // m+5 | callee-saved 1 | ^ | 72 // m+4 | callee-saved 1 | ^ |
82 // |- - - - - - - - -| | | 73 // |- - - - - - - - -| | |
83 // | ... | Callee-saved | 74 // | ... | Callee-saved |
84 // |- - - - - - - - -| | | 75 // |- - - - - - - - -| | |
85 // m+r+4 | callee-saved r | v v 76 // m+r+3 | callee-saved r | v v
86 // -----+-----------------+----- <-- stack ptr ------------- 77 // -----+-----------------+----- <-- stack ptr -------------
87 // 78 //
88 class Frame : public ZoneObject { 79 class Frame : public ZoneObject {
89 public: 80 public:
90 explicit Frame(int fixed_frame_size_in_slots, 81 explicit Frame(int fixed_frame_size_in_slots,
91 const CallDescriptor* descriptor); 82 const CallDescriptor* descriptor);
92 83
93 static int FPOffsetToSlot(int frame_offset) {
94 return StandardFrameConstants::kFixedSlotCountAboveFp - 1 -
95 frame_offset / kPointerSize;
96 }
97
98 static int SlotToFPOffset(int slot) {
99 return (StandardFrameConstants::kFixedSlotCountAboveFp - 1 - slot) *
100 kPointerSize;
101 }
102
103 inline bool needs_frame() const { return needs_frame_; } 84 inline bool needs_frame() const { return needs_frame_; }
104 inline void MarkNeedsFrame() { needs_frame_ = true; } 85 inline void MarkNeedsFrame() { needs_frame_ = true; }
105 86
106 inline int GetTotalFrameSlotCount() const { return frame_slot_count_; } 87 inline int GetTotalFrameSlotCount() const { return frame_slot_count_; }
107 88
108 inline int GetSpToFpSlotCount() const { 89 inline int GetSpToFpSlotCount() const {
109 return GetTotalFrameSlotCount() - 90 return GetTotalFrameSlotCount() -
110 StandardFrameConstants::kFixedSlotCountAboveFp; 91 StandardFrameConstants::kFixedSlotCountAboveFp;
111 } 92 }
112 inline int GetSavedCalleeRegisterSlotCount() const { 93 inline int GetSavedCalleeRegisterSlotCount() const {
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after
248 private: 229 private:
249 Frame* const frame_; 230 Frame* const frame_;
250 bool access_frame_with_fp_; 231 bool access_frame_with_fp_;
251 int sp_delta_; 232 int sp_delta_;
252 }; 233 };
253 } // namespace compiler 234 } // namespace compiler
254 } // namespace internal 235 } // namespace internal
255 } // namespace v8 236 } // namespace v8
256 237
257 #endif // V8_COMPILER_FRAME_H_ 238 #endif // V8_COMPILER_FRAME_H_
OLDNEW
« no previous file with comments | « src/compiler/code-generator.cc ('k') | src/compiler/ia32/code-generator-ia32.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698