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 1074 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1085 if (binop) { | 1085 if (binop) { |
1086 DCHECK_EQ(Token::SAR, binop->op()); | 1086 DCHECK_EQ(Token::SAR, binop->op()); |
1087 DCHECK(binop->right()->AsLiteral()->raw_value()->IsNumber()); | 1087 DCHECK(binop->right()->AsLiteral()->raw_value()->IsNumber()); |
1088 DCHECK(kWasmI32 == TypeOf(binop->right()->AsLiteral())); | 1088 DCHECK(kWasmI32 == TypeOf(binop->right()->AsLiteral())); |
1089 DCHECK_EQ(size, | 1089 DCHECK_EQ(size, |
1090 1 << static_cast<int>( | 1090 1 << static_cast<int>( |
1091 binop->right()->AsLiteral()->raw_value()->AsNumber())); | 1091 binop->right()->AsLiteral()->raw_value()->AsNumber())); |
1092 // Mask bottom bits to match asm.js behavior. | 1092 // Mask bottom bits to match asm.js behavior. |
1093 byte mask = static_cast<byte>(~(size - 1)); | 1093 byte mask = static_cast<byte>(~(size - 1)); |
1094 RECURSE(Visit(binop->left())); | 1094 RECURSE(Visit(binop->left())); |
1095 current_function_builder_->EmitWithU8(kExprI8Const, mask); | 1095 current_function_builder_->EmitI32Const(mask); |
1096 current_function_builder_->Emit(kExprI32And); | 1096 current_function_builder_->Emit(kExprI32And); |
1097 return; | 1097 return; |
1098 } | 1098 } |
1099 UNREACHABLE(); | 1099 UNREACHABLE(); |
1100 } | 1100 } |
1101 | 1101 |
1102 void VisitProperty(Property* expr) { | 1102 void VisitProperty(Property* expr) { |
1103 AsmType* type = AsmType::None(); | 1103 AsmType* type = AsmType::None(); |
1104 VisitPropertyAndEmitIndex(expr, &type); | 1104 VisitPropertyAndEmitIndex(expr, &type); |
1105 WasmOpcode opcode; | 1105 WasmOpcode opcode; |
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1224 current_function_builder_->Emit(kExprI32Clz); | 1224 current_function_builder_->Emit(kExprI32Clz); |
1225 break; | 1225 break; |
1226 } | 1226 } |
1227 case AsmTyper::kMathAbs: { | 1227 case AsmTyper::kMathAbs: { |
1228 if (call_type == kWasmI32) { | 1228 if (call_type == kWasmI32) { |
1229 WasmTemporary tmp(current_function_builder_, kWasmI32); | 1229 WasmTemporary tmp(current_function_builder_, kWasmI32); |
1230 | 1230 |
1231 // if set_local(tmp, x) < 0 | 1231 // if set_local(tmp, x) < 0 |
1232 Visit(call->arguments()->at(0)); | 1232 Visit(call->arguments()->at(0)); |
1233 current_function_builder_->EmitTeeLocal(tmp.index()); | 1233 current_function_builder_->EmitTeeLocal(tmp.index()); |
1234 byte code[] = {WASM_I8(0)}; | 1234 byte code[] = {WASM_ZERO}; |
1235 current_function_builder_->EmitCode(code, sizeof(code)); | 1235 current_function_builder_->EmitCode(code, sizeof(code)); |
1236 current_function_builder_->Emit(kExprI32LtS); | 1236 current_function_builder_->Emit(kExprI32LtS); |
1237 current_function_builder_->EmitWithU8(kExprIf, kLocalI32); | 1237 current_function_builder_->EmitWithU8(kExprIf, kLocalI32); |
1238 | 1238 |
1239 // then (0 - tmp) | 1239 // then (0 - tmp) |
1240 current_function_builder_->EmitCode(code, sizeof(code)); | 1240 current_function_builder_->EmitCode(code, sizeof(code)); |
1241 current_function_builder_->EmitGetLocal(tmp.index()); | 1241 current_function_builder_->EmitGetLocal(tmp.index()); |
1242 current_function_builder_->Emit(kExprI32Sub); | 1242 current_function_builder_->Emit(kExprI32Sub); |
1243 | 1243 |
1244 // else tmp | 1244 // else tmp |
(...skipping 734 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1979 impl.builder_->WriteAsmJsOffsetTable(*asm_offsets_buffer); | 1979 impl.builder_->WriteAsmJsOffsetTable(*asm_offsets_buffer); |
1980 return {module_buffer, asm_offsets_buffer, success}; | 1980 return {module_buffer, asm_offsets_buffer, success}; |
1981 } | 1981 } |
1982 | 1982 |
1983 const char* AsmWasmBuilder::foreign_init_name = "__foreign_init__"; | 1983 const char* AsmWasmBuilder::foreign_init_name = "__foreign_init__"; |
1984 const char* AsmWasmBuilder::single_function_name = "__single_function__"; | 1984 const char* AsmWasmBuilder::single_function_name = "__single_function__"; |
1985 | 1985 |
1986 } // namespace wasm | 1986 } // namespace wasm |
1987 } // namespace internal | 1987 } // namespace internal |
1988 } // namespace v8 | 1988 } // namespace v8 |
OLD | NEW |