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

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

Issue 335173002: Save ICData of unoptimized code in the function, thus preserving it across repated unoptimized comp… (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 6 years, 6 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/flow_graph_compiler.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 8
9 #include "vm/ast_printer.h" 9 #include "vm/ast_printer.h"
10 #include "vm/block_scheduler.h" 10 #include "vm/block_scheduler.h"
(...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after
234 Error& error = Error::Handle(isolate); 234 Error& error = Error::Handle(isolate);
235 error = isolate->object_store()->sticky_error(); 235 error = isolate->object_store()->sticky_error();
236 isolate->object_store()->clear_sticky_error(); 236 isolate->object_store()->clear_sticky_error();
237 return error.raw(); 237 return error.raw();
238 } 238 }
239 UNREACHABLE(); 239 UNREACHABLE();
240 return Error::null(); 240 return Error::null();
241 } 241 }
242 242
243 243
244
244 // Return false if bailed out. 245 // Return false if bailed out.
245 static bool CompileParsedFunctionHelper(ParsedFunction* parsed_function, 246 static bool CompileParsedFunctionHelper(ParsedFunction* parsed_function,
246 bool optimized, 247 bool optimized,
247 intptr_t osr_id) { 248 intptr_t osr_id) {
248 const Function& function = parsed_function->function(); 249 const Function& function = parsed_function->function();
249 if (optimized && !function.IsOptimizable()) { 250 if (optimized && !function.IsOptimizable()) {
250 return false; 251 return false;
251 } 252 }
252 TimerScope timer(FLAG_compiler_stats, &CompilerStats::codegen_timer); 253 TimerScope timer(FLAG_compiler_stats, &CompilerStats::codegen_timer);
253 bool is_compiled = false; 254 bool is_compiled = false;
(...skipping 22 matching lines...) Expand all
276 TimerScope timer(FLAG_compiler_stats, 277 TimerScope timer(FLAG_compiler_stats,
277 &CompilerStats::graphbuilder_timer, 278 &CompilerStats::graphbuilder_timer,
278 isolate); 279 isolate);
279 Array& ic_data_array = Array::Handle(); 280 Array& ic_data_array = Array::Handle();
280 if (optimized) { 281 if (optimized) {
281 ASSERT(function.HasCode()); 282 ASSERT(function.HasCode());
282 // Extract type feedback before the graph is built, as the graph 283 // Extract type feedback before the graph is built, as the graph
283 // builder uses it to attach it to nodes. 284 // builder uses it to attach it to nodes.
284 ASSERT(function.deoptimization_counter() < 285 ASSERT(function.deoptimization_counter() <
285 FLAG_deoptimization_counter_threshold); 286 FLAG_deoptimization_counter_threshold);
286 const Code& unoptimized_code = 287 ic_data_array = function.RestoreICDataMap();
287 Code::Handle(function.unoptimized_code());
288 ic_data_array = unoptimized_code.ExtractTypeFeedbackArray();
289 } 288 }
290 289
291 // Build the flow graph. 290 // Build the flow graph.
292 FlowGraphBuilder builder(parsed_function, 291 FlowGraphBuilder builder(parsed_function,
293 ic_data_array, 292 ic_data_array,
294 NULL, // NULL = not inlining. 293 NULL, // NULL = not inlining.
295 osr_id, 294 osr_id,
296 optimized); 295 optimized);
297 flow_graph = builder.BuildGraph(); 296 flow_graph = builder.BuildGraph();
298 } 297 }
(...skipping 270 matching lines...) Expand 10 before | Expand all | Expand 10 after
569 } 568 }
570 } 569 }
571 function.AttachCode(code); 570 function.AttachCode(code);
572 571
573 for (intptr_t i = 0; 572 for (intptr_t i = 0;
574 i < flow_graph->guarded_fields()->length(); 573 i < flow_graph->guarded_fields()->length();
575 i++) { 574 i++) {
576 const Field* field = (*flow_graph->guarded_fields())[i]; 575 const Field* field = (*flow_graph->guarded_fields())[i];
577 field->RegisterDependentCode(code); 576 field->RegisterDependentCode(code);
578 } 577 }
579 } else { 578 } else { // not optimized.
579 if (function.ic_data_array() == Array::null()) {
580 function.SaveICDataMap(graph_compiler.deopt_id_to_ic_data());
581 }
580 function.set_unoptimized_code(code); 582 function.set_unoptimized_code(code);
581 function.AttachCode(code); 583 function.AttachCode(code);
582 ASSERT(CodePatcher::CodeIsPatchable(code)); 584 ASSERT(CodePatcher::CodeIsPatchable(code));
583 } 585 }
584 if (parsed_function->HasDeferredPrefixes()) { 586 if (parsed_function->HasDeferredPrefixes()) {
585 ZoneGrowableArray<const LibraryPrefix*>* prefixes = 587 ZoneGrowableArray<const LibraryPrefix*>* prefixes =
586 parsed_function->deferred_prefixes(); 588 parsed_function->deferred_prefixes();
587 for (intptr_t i = 0; i < prefixes->length(); i++) { 589 for (intptr_t i = 0; i < prefixes->length(); i++) {
588 (*prefixes)[i]->RegisterDependentCode(code); 590 (*prefixes)[i]->RegisterDependentCode(code);
589 } 591 }
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after
760 static RawError* CompileFunctionHelper(const Function& function, 762 static RawError* CompileFunctionHelper(const Function& function,
761 bool optimized, 763 bool optimized,
762 intptr_t osr_id) { 764 intptr_t osr_id) {
763 Isolate* isolate = Isolate::Current(); 765 Isolate* isolate = Isolate::Current();
764 StackZone zone(isolate); 766 StackZone zone(isolate);
765 LongJumpScope jump; 767 LongJumpScope jump;
766 if (setjmp(*jump.Set()) == 0) { 768 if (setjmp(*jump.Set()) == 0) {
767 TIMERSCOPE(isolate, time_compilation); 769 TIMERSCOPE(isolate, time_compilation);
768 Timer per_compile_timer(FLAG_trace_compiler, "Compilation time"); 770 Timer per_compile_timer(FLAG_trace_compiler, "Compilation time");
769 per_compile_timer.Start(); 771 per_compile_timer.Start();
770 ParsedFunction* parsed_function = new ParsedFunction( 772 ParsedFunction* parsed_function = new(isolate) ParsedFunction(
771 isolate, Function::ZoneHandle(isolate, function.raw())); 773 isolate, Function::ZoneHandle(isolate, function.raw()));
772 if (FLAG_trace_compiler) { 774 if (FLAG_trace_compiler) {
773 OS::Print("Compiling %s%sfunction: '%s' @ token %" Pd ", size %" Pd "\n", 775 OS::Print("Compiling %s%sfunction: '%s' @ token %" Pd ", size %" Pd "\n",
774 (osr_id == Isolate::kNoDeoptId ? "" : "osr "), 776 (osr_id == Isolate::kNoDeoptId ? "" : "osr "),
775 (optimized ? "optimized " : ""), 777 (optimized ? "optimized " : ""),
776 function.ToFullyQualifiedCString(), 778 function.ToFullyQualifiedCString(),
777 function.token_pos(), 779 function.token_pos(),
778 (function.end_token_pos() - function.token_pos())); 780 (function.end_token_pos() - function.token_pos()));
779 } 781 }
780 { 782 {
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after
977 const Object& result = 979 const Object& result =
978 Object::Handle(isolate->object_store()->sticky_error()); 980 Object::Handle(isolate->object_store()->sticky_error());
979 isolate->object_store()->clear_sticky_error(); 981 isolate->object_store()->clear_sticky_error();
980 return result.raw(); 982 return result.raw();
981 } 983 }
982 UNREACHABLE(); 984 UNREACHABLE();
983 return Object::null(); 985 return Object::null();
984 } 986 }
985 987
986 } // namespace dart 988 } // namespace dart
OLDNEW
« no previous file with comments | « no previous file | runtime/vm/flow_graph_compiler.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698