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

Side by Side Diff: runtime/vm/compiler.cc

Issue 10378093: Adding collected type feedback to the IL nodes (only in optimized mode). (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 7 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | runtime/vm/intermediate_language.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 #include "vm/compiler.h" 5 #include "vm/compiler.h"
6 6
7 #include "vm/assembler.h" 7 #include "vm/assembler.h"
8 #include "vm/ast_printer.h" 8 #include "vm/ast_printer.h"
9 #include "vm/code_generator.h" 9 #include "vm/code_generator.h"
10 #include "vm/code_patcher.h" 10 #include "vm/code_patcher.h"
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
76 ASSERT(all_nodes[n]->ICDataAtId(node_id).IsNull()); 76 ASSERT(all_nodes[n]->ICDataAtId(node_id).IsNull());
77 ic_data_obj ^= ic_data_objs.At(i); 77 ic_data_obj ^= ic_data_objs.At(i);
78 all_nodes[n]->SetIcDataAtId(node_id, ic_data_obj); 78 all_nodes[n]->SetIcDataAtId(node_id, ic_data_obj);
79 } 79 }
80 } 80 }
81 ASSERT(found_node); 81 ASSERT(found_node);
82 } 82 }
83 } 83 }
84 84
85 85
86 // Returns an array indexed by computation id, containing the extracted ICData.
87 static RawArray* ExtractTypeFeedbackArray(const Code& code) {
88 ASSERT(!code.IsNull() && !code.is_optimized());
89 GrowableArray<intptr_t> computation_ids;
90 const GrowableObjectArray& ic_data_objs =
91 GrowableObjectArray::Handle(GrowableObjectArray::New());
92 const intptr_t max_id =
93 code.ExtractIcDataArraysAtCalls(&computation_ids, ic_data_objs);
94 const Array& result = Array::Handle(Array::New(max_id + 1));
95 for (intptr_t i = 0; i < computation_ids.length(); i++) {
96 ASSERT(result.At(i) == Object::null());
97 result.SetAt(i, Object::Handle(ic_data_objs.At(i)));
98 }
99 return result.raw();
100 }
101
102
86 RawError* Compiler::Compile(const Library& library, const Script& script) { 103 RawError* Compiler::Compile(const Library& library, const Script& script) {
87 Isolate* isolate = Isolate::Current(); 104 Isolate* isolate = Isolate::Current();
88 LongJump* base = isolate->long_jump_base(); 105 LongJump* base = isolate->long_jump_base();
89 LongJump jump; 106 LongJump jump;
90 isolate->set_long_jump_base(&jump); 107 isolate->set_long_jump_base(&jump);
91 if (setjmp(*jump.Set()) == 0) { 108 if (setjmp(*jump.Set()) == 0) {
92 if (FLAG_trace_compiler) { 109 if (FLAG_trace_compiler) {
93 HANDLESCOPE(isolate); 110 HANDLESCOPE(isolate);
94 const String& script_url = String::Handle(script.url()); 111 const String& script_url = String::Handle(script.url());
95 // TODO(iposva): Extract script kind. 112 // TODO(iposva): Extract script kind.
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
161 178
162 if (optimized) { 179 if (optimized) {
163 // Transition to optimized code only from unoptimized code ... 180 // Transition to optimized code only from unoptimized code ...
164 // for now. 181 // for now.
165 ASSERT(parsed_function.function().HasCode()); 182 ASSERT(parsed_function.function().HasCode());
166 ASSERT(!parsed_function.function().HasOptimizedCode()); 183 ASSERT(!parsed_function.function().HasOptimizedCode());
167 // Do not use type feedback to optimize a function that was 184 // Do not use type feedback to optimize a function that was
168 // deoptimized too often. 185 // deoptimized too often.
169 if (parsed_function.function().deoptimization_counter() < 186 if (parsed_function.function().deoptimization_counter() <
170 FLAG_deoptimization_counter_threshold) { 187 FLAG_deoptimization_counter_threshold) {
171 // Extract type feedback etc. 188 const Code& unoptimized_code =
189 Code::Handle(parsed_function.function().unoptimized_code());
190 isolate->set_ic_data_array(
191 ExtractTypeFeedbackArray(unoptimized_code));
172 } 192 }
173 } 193 }
174 } 194 }
175 195
176 Assembler assembler; 196 Assembler assembler;
177 FlowGraphCompiler graph_compiler(&assembler, parsed_function, 197 FlowGraphCompiler graph_compiler(&assembler, parsed_function,
178 block_order, optimized); 198 block_order, optimized);
179 { 199 {
180 TimerScope timer(FLAG_compiler_stats, 200 TimerScope timer(FLAG_compiler_stats,
181 &CompilerStats::graphcompiler_timer, 201 &CompilerStats::graphcompiler_timer,
182 isolate); 202 isolate);
183 graph_compiler.CompileGraph(); 203 graph_compiler.CompileGraph();
204 isolate->set_ic_data_array(Array::null());
184 } 205 }
185 { 206 {
186 TimerScope timer(FLAG_compiler_stats, 207 TimerScope timer(FLAG_compiler_stats,
187 &CompilerStats::codefinalizer_timer, 208 &CompilerStats::codefinalizer_timer,
188 isolate); 209 isolate);
189 const Function& function = parsed_function.function(); 210 const Function& function = parsed_function.function();
190 const Code& code = Code::Handle(Code::FinalizeCode(function, &assembler)); 211 const Code& code = Code::Handle(Code::FinalizeCode(function, &assembler));
191 code.set_is_optimized(optimized); 212 code.set_is_optimized(optimized);
192 graph_compiler.FinalizePcDescriptors(code); 213 graph_compiler.FinalizePcDescriptors(code);
193 graph_compiler.FinalizeStackmaps(code); 214 graph_compiler.FinalizeStackmaps(code);
(...skipping 318 matching lines...) Expand 10 before | Expand all | Expand 10 after
512 isolate->object_store()->clear_sticky_error(); 533 isolate->object_store()->clear_sticky_error();
513 isolate->set_long_jump_base(base); 534 isolate->set_long_jump_base(base);
514 return result.raw(); 535 return result.raw();
515 } 536 }
516 UNREACHABLE(); 537 UNREACHABLE();
517 return Object::null(); 538 return Object::null();
518 } 539 }
519 540
520 541
521 } // namespace dart 542 } // namespace dart
OLDNEW
« no previous file with comments | « no previous file | runtime/vm/intermediate_language.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698