v8
V8 is Google’s open source high-performance JavaScript and WebAssembly engine, written in C++.
Loading...
Searching...
No Matches
js-generic-lowering-reducer.h
Go to the documentation of this file.
1// Copyright 2024 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_TURBOSHAFT_JS_GENERIC_LOWERING_REDUCER_H_
6#define V8_COMPILER_TURBOSHAFT_JS_GENERIC_LOWERING_REDUCER_H_
7
12
14
16
17// JSGenericLowering lowers JS operators to generic builtin calls (possibly with
18// some small inlined fast paths).
19//
20// It should run after SimplifiedLowering, which should have already replaced
21// most of the JS operations with lower levels (Simplified or Machine) more
22// specialized operations. However, SimplifiedLowering won't be able to remove
23// all JS operators; the remaining JS operations will thus be replaced by
24// builtin calls here in JSGenericLowering.
25
26template <class Next>
27class JSGenericLoweringReducer : public Next {
28 public:
30
32 V<FrameState> frame_state, V<Context> context,
33 GenericBinopOp::Kind kind,
34 LazyDeoptOnThrow lazy_deopt_on_throw) {
35 // Note that we're **not** calling the __WithFeedback variants of the
36 // generic builtins, on purpose. There have been several experiments with
37 // this in the past, and we always concluded that it wasn't worth it. The
38 // latest experiment was ended with this commit:
39 // https://crrev.com/c/4110858.
40 switch (kind) {
41#define CASE(Name) \
42 case GenericBinopOp::Kind::k##Name: \
43 return __ CallBuiltin_##Name(isolate_, frame_state, context, left, right, \
44 lazy_deopt_on_throw);
46#undef CASE
47 }
48 }
49
52 LazyDeoptOnThrow lazy_deopt_on_throw) {
53 switch (kind) {
54#define CASE(Name) \
55 case GenericUnopOp::Kind::k##Name: \
56 return __ CallBuiltin_##Name(isolate_, frame_state, context, input, \
57 lazy_deopt_on_throw);
59#undef CASE
60 }
61 }
62
65 LazyDeoptOnThrow lazy_deopt_on_throw) {
66 Label<Object> done(this);
67 // Avoid builtin call for Smis and HeapNumbers.
68 GOTO_IF(__ ObjectIs(input, ObjectIsOp::Kind::kNumber,
70 done, input);
71 switch (kind) {
73 GOTO(done, __ CallBuiltin_ToNumber(isolate_, frame_state, context,
74 input, lazy_deopt_on_throw));
75 break;
77 GOTO(done, __ CallBuiltin_ToNumeric(isolate_, frame_state, context,
78 input, lazy_deopt_on_throw));
79 break;
80 }
81 BIND(done, result);
82 return result;
83 }
84
85 private:
87};
88
90
91} // namespace v8::internal::compiler::turboshaft
92
93#endif // V8_COMPILER_TURBOSHAFT_JS_GENERIC_LOWERING_REDUCER_H_
#define BIND(label)
#define REDUCE(operation)
#define GOTO(label,...)
#define GOTO_IF(cond, label,...)
union v8::internal::@341::BuiltinMetadata::KindSpecificData data
Builtins::Kind kind
Definition builtins.cc:40
V< Object > REDUCE GenericBinop(V< Object > left, V< Object > right, V< FrameState > frame_state, V< Context > context, GenericBinopOp::Kind kind, LazyDeoptOnThrow lazy_deopt_on_throw)
OpIndex REDUCE ToNumberOrNumeric(V< Object > input, V< FrameState > frame_state, V< Context > context, Object::Conversion kind, LazyDeoptOnThrow lazy_deopt_on_throw)
V< Object > REDUCE GenericUnop(V< Object > input, V< FrameState > frame_state, V< Context > context, GenericUnopOp::Kind kind, LazyDeoptOnThrow lazy_deopt_on_throw)
#define TURBOSHAFT_REDUCER_BOILERPLATE(Name)
Definition assembler.h:823
Isolate * isolate
TNode< Context > context
ZoneVector< RpoNumber > & result
#define GENERIC_BINOP_LIST(V)
#define GENERIC_UNOP_LIST(V)