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

Side by Side Diff: vm/compiler.cc

Issue 9791048: - Wire the stack frame iterator to use stack maps for traversing objects if there are stack maps in… (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/runtime/
Patch Set: Created 8 years, 8 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 | « vm/code_index_table_test.cc ('k') | vm/debugger.cc » ('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_index_table.h"
11 #include "vm/code_patcher.h" 10 #include "vm/code_patcher.h"
12 #include "vm/dart_entry.h" 11 #include "vm/dart_entry.h"
13 #include "vm/debugger.h" 12 #include "vm/debugger.h"
14 #include "vm/disassembler.h" 13 #include "vm/disassembler.h"
15 #include "vm/exceptions.h" 14 #include "vm/exceptions.h"
16 #include "vm/flags.h" 15 #include "vm/flags.h"
17 #include "vm/flow_graph_builder.h" 16 #include "vm/flow_graph_builder.h"
18 #include "vm/flow_graph_compiler.h" 17 #include "vm/flow_graph_compiler.h"
19 #include "vm/longjump.h" 18 #include "vm/longjump.h"
20 #include "vm/object.h" 19 #include "vm/object.h"
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
122 const char* function_fullname = function.ToFullyQualifiedCString(); 121 const char* function_fullname = function.ToFullyQualifiedCString();
123 if (FLAG_trace_compiler) { 122 if (FLAG_trace_compiler) {
124 OS::Print("Compiling %sfunction: '%s' @ token %d\n", 123 OS::Print("Compiling %sfunction: '%s' @ token %d\n",
125 (optimized ? "optimized " : ""), 124 (optimized ? "optimized " : ""),
126 function_fullname, 125 function_fullname,
127 function.token_index()); 126 function.token_index());
128 } 127 }
129 Parser::ParseFunction(&parsed_function); 128 Parser::ParseFunction(&parsed_function);
130 parsed_function.AllocateVariables(); 129 parsed_function.AllocateVariables();
131 130
132 CodeIndexTable* code_index_table = isolate->code_index_table();
133 ASSERT(code_index_table != NULL);
134 bool is_compiled = false; 131 bool is_compiled = false;
135 if (FLAG_use_new_compiler) { 132 if (FLAG_use_new_compiler) {
136 ASSERT(!optimized); 133 ASSERT(!optimized);
137 LongJump* old_base = isolate->long_jump_base(); 134 LongJump* old_base = isolate->long_jump_base();
138 LongJump bailout_jump; 135 LongJump bailout_jump;
139 isolate->set_long_jump_base(&bailout_jump); 136 isolate->set_long_jump_base(&bailout_jump);
140 if (setjmp(*bailout_jump.Set()) == 0) { 137 if (setjmp(*bailout_jump.Set()) == 0) {
141 FlowGraphBuilder graph_builder(parsed_function); 138 FlowGraphBuilder graph_builder(parsed_function);
142 graph_builder.BuildGraph(); 139 graph_builder.BuildGraph();
143 140
(...skipping 11 matching lines...) Expand all
155 graph_compiler.CompileGraph(); 152 graph_compiler.CompileGraph();
156 const Code& code = 153 const Code& code =
157 Code::Handle(Code::FinalizeCode(function_fullname, &assembler)); 154 Code::Handle(Code::FinalizeCode(function_fullname, &assembler));
158 code.set_is_optimized(false); 155 code.set_is_optimized(false);
159 graph_compiler.FinalizePcDescriptors(code); 156 graph_compiler.FinalizePcDescriptors(code);
160 graph_compiler.FinalizeVarDescriptors(code); 157 graph_compiler.FinalizeVarDescriptors(code);
161 graph_compiler.FinalizeExceptionHandlers(code); 158 graph_compiler.FinalizeExceptionHandlers(code);
162 function.set_unoptimized_code(code); 159 function.set_unoptimized_code(code);
163 function.SetCode(code); 160 function.SetCode(code);
164 ASSERT(CodePatcher::CodeIsPatchable(code)); 161 ASSERT(CodePatcher::CodeIsPatchable(code));
165 code_index_table->AddCode(code);
166 is_compiled = true; 162 is_compiled = true;
167 } else { 163 } else {
168 // We bailed out. 164 // We bailed out.
169 Error& bailout_error = Error::Handle( 165 Error& bailout_error = Error::Handle(
170 isolate->object_store()->sticky_error()); 166 isolate->object_store()->sticky_error());
171 isolate->object_store()->clear_sticky_error(); 167 isolate->object_store()->clear_sticky_error();
172 if (FLAG_trace_bailout) { 168 if (FLAG_trace_bailout) {
173 OS::Print("%s\n", bailout_error.ToErrorCString()); 169 OS::Print("%s\n", bailout_error.ToErrorCString());
174 } 170 }
175 } 171 }
(...skipping 17 matching lines...) Expand all
193 } 189 }
194 OptimizingCodeGenerator code_gen(&assembler, parsed_function); 190 OptimizingCodeGenerator code_gen(&assembler, parsed_function);
195 code_gen.GenerateCode(); 191 code_gen.GenerateCode();
196 Code& code = Code::Handle( 192 Code& code = Code::Handle(
197 Code::FinalizeCode(function_fullname, &assembler)); 193 Code::FinalizeCode(function_fullname, &assembler));
198 code.set_is_optimized(true); 194 code.set_is_optimized(true);
199 code_gen.FinalizePcDescriptors(code); 195 code_gen.FinalizePcDescriptors(code);
200 code_gen.FinalizeStackmaps(code); 196 code_gen.FinalizeStackmaps(code);
201 code_gen.FinalizeExceptionHandlers(code); 197 code_gen.FinalizeExceptionHandlers(code);
202 function.SetCode(code); 198 function.SetCode(code);
203 code_index_table->AddCode(code);
204 CodePatcher::PatchEntry(Code::Handle(function.unoptimized_code())); 199 CodePatcher::PatchEntry(Code::Handle(function.unoptimized_code()));
205 if (FLAG_trace_compiler) { 200 if (FLAG_trace_compiler) {
206 OS::Print("--> patching entry 0x%x\n", 201 OS::Print("--> patching entry 0x%x\n",
207 Code::Handle(function.unoptimized_code()).EntryPoint()); 202 Code::Handle(function.unoptimized_code()).EntryPoint());
208 } 203 }
209 } else { 204 } else {
210 // Unoptimized code. 205 // Unoptimized code.
211 if (Code::Handle(function.unoptimized_code()).IsNull()) { 206 if (Code::Handle(function.unoptimized_code()).IsNull()) {
212 ASSERT(!function.HasCode()); 207 ASSERT(!function.HasCode());
213 // Compiling first time. 208 // Compiling first time.
214 CodeGenerator code_gen(&assembler, parsed_function); 209 CodeGenerator code_gen(&assembler, parsed_function);
215 code_gen.GenerateCode(); 210 code_gen.GenerateCode();
216 const Code& code = 211 const Code& code =
217 Code::Handle(Code::FinalizeCode(function_fullname, &assembler)); 212 Code::Handle(Code::FinalizeCode(function_fullname, &assembler));
218 code.set_is_optimized(false); 213 code.set_is_optimized(false);
219 code_gen.FinalizePcDescriptors(code); 214 code_gen.FinalizePcDescriptors(code);
220 code_gen.FinalizeStackmaps(code); 215 code_gen.FinalizeStackmaps(code);
221 code_gen.FinalizeVarDescriptors(code); 216 code_gen.FinalizeVarDescriptors(code);
222 code_gen.FinalizeExceptionHandlers(code); 217 code_gen.FinalizeExceptionHandlers(code);
223 function.set_unoptimized_code(code); 218 function.set_unoptimized_code(code);
224 function.SetCode(code); 219 function.SetCode(code);
225 ASSERT(CodePatcher::CodeIsPatchable(code)); 220 ASSERT(CodePatcher::CodeIsPatchable(code));
226 code_index_table->AddCode(code);
227 } else { 221 } else {
228 // Disable optimized code. 222 // Disable optimized code.
229 ASSERT(function.HasOptimizedCode()); 223 ASSERT(function.HasOptimizedCode());
230 // Patch entry of optimized code. 224 // Patch entry of optimized code.
231 CodePatcher::PatchEntry(Code::Handle(function.CurrentCode())); 225 CodePatcher::PatchEntry(Code::Handle(function.CurrentCode()));
232 if (FLAG_trace_compiler) { 226 if (FLAG_trace_compiler) {
233 OS::Print("--> patching entry 0x%x\n", 227 OS::Print("--> patching entry 0x%x\n",
234 Code::Handle(function.CurrentCode()).EntryPoint()); 228 Code::Handle(function.CurrentCode()).EntryPoint());
235 } 229 }
236 // Use previously compiled code. 230 // Use previously compiled code.
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
371 ParsedFunction parsed_function(func); 365 ParsedFunction parsed_function(func);
372 parsed_function.set_node_sequence(fragment); 366 parsed_function.set_node_sequence(fragment);
373 parsed_function.set_default_parameter_values(Array::Handle()); 367 parsed_function.set_default_parameter_values(Array::Handle());
374 368
375 Assembler assembler; 369 Assembler assembler;
376 CodeGenerator code_gen(&assembler, parsed_function); 370 CodeGenerator code_gen(&assembler, parsed_function);
377 code_gen.GenerateCode(); 371 code_gen.GenerateCode();
378 const Code& code = Code::Handle(Code::FinalizeCode(kEvalConst, &assembler)); 372 const Code& code = Code::Handle(Code::FinalizeCode(kEvalConst, &assembler));
379 373
380 func.SetCode(code); 374 func.SetCode(code);
381 CodeIndexTable* code_index_table = isolate->code_index_table();
382 ASSERT(code_index_table != NULL);
383 code_index_table->AddCode(code);
384 // TODO(hausner): We need a way to remove these one-time execution
385 // functions from the global code description (PC mapping) tables so
386 // we don't pollute the system unnecessarily with stale data.
387 code_gen.FinalizePcDescriptors(code); 375 code_gen.FinalizePcDescriptors(code);
388 code_gen.FinalizeStackmaps(code); 376 code_gen.FinalizeStackmaps(code);
389 code_gen.FinalizeExceptionHandlers(code); 377 code_gen.FinalizeExceptionHandlers(code);
390 378
391 GrowableArray<const Object*> arguments; // no arguments. 379 GrowableArray<const Object*> arguments; // no arguments.
392 const Array& kNoArgumentNames = Array::Handle(); 380 const Array& kNoArgumentNames = Array::Handle();
393 result = DartEntry::InvokeStatic(func, 381 result = DartEntry::InvokeStatic(func,
394 arguments, 382 arguments,
395 kNoArgumentNames); 383 kNoArgumentNames);
396 } else { 384 } else {
397 result = isolate->object_store()->sticky_error(); 385 result = isolate->object_store()->sticky_error();
398 isolate->object_store()->clear_sticky_error(); 386 isolate->object_store()->clear_sticky_error();
399 } 387 }
400 isolate->set_long_jump_base(base); 388 isolate->set_long_jump_base(base);
401 return result.raw(); 389 return result.raw();
402 } 390 }
403 391
404 392
405 } // namespace dart 393 } // namespace dart
OLDNEW
« no previous file with comments | « vm/code_index_table_test.cc ('k') | vm/debugger.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698