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

Side by Side Diff: runtime/vm/flow_graph_compiler.h

Issue 2587133002: VM: [DBC] Fix lazy deoptimization after calls that return no values. (Closed)
Patch Set: Add test Created 4 years 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 #ifndef RUNTIME_VM_FLOW_GRAPH_COMPILER_H_ 5 #ifndef RUNTIME_VM_FLOW_GRAPH_COMPILER_H_
6 #define RUNTIME_VM_FLOW_GRAPH_COMPILER_H_ 6 #define RUNTIME_VM_FLOW_GRAPH_COMPILER_H_
7 7
8 #include "vm/allocation.h" 8 #include "vm/allocation.h"
9 #include "vm/assembler.h" 9 #include "vm/assembler.h"
10 #include "vm/code_descriptors.h" 10 #include "vm/code_descriptors.h"
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
115 class CompilerDeoptInfo : public ZoneAllocated { 115 class CompilerDeoptInfo : public ZoneAllocated {
116 public: 116 public:
117 CompilerDeoptInfo(intptr_t deopt_id, 117 CompilerDeoptInfo(intptr_t deopt_id,
118 ICData::DeoptReasonId reason, 118 ICData::DeoptReasonId reason,
119 uint32_t flags, 119 uint32_t flags,
120 Environment* deopt_env) 120 Environment* deopt_env)
121 : pc_offset_(-1), 121 : pc_offset_(-1),
122 deopt_id_(deopt_id), 122 deopt_id_(deopt_id),
123 reason_(reason), 123 reason_(reason),
124 flags_(flags), 124 flags_(flags),
125 #if defined(TARGET_ARCH_DBC)
126 lazy_deopt_with_result_(false),
127 #endif
125 deopt_env_(deopt_env) { 128 deopt_env_(deopt_env) {
126 ASSERT(deopt_env != NULL); 129 ASSERT(deopt_env != NULL);
127 } 130 }
128 virtual ~CompilerDeoptInfo() {} 131 virtual ~CompilerDeoptInfo() {}
129 132
130 RawTypedData* CreateDeoptInfo(FlowGraphCompiler* compiler, 133 RawTypedData* CreateDeoptInfo(FlowGraphCompiler* compiler,
131 DeoptInfoBuilder* builder, 134 DeoptInfoBuilder* builder,
132 const Array& deopt_table); 135 const Array& deopt_table);
133 136
134 137
135 // No code needs to be generated. 138 // No code needs to be generated.
136 virtual void GenerateCode(FlowGraphCompiler* compiler, intptr_t stub_ix) {} 139 virtual void GenerateCode(FlowGraphCompiler* compiler, intptr_t stub_ix) {}
137 140
138 intptr_t pc_offset() const { return pc_offset_; } 141 intptr_t pc_offset() const { return pc_offset_; }
139 void set_pc_offset(intptr_t offset) { pc_offset_ = offset; } 142 void set_pc_offset(intptr_t offset) { pc_offset_ = offset; }
140 143
141 intptr_t deopt_id() const { return deopt_id_; } 144 intptr_t deopt_id() const { return deopt_id_; }
142 ICData::DeoptReasonId reason() const { return reason_; } 145 ICData::DeoptReasonId reason() const { return reason_; }
143 uint32_t flags() const { return flags_; } 146 uint32_t flags() const { return flags_; }
144 const Environment* deopt_env() const { return deopt_env_; } 147 const Environment* deopt_env() const { return deopt_env_; }
145 148
149 #if defined(TARGET_ARCH_DBC)
150 // On DBC calls return results on the stack but not all calls have a result.
151 // This needs to be taken into account when constructing lazy deoptimization
152 // environment.
153 // For calls with results we add a deopt instruction that would copy top
154 // of the stack from optimized frame to unoptimized frame effectively
155 // preserving the result of the call.
156 // For calls with no results we don't emit such instruction - because there
157 // is no result pushed by the return sequence.
158 void mark_lazy_deopt_with_result() { lazy_deopt_with_result_ = true; }
159 #endif
160
146 private: 161 private:
147 void EmitMaterializations(Environment* env, DeoptInfoBuilder* builder); 162 void EmitMaterializations(Environment* env, DeoptInfoBuilder* builder);
148 163
149 void AllocateIncomingParametersRecursive(Environment* env, 164 void AllocateIncomingParametersRecursive(Environment* env,
150 intptr_t* stack_height); 165 intptr_t* stack_height);
151 166
152 intptr_t pc_offset_; 167 intptr_t pc_offset_;
153 const intptr_t deopt_id_; 168 const intptr_t deopt_id_;
154 const ICData::DeoptReasonId reason_; 169 const ICData::DeoptReasonId reason_;
155 const uint32_t flags_; 170 const uint32_t flags_;
171 #if defined(TARGET_ARCH_DBC)
172 bool lazy_deopt_with_result_;
173 #endif
156 Environment* deopt_env_; 174 Environment* deopt_env_;
157 175
158 DISALLOW_COPY_AND_ASSIGN(CompilerDeoptInfo); 176 DISALLOW_COPY_AND_ASSIGN(CompilerDeoptInfo);
159 }; 177 };
160 178
161 179
162 class CompilerDeoptInfoWithStub : public CompilerDeoptInfo { 180 class CompilerDeoptInfoWithStub : public CompilerDeoptInfo {
163 public: 181 public:
164 CompilerDeoptInfoWithStub(intptr_t deopt_id, 182 CompilerDeoptInfoWithStub(intptr_t deopt_id,
165 ICData::DeoptReasonId reason, 183 ICData::DeoptReasonId reason,
(...skipping 326 matching lines...) Expand 10 before | Expand all | Expand 10 after
492 510
493 #if defined(TARGET_ARCH_DBC) 511 #if defined(TARGET_ARCH_DBC)
494 void EmitDeopt(intptr_t deopt_id, 512 void EmitDeopt(intptr_t deopt_id,
495 ICData::DeoptReasonId reason, 513 ICData::DeoptReasonId reason,
496 uint32_t flags = 0); 514 uint32_t flags = 0);
497 515
498 // If the cid does not fit in 16 bits, then this will cause a bailout. 516 // If the cid does not fit in 16 bits, then this will cause a bailout.
499 uint16_t ToEmbeddableCid(intptr_t cid, Instruction* instruction); 517 uint16_t ToEmbeddableCid(intptr_t cid, Instruction* instruction);
500 #endif // defined(TARGET_ARCH_DBC) 518 #endif // defined(TARGET_ARCH_DBC)
501 519
502 void AddDeoptIndexAtCall(intptr_t deopt_id); 520 CompilerDeoptInfo* AddDeoptIndexAtCall(intptr_t deopt_id);
503 521
504 void AddSlowPathCode(SlowPathCode* slow_path); 522 void AddSlowPathCode(SlowPathCode* slow_path);
505 523
506 void FinalizeExceptionHandlers(const Code& code); 524 void FinalizeExceptionHandlers(const Code& code);
507 void FinalizePcDescriptors(const Code& code); 525 void FinalizePcDescriptors(const Code& code);
508 RawArray* CreateDeoptInfo(Assembler* assembler); 526 RawArray* CreateDeoptInfo(Assembler* assembler);
509 void FinalizeStackMaps(const Code& code); 527 void FinalizeStackMaps(const Code& code);
510 void FinalizeVarDescriptors(const Code& code); 528 void FinalizeVarDescriptors(const Code& code);
511 void FinalizeStaticCallTargetsTable(const Code& code); 529 void FinalizeStaticCallTargetsTable(const Code& code);
512 530
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
576 code_source_map_builder_ = new CodeSourceMapBuilder(); 594 code_source_map_builder_ = new CodeSourceMapBuilder();
577 } 595 }
578 ASSERT(code_source_map_builder_ != NULL); 596 ASSERT(code_source_map_builder_ != NULL);
579 return code_source_map_builder_; 597 return code_source_map_builder_;
580 } 598 }
581 599
582 void BeginCodeSourceRange(); 600 void BeginCodeSourceRange();
583 bool EndCodeSourceRange(TokenPosition token_pos); 601 bool EndCodeSourceRange(TokenPosition token_pos);
584 602
585 #if defined(TARGET_ARCH_DBC) 603 #if defined(TARGET_ARCH_DBC)
604 enum CallResult {
605 kHasResult,
606 kNoResult,
607 };
586 void RecordAfterCallHelper(TokenPosition token_pos, 608 void RecordAfterCallHelper(TokenPosition token_pos,
587 intptr_t deopt_id, 609 intptr_t deopt_id,
588 intptr_t argument_count, 610 intptr_t argument_count,
611 CallResult result,
589 LocationSummary* locs); 612 LocationSummary* locs);
590 void RecordAfterCall(Instruction* instr); 613 void RecordAfterCall(Instruction* instr, CallResult result);
591 #endif 614 #endif
592 615
593 private: 616 private:
594 friend class CheckStackOverflowSlowPath; // For pending_deoptimization_env_. 617 friend class CheckStackOverflowSlowPath; // For pending_deoptimization_env_.
595 618
596 static bool ShouldInlineSmiStringHashCode(const ICData& ic_data); 619 static bool ShouldInlineSmiStringHashCode(const ICData& ic_data);
597 620
598 void EmitFrameEntry(); 621 void EmitFrameEntry();
599 622
600 void AddStaticCallTarget(const Function& function); 623 void AddStaticCallTarget(const Function& function);
(...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after
792 const GrowableArray<const Function*>& inline_id_to_function_; 815 const GrowableArray<const Function*>& inline_id_to_function_;
793 const GrowableArray<TokenPosition>& inline_id_to_token_pos_; 816 const GrowableArray<TokenPosition>& inline_id_to_token_pos_;
794 const GrowableArray<intptr_t>& caller_inline_id_; 817 const GrowableArray<intptr_t>& caller_inline_id_;
795 818
796 DISALLOW_COPY_AND_ASSIGN(FlowGraphCompiler); 819 DISALLOW_COPY_AND_ASSIGN(FlowGraphCompiler);
797 }; 820 };
798 821
799 } // namespace dart 822 } // namespace dart
800 823
801 #endif // RUNTIME_VM_FLOW_GRAPH_COMPILER_H_ 824 #endif // RUNTIME_VM_FLOW_GRAPH_COMPILER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698