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_COMPILER_FAST_API_CALLS_H_ 6#define V8_COMPILER_FAST_API_CALLS_H_ 7 8#include "include/v8-fast-api-calls.h" 9#include "src/compiler/graph-assembler.h" 10 11namespace v8 { 12namespace internal { 13namespace compiler { 14namespace fast_api_call { 15 16struct OverloadsResolutionResult { 17 static OverloadsResolutionResult Invalid() { 18 return OverloadsResolutionResult(-1, CTypeInfo::Type::kVoid); 19 } 20 21 OverloadsResolutionResult(int distinguishable_arg_index_, 22 CTypeInfo::Type element_type_) 23 : distinguishable_arg_index(distinguishable_arg_index_), 24 element_type(element_type_) { 25 DCHECK(distinguishable_arg_index_ < 0 || 26 element_type_ != CTypeInfo::Type::kVoid); 27 } 28 29 bool is_valid() const { return distinguishable_arg_index >= 0; } 30 31 // The index of the distinguishable overload argument. Only the case where the 32 // types of this argument is a JSArray vs a TypedArray is supported. 33 int distinguishable_arg_index; 34 35 // The element type in the typed array argument. 36 CTypeInfo::Type element_type; 37}; 38 39ElementsKind GetTypedArrayElementsKind(CTypeInfo::Type type); 40 41OverloadsResolutionResult ResolveOverloads( 42 Zone* zone, const FastApiCallFunctionVector& candidates, 43 unsigned int arg_count); 44 45bool CanOptimizeFastSignature(const CFunctionInfo* c_signature); 46 47} // namespace fast_api_call 48} // namespace compiler 49} // namespace internal 50} // namespace v8 51 52#endif // V8_COMPILER_FAST_API_CALLS_H_ 53