v8
V8 is Google’s open source high-performance JavaScript and WebAssembly engine, written in C++.
Loading...
Searching...
No Matches
baseline-compiler-riscv-inl.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_BASELINE_RISCV_BASELINE_COMPILER_RISCV_INL_H_
6#define V8_BASELINE_RISCV_BASELINE_COMPILER_RISCV_INL_H_
7
9
10namespace v8 {
11namespace internal {
12namespace baseline {
13
14// A builtin call/jump mode that is used then short builtin calls feature is
15// not enabled.
18
19#define __ basm_.
20
23 // Enter the frame here, since CallBuiltin will override lr.
24 __ masm()->EnterFrame(StackFrame::BASELINE);
26 int max_frame_size = bytecode_->max_frame_size();
31}
32
35 // Inlined register frame fill
36 interpreter::Register new_target_or_generator_register =
37 bytecode_->incoming_new_target_or_generator_register();
38 __ LoadRoot(kInterpreterAccumulatorRegister, RootIndex::kUndefinedValue);
39 int register_count = bytecode_->register_count();
40 // Magic value
41 const int kLoopUnrollSize = 8;
42 const int new_target_index = new_target_or_generator_register.index();
43 const bool has_new_target = new_target_index != kMaxInt;
44 if (has_new_target) {
45 DCHECK_LE(new_target_index, register_count);
46 __ masm()->AddWord(sp, sp,
47 Operand(-(kSystemPointerSize * new_target_index)));
48 for (int i = 0; i < new_target_index; i++) {
49 __ masm()->StoreWord(kInterpreterAccumulatorRegister,
51 }
52 // Push new_target_or_generator.
54 register_count -= new_target_index + 1;
55 }
56 if (register_count < 2 * kLoopUnrollSize) {
57 // If the frame is small enough, just unroll the frame fill completely.
58 __ masm()->AddWord(sp, sp, Operand(-(kSystemPointerSize * register_count)));
59 for (int i = 0; i < register_count; ++i) {
60 __ masm()->StoreWord(kInterpreterAccumulatorRegister,
62 }
63 } else {
64 __ masm()->AddWord(sp, sp, Operand(-(kSystemPointerSize * register_count)));
65 for (int i = 0; i < register_count; ++i) {
66 __ masm()->StoreWord(kInterpreterAccumulatorRegister,
68 }
69 }
70}
71
74 __ masm()->AddWord(t0, sp,
76 bytecode_->frame_size()));
77 __ masm()->Assert(eq, AbortReason::kUnexpectedStackPointer, t0, Operand(fp));
78}
79
80#undef __
81
82} // namespace baseline
83} // namespace internal
84} // namespace v8
85
86#endif // V8_BASELINE_RISCV_BASELINE_COMPILER_RISCV_INL_H_
#define ASM_CODE_COMMENT(asm)
Definition assembler.h:617
constexpr BuiltinCallJumpMode kFallbackBuiltinCallJumpModeForBaseline
constexpr Register kJavaScriptCallTargetRegister
constexpr Register kJavaScriptCallArgCountRegister
constexpr Register kInterpreterAccumulatorRegister
constexpr int kSystemPointerSize
Definition globals.h:410
constexpr Register kContextRegister
constexpr int kMaxInt
Definition globals.h:374
constexpr Register kJavaScriptCallNewTargetRegister
constexpr Register kJSFunctionRegister
#define DCHECK_LE(v1, v2)
Definition logging.h:490
#define DCHECK_EQ(v1, v2)
Definition logging.h:485