• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright 2021 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 
5 #include "src/wasm/value-type.h"
6 
7 #include "src/codegen/signature.h"
8 
9 namespace v8 {
10 namespace internal {
11 namespace wasm {
12 
WasmReturnTypeFromSignature(const FunctionSig * wasm_signature)13 base::Optional<wasm::ValueKind> WasmReturnTypeFromSignature(
14     const FunctionSig* wasm_signature) {
15   if (wasm_signature->return_count() == 0) {
16     return {};
17   } else {
18     DCHECK_EQ(wasm_signature->return_count(), 1);
19     ValueType return_type = wasm_signature->GetReturn(0);
20     switch (return_type.kind()) {
21       case kI32:
22       case kI64:
23       case kF32:
24       case kF64:
25         return {return_type.kind()};
26       default:
27         UNREACHABLE();
28     }
29   }
30 }
31 
32 }  // namespace wasm
33 }  // namespace internal
34 }  // namespace v8
35