V8 API Reference, 7.2.502.16 (for Deno 0.2.4)
frame.cc
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 
5 #include "src/compiler/frame.h"
6 
7 #include "src/compiler/linkage.h"
8 #include "src/macro-assembler.h"
9 
10 namespace v8 {
11 namespace internal {
12 namespace compiler {
13 
14 Frame::Frame(int fixed_frame_size_in_slots)
15  : fixed_slot_count_(fixed_frame_size_in_slots),
16  frame_slot_count_(fixed_frame_size_in_slots),
17  spill_slot_count_(0),
18  return_slot_count_(0),
19  allocated_registers_(nullptr),
20  allocated_double_registers_(nullptr) {}
21 
22 int Frame::AlignFrame(int alignment) {
23  int alignment_slots = alignment / kPointerSize;
24  // We have to align return slots separately, because they are claimed
25  // separately on the stack.
26  int return_delta =
27  alignment_slots - (return_slot_count_ & (alignment_slots - 1));
28  if (return_delta != alignment_slots) {
29  frame_slot_count_ += return_delta;
30  }
31  int delta = alignment_slots - (frame_slot_count_ & (alignment_slots - 1));
32  if (delta != alignment_slots) {
33  frame_slot_count_ += delta;
34  if (spill_slot_count_ != 0) {
35  spill_slot_count_ += delta;
36  }
37  }
38  return delta;
39 }
40 
41 void FrameAccessState::MarkHasFrame(bool state) {
42  has_frame_ = state;
43  SetFrameAccessToDefault();
44 }
45 
46 void FrameAccessState::SetFrameAccessToDefault() {
47  if (has_frame() && !FLAG_turbo_sp_frame_access) {
48  SetFrameAccessToFP();
49  } else {
50  SetFrameAccessToSP();
51  }
52 }
53 
54 
55 FrameOffset FrameAccessState::GetFrameOffset(int spill_slot) const {
56  const int frame_offset = FrameSlotToFPOffset(spill_slot);
57  if (access_frame_with_fp()) {
58  return FrameOffset::FromFramePointer(frame_offset);
59  } else {
60  // No frame. Retrieve all parameters relative to stack pointer.
61  int sp_offset = frame_offset + GetSPToFPOffset();
62  return FrameOffset::FromStackPointer(sp_offset);
63  }
64 }
65 
66 
67 } // namespace compiler
68 } // namespace internal
69 } // namespace v8
Definition: libplatform.h:13