v8
V8 is Google’s open source high-performance JavaScript and WebAssembly engine, written in C++.
Loading...
Searching...
No Matches
encoded-c-signature.h
Go to the documentation of this file.
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#ifndef V8_EXECUTION_ENCODED_C_SIGNATURE_H_
6#define V8_EXECUTION_ENCODED_C_SIGNATURE_H_
7
8#include <stdint.h>
9
10namespace v8 {
11class CFunctionInfo;
12
13namespace internal {
14
15namespace compiler {
16class CallDescriptor;
17} // namespace compiler
18
19// This structure represents whether the parameters for a given function
20// should be read from general purpose or FP registers. parameter_count =
21// kInvalidParamCount represents "invalid" signature, a placeholder for
22// non-existing elements in the mapping.
24 public:
25 EncodedCSignature() = default;
26 EncodedCSignature(uint32_t bitfield, int parameter_count)
30 explicit EncodedCSignature(const CFunctionInfo* signature);
31
32 bool IsFloat(int index) const {
33 return (bitfield_ & (static_cast<uint32_t>(1) << index)) != 0;
34 }
35 bool IsReturnFloat() const { return IsFloat(kReturnIndex); }
36#ifdef V8_TARGET_ARCH_RISCV64
37 bool IsReturnFloat64() const {
38 return IsFloat(kReturnIndex) && return_type_is_float64_;
39 }
40#endif
41 void SetFloat(int index) { bitfield_ |= (static_cast<uint32_t>(1) << index); }
42
45#ifdef V8_TARGET_ARCH_RISCV64
46 return_type_is_float64_ = true;
47#endif
48 }
51#ifdef V8_TARGET_ARCH_RISCV64
52 return_type_is_float64_ = false;
53#endif
54 }
55
56 bool IsValid() const { return parameter_count_ < kInvalidParamCount; }
57
58 int ParameterCount() const { return parameter_count_; }
59 int FPParameterCount() const;
60
61 static const EncodedCSignature& Invalid() {
63 return kInvalid;
64 }
65
66 static const int kReturnIndex = 31;
67 static const int kInvalidParamCount = kReturnIndex + 1;
68
69 private:
70 // Bit i is set if floating point, unset if not.
71 uint32_t bitfield_ = 0;
72#ifdef V8_TARGET_ARCH_RISCV64
73 // Indicates whether the return type for functions is float64,
74 // RISC-V need NaNboxing float32 return value in simulator.
75 bool return_type_is_float64_ = false;
76#endif // V8_TARGET_ARCH_RISCV64
78};
79
80} // namespace internal
81} // namespace v8
82
83#endif // V8_EXECUTION_ENCODED_C_SIGNATURE_H_
int16_t parameter_count
Definition builtins.cc:67
static const EncodedCSignature & Invalid()
EncodedCSignature(uint32_t bitfield, int parameter_count)