| OLD | NEW |
| 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 Loading... |
| 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 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 112 } | 112 } |
| 113 return ret; | 113 return ret; |
| 114 } | 114 } |
| 115 | 115 |
| 116 void Build() { | 116 void Build() { |
| 117 InitializeInitFunction(); | 117 InitializeInitFunction(); |
| 118 RECURSE(VisitFunctionLiteral(literal_)); | 118 RECURSE(VisitFunctionLiteral(literal_)); |
| 119 BuildForeignInitFunction(); | 119 BuildForeignInitFunction(); |
| 120 } | 120 } |
| 121 | 121 |
| 122 void VisitVariableDeclaration(VariableDeclaration* decl) override {} | 122 void VisitVariableDeclaration(VariableDeclaration* decl) {} |
| 123 | 123 |
| 124 void VisitFunctionDeclaration(FunctionDeclaration* decl) override { | 124 void VisitFunctionDeclaration(FunctionDeclaration* decl) { |
| 125 DCHECK_EQ(kModuleScope, scope_); | 125 DCHECK_EQ(kModuleScope, scope_); |
| 126 DCHECK_NULL(current_function_builder_); | 126 DCHECK_NULL(current_function_builder_); |
| 127 uint32_t index = LookupOrInsertFunction(decl->proxy()->var()); | 127 uint32_t index = LookupOrInsertFunction(decl->proxy()->var()); |
| 128 current_function_builder_ = builder_->FunctionAt(index); | 128 current_function_builder_ = builder_->FunctionAt(index); |
| 129 scope_ = kFuncScope; | 129 scope_ = kFuncScope; |
| 130 RECURSE(Visit(decl->fun())); | 130 RECURSE(Visit(decl->fun())); |
| 131 scope_ = kModuleScope; | 131 scope_ = kModuleScope; |
| 132 current_function_builder_ = nullptr; | 132 current_function_builder_ = nullptr; |
| 133 local_variables_.Clear(); | 133 local_variables_.Clear(); |
| 134 } | 134 } |
| 135 | 135 |
| 136 void VisitImportDeclaration(ImportDeclaration* decl) override {} | 136 void VisitImportDeclaration(ImportDeclaration* decl) {} |
| 137 | 137 |
| 138 void VisitStatements(ZoneList<Statement*>* stmts) override { | 138 void VisitStatements(ZoneList<Statement*>* stmts) { |
| 139 for (int i = 0; i < stmts->length(); ++i) { | 139 for (int i = 0; i < stmts->length(); ++i) { |
| 140 Statement* stmt = stmts->at(i); | 140 Statement* stmt = stmts->at(i); |
| 141 ExpressionStatement* e = stmt->AsExpressionStatement(); | 141 ExpressionStatement* e = stmt->AsExpressionStatement(); |
| 142 if (e != nullptr && e->expression()->IsUndefinedLiteral()) { | 142 if (e != nullptr && e->expression()->IsUndefinedLiteral()) { |
| 143 continue; | 143 continue; |
| 144 } | 144 } |
| 145 RECURSE(Visit(stmt)); | 145 RECURSE(Visit(stmt)); |
| 146 if (stmt->IsJump()) break; | 146 if (stmt->IsJump()) break; |
| 147 } | 147 } |
| 148 } | 148 } |
| 149 | 149 |
| 150 void VisitBlock(Block* stmt) override { | 150 void VisitBlock(Block* stmt) { |
| 151 if (stmt->statements()->length() == 1) { | 151 if (stmt->statements()->length() == 1) { |
| 152 ExpressionStatement* expr = | 152 ExpressionStatement* expr = |
| 153 stmt->statements()->at(0)->AsExpressionStatement(); | 153 stmt->statements()->at(0)->AsExpressionStatement(); |
| 154 if (expr != nullptr) { | 154 if (expr != nullptr) { |
| 155 if (expr->expression()->IsAssignment()) { | 155 if (expr->expression()->IsAssignment()) { |
| 156 RECURSE(VisitExpressionStatement(expr)); | 156 RECURSE(VisitExpressionStatement(expr)); |
| 157 return; | 157 return; |
| 158 } | 158 } |
| 159 } | 159 } |
| 160 } | 160 } |
| (...skipping 16 matching lines...) Expand all Loading... |
| 177 : builder_(builder) { | 177 : builder_(builder) { |
| 178 builder_->breakable_blocks_.push_back(std::make_pair(stmt, is_loop)); | 178 builder_->breakable_blocks_.push_back(std::make_pair(stmt, is_loop)); |
| 179 builder_->current_function_builder_->Emit(opcode); | 179 builder_->current_function_builder_->Emit(opcode); |
| 180 } | 180 } |
| 181 ~BlockVisitor() { | 181 ~BlockVisitor() { |
| 182 builder_->current_function_builder_->Emit(kExprEnd); | 182 builder_->current_function_builder_->Emit(kExprEnd); |
| 183 builder_->breakable_blocks_.pop_back(); | 183 builder_->breakable_blocks_.pop_back(); |
| 184 } | 184 } |
| 185 }; | 185 }; |
| 186 | 186 |
| 187 void VisitExpressionStatement(ExpressionStatement* stmt) override { | 187 void VisitExpressionStatement(ExpressionStatement* stmt) { |
| 188 RECURSE(Visit(stmt->expression())); | 188 RECURSE(Visit(stmt->expression())); |
| 189 } | 189 } |
| 190 | 190 |
| 191 void VisitEmptyStatement(EmptyStatement* stmt) override {} | 191 void VisitEmptyStatement(EmptyStatement* stmt) {} |
| 192 | 192 |
| 193 void VisitEmptyParentheses(EmptyParentheses* paren) override { | 193 void VisitEmptyParentheses(EmptyParentheses* paren) { UNREACHABLE(); } |
| 194 UNREACHABLE(); | |
| 195 } | |
| 196 | 194 |
| 197 void VisitIfStatement(IfStatement* stmt) override { | 195 void VisitIfStatement(IfStatement* stmt) { |
| 198 DCHECK_EQ(kFuncScope, scope_); | 196 DCHECK_EQ(kFuncScope, scope_); |
| 199 RECURSE(Visit(stmt->condition())); | 197 RECURSE(Visit(stmt->condition())); |
| 200 current_function_builder_->Emit(kExprIf); | 198 current_function_builder_->Emit(kExprIf); |
| 201 // WASM ifs come with implement blocks for both arms. | 199 // WASM ifs come with implement blocks for both arms. |
| 202 breakable_blocks_.push_back(std::make_pair(nullptr, false)); | 200 breakable_blocks_.push_back(std::make_pair(nullptr, false)); |
| 203 if (stmt->HasThenStatement()) { | 201 if (stmt->HasThenStatement()) { |
| 204 RECURSE(Visit(stmt->then_statement())); | 202 RECURSE(Visit(stmt->then_statement())); |
| 205 } | 203 } |
| 206 if (stmt->HasElseStatement()) { | 204 if (stmt->HasElseStatement()) { |
| 207 current_function_builder_->Emit(kExprElse); | 205 current_function_builder_->Emit(kExprElse); |
| 208 RECURSE(Visit(stmt->else_statement())); | 206 RECURSE(Visit(stmt->else_statement())); |
| 209 } | 207 } |
| 210 current_function_builder_->Emit(kExprEnd); | 208 current_function_builder_->Emit(kExprEnd); |
| 211 breakable_blocks_.pop_back(); | 209 breakable_blocks_.pop_back(); |
| 212 } | 210 } |
| 213 | 211 |
| 214 void VisitContinueStatement(ContinueStatement* stmt) override { | 212 void VisitContinueStatement(ContinueStatement* stmt) { |
| 215 DCHECK_EQ(kFuncScope, scope_); | 213 DCHECK_EQ(kFuncScope, scope_); |
| 216 DCHECK_NOT_NULL(stmt->target()); | 214 DCHECK_NOT_NULL(stmt->target()); |
| 217 int i = static_cast<int>(breakable_blocks_.size()) - 1; | 215 int i = static_cast<int>(breakable_blocks_.size()) - 1; |
| 218 int block_distance = 0; | 216 int block_distance = 0; |
| 219 for (; i >= 0; i--) { | 217 for (; i >= 0; i--) { |
| 220 auto elem = breakable_blocks_.at(i); | 218 auto elem = breakable_blocks_.at(i); |
| 221 if (elem.first == stmt->target()) { | 219 if (elem.first == stmt->target()) { |
| 222 DCHECK(elem.second); | 220 DCHECK(elem.second); |
| 223 break; | 221 break; |
| 224 } else if (elem.second) { | 222 } else if (elem.second) { |
| 225 block_distance += 2; | 223 block_distance += 2; |
| 226 } else { | 224 } else { |
| 227 block_distance += 1; | 225 block_distance += 1; |
| 228 } | 226 } |
| 229 } | 227 } |
| 230 DCHECK(i >= 0); | 228 DCHECK(i >= 0); |
| 231 current_function_builder_->EmitWithU8(kExprBr, ARITY_0); | 229 current_function_builder_->EmitWithU8(kExprBr, ARITY_0); |
| 232 current_function_builder_->EmitVarInt(block_distance); | 230 current_function_builder_->EmitVarInt(block_distance); |
| 233 } | 231 } |
| 234 | 232 |
| 235 void VisitBreakStatement(BreakStatement* stmt) override { | 233 void VisitBreakStatement(BreakStatement* stmt) { |
| 236 DCHECK_EQ(kFuncScope, scope_); | 234 DCHECK_EQ(kFuncScope, scope_); |
| 237 DCHECK_NOT_NULL(stmt->target()); | 235 DCHECK_NOT_NULL(stmt->target()); |
| 238 int i = static_cast<int>(breakable_blocks_.size()) - 1; | 236 int i = static_cast<int>(breakable_blocks_.size()) - 1; |
| 239 int block_distance = 0; | 237 int block_distance = 0; |
| 240 for (; i >= 0; i--) { | 238 for (; i >= 0; i--) { |
| 241 auto elem = breakable_blocks_.at(i); | 239 auto elem = breakable_blocks_.at(i); |
| 242 if (elem.first == stmt->target()) { | 240 if (elem.first == stmt->target()) { |
| 243 if (elem.second) { | 241 if (elem.second) { |
| 244 block_distance++; | 242 block_distance++; |
| 245 } | 243 } |
| 246 break; | 244 break; |
| 247 } else if (elem.second) { | 245 } else if (elem.second) { |
| 248 block_distance += 2; | 246 block_distance += 2; |
| 249 } else { | 247 } else { |
| 250 block_distance += 1; | 248 block_distance += 1; |
| 251 } | 249 } |
| 252 } | 250 } |
| 253 DCHECK(i >= 0); | 251 DCHECK(i >= 0); |
| 254 current_function_builder_->EmitWithU8(kExprBr, ARITY_0); | 252 current_function_builder_->EmitWithU8(kExprBr, ARITY_0); |
| 255 current_function_builder_->EmitVarInt(block_distance); | 253 current_function_builder_->EmitVarInt(block_distance); |
| 256 } | 254 } |
| 257 | 255 |
| 258 void VisitReturnStatement(ReturnStatement* stmt) override { | 256 void VisitReturnStatement(ReturnStatement* stmt) { |
| 259 if (scope_ == kModuleScope) { | 257 if (scope_ == kModuleScope) { |
| 260 scope_ = kExportScope; | 258 scope_ = kExportScope; |
| 261 RECURSE(Visit(stmt->expression())); | 259 RECURSE(Visit(stmt->expression())); |
| 262 scope_ = kModuleScope; | 260 scope_ = kModuleScope; |
| 263 } else if (scope_ == kFuncScope) { | 261 } else if (scope_ == kFuncScope) { |
| 264 RECURSE(Visit(stmt->expression())); | 262 RECURSE(Visit(stmt->expression())); |
| 265 uint8_t arity = | 263 uint8_t arity = |
| 266 TypeOf(stmt->expression()) == kAstStmt ? ARITY_0 : ARITY_1; | 264 TypeOf(stmt->expression()) == kAstStmt ? ARITY_0 : ARITY_1; |
| 267 current_function_builder_->EmitWithU8(kExprReturn, arity); | 265 current_function_builder_->EmitWithU8(kExprReturn, arity); |
| 268 } else { | 266 } else { |
| 269 UNREACHABLE(); | 267 UNREACHABLE(); |
| 270 } | 268 } |
| 271 } | 269 } |
| 272 | 270 |
| 273 void VisitWithStatement(WithStatement* stmt) override { UNREACHABLE(); } | 271 void VisitWithStatement(WithStatement* stmt) { UNREACHABLE(); } |
| 274 | 272 |
| 275 void HandleCase(CaseNode* node, | 273 void HandleCase(CaseNode* node, |
| 276 const ZoneMap<int, unsigned int>& case_to_block, | 274 const ZoneMap<int, unsigned int>& case_to_block, |
| 277 VariableProxy* tag, int default_block, int if_depth) { | 275 VariableProxy* tag, int default_block, int if_depth) { |
| 278 int prev_if_depth = if_depth; | 276 int prev_if_depth = if_depth; |
| 279 if (node->left != nullptr) { | 277 if (node->left != nullptr) { |
| 280 VisitVariableProxy(tag); | 278 VisitVariableProxy(tag); |
| 281 current_function_builder_->EmitI32Const(node->begin); | 279 current_function_builder_->EmitI32Const(node->begin); |
| 282 current_function_builder_->Emit(kExprI32LtS); | 280 current_function_builder_->Emit(kExprI32LtS); |
| 283 current_function_builder_->Emit(kExprIf); | 281 current_function_builder_->Emit(kExprIf); |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 331 byte break_code[] = {BR_TARGET(if_depth + default_block)}; | 329 byte break_code[] = {BR_TARGET(if_depth + default_block)}; |
| 332 current_function_builder_->EmitCode(break_code, sizeof(break_code)); | 330 current_function_builder_->EmitCode(break_code, sizeof(break_code)); |
| 333 } | 331 } |
| 334 | 332 |
| 335 while (if_depth-- != prev_if_depth) { | 333 while (if_depth-- != prev_if_depth) { |
| 336 breakable_blocks_.pop_back(); | 334 breakable_blocks_.pop_back(); |
| 337 current_function_builder_->Emit(kExprEnd); | 335 current_function_builder_->Emit(kExprEnd); |
| 338 } | 336 } |
| 339 } | 337 } |
| 340 | 338 |
| 341 void VisitSwitchStatement(SwitchStatement* stmt) override { | 339 void VisitSwitchStatement(SwitchStatement* stmt) { |
| 342 VariableProxy* tag = stmt->tag()->AsVariableProxy(); | 340 VariableProxy* tag = stmt->tag()->AsVariableProxy(); |
| 343 DCHECK_NOT_NULL(tag); | 341 DCHECK_NOT_NULL(tag); |
| 344 ZoneList<CaseClause*>* clauses = stmt->cases(); | 342 ZoneList<CaseClause*>* clauses = stmt->cases(); |
| 345 int case_count = clauses->length(); | 343 int case_count = clauses->length(); |
| 346 if (case_count == 0) { | 344 if (case_count == 0) { |
| 347 return; | 345 return; |
| 348 } | 346 } |
| 349 BlockVisitor visitor(this, stmt->AsBreakableStatement(), kExprBlock, false); | 347 BlockVisitor visitor(this, stmt->AsBreakableStatement(), kExprBlock, false); |
| 350 ZoneVector<BlockVisitor*> blocks(zone_); | 348 ZoneVector<BlockVisitor*> blocks(zone_); |
| 351 ZoneVector<int32_t> cases(zone_); | 349 ZoneVector<int32_t> cases(zone_); |
| (...skipping 29 matching lines...) Expand all Loading... |
| 381 } | 379 } |
| 382 for (int i = 0; i < case_count; ++i) { | 380 for (int i = 0; i < case_count; ++i) { |
| 383 CaseClause* clause = clauses->at(i); | 381 CaseClause* clause = clauses->at(i); |
| 384 RECURSE(VisitStatements(clause->statements())); | 382 RECURSE(VisitStatements(clause->statements())); |
| 385 BlockVisitor* v = blocks.at(case_count - i - 1); | 383 BlockVisitor* v = blocks.at(case_count - i - 1); |
| 386 blocks.pop_back(); | 384 blocks.pop_back(); |
| 387 delete v; | 385 delete v; |
| 388 } | 386 } |
| 389 } | 387 } |
| 390 | 388 |
| 391 void VisitCaseClause(CaseClause* clause) override { UNREACHABLE(); } | 389 void VisitCaseClause(CaseClause* clause) { UNREACHABLE(); } |
| 392 | 390 |
| 393 void VisitDoWhileStatement(DoWhileStatement* stmt) override { | 391 void VisitDoWhileStatement(DoWhileStatement* stmt) { |
| 394 DCHECK_EQ(kFuncScope, scope_); | 392 DCHECK_EQ(kFuncScope, scope_); |
| 395 BlockVisitor visitor(this, stmt->AsBreakableStatement(), kExprLoop, true); | 393 BlockVisitor visitor(this, stmt->AsBreakableStatement(), kExprLoop, true); |
| 396 RECURSE(Visit(stmt->body())); | 394 RECURSE(Visit(stmt->body())); |
| 397 RECURSE(Visit(stmt->cond())); | 395 RECURSE(Visit(stmt->cond())); |
| 398 current_function_builder_->Emit(kExprIf); | 396 current_function_builder_->Emit(kExprIf); |
| 399 current_function_builder_->EmitWithU8U8(kExprBr, ARITY_0, 1); | 397 current_function_builder_->EmitWithU8U8(kExprBr, ARITY_0, 1); |
| 400 current_function_builder_->Emit(kExprEnd); | 398 current_function_builder_->Emit(kExprEnd); |
| 401 } | 399 } |
| 402 | 400 |
| 403 void VisitWhileStatement(WhileStatement* stmt) override { | 401 void VisitWhileStatement(WhileStatement* stmt) { |
| 404 DCHECK_EQ(kFuncScope, scope_); | 402 DCHECK_EQ(kFuncScope, scope_); |
| 405 BlockVisitor visitor(this, stmt->AsBreakableStatement(), kExprLoop, true); | 403 BlockVisitor visitor(this, stmt->AsBreakableStatement(), kExprLoop, true); |
| 406 RECURSE(Visit(stmt->cond())); | 404 RECURSE(Visit(stmt->cond())); |
| 407 breakable_blocks_.push_back(std::make_pair(nullptr, false)); | 405 breakable_blocks_.push_back(std::make_pair(nullptr, false)); |
| 408 current_function_builder_->Emit(kExprIf); | 406 current_function_builder_->Emit(kExprIf); |
| 409 RECURSE(Visit(stmt->body())); | 407 RECURSE(Visit(stmt->body())); |
| 410 current_function_builder_->EmitWithU8U8(kExprBr, ARITY_0, 1); | 408 current_function_builder_->EmitWithU8U8(kExprBr, ARITY_0, 1); |
| 411 current_function_builder_->Emit(kExprEnd); | 409 current_function_builder_->Emit(kExprEnd); |
| 412 breakable_blocks_.pop_back(); | 410 breakable_blocks_.pop_back(); |
| 413 } | 411 } |
| 414 | 412 |
| 415 void VisitForStatement(ForStatement* stmt) override { | 413 void VisitForStatement(ForStatement* stmt) { |
| 416 DCHECK_EQ(kFuncScope, scope_); | 414 DCHECK_EQ(kFuncScope, scope_); |
| 417 if (stmt->init() != nullptr) { | 415 if (stmt->init() != nullptr) { |
| 418 RECURSE(Visit(stmt->init())); | 416 RECURSE(Visit(stmt->init())); |
| 419 } | 417 } |
| 420 BlockVisitor visitor(this, stmt->AsBreakableStatement(), kExprLoop, true); | 418 BlockVisitor visitor(this, stmt->AsBreakableStatement(), kExprLoop, true); |
| 421 if (stmt->cond() != nullptr) { | 419 if (stmt->cond() != nullptr) { |
| 422 RECURSE(Visit(stmt->cond())); | 420 RECURSE(Visit(stmt->cond())); |
| 423 current_function_builder_->Emit(kExprI32Eqz); | 421 current_function_builder_->Emit(kExprI32Eqz); |
| 424 current_function_builder_->Emit(kExprIf); | 422 current_function_builder_->Emit(kExprIf); |
| 425 current_function_builder_->Emit(kExprNop); | 423 current_function_builder_->Emit(kExprNop); |
| 426 current_function_builder_->EmitWithU8U8(kExprBr, ARITY_0, 2); | 424 current_function_builder_->EmitWithU8U8(kExprBr, ARITY_0, 2); |
| 427 current_function_builder_->Emit(kExprEnd); | 425 current_function_builder_->Emit(kExprEnd); |
| 428 } | 426 } |
| 429 if (stmt->body() != nullptr) { | 427 if (stmt->body() != nullptr) { |
| 430 RECURSE(Visit(stmt->body())); | 428 RECURSE(Visit(stmt->body())); |
| 431 } | 429 } |
| 432 if (stmt->next() != nullptr) { | 430 if (stmt->next() != nullptr) { |
| 433 RECURSE(Visit(stmt->next())); | 431 RECURSE(Visit(stmt->next())); |
| 434 } | 432 } |
| 435 current_function_builder_->Emit(kExprNop); | 433 current_function_builder_->Emit(kExprNop); |
| 436 current_function_builder_->EmitWithU8U8(kExprBr, ARITY_0, 0); | 434 current_function_builder_->EmitWithU8U8(kExprBr, ARITY_0, 0); |
| 437 } | 435 } |
| 438 | 436 |
| 439 void VisitForInStatement(ForInStatement* stmt) override { UNREACHABLE(); } | 437 void VisitForInStatement(ForInStatement* stmt) { UNREACHABLE(); } |
| 440 | 438 |
| 441 void VisitForOfStatement(ForOfStatement* stmt) override { UNREACHABLE(); } | 439 void VisitForOfStatement(ForOfStatement* stmt) { UNREACHABLE(); } |
| 442 | 440 |
| 443 void VisitTryCatchStatement(TryCatchStatement* stmt) override { | 441 void VisitTryCatchStatement(TryCatchStatement* stmt) { UNREACHABLE(); } |
| 444 UNREACHABLE(); | |
| 445 } | |
| 446 | 442 |
| 447 void VisitTryFinallyStatement(TryFinallyStatement* stmt) override { | 443 void VisitTryFinallyStatement(TryFinallyStatement* stmt) { UNREACHABLE(); } |
| 448 UNREACHABLE(); | |
| 449 } | |
| 450 | 444 |
| 451 void VisitDebuggerStatement(DebuggerStatement* stmt) override { | 445 void VisitDebuggerStatement(DebuggerStatement* stmt) { UNREACHABLE(); } |
| 452 UNREACHABLE(); | |
| 453 } | |
| 454 | 446 |
| 455 void VisitFunctionLiteral(FunctionLiteral* expr) override { | 447 void VisitFunctionLiteral(FunctionLiteral* expr) { |
| 456 Scope* scope = expr->scope(); | 448 Scope* scope = expr->scope(); |
| 457 if (scope_ == kFuncScope) { | 449 if (scope_ == kFuncScope) { |
| 458 if (auto* func_type = typer_->TypeOf(expr)->AsFunctionType()) { | 450 if (auto* func_type = typer_->TypeOf(expr)->AsFunctionType()) { |
| 459 // Build the signature for the function. | 451 // Build the signature for the function. |
| 460 LocalType return_type = TypeFrom(func_type->ReturnType()); | 452 LocalType return_type = TypeFrom(func_type->ReturnType()); |
| 461 const auto& arguments = func_type->Arguments(); | 453 const auto& arguments = func_type->Arguments(); |
| 462 FunctionSig::Builder b(zone(), return_type == kAstStmt ? 0 : 1, | 454 FunctionSig::Builder b(zone(), return_type == kAstStmt ? 0 : 1, |
| 463 arguments.size()); | 455 arguments.size()); |
| 464 if (return_type != kAstStmt) b.AddReturn(return_type); | 456 if (return_type != kAstStmt) b.AddReturn(return_type); |
| 465 for (int i = 0; i < expr->parameter_count(); ++i) { | 457 for (int i = 0; i < expr->parameter_count(); ++i) { |
| 466 LocalType type = TypeFrom(arguments[i]); | 458 LocalType type = TypeFrom(arguments[i]); |
| 467 DCHECK_NE(kAstStmt, type); | 459 DCHECK_NE(kAstStmt, type); |
| 468 b.AddParam(type); | 460 b.AddParam(type); |
| 469 InsertParameter(scope->parameter(i), type, i); | 461 InsertParameter(scope->parameter(i), type, i); |
| 470 } | 462 } |
| 471 current_function_builder_->SetSignature(b.Build()); | 463 current_function_builder_->SetSignature(b.Build()); |
| 472 } else { | 464 } else { |
| 473 UNREACHABLE(); | 465 UNREACHABLE(); |
| 474 } | 466 } |
| 475 } | 467 } |
| 476 RECURSE(VisitStatements(expr->body())); | 468 RECURSE(VisitStatements(expr->body())); |
| 477 RECURSE(VisitDeclarations(scope->declarations())); | 469 RECURSE(VisitDeclarations(scope->declarations())); |
| 478 } | 470 } |
| 479 | 471 |
| 480 void VisitNativeFunctionLiteral(NativeFunctionLiteral* expr) override { | 472 void VisitNativeFunctionLiteral(NativeFunctionLiteral* expr) { |
| 481 UNREACHABLE(); | 473 UNREACHABLE(); |
| 482 } | 474 } |
| 483 | 475 |
| 484 void VisitConditional(Conditional* expr) override { | 476 void VisitConditional(Conditional* expr) { |
| 485 DCHECK_EQ(kFuncScope, scope_); | 477 DCHECK_EQ(kFuncScope, scope_); |
| 486 RECURSE(Visit(expr->condition())); | 478 RECURSE(Visit(expr->condition())); |
| 487 // WASM ifs come with implicit blocks for both arms. | 479 // WASM ifs come with implicit blocks for both arms. |
| 488 breakable_blocks_.push_back(std::make_pair(nullptr, false)); | 480 breakable_blocks_.push_back(std::make_pair(nullptr, false)); |
| 489 current_function_builder_->Emit(kExprIf); | 481 current_function_builder_->Emit(kExprIf); |
| 490 RECURSE(Visit(expr->then_expression())); | 482 RECURSE(Visit(expr->then_expression())); |
| 491 current_function_builder_->Emit(kExprElse); | 483 current_function_builder_->Emit(kExprElse); |
| 492 RECURSE(Visit(expr->else_expression())); | 484 RECURSE(Visit(expr->else_expression())); |
| 493 current_function_builder_->Emit(kExprEnd); | 485 current_function_builder_->Emit(kExprEnd); |
| 494 breakable_blocks_.pop_back(); | 486 breakable_blocks_.pop_back(); |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 539 value = M_SQRT2; | 531 value = M_SQRT2; |
| 540 break; | 532 break; |
| 541 } | 533 } |
| 542 default: { return false; } | 534 default: { return false; } |
| 543 } | 535 } |
| 544 byte code[] = {WASM_F64(value)}; | 536 byte code[] = {WASM_F64(value)}; |
| 545 current_function_builder_->EmitCode(code, sizeof(code)); | 537 current_function_builder_->EmitCode(code, sizeof(code)); |
| 546 return true; | 538 return true; |
| 547 } | 539 } |
| 548 | 540 |
| 549 void VisitVariableProxy(VariableProxy* expr) override { | 541 void VisitVariableProxy(VariableProxy* expr) { |
| 550 if (scope_ == kFuncScope || scope_ == kInitScope) { | 542 if (scope_ == kFuncScope || scope_ == kInitScope) { |
| 551 Variable* var = expr->var(); | 543 Variable* var = expr->var(); |
| 552 if (VisitStdlibConstant(var)) { | 544 if (VisitStdlibConstant(var)) { |
| 553 return; | 545 return; |
| 554 } | 546 } |
| 555 LocalType var_type = TypeOf(expr); | 547 LocalType var_type = TypeOf(expr); |
| 556 DCHECK_NE(kAstStmt, var_type); | 548 DCHECK_NE(kAstStmt, var_type); |
| 557 if (var->IsContextSlot()) { | 549 if (var->IsContextSlot()) { |
| 558 current_function_builder_->EmitWithVarInt( | 550 current_function_builder_->EmitWithVarInt( |
| 559 kExprLoadGlobal, LookupOrInsertGlobal(var, var_type)); | 551 kExprLoadGlobal, LookupOrInsertGlobal(var, var_type)); |
| 560 } else { | 552 } else { |
| 561 current_function_builder_->EmitGetLocal( | 553 current_function_builder_->EmitGetLocal( |
| 562 LookupOrInsertLocal(var, var_type)); | 554 LookupOrInsertLocal(var, var_type)); |
| 563 } | 555 } |
| 564 } | 556 } |
| 565 } | 557 } |
| 566 | 558 |
| 567 void VisitLiteral(Literal* expr) override { | 559 void VisitLiteral(Literal* expr) { |
| 568 Handle<Object> value = expr->value(); | 560 Handle<Object> value = expr->value(); |
| 569 if (!value->IsNumber() || (scope_ != kFuncScope && scope_ != kInitScope)) { | 561 if (!value->IsNumber() || (scope_ != kFuncScope && scope_ != kInitScope)) { |
| 570 return; | 562 return; |
| 571 } | 563 } |
| 572 AsmType* type = typer_->TypeOf(expr); | 564 AsmType* type = typer_->TypeOf(expr); |
| 573 DCHECK_NE(type, AsmType::None()); | 565 DCHECK_NE(type, AsmType::None()); |
| 574 | 566 |
| 575 if (type->IsA(AsmType::Signed())) { | 567 if (type->IsA(AsmType::Signed())) { |
| 576 int32_t i = 0; | 568 int32_t i = 0; |
| 577 if (!value->ToInt32(&i)) { | 569 if (!value->ToInt32(&i)) { |
| (...skipping 11 matching lines...) Expand all Loading... |
| 589 current_function_builder_->EmitCode(code, sizeof(code)); | 581 current_function_builder_->EmitCode(code, sizeof(code)); |
| 590 } else if (type->IsA(AsmType::Double())) { | 582 } else if (type->IsA(AsmType::Double())) { |
| 591 double val = expr->raw_value()->AsNumber(); | 583 double val = expr->raw_value()->AsNumber(); |
| 592 byte code[] = {WASM_F64(val)}; | 584 byte code[] = {WASM_F64(val)}; |
| 593 current_function_builder_->EmitCode(code, sizeof(code)); | 585 current_function_builder_->EmitCode(code, sizeof(code)); |
| 594 } else { | 586 } else { |
| 595 UNREACHABLE(); | 587 UNREACHABLE(); |
| 596 } | 588 } |
| 597 } | 589 } |
| 598 | 590 |
| 599 void VisitRegExpLiteral(RegExpLiteral* expr) override { UNREACHABLE(); } | 591 void VisitRegExpLiteral(RegExpLiteral* expr) { UNREACHABLE(); } |
| 600 | 592 |
| 601 void VisitObjectLiteral(ObjectLiteral* expr) override { | 593 void VisitObjectLiteral(ObjectLiteral* expr) { |
| 602 ZoneList<ObjectLiteralProperty*>* props = expr->properties(); | 594 ZoneList<ObjectLiteralProperty*>* props = expr->properties(); |
| 603 for (int i = 0; i < props->length(); ++i) { | 595 for (int i = 0; i < props->length(); ++i) { |
| 604 ObjectLiteralProperty* prop = props->at(i); | 596 ObjectLiteralProperty* prop = props->at(i); |
| 605 DCHECK_EQ(kExportScope, scope_); | 597 DCHECK_EQ(kExportScope, scope_); |
| 606 VariableProxy* expr = prop->value()->AsVariableProxy(); | 598 VariableProxy* expr = prop->value()->AsVariableProxy(); |
| 607 DCHECK_NOT_NULL(expr); | 599 DCHECK_NOT_NULL(expr); |
| 608 Variable* var = expr->var(); | 600 Variable* var = expr->var(); |
| 609 Literal* name = prop->key()->AsLiteral(); | 601 Literal* name = prop->key()->AsLiteral(); |
| 610 DCHECK_NOT_NULL(name); | 602 DCHECK_NOT_NULL(name); |
| 611 DCHECK(name->IsPropertyName()); | 603 DCHECK(name->IsPropertyName()); |
| 612 const AstRawString* raw_name = name->AsRawPropertyName(); | 604 const AstRawString* raw_name = name->AsRawPropertyName(); |
| 613 if (var->is_function()) { | 605 if (var->is_function()) { |
| 614 uint32_t index = LookupOrInsertFunction(var); | 606 uint32_t index = LookupOrInsertFunction(var); |
| 615 builder_->FunctionAt(index)->SetExported(); | 607 builder_->FunctionAt(index)->SetExported(); |
| 616 builder_->FunctionAt(index)->SetName( | 608 builder_->FunctionAt(index)->SetName( |
| 617 reinterpret_cast<const char*>(raw_name->raw_data()), | 609 reinterpret_cast<const char*>(raw_name->raw_data()), |
| 618 raw_name->length()); | 610 raw_name->length()); |
| 619 } | 611 } |
| 620 } | 612 } |
| 621 } | 613 } |
| 622 | 614 |
| 623 void VisitArrayLiteral(ArrayLiteral* expr) override { UNREACHABLE(); } | 615 void VisitArrayLiteral(ArrayLiteral* expr) { UNREACHABLE(); } |
| 624 | 616 |
| 625 void LoadInitFunction() { | 617 void LoadInitFunction() { |
| 626 current_function_builder_ = builder_->FunctionAt(init_function_index_); | 618 current_function_builder_ = builder_->FunctionAt(init_function_index_); |
| 627 scope_ = kInitScope; | 619 scope_ = kInitScope; |
| 628 } | 620 } |
| 629 | 621 |
| 630 void UnLoadInitFunction() { | 622 void UnLoadInitFunction() { |
| 631 scope_ = kModuleScope; | 623 scope_ = kModuleScope; |
| 632 current_function_builder_ = nullptr; | 624 current_function_builder_ = nullptr; |
| 633 } | 625 } |
| (...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 (typer_->TypeOf(target)->AsFFIType() != nullptr) { | 841 if (typer_->TypeOf(target)->AsFFIType() != nullptr) { |
| 850 const AstRawString* name = | 842 const AstRawString* name = |
| (...skipping 29 matching lines...) Expand all Loading... |
| 880 MachineType mtype; | 872 MachineType mtype; |
| 881 bool is_nop = false; | 873 bool is_nop = false; |
| 882 EmitAssignmentLhs(expr->target(), &mtype); | 874 EmitAssignmentLhs(expr->target(), &mtype); |
| 883 EmitAssignmentRhs(expr->target(), expr->value(), &is_nop); | 875 EmitAssignmentRhs(expr->target(), expr->value(), &is_nop); |
| 884 if (!is_nop) { | 876 if (!is_nop) { |
| 885 EmitAssignment(expr, mtype); | 877 EmitAssignment(expr, mtype); |
| 886 } | 878 } |
| 887 if (as_init) UnLoadInitFunction(); | 879 if (as_init) UnLoadInitFunction(); |
| 888 } | 880 } |
| 889 | 881 |
| 890 void VisitYield(Yield* expr) override { UNREACHABLE(); } | 882 void VisitYield(Yield* expr) { UNREACHABLE(); } |
| 891 | 883 |
| 892 void VisitThrow(Throw* expr) override { UNREACHABLE(); } | 884 void VisitThrow(Throw* expr) { UNREACHABLE(); } |
| 893 | 885 |
| 894 void VisitForeignVariable(bool is_float, Variable* var, Property* expr) { | 886 void VisitForeignVariable(bool is_float, Variable* var, Property* expr) { |
| 895 DCHECK(expr->obj()->AsVariableProxy()); | 887 DCHECK(expr->obj()->AsVariableProxy()); |
| 896 DCHECK(VariableLocation::PARAMETER == | 888 DCHECK(VariableLocation::PARAMETER == |
| 897 expr->obj()->AsVariableProxy()->var()->location()); | 889 expr->obj()->AsVariableProxy()->var()->location()); |
| 898 DCHECK_EQ(1, expr->obj()->AsVariableProxy()->var()->index()); | 890 DCHECK_EQ(1, expr->obj()->AsVariableProxy()->var()->index()); |
| 899 Literal* key_literal = expr->key()->AsLiteral(); | 891 Literal* key_literal = expr->key()->AsLiteral(); |
| 900 DCHECK_NOT_NULL(key_literal); | 892 DCHECK_NOT_NULL(key_literal); |
| 901 if (!key_literal->value().is_null()) { | 893 if (!key_literal->value().is_null()) { |
| 902 Handle<Name> name = | 894 Handle<Name> name = |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 969 // Mask bottom bits to match asm.js behavior. | 961 // Mask bottom bits to match asm.js behavior. |
| 970 byte mask = static_cast<byte>(~(size - 1)); | 962 byte mask = static_cast<byte>(~(size - 1)); |
| 971 RECURSE(Visit(binop->left())); | 963 RECURSE(Visit(binop->left())); |
| 972 current_function_builder_->EmitWithU8(kExprI8Const, mask); | 964 current_function_builder_->EmitWithU8(kExprI8Const, mask); |
| 973 current_function_builder_->Emit(kExprI32And); | 965 current_function_builder_->Emit(kExprI32And); |
| 974 return; | 966 return; |
| 975 } | 967 } |
| 976 UNREACHABLE(); | 968 UNREACHABLE(); |
| 977 } | 969 } |
| 978 | 970 |
| 979 void VisitProperty(Property* expr) override { | 971 void VisitProperty(Property* expr) { |
| 980 MachineType type; | 972 MachineType type; |
| 981 VisitPropertyAndEmitIndex(expr, &type); | 973 VisitPropertyAndEmitIndex(expr, &type); |
| 982 WasmOpcode opcode; | 974 WasmOpcode opcode; |
| 983 if (type == MachineType::Int8()) { | 975 if (type == MachineType::Int8()) { |
| 984 opcode = kExprI32AsmjsLoadMem8S; | 976 opcode = kExprI32AsmjsLoadMem8S; |
| 985 } else if (type == MachineType::Uint8()) { | 977 } else if (type == MachineType::Uint8()) { |
| 986 opcode = kExprI32AsmjsLoadMem8U; | 978 opcode = kExprI32AsmjsLoadMem8U; |
| 987 } else if (type == MachineType::Int16()) { | 979 } else if (type == MachineType::Int16()) { |
| 988 opcode = kExprI32AsmjsLoadMem16S; | 980 opcode = kExprI32AsmjsLoadMem16S; |
| 989 } else if (type == MachineType::Uint16()) { | 981 } else if (type == MachineType::Uint16()) { |
| (...skipping 268 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1258 } | 1250 } |
| 1259 | 1251 |
| 1260 void VisitCallArgs(Call* expr) { | 1252 void VisitCallArgs(Call* expr) { |
| 1261 ZoneList<Expression*>* args = expr->arguments(); | 1253 ZoneList<Expression*>* args = expr->arguments(); |
| 1262 for (int i = 0; i < args->length(); ++i) { | 1254 for (int i = 0; i < args->length(); ++i) { |
| 1263 Expression* arg = args->at(i); | 1255 Expression* arg = args->at(i); |
| 1264 RECURSE(Visit(arg)); | 1256 RECURSE(Visit(arg)); |
| 1265 } | 1257 } |
| 1266 } | 1258 } |
| 1267 | 1259 |
| 1268 void VisitCall(Call* expr) override { | 1260 void VisitCall(Call* expr) { |
| 1269 Call::CallType call_type = expr->GetCallType(isolate_); | 1261 Call::CallType call_type = expr->GetCallType(isolate_); |
| 1270 switch (call_type) { | 1262 switch (call_type) { |
| 1271 case Call::OTHER_CALL: { | 1263 case Call::OTHER_CALL: { |
| 1272 DCHECK_EQ(kFuncScope, scope_); | 1264 DCHECK_EQ(kFuncScope, scope_); |
| 1273 VariableProxy* proxy = expr->expression()->AsVariableProxy(); | 1265 VariableProxy* proxy = expr->expression()->AsVariableProxy(); |
| 1274 if (proxy != nullptr) { | 1266 if (proxy != nullptr) { |
| 1275 if (VisitStdlibFunction(expr, proxy)) { | 1267 if (VisitStdlibFunction(expr, proxy)) { |
| 1276 return; | 1268 return; |
| 1277 } | 1269 } |
| 1278 } | 1270 } |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1319 current_function_builder_->Emit(kExprCallIndirect); | 1311 current_function_builder_->Emit(kExprCallIndirect); |
| 1320 current_function_builder_->EmitVarInt(expr->arguments()->length()); | 1312 current_function_builder_->EmitVarInt(expr->arguments()->length()); |
| 1321 current_function_builder_->EmitVarInt(indices->signature_index); | 1313 current_function_builder_->EmitVarInt(indices->signature_index); |
| 1322 break; | 1314 break; |
| 1323 } | 1315 } |
| 1324 default: | 1316 default: |
| 1325 UNREACHABLE(); | 1317 UNREACHABLE(); |
| 1326 } | 1318 } |
| 1327 } | 1319 } |
| 1328 | 1320 |
| 1329 void VisitCallNew(CallNew* expr) override { UNREACHABLE(); } | 1321 void VisitCallNew(CallNew* expr) { UNREACHABLE(); } |
| 1330 | 1322 |
| 1331 void VisitCallRuntime(CallRuntime* expr) override { UNREACHABLE(); } | 1323 void VisitCallRuntime(CallRuntime* expr) { UNREACHABLE(); } |
| 1332 | 1324 |
| 1333 void VisitUnaryOperation(UnaryOperation* expr) override { | 1325 void VisitUnaryOperation(UnaryOperation* expr) { |
| 1334 RECURSE(Visit(expr->expression())); | 1326 RECURSE(Visit(expr->expression())); |
| 1335 switch (expr->op()) { | 1327 switch (expr->op()) { |
| 1336 case Token::NOT: { | 1328 case Token::NOT: { |
| 1337 DCHECK_EQ(kAstI32, TypeOf(expr->expression())); | 1329 DCHECK_EQ(kAstI32, TypeOf(expr->expression())); |
| 1338 current_function_builder_->Emit(kExprI32Eqz); | 1330 current_function_builder_->Emit(kExprI32Eqz); |
| 1339 break; | 1331 break; |
| 1340 } | 1332 } |
| 1341 default: | 1333 default: |
| 1342 UNREACHABLE(); | 1334 UNREACHABLE(); |
| 1343 } | 1335 } |
| 1344 } | 1336 } |
| 1345 | 1337 |
| 1346 void VisitCountOperation(CountOperation* expr) override { UNREACHABLE(); } | 1338 void VisitCountOperation(CountOperation* expr) { UNREACHABLE(); } |
| 1347 | 1339 |
| 1348 bool MatchIntBinaryOperation(BinaryOperation* expr, Token::Value op, | 1340 bool MatchIntBinaryOperation(BinaryOperation* expr, Token::Value op, |
| 1349 int32_t val) { | 1341 int32_t val) { |
| 1350 DCHECK_NOT_NULL(expr->right()); | 1342 DCHECK_NOT_NULL(expr->right()); |
| 1351 if (expr->op() == op && expr->right()->IsLiteral() && | 1343 if (expr->op() == op && expr->right()->IsLiteral() && |
| 1352 TypeOf(expr) == kAstI32) { | 1344 TypeOf(expr) == kAstI32) { |
| 1353 Literal* right = expr->right()->AsLiteral(); | 1345 Literal* right = expr->right()->AsLiteral(); |
| 1354 DCHECK(right->raw_value()->IsNumber()); | 1346 DCHECK(right->raw_value()->IsNumber()); |
| 1355 if (static_cast<int32_t>(right->raw_value()->AsNumber()) == val) { | 1347 if (static_cast<int32_t>(right->raw_value()->AsNumber()) == val) { |
| 1356 return true; | 1348 return true; |
| (...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1473 } | 1465 } |
| 1474 | 1466 |
| 1475 Expression* GetLeft(BinaryOperation* expr) { | 1467 Expression* GetLeft(BinaryOperation* expr) { |
| 1476 if (expr->op() == Token::BIT_XOR) { | 1468 if (expr->op() == Token::BIT_XOR) { |
| 1477 return expr->left()->AsBinaryOperation()->left(); | 1469 return expr->left()->AsBinaryOperation()->left(); |
| 1478 } else { | 1470 } else { |
| 1479 return expr->left(); | 1471 return expr->left(); |
| 1480 } | 1472 } |
| 1481 } | 1473 } |
| 1482 | 1474 |
| 1483 void VisitBinaryOperation(BinaryOperation* expr) override { | 1475 void VisitBinaryOperation(BinaryOperation* expr) { |
| 1484 ConvertOperation convertOperation = MatchBinaryOperation(expr); | 1476 ConvertOperation convertOperation = MatchBinaryOperation(expr); |
| 1485 static const bool kDontIgnoreSign = false; | 1477 static const bool kDontIgnoreSign = false; |
| 1486 if (convertOperation == kToDouble) { | 1478 if (convertOperation == kToDouble) { |
| 1487 RECURSE(Visit(expr->left())); | 1479 RECURSE(Visit(expr->left())); |
| 1488 TypeIndex type = TypeIndexOf(expr->left(), kDontIgnoreSign); | 1480 TypeIndex type = TypeIndexOf(expr->left(), kDontIgnoreSign); |
| 1489 if (type == kInt32 || type == kFixnum) { | 1481 if (type == kInt32 || type == kFixnum) { |
| 1490 current_function_builder_->Emit(kExprF64SConvertI32); | 1482 current_function_builder_->Emit(kExprF64SConvertI32); |
| 1491 } else if (type == kUint32) { | 1483 } else if (type == kUint32) { |
| 1492 current_function_builder_->Emit(kExprF64UConvertI32); | 1484 current_function_builder_->Emit(kExprF64UConvertI32); |
| 1493 } else if (type == kFloat32) { | 1485 } else if (type == kFloat32) { |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1552 } | 1544 } |
| 1553 case Token::COMMA: { | 1545 case Token::COMMA: { |
| 1554 break; | 1546 break; |
| 1555 } | 1547 } |
| 1556 default: | 1548 default: |
| 1557 UNREACHABLE(); | 1549 UNREACHABLE(); |
| 1558 } | 1550 } |
| 1559 } | 1551 } |
| 1560 } | 1552 } |
| 1561 | 1553 |
| 1562 void VisitCompareOperation(CompareOperation* expr) override { | 1554 void VisitCompareOperation(CompareOperation* expr) { |
| 1563 RECURSE(Visit(expr->left())); | 1555 RECURSE(Visit(expr->left())); |
| 1564 RECURSE(Visit(expr->right())); | 1556 RECURSE(Visit(expr->right())); |
| 1565 switch (expr->op()) { | 1557 switch (expr->op()) { |
| 1566 BINOP_CASE(Token::EQ, Eq, NON_SIGNED_BINOP, false); | 1558 BINOP_CASE(Token::EQ, Eq, NON_SIGNED_BINOP, false); |
| 1567 BINOP_CASE(Token::LT, Lt, SIGNED_BINOP, false); | 1559 BINOP_CASE(Token::LT, Lt, SIGNED_BINOP, false); |
| 1568 BINOP_CASE(Token::LTE, Le, SIGNED_BINOP, false); | 1560 BINOP_CASE(Token::LTE, Le, SIGNED_BINOP, false); |
| 1569 BINOP_CASE(Token::GT, Gt, SIGNED_BINOP, false); | 1561 BINOP_CASE(Token::GT, Gt, SIGNED_BINOP, false); |
| 1570 BINOP_CASE(Token::GTE, Ge, SIGNED_BINOP, false); | 1562 BINOP_CASE(Token::GTE, Ge, SIGNED_BINOP, false); |
| 1571 default: | 1563 default: |
| 1572 UNREACHABLE(); | 1564 UNREACHABLE(); |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1636 | 1628 |
| 1637 UNREACHABLE(); | 1629 UNREACHABLE(); |
| 1638 return kInt32; | 1630 return kInt32; |
| 1639 } | 1631 } |
| 1640 | 1632 |
| 1641 #undef CASE | 1633 #undef CASE |
| 1642 #undef NON_SIGNED_INT | 1634 #undef NON_SIGNED_INT |
| 1643 #undef SIGNED | 1635 #undef SIGNED |
| 1644 #undef NON_SIGNED | 1636 #undef NON_SIGNED |
| 1645 | 1637 |
| 1646 void VisitThisFunction(ThisFunction* expr) override { UNREACHABLE(); } | 1638 void VisitThisFunction(ThisFunction* expr) { UNREACHABLE(); } |
| 1647 | 1639 |
| 1648 void VisitDeclarations(ZoneList<Declaration*>* decls) override { | 1640 void VisitDeclarations(ZoneList<Declaration*>* decls) { |
| 1649 for (int i = 0; i < decls->length(); ++i) { | 1641 for (int i = 0; i < decls->length(); ++i) { |
| 1650 Declaration* decl = decls->at(i); | 1642 Declaration* decl = decls->at(i); |
| 1651 RECURSE(Visit(decl)); | 1643 RECURSE(Visit(decl)); |
| 1652 } | 1644 } |
| 1653 } | 1645 } |
| 1654 | 1646 |
| 1655 void VisitClassLiteral(ClassLiteral* expr) override { UNREACHABLE(); } | 1647 void VisitClassLiteral(ClassLiteral* expr) { UNREACHABLE(); } |
| 1656 | 1648 |
| 1657 void VisitSpread(Spread* expr) override { UNREACHABLE(); } | 1649 void VisitSpread(Spread* expr) { UNREACHABLE(); } |
| 1658 | 1650 |
| 1659 void VisitSuperPropertyReference(SuperPropertyReference* expr) override { | 1651 void VisitSuperPropertyReference(SuperPropertyReference* expr) { |
| 1660 UNREACHABLE(); | 1652 UNREACHABLE(); |
| 1661 } | 1653 } |
| 1662 | 1654 |
| 1663 void VisitSuperCallReference(SuperCallReference* expr) override { | 1655 void VisitSuperCallReference(SuperCallReference* expr) { UNREACHABLE(); } |
| 1656 |
| 1657 void VisitSloppyBlockFunctionStatement(SloppyBlockFunctionStatement* expr) { |
| 1664 UNREACHABLE(); | 1658 UNREACHABLE(); |
| 1665 } | 1659 } |
| 1666 | 1660 |
| 1667 void VisitSloppyBlockFunctionStatement( | 1661 void VisitDoExpression(DoExpression* expr) { UNREACHABLE(); } |
| 1668 SloppyBlockFunctionStatement* expr) override { | |
| 1669 UNREACHABLE(); | |
| 1670 } | |
| 1671 | 1662 |
| 1672 void VisitDoExpression(DoExpression* expr) override { UNREACHABLE(); } | 1663 void VisitRewritableExpression(RewritableExpression* expr) { UNREACHABLE(); } |
| 1673 | |
| 1674 void VisitRewritableExpression(RewritableExpression* expr) override { | |
| 1675 UNREACHABLE(); | |
| 1676 } | |
| 1677 | 1664 |
| 1678 struct IndexContainer : public ZoneObject { | 1665 struct IndexContainer : public ZoneObject { |
| 1679 uint32_t index; | 1666 uint32_t index; |
| 1680 }; | 1667 }; |
| 1681 | 1668 |
| 1682 uint32_t LookupOrInsertLocal(Variable* v, LocalType type) { | 1669 uint32_t LookupOrInsertLocal(Variable* v, LocalType type) { |
| 1683 DCHECK_NOT_NULL(current_function_builder_); | 1670 DCHECK_NOT_NULL(current_function_builder_); |
| 1684 ZoneHashMap::Entry* entry = | 1671 ZoneHashMap::Entry* entry = |
| 1685 local_variables_.Lookup(v, ComputePointerHash(v)); | 1672 local_variables_.Lookup(v, ComputePointerHash(v)); |
| 1686 if (entry == nullptr) { | 1673 if (entry == nullptr) { |
| (...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1792 AsmWasmBuilderImpl impl(isolate_, zone_, literal_, typer_); | 1779 AsmWasmBuilderImpl impl(isolate_, zone_, literal_, typer_); |
| 1793 impl.Build(); | 1780 impl.Build(); |
| 1794 *foreign_args = impl.GetForeignArgs(); | 1781 *foreign_args = impl.GetForeignArgs(); |
| 1795 ZoneBuffer* buffer = new (zone_) ZoneBuffer(zone_); | 1782 ZoneBuffer* buffer = new (zone_) ZoneBuffer(zone_); |
| 1796 impl.builder_->WriteTo(*buffer); | 1783 impl.builder_->WriteTo(*buffer); |
| 1797 return buffer; | 1784 return buffer; |
| 1798 } | 1785 } |
| 1799 } // namespace wasm | 1786 } // namespace wasm |
| 1800 } // namespace internal | 1787 } // namespace internal |
| 1801 } // namespace v8 | 1788 } // namespace v8 |
| OLD | NEW |