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

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

Issue 10952002: Reapply "Deoptimization support in inlined code." (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 3 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 | « runtime/vm/compiler.h ('k') | runtime/vm/deopt_instructions.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 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
50 ASSERT(arguments.Count() == kCompileFunctionRuntimeEntry.argument_count()); 50 ASSERT(arguments.Count() == kCompileFunctionRuntimeEntry.argument_count());
51 const Function& function = Function::CheckedHandle(arguments.At(0)); 51 const Function& function = Function::CheckedHandle(arguments.At(0));
52 ASSERT(!function.HasCode()); 52 ASSERT(!function.HasCode());
53 const Error& error = Error::Handle(Compiler::CompileFunction(function)); 53 const Error& error = Error::Handle(Compiler::CompileFunction(function));
54 if (!error.IsNull()) { 54 if (!error.IsNull()) {
55 Exceptions::PropagateError(error); 55 Exceptions::PropagateError(error);
56 } 56 }
57 } 57 }
58 58
59 59
60 // Returns an array indexed by deopt id, containing the extracted ICData.
61 static RawArray* ExtractTypeFeedbackArray(const Code& code) {
62 ASSERT(!code.IsNull() && !code.is_optimized());
63 GrowableArray<intptr_t> deopt_ids;
64 const GrowableObjectArray& ic_data_objs =
65 GrowableObjectArray::Handle(GrowableObjectArray::New());
66 const intptr_t max_id =
67 code.ExtractIcDataArraysAtCalls(&deopt_ids, ic_data_objs);
68 const Array& result = Array::Handle(Array::New(max_id + 1));
69 for (intptr_t i = 0; i < deopt_ids.length(); i++) {
70 intptr_t result_index = deopt_ids[i];
71 ASSERT(result.At(result_index) == Object::null());
72 result.SetAt(result_index, Object::Handle(ic_data_objs.At(i)));
73 }
74 return result.raw();
75 }
76
77
78 RawError* Compiler::Compile(const Library& library, const Script& script) { 60 RawError* Compiler::Compile(const Library& library, const Script& script) {
79 Isolate* isolate = Isolate::Current(); 61 Isolate* isolate = Isolate::Current();
80 LongJump* base = isolate->long_jump_base(); 62 LongJump* base = isolate->long_jump_base();
81 LongJump jump; 63 LongJump jump;
82 isolate->set_long_jump_base(&jump); 64 isolate->set_long_jump_base(&jump);
83 if (setjmp(*jump.Set()) == 0) { 65 if (setjmp(*jump.Set()) == 0) {
84 if (FLAG_trace_compiler) { 66 if (FLAG_trace_compiler) {
85 HANDLESCOPE(isolate); 67 HANDLESCOPE(isolate);
86 const String& script_url = String::Handle(script.url()); 68 const String& script_url = String::Handle(script.url());
87 // TODO(iposva): Extract script kind. 69 // TODO(iposva): Extract script kind.
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
150 ASSERT(!parsed_function.function().HasOptimizedCode()); 132 ASSERT(!parsed_function.function().HasOptimizedCode());
151 // Extract type feedback before the graph is built, as the graph 133 // Extract type feedback before the graph is built, as the graph
152 // builder uses it to attach it to nodes. 134 // builder uses it to attach it to nodes.
153 // Do not use type feedback to optimize a function that was 135 // Do not use type feedback to optimize a function that was
154 // deoptimized too often. 136 // deoptimized too often.
155 if (parsed_function.function().deoptimization_counter() < 137 if (parsed_function.function().deoptimization_counter() <
156 FLAG_deoptimization_counter_threshold) { 138 FLAG_deoptimization_counter_threshold) {
157 const Code& unoptimized_code = 139 const Code& unoptimized_code =
158 Code::Handle(parsed_function.function().unoptimized_code()); 140 Code::Handle(parsed_function.function().unoptimized_code());
159 isolate->set_ic_data_array( 141 isolate->set_ic_data_array(
160 ExtractTypeFeedbackArray(unoptimized_code)); 142 unoptimized_code.ExtractTypeFeedbackArray());
161 } 143 }
162 } 144 }
163 145
164 // Build the flow graph. 146 // Build the flow graph.
165 FlowGraphBuilder builder(parsed_function); 147 FlowGraphBuilder builder(parsed_function);
166 flow_graph = builder.BuildGraph(FlowGraphBuilder::kNotInlining); 148 flow_graph = builder.BuildGraph(FlowGraphBuilder::kNotInlining);
167 149
168 // Transform to SSA. 150 // Transform to SSA.
169 if (optimized) flow_graph->ComputeSSA(0); // Start at virtual register 0. 151 if (optimized) flow_graph->ComputeSSA(0); // Start at virtual register 0.
170 152
(...skipping 407 matching lines...) Expand 10 before | Expand all | Expand 10 after
578 result = isolate->object_store()->sticky_error(); 560 result = isolate->object_store()->sticky_error();
579 isolate->object_store()->clear_sticky_error(); 561 isolate->object_store()->clear_sticky_error();
580 isolate->set_long_jump_base(base); 562 isolate->set_long_jump_base(base);
581 return result.raw(); 563 return result.raw();
582 } 564 }
583 UNREACHABLE(); 565 UNREACHABLE();
584 return Object::null(); 566 return Object::null();
585 } 567 }
586 568
587 } // namespace dart 569 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/compiler.h ('k') | runtime/vm/deopt_instructions.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698