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

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

Issue 2416243002: Make unittests work in component build (Closed)
Patch Set: updates Created 4 years, 2 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/allocation.h ('k') | src/asmjs/switch-logic.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 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/compiler-specific.h"
10 #include "src/base/macros.h" 11 #include "src/base/macros.h"
12 #include "src/globals.h"
11 #include "src/zone/zone-containers.h" 13 #include "src/zone/zone-containers.h"
12 #include "src/zone/zone.h" 14 #include "src/zone/zone.h"
13 15
14 namespace v8 { 16 namespace v8 {
15 namespace internal { 17 namespace internal {
16 namespace wasm { 18 namespace wasm {
17 19
18 class AsmType; 20 class AsmType;
19 class AsmFFIType; 21 class AsmFFIType;
20 class AsmFunctionType; 22 class AsmFunctionType;
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
94 static AsmType* New(bitset_t bits) { 96 static AsmType* New(bitset_t bits) {
95 DCHECK_EQ((bits & kAsmValueTypeTag), 0); 97 DCHECK_EQ((bits & kAsmValueTypeTag), 0);
96 return reinterpret_cast<AsmType*>( 98 return reinterpret_cast<AsmType*>(
97 static_cast<uintptr_t>(bits | kAsmValueTypeTag)); 99 static_cast<uintptr_t>(bits | kAsmValueTypeTag));
98 } 100 }
99 101
100 // AsmValueTypes can't be created except through AsmValueType::New. 102 // AsmValueTypes can't be created except through AsmValueType::New.
101 DISALLOW_IMPLICIT_CONSTRUCTORS(AsmValueType); 103 DISALLOW_IMPLICIT_CONSTRUCTORS(AsmValueType);
102 }; 104 };
103 105
104 class AsmCallableType : public ZoneObject { 106 class V8_EXPORT_PRIVATE AsmCallableType : public NON_EXPORTED_BASE(ZoneObject) {
105 public: 107 public:
106 virtual std::string Name() = 0; 108 virtual std::string Name() = 0;
107 109
108 virtual bool CanBeInvokedWith(AsmType* return_type, 110 virtual bool CanBeInvokedWith(AsmType* return_type,
109 const ZoneVector<AsmType*>& args) = 0; 111 const ZoneVector<AsmType*>& args) = 0;
110 112
111 #define DECLARE_CAST(CamelName) \ 113 #define DECLARE_CAST(CamelName) \
112 virtual Asm##CamelName* As##CamelName() { return nullptr; } 114 virtual Asm##CamelName* As##CamelName() { return nullptr; }
113 FOR_EACH_ASM_CALLABLE_TYPE_LIST(DECLARE_CAST) 115 FOR_EACH_ASM_CALLABLE_TYPE_LIST(DECLARE_CAST)
114 #undef DECLARE_CAST 116 #undef DECLARE_CAST
115 117
116 protected: 118 protected:
117 AsmCallableType() = default; 119 AsmCallableType() = default;
118 virtual ~AsmCallableType() = default; 120 virtual ~AsmCallableType() = default;
119 virtual bool IsA(AsmType* other); 121 virtual bool IsA(AsmType* other);
120 122
121 private: 123 private:
122 friend class AsmType; 124 friend class AsmType;
123 125
124 DISALLOW_COPY_AND_ASSIGN(AsmCallableType); 126 DISALLOW_COPY_AND_ASSIGN(AsmCallableType);
125 }; 127 };
126 128
127 class AsmFunctionType final : public AsmCallableType { 129 class V8_EXPORT_PRIVATE AsmFunctionType final : public AsmCallableType {
128 public: 130 public:
129 AsmFunctionType* AsFunctionType() final { return this; } 131 AsmFunctionType* AsFunctionType() final { return this; }
130 132
131 void AddArgument(AsmType* type) { args_.push_back(type); } 133 void AddArgument(AsmType* type) { args_.push_back(type); }
132 const ZoneVector<AsmType*> Arguments() const { return args_; } 134 const ZoneVector<AsmType*> Arguments() const { return args_; }
133 AsmType* ReturnType() const { return return_type_; } 135 AsmType* ReturnType() const { return return_type_; }
134 136
135 bool CanBeInvokedWith(AsmType* return_type, 137 bool CanBeInvokedWith(AsmType* return_type,
136 const ZoneVector<AsmType*>& args) override; 138 const ZoneVector<AsmType*>& args) override;
137 139
138 protected: 140 protected:
139 AsmFunctionType(Zone* zone, AsmType* return_type) 141 AsmFunctionType(Zone* zone, AsmType* return_type)
140 : return_type_(return_type), args_(zone) {} 142 : return_type_(return_type), args_(zone) {}
141 143
142 private: 144 private:
143 friend AsmType; 145 friend AsmType;
144 146
145 std::string Name() override; 147 std::string Name() override;
146 bool IsA(AsmType* other) override; 148 bool IsA(AsmType* other) override;
147 149
148 AsmType* return_type_; 150 AsmType* return_type_;
149 ZoneVector<AsmType*> args_; 151 ZoneVector<AsmType*> args_;
150 152
151 DISALLOW_COPY_AND_ASSIGN(AsmFunctionType); 153 DISALLOW_COPY_AND_ASSIGN(AsmFunctionType);
152 }; 154 };
153 155
154 class AsmOverloadedFunctionType final : public AsmCallableType { 156 class V8_EXPORT_PRIVATE AsmOverloadedFunctionType final
157 : public AsmCallableType {
155 public: 158 public:
156 AsmOverloadedFunctionType* AsOverloadedFunctionType() override { 159 AsmOverloadedFunctionType* AsOverloadedFunctionType() override {
157 return this; 160 return this;
158 } 161 }
159 162
160 void AddOverload(AsmType* overload); 163 void AddOverload(AsmType* overload);
161 164
162 private: 165 private:
163 friend AsmType; 166 friend AsmType;
164 167
165 explicit AsmOverloadedFunctionType(Zone* zone) : overloads_(zone) {} 168 explicit AsmOverloadedFunctionType(Zone* zone) : overloads_(zone) {}
166 169
167 std::string Name() override; 170 std::string Name() override;
168 bool CanBeInvokedWith(AsmType* return_type, 171 bool CanBeInvokedWith(AsmType* return_type,
169 const ZoneVector<AsmType*>& args) override; 172 const ZoneVector<AsmType*>& args) override;
170 173
171 ZoneVector<AsmType*> overloads_; 174 ZoneVector<AsmType*> overloads_;
172 175
173 DISALLOW_IMPLICIT_CONSTRUCTORS(AsmOverloadedFunctionType); 176 DISALLOW_IMPLICIT_CONSTRUCTORS(AsmOverloadedFunctionType);
174 }; 177 };
175 178
176 class AsmFFIType final : public AsmCallableType { 179 class V8_EXPORT_PRIVATE AsmFFIType final : public AsmCallableType {
177 public: 180 public:
178 AsmFFIType* AsFFIType() override { return this; } 181 AsmFFIType* AsFFIType() override { return this; }
179 182
180 std::string Name() override { return "Function"; } 183 std::string Name() override { return "Function"; }
181 bool CanBeInvokedWith(AsmType* return_type, 184 bool CanBeInvokedWith(AsmType* return_type,
182 const ZoneVector<AsmType*>& args) override; 185 const ZoneVector<AsmType*>& args) override;
183 186
184 private: 187 private:
185 friend AsmType; 188 friend AsmType;
186 189
187 AsmFFIType() = default; 190 AsmFFIType() = default;
188 191
189 DISALLOW_COPY_AND_ASSIGN(AsmFFIType); 192 DISALLOW_COPY_AND_ASSIGN(AsmFFIType);
190 }; 193 };
191 194
192 class AsmFunctionTableType : public AsmCallableType { 195 class V8_EXPORT_PRIVATE AsmFunctionTableType : public AsmCallableType {
193 public: 196 public:
194 AsmFunctionTableType* AsFunctionTableType() override { return this; } 197 AsmFunctionTableType* AsFunctionTableType() override { return this; }
195 198
196 std::string Name() override; 199 std::string Name() override;
197 200
198 bool CanBeInvokedWith(AsmType* return_type, 201 bool CanBeInvokedWith(AsmType* return_type,
199 const ZoneVector<AsmType*>& args) override; 202 const ZoneVector<AsmType*>& args) override;
200 203
201 size_t length() const { return length_; } 204 size_t length() const { return length_; }
202 AsmType* signature() { return signature_; } 205 AsmType* signature() { return signature_; }
203 206
204 private: 207 private:
205 friend class AsmType; 208 friend class AsmType;
206 209
207 AsmFunctionTableType(size_t length, AsmType* signature); 210 AsmFunctionTableType(size_t length, AsmType* signature);
208 211
209 size_t length_; 212 size_t length_;
210 AsmType* signature_; 213 AsmType* signature_;
211 214
212 DISALLOW_IMPLICIT_CONSTRUCTORS(AsmFunctionTableType); 215 DISALLOW_IMPLICIT_CONSTRUCTORS(AsmFunctionTableType);
213 }; 216 };
214 217
215 class AsmType { 218 class V8_EXPORT_PRIVATE AsmType {
216 public: 219 public:
217 #define DEFINE_CONSTRUCTOR(CamelName, string_name, number, parent_types) \ 220 #define DEFINE_CONSTRUCTOR(CamelName, string_name, number, parent_types) \
218 static AsmType* CamelName() { \ 221 static AsmType* CamelName() { \
219 return AsmValueType::New(AsmValueType::kAsm##CamelName); \ 222 return AsmValueType::New(AsmValueType::kAsm##CamelName); \
220 } 223 }
221 FOR_EACH_ASM_VALUE_TYPE_LIST(DEFINE_CONSTRUCTOR) 224 FOR_EACH_ASM_VALUE_TYPE_LIST(DEFINE_CONSTRUCTOR)
222 #undef DEFINE_CONSTRUCTOR 225 #undef DEFINE_CONSTRUCTOR
223 226
224 #define DEFINE_CAST(CamelCase) \ 227 #define DEFINE_CAST(CamelCase) \
225 Asm##CamelCase* As##CamelCase() { \ 228 Asm##CamelCase* As##CamelCase() { \
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
338 // Returns the store type if this is a heap type. AsmType::None is returned if 341 // Returns the store type if this is a heap type. AsmType::None is returned if
339 // this is not a heap type. 342 // this is not a heap type.
340 AsmType* StoreType(); 343 AsmType* StoreType();
341 }; 344 };
342 345
343 } // namespace wasm 346 } // namespace wasm
344 } // namespace internal 347 } // namespace internal
345 } // namespace v8 348 } // namespace v8
346 349
347 #endif // SRC_ASMJS_ASM_TYPES_H_ 350 #endif // SRC_ASMJS_ASM_TYPES_H_
OLDNEW
« no previous file with comments | « src/allocation.h ('k') | src/asmjs/switch-logic.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698