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

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

Issue 1707703002: Revert of More simplification and unification of frame handling (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: 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 | « no previous file | 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 // The frame region immediately below the fixed header contains spill slots 37 // Every pointer in a frame has a slot id. On 32-bit platforms, doubles consume
38 // starting at slot 4 for JSFunctions. The callee-saved frame region below that 38 // two slots.
39 // starts at 4+spill_slot_count_. Callee stack slots corresponding to 39 //
40 // parameters are accessible through negative slot ids. 40 // Stack slot indices >= 0 access the callee stack with slot 0 corresponding to
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.
41 // 50 //
42 // Every slot of a caller or callee frame is accessible by the register 51 // Every slot of a caller or callee frame is accessible by the register
43 // allocator and gap resolver with a SpillSlotOperand containing its 52 // allocator and gap resolver with a SpillSlotOperand containing its
44 // corresponding slot id. 53 // corresponding slot id.
45 // 54 //
46 // Below an example JSFunction Frame with slot ids, frame regions and contents: 55 // Below an example JSFunction Frame with slot ids, frame regions and contents:
47 // 56 //
48 // slot JS frame 57 // slot JS frame
49 // +-----------------+-------------------------------- 58 // +-----------------+--------------------------------
50 // -n-1 | parameter 0 | ^ 59 // -n-1 | parameter 0 | ^
51 // |- - - - - - - - -| | 60 // |- - - - - - - - -| |
52 // -n | | Caller 61 // -n | | Caller
53 // ... | ... | frame slots 62 // ... | ... | frame slots
54 // -2 | parameter n-1 | (slot < 0) 63 // -2 | parameter n-1 | (slot < 0)
55 // |- - - - - - - - -| | 64 // |- - - - - - - - -| |
56 // -1 | parameter n | v 65 // -1 | parameter n | v
57 // -----+-----------------+-------------------------------- 66 // -----+-----------------+--------------------------------
58 // 0 | return addr | ^ ^ 67 // 0 | return addr | ^ ^
59 // |- - - - - - - - -| | | 68 // |- - - - - - - - -| | |
60 // 1 | saved frame ptr | Fixed | 69 // 1 | saved frame ptr | Fixed |
61 // |- - - - - - - - -| Header <-- frame ptr | 70 // |- - - - - - - - -| Header <-- frame ptr |
62 // 2 | Context | | | 71 // 2 | Context | | |
63 // |- - - - - - - - -| | | 72 // |- - - - - - - - -| | |
64 // 3 |JSFunction/Marker| v | 73 // 3 |JSFunction/Marker| v |
65 // +-----------------+---- | 74 // +-----------------+---- |
66 // 4 | spill 1 | ^ Callee 75 // 4 | spill 1 | ^ Callee
67 // |- - - - - - - - -| | frame slots 76 // |- - - - - - - - -| | frame slots
68 // ... | ... | Spill slots (slot >= 0) 77 // ... | ... | Spill slots (slot >= 0)
69 // |- - - - - - - - -| | | 78 // |- - - - - - - - -| | |
70 // m+3 | spill m | v | 79 // m+4 | spill m | v |
71 // +-----------------+---- | 80 // +-----------------+---- |
72 // m+4 | callee-saved 1 | ^ | 81 // m+5 | callee-saved 1 | ^ |
73 // |- - - - - - - - -| | | 82 // |- - - - - - - - -| | |
74 // | ... | Callee-saved | 83 // | ... | Callee-saved |
75 // |- - - - - - - - -| | | 84 // |- - - - - - - - -| | |
76 // m+r+3 | callee-saved r | v v 85 // m+r+4 | callee-saved r | v v
77 // -----+-----------------+----- <-- stack ptr ------------- 86 // -----+-----------------+----- <-- stack ptr -------------
78 // 87 //
79 class Frame : public ZoneObject { 88 class Frame : public ZoneObject {
80 public: 89 public:
81 explicit Frame(int fixed_frame_size_in_slots, 90 explicit Frame(int fixed_frame_size_in_slots,
82 const CallDescriptor* descriptor); 91 const CallDescriptor* descriptor);
83 92
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
84 inline bool needs_frame() const { return needs_frame_; } 103 inline bool needs_frame() const { return needs_frame_; }
85 inline void MarkNeedsFrame() { needs_frame_ = true; } 104 inline void MarkNeedsFrame() { needs_frame_ = true; }
86 105
87 inline int GetTotalFrameSlotCount() const { return frame_slot_count_; } 106 inline int GetTotalFrameSlotCount() const { return frame_slot_count_; }
88 107
89 inline int GetSpToFpSlotCount() const { 108 inline int GetSpToFpSlotCount() const {
90 return GetTotalFrameSlotCount() - 109 return GetTotalFrameSlotCount() -
91 StandardFrameConstants::kFixedSlotCountAboveFp; 110 StandardFrameConstants::kFixedSlotCountAboveFp;
92 } 111 }
93 inline int GetSavedCalleeRegisterSlotCount() const { 112 inline int GetSavedCalleeRegisterSlotCount() const {
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after
229 private: 248 private:
230 Frame* const frame_; 249 Frame* const frame_;
231 bool access_frame_with_fp_; 250 bool access_frame_with_fp_;
232 int sp_delta_; 251 int sp_delta_;
233 }; 252 };
234 } // namespace compiler 253 } // namespace compiler
235 } // namespace internal 254 } // namespace internal
236 } // namespace v8 255 } // namespace v8
237 256
238 #endif // V8_COMPILER_FRAME_H_ 257 #endif // V8_COMPILER_FRAME_H_
OLDNEW
« no previous file with comments | « no previous file | src/compiler/ia32/code-generator-ia32.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698