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

Side by Side Diff: src/compiler/wasm-compiler.cc

Issue 2400863003: [wasm] Simd128 types should not be available in asmjs modules. (Closed)
Patch Set: Fix test Created 4 years, 2 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.h ('k') | src/wasm/ast-decoder.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/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 188 matching lines...) Expand 10 before | Expand all | Expand 10 after
199 switch (type) { 199 switch (type) {
200 case wasm::kAstI32: 200 case wasm::kAstI32:
201 return jsgraph()->Int32Constant(0xdeadbeef); 201 return jsgraph()->Int32Constant(0xdeadbeef);
202 case wasm::kAstI64: 202 case wasm::kAstI64:
203 return jsgraph()->Int64Constant(0xdeadbeefdeadbeef); 203 return jsgraph()->Int64Constant(0xdeadbeefdeadbeef);
204 case wasm::kAstF32: 204 case wasm::kAstF32:
205 return jsgraph()->Float32Constant(bit_cast<float>(0xdeadbeef)); 205 return jsgraph()->Float32Constant(bit_cast<float>(0xdeadbeef));
206 case wasm::kAstF64: 206 case wasm::kAstF64:
207 return jsgraph()->Float64Constant(bit_cast<double>(0xdeadbeefdeadbeef)); 207 return jsgraph()->Float64Constant(bit_cast<double>(0xdeadbeefdeadbeef));
208 break; 208 break;
209 case wasm::kAstS128:
210 return builder_->CreateS128Value(0xdeadbeef);
211 break;
209 default: 212 default:
210 UNREACHABLE(); 213 UNREACHABLE();
211 return nullptr; 214 return nullptr;
212 } 215 }
213 } 216 }
214 217
215 private: 218 private:
216 WasmGraphBuilder* builder_; 219 WasmGraphBuilder* builder_;
217 JSGraph* jsgraph_; 220 JSGraph* jsgraph_;
218 Graph* graph_; 221 Graph* graph_;
(...skipping 2069 matching lines...) Expand 10 before | Expand all | Expand 10 after
2288 Node* control = graph()->NewNode(common->Merge(2), if_smi, if_box); 2291 Node* control = graph()->NewNode(common->Merge(2), if_smi, if_box);
2289 value = graph()->NewNode(common->Phi(MachineRepresentation::kTagged, 2), vsmi, 2292 value = graph()->NewNode(common->Phi(MachineRepresentation::kTagged, 2), vsmi,
2290 vbox, control); 2293 vbox, control);
2291 return value; 2294 return value;
2292 } 2295 }
2293 2296
2294 Node* WasmGraphBuilder::ToJS(Node* node, wasm::LocalType type) { 2297 Node* WasmGraphBuilder::ToJS(Node* node, wasm::LocalType type) {
2295 switch (type) { 2298 switch (type) {
2296 case wasm::kAstI32: 2299 case wasm::kAstI32:
2297 return BuildChangeInt32ToTagged(node); 2300 return BuildChangeInt32ToTagged(node);
2301 case wasm::kAstS128:
2298 case wasm::kAstI64: 2302 case wasm::kAstI64:
2299 // Throw a TypeError. The native context is good enough here because we 2303 // Throw a TypeError. The native context is good enough here because we
2300 // only throw a TypeError. 2304 // only throw a TypeError.
2301 return BuildCallToRuntime(Runtime::kWasmThrowTypeError, jsgraph(), 2305 return BuildCallToRuntime(Runtime::kWasmThrowTypeError, jsgraph(),
2302 jsgraph()->isolate()->native_context(), nullptr, 2306 jsgraph()->isolate()->native_context(), nullptr,
2303 0, effect_, *control_); 2307 0, effect_, *control_);
2304 case wasm::kAstF32: 2308 case wasm::kAstF32:
2305 node = graph()->NewNode(jsgraph()->machine()->ChangeFloat32ToFloat64(), 2309 node = graph()->NewNode(jsgraph()->machine()->ChangeFloat32ToFloat64(),
2306 node); 2310 node);
2307 return BuildChangeFloat64ToTagged(node); 2311 return BuildChangeFloat64ToTagged(node);
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after
2450 // Change representation. 2454 // Change representation.
2451 SimplifiedOperatorBuilder simplified(jsgraph()->zone()); 2455 SimplifiedOperatorBuilder simplified(jsgraph()->zone());
2452 num = BuildChangeTaggedToFloat64(num); 2456 num = BuildChangeTaggedToFloat64(num);
2453 2457
2454 switch (type) { 2458 switch (type) {
2455 case wasm::kAstI32: { 2459 case wasm::kAstI32: {
2456 num = graph()->NewNode(jsgraph()->machine()->TruncateFloat64ToWord32(), 2460 num = graph()->NewNode(jsgraph()->machine()->TruncateFloat64ToWord32(),
2457 num); 2461 num);
2458 break; 2462 break;
2459 } 2463 }
2464 case wasm::kAstS128:
2460 case wasm::kAstI64: 2465 case wasm::kAstI64:
2461 // Throw a TypeError. The native context is good enough here because we 2466 // Throw a TypeError. The native context is good enough here because we
2462 // only throw a TypeError. 2467 // only throw a TypeError.
2463 return BuildCallToRuntime(Runtime::kWasmThrowTypeError, jsgraph(), 2468 return BuildCallToRuntime(Runtime::kWasmThrowTypeError, jsgraph(),
2464 jsgraph()->isolate()->native_context(), nullptr, 2469 jsgraph()->isolate()->native_context(), nullptr,
2465 0, effect_, *control_); 2470 0, effect_, *control_);
2466 case wasm::kAstF32: 2471 case wasm::kAstF32:
2467 num = graph()->NewNode(jsgraph()->machine()->TruncateFloat64ToFloat32(), 2472 num = graph()->NewNode(jsgraph()->machine()->TruncateFloat64ToFloat32(),
2468 num); 2473 num);
2469 break; 2474 break;
(...skipping 547 matching lines...) Expand 10 before | Expand all | Expand 10 after
3017 } 3022 }
3018 3023
3019 void WasmGraphBuilder::SetSourcePosition(Node* node, 3024 void WasmGraphBuilder::SetSourcePosition(Node* node,
3020 wasm::WasmCodePosition position) { 3025 wasm::WasmCodePosition position) {
3021 DCHECK_NE(position, wasm::kNoCodePosition); 3026 DCHECK_NE(position, wasm::kNoCodePosition);
3022 compiler::SourcePosition pos(position); 3027 compiler::SourcePosition pos(position);
3023 if (source_position_table_) 3028 if (source_position_table_)
3024 source_position_table_->SetSourcePosition(node, pos); 3029 source_position_table_->SetSourcePosition(node, pos);
3025 } 3030 }
3026 3031
3027 Node* WasmGraphBuilder::DefaultS128Value() { 3032 Node* WasmGraphBuilder::CreateS128Value(int32_t value) {
3028 // TODO(gdeepti): Introduce Simd128Constant to common-operator.h and use 3033 // TODO(gdeepti): Introduce Simd128Constant to common-operator.h and use
3029 // instead of creating a SIMD Value. 3034 // instead of creating a SIMD Value.
3030 return graph()->NewNode(jsgraph()->machine()->CreateInt32x4(), 3035 return graph()->NewNode(jsgraph()->machine()->CreateInt32x4(),
3031 Int32Constant(0), Int32Constant(0), Int32Constant(0), 3036 Int32Constant(value), Int32Constant(value),
3032 Int32Constant(0)); 3037 Int32Constant(value), Int32Constant(value));
3033 } 3038 }
3034 3039
3035 Node* WasmGraphBuilder::SimdOp(wasm::WasmOpcode opcode, 3040 Node* WasmGraphBuilder::SimdOp(wasm::WasmOpcode opcode,
3036 const NodeVector& inputs) { 3041 const NodeVector& inputs) {
3037 switch (opcode) { 3042 switch (opcode) {
3038 case wasm::kExprI32x4Splat: 3043 case wasm::kExprI32x4Splat:
3039 return graph()->NewNode(jsgraph()->machine()->CreateInt32x4(), inputs[0], 3044 return graph()->NewNode(jsgraph()->machine()->CreateInt32x4(), inputs[0],
3040 inputs[0], inputs[0], inputs[0]); 3045 inputs[0], inputs[0], inputs[0]);
3041 default: 3046 default:
3042 return graph()->NewNode(UnsupportedOpcode(opcode), nullptr); 3047 return graph()->NewNode(UnsupportedOpcode(opcode), nullptr);
(...skipping 359 matching lines...) Expand 10 before | Expand all | Expand 10 after
3402 function_->code_start_offset), 3407 function_->code_start_offset),
3403 compile_ms); 3408 compile_ms);
3404 } 3409 }
3405 3410
3406 return code; 3411 return code;
3407 } 3412 }
3408 3413
3409 } // namespace compiler 3414 } // namespace compiler
3410 } // namespace internal 3415 } // namespace internal
3411 } // namespace v8 3416 } // namespace v8
OLDNEW
« no previous file with comments | « src/compiler/wasm-compiler.h ('k') | src/wasm/ast-decoder.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698