summaryrefslogtreecommitdiff
path: root/deps/v8/src/compiler/wasm-call-descriptors.h
blob: 8f3fcdcbc8e573666e24d0a7868d7e5962721372 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
// Copyright 2022 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.

#if !V8_ENABLE_WEBASSEMBLY
#error This header should only be included if WebAssembly is enabled.
#endif  // !V8_ENABLE_WEBASSEMBLY

#ifndef V8_COMPILER_WASM_CALL_DESCRIPTORS_H_
#define V8_COMPILER_WASM_CALL_DESCRIPTORS_H_

#include <memory>

#include "src/common/globals.h"

namespace v8::internal {

class AccountingAllocator;
class Zone;

namespace compiler {
class CallDescriptor;

class WasmCallDescriptors {
 public:
  explicit WasmCallDescriptors(AccountingAllocator* allocator);

  compiler::CallDescriptor* GetI64ToBigIntDescriptor(StubCallMode mode) {
    return i64_to_bigint_descriptors_[static_cast<size_t>(mode)];
  }
  compiler::CallDescriptor* GetBigIntToI64Descriptor(StubCallMode mode,
                                                     bool needs_frame_state) {
    if (needs_frame_state) {
      DCHECK_EQ(mode, StubCallMode::kCallBuiltinPointer);
      return bigint_to_i64_descriptor_with_framestate_;
    }
    return bigint_to_i64_descriptors_[static_cast<size_t>(mode)];
  }

#if V8_TARGET_ARCH_32_BIT
  V8_EXPORT_PRIVATE compiler::CallDescriptor* GetLoweredCallDescriptor(
      const compiler::CallDescriptor* original);
#endif  // V8_TARGET_ARCH_32_BIT

 private:
  static_assert(static_cast<int>(StubCallMode::kCallCodeObject) == 0);
  static_assert(static_cast<int>(StubCallMode::kCallWasmRuntimeStub) == 1);
  static_assert(static_cast<int>(StubCallMode::kCallBuiltinPointer) == 2);
  static constexpr int kNumCallModes = 3;

  std::unique_ptr<Zone> zone_;

  compiler::CallDescriptor* i64_to_bigint_descriptors_[kNumCallModes];
  compiler::CallDescriptor* bigint_to_i64_descriptors_[kNumCallModes];
  compiler::CallDescriptor* bigint_to_i64_descriptor_with_framestate_;

#if V8_TARGET_ARCH_32_BIT
  compiler::CallDescriptor* i32pair_to_bigint_descriptors_[kNumCallModes];
  compiler::CallDescriptor* bigint_to_i32pair_descriptors_[kNumCallModes];
  compiler::CallDescriptor* bigint_to_i32pair_descriptor_with_framestate_;
#endif  // V8_TARGET_ARCH_32_BIT
};

}  // namespace compiler
}  // namespace v8::internal

#endif  // V8_COMPILER_WASM_CALL_DESCRIPTORS_H_