Commit 19dab886 authored by gdeepti's avatar gdeepti Committed by Commit bot

[wasm] Simd128 types should not be available in asmjs modules.

 - Added gating code in the module-decoder to allow SIMD code only when
 it can be decoded correctly
 - SIMD128 values should not be exported to JS
 - Try/Catch should not be available in asmjs modules
 - Trivial fixes for S128  values

BUG=chromium:648079

R=ahaas@chromium.org, titzer@chromium.org, bradnelson@chromium.org

Review-Url: https://codereview.chromium.org/2400863003
Cr-Commit-Position: refs/heads/master@{#40067}
parent a78c5ea5
......@@ -206,6 +206,9 @@ class WasmTrapHelper : public ZoneObject {
case wasm::kAstF64:
return jsgraph()->Float64Constant(bit_cast<double>(0xdeadbeefdeadbeef));
break;
case wasm::kAstS128:
return builder_->CreateS128Value(0xdeadbeef);
break;
default:
UNREACHABLE();
return nullptr;
......@@ -2295,6 +2298,7 @@ Node* WasmGraphBuilder::ToJS(Node* node, wasm::LocalType type) {
switch (type) {
case wasm::kAstI32:
return BuildChangeInt32ToTagged(node);
case wasm::kAstS128:
case wasm::kAstI64:
// Throw a TypeError. The native context is good enough here because we
// only throw a TypeError.
......@@ -2457,6 +2461,7 @@ Node* WasmGraphBuilder::FromJS(Node* node, Node* context,
num);
break;
}
case wasm::kAstS128:
case wasm::kAstI64:
// Throw a TypeError. The native context is good enough here because we
// only throw a TypeError.
......@@ -3024,12 +3029,12 @@ void WasmGraphBuilder::SetSourcePosition(Node* node,
source_position_table_->SetSourcePosition(node, pos);
}
Node* WasmGraphBuilder::DefaultS128Value() {
Node* WasmGraphBuilder::CreateS128Value(int32_t value) {
// TODO(gdeepti): Introduce Simd128Constant to common-operator.h and use
// instead of creating a SIMD Value.
return graph()->NewNode(jsgraph()->machine()->CreateInt32x4(),
Int32Constant(0), Int32Constant(0), Int32Constant(0),
Int32Constant(0));
Int32Constant(value), Int32Constant(value),
Int32Constant(value), Int32Constant(value));
}
Node* WasmGraphBuilder::SimdOp(wasm::WasmOpcode opcode,
......
......@@ -198,7 +198,7 @@ class WasmGraphBuilder {
void SetSourcePosition(Node* node, wasm::WasmCodePosition position);
Node* DefaultS128Value();
Node* CreateS128Value(int32_t value);
Node* SimdOp(wasm::WasmOpcode opcode, const NodeVector& inputs);
Node* SimdExtractLane(wasm::WasmOpcode opcode, uint8_t lane, Node* input);
......
......@@ -32,6 +32,9 @@ namespace wasm {
#endif
#define CHECK_PROTOTYPE_OPCODE(flag) \
if (module_ && module_->origin == kAsmJsOrigin) { \
error("Opcode not supported for asmjs modules"); \
} \
if (!FLAG_##flag) { \
error("Invalid opcode (enable with --" #flag ")"); \
break; \
......@@ -500,7 +503,7 @@ class WasmFullDecoder : public WasmDecoder {
case kAstF64:
return builder_->Float64Constant(0);
case kAstS128:
return builder_->DefaultS128Value();
return builder_->CreateS128Value(0);
default:
UNREACHABLE();
return nullptr;
......
......@@ -156,6 +156,9 @@ struct BlockTypeOperand {
case kLocalF64:
*result = kAstF64;
return true;
case kLocalS128:
*result = kAstS128;
return true;
default:
*result = kAstStmt;
return false;
......
......@@ -6,6 +6,7 @@
#include "src/base/functional.h"
#include "src/base/platform/platform.h"
#include "src/flags.h"
#include "src/macro-assembler.h"
#include "src/objects.h"
#include "src/v8.h"
......@@ -932,7 +933,12 @@ class ModuleDecoder : public Decoder {
case kLocalF64:
return kAstF64;
case kLocalS128:
return kAstS128;
if (origin_ != kAsmJsOrigin && FLAG_wasm_simd_prototype) {
return kAstS128;
} else {
error(pc_ - 1, "invalid local type");
return kAstStmt;
}
default:
error(pc_ - 1, "invalid local type");
return kAstStmt;
......
This diff is collapsed.
......@@ -82,6 +82,7 @@ var kAstI32 = 1;
var kAstI64 = 2;
var kAstF32 = 3;
var kAstF64 = 4;
var kAstS128 = 5;
var kExternalFunction = 0;
var kExternalTable = 1;
......@@ -106,6 +107,7 @@ var kSig_v_iii = makeSig([kAstI32, kAstI32, kAstI32], []);
var kSig_v_d = makeSig([kAstF64], []);
var kSig_v_dd = makeSig([kAstF64, kAstF64], []);
var kSig_v_ddi = makeSig([kAstF64, kAstF64, kAstI32], []);
var kSig_s_v = makeSig([], [kAstS128]);
function makeSig(params, results) {
return {params: params, results: results};
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment