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

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

Issue 1968493002: [wasm] Introduce special bytecodes for asm.js division/remainder instead of relying on module state. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Move asm.js tests to their own file. Created 4 years, 7 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/compiler/wasm-compiler.cc ('k') | src/wasm/wasm-opcodes.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 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 1365 matching lines...) Expand 10 before | Expand all | Expand 10 after
1376 return MatchMul(expr); 1376 return MatchMul(expr);
1377 default: 1377 default:
1378 return kNone; 1378 return kNone;
1379 } 1379 }
1380 } 1380 }
1381 1381
1382 // Work around Mul + Div being defined in PPC assembler. 1382 // Work around Mul + Div being defined in PPC assembler.
1383 #ifdef Mul 1383 #ifdef Mul
1384 #undef Mul 1384 #undef Mul
1385 #endif 1385 #endif
1386 #ifdef Div
1387 #undef Div
1388 #endif
1389 1386
1390 #define NON_SIGNED_BINOP(op) \ 1387 #define NON_SIGNED_BINOP(op) \
1391 static WasmOpcode opcodes[] = { \ 1388 static WasmOpcode opcodes[] = { \
1392 kExprI32##op, \ 1389 kExprI32##op, \
1393 kExprI32##op, \ 1390 kExprI32##op, \
1394 kExprF32##op, \ 1391 kExprF32##op, \
1395 kExprF64##op \ 1392 kExprF64##op \
1396 } 1393 }
1397 1394
1398 #define SIGNED_BINOP(op) \ 1395 #define SIGNED_BINOP(op) \
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
1457 RECURSE(Visit(expr->right())); 1454 RECURSE(Visit(expr->right()));
1458 1455
1459 if (expr->op() == Token::COMMA) { 1456 if (expr->op() == Token::COMMA) {
1460 current_function_builder_->Emit(kExprEnd); 1457 current_function_builder_->Emit(kExprEnd);
1461 } 1458 }
1462 1459
1463 switch (expr->op()) { 1460 switch (expr->op()) {
1464 BINOP_CASE(Token::ADD, Add, NON_SIGNED_BINOP, true); 1461 BINOP_CASE(Token::ADD, Add, NON_SIGNED_BINOP, true);
1465 BINOP_CASE(Token::SUB, Sub, NON_SIGNED_BINOP, true); 1462 BINOP_CASE(Token::SUB, Sub, NON_SIGNED_BINOP, true);
1466 BINOP_CASE(Token::MUL, Mul, NON_SIGNED_BINOP, true); 1463 BINOP_CASE(Token::MUL, Mul, NON_SIGNED_BINOP, true);
1467 BINOP_CASE(Token::DIV, Div, SIGNED_BINOP, false);
1468 BINOP_CASE(Token::BIT_OR, Ior, NON_SIGNED_INT_BINOP, true); 1464 BINOP_CASE(Token::BIT_OR, Ior, NON_SIGNED_INT_BINOP, true);
1469 BINOP_CASE(Token::BIT_AND, And, NON_SIGNED_INT_BINOP, true); 1465 BINOP_CASE(Token::BIT_AND, And, NON_SIGNED_INT_BINOP, true);
1470 BINOP_CASE(Token::BIT_XOR, Xor, NON_SIGNED_INT_BINOP, true); 1466 BINOP_CASE(Token::BIT_XOR, Xor, NON_SIGNED_INT_BINOP, true);
1471 BINOP_CASE(Token::SHL, Shl, NON_SIGNED_INT_BINOP, true); 1467 BINOP_CASE(Token::SHL, Shl, NON_SIGNED_INT_BINOP, true);
1472 BINOP_CASE(Token::SAR, ShrS, NON_SIGNED_INT_BINOP, true); 1468 BINOP_CASE(Token::SAR, ShrS, NON_SIGNED_INT_BINOP, true);
1473 BINOP_CASE(Token::SHR, ShrU, NON_SIGNED_INT_BINOP, true); 1469 BINOP_CASE(Token::SHR, ShrU, NON_SIGNED_INT_BINOP, true);
1470 case Token::DIV: {
1471 static WasmOpcode opcodes[] = {kExprI32AsmjsDivS, kExprI32AsmjsDivU,
1472 kExprF32Div, kExprF64Div};
1473 int type = TypeIndexOf(expr->left(), expr->right(), false);
1474 current_function_builder_->Emit(opcodes[type]);
1475 break;
1476 }
1474 case Token::MOD: { 1477 case Token::MOD: {
1475 TypeIndex type = TypeIndexOf(expr->left(), expr->right(), false); 1478 TypeIndex type = TypeIndexOf(expr->left(), expr->right(), false);
1476 if (type == kInt32) { 1479 if (type == kInt32) {
1477 current_function_builder_->Emit(kExprI32RemS); 1480 current_function_builder_->Emit(kExprI32AsmjsRemS);
1478 } else if (type == kUint32) { 1481 } else if (type == kUint32) {
1479 current_function_builder_->Emit(kExprI32RemU); 1482 current_function_builder_->Emit(kExprI32AsmjsRemU);
1480 } else if (type == kFloat64) { 1483 } else if (type == kFloat64) {
1481 current_function_builder_->Emit(kExprF64Mod); 1484 current_function_builder_->Emit(kExprF64Mod);
1482 return; 1485 return;
1483 } else { 1486 } else {
1484 UNREACHABLE(); 1487 UNREACHABLE();
1485 } 1488 }
1486 break; 1489 break;
1487 } 1490 }
1488 case Token::COMMA: { 1491 case Token::COMMA: {
1489 break; 1492 break;
(...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after
1701 // that zone in constructor may be thrown away once wasm module is written. 1704 // that zone in constructor may be thrown away once wasm module is written.
1702 WasmModuleIndex* AsmWasmBuilder::Run() { 1705 WasmModuleIndex* AsmWasmBuilder::Run() {
1703 AsmWasmBuilderImpl impl(isolate_, zone_, literal_, foreign_, typer_); 1706 AsmWasmBuilderImpl impl(isolate_, zone_, literal_, foreign_, typer_);
1704 impl.Compile(); 1707 impl.Compile();
1705 WasmModuleWriter* writer = impl.builder_->Build(zone_); 1708 WasmModuleWriter* writer = impl.builder_->Build(zone_);
1706 return writer->WriteTo(zone_); 1709 return writer->WriteTo(zone_);
1707 } 1710 }
1708 } // namespace wasm 1711 } // namespace wasm
1709 } // namespace internal 1712 } // namespace internal
1710 } // namespace v8 1713 } // namespace v8
OLDNEW
« no previous file with comments | « src/compiler/wasm-compiler.cc ('k') | src/wasm/wasm-opcodes.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698