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_PPC_UNWINDING_INFO_WRITER_PPC_H_ 6 #define V8_COMPILER_BACKEND_PPC_UNWINDING_INFO_WRITER_PPC_H_ 7 8 #include "src/diagnostics/eh-frame.h" 9 #include "src/flags/flags.h" 10 11 namespace v8 { 12 namespace internal { 13 namespace compiler { 14 15 class InstructionBlock; 16 17 class UnwindingInfoWriter { 18 public: UnwindingInfoWriter(Zone * zone)19 explicit UnwindingInfoWriter(Zone* zone) 20 : zone_(zone), 21 eh_frame_writer_(zone), 22 saved_lr_(false), 23 block_will_exit_(false), 24 block_initial_states_(zone) { 25 if (enabled()) eh_frame_writer_.Initialize(); 26 } 27 SetNumberOfInstructionBlocks(int number)28 void SetNumberOfInstructionBlocks(int number) { 29 if (enabled()) block_initial_states_.resize(number); 30 } 31 32 void BeginInstructionBlock(int pc_offset, const InstructionBlock* block); 33 void EndInstructionBlock(const InstructionBlock* block); 34 35 void MarkLinkRegisterOnTopOfStack(int pc_offset); 36 void MarkPopLinkRegisterFromTopOfStack(int pc_offset); 37 38 void MarkFrameConstructed(int at_pc); 39 void MarkFrameDeconstructed(int at_pc); 40 MarkBlockWillExit()41 void MarkBlockWillExit() { block_will_exit_ = true; } 42 Finish(int code_size)43 void Finish(int code_size) { 44 if (enabled()) eh_frame_writer_.Finish(code_size); 45 } 46 eh_frame_writer()47 EhFrameWriter* eh_frame_writer() { 48 return enabled() ? &eh_frame_writer_ : nullptr; 49 } 50 51 private: enabled()52 bool enabled() const { return FLAG_perf_prof_unwinding_info; } 53 54 class BlockInitialState : public ZoneObject { 55 public: BlockInitialState(bool saved_lr)56 explicit BlockInitialState(bool saved_lr) : saved_lr_(saved_lr) {} 57 58 bool saved_lr_; 59 }; 60 61 Zone* zone_; 62 EhFrameWriter eh_frame_writer_; 63 bool saved_lr_; 64 bool block_will_exit_; 65 66 ZoneVector<const BlockInitialState*> block_initial_states_; 67 }; 68 69 } // namespace compiler 70 } // namespace internal 71 } // namespace v8 72 73 #endif // V8_COMPILER_BACKEND_PPC_UNWINDING_INFO_WRITER_PPC_H_ 74