v8
V8 is Google’s open source high-performance JavaScript and WebAssembly engine, written in C++.
Loading...
Searching...
No Matches
baseline-compiler-x64-inl.h
Go to the documentation of this file.
1// Use of this source code is governed by a BSD-style license that can be
2// Copyright 2021 the V8 project authors. All rights reserved.
3// found in the LICENSE file.
4
5#ifndef V8_BASELINE_X64_BASELINE_COMPILER_X64_INL_H_
6#define V8_BASELINE_X64_BASELINE_COMPILER_X64_INL_H_
7
8#include "src/base/macros.h"
11
12namespace v8 {
13namespace internal {
14namespace baseline {
15
16#define __ basm_.
17
18// A builtin call/jump mode that is used then short builtin calls feature is
19// not enabled.
22
26 int max_frame_size = bytecode_->max_frame_size();
30#ifdef V8_ENABLE_CET_SHADOW_STACK
31 __ MaybeEmitPlaceHolderForDeopt();
32#endif // V8_ENABLE_CET_SHADOW_STACK
33
35}
36
39 // Inlined register frame fill
40 interpreter::Register new_target_or_generator_register =
41 bytecode_->incoming_new_target_or_generator_register();
42 if (v8_flags.debug_code) {
44 handle(ReadOnlyRoots(local_isolate_).undefined_value(),
46 __ masm()->Assert(equal, AbortReason::kUnexpectedValue);
47 }
48 int register_count = bytecode_->register_count();
49 // Magic value
50 const int kLoopUnrollSize = 8;
51 const int new_target_index = new_target_or_generator_register.index();
52 const bool has_new_target = new_target_index != kMaxInt;
53 if (has_new_target) {
54 DCHECK_LE(new_target_index, register_count);
55 for (int i = 0; i < new_target_index; i++) {
57 }
58 // Push new_target_or_generator.
60 register_count -= new_target_index + 1;
61 }
62 if (register_count < 2 * kLoopUnrollSize) {
63 // If the frame is small enough, just unroll the frame fill completely.
64 for (int i = 0; i < register_count; ++i) {
66 }
67 } else {
68 // Extract the first few registers to round to the unroll size.
69 int first_registers = register_count % kLoopUnrollSize;
70 for (int i = 0; i < first_registers; ++i) {
72 }
73 BaselineAssembler::ScratchRegisterScope scope(&basm_);
74 Register scratch = scope.AcquireScratch();
75 __ Move(scratch, register_count / kLoopUnrollSize);
76 // We enter the loop unconditionally, so make sure we need to loop at least
77 // once.
78 DCHECK_GT(register_count / kLoopUnrollSize, 0);
79 Label loop;
80 __ Bind(&loop);
81 for (int i = 0; i < kLoopUnrollSize; ++i) {
83 }
84 __ masm()->decl(scratch);
85 __ masm()->j(greater, &loop);
86 }
87}
88
91 __ Move(kScratchRegister, rsp);
92 __ masm()->addq(kScratchRegister,
94 bytecode_->frame_size()));
95 __ masm()->cmpq(kScratchRegister, rbp);
96 __ masm()->Assert(equal, AbortReason::kUnexpectedStackPointer);
97}
98
99#undef __
100
101} // namespace baseline
102} // namespace internal
103} // namespace v8
104
105#endif // V8_BASELINE_X64_BASELINE_COMPILER_X64_INL_H_
#define ASM_CODE_COMMENT(asm)
Definition assembler.h:617
constexpr BuiltinCallJumpMode kFallbackBuiltinCallJumpModeForBaseline
V8_INLINE IndirectHandle< T > handle(Tagged< T > object, Isolate *isolate)
Definition handles-inl.h:72
constexpr Register kJavaScriptCallTargetRegister
constexpr Register kJavaScriptCallArgCountRegister
constexpr Register kInterpreterAccumulatorRegister
constexpr Register kScratchRegister
constexpr Register kContextRegister
V8_EXPORT_PRIVATE FlagValues v8_flags
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
#define DCHECK_GT(v1, v2)
Definition logging.h:487