| OLD | NEW |
| 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 196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 207 TimerScope timer(FLAG_compiler_stats, | 207 TimerScope timer(FLAG_compiler_stats, |
| 208 &CompilerStats::codefinalizer_timer, | 208 &CompilerStats::codefinalizer_timer, |
| 209 isolate); | 209 isolate); |
| 210 const Function& function = parsed_function.function(); | 210 const Function& function = parsed_function.function(); |
| 211 const Code& code = Code::Handle(Code::FinalizeCode(function, &assembler)); | 211 const Code& code = Code::Handle(Code::FinalizeCode(function, &assembler)); |
| 212 code.set_is_optimized(optimized); | 212 code.set_is_optimized(optimized); |
| 213 graph_compiler.FinalizePcDescriptors(code); | 213 graph_compiler.FinalizePcDescriptors(code); |
| 214 graph_compiler.FinalizeStackmaps(code); | 214 graph_compiler.FinalizeStackmaps(code); |
| 215 graph_compiler.FinalizeVarDescriptors(code); | 215 graph_compiler.FinalizeVarDescriptors(code); |
| 216 graph_compiler.FinalizeExceptionHandlers(code); | 216 graph_compiler.FinalizeExceptionHandlers(code); |
| 217 graph_compiler.FinalizeComments(code); |
| 217 if (optimized) { | 218 if (optimized) { |
| 218 function.SetCode(code); | 219 function.SetCode(code); |
| 219 CodePatcher::PatchEntry(Code::Handle(function.unoptimized_code())); | 220 CodePatcher::PatchEntry(Code::Handle(function.unoptimized_code())); |
| 220 if (FLAG_trace_compiler) { | 221 if (FLAG_trace_compiler) { |
| 221 OS::Print("--> patching entry 0x%x\n", | 222 OS::Print("--> patching entry 0x%x\n", |
| 222 Code::Handle(function.unoptimized_code()).EntryPoint()); | 223 Code::Handle(function.unoptimized_code()).EntryPoint()); |
| 223 } | 224 } |
| 224 } else { | 225 } else { |
| 225 function.set_unoptimized_code(code); | 226 function.set_unoptimized_code(code); |
| 226 function.SetCode(code); | 227 function.SetCode(code); |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 269 code_gen.GenerateCode(); | 270 code_gen.GenerateCode(); |
| 270 } | 271 } |
| 271 { | 272 { |
| 272 TimerScope timer(FLAG_compiler_stats, | 273 TimerScope timer(FLAG_compiler_stats, |
| 273 &CompilerStats::codefinalizer_timer); | 274 &CompilerStats::codefinalizer_timer); |
| 274 Code& code = Code::Handle(Code::FinalizeCode(function, &assembler)); | 275 Code& code = Code::Handle(Code::FinalizeCode(function, &assembler)); |
| 275 code.set_is_optimized(true); | 276 code.set_is_optimized(true); |
| 276 code_gen.FinalizePcDescriptors(code); | 277 code_gen.FinalizePcDescriptors(code); |
| 277 code_gen.FinalizeStackmaps(code); | 278 code_gen.FinalizeStackmaps(code); |
| 278 code_gen.FinalizeExceptionHandlers(code); | 279 code_gen.FinalizeExceptionHandlers(code); |
| 280 code_gen.FinalizeComments(code); |
| 279 function.SetCode(code); | 281 function.SetCode(code); |
| 280 CodePatcher::PatchEntry(Code::Handle(function.unoptimized_code())); | 282 CodePatcher::PatchEntry(Code::Handle(function.unoptimized_code())); |
| 281 } | 283 } |
| 282 if (FLAG_trace_compiler) { | 284 if (FLAG_trace_compiler) { |
| 283 OS::Print("--> patching entry 0x%x\n", | 285 OS::Print("--> patching entry 0x%x\n", |
| 284 Code::Handle(function.unoptimized_code()).EntryPoint()); | 286 Code::Handle(function.unoptimized_code()).EntryPoint()); |
| 285 } | 287 } |
| 286 } else { | 288 } else { |
| 287 // Compile unoptimized code. | 289 // Compile unoptimized code. |
| 288 ASSERT(!function.HasCode()); | 290 ASSERT(!function.HasCode()); |
| 289 // Compiling first time. | 291 // Compiling first time. |
| 290 CodeGenerator code_gen(&assembler, parsed_function); | 292 CodeGenerator code_gen(&assembler, parsed_function); |
| 291 { | 293 { |
| 292 TimerScope timer(FLAG_compiler_stats, | 294 TimerScope timer(FLAG_compiler_stats, |
| 293 &CompilerStats::graphcompiler_timer); | 295 &CompilerStats::graphcompiler_timer); |
| 294 code_gen.GenerateCode(); | 296 code_gen.GenerateCode(); |
| 295 } | 297 } |
| 296 { | 298 { |
| 297 TimerScope timer(FLAG_compiler_stats, | 299 TimerScope timer(FLAG_compiler_stats, |
| 298 &CompilerStats::codefinalizer_timer); | 300 &CompilerStats::codefinalizer_timer); |
| 299 const Code& code = Code::Handle(Code::FinalizeCode(function, &assembler)); | 301 const Code& code = Code::Handle(Code::FinalizeCode(function, &assembler)); |
| 300 code.set_is_optimized(false); | 302 code.set_is_optimized(false); |
| 301 code_gen.FinalizePcDescriptors(code); | 303 code_gen.FinalizePcDescriptors(code); |
| 302 code_gen.FinalizeStackmaps(code); | 304 code_gen.FinalizeStackmaps(code); |
| 303 code_gen.FinalizeVarDescriptors(code); | 305 code_gen.FinalizeVarDescriptors(code); |
| 304 code_gen.FinalizeExceptionHandlers(code); | 306 code_gen.FinalizeExceptionHandlers(code); |
| 307 code_gen.FinalizeComments(code); |
| 305 function.set_unoptimized_code(code); | 308 function.set_unoptimized_code(code); |
| 306 function.SetCode(code); | 309 function.SetCode(code); |
| 307 ASSERT(CodePatcher::CodeIsPatchable(code)); | 310 ASSERT(CodePatcher::CodeIsPatchable(code)); |
| 308 } | 311 } |
| 309 } | 312 } |
| 310 } | 313 } |
| 311 | 314 |
| 312 static void CompileParsedFunctionHelper( | 315 static void CompileParsedFunctionHelper( |
| 313 const ParsedFunction& parsed_function, bool optimized) { | 316 const ParsedFunction& parsed_function, bool optimized) { |
| 314 TimerScope timer(FLAG_compiler_stats, &CompilerStats::codegen_timer); | 317 TimerScope timer(FLAG_compiler_stats, &CompilerStats::codegen_timer); |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 365 } | 368 } |
| 366 if (FLAG_disassemble) { | 369 if (FLAG_disassemble) { |
| 367 const char* function_fullname = function.ToFullyQualifiedCString(); | 370 const char* function_fullname = function.ToFullyQualifiedCString(); |
| 368 OS::Print("Code for %sfunction '%s' {\n", | 371 OS::Print("Code for %sfunction '%s' {\n", |
| 369 optimized ? "optimized " : "", | 372 optimized ? "optimized " : "", |
| 370 function_fullname); | 373 function_fullname); |
| 371 const Code& code = Code::Handle(function.CurrentCode()); | 374 const Code& code = Code::Handle(function.CurrentCode()); |
| 372 const Instructions& instructions = | 375 const Instructions& instructions = |
| 373 Instructions::Handle(code.instructions()); | 376 Instructions::Handle(code.instructions()); |
| 374 uword start = instructions.EntryPoint(); | 377 uword start = instructions.EntryPoint(); |
| 375 Disassembler::Disassemble(start, start + instructions.size()); | 378 Disassembler::Disassemble(start, |
| 379 start + instructions.size(), |
| 380 code.comments()); |
| 376 OS::Print("}\n"); | 381 OS::Print("}\n"); |
| 377 OS::Print("Pointer offsets for function: {\n"); | 382 OS::Print("Pointer offsets for function: {\n"); |
| 378 for (intptr_t i = 0; i < code.pointer_offsets_length(); i++) { | 383 for (intptr_t i = 0; i < code.pointer_offsets_length(); i++) { |
| 379 const uword addr = code.GetPointerOffsetAt(i) + code.EntryPoint(); | 384 const uword addr = code.GetPointerOffsetAt(i) + code.EntryPoint(); |
| 380 Object& obj = Object::Handle(); | 385 Object& obj = Object::Handle(); |
| 381 obj = *reinterpret_cast<RawObject**>(addr); | 386 obj = *reinterpret_cast<RawObject**>(addr); |
| 382 OS::Print(" %d : 0x%x '%s'\n", | 387 OS::Print(" %d : 0x%x '%s'\n", |
| 383 code.GetPointerOffsetAt(i), addr, obj.ToCString()); | 388 code.GetPointerOffsetAt(i), addr, obj.ToCString()); |
| 384 } | 389 } |
| 385 OS::Print("}\n"); | 390 OS::Print("}\n"); |
| (...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 533 isolate->object_store()->clear_sticky_error(); | 538 isolate->object_store()->clear_sticky_error(); |
| 534 isolate->set_long_jump_base(base); | 539 isolate->set_long_jump_base(base); |
| 535 return result.raw(); | 540 return result.raw(); |
| 536 } | 541 } |
| 537 UNREACHABLE(); | 542 UNREACHABLE(); |
| 538 return Object::null(); | 543 return Object::null(); |
| 539 } | 544 } |
| 540 | 545 |
| 541 | 546 |
| 542 } // namespace dart | 547 } // namespace dart |
| OLD | NEW |