Commit 5eca0acc authored by kschimpf's avatar kschimpf Committed by Commit Bot

[wasm] Clean up float to integer conversions

Cleans up the implementation of trapping/saturating operations to
use existing models of types, instead of defining new ones. That is,
it uses MachineType to represent the kind of integer/float value the
conversion is operating on.

It also removes the need to define NumericImplementation by using
the actual opcodes to determine if the instruction is trapping or
saturating.

Finally, it now defines a single method to implement the truncating
(that doesn't use a ccall) conversions. The previous code had two
methods, one for I32 and one for I64.

Bug: v8:7226
Change-Id: Ia869416c8bd1abe76d0583c28a3105102d130b46
Reviewed-on: https://chromium-review.googlesource.com/900558
Commit-Queue: Karl Schimpf <kschimpf@chromium.org>
Reviewed-by: 's avatarClemens Hammacher <clemensh@chromium.org>
Cr-Commit-Position: refs/heads/master@{#51129}
parent ec434d67
This diff is collapsed.
...@@ -255,16 +255,6 @@ typedef ZoneVector<Node*> NodeVector; ...@@ -255,16 +255,6 @@ typedef ZoneVector<Node*> NodeVector;
class WasmGraphBuilder { class WasmGraphBuilder {
public: public:
enum EnforceBoundsCheck : bool { kNeedsBoundsCheck, kCanOmitBoundsCheck }; enum EnforceBoundsCheck : bool { kNeedsBoundsCheck, kCanOmitBoundsCheck };
enum class Type {
kInt8s,
kInt8u,
kInt32s,
kInt32u,
kInt64s,
kInt64u,
kFloat32,
kFloat64
};
WasmGraphBuilder(ModuleEnv* env, Zone* zone, JSGraph* graph, WasmGraphBuilder(ModuleEnv* env, Zone* zone, JSGraph* graph,
Handle<Code> centry_stub, wasm::FunctionSig* sig, Handle<Code> centry_stub, wasm::FunctionSig* sig,
...@@ -459,9 +449,10 @@ class WasmGraphBuilder { ...@@ -459,9 +449,10 @@ class WasmGraphBuilder {
bool use_trap_handler() const { return env_ && env_->use_trap_handler; } bool use_trap_handler() const { return env_ && env_->use_trap_handler; }
private: JSGraph* jsgraph() { return jsgraph_; }
enum class NumericImplementation : uint8_t { kTrap, kSaturate }; Graph* graph();
private:
static const int kDefaultBufferSize = 16; static const int kDefaultBufferSize = 16;
Zone* const zone_; Zone* const zone_;
...@@ -496,10 +487,6 @@ class WasmGraphBuilder { ...@@ -496,10 +487,6 @@ class WasmGraphBuilder {
compiler::SourcePositionTable* const source_position_table_ = nullptr; compiler::SourcePositionTable* const source_position_table_ = nullptr;
// Internal helper methods.
JSGraph* jsgraph() { return jsgraph_; }
Graph* graph();
Node* String(const char* string); Node* String(const char* string);
Node* MemBuffer(uint32_t offset); Node* MemBuffer(uint32_t offset);
// BoundsCheckMem receives a uint32 {index} node and returns a ptrsize index. // BoundsCheckMem receives a uint32 {index} node and returns a ptrsize index.
...@@ -524,18 +511,8 @@ class WasmGraphBuilder { ...@@ -524,18 +511,8 @@ class WasmGraphBuilder {
Node* BuildF32CopySign(Node* left, Node* right); Node* BuildF32CopySign(Node* left, Node* right);
Node* BuildF64CopySign(Node* left, Node* right); Node* BuildF64CopySign(Node* left, Node* right);
Node* BuildI32ConvertFloat(Node* input, wasm::WasmCodePosition position, Node* BuildIntConvertFloat(Node* input, wasm::WasmCodePosition position,
NumericImplementation impl, Type int_type, wasm::WasmOpcode);
Type float_type, const Operator* conv_op,
const wasm::WasmOpcode check_op);
Node* BuildI32SConvertF32(Node* input, wasm::WasmCodePosition position,
NumericImplementation impl);
Node* BuildI32SConvertF64(Node* input, wasm::WasmCodePosition position,
NumericImplementation impl);
Node* BuildI32UConvertF32(Node* input, wasm::WasmCodePosition position,
NumericImplementation impl);
Node* BuildI32UConvertF64(Node* input, wasm::WasmCodePosition position,
NumericImplementation impl);
Node* BuildI32Ctz(Node* input); Node* BuildI32Ctz(Node* input);
Node* BuildI32Popcnt(Node* input); Node* BuildI32Popcnt(Node* input);
Node* BuildI64Ctz(Node* input); Node* BuildI64Ctz(Node* input);
...@@ -574,15 +551,8 @@ class WasmGraphBuilder { ...@@ -574,15 +551,8 @@ class WasmGraphBuilder {
Node* input, ExternalReference ref, Node* input, ExternalReference ref,
MachineRepresentation parameter_representation, MachineRepresentation parameter_representation,
const MachineType result_type, wasm::WasmCodePosition position); const MachineType result_type, wasm::WasmCodePosition position);
Node* BuildI64CcallConvertFloat(Node* input, wasm::WasmCodePosition position, Node* BuildCcallConvertFloat(Node* input, wasm::WasmCodePosition position,
NumericImplementation impl, Type int_type, wasm::WasmOpcode opcode);
Type float_type, ExternalReference call_ref);
Node* BuildI64TruncConvertFloat(Node* input, wasm::WasmCodePosition position,
NumericImplementation impl, Type int_type,
Type float_type, const Operator* trunc_op);
Node* BuildI64SConvertF32(Node* input, wasm::WasmCodePosition position,
NumericImplementation impl);
Node* BuildI64UConvertF32(Node* input, wasm::WasmCodePosition position); Node* BuildI64UConvertF32(Node* input, wasm::WasmCodePosition position);
Node* BuildI64SConvertF64(Node* input, wasm::WasmCodePosition position); Node* BuildI64SConvertF64(Node* input, wasm::WasmCodePosition position);
Node* BuildI64UConvertF64(Node* input, wasm::WasmCodePosition position); Node* BuildI64UConvertF64(Node* input, wasm::WasmCodePosition position);
......
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