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

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

Issue 426233002: Land the Fan (disabled) (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 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 | Annotate | Revision Log
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #ifndef V8_COMPILER_FRAME_H_
6 #define V8_COMPILER_FRAME_H_
7
8 #include "src/v8.h"
9
10 #include "src/data-flow.h"
11
12 namespace v8 {
13 namespace internal {
14 namespace compiler {
15
16 // Collects the spill slot requirements and the allocated general and double
17 // registers for a compiled function. Frames are usually populated by the
18 // register allocator and are used by Linkage to generate code for the prologue
19 // and epilogue to compiled code.
20 class Frame {
21 public:
22 Frame()
23 : register_save_area_size_(0),
24 spill_slot_count_(0),
25 double_spill_slot_count_(0),
26 allocated_registers_(NULL),
27 allocated_double_registers_(NULL) { }
28
29 inline int GetSpillSlotCount() { return spill_slot_count_; }
30 inline int GetDoubleSpillSlotCount() { return double_spill_slot_count_; }
31
32 void SetAllocatedRegisters(BitVector* regs) {
33 ASSERT(allocated_registers_ == NULL);
34 allocated_registers_ = regs;
35 }
36
37 void SetAllocatedDoubleRegisters(BitVector* regs) {
38 ASSERT(allocated_double_registers_ == NULL);
39 allocated_double_registers_ = regs;
40 }
41
42 bool DidAllocateDoubleRegisters() {
43 return !allocated_double_registers_->IsEmpty();
44 }
45
46 void SetRegisterSaveAreaSize(int size) {
47 ASSERT(IsAligned(size, kPointerSize));
48 register_save_area_size_ = size;
49 }
50
51 int GetRegisterSaveAreaSize() {
52 return register_save_area_size_;
53 }
54
55 int AllocateSpillSlot(bool is_double) {
56 // If 32-bit, skip one if the new slot is a double.
57 if (is_double) {
58 if (kDoubleSize > kPointerSize) {
59 ASSERT(kDoubleSize == kPointerSize * 2);
60 spill_slot_count_++;
61 spill_slot_count_ |= 1;
62 }
63 double_spill_slot_count_++;
64 }
65 return spill_slot_count_++;
66 }
67
68 private:
69 int register_save_area_size_;
70 int spill_slot_count_;
71 int double_spill_slot_count_;
72 BitVector* allocated_registers_;
73 BitVector* allocated_double_registers_;
74 };
75
76
77 // Represents an offset from either the stack pointer or frame pointer.
78 class FrameOffset {
79 public:
80 inline bool from_stack_pointer() { return (offset_ & 1) == kFromSp; }
81 inline bool from_frame_pointer() { return (offset_ & 1) == kFromFp; }
82 inline int offset() { return offset_ & ~1; }
83
84 inline static FrameOffset FromStackPointer(int offset) {
85 ASSERT((offset & 1) == 0);
86 return FrameOffset(offset | kFromSp);
87 }
88
89 inline static FrameOffset FromFramePointer(int offset) {
90 ASSERT((offset & 1) == 0);
91 return FrameOffset(offset | kFromFp);
92 }
93
94 private:
95 explicit FrameOffset(int offset) : offset_(offset) { }
96
97 int offset_; // Encodes SP or FP in the low order bit.
98
99 static const int kFromSp = 1;
100 static const int kFromFp = 0;
101 };
102
103 } } } // namespace v8::internal::compiler
104
105 #endif // V8_COMPILER_FRAME_H_
OLDNEW
« no previous file with comments | « src/compiler/control-builders.cc ('k') | src/compiler/gap-resolver.h » ('j') | src/lithium-inl.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698