Line data Source code
1 : // Copyright 2016 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 : #ifndef V8_COMPILER_BACKEND_X64_UNWINDING_INFO_WRITER_X64_H_
6 : #define V8_COMPILER_BACKEND_X64_UNWINDING_INFO_WRITER_X64_H_
7 :
8 : #include "src/eh-frame.h"
9 : #include "src/flags.h"
10 :
11 : namespace v8 {
12 : namespace internal {
13 : namespace compiler {
14 :
15 : class InstructionBlock;
16 :
17 : class UnwindingInfoWriter {
18 : public:
19 2949500 : explicit UnwindingInfoWriter(Zone* zone)
20 : : zone_(zone),
21 : eh_frame_writer_(zone),
22 : tracking_fp_(false),
23 : block_will_exit_(false),
24 2949500 : block_initial_states_(zone) {
25 2949389 : if (enabled()) eh_frame_writer_.Initialize();
26 2949389 : }
27 :
28 3189768 : void MaybeIncreaseBaseOffsetAt(int pc_offset, int base_delta) {
29 3189768 : if (enabled() && !tracking_fp_) {
30 0 : eh_frame_writer_.AdvanceLocation(pc_offset);
31 : eh_frame_writer_.IncreaseBaseAddressOffset(base_delta);
32 : }
33 3189768 : }
34 :
35 : void SetNumberOfInstructionBlocks(int number) {
36 2949382 : if (enabled()) block_initial_states_.resize(number);
37 : }
38 :
39 : void BeginInstructionBlock(int pc_offset, const InstructionBlock* block);
40 : void EndInstructionBlock(const InstructionBlock* block);
41 :
42 : void MarkFrameConstructed(int pc_base);
43 : void MarkFrameDeconstructed(int pc_base);
44 :
45 3648072 : void MarkBlockWillExit() { block_will_exit_ = true; }
46 :
47 : void Finish(int code_size) {
48 2949246 : if (enabled()) eh_frame_writer_.Finish(code_size);
49 : }
50 :
51 : EhFrameWriter* eh_frame_writer() {
52 1880796 : return enabled() ? &eh_frame_writer_ : nullptr;
53 : }
54 :
55 : private:
56 61007644 : bool enabled() const { return FLAG_perf_prof_unwinding_info; }
57 :
58 : class BlockInitialState : public ZoneObject {
59 : public:
60 : BlockInitialState(Register reg, int offset, bool tracking_fp)
61 166 : : register_(reg), offset_(offset), tracking_fp_(tracking_fp) {}
62 :
63 : Register register_;
64 : int offset_;
65 : bool tracking_fp_;
66 : };
67 :
68 : Zone* zone_;
69 : EhFrameWriter eh_frame_writer_;
70 : bool tracking_fp_;
71 : bool block_will_exit_;
72 :
73 : ZoneVector<const BlockInitialState*> block_initial_states_;
74 : };
75 :
76 : } // namespace compiler
77 : } // namespace internal
78 : } // namespace v8
79 :
80 : #endif // V8_COMPILER_BACKEND_X64_UNWINDING_INFO_WRITER_X64_H_
|