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

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') | runtime/vm/flow_graph_compiler.cc » ('J')
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 static RawArray* ComputeICDataArray(const Function& function) {
Cutch 2014/06/16 21:39:42 Maybe, make this a method on Function and call it
srdjan 2014/06/16 21:58:08 Yes: SaveICDataMap and RestoreICDataMap.
245 const Array& saved_icd = Array::Handle(function.ic_data_array());
246 if (saved_icd.Length() == 0) {
247 return Array::empty_array().raw();
248 }
249 ICData& icd = ICData::Handle();
250 icd ^= saved_icd.At(saved_icd.Length() - 1);
251 const Array& result = Array::Handle(Array::New(icd.deopt_id() + 1));
252 for (intptr_t i = 0; i < saved_icd.Length(); i++) {
253 icd ^= saved_icd.At(i);
254 result.SetAt(icd.deopt_id(), icd);
255 }
256 return result.raw();
257 }
258
259
244 // Return false if bailed out. 260 // Return false if bailed out.
245 static bool CompileParsedFunctionHelper(ParsedFunction* parsed_function, 261 static bool CompileParsedFunctionHelper(ParsedFunction* parsed_function,
246 bool optimized, 262 bool optimized,
247 intptr_t osr_id) { 263 intptr_t osr_id) {
248 const Function& function = parsed_function->function(); 264 const Function& function = parsed_function->function();
249 if (optimized && !function.IsOptimizable()) { 265 if (optimized && !function.IsOptimizable()) {
250 return false; 266 return false;
251 } 267 }
252 TimerScope timer(FLAG_compiler_stats, &CompilerStats::codegen_timer); 268 TimerScope timer(FLAG_compiler_stats, &CompilerStats::codegen_timer);
253 bool is_compiled = false; 269 bool is_compiled = false;
(...skipping 22 matching lines...) Expand all
276 TimerScope timer(FLAG_compiler_stats, 292 TimerScope timer(FLAG_compiler_stats,
277 &CompilerStats::graphbuilder_timer, 293 &CompilerStats::graphbuilder_timer,
278 isolate); 294 isolate);
279 Array& ic_data_array = Array::Handle(); 295 Array& ic_data_array = Array::Handle();
280 if (optimized) { 296 if (optimized) {
281 ASSERT(function.HasCode()); 297 ASSERT(function.HasCode());
282 // Extract type feedback before the graph is built, as the graph 298 // Extract type feedback before the graph is built, as the graph
283 // builder uses it to attach it to nodes. 299 // builder uses it to attach it to nodes.
284 ASSERT(function.deoptimization_counter() < 300 ASSERT(function.deoptimization_counter() <
285 FLAG_deoptimization_counter_threshold); 301 FLAG_deoptimization_counter_threshold);
286 const Code& unoptimized_code = 302 ic_data_array = ComputeICDataArray(function);
287 Code::Handle(function.unoptimized_code());
288 ic_data_array = unoptimized_code.ExtractTypeFeedbackArray();
289 } 303 }
290 304
291 // Build the flow graph. 305 // Build the flow graph.
292 FlowGraphBuilder builder(parsed_function, 306 FlowGraphBuilder builder(parsed_function,
293 ic_data_array, 307 ic_data_array,
294 NULL, // NULL = not inlining. 308 NULL, // NULL = not inlining.
295 osr_id, 309 osr_id,
296 optimized); 310 optimized);
297 flow_graph = builder.BuildGraph(); 311 flow_graph = builder.BuildGraph();
298 } 312 }
(...skipping 270 matching lines...) Expand 10 before | Expand all | Expand 10 after
569 } 583 }
570 } 584 }
571 function.AttachCode(code); 585 function.AttachCode(code);
572 586
573 for (intptr_t i = 0; 587 for (intptr_t i = 0;
574 i < flow_graph->guarded_fields()->length(); 588 i < flow_graph->guarded_fields()->length();
575 i++) { 589 i++) {
576 const Field* field = (*flow_graph->guarded_fields())[i]; 590 const Field* field = (*flow_graph->guarded_fields())[i];
577 field->RegisterDependentCode(code); 591 field->RegisterDependentCode(code);
578 } 592 }
579 } else { 593 } else { // not optimized.
594 if (function.ic_data_array() == Array::null()) {
595 function.SetSavedICData(graph_compiler.deopt_id_to_ic_data());
596 }
580 function.set_unoptimized_code(code); 597 function.set_unoptimized_code(code);
581 function.AttachCode(code); 598 function.AttachCode(code);
582 ASSERT(CodePatcher::CodeIsPatchable(code)); 599 ASSERT(CodePatcher::CodeIsPatchable(code));
583 } 600 }
584 if (parsed_function->HasDeferredPrefixes()) { 601 if (parsed_function->HasDeferredPrefixes()) {
585 ZoneGrowableArray<const LibraryPrefix*>* prefixes = 602 ZoneGrowableArray<const LibraryPrefix*>* prefixes =
586 parsed_function->deferred_prefixes(); 603 parsed_function->deferred_prefixes();
587 for (intptr_t i = 0; i < prefixes->length(); i++) { 604 for (intptr_t i = 0; i < prefixes->length(); i++) {
588 (*prefixes)[i]->RegisterDependentCode(code); 605 (*prefixes)[i]->RegisterDependentCode(code);
589 } 606 }
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after
760 static RawError* CompileFunctionHelper(const Function& function, 777 static RawError* CompileFunctionHelper(const Function& function,
761 bool optimized, 778 bool optimized,
762 intptr_t osr_id) { 779 intptr_t osr_id) {
763 Isolate* isolate = Isolate::Current(); 780 Isolate* isolate = Isolate::Current();
764 StackZone zone(isolate); 781 StackZone zone(isolate);
765 LongJumpScope jump; 782 LongJumpScope jump;
766 if (setjmp(*jump.Set()) == 0) { 783 if (setjmp(*jump.Set()) == 0) {
767 TIMERSCOPE(isolate, time_compilation); 784 TIMERSCOPE(isolate, time_compilation);
768 Timer per_compile_timer(FLAG_trace_compiler, "Compilation time"); 785 Timer per_compile_timer(FLAG_trace_compiler, "Compilation time");
769 per_compile_timer.Start(); 786 per_compile_timer.Start();
770 ParsedFunction* parsed_function = new ParsedFunction( 787 ParsedFunction* parsed_function = new(isolate) ParsedFunction(
771 isolate, Function::ZoneHandle(isolate, function.raw())); 788 isolate, Function::ZoneHandle(isolate, function.raw()));
772 if (FLAG_trace_compiler) { 789 if (FLAG_trace_compiler) {
773 OS::Print("Compiling %s%sfunction: '%s' @ token %" Pd ", size %" Pd "\n", 790 OS::Print("Compiling %s%sfunction: '%s' @ token %" Pd ", size %" Pd "\n",
774 (osr_id == Isolate::kNoDeoptId ? "" : "osr "), 791 (osr_id == Isolate::kNoDeoptId ? "" : "osr "),
775 (optimized ? "optimized " : ""), 792 (optimized ? "optimized " : ""),
776 function.ToFullyQualifiedCString(), 793 function.ToFullyQualifiedCString(),
777 function.token_pos(), 794 function.token_pos(),
778 (function.end_token_pos() - function.token_pos())); 795 (function.end_token_pos() - function.token_pos()));
779 } 796 }
780 { 797 {
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after
977 const Object& result = 994 const Object& result =
978 Object::Handle(isolate->object_store()->sticky_error()); 995 Object::Handle(isolate->object_store()->sticky_error());
979 isolate->object_store()->clear_sticky_error(); 996 isolate->object_store()->clear_sticky_error();
980 return result.raw(); 997 return result.raw();
981 } 998 }
982 UNREACHABLE(); 999 UNREACHABLE();
983 return Object::null(); 1000 return Object::null();
984 } 1001 }
985 1002
986 } // namespace dart 1003 } // namespace dart
OLDNEW
« no previous file with comments | « no previous file | runtime/vm/flow_graph_compiler.h » ('j') | runtime/vm/flow_graph_compiler.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698