Chromium Code Reviews| 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/compiler/wasm-compiler.h" | 5 #include "src/compiler/wasm-compiler.h" |
| 6 | 6 |
| 7 #include <memory> | 7 #include <memory> |
| 8 | 8 |
| 9 #include "src/isolate-inl.h" | 9 #include "src/isolate-inl.h" |
| 10 | 10 |
| (...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 263 Node* GetTrapValue(wasm::ValueType type) { | 263 Node* GetTrapValue(wasm::ValueType type) { |
| 264 switch (type) { | 264 switch (type) { |
| 265 case wasm::kWasmI32: | 265 case wasm::kWasmI32: |
| 266 return jsgraph()->Int32Constant(0xdeadbeef); | 266 return jsgraph()->Int32Constant(0xdeadbeef); |
| 267 case wasm::kWasmI64: | 267 case wasm::kWasmI64: |
| 268 return jsgraph()->Int64Constant(0xdeadbeefdeadbeef); | 268 return jsgraph()->Int64Constant(0xdeadbeefdeadbeef); |
| 269 case wasm::kWasmF32: | 269 case wasm::kWasmF32: |
| 270 return jsgraph()->Float32Constant(bit_cast<float>(0xdeadbeef)); | 270 return jsgraph()->Float32Constant(bit_cast<float>(0xdeadbeef)); |
| 271 case wasm::kWasmF64: | 271 case wasm::kWasmF64: |
| 272 return jsgraph()->Float64Constant(bit_cast<double>(0xdeadbeefdeadbeef)); | 272 return jsgraph()->Float64Constant(bit_cast<double>(0xdeadbeefdeadbeef)); |
| 273 break; | 273 // We can't always set SIMD types to specific bit patterns. Just zero |
| 274 // them out. | |
| 274 case wasm::kWasmS128: | 275 case wasm::kWasmS128: |
| 275 return builder_->CreateS128Value(0xdeadbeef); | 276 return builder_->Simd128Zero(); |
| 276 break; | 277 case wasm::kWasmS1x4: |
| 278 return builder_->Simd1x4Zero(); | |
|
gdeepti
2017/02/24 14:18:11
Would it be better to have these fall through to S
bbudge
2017/02/24 18:33:51
It does seem like a lot of trouble to support a sc
| |
| 279 case wasm::kWasmS1x8: | |
| 280 return builder_->Simd1x8Zero(); | |
| 281 case wasm::kWasmS1x16: | |
| 282 return builder_->Simd1x16Zero(); | |
| 277 default: | 283 default: |
| 278 UNREACHABLE(); | 284 UNREACHABLE(); |
| 279 return nullptr; | 285 return nullptr; |
| 280 } | 286 } |
| 281 } | 287 } |
| 282 | 288 |
| 283 private: | 289 private: |
| 284 WasmGraphBuilder* builder_; | 290 WasmGraphBuilder* builder_; |
| 285 JSGraph* jsgraph_; | 291 JSGraph* jsgraph_; |
| 286 Graph* graph_; | 292 Graph* graph_; |
| (...skipping 3053 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3340 .LowerGraph(); | 3346 .LowerGraph(); |
| 3341 } | 3347 } |
| 3342 | 3348 |
| 3343 void WasmGraphBuilder::SetSourcePosition(Node* node, | 3349 void WasmGraphBuilder::SetSourcePosition(Node* node, |
| 3344 wasm::WasmCodePosition position) { | 3350 wasm::WasmCodePosition position) { |
| 3345 DCHECK_NE(position, wasm::kNoCodePosition); | 3351 DCHECK_NE(position, wasm::kNoCodePosition); |
| 3346 if (source_position_table_) | 3352 if (source_position_table_) |
| 3347 source_position_table_->SetSourcePosition(node, SourcePosition(position)); | 3353 source_position_table_->SetSourcePosition(node, SourcePosition(position)); |
| 3348 } | 3354 } |
| 3349 | 3355 |
| 3350 Node* WasmGraphBuilder::CreateS128Value(int32_t value) { | 3356 Node* WasmGraphBuilder::Simd128Zero() { |
| 3351 // TODO(gdeepti): Introduce Simd128Constant to common-operator.h and use | |
| 3352 // instead of creating a SIMD Value. | |
| 3353 has_simd_ = true; | 3357 has_simd_ = true; |
| 3354 return graph()->NewNode(jsgraph()->machine()->CreateInt32x4(), | 3358 return graph()->NewNode(jsgraph()->machine()->Simd128Zero()); |
| 3355 Int32Constant(value), Int32Constant(value), | 3359 } |
| 3356 Int32Constant(value), Int32Constant(value)); | 3360 |
| 3361 Node* WasmGraphBuilder::Simd1x4Zero() { | |
| 3362 has_simd_ = true; | |
| 3363 return graph()->NewNode(jsgraph()->machine()->Simd1x4Zero()); | |
| 3364 } | |
| 3365 | |
| 3366 Node* WasmGraphBuilder::Simd1x8Zero() { | |
| 3367 has_simd_ = true; | |
| 3368 return graph()->NewNode(jsgraph()->machine()->Simd1x8Zero()); | |
| 3369 } | |
| 3370 | |
| 3371 Node* WasmGraphBuilder::Simd1x16Zero() { | |
| 3372 has_simd_ = true; | |
| 3373 return graph()->NewNode(jsgraph()->machine()->Simd1x16Zero()); | |
| 3357 } | 3374 } |
| 3358 | 3375 |
| 3359 Node* WasmGraphBuilder::SimdOp(wasm::WasmOpcode opcode, | 3376 Node* WasmGraphBuilder::SimdOp(wasm::WasmOpcode opcode, |
| 3360 const NodeVector& inputs) { | 3377 const NodeVector& inputs) { |
| 3361 has_simd_ = true; | 3378 has_simd_ = true; |
| 3362 switch (opcode) { | 3379 switch (opcode) { |
| 3363 case wasm::kExprF32x4Splat: | 3380 case wasm::kExprF32x4Splat: |
| 3364 return graph()->NewNode(jsgraph()->machine()->CreateFloat32x4(), | 3381 return graph()->NewNode(jsgraph()->machine()->Float32x4Splat(), |
| 3365 inputs[0], inputs[0], inputs[0], inputs[0]); | 3382 inputs[0]); |
| 3366 case wasm::kExprF32x4SConvertI32x4: | 3383 case wasm::kExprF32x4SConvertI32x4: |
| 3367 return graph()->NewNode(jsgraph()->machine()->Float32x4FromInt32x4(), | 3384 return graph()->NewNode(jsgraph()->machine()->Float32x4FromInt32x4(), |
| 3368 inputs[0]); | 3385 inputs[0]); |
| 3369 case wasm::kExprF32x4UConvertI32x4: | 3386 case wasm::kExprF32x4UConvertI32x4: |
| 3370 return graph()->NewNode(jsgraph()->machine()->Float32x4FromUint32x4(), | 3387 return graph()->NewNode(jsgraph()->machine()->Float32x4FromUint32x4(), |
| 3371 inputs[0]); | 3388 inputs[0]); |
| 3372 case wasm::kExprF32x4Abs: | 3389 case wasm::kExprF32x4Abs: |
| 3373 return graph()->NewNode(jsgraph()->machine()->Float32x4Abs(), inputs[0]); | 3390 return graph()->NewNode(jsgraph()->machine()->Float32x4Abs(), inputs[0]); |
| 3374 case wasm::kExprF32x4Neg: | 3391 case wasm::kExprF32x4Neg: |
| 3375 return graph()->NewNode(jsgraph()->machine()->Float32x4Neg(), inputs[0]); | 3392 return graph()->NewNode(jsgraph()->machine()->Float32x4Neg(), inputs[0]); |
| 3376 case wasm::kExprF32x4Add: | 3393 case wasm::kExprF32x4Add: |
| 3377 return graph()->NewNode(jsgraph()->machine()->Float32x4Add(), inputs[0], | 3394 return graph()->NewNode(jsgraph()->machine()->Float32x4Add(), inputs[0], |
| 3378 inputs[1]); | 3395 inputs[1]); |
| 3379 case wasm::kExprF32x4Sub: | 3396 case wasm::kExprF32x4Sub: |
| 3380 return graph()->NewNode(jsgraph()->machine()->Float32x4Sub(), inputs[0], | 3397 return graph()->NewNode(jsgraph()->machine()->Float32x4Sub(), inputs[0], |
| 3381 inputs[1]); | 3398 inputs[1]); |
| 3382 case wasm::kExprF32x4Eq: | 3399 case wasm::kExprF32x4Eq: |
| 3383 return graph()->NewNode(jsgraph()->machine()->Float32x4Equal(), inputs[0], | 3400 return graph()->NewNode(jsgraph()->machine()->Float32x4Equal(), inputs[0], |
| 3384 inputs[1]); | 3401 inputs[1]); |
| 3385 case wasm::kExprF32x4Ne: | 3402 case wasm::kExprF32x4Ne: |
| 3386 return graph()->NewNode(jsgraph()->machine()->Float32x4NotEqual(), | 3403 return graph()->NewNode(jsgraph()->machine()->Float32x4NotEqual(), |
| 3387 inputs[0], inputs[1]); | 3404 inputs[0], inputs[1]); |
| 3388 case wasm::kExprI32x4Splat: | 3405 case wasm::kExprI32x4Splat: |
| 3389 return graph()->NewNode(jsgraph()->machine()->CreateInt32x4(), inputs[0], | 3406 return graph()->NewNode(jsgraph()->machine()->Int32x4Splat(), inputs[0]); |
| 3390 inputs[0], inputs[0], inputs[0]); | |
| 3391 case wasm::kExprI32x4SConvertF32x4: | 3407 case wasm::kExprI32x4SConvertF32x4: |
| 3392 return graph()->NewNode(jsgraph()->machine()->Int32x4FromFloat32x4(), | 3408 return graph()->NewNode(jsgraph()->machine()->Int32x4FromFloat32x4(), |
| 3393 inputs[0]); | 3409 inputs[0]); |
| 3394 case wasm::kExprI32x4UConvertF32x4: | 3410 case wasm::kExprI32x4UConvertF32x4: |
| 3395 return graph()->NewNode(jsgraph()->machine()->Uint32x4FromFloat32x4(), | 3411 return graph()->NewNode(jsgraph()->machine()->Uint32x4FromFloat32x4(), |
| 3396 inputs[0]); | 3412 inputs[0]); |
| 3397 case wasm::kExprI32x4Neg: | 3413 case wasm::kExprI32x4Neg: |
| 3398 return graph()->NewNode(jsgraph()->machine()->Int32x4Neg(), inputs[0]); | 3414 return graph()->NewNode(jsgraph()->machine()->Int32x4Neg(), inputs[0]); |
| 3399 case wasm::kExprI32x4Add: | 3415 case wasm::kExprI32x4Add: |
| 3400 return graph()->NewNode(jsgraph()->machine()->Int32x4Add(), inputs[0], | 3416 return graph()->NewNode(jsgraph()->machine()->Int32x4Add(), inputs[0], |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3443 jsgraph()->machine()->Uint32x4GreaterThanOrEqual(), inputs[1], | 3459 jsgraph()->machine()->Uint32x4GreaterThanOrEqual(), inputs[1], |
| 3444 inputs[0]); | 3460 inputs[0]); |
| 3445 case wasm::kExprI32x4GtU: | 3461 case wasm::kExprI32x4GtU: |
| 3446 return graph()->NewNode(jsgraph()->machine()->Uint32x4GreaterThan(), | 3462 return graph()->NewNode(jsgraph()->machine()->Uint32x4GreaterThan(), |
| 3447 inputs[0], inputs[1]); | 3463 inputs[0], inputs[1]); |
| 3448 case wasm::kExprI32x4GeU: | 3464 case wasm::kExprI32x4GeU: |
| 3449 return graph()->NewNode( | 3465 return graph()->NewNode( |
| 3450 jsgraph()->machine()->Uint32x4GreaterThanOrEqual(), inputs[0], | 3466 jsgraph()->machine()->Uint32x4GreaterThanOrEqual(), inputs[0], |
| 3451 inputs[1]); | 3467 inputs[1]); |
| 3452 case wasm::kExprI16x8Splat: | 3468 case wasm::kExprI16x8Splat: |
| 3453 return graph()->NewNode(jsgraph()->machine()->CreateInt16x8(), inputs[0], | 3469 return graph()->NewNode(jsgraph()->machine()->Int16x8Splat(), inputs[0]); |
| 3454 inputs[0], inputs[0], inputs[0], inputs[0], | |
| 3455 inputs[0], inputs[0], inputs[0]); | |
| 3456 case wasm::kExprI16x8Neg: | 3470 case wasm::kExprI16x8Neg: |
| 3457 return graph()->NewNode(jsgraph()->machine()->Int16x8Neg(), inputs[0]); | 3471 return graph()->NewNode(jsgraph()->machine()->Int16x8Neg(), inputs[0]); |
| 3458 case wasm::kExprI16x8Add: | 3472 case wasm::kExprI16x8Add: |
| 3459 return graph()->NewNode(jsgraph()->machine()->Int16x8Add(), inputs[0], | 3473 return graph()->NewNode(jsgraph()->machine()->Int16x8Add(), inputs[0], |
| 3460 inputs[1]); | 3474 inputs[1]); |
| 3461 case wasm::kExprI16x8AddSaturateS: | 3475 case wasm::kExprI16x8AddSaturateS: |
| 3462 return graph()->NewNode(jsgraph()->machine()->Int16x8AddSaturate(), | 3476 return graph()->NewNode(jsgraph()->machine()->Int16x8AddSaturate(), |
| 3463 inputs[0], inputs[1]); | 3477 inputs[0], inputs[1]); |
| 3464 case wasm::kExprI16x8Sub: | 3478 case wasm::kExprI16x8Sub: |
| 3465 return graph()->NewNode(jsgraph()->machine()->Int16x8Sub(), inputs[0], | 3479 return graph()->NewNode(jsgraph()->machine()->Int16x8Sub(), inputs[0], |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3514 jsgraph()->machine()->Uint16x8GreaterThanOrEqual(), inputs[1], | 3528 jsgraph()->machine()->Uint16x8GreaterThanOrEqual(), inputs[1], |
| 3515 inputs[0]); | 3529 inputs[0]); |
| 3516 case wasm::kExprI16x8GtU: | 3530 case wasm::kExprI16x8GtU: |
| 3517 return graph()->NewNode(jsgraph()->machine()->Uint16x8GreaterThan(), | 3531 return graph()->NewNode(jsgraph()->machine()->Uint16x8GreaterThan(), |
| 3518 inputs[0], inputs[1]); | 3532 inputs[0], inputs[1]); |
| 3519 case wasm::kExprI16x8GeU: | 3533 case wasm::kExprI16x8GeU: |
| 3520 return graph()->NewNode( | 3534 return graph()->NewNode( |
| 3521 jsgraph()->machine()->Uint16x8GreaterThanOrEqual(), inputs[0], | 3535 jsgraph()->machine()->Uint16x8GreaterThanOrEqual(), inputs[0], |
| 3522 inputs[1]); | 3536 inputs[1]); |
| 3523 case wasm::kExprI8x16Splat: | 3537 case wasm::kExprI8x16Splat: |
| 3524 return graph()->NewNode(jsgraph()->machine()->CreateInt8x16(), inputs[0], | 3538 return graph()->NewNode(jsgraph()->machine()->Int8x16Splat(), inputs[0]); |
| 3525 inputs[0], inputs[0], inputs[0], inputs[0], | |
| 3526 inputs[0], inputs[0], inputs[0], inputs[0], | |
| 3527 inputs[0], inputs[0], inputs[0], inputs[0], | |
| 3528 inputs[0], inputs[0], inputs[0]); | |
| 3529 case wasm::kExprI8x16Neg: | 3539 case wasm::kExprI8x16Neg: |
| 3530 return graph()->NewNode(jsgraph()->machine()->Int8x16Neg(), inputs[0]); | 3540 return graph()->NewNode(jsgraph()->machine()->Int8x16Neg(), inputs[0]); |
| 3531 case wasm::kExprI8x16Add: | 3541 case wasm::kExprI8x16Add: |
| 3532 return graph()->NewNode(jsgraph()->machine()->Int8x16Add(), inputs[0], | 3542 return graph()->NewNode(jsgraph()->machine()->Int8x16Add(), inputs[0], |
| 3533 inputs[1]); | 3543 inputs[1]); |
| 3534 case wasm::kExprI8x16AddSaturateS: | 3544 case wasm::kExprI8x16AddSaturateS: |
| 3535 return graph()->NewNode(jsgraph()->machine()->Int8x16AddSaturate(), | 3545 return graph()->NewNode(jsgraph()->machine()->Int8x16AddSaturate(), |
| 3536 inputs[0], inputs[1]); | 3546 inputs[0], inputs[1]); |
| 3537 case wasm::kExprI8x16Sub: | 3547 case wasm::kExprI8x16Sub: |
| 3538 return graph()->NewNode(jsgraph()->machine()->Int8x16Sub(), inputs[0], | 3548 return graph()->NewNode(jsgraph()->machine()->Int8x16Sub(), inputs[0], |
| (...skipping 608 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 4147 function_->code_start_offset), | 4157 function_->code_start_offset), |
| 4148 compile_ms); | 4158 compile_ms); |
| 4149 } | 4159 } |
| 4150 | 4160 |
| 4151 return code; | 4161 return code; |
| 4152 } | 4162 } |
| 4153 | 4163 |
| 4154 } // namespace compiler | 4164 } // namespace compiler |
| 4155 } // namespace internal | 4165 } // namespace internal |
| 4156 } // namespace v8 | 4166 } // namespace v8 |
| OLD | NEW |