Line data Source code
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 :
15 915896 : 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 915896 : allocated_double_registers_(nullptr) {}
20 :
21 0 : int Frame::AlignFrame(int alignment) {
22 0 : int alignment_slots = alignment / kPointerSize;
23 0 : int delta = alignment_slots - (frame_slot_count_ & (alignment_slots - 1));
24 0 : if (delta != alignment_slots) {
25 0 : frame_slot_count_ += delta;
26 0 : if (spill_slot_count_ != 0) {
27 0 : spill_slot_count_ += delta;
28 : }
29 : }
30 0 : return delta;
31 : }
32 :
33 11397346 : void FrameAccessState::MarkHasFrame(bool state) {
34 11397346 : has_frame_ = state;
35 : SetFrameAccessToDefault();
36 11397346 : }
37 :
38 151310 : void FrameAccessState::SetFrameAccessToDefault() {
39 11548656 : if (has_frame() && !FLAG_turbo_sp_frame_access) {
40 : SetFrameAccessToFP();
41 : } else {
42 : SetFrameAccessToSP();
43 : }
44 151310 : }
45 :
46 :
47 18542436 : FrameOffset FrameAccessState::GetFrameOffset(int spill_slot) const {
48 : const int frame_offset = FrameSlotToFPOffset(spill_slot);
49 9271218 : if (access_frame_with_fp()) {
50 : return FrameOffset::FromFramePointer(frame_offset);
51 : } else {
52 : // No frame. Retrieve all parameters relative to stack pointer.
53 72693 : 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
|