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/machine-type.h

Issue 530783002: Convert Linkage to use MachineSignature. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: 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
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/globals.h" 8 #include "src/globals.h"
9 #include "src/zone.h"
9 10
10 namespace v8 { 11 namespace v8 {
11 namespace internal { 12 namespace internal {
12 13
13 class OStream; 14 class OStream;
14 15
15 namespace compiler { 16 namespace compiler {
16 17
17 // Machine-level types and representations. 18 // Machine-level types and representations.
18 // TODO(titzer): Use the real type system instead of MachineType. 19 // TODO(titzer): Use the real type system instead of MachineType.
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
101 case kRepFloat64: 102 case kRepFloat64:
102 return 8; 103 return 8;
103 case kRepTagged: 104 case kRepTagged:
104 return kPointerSize; 105 return kPointerSize;
105 default: 106 default:
106 UNREACHABLE(); 107 UNREACHABLE();
107 return kPointerSize; 108 return kPointerSize;
108 } 109 }
109 } 110 }
110 111
111 // Describes the inputs and outputs of a function or call in terms of machine 112 // Describes the inputs and outputs of a function or call.
112 // types. 113 template <typename T>
113 class MachineSignature { 114 class Signature : public ZoneObject {
114 public: 115 public:
115 MachineSignature(uint8_t return_count, uint16_t param_count, 116 Signature(uint8_t return_count, uint16_t param_count, T* reps)
Benedikt Meurer 2014/09/02 08:37:41 The Chrome Coding Style says: "Use unsigned intege
titzer 2014/09/02 12:13:53 Done.
116 MachineType* reps)
117 : return_count_(return_count), param_count_(param_count), reps_(reps) {} 117 : return_count_(return_count), param_count_(param_count), reps_(reps) {}
118 118
119 int GetReturnCount() const { return return_count_; } 119 int ReturnCount() const { return return_count_; }
Benedikt Meurer 2014/09/02 08:37:42 size_t return_count() const { return return_count_
titzer 2014/09/02 12:13:53 Done.
120 int GetParamCount() const { return param_count_; } 120 int ParamCount() const { return param_count_; }
Benedikt Meurer 2014/09/02 08:37:42 size_t param_count() const { return param_count_;
titzer 2014/09/02 12:13:53 Done.
121 121
122 MachineType GetParameterType(int index) const { 122 T GetParam(int index) const {
Benedikt Meurer 2014/09/02 08:37:41 size_t for index
titzer 2014/09/02 12:13:53 Done.
123 DCHECK(index >= 0 && index < param_count_); 123 DCHECK(index >= 0 && index < param_count_);
Benedikt Meurer 2014/09/02 08:37:41 DCHECK_LT(index, param_count());
titzer 2014/09/02 12:13:52 Done.
124 return reps_[return_count_ + index]; 124 return reps_[return_count_ + index];
Benedikt Meurer 2014/09/02 08:37:42 reps_[return_count() + index]
titzer 2014/09/02 12:13:53 This is mostly personal preference, but inside the
125 } 125 }
126 126
127 MachineType GetReturnType(int index = 0) const { 127 T GetReturn(int index = 0) const {
Benedikt Meurer 2014/09/02 08:37:42 size_t for index
titzer 2014/09/02 12:13:53 Done.
128 DCHECK(index >= 0 && index < return_count_); 128 DCHECK(index >= 0 && index < return_count_);
Benedikt Meurer 2014/09/02 08:37:42 DCHECK_LT(index, return_count());
titzer 2014/09/02 12:13:53 Done.
129 return reps_[index]; 129 return reps_[index];
130 } 130 }
131 131
132 // For incrementally building signatures.
133 class Builder {
134 public:
135 Builder(Zone* zone, int return_count, int param_count)
136 : return_count_(return_count),
137 param_count_(param_count),
138 zone_(zone),
139 rcursor_(0),
140 pcursor_(0),
141 buffer_(zone->NewArray<T>(return_count + param_count)) {}
142
143 const int return_count_;
Benedikt Meurer 2014/09/02 08:37:42 size_t
titzer 2014/09/02 12:13:52 Done.
144 const int param_count_;
Benedikt Meurer 2014/09/02 08:37:42 size_t
titzer 2014/09/02 12:13:52 Done.
145
146 void AddReturn(T val) {
147 DCHECK_LT(rcursor_, return_count_);
148 buffer_[rcursor_++] = val;
149 }
150 void AddParam(T val) {
151 DCHECK_LT(pcursor_, param_count_);
152 buffer_[return_count_ + pcursor_++] = val;
153 }
154 Signature<T>* Build() {
155 DCHECK_EQ(rcursor_, return_count_);
156 DCHECK_EQ(pcursor_, param_count_);
157 return new (zone_) Signature<T>(return_count_, param_count_, buffer_);
158 }
159
160 private:
161 Zone* zone_;
162 int rcursor_;
163 int pcursor_;
164 T* buffer_;
165 };
166
132 protected: 167 protected:
133 uint8_t return_count_; 168 uint8_t return_count_;
134 uint16_t param_count_; 169 uint16_t param_count_;
135 MachineType* reps_; 170 T* reps_;
136 }; 171 };
172
173 typedef Signature<MachineType> MachineSignature;
137 } // namespace compiler 174 } // namespace compiler
138 } // namespace internal 175 } // namespace internal
139 } // namespace v8 176 } // namespace v8
140 177
141 #endif // V8_COMPILER_MACHINE_TYPE_H_ 178 #endif // V8_COMPILER_MACHINE_TYPE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698