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

Side by Side Diff: src/asmjs/asm-types.h

Issue 2134333003: V8. ASM-2-WASM. Migrates asm-wasm-builder to the new asm-typer. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: addresses comments. Created 4 years, 5 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 | « src/asmjs/asm-typer.cc ('k') | src/asmjs/asm-types.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 2016 the V8 project authors. All rights reserved. 1 // Copyright 2016 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 SRC_ASMJS_ASM_TYPES_H_ 5 #ifndef SRC_ASMJS_ASM_TYPES_H_
6 #define SRC_ASMJS_ASM_TYPES_H_ 6 #define SRC_ASMJS_ASM_TYPES_H_
7 7
8 #include <string> 8 #include <string>
9 9
10 #include "src/base/macros.h" 10 #include "src/base/macros.h"
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
103 // AsmValueTypes can't be created except through AsmValueType::New. 103 // AsmValueTypes can't be created except through AsmValueType::New.
104 DISALLOW_IMPLICIT_CONSTRUCTORS(AsmValueType); 104 DISALLOW_IMPLICIT_CONSTRUCTORS(AsmValueType);
105 }; 105 };
106 106
107 class AsmCallableType : public ZoneObject { 107 class AsmCallableType : public ZoneObject {
108 public: 108 public:
109 virtual std::string Name() = 0; 109 virtual std::string Name() = 0;
110 virtual AsmType* ValidateCall(AsmType* return_type, 110 virtual AsmType* ValidateCall(AsmType* return_type,
111 const ZoneVector<AsmType*>& args) = 0; 111 const ZoneVector<AsmType*>& args) = 0;
112 112
113 virtual bool CanBeInvokedWith(AsmType* return_type,
114 const ZoneVector<AsmType*>& args) = 0;
115
113 #define DECLARE_CAST(CamelName) \ 116 #define DECLARE_CAST(CamelName) \
114 virtual Asm##CamelName* As##CamelName() { return nullptr; } 117 virtual Asm##CamelName* As##CamelName() { return nullptr; }
115 FOR_EACH_ASM_CALLABLE_TYPE_LIST(DECLARE_CAST) 118 FOR_EACH_ASM_CALLABLE_TYPE_LIST(DECLARE_CAST)
116 #undef DECLARE_CAST 119 #undef DECLARE_CAST
117 120
118 protected: 121 protected:
119 AsmCallableType() = default; 122 AsmCallableType() = default;
120 virtual ~AsmCallableType() = default; 123 virtual ~AsmCallableType() = default;
121 124
122 private: 125 private:
123 DISALLOW_COPY_AND_ASSIGN(AsmCallableType); 126 DISALLOW_COPY_AND_ASSIGN(AsmCallableType);
124 }; 127 };
125 128
126 class AsmFunctionType : public AsmCallableType { 129 class AsmFunctionType : public AsmCallableType {
127 public: 130 public:
128 AsmFunctionType* AsFunctionType() final { return this; } 131 AsmFunctionType* AsFunctionType() final { return this; }
129 132
130 void AddArgument(AsmType* type) { args_.push_back(type); } 133 void AddArgument(AsmType* type) { args_.push_back(type); }
131 const ZoneVector<AsmType*> Arguments() const { return args_; } 134 const ZoneVector<AsmType*> Arguments() const { return args_; }
132 AsmType* ReturnType() const { return return_type_; } 135 AsmType* ReturnType() const { return return_type_; }
133 136
134 virtual bool IsMinMaxType() const { return false; } 137 virtual bool IsMinMaxType() const { return false; }
135 virtual bool IsFroundType() const { return false; } 138 virtual bool IsFroundType() const { return false; }
136 139
137 AsmType* ValidateCall(AsmType* return_type, 140 AsmType* ValidateCall(AsmType* return_type,
138 const ZoneVector<AsmType*>& args) override; 141 const ZoneVector<AsmType*>& args) override;
142 bool CanBeInvokedWith(AsmType* return_type,
143 const ZoneVector<AsmType*>& args) override;
139 144
140 protected: 145 protected:
141 AsmFunctionType(Zone* zone, AsmType* return_type) 146 AsmFunctionType(Zone* zone, AsmType* return_type)
142 : return_type_(return_type), args_(zone) {} 147 : return_type_(return_type), args_(zone) {}
143 148
144 private: 149 private:
145 friend AsmType; 150 friend AsmType;
146 151
147 std::string Name() override; 152 std::string Name() override;
148 153
(...skipping 12 matching lines...) Expand all
161 void AddOverload(AsmType* overload); 166 void AddOverload(AsmType* overload);
162 167
163 private: 168 private:
164 friend AsmType; 169 friend AsmType;
165 170
166 explicit AsmOverloadedFunctionType(Zone* zone) : overloads_(zone) {} 171 explicit AsmOverloadedFunctionType(Zone* zone) : overloads_(zone) {}
167 172
168 std::string Name() override; 173 std::string Name() override;
169 AsmType* ValidateCall(AsmType* return_type, 174 AsmType* ValidateCall(AsmType* return_type,
170 const ZoneVector<AsmType*>& args) override; 175 const ZoneVector<AsmType*>& args) override;
176 bool CanBeInvokedWith(AsmType* return_type,
177 const ZoneVector<AsmType*>& args) override;
171 178
172 ZoneVector<AsmType*> overloads_; 179 ZoneVector<AsmType*> overloads_;
173 180
174 DISALLOW_IMPLICIT_CONSTRUCTORS(AsmOverloadedFunctionType); 181 DISALLOW_IMPLICIT_CONSTRUCTORS(AsmOverloadedFunctionType);
175 }; 182 };
176 183
177 class AsmFFIType final : public AsmCallableType { 184 class AsmFFIType final : public AsmCallableType {
178 public: 185 public:
179 AsmFFIType* AsFFIType() override { return this; } 186 AsmFFIType* AsFFIType() override { return this; }
180 187
181 std::string Name() override { return "Function"; } 188 std::string Name() override { return "Function"; }
182 AsmType* ValidateCall(AsmType* return_type, 189 AsmType* ValidateCall(AsmType* return_type,
183 const ZoneVector<AsmType*>& args) override; 190 const ZoneVector<AsmType*>& args) override;
191 bool CanBeInvokedWith(AsmType* return_type,
192 const ZoneVector<AsmType*>& args) override;
184 193
185 private: 194 private:
186 friend AsmType; 195 friend AsmType;
187 196
188 AsmFFIType() = default; 197 AsmFFIType() = default;
189 198
190 DISALLOW_COPY_AND_ASSIGN(AsmFFIType); 199 DISALLOW_COPY_AND_ASSIGN(AsmFFIType);
191 }; 200 };
192 201
193 class AsmFunctionTableType : public AsmCallableType { 202 class AsmFunctionTableType : public AsmCallableType {
194 public: 203 public:
195 AsmFunctionTableType* AsFunctionTableType() override { return this; } 204 AsmFunctionTableType* AsFunctionTableType() override { return this; }
196 205
197 std::string Name() override; 206 std::string Name() override;
198 207
199 AsmType* ValidateCall(AsmType* return_type, 208 AsmType* ValidateCall(AsmType* return_type,
200 const ZoneVector<AsmType*>& args) override; 209 const ZoneVector<AsmType*>& args) override;
210 bool CanBeInvokedWith(AsmType* return_type,
211 const ZoneVector<AsmType*>& args) override;
201 212
202 size_t length() const { return length_; } 213 size_t length() const { return length_; }
203 AsmType* signature() { return signature_; } 214 AsmType* signature() { return signature_; }
204 215
205 private: 216 private:
206 friend class AsmType; 217 friend class AsmType;
207 218
208 AsmFunctionTableType(size_t length, AsmType* signature); 219 AsmFunctionTableType(size_t length, AsmType* signature);
209 220
210 size_t length_; 221 size_t length_;
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after
339 // Returns the store type if this is a heap type. AsmType::None is returned if 350 // Returns the store type if this is a heap type. AsmType::None is returned if
340 // this is not a heap type. 351 // this is not a heap type.
341 AsmType* StoreType(); 352 AsmType* StoreType();
342 }; 353 };
343 354
344 } // namespace wasm 355 } // namespace wasm
345 } // namespace internal 356 } // namespace internal
346 } // namespace v8 357 } // namespace v8
347 358
348 #endif // SRC_ASMJS_ASM_TYPES_H_ 359 #endif // SRC_ASMJS_ASM_TYPES_H_
OLDNEW
« no previous file with comments | « src/asmjs/asm-typer.cc ('k') | src/asmjs/asm-types.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698