v8
V8 is Google’s open source high-performance JavaScript and WebAssembly engine, written in C++.
Loading...
Searching...
No Matches
frame.cc
Go to the documentation of this file.
1// Copyright 2015 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
6
7namespace v8 {
8namespace internal {
9namespace compiler {
10
11Frame::Frame(int fixed_frame_size_in_slots, Zone* zone)
12 : fixed_slot_count_(fixed_frame_size_in_slots),
13 allocated_registers_(nullptr),
14 allocated_double_registers_(nullptr),
15 zone_(zone) {
16 slot_allocator_.AllocateUnaligned(fixed_frame_size_in_slots);
17}
18
19void Frame::AlignFrame(int alignment) {
20#if DEBUG
21 spill_slots_finished_ = true;
22 frame_aligned_ = true;
23#endif
24 // In the calculations below we assume that alignment is a power of 2.
26 int alignment_in_slots = AlignedSlotAllocator::NumSlotsForWidth(alignment);
27
28 // We have to align return slots separately, because they are claimed
29 // separately on the stack.
30 const int mask = alignment_in_slots - 1;
31 int return_delta = alignment_in_slots - (return_slot_count_ & mask);
32 if (return_delta != alignment_in_slots) {
33 return_slot_count_ += return_delta;
34 }
35 int delta = alignment_in_slots - (slot_allocator_.Size() & mask);
36 if (delta != alignment_in_slots) {
37 slot_allocator_.Align(alignment_in_slots);
38 if (spill_slot_count_ != 0) {
39 spill_slot_count_ += delta;
40 }
41 }
42}
43
48
52
60
62 const int frame_offset = FrameSlotToFPOffset(spill_slot);
64 return FrameOffset::FromFramePointer(frame_offset);
65 } else {
66 // No frame. Retrieve all parameters relative to stack pointer.
67 int sp_offset = frame_offset + GetSPToFPOffset();
68 DCHECK_GE(sp_offset, 0);
69 return FrameOffset::FromStackPointer(sp_offset);
70 }
71}
72
73} // namespace compiler
74} // namespace internal
75} // namespace v8
std::vector< Register * > allocated_registers_
V8_EXPORT_PRIVATE void MarkHasFrame(bool state)
Definition frame.cc:44
FrameOffset GetFrameOffset(int spill_slot) const
Definition frame.cc:61
static FrameOffset FromFramePointer(int offset)
Definition frame.h:219
static FrameOffset FromStackPointer(int offset)
Definition frame.h:214
void AlignFrame(int alignment=kDoubleSize)
Definition frame.cc:19
Frame(int fixed_frame_size_in_slots, Zone *zone)
Definition frame.cc:11
AlignedSlotAllocator slot_allocator_
Definition frame.h:196
Zone * zone_
LiftoffAssembler::CacheState state
uint32_t const mask
constexpr bool IsPowerOfTwo(T value)
Definition bits.h:187
static int FrameSlotToFPOffset(int slot)
#define DCHECK_GE(v1, v2)
Definition logging.h:488
#define DCHECK(condition)
Definition logging.h:482