Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1222)

Unified Diff: runtime/vm/code_descriptors.h

Issue 2670843006: Encode inlining information in CodeSourceMap and remove inlining interval arrays. (Closed)
Patch Set: . Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « runtime/vm/clustered_snapshot.cc ('k') | runtime/vm/code_descriptors.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/code_descriptors.h
diff --git a/runtime/vm/code_descriptors.h b/runtime/vm/code_descriptors.h
index fa99412751584d18a508e63574c1be96f1e7e60e..d2faea285dbd8e28de593501d405c68887eff905 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,102 @@ 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);
+
+ // The position at which a function implicitly starts, for both the root and
+ // after a push bytecode. We use the classifying position kDartCodePrologue
+ // since it is the most common.
+ static const TokenPosition kInitialPosition;
+
+ 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_
« no previous file with comments | « runtime/vm/clustered_snapshot.cc ('k') | runtime/vm/code_descriptors.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698