v8
V8 is Google’s open source high-performance JavaScript and WebAssembly engine, written in C++.
Loading...
Searching...
No Matches
call-optimization.h
Go to the documentation of this file.
1// Copyright 2014 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_IC_CALL_OPTIMIZATION_H_
6#define V8_IC_CALL_OPTIMIZATION_H_
7
8#include <optional>
9
11#include "src/objects/objects.h"
12
13namespace v8 {
14namespace internal {
15
16// Holds information about possible function call optimizations.
18 public:
19 template <class IsolateT>
20 CallOptimization(IsolateT* isolate, Handle<Object> function);
21
22 // Gets accessor context by given holder map via holder's constructor.
23 // If the holder is a remote object returns empty optional.
24 // This method must not be called for holder maps with null constructor
25 // because they can't be holders for lazy accessor pairs anyway.
26 std::optional<Tagged<NativeContext>> GetAccessorContext(
27 Tagged<Map> holder_map) const;
28
29 // Return true if the accessor context for given holder doesn't match
30 // given native context of if the holder is a remote object.
32 Tagged<Map> holder_map) const;
33
34 bool is_constant_call() const { return !constant_function_.is_null(); }
37 return !expected_receiver_type_.is_null();
38 }
39
44
45 bool is_simple_api_call() const { return is_simple_api_call_; }
46
51
56
58
59 template <class IsolateT>
61 IsolateT* isolate, DirectHandle<Map> receiver_map,
62 HolderLookup* holder_lookup) const;
63
65 Handle<JSObject> holder, HolderLookup) const;
66
67 private:
68 template <class IsolateT>
69 void Initialize(IsolateT* isolate, Handle<JSFunction> function);
70 template <class IsolateT>
71 void Initialize(IsolateT* isolate,
72 Handle<FunctionTemplateInfo> function_template_info);
73
74 // Determines whether the given function can be called using the
75 // fast api call builtin.
76 template <class IsolateT>
77 void AnalyzePossibleApiFunction(IsolateT* isolate,
79
83
84 // TODO(gsathya): Change these to be a bitfield and do a single fast check
85 // rather than two checks.
86 bool is_simple_api_call_ = false;
88};
89
90} // namespace internal
91} // namespace v8
92
93#endif // V8_IC_CALL_OPTIMIZATION_H_
Handle< FunctionTemplateInfo > api_call_info_
std::optional< Tagged< NativeContext > > GetAccessorContext(Tagged< Map > holder_map) const
void Initialize(IsolateT *isolate, Handle< JSFunction > function)
Handle< FunctionTemplateInfo > expected_receiver_type_
DirectHandle< JSFunction > constant_function() const
bool IsCrossContextLazyAccessorPair(Tagged< NativeContext > native_context, Tagged< Map > holder_map) const
CallOptimization(IsolateT *isolate, Handle< Object > function)
bool IsCompatibleReceiverMap(DirectHandle< JSObject > api_holder, Handle< JSObject > holder, HolderLookup) const
Handle< JSFunction > constant_function_
DirectHandle< FunctionTemplateInfo > api_call_info() const
Handle< JSObject > LookupHolderOfExpectedType(IsolateT *isolate, DirectHandle< Map > receiver_map, HolderLookup *holder_lookup) const
DirectHandle< FunctionTemplateInfo > expected_receiver_type() const
void AnalyzePossibleApiFunction(IsolateT *isolate, DirectHandle< JSFunction > function)
!IsContextMap !IsContextMap native_context
Definition map-inl.h:877
#define DCHECK(condition)
Definition logging.h:482