value-type.cc 828 Bytes
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12
// Copyright 2021 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "src/wasm/value-type.h"

#include "src/codegen/signature.h"

namespace v8 {
namespace internal {
namespace wasm {

13
base::Optional<wasm::ValueKind> WasmReturnTypeFromSignature(
14 15 16 17 18 19 20
    const FunctionSig* wasm_signature) {
  if (wasm_signature->return_count() == 0) {
    return {};
  } else {
    DCHECK_EQ(wasm_signature->return_count(), 1);
    ValueType return_type = wasm_signature->GetReturn(0);
    switch (return_type.kind()) {
21 22 23 24
      case kI32:
      case kI64:
      case kF32:
      case kF64:
25 26 27 28 29 30 31 32 33 34
        return {return_type.kind()};
      default:
        UNREACHABLE();
    }
  }
}

}  // namespace wasm
}  // namespace internal
}  // namespace v8