• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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/compiler/register-allocator.h"
9 #include "src/macro-assembler.h"
10 
11 namespace v8 {
12 namespace internal {
13 namespace compiler {
14 
Frame(int fixed_frame_size_in_slots)15 Frame::Frame(int fixed_frame_size_in_slots)
16     : frame_slot_count_(fixed_frame_size_in_slots),
17       spill_slot_count_(0),
18       allocated_registers_(nullptr),
19       allocated_double_registers_(nullptr) {}
20 
AlignFrame(int alignment)21 int Frame::AlignFrame(int alignment) {
22   int alignment_slots = alignment / kPointerSize;
23   int delta = alignment_slots - (frame_slot_count_ & (alignment_slots - 1));
24   if (delta != alignment_slots) {
25     frame_slot_count_ += delta;
26     if (spill_slot_count_ != 0) {
27       spill_slot_count_ += delta;
28     }
29   }
30   return delta;
31 }
32 
MarkHasFrame(bool state)33 void FrameAccessState::MarkHasFrame(bool state) {
34   has_frame_ = state;
35   SetFrameAccessToDefault();
36 }
37 
SetFrameAccessToDefault()38 void FrameAccessState::SetFrameAccessToDefault() {
39   if (has_frame() && !FLAG_turbo_sp_frame_access) {
40     SetFrameAccessToFP();
41   } else {
42     SetFrameAccessToSP();
43   }
44 }
45 
46 
GetFrameOffset(int spill_slot) const47 FrameOffset FrameAccessState::GetFrameOffset(int spill_slot) const {
48   const int frame_offset = FrameSlotToFPOffset(spill_slot);
49   if (access_frame_with_fp()) {
50     return FrameOffset::FromFramePointer(frame_offset);
51   } else {
52     // No frame. Retrieve all parameters relative to stack pointer.
53     int sp_offset = frame_offset + GetSPToFPOffset();
54     return FrameOffset::FromStackPointer(sp_offset);
55   }
56 }
57 
58 
59 }  // namespace compiler
60 }  // namespace internal
61 }  // namespace v8
62