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

Side by Side Diff: src/compiler/machine-type.h

Issue 530783002: Convert Linkage to use MachineSignature. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Rebase. Created 6 years, 3 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
« no previous file with comments | « src/compiler/machine-node-factory.h ('k') | src/compiler/raw-machine-assembler.h » ('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_MACHINE_TYPE_H_ 5 #ifndef V8_COMPILER_MACHINE_TYPE_H_
6 #define V8_COMPILER_MACHINE_TYPE_H_ 6 #define V8_COMPILER_MACHINE_TYPE_H_
7 7
8 #include "src/base/bits.h" 8 #include "src/base/bits.h"
9 #include "src/globals.h" 9 #include "src/globals.h"
10 #include "src/zone.h"
10 11
11 namespace v8 { 12 namespace v8 {
12 namespace internal { 13 namespace internal {
13 14
14 class OStream; 15 class OStream;
15 16
16 namespace compiler { 17 namespace compiler {
17 18
18 // Machine-level types and representations. 19 // Machine-level types and representations.
19 // TODO(titzer): Use the real type system instead of MachineType. 20 // TODO(titzer): Use the real type system instead of MachineType.
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
102 case kRepFloat64: 103 case kRepFloat64:
103 return 8; 104 return 8;
104 case kRepTagged: 105 case kRepTagged:
105 return kPointerSize; 106 return kPointerSize;
106 default: 107 default:
107 UNREACHABLE(); 108 UNREACHABLE();
108 return kPointerSize; 109 return kPointerSize;
109 } 110 }
110 } 111 }
111 112
112 // Describes the inputs and outputs of a function or call in terms of machine 113 // Describes the inputs and outputs of a function or call.
113 // types. 114 template <typename T>
114 class MachineSignature { 115 class Signature : public ZoneObject {
115 public: 116 public:
116 MachineSignature(uint8_t return_count, uint16_t param_count, 117 Signature(size_t return_count, size_t parameter_count, T* reps)
117 MachineType* reps) 118 : return_count_(return_count),
118 : return_count_(return_count), param_count_(param_count), reps_(reps) {} 119 parameter_count_(parameter_count),
120 reps_(reps) {}
119 121
120 int GetReturnCount() const { return return_count_; } 122 size_t return_count() const { return return_count_; }
121 int GetParamCount() const { return param_count_; } 123 size_t parameter_count() const { return parameter_count_; }
122 124
123 MachineType GetParameterType(int index) const { 125 T GetParam(size_t index) const {
124 DCHECK(index >= 0 && index < param_count_); 126 DCHECK(index < parameter_count_);
125 return reps_[return_count_ + index]; 127 return reps_[return_count_ + index];
126 } 128 }
127 129
128 MachineType GetReturnType(int index = 0) const { 130 T GetReturn(size_t index = 0) const {
129 DCHECK(index >= 0 && index < return_count_); 131 DCHECK(index < return_count_);
130 return reps_[index]; 132 return reps_[index];
131 } 133 }
132 134
135 // For incrementally building signatures.
136 class Builder {
137 public:
138 Builder(Zone* zone, size_t return_count, size_t parameter_count)
139 : return_count_(return_count),
140 parameter_count_(parameter_count),
141 zone_(zone),
142 rcursor_(0),
143 pcursor_(0),
144 buffer_(zone->NewArray<T>(
145 static_cast<int>(return_count + parameter_count))) {}
146
147 const size_t return_count_;
148 const size_t parameter_count_;
149
150 void AddReturn(T val) {
151 DCHECK(rcursor_ < return_count_);
152 buffer_[rcursor_++] = val;
153 }
154 void AddParam(T val) {
155 DCHECK(pcursor_ < parameter_count_);
156 buffer_[return_count_ + pcursor_++] = val;
157 }
158 Signature<T>* Build() {
159 DCHECK(rcursor_ == return_count_);
160 DCHECK(pcursor_ == parameter_count_);
161 return new (zone_) Signature<T>(return_count_, parameter_count_, buffer_);
162 }
163
164 private:
165 Zone* zone_;
166 size_t rcursor_;
167 size_t pcursor_;
168 T* buffer_;
169 };
170
133 protected: 171 protected:
134 uint8_t return_count_; 172 size_t return_count_;
135 uint16_t param_count_; 173 size_t parameter_count_;
136 MachineType* reps_; 174 T* reps_;
137 }; 175 };
176
177 typedef Signature<MachineType> MachineSignature;
138 } // namespace compiler 178 } // namespace compiler
139 } // namespace internal 179 } // namespace internal
140 } // namespace v8 180 } // namespace v8
141 181
142 #endif // V8_COMPILER_MACHINE_TYPE_H_ 182 #endif // V8_COMPILER_MACHINE_TYPE_H_
OLDNEW
« no previous file with comments | « src/compiler/machine-node-factory.h ('k') | src/compiler/raw-machine-assembler.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698