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

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

Issue 1259203002: [turbofan] Implement tail calls with differing stack parameter counts (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Fix bugs in frameless tail calls Created 5 years, 4 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
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 9
10 namespace v8 { 10 namespace v8 {
11 namespace internal { 11 namespace internal {
12 namespace compiler { 12 namespace compiler {
13 13
14 // Collects the spill slot requirements and the allocated general and double 14 // Collects the spill slot requirements and the allocated general and double
15 // registers for a compiled function. Frames are usually populated by the 15 // registers for a compiled function. Frames are usually populated by the
16 // register allocator and are used by Linkage to generate code for the prologue 16 // register allocator and are used by Linkage to generate code for the prologue
17 // and epilogue to compiled code. 17 // and epilogue to compiled code.
18 class Frame : public ZoneObject { 18 class Frame : public ZoneObject {
19 public: 19 public:
20 Frame() 20 explicit Frame(bool needs_frame)
21 : register_save_area_size_(0), 21 : needs_frame_(needs_frame),
22 register_save_area_size_(0),
22 spill_slot_count_(0), 23 spill_slot_count_(0),
24 max_tail_call_stack_delta_(0),
23 osr_stack_slot_count_(0), 25 osr_stack_slot_count_(0),
24 allocated_registers_(NULL), 26 allocated_registers_(NULL),
25 allocated_double_registers_(NULL) {} 27 allocated_double_registers_(NULL) {}
26 28
27 inline int GetSpillSlotCount() { return spill_slot_count_; } 29 inline int GetSpillSlotCount() const { return spill_slot_count_; }
30
31 inline int GetFrameSlotCount() const {
32 if (needs_frame_ || spill_slot_count_ > 0) {
33 return std::max(spill_slot_count_, max_tail_call_stack_delta_);
34 }
35 return 0;
36 }
37
38 inline void MarkNeedsFrame() { needs_frame_ = true; }
39 inline bool NeedsFrame() const { return needs_frame_; }
28 40
29 void SetAllocatedRegisters(BitVector* regs) { 41 void SetAllocatedRegisters(BitVector* regs) {
30 DCHECK(allocated_registers_ == NULL); 42 DCHECK(allocated_registers_ == NULL);
31 allocated_registers_ = regs; 43 allocated_registers_ = regs;
32 } 44 }
33 45
34 void SetAllocatedDoubleRegisters(BitVector* regs) { 46 void SetAllocatedDoubleRegisters(BitVector* regs) {
35 DCHECK(allocated_double_registers_ == NULL); 47 DCHECK(allocated_double_registers_ == NULL);
36 allocated_double_registers_ = regs; 48 allocated_double_registers_ = regs;
37 } 49 }
(...skipping 12 matching lines...) Expand all
50 // OSR stack slots, including locals and expression stack slots. 62 // OSR stack slots, including locals and expression stack slots.
51 void SetOsrStackSlotCount(int slots) { 63 void SetOsrStackSlotCount(int slots) {
52 DCHECK(slots >= 0); 64 DCHECK(slots >= 0);
53 osr_stack_slot_count_ = slots; 65 osr_stack_slot_count_ = slots;
54 } 66 }
55 67
56 int GetOsrStackSlotCount() { return osr_stack_slot_count_; } 68 int GetOsrStackSlotCount() { return osr_stack_slot_count_; }
57 69
58 int AllocateSpillSlot(int width) { 70 int AllocateSpillSlot(int width) {
59 DCHECK(width == 4 || width == 8); 71 DCHECK(width == 4 || width == 8);
72 needs_frame_ = true;
60 // Skip one slot if necessary. 73 // Skip one slot if necessary.
61 if (width > kPointerSize) { 74 if (width > kPointerSize) {
62 DCHECK(width == kPointerSize * 2); 75 DCHECK(width == kPointerSize * 2);
63 spill_slot_count_++; 76 spill_slot_count_++;
64 spill_slot_count_ |= 1; 77 spill_slot_count_ |= 1;
65 } 78 }
66 return spill_slot_count_++; 79 return spill_slot_count_++;
67 } 80 }
68 81
69 void ReserveSpillSlots(size_t slot_count) { 82 void ReserveSpillSlots(size_t slot_count) {
70 DCHECK_EQ(0, spill_slot_count_); // can only reserve before allocation. 83 DCHECK_EQ(0, spill_slot_count_); // can only reserve before allocation.
84 needs_frame_ = true;
71 spill_slot_count_ = static_cast<int>(slot_count); 85 spill_slot_count_ = static_cast<int>(slot_count);
72 } 86 }
73 87
88 void UpdateMaxTailCallStackDelta(int stack_delta) {
89 if (stack_delta > max_tail_call_stack_delta_) {
90 max_tail_call_stack_delta_ = stack_delta;
91 }
92 }
93 int max_tail_call_stack_delta() { return max_tail_call_stack_delta_; }
94
74 private: 95 private:
96 bool needs_frame_;
75 int register_save_area_size_; 97 int register_save_area_size_;
76 int spill_slot_count_; 98 int spill_slot_count_;
99 int max_tail_call_stack_delta_;
77 int osr_stack_slot_count_; 100 int osr_stack_slot_count_;
78 BitVector* allocated_registers_; 101 BitVector* allocated_registers_;
79 BitVector* allocated_double_registers_; 102 BitVector* allocated_double_registers_;
80 103
81 DISALLOW_COPY_AND_ASSIGN(Frame); 104 DISALLOW_COPY_AND_ASSIGN(Frame);
82 }; 105 };
83 106
84 107
85 // Represents an offset from either the stack pointer or frame pointer. 108 // Represents an offset from either the stack pointer or frame pointer.
86 class FrameOffset { 109 class FrameOffset {
(...skipping 18 matching lines...) Expand all
105 int offset_; // Encodes SP or FP in the low order bit. 128 int offset_; // Encodes SP or FP in the low order bit.
106 129
107 static const int kFromSp = 1; 130 static const int kFromSp = 1;
108 static const int kFromFp = 0; 131 static const int kFromFp = 0;
109 }; 132 };
110 } 133 }
111 } 134 }
112 } // namespace v8::internal::compiler 135 } // namespace v8::internal::compiler
113 136
114 #endif // V8_COMPILER_FRAME_H_ 137 #endif // V8_COMPILER_FRAME_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698