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

Side by Side Diff: src/asmjs/asm-wasm-builder.cc

Issue 2142233003: Templatize AstVisitor with its subclass (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: 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 | « no previous file | src/asmjs/typing-asm.h » ('j') | src/ast/ast.h » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 the V8 project authors. All rights reserved. 1 // Copyright 2015 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 #include "src/v8.h" 5 #include "src/v8.h"
6 6
7 // Required to get M_E etc. in MSVC. 7 // Required to get M_E etc. in MSVC.
8 #if defined(_WIN32) 8 #if defined(_WIN32)
9 #define _USE_MATH_DEFINES 9 #define _USE_MATH_DEFINES
10 #endif 10 #endif
(...skipping 21 matching lines...) Expand all
32 } while (false) 32 } while (false)
33 33
34 enum AsmScope { kModuleScope, kInitScope, kFuncScope, kExportScope }; 34 enum AsmScope { kModuleScope, kInitScope, kFuncScope, kExportScope };
35 35
36 struct ForeignVariable { 36 struct ForeignVariable {
37 Handle<Name> name; 37 Handle<Name> name;
38 Variable* var; 38 Variable* var;
39 LocalType type; 39 LocalType type;
40 }; 40 };
41 41
42 class AsmWasmBuilderImpl : public AstVisitor { 42 class AsmWasmBuilderImpl final : public AstVisitor<AsmWasmBuilderImpl> {
43 public: 43 public:
44 AsmWasmBuilderImpl(Isolate* isolate, Zone* zone, FunctionLiteral* literal, 44 AsmWasmBuilderImpl(Isolate* isolate, Zone* zone, FunctionLiteral* literal,
45 AsmTyper* typer) 45 AsmTyper* typer)
46 : local_variables_(base::HashMap::PointersMatch, 46 : local_variables_(base::HashMap::PointersMatch,
47 ZoneHashMap::kDefaultHashMapCapacity, 47 ZoneHashMap::kDefaultHashMapCapacity,
48 ZoneAllocationPolicy(zone)), 48 ZoneAllocationPolicy(zone)),
49 functions_(base::HashMap::PointersMatch, 49 functions_(base::HashMap::PointersMatch,
50 ZoneHashMap::kDefaultHashMapCapacity, 50 ZoneHashMap::kDefaultHashMapCapacity,
51 ZoneAllocationPolicy(zone)), 51 ZoneAllocationPolicy(zone)),
52 global_variables_(base::HashMap::PointersMatch, 52 global_variables_(base::HashMap::PointersMatch,
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
114 } 114 }
115 return ret; 115 return ret;
116 } 116 }
117 117
118 void Build() { 118 void Build() {
119 InitializeInitFunction(); 119 InitializeInitFunction();
120 RECURSE(VisitFunctionLiteral(literal_)); 120 RECURSE(VisitFunctionLiteral(literal_));
121 BuildForeignInitFunction(); 121 BuildForeignInitFunction();
122 } 122 }
123 123
124 void VisitVariableDeclaration(VariableDeclaration* decl) override {} 124 void VisitVariableDeclaration(VariableDeclaration* decl) {}
125 125
126 void VisitFunctionDeclaration(FunctionDeclaration* decl) override { 126 void VisitFunctionDeclaration(FunctionDeclaration* decl) {
127 DCHECK_EQ(kModuleScope, scope_); 127 DCHECK_EQ(kModuleScope, scope_);
128 DCHECK_NULL(current_function_builder_); 128 DCHECK_NULL(current_function_builder_);
129 uint32_t index = LookupOrInsertFunction(decl->proxy()->var()); 129 uint32_t index = LookupOrInsertFunction(decl->proxy()->var());
130 current_function_builder_ = builder_->FunctionAt(index); 130 current_function_builder_ = builder_->FunctionAt(index);
131 scope_ = kFuncScope; 131 scope_ = kFuncScope;
132 RECURSE(Visit(decl->fun())); 132 RECURSE(Visit(decl->fun()));
133 scope_ = kModuleScope; 133 scope_ = kModuleScope;
134 current_function_builder_ = nullptr; 134 current_function_builder_ = nullptr;
135 local_variables_.Clear(); 135 local_variables_.Clear();
136 } 136 }
137 137
138 void VisitImportDeclaration(ImportDeclaration* decl) override {} 138 void VisitImportDeclaration(ImportDeclaration* decl) {}
139 139
140 void VisitStatements(ZoneList<Statement*>* stmts) override { 140 void VisitStatements(ZoneList<Statement*>* stmts) {
141 for (int i = 0; i < stmts->length(); ++i) { 141 for (int i = 0; i < stmts->length(); ++i) {
142 Statement* stmt = stmts->at(i); 142 Statement* stmt = stmts->at(i);
143 ExpressionStatement* e = stmt->AsExpressionStatement(); 143 ExpressionStatement* e = stmt->AsExpressionStatement();
144 if (e != nullptr && e->expression()->IsUndefinedLiteral()) { 144 if (e != nullptr && e->expression()->IsUndefinedLiteral()) {
145 continue; 145 continue;
146 } 146 }
147 RECURSE(Visit(stmt)); 147 RECURSE(Visit(stmt));
148 if (stmt->IsJump()) break; 148 if (stmt->IsJump()) break;
149 } 149 }
150 } 150 }
151 151
152 void VisitBlock(Block* stmt) override { 152 void VisitBlock(Block* stmt) {
153 if (stmt->statements()->length() == 1) { 153 if (stmt->statements()->length() == 1) {
154 ExpressionStatement* expr = 154 ExpressionStatement* expr =
155 stmt->statements()->at(0)->AsExpressionStatement(); 155 stmt->statements()->at(0)->AsExpressionStatement();
156 if (expr != nullptr) { 156 if (expr != nullptr) {
157 if (expr->expression()->IsAssignment()) { 157 if (expr->expression()->IsAssignment()) {
158 RECURSE(VisitExpressionStatement(expr)); 158 RECURSE(VisitExpressionStatement(expr));
159 return; 159 return;
160 } 160 }
161 } 161 }
162 } 162 }
(...skipping 16 matching lines...) Expand all
179 : builder_(builder) { 179 : builder_(builder) {
180 builder_->breakable_blocks_.push_back(std::make_pair(stmt, is_loop)); 180 builder_->breakable_blocks_.push_back(std::make_pair(stmt, is_loop));
181 builder_->current_function_builder_->Emit(opcode); 181 builder_->current_function_builder_->Emit(opcode);
182 } 182 }
183 ~BlockVisitor() { 183 ~BlockVisitor() {
184 builder_->current_function_builder_->Emit(kExprEnd); 184 builder_->current_function_builder_->Emit(kExprEnd);
185 builder_->breakable_blocks_.pop_back(); 185 builder_->breakable_blocks_.pop_back();
186 } 186 }
187 }; 187 };
188 188
189 void VisitExpressionStatement(ExpressionStatement* stmt) override { 189 void VisitExpressionStatement(ExpressionStatement* stmt) {
190 RECURSE(Visit(stmt->expression())); 190 RECURSE(Visit(stmt->expression()));
191 } 191 }
192 192
193 void VisitEmptyStatement(EmptyStatement* stmt) override {} 193 void VisitEmptyStatement(EmptyStatement* stmt) {}
194 194
195 void VisitEmptyParentheses(EmptyParentheses* paren) override { 195 void VisitEmptyParentheses(EmptyParentheses* paren) { UNREACHABLE(); }
196 UNREACHABLE();
197 }
198 196
199 void VisitIfStatement(IfStatement* stmt) override { 197 void VisitIfStatement(IfStatement* stmt) {
200 DCHECK_EQ(kFuncScope, scope_); 198 DCHECK_EQ(kFuncScope, scope_);
201 RECURSE(Visit(stmt->condition())); 199 RECURSE(Visit(stmt->condition()));
202 current_function_builder_->Emit(kExprIf); 200 current_function_builder_->Emit(kExprIf);
203 // WASM ifs come with implement blocks for both arms. 201 // WASM ifs come with implement blocks for both arms.
204 breakable_blocks_.push_back(std::make_pair(nullptr, false)); 202 breakable_blocks_.push_back(std::make_pair(nullptr, false));
205 if (stmt->HasThenStatement()) { 203 if (stmt->HasThenStatement()) {
206 RECURSE(Visit(stmt->then_statement())); 204 RECURSE(Visit(stmt->then_statement()));
207 } 205 }
208 if (stmt->HasElseStatement()) { 206 if (stmt->HasElseStatement()) {
209 current_function_builder_->Emit(kExprElse); 207 current_function_builder_->Emit(kExprElse);
210 RECURSE(Visit(stmt->else_statement())); 208 RECURSE(Visit(stmt->else_statement()));
211 } 209 }
212 current_function_builder_->Emit(kExprEnd); 210 current_function_builder_->Emit(kExprEnd);
213 breakable_blocks_.pop_back(); 211 breakable_blocks_.pop_back();
214 } 212 }
215 213
216 void VisitContinueStatement(ContinueStatement* stmt) override { 214 void VisitContinueStatement(ContinueStatement* stmt) {
217 DCHECK_EQ(kFuncScope, scope_); 215 DCHECK_EQ(kFuncScope, scope_);
218 DCHECK_NOT_NULL(stmt->target()); 216 DCHECK_NOT_NULL(stmt->target());
219 int i = static_cast<int>(breakable_blocks_.size()) - 1; 217 int i = static_cast<int>(breakable_blocks_.size()) - 1;
220 int block_distance = 0; 218 int block_distance = 0;
221 for (; i >= 0; i--) { 219 for (; i >= 0; i--) {
222 auto elem = breakable_blocks_.at(i); 220 auto elem = breakable_blocks_.at(i);
223 if (elem.first == stmt->target()) { 221 if (elem.first == stmt->target()) {
224 DCHECK(elem.second); 222 DCHECK(elem.second);
225 break; 223 break;
226 } else if (elem.second) { 224 } else if (elem.second) {
227 block_distance += 2; 225 block_distance += 2;
228 } else { 226 } else {
229 block_distance += 1; 227 block_distance += 1;
230 } 228 }
231 } 229 }
232 DCHECK(i >= 0); 230 DCHECK(i >= 0);
233 current_function_builder_->EmitWithU8(kExprBr, ARITY_0); 231 current_function_builder_->EmitWithU8(kExprBr, ARITY_0);
234 current_function_builder_->EmitVarInt(block_distance); 232 current_function_builder_->EmitVarInt(block_distance);
235 } 233 }
236 234
237 void VisitBreakStatement(BreakStatement* stmt) override { 235 void VisitBreakStatement(BreakStatement* stmt) {
238 DCHECK_EQ(kFuncScope, scope_); 236 DCHECK_EQ(kFuncScope, scope_);
239 DCHECK_NOT_NULL(stmt->target()); 237 DCHECK_NOT_NULL(stmt->target());
240 int i = static_cast<int>(breakable_blocks_.size()) - 1; 238 int i = static_cast<int>(breakable_blocks_.size()) - 1;
241 int block_distance = 0; 239 int block_distance = 0;
242 for (; i >= 0; i--) { 240 for (; i >= 0; i--) {
243 auto elem = breakable_blocks_.at(i); 241 auto elem = breakable_blocks_.at(i);
244 if (elem.first == stmt->target()) { 242 if (elem.first == stmt->target()) {
245 if (elem.second) { 243 if (elem.second) {
246 block_distance++; 244 block_distance++;
247 } 245 }
248 break; 246 break;
249 } else if (elem.second) { 247 } else if (elem.second) {
250 block_distance += 2; 248 block_distance += 2;
251 } else { 249 } else {
252 block_distance += 1; 250 block_distance += 1;
253 } 251 }
254 } 252 }
255 DCHECK(i >= 0); 253 DCHECK(i >= 0);
256 current_function_builder_->EmitWithU8(kExprBr, ARITY_0); 254 current_function_builder_->EmitWithU8(kExprBr, ARITY_0);
257 current_function_builder_->EmitVarInt(block_distance); 255 current_function_builder_->EmitVarInt(block_distance);
258 } 256 }
259 257
260 void VisitReturnStatement(ReturnStatement* stmt) override { 258 void VisitReturnStatement(ReturnStatement* stmt) {
261 if (scope_ == kModuleScope) { 259 if (scope_ == kModuleScope) {
262 scope_ = kExportScope; 260 scope_ = kExportScope;
263 RECURSE(Visit(stmt->expression())); 261 RECURSE(Visit(stmt->expression()));
264 scope_ = kModuleScope; 262 scope_ = kModuleScope;
265 } else if (scope_ == kFuncScope) { 263 } else if (scope_ == kFuncScope) {
266 RECURSE(Visit(stmt->expression())); 264 RECURSE(Visit(stmt->expression()));
267 uint8_t arity = 265 uint8_t arity =
268 TypeOf(stmt->expression()) == kAstStmt ? ARITY_0 : ARITY_1; 266 TypeOf(stmt->expression()) == kAstStmt ? ARITY_0 : ARITY_1;
269 current_function_builder_->EmitWithU8(kExprReturn, arity); 267 current_function_builder_->EmitWithU8(kExprReturn, arity);
270 } else { 268 } else {
271 UNREACHABLE(); 269 UNREACHABLE();
272 } 270 }
273 } 271 }
274 272
275 void VisitWithStatement(WithStatement* stmt) override { UNREACHABLE(); } 273 void VisitWithStatement(WithStatement* stmt) { UNREACHABLE(); }
276 274
277 void HandleCase(CaseNode* node, 275 void HandleCase(CaseNode* node,
278 const ZoneMap<int, unsigned int>& case_to_block, 276 const ZoneMap<int, unsigned int>& case_to_block,
279 VariableProxy* tag, int default_block, int if_depth) { 277 VariableProxy* tag, int default_block, int if_depth) {
280 int prev_if_depth = if_depth; 278 int prev_if_depth = if_depth;
281 if (node->left != nullptr) { 279 if (node->left != nullptr) {
282 VisitVariableProxy(tag); 280 VisitVariableProxy(tag);
283 current_function_builder_->EmitI32Const(node->begin); 281 current_function_builder_->EmitI32Const(node->begin);
284 current_function_builder_->Emit(kExprI32LtS); 282 current_function_builder_->Emit(kExprI32LtS);
285 current_function_builder_->Emit(kExprIf); 283 current_function_builder_->Emit(kExprIf);
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
333 byte break_code[] = {BR_TARGET(if_depth + default_block)}; 331 byte break_code[] = {BR_TARGET(if_depth + default_block)};
334 current_function_builder_->EmitCode(break_code, sizeof(break_code)); 332 current_function_builder_->EmitCode(break_code, sizeof(break_code));
335 } 333 }
336 334
337 while (if_depth-- != prev_if_depth) { 335 while (if_depth-- != prev_if_depth) {
338 breakable_blocks_.pop_back(); 336 breakable_blocks_.pop_back();
339 current_function_builder_->Emit(kExprEnd); 337 current_function_builder_->Emit(kExprEnd);
340 } 338 }
341 } 339 }
342 340
343 void VisitSwitchStatement(SwitchStatement* stmt) override { 341 void VisitSwitchStatement(SwitchStatement* stmt) {
344 VariableProxy* tag = stmt->tag()->AsVariableProxy(); 342 VariableProxy* tag = stmt->tag()->AsVariableProxy();
345 DCHECK_NOT_NULL(tag); 343 DCHECK_NOT_NULL(tag);
346 ZoneList<CaseClause*>* clauses = stmt->cases(); 344 ZoneList<CaseClause*>* clauses = stmt->cases();
347 int case_count = clauses->length(); 345 int case_count = clauses->length();
348 if (case_count == 0) { 346 if (case_count == 0) {
349 return; 347 return;
350 } 348 }
351 BlockVisitor visitor(this, stmt->AsBreakableStatement(), kExprBlock, false); 349 BlockVisitor visitor(this, stmt->AsBreakableStatement(), kExprBlock, false);
352 ZoneVector<BlockVisitor*> blocks(zone_); 350 ZoneVector<BlockVisitor*> blocks(zone_);
353 ZoneVector<int32_t> cases(zone_); 351 ZoneVector<int32_t> cases(zone_);
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
385 } 383 }
386 for (int i = 0; i < case_count; ++i) { 384 for (int i = 0; i < case_count; ++i) {
387 CaseClause* clause = clauses->at(i); 385 CaseClause* clause = clauses->at(i);
388 RECURSE(VisitStatements(clause->statements())); 386 RECURSE(VisitStatements(clause->statements()));
389 BlockVisitor* v = blocks.at(case_count - i - 1); 387 BlockVisitor* v = blocks.at(case_count - i - 1);
390 blocks.pop_back(); 388 blocks.pop_back();
391 delete v; 389 delete v;
392 } 390 }
393 } 391 }
394 392
395 void VisitCaseClause(CaseClause* clause) override { UNREACHABLE(); } 393 void VisitCaseClause(CaseClause* clause) { UNREACHABLE(); }
396 394
397 void VisitDoWhileStatement(DoWhileStatement* stmt) override { 395 void VisitDoWhileStatement(DoWhileStatement* stmt) {
398 DCHECK_EQ(kFuncScope, scope_); 396 DCHECK_EQ(kFuncScope, scope_);
399 BlockVisitor visitor(this, stmt->AsBreakableStatement(), kExprLoop, true); 397 BlockVisitor visitor(this, stmt->AsBreakableStatement(), kExprLoop, true);
400 RECURSE(Visit(stmt->body())); 398 RECURSE(Visit(stmt->body()));
401 RECURSE(Visit(stmt->cond())); 399 RECURSE(Visit(stmt->cond()));
402 current_function_builder_->Emit(kExprIf); 400 current_function_builder_->Emit(kExprIf);
403 current_function_builder_->EmitWithU8U8(kExprBr, ARITY_0, 1); 401 current_function_builder_->EmitWithU8U8(kExprBr, ARITY_0, 1);
404 current_function_builder_->Emit(kExprEnd); 402 current_function_builder_->Emit(kExprEnd);
405 } 403 }
406 404
407 void VisitWhileStatement(WhileStatement* stmt) override { 405 void VisitWhileStatement(WhileStatement* stmt) {
408 DCHECK_EQ(kFuncScope, scope_); 406 DCHECK_EQ(kFuncScope, scope_);
409 BlockVisitor visitor(this, stmt->AsBreakableStatement(), kExprLoop, true); 407 BlockVisitor visitor(this, stmt->AsBreakableStatement(), kExprLoop, true);
410 RECURSE(Visit(stmt->cond())); 408 RECURSE(Visit(stmt->cond()));
411 breakable_blocks_.push_back(std::make_pair(nullptr, false)); 409 breakable_blocks_.push_back(std::make_pair(nullptr, false));
412 current_function_builder_->Emit(kExprIf); 410 current_function_builder_->Emit(kExprIf);
413 RECURSE(Visit(stmt->body())); 411 RECURSE(Visit(stmt->body()));
414 current_function_builder_->EmitWithU8U8(kExprBr, ARITY_0, 1); 412 current_function_builder_->EmitWithU8U8(kExprBr, ARITY_0, 1);
415 current_function_builder_->Emit(kExprEnd); 413 current_function_builder_->Emit(kExprEnd);
416 breakable_blocks_.pop_back(); 414 breakable_blocks_.pop_back();
417 } 415 }
418 416
419 void VisitForStatement(ForStatement* stmt) override { 417 void VisitForStatement(ForStatement* stmt) {
420 DCHECK_EQ(kFuncScope, scope_); 418 DCHECK_EQ(kFuncScope, scope_);
421 if (stmt->init() != nullptr) { 419 if (stmt->init() != nullptr) {
422 RECURSE(Visit(stmt->init())); 420 RECURSE(Visit(stmt->init()));
423 } 421 }
424 BlockVisitor visitor(this, stmt->AsBreakableStatement(), kExprLoop, true); 422 BlockVisitor visitor(this, stmt->AsBreakableStatement(), kExprLoop, true);
425 if (stmt->cond() != nullptr) { 423 if (stmt->cond() != nullptr) {
426 RECURSE(Visit(stmt->cond())); 424 RECURSE(Visit(stmt->cond()));
427 current_function_builder_->Emit(kExprI32Eqz); 425 current_function_builder_->Emit(kExprI32Eqz);
428 current_function_builder_->Emit(kExprIf); 426 current_function_builder_->Emit(kExprIf);
429 current_function_builder_->Emit(kExprNop); 427 current_function_builder_->Emit(kExprNop);
430 current_function_builder_->EmitWithU8U8(kExprBr, ARITY_0, 2); 428 current_function_builder_->EmitWithU8U8(kExprBr, ARITY_0, 2);
431 current_function_builder_->Emit(kExprEnd); 429 current_function_builder_->Emit(kExprEnd);
432 } 430 }
433 if (stmt->body() != nullptr) { 431 if (stmt->body() != nullptr) {
434 RECURSE(Visit(stmt->body())); 432 RECURSE(Visit(stmt->body()));
435 } 433 }
436 if (stmt->next() != nullptr) { 434 if (stmt->next() != nullptr) {
437 RECURSE(Visit(stmt->next())); 435 RECURSE(Visit(stmt->next()));
438 } 436 }
439 current_function_builder_->Emit(kExprNop); 437 current_function_builder_->Emit(kExprNop);
440 current_function_builder_->EmitWithU8U8(kExprBr, ARITY_0, 0); 438 current_function_builder_->EmitWithU8U8(kExprBr, ARITY_0, 0);
441 } 439 }
442 440
443 void VisitForInStatement(ForInStatement* stmt) override { UNREACHABLE(); } 441 void VisitForInStatement(ForInStatement* stmt) { UNREACHABLE(); }
444 442
445 void VisitForOfStatement(ForOfStatement* stmt) override { UNREACHABLE(); } 443 void VisitForOfStatement(ForOfStatement* stmt) { UNREACHABLE(); }
446 444
447 void VisitTryCatchStatement(TryCatchStatement* stmt) override { 445 void VisitTryCatchStatement(TryCatchStatement* stmt) { UNREACHABLE(); }
448 UNREACHABLE();
449 }
450 446
451 void VisitTryFinallyStatement(TryFinallyStatement* stmt) override { 447 void VisitTryFinallyStatement(TryFinallyStatement* stmt) { UNREACHABLE(); }
452 UNREACHABLE();
453 }
454 448
455 void VisitDebuggerStatement(DebuggerStatement* stmt) override { 449 void VisitDebuggerStatement(DebuggerStatement* stmt) { UNREACHABLE(); }
456 UNREACHABLE();
457 }
458 450
459 void VisitFunctionLiteral(FunctionLiteral* expr) override { 451 void VisitFunctionLiteral(FunctionLiteral* expr) {
460 Scope* scope = expr->scope(); 452 Scope* scope = expr->scope();
461 if (scope_ == kFuncScope) { 453 if (scope_ == kFuncScope) {
462 if (bounds_->get(expr).lower->IsFunction()) { 454 if (bounds_->get(expr).lower->IsFunction()) {
463 // Build the signature for the function. 455 // Build the signature for the function.
464 FunctionType* func_type = bounds_->get(expr).lower->AsFunction(); 456 FunctionType* func_type = bounds_->get(expr).lower->AsFunction();
465 LocalType return_type = TypeFrom(func_type->Result()); 457 LocalType return_type = TypeFrom(func_type->Result());
466 FunctionSig::Builder b(zone(), return_type == kAstStmt ? 0 : 1, 458 FunctionSig::Builder b(zone(), return_type == kAstStmt ? 0 : 1,
467 func_type->Arity()); 459 func_type->Arity());
468 if (return_type != kAstStmt) b.AddReturn(return_type); 460 if (return_type != kAstStmt) b.AddReturn(return_type);
469 for (int i = 0; i < expr->parameter_count(); ++i) { 461 for (int i = 0; i < expr->parameter_count(); ++i) {
470 LocalType type = TypeFrom(func_type->Parameter(i)); 462 LocalType type = TypeFrom(func_type->Parameter(i));
471 DCHECK_NE(kAstStmt, type); 463 DCHECK_NE(kAstStmt, type);
472 b.AddParam(type); 464 b.AddParam(type);
473 InsertParameter(scope->parameter(i), type, i); 465 InsertParameter(scope->parameter(i), type, i);
474 } 466 }
475 current_function_builder_->SetSignature(b.Build()); 467 current_function_builder_->SetSignature(b.Build());
476 } else { 468 } else {
477 UNREACHABLE(); 469 UNREACHABLE();
478 } 470 }
479 } 471 }
480 RECURSE(VisitStatements(expr->body())); 472 RECURSE(VisitStatements(expr->body()));
481 RECURSE(VisitDeclarations(scope->declarations())); 473 RECURSE(VisitDeclarations(scope->declarations()));
482 } 474 }
483 475
484 void VisitNativeFunctionLiteral(NativeFunctionLiteral* expr) override { 476 void VisitNativeFunctionLiteral(NativeFunctionLiteral* expr) {
485 UNREACHABLE(); 477 UNREACHABLE();
486 } 478 }
487 479
488 void VisitConditional(Conditional* expr) override { 480 void VisitConditional(Conditional* expr) {
489 DCHECK_EQ(kFuncScope, scope_); 481 DCHECK_EQ(kFuncScope, scope_);
490 RECURSE(Visit(expr->condition())); 482 RECURSE(Visit(expr->condition()));
491 // WASM ifs come with implicit blocks for both arms. 483 // WASM ifs come with implicit blocks for both arms.
492 breakable_blocks_.push_back(std::make_pair(nullptr, false)); 484 breakable_blocks_.push_back(std::make_pair(nullptr, false));
493 current_function_builder_->Emit(kExprIf); 485 current_function_builder_->Emit(kExprIf);
494 RECURSE(Visit(expr->then_expression())); 486 RECURSE(Visit(expr->then_expression()));
495 current_function_builder_->Emit(kExprElse); 487 current_function_builder_->Emit(kExprElse);
496 RECURSE(Visit(expr->else_expression())); 488 RECURSE(Visit(expr->else_expression()));
497 current_function_builder_->Emit(kExprEnd); 489 current_function_builder_->Emit(kExprEnd);
498 breakable_blocks_.pop_back(); 490 breakable_blocks_.pop_back();
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
543 value = M_SQRT2; 535 value = M_SQRT2;
544 break; 536 break;
545 } 537 }
546 default: { return false; } 538 default: { return false; }
547 } 539 }
548 byte code[] = {WASM_F64(value)}; 540 byte code[] = {WASM_F64(value)};
549 current_function_builder_->EmitCode(code, sizeof(code)); 541 current_function_builder_->EmitCode(code, sizeof(code));
550 return true; 542 return true;
551 } 543 }
552 544
553 void VisitVariableProxy(VariableProxy* expr) override { 545 void VisitVariableProxy(VariableProxy* expr) {
554 if (scope_ == kFuncScope || scope_ == kInitScope) { 546 if (scope_ == kFuncScope || scope_ == kInitScope) {
555 Variable* var = expr->var(); 547 Variable* var = expr->var();
556 if (VisitStdlibConstant(var)) { 548 if (VisitStdlibConstant(var)) {
557 return; 549 return;
558 } 550 }
559 LocalType var_type = TypeOf(expr); 551 LocalType var_type = TypeOf(expr);
560 DCHECK_NE(kAstStmt, var_type); 552 DCHECK_NE(kAstStmt, var_type);
561 if (var->IsContextSlot()) { 553 if (var->IsContextSlot()) {
562 current_function_builder_->EmitWithVarInt( 554 current_function_builder_->EmitWithVarInt(
563 kExprLoadGlobal, LookupOrInsertGlobal(var, var_type)); 555 kExprLoadGlobal, LookupOrInsertGlobal(var, var_type));
564 } else { 556 } else {
565 current_function_builder_->EmitGetLocal( 557 current_function_builder_->EmitGetLocal(
566 LookupOrInsertLocal(var, var_type)); 558 LookupOrInsertLocal(var, var_type));
567 } 559 }
568 } 560 }
569 } 561 }
570 562
571 void VisitLiteral(Literal* expr) override { 563 void VisitLiteral(Literal* expr) {
572 Handle<Object> value = expr->value(); 564 Handle<Object> value = expr->value();
573 if (!value->IsNumber() || (scope_ != kFuncScope && scope_ != kInitScope)) { 565 if (!value->IsNumber() || (scope_ != kFuncScope && scope_ != kInitScope)) {
574 return; 566 return;
575 } 567 }
576 Type* type = bounds_->get(expr).upper; 568 Type* type = bounds_->get(expr).upper;
577 if (type->Is(cache_.kAsmSigned)) { 569 if (type->Is(cache_.kAsmSigned)) {
578 int32_t i = 0; 570 int32_t i = 0;
579 if (!value->ToInt32(&i)) { 571 if (!value->ToInt32(&i)) {
580 UNREACHABLE(); 572 UNREACHABLE();
581 } 573 }
582 byte code[] = {WASM_I32V(i)}; 574 byte code[] = {WASM_I32V(i)};
583 current_function_builder_->EmitCode(code, sizeof(code)); 575 current_function_builder_->EmitCode(code, sizeof(code));
584 } else if (type->Is(cache_.kAsmUnsigned) || type->Is(cache_.kAsmFixnum)) { 576 } else if (type->Is(cache_.kAsmUnsigned) || type->Is(cache_.kAsmFixnum)) {
585 uint32_t u = 0; 577 uint32_t u = 0;
586 if (!value->ToUint32(&u)) { 578 if (!value->ToUint32(&u)) {
587 UNREACHABLE(); 579 UNREACHABLE();
588 } 580 }
589 int32_t i = static_cast<int32_t>(u); 581 int32_t i = static_cast<int32_t>(u);
590 byte code[] = {WASM_I32V(i)}; 582 byte code[] = {WASM_I32V(i)};
591 current_function_builder_->EmitCode(code, sizeof(code)); 583 current_function_builder_->EmitCode(code, sizeof(code));
592 } else if (type->Is(cache_.kAsmDouble)) { 584 } else if (type->Is(cache_.kAsmDouble)) {
593 double val = expr->raw_value()->AsNumber(); 585 double val = expr->raw_value()->AsNumber();
594 byte code[] = {WASM_F64(val)}; 586 byte code[] = {WASM_F64(val)};
595 current_function_builder_->EmitCode(code, sizeof(code)); 587 current_function_builder_->EmitCode(code, sizeof(code));
596 } else { 588 } else {
597 UNREACHABLE(); 589 UNREACHABLE();
598 } 590 }
599 } 591 }
600 592
601 void VisitRegExpLiteral(RegExpLiteral* expr) override { UNREACHABLE(); } 593 void VisitRegExpLiteral(RegExpLiteral* expr) { UNREACHABLE(); }
602 594
603 void VisitObjectLiteral(ObjectLiteral* expr) override { 595 void VisitObjectLiteral(ObjectLiteral* expr) {
604 ZoneList<ObjectLiteralProperty*>* props = expr->properties(); 596 ZoneList<ObjectLiteralProperty*>* props = expr->properties();
605 for (int i = 0; i < props->length(); ++i) { 597 for (int i = 0; i < props->length(); ++i) {
606 ObjectLiteralProperty* prop = props->at(i); 598 ObjectLiteralProperty* prop = props->at(i);
607 DCHECK_EQ(kExportScope, scope_); 599 DCHECK_EQ(kExportScope, scope_);
608 VariableProxy* expr = prop->value()->AsVariableProxy(); 600 VariableProxy* expr = prop->value()->AsVariableProxy();
609 DCHECK_NOT_NULL(expr); 601 DCHECK_NOT_NULL(expr);
610 Variable* var = expr->var(); 602 Variable* var = expr->var();
611 Literal* name = prop->key()->AsLiteral(); 603 Literal* name = prop->key()->AsLiteral();
612 DCHECK_NOT_NULL(name); 604 DCHECK_NOT_NULL(name);
613 DCHECK(name->IsPropertyName()); 605 DCHECK(name->IsPropertyName());
614 const AstRawString* raw_name = name->AsRawPropertyName(); 606 const AstRawString* raw_name = name->AsRawPropertyName();
615 if (var->is_function()) { 607 if (var->is_function()) {
616 uint32_t index = LookupOrInsertFunction(var); 608 uint32_t index = LookupOrInsertFunction(var);
617 builder_->FunctionAt(index)->SetExported(); 609 builder_->FunctionAt(index)->SetExported();
618 builder_->FunctionAt(index)->SetName( 610 builder_->FunctionAt(index)->SetName(
619 reinterpret_cast<const char*>(raw_name->raw_data()), 611 reinterpret_cast<const char*>(raw_name->raw_data()),
620 raw_name->length()); 612 raw_name->length());
621 } 613 }
622 } 614 }
623 } 615 }
624 616
625 void VisitArrayLiteral(ArrayLiteral* expr) override { UNREACHABLE(); } 617 void VisitArrayLiteral(ArrayLiteral* expr) { UNREACHABLE(); }
626 618
627 void LoadInitFunction() { 619 void LoadInitFunction() {
628 current_function_builder_ = builder_->FunctionAt(init_function_index_); 620 current_function_builder_ = builder_->FunctionAt(init_function_index_);
629 scope_ = kInitScope; 621 scope_ = kInitScope;
630 } 622 }
631 623
632 void UnLoadInitFunction() { 624 void UnLoadInitFunction() {
633 scope_ = kModuleScope; 625 scope_ = kModuleScope;
634 current_function_builder_ = nullptr; 626 current_function_builder_ = nullptr;
635 } 627 }
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after
830 UNREACHABLE(); 822 UNREACHABLE();
831 } 823 }
832 current_function_builder_->Emit(opcode); 824 current_function_builder_->Emit(opcode);
833 } 825 }
834 826
835 if (target_var == nullptr && target_prop == nullptr) { 827 if (target_var == nullptr && target_prop == nullptr) {
836 UNREACHABLE(); // invalid assignment. 828 UNREACHABLE(); // invalid assignment.
837 } 829 }
838 } 830 }
839 831
840 void VisitAssignment(Assignment* expr) override { 832 void VisitAssignment(Assignment* expr) {
841 bool as_init = false; 833 bool as_init = false;
842 if (scope_ == kModuleScope) { 834 if (scope_ == kModuleScope) {
843 Property* prop = expr->value()->AsProperty(); 835 Property* prop = expr->value()->AsProperty();
844 if (prop != nullptr) { 836 if (prop != nullptr) {
845 VariableProxy* vp = prop->obj()->AsVariableProxy(); 837 VariableProxy* vp = prop->obj()->AsVariableProxy();
846 if (vp != nullptr && vp->var()->IsParameter() && 838 if (vp != nullptr && vp->var()->IsParameter() &&
847 vp->var()->index() == 1) { 839 vp->var()->index() == 1) {
848 VariableProxy* target = expr->target()->AsVariableProxy(); 840 VariableProxy* target = expr->target()->AsVariableProxy();
849 if (bounds_->get(target).lower->Is(Type::Function())) { 841 if (bounds_->get(target).lower->Is(Type::Function())) {
850 const AstRawString* name = 842 const AstRawString* name =
(...skipping 26 matching lines...) Expand all
877 MachineType mtype; 869 MachineType mtype;
878 bool is_nop = false; 870 bool is_nop = false;
879 EmitAssignmentLhs(expr->target(), &mtype); 871 EmitAssignmentLhs(expr->target(), &mtype);
880 EmitAssignmentRhs(expr->target(), expr->value(), &is_nop); 872 EmitAssignmentRhs(expr->target(), expr->value(), &is_nop);
881 if (!is_nop) { 873 if (!is_nop) {
882 EmitAssignment(expr, mtype); 874 EmitAssignment(expr, mtype);
883 } 875 }
884 if (as_init) UnLoadInitFunction(); 876 if (as_init) UnLoadInitFunction();
885 } 877 }
886 878
887 void VisitYield(Yield* expr) override { UNREACHABLE(); } 879 void VisitYield(Yield* expr) { UNREACHABLE(); }
888 880
889 void VisitThrow(Throw* expr) override { UNREACHABLE(); } 881 void VisitThrow(Throw* expr) { UNREACHABLE(); }
890 882
891 void VisitForeignVariable(bool is_float, Variable* var, Property* expr) { 883 void VisitForeignVariable(bool is_float, Variable* var, Property* expr) {
892 DCHECK(expr->obj()->AsVariableProxy()); 884 DCHECK(expr->obj()->AsVariableProxy());
893 DCHECK(VariableLocation::PARAMETER == 885 DCHECK(VariableLocation::PARAMETER ==
894 expr->obj()->AsVariableProxy()->var()->location()); 886 expr->obj()->AsVariableProxy()->var()->location());
895 DCHECK_EQ(1, expr->obj()->AsVariableProxy()->var()->index()); 887 DCHECK_EQ(1, expr->obj()->AsVariableProxy()->var()->index());
896 Literal* key_literal = expr->key()->AsLiteral(); 888 Literal* key_literal = expr->key()->AsLiteral();
897 DCHECK_NOT_NULL(key_literal); 889 DCHECK_NOT_NULL(key_literal);
898 if (!key_literal->value().is_null()) { 890 if (!key_literal->value().is_null()) {
899 Handle<Name> name = 891 Handle<Name> name =
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
967 // Mask bottom bits to match asm.js behavior. 959 // Mask bottom bits to match asm.js behavior.
968 byte mask = static_cast<byte>(~(size - 1)); 960 byte mask = static_cast<byte>(~(size - 1));
969 RECURSE(Visit(binop->left())); 961 RECURSE(Visit(binop->left()));
970 current_function_builder_->EmitWithU8(kExprI8Const, mask); 962 current_function_builder_->EmitWithU8(kExprI8Const, mask);
971 current_function_builder_->Emit(kExprI32And); 963 current_function_builder_->Emit(kExprI32And);
972 return; 964 return;
973 } 965 }
974 UNREACHABLE(); 966 UNREACHABLE();
975 } 967 }
976 968
977 void VisitProperty(Property* expr) override { 969 void VisitProperty(Property* expr) {
978 MachineType type; 970 MachineType type;
979 VisitPropertyAndEmitIndex(expr, &type); 971 VisitPropertyAndEmitIndex(expr, &type);
980 WasmOpcode opcode; 972 WasmOpcode opcode;
981 if (type == MachineType::Int8()) { 973 if (type == MachineType::Int8()) {
982 opcode = kExprI32AsmjsLoadMem8S; 974 opcode = kExprI32AsmjsLoadMem8S;
983 } else if (type == MachineType::Uint8()) { 975 } else if (type == MachineType::Uint8()) {
984 opcode = kExprI32AsmjsLoadMem8U; 976 opcode = kExprI32AsmjsLoadMem8U;
985 } else if (type == MachineType::Int16()) { 977 } else if (type == MachineType::Int16()) {
986 opcode = kExprI32AsmjsLoadMem16S; 978 opcode = kExprI32AsmjsLoadMem16S;
987 } else if (type == MachineType::Uint16()) { 979 } else if (type == MachineType::Uint16()) {
(...skipping 267 matching lines...) Expand 10 before | Expand all | Expand 10 after
1255 } 1247 }
1256 1248
1257 void VisitCallArgs(Call* expr) { 1249 void VisitCallArgs(Call* expr) {
1258 ZoneList<Expression*>* args = expr->arguments(); 1250 ZoneList<Expression*>* args = expr->arguments();
1259 for (int i = 0; i < args->length(); ++i) { 1251 for (int i = 0; i < args->length(); ++i) {
1260 Expression* arg = args->at(i); 1252 Expression* arg = args->at(i);
1261 RECURSE(Visit(arg)); 1253 RECURSE(Visit(arg));
1262 } 1254 }
1263 } 1255 }
1264 1256
1265 void VisitCall(Call* expr) override { 1257 void VisitCall(Call* expr) {
1266 Call::CallType call_type = expr->GetCallType(isolate_); 1258 Call::CallType call_type = expr->GetCallType(isolate_);
1267 switch (call_type) { 1259 switch (call_type) {
1268 case Call::OTHER_CALL: { 1260 case Call::OTHER_CALL: {
1269 DCHECK_EQ(kFuncScope, scope_); 1261 DCHECK_EQ(kFuncScope, scope_);
1270 VariableProxy* proxy = expr->expression()->AsVariableProxy(); 1262 VariableProxy* proxy = expr->expression()->AsVariableProxy();
1271 if (proxy != nullptr) { 1263 if (proxy != nullptr) {
1272 if (VisitStdlibFunction(expr, proxy)) { 1264 if (VisitStdlibFunction(expr, proxy)) {
1273 return; 1265 return;
1274 } 1266 }
1275 } 1267 }
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
1316 current_function_builder_->Emit(kExprCallIndirect); 1308 current_function_builder_->Emit(kExprCallIndirect);
1317 current_function_builder_->EmitVarInt(expr->arguments()->length()); 1309 current_function_builder_->EmitVarInt(expr->arguments()->length());
1318 current_function_builder_->EmitVarInt(indices->signature_index); 1310 current_function_builder_->EmitVarInt(indices->signature_index);
1319 break; 1311 break;
1320 } 1312 }
1321 default: 1313 default:
1322 UNREACHABLE(); 1314 UNREACHABLE();
1323 } 1315 }
1324 } 1316 }
1325 1317
1326 void VisitCallNew(CallNew* expr) override { UNREACHABLE(); } 1318 void VisitCallNew(CallNew* expr) { UNREACHABLE(); }
1327 1319
1328 void VisitCallRuntime(CallRuntime* expr) override { UNREACHABLE(); } 1320 void VisitCallRuntime(CallRuntime* expr) { UNREACHABLE(); }
1329 1321
1330 void VisitUnaryOperation(UnaryOperation* expr) override { 1322 void VisitUnaryOperation(UnaryOperation* expr) {
1331 RECURSE(Visit(expr->expression())); 1323 RECURSE(Visit(expr->expression()));
1332 switch (expr->op()) { 1324 switch (expr->op()) {
1333 case Token::NOT: { 1325 case Token::NOT: {
1334 DCHECK_EQ(kAstI32, TypeOf(expr->expression())); 1326 DCHECK_EQ(kAstI32, TypeOf(expr->expression()));
1335 current_function_builder_->Emit(kExprI32Eqz); 1327 current_function_builder_->Emit(kExprI32Eqz);
1336 break; 1328 break;
1337 } 1329 }
1338 default: 1330 default:
1339 UNREACHABLE(); 1331 UNREACHABLE();
1340 } 1332 }
1341 } 1333 }
1342 1334
1343 void VisitCountOperation(CountOperation* expr) override { UNREACHABLE(); } 1335 void VisitCountOperation(CountOperation* expr) { UNREACHABLE(); }
1344 1336
1345 bool MatchIntBinaryOperation(BinaryOperation* expr, Token::Value op, 1337 bool MatchIntBinaryOperation(BinaryOperation* expr, Token::Value op,
1346 int32_t val) { 1338 int32_t val) {
1347 DCHECK_NOT_NULL(expr->right()); 1339 DCHECK_NOT_NULL(expr->right());
1348 if (expr->op() == op && expr->right()->IsLiteral() && 1340 if (expr->op() == op && expr->right()->IsLiteral() &&
1349 TypeOf(expr) == kAstI32) { 1341 TypeOf(expr) == kAstI32) {
1350 Literal* right = expr->right()->AsLiteral(); 1342 Literal* right = expr->right()->AsLiteral();
1351 DCHECK(right->raw_value()->IsNumber()); 1343 DCHECK(right->raw_value()->IsNumber());
1352 if (static_cast<int32_t>(right->raw_value()->AsNumber()) == val) { 1344 if (static_cast<int32_t>(right->raw_value()->AsNumber()) == val) {
1353 return true; 1345 return true;
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
1470 } 1462 }
1471 1463
1472 Expression* GetLeft(BinaryOperation* expr) { 1464 Expression* GetLeft(BinaryOperation* expr) {
1473 if (expr->op() == Token::BIT_XOR) { 1465 if (expr->op() == Token::BIT_XOR) {
1474 return expr->left()->AsBinaryOperation()->left(); 1466 return expr->left()->AsBinaryOperation()->left();
1475 } else { 1467 } else {
1476 return expr->left(); 1468 return expr->left();
1477 } 1469 }
1478 } 1470 }
1479 1471
1480 void VisitBinaryOperation(BinaryOperation* expr) override { 1472 void VisitBinaryOperation(BinaryOperation* expr) {
1481 ConvertOperation convertOperation = MatchBinaryOperation(expr); 1473 ConvertOperation convertOperation = MatchBinaryOperation(expr);
1482 if (convertOperation == kToDouble) { 1474 if (convertOperation == kToDouble) {
1483 RECURSE(Visit(expr->left())); 1475 RECURSE(Visit(expr->left()));
1484 TypeIndex type = TypeIndexOf(expr->left()); 1476 TypeIndex type = TypeIndexOf(expr->left());
1485 if (type == kInt32 || type == kFixnum) { 1477 if (type == kInt32 || type == kFixnum) {
1486 current_function_builder_->Emit(kExprF64SConvertI32); 1478 current_function_builder_->Emit(kExprF64SConvertI32);
1487 } else if (type == kUint32) { 1479 } else if (type == kUint32) {
1488 current_function_builder_->Emit(kExprF64UConvertI32); 1480 current_function_builder_->Emit(kExprF64UConvertI32);
1489 } else if (type == kFloat32) { 1481 } else if (type == kFloat32) {
1490 current_function_builder_->Emit(kExprF64ConvertF32); 1482 current_function_builder_->Emit(kExprF64ConvertF32);
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
1548 } 1540 }
1549 case Token::COMMA: { 1541 case Token::COMMA: {
1550 break; 1542 break;
1551 } 1543 }
1552 default: 1544 default:
1553 UNREACHABLE(); 1545 UNREACHABLE();
1554 } 1546 }
1555 } 1547 }
1556 } 1548 }
1557 1549
1558 void VisitCompareOperation(CompareOperation* expr) override { 1550 void VisitCompareOperation(CompareOperation* expr) {
1559 RECURSE(Visit(expr->left())); 1551 RECURSE(Visit(expr->left()));
1560 RECURSE(Visit(expr->right())); 1552 RECURSE(Visit(expr->right()));
1561 switch (expr->op()) { 1553 switch (expr->op()) {
1562 BINOP_CASE(Token::EQ, Eq, NON_SIGNED_BINOP, false); 1554 BINOP_CASE(Token::EQ, Eq, NON_SIGNED_BINOP, false);
1563 BINOP_CASE(Token::LT, Lt, SIGNED_BINOP, false); 1555 BINOP_CASE(Token::LT, Lt, SIGNED_BINOP, false);
1564 BINOP_CASE(Token::LTE, Le, SIGNED_BINOP, false); 1556 BINOP_CASE(Token::LTE, Le, SIGNED_BINOP, false);
1565 BINOP_CASE(Token::GT, Gt, SIGNED_BINOP, false); 1557 BINOP_CASE(Token::GT, Gt, SIGNED_BINOP, false);
1566 BINOP_CASE(Token::GTE, Ge, SIGNED_BINOP, false); 1558 BINOP_CASE(Token::GTE, Ge, SIGNED_BINOP, false);
1567 default: 1559 default:
1568 UNREACHABLE(); 1560 UNREACHABLE();
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
1619 UNREACHABLE(); 1611 UNREACHABLE();
1620 return kInt32; 1612 return kInt32;
1621 } 1613 }
1622 } 1614 }
1623 1615
1624 #undef CASE 1616 #undef CASE
1625 #undef NON_SIGNED_INT 1617 #undef NON_SIGNED_INT
1626 #undef SIGNED 1618 #undef SIGNED
1627 #undef NON_SIGNED 1619 #undef NON_SIGNED
1628 1620
1629 void VisitThisFunction(ThisFunction* expr) override { UNREACHABLE(); } 1621 void VisitThisFunction(ThisFunction* expr) { UNREACHABLE(); }
1630 1622
1631 void VisitDeclarations(ZoneList<Declaration*>* decls) override { 1623 void VisitDeclarations(ZoneList<Declaration*>* decls) {
1632 for (int i = 0; i < decls->length(); ++i) { 1624 for (int i = 0; i < decls->length(); ++i) {
1633 Declaration* decl = decls->at(i); 1625 Declaration* decl = decls->at(i);
1634 RECURSE(Visit(decl)); 1626 RECURSE(Visit(decl));
1635 } 1627 }
1636 } 1628 }
1637 1629
1638 void VisitClassLiteral(ClassLiteral* expr) override { UNREACHABLE(); } 1630 void VisitClassLiteral(ClassLiteral* expr) { UNREACHABLE(); }
1639 1631
1640 void VisitSpread(Spread* expr) override { UNREACHABLE(); } 1632 void VisitSpread(Spread* expr) { UNREACHABLE(); }
1641 1633
1642 void VisitSuperPropertyReference(SuperPropertyReference* expr) override { 1634 void VisitSuperPropertyReference(SuperPropertyReference* expr) {
1643 UNREACHABLE(); 1635 UNREACHABLE();
1644 } 1636 }
1645 1637
1646 void VisitSuperCallReference(SuperCallReference* expr) override { 1638 void VisitSuperCallReference(SuperCallReference* expr) { UNREACHABLE(); }
1639
1640 void VisitSloppyBlockFunctionStatement(SloppyBlockFunctionStatement* expr) {
1647 UNREACHABLE(); 1641 UNREACHABLE();
1648 } 1642 }
1649 1643
1650 void VisitSloppyBlockFunctionStatement( 1644 void VisitDoExpression(DoExpression* expr) { UNREACHABLE(); }
1651 SloppyBlockFunctionStatement* expr) override {
1652 UNREACHABLE();
1653 }
1654 1645
1655 void VisitDoExpression(DoExpression* expr) override { UNREACHABLE(); } 1646 void VisitRewritableExpression(RewritableExpression* expr) { UNREACHABLE(); }
1656
1657 void VisitRewritableExpression(RewritableExpression* expr) override {
1658 UNREACHABLE();
1659 }
1660 1647
1661 struct IndexContainer : public ZoneObject { 1648 struct IndexContainer : public ZoneObject {
1662 uint32_t index; 1649 uint32_t index;
1663 }; 1650 };
1664 1651
1665 uint32_t LookupOrInsertLocal(Variable* v, LocalType type) { 1652 uint32_t LookupOrInsertLocal(Variable* v, LocalType type) {
1666 DCHECK_NOT_NULL(current_function_builder_); 1653 DCHECK_NOT_NULL(current_function_builder_);
1667 ZoneHashMap::Entry* entry = 1654 ZoneHashMap::Entry* entry =
1668 local_variables_.Lookup(v, ComputePointerHash(v)); 1655 local_variables_.Lookup(v, ComputePointerHash(v));
1669 if (entry == nullptr) { 1656 if (entry == nullptr) {
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
1776 AsmWasmBuilderImpl impl(isolate_, zone_, literal_, typer_); 1763 AsmWasmBuilderImpl impl(isolate_, zone_, literal_, typer_);
1777 impl.Build(); 1764 impl.Build();
1778 *foreign_args = impl.GetForeignArgs(); 1765 *foreign_args = impl.GetForeignArgs();
1779 ZoneBuffer* buffer = new (zone_) ZoneBuffer(zone_); 1766 ZoneBuffer* buffer = new (zone_) ZoneBuffer(zone_);
1780 impl.builder_->WriteTo(*buffer); 1767 impl.builder_->WriteTo(*buffer);
1781 return buffer; 1768 return buffer;
1782 } 1769 }
1783 } // namespace wasm 1770 } // namespace wasm
1784 } // namespace internal 1771 } // namespace internal
1785 } // namespace v8 1772 } // namespace v8
OLDNEW
« no previous file with comments | « no previous file | src/asmjs/typing-asm.h » ('j') | src/ast/ast.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698