frame.cc 1.63 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14
// Copyright 2015 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "src/compiler/frame.h"

#include "src/compiler/linkage.h"
#include "src/compiler/register-allocator.h"
#include "src/macro-assembler.h"

namespace v8 {
namespace internal {
namespace compiler {

15
Frame::Frame(int fixed_frame_size_in_slots)
16
    : frame_slot_count_(fixed_frame_size_in_slots),
17
      spill_slot_count_(0),
18 19
      allocated_registers_(nullptr),
      allocated_double_registers_(nullptr) {}
20

21 22 23 24 25 26 27 28 29 30 31
int Frame::AlignFrame(int alignment) {
  int alignment_slots = alignment / kPointerSize;
  int delta = alignment_slots - (frame_slot_count_ & (alignment_slots - 1));
  if (delta != alignment_slots) {
    frame_slot_count_ += delta;
    if (spill_slot_count_ != 0) {
      spill_slot_count_ += delta;
    }
  }
  return delta;
}
32

33 34 35 36 37
void FrameAccessState::MarkHasFrame(bool state) {
  has_frame_ = state;
  SetFrameAccessToDefault();
}

38
void FrameAccessState::SetFrameAccessToDefault() {
39
  if (has_frame() && !FLAG_turbo_sp_frame_access) {
40 41 42 43 44 45 46 47
    SetFrameAccessToFP();
  } else {
    SetFrameAccessToSP();
  }
}


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 52
  } else {
    // No frame. Retrieve all parameters relative to stack pointer.
53
    int sp_offset = frame_offset + GetSPToFPOffset();
54 55 56 57 58
    return FrameOffset::FromStackPointer(sp_offset);
  }
}


59 60 61
}  // namespace compiler
}  // namespace internal
}  // namespace v8