11cb0ef41Sopenharmony_ci// Copyright 2021 the V8 project authors. All rights reserved.
21cb0ef41Sopenharmony_ci// Use of this source code is governed by a BSD-style license that can be
31cb0ef41Sopenharmony_ci// found in the LICENSE file.
41cb0ef41Sopenharmony_ci
51cb0ef41Sopenharmony_ci#ifndef V8_COMPILER_FAST_API_CALLS_H_
61cb0ef41Sopenharmony_ci#define V8_COMPILER_FAST_API_CALLS_H_
71cb0ef41Sopenharmony_ci
81cb0ef41Sopenharmony_ci#include "include/v8-fast-api-calls.h"
91cb0ef41Sopenharmony_ci#include "src/compiler/graph-assembler.h"
101cb0ef41Sopenharmony_ci
111cb0ef41Sopenharmony_cinamespace v8 {
121cb0ef41Sopenharmony_cinamespace internal {
131cb0ef41Sopenharmony_cinamespace compiler {
141cb0ef41Sopenharmony_cinamespace fast_api_call {
151cb0ef41Sopenharmony_ci
161cb0ef41Sopenharmony_cistruct OverloadsResolutionResult {
171cb0ef41Sopenharmony_ci  static OverloadsResolutionResult Invalid() {
181cb0ef41Sopenharmony_ci    return OverloadsResolutionResult(-1, CTypeInfo::Type::kVoid);
191cb0ef41Sopenharmony_ci  }
201cb0ef41Sopenharmony_ci
211cb0ef41Sopenharmony_ci  OverloadsResolutionResult(int distinguishable_arg_index_,
221cb0ef41Sopenharmony_ci                            CTypeInfo::Type element_type_)
231cb0ef41Sopenharmony_ci      : distinguishable_arg_index(distinguishable_arg_index_),
241cb0ef41Sopenharmony_ci        element_type(element_type_) {
251cb0ef41Sopenharmony_ci    DCHECK(distinguishable_arg_index_ < 0 ||
261cb0ef41Sopenharmony_ci           element_type_ != CTypeInfo::Type::kVoid);
271cb0ef41Sopenharmony_ci  }
281cb0ef41Sopenharmony_ci
291cb0ef41Sopenharmony_ci  bool is_valid() const { return distinguishable_arg_index >= 0; }
301cb0ef41Sopenharmony_ci
311cb0ef41Sopenharmony_ci  // The index of the distinguishable overload argument. Only the case where the
321cb0ef41Sopenharmony_ci  // types of this argument is a JSArray vs a TypedArray is supported.
331cb0ef41Sopenharmony_ci  int distinguishable_arg_index;
341cb0ef41Sopenharmony_ci
351cb0ef41Sopenharmony_ci  // The element type in the typed array argument.
361cb0ef41Sopenharmony_ci  CTypeInfo::Type element_type;
371cb0ef41Sopenharmony_ci};
381cb0ef41Sopenharmony_ci
391cb0ef41Sopenharmony_ciElementsKind GetTypedArrayElementsKind(CTypeInfo::Type type);
401cb0ef41Sopenharmony_ci
411cb0ef41Sopenharmony_ciOverloadsResolutionResult ResolveOverloads(
421cb0ef41Sopenharmony_ci    Zone* zone, const FastApiCallFunctionVector& candidates,
431cb0ef41Sopenharmony_ci    unsigned int arg_count);
441cb0ef41Sopenharmony_ci
451cb0ef41Sopenharmony_cibool CanOptimizeFastSignature(const CFunctionInfo* c_signature);
461cb0ef41Sopenharmony_ci
471cb0ef41Sopenharmony_ci}  // namespace fast_api_call
481cb0ef41Sopenharmony_ci}  // namespace compiler
491cb0ef41Sopenharmony_ci}  // namespace internal
501cb0ef41Sopenharmony_ci}  // namespace v8
511cb0ef41Sopenharmony_ci
521cb0ef41Sopenharmony_ci#endif  // V8_COMPILER_FAST_API_CALLS_H_
53