Chromium Code Reviews| Index: runtime/vm/code_descriptors.h |
| diff --git a/runtime/vm/code_descriptors.h b/runtime/vm/code_descriptors.h |
| index fa99412751584d18a508e63574c1be96f1e7e60e..c88dd5215a12d4fbd09a4792c144672eec47c91b 100644 |
| --- a/runtime/vm/code_descriptors.h |
| +++ b/runtime/vm/code_descriptors.h |
| @@ -42,27 +42,6 @@ class DescriptorList : public ZoneAllocated { |
| }; |
| -class CodeSourceMapBuilder : public ZoneAllocated { |
| - public: |
| - explicit CodeSourceMapBuilder(intptr_t initial_capacity = 64) |
| - : encoded_data_(initial_capacity), prev_pc_offset(0), prev_token_pos(0) {} |
| - |
| - ~CodeSourceMapBuilder() {} |
| - |
| - void AddEntry(intptr_t pc_offset, TokenPosition token_pos); |
| - |
| - RawCodeSourceMap* Finalize(); |
| - |
| - private: |
| - GrowableArray<uint8_t> encoded_data_; |
| - |
| - intptr_t prev_pc_offset; |
| - intptr_t prev_token_pos; |
| - |
| - DISALLOW_COPY_AND_ASSIGN(CodeSourceMapBuilder); |
| -}; |
| - |
| - |
| class StackMapTableBuilder : public ZoneAllocated { |
| public: |
| StackMapTableBuilder() |
| @@ -159,6 +138,98 @@ class ExceptionHandlerList : public ZoneAllocated { |
| DISALLOW_COPY_AND_ASSIGN(ExceptionHandlerList); |
| }; |
| + |
| +class CodeSourceMapBuilder : public ZoneAllocated { |
| + public: |
| + CodeSourceMapBuilder( |
| + const GrowableArray<intptr_t>& caller_inline_id, |
| + const GrowableArray<TokenPosition>& inline_id_to_token_pos, |
| + const GrowableArray<const Function*>& inline_id_to_function); |
| + |
| + static const TokenPosition kInitialPosition; |
|
Cutch
2017/02/07 18:27:04
Maybe comment that this is the seed token position
rmacnak
2017/02/07 20:50:45
Done.
|
| + static const uint8_t kChangePosition = 0; |
| + static const uint8_t kAdvancePC = 1; |
| + static const uint8_t kPushFunction = 2; |
| + static const uint8_t kPopFunction = 3; |
| + |
| + void StartInliningInterval(int32_t pc_offset, intptr_t inline_id); |
| + void BeginCodeSourceRange(int32_t pc_offset); |
| + void EndCodeSourceRange(int32_t pc_offset, TokenPosition pos); |
| + |
| + RawArray* InliningIdToFunction(); |
| + RawCodeSourceMap* Finalize(); |
| + |
| + private: |
| + void EmitPosition(TokenPosition pos) { |
| + FlushPeephole(); |
| + stream_.Write<uint8_t>(kChangePosition); |
| + stream_.Write<int32_t>(static_cast<int32_t>(pos.value())); |
| + } |
| + void EmitAdvancePC(int32_t distance) { advance_pc_peephole_ += distance; } |
| + void FlushPeephole() { |
| + if (advance_pc_peephole_ != 0) { |
| + stream_.Write<uint8_t>(kAdvancePC); |
| + stream_.Write<int32_t>(advance_pc_peephole_); |
| + advance_pc_peephole_ = 0; |
| + } |
| + } |
| + void EmitPush(intptr_t inline_id) { |
| + FlushPeephole(); |
| + stream_.Write<uint8_t>(kPushFunction); |
| + stream_.Write<int32_t>(inline_id); |
| + } |
| + void EmitPop() { |
| + FlushPeephole(); |
| + stream_.Write<uint8_t>(kPopFunction); |
| + } |
| + |
| + bool IsOnStack(intptr_t inline_id) { |
| + for (intptr_t i = 0; i < inline_id_stack_.length(); i++) { |
| + if (inline_id_stack_[i] == inline_id) { |
| + return true; |
| + } |
| + } |
| + return false; |
| + } |
| + |
| + intptr_t pc_offset_; |
| + intptr_t advance_pc_peephole_; |
| + GrowableArray<intptr_t> inline_id_stack_; |
| + GrowableArray<TokenPosition> token_pos_stack_; |
| + |
| + const GrowableArray<intptr_t>& caller_inline_id_; |
| + const GrowableArray<TokenPosition>& inline_id_to_token_pos_; |
| + const GrowableArray<const Function*>& inline_id_to_function_; |
| + |
| + uint8_t* buffer_; |
| + WriteStream stream_; |
| + |
| + DISALLOW_COPY_AND_ASSIGN(CodeSourceMapBuilder); |
| +}; |
| + |
| + |
| +class CodeSourceMapReader : public ValueObject { |
| + public: |
| + CodeSourceMapReader(const CodeSourceMap& map, |
| + const Array& functions, |
| + const Function& root) |
| + : map_(map), functions_(functions), root_(root) {} |
| + |
| + void GetInlinedFunctionsAt(int32_t pc_offset, |
| + GrowableArray<const Function*>* function_stack, |
| + GrowableArray<TokenPosition>* token_positions); |
| + NOT_IN_PRODUCT(void PrintJSONInlineIntervals(JSONObject* jsobj)); |
| + void DumpInlineIntervals(uword start); |
| + void DumpSourcePositions(uword start); |
| + |
| + private: |
| + const CodeSourceMap& map_; |
| + const Array& functions_; |
| + const Function& root_; |
| + |
| + DISALLOW_COPY_AND_ASSIGN(CodeSourceMapReader); |
| +}; |
| + |
| } // namespace dart |
| #endif // RUNTIME_VM_CODE_DESCRIPTORS_H_ |