| 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 198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 209 isolate); | 209 isolate); |
| 210 graph_compiler.CompileGraph(); | 210 graph_compiler.CompileGraph(); |
| 211 } | 211 } |
| 212 { | 212 { |
| 213 TimerScope timer(FLAG_compiler_stats, | 213 TimerScope timer(FLAG_compiler_stats, |
| 214 &CompilerStats::codefinalizer_timer, | 214 &CompilerStats::codefinalizer_timer, |
| 215 isolate); | 215 isolate); |
| 216 const Function& function = parsed_function.function(); | 216 const Function& function = parsed_function.function(); |
| 217 const Code& code = Code::Handle(Code::FinalizeCode(function, &assembler)); | 217 const Code& code = Code::Handle(Code::FinalizeCode(function, &assembler)); |
| 218 code.set_is_optimized(optimized); | 218 code.set_is_optimized(optimized); |
| 219 if (optimized && use_ssa) { |
| 220 code.set_spill_slot_count(graph_compiler.StackSize()); |
| 221 } |
| 219 graph_compiler.FinalizePcDescriptors(code); | 222 graph_compiler.FinalizePcDescriptors(code); |
| 220 graph_compiler.FinalizeDeoptInfo(code); | 223 graph_compiler.FinalizeDeoptInfo(code); |
| 221 graph_compiler.FinalizeStackmaps(code); | 224 graph_compiler.FinalizeStackmaps(code); |
| 222 graph_compiler.FinalizeVarDescriptors(code); | 225 graph_compiler.FinalizeVarDescriptors(code); |
| 223 graph_compiler.FinalizeExceptionHandlers(code); | 226 graph_compiler.FinalizeExceptionHandlers(code); |
| 224 graph_compiler.FinalizeComments(code); | 227 graph_compiler.FinalizeComments(code); |
| 225 if (optimized) { | 228 if (optimized) { |
| 226 function.SetCode(code); | 229 function.SetCode(code); |
| 227 CodePatcher::PatchEntry(Code::Handle(function.unoptimized_code())); | 230 CodePatcher::PatchEntry(Code::Handle(function.unoptimized_code())); |
| 228 if (FLAG_trace_compiler) { | 231 if (FLAG_trace_compiler) { |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 305 optimized ? "optimized " : "", | 308 optimized ? "optimized " : "", |
| 306 function_fullname); | 309 function_fullname); |
| 307 const Code& code = Code::Handle(function.CurrentCode()); | 310 const Code& code = Code::Handle(function.CurrentCode()); |
| 308 const Instructions& instructions = | 311 const Instructions& instructions = |
| 309 Instructions::Handle(code.instructions()); | 312 Instructions::Handle(code.instructions()); |
| 310 uword start = instructions.EntryPoint(); | 313 uword start = instructions.EntryPoint(); |
| 311 Disassembler::Disassemble(start, | 314 Disassembler::Disassemble(start, |
| 312 start + instructions.size(), | 315 start + instructions.size(), |
| 313 code.comments()); | 316 code.comments()); |
| 314 OS::Print("}\n"); | 317 OS::Print("}\n"); |
| 318 |
| 315 OS::Print("Pointer offsets for function: {\n"); | 319 OS::Print("Pointer offsets for function: {\n"); |
| 316 // Pointer offsets are stored in descending order. | 320 // Pointer offsets are stored in descending order. |
| 317 for (intptr_t i = code.pointer_offsets_length() - 1; i >= 0; i--) { | 321 for (intptr_t i = code.pointer_offsets_length() - 1; i >= 0; i--) { |
| 318 const uword addr = code.GetPointerOffsetAt(i) + code.EntryPoint(); | 322 const uword addr = code.GetPointerOffsetAt(i) + code.EntryPoint(); |
| 319 Object& obj = Object::Handle(); | 323 Object& obj = Object::Handle(); |
| 320 obj = *reinterpret_cast<RawObject**>(addr); | 324 obj = *reinterpret_cast<RawObject**>(addr); |
| 321 OS::Print(" %" PRIdPTR " : 0x%" PRIxPTR " '%s'\n", | 325 OS::Print(" %" PRIdPTR " : 0x%" PRIxPTR " '%s'\n", |
| 322 code.GetPointerOffsetAt(i), addr, obj.ToCString()); | 326 code.GetPointerOffsetAt(i), addr, obj.ToCString()); |
| 323 } | 327 } |
| 324 OS::Print("}\n"); | 328 OS::Print("}\n"); |
| 329 |
| 325 OS::Print("PC Descriptors for function '%s' {\n", function_fullname); | 330 OS::Print("PC Descriptors for function '%s' {\n", function_fullname); |
| 326 OS::Print("(pc\t\tkind\t\tid\ttok-ix\ttry/deopt-ix)\n"); | 331 PcDescriptors::PrintHeaderString(); |
| 327 const PcDescriptors& descriptors = | 332 const PcDescriptors& descriptors = |
| 328 PcDescriptors::Handle(code.pc_descriptors()); | 333 PcDescriptors::Handle(code.pc_descriptors()); |
| 329 OS::Print("%s\n", descriptors.ToCString()); | 334 OS::Print("%s\n}\n", descriptors.ToCString()); |
| 330 OS::Print("}\n"); | 335 |
| 331 const Array& deopt_info_array = Array::Handle(code.deopt_info_array()); | 336 const Array& deopt_info_array = Array::Handle(code.deopt_info_array()); |
| 332 if (deopt_info_array.Length() > 0) { | 337 if (deopt_info_array.Length() > 0) { |
| 333 OS::Print("DeoptInfo: {\n"); | 338 OS::Print("DeoptInfo: {\n"); |
| 334 for (intptr_t i = 0; i < deopt_info_array.Length(); i++) { | 339 for (intptr_t i = 0; i < deopt_info_array.Length(); i++) { |
| 335 OS::Print(" %d: %s\n", | 340 OS::Print(" %d: %s\n", |
| 336 i, Object::Handle(deopt_info_array.At(i)).ToCString()); | 341 i, Object::Handle(deopt_info_array.At(i)).ToCString()); |
| 337 } | 342 } |
| 338 OS::Print("}\n"); | 343 OS::Print("}\n"); |
| 339 } | 344 } |
| 345 |
| 340 const Array& object_table = Array::Handle(code.object_table()); | 346 const Array& object_table = Array::Handle(code.object_table()); |
| 341 if (object_table.Length() > 0) { | 347 if (object_table.Length() > 0) { |
| 342 OS::Print("Object Table: {\n"); | 348 OS::Print("Object Table: {\n"); |
| 343 for (intptr_t i = 0; i < object_table.Length(); i++) { | 349 for (intptr_t i = 0; i < object_table.Length(); i++) { |
| 344 OS::Print(" %d: %s\n", i, | 350 OS::Print(" %d: %s\n", i, |
| 345 Object::Handle(object_table.At(i)).ToCString()); | 351 Object::Handle(object_table.At(i)).ToCString()); |
| 346 } | 352 } |
| 347 OS::Print("}\n"); | 353 OS::Print("}\n"); |
| 348 } | 354 } |
| 355 |
| 356 OS::Print("Stackmaps for function '%s' {\n", function_fullname); |
| 357 if (code.stackmaps() != Array::null()) { |
| 358 const Array& stackmap_table = Array::Handle(code.stackmaps()); |
| 359 Stackmap& map = Stackmap::Handle(); |
| 360 for (intptr_t i = 0; i < stackmap_table.Length(); ++i) { |
| 361 map ^= stackmap_table.At(i); |
| 362 OS::Print("%s\n", map.ToCString()); |
| 363 } |
| 364 } |
| 365 OS::Print("}\n"); |
| 366 |
| 349 OS::Print("Variable Descriptors for function '%s' {\n", | 367 OS::Print("Variable Descriptors for function '%s' {\n", |
| 350 function_fullname); | 368 function_fullname); |
| 351 const LocalVarDescriptors& var_descriptors = | 369 const LocalVarDescriptors& var_descriptors = |
| 352 LocalVarDescriptors::Handle(code.var_descriptors()); | 370 LocalVarDescriptors::Handle(code.var_descriptors()); |
| 353 intptr_t var_desc_length = | 371 intptr_t var_desc_length = |
| 354 var_descriptors.IsNull() ? 0 : var_descriptors.Length(); | 372 var_descriptors.IsNull() ? 0 : var_descriptors.Length(); |
| 355 String& var_name = String::Handle(); | 373 String& var_name = String::Handle(); |
| 356 for (intptr_t i = 0; i < var_desc_length; i++) { | 374 for (intptr_t i = 0; i < var_desc_length; i++) { |
| 357 var_name = var_descriptors.GetName(i); | 375 var_name = var_descriptors.GetName(i); |
| 358 RawLocalVarDescriptors::VarInfo var_info; | 376 RawLocalVarDescriptors::VarInfo var_info; |
| (...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 505 result = isolate->object_store()->sticky_error(); | 523 result = isolate->object_store()->sticky_error(); |
| 506 isolate->object_store()->clear_sticky_error(); | 524 isolate->object_store()->clear_sticky_error(); |
| 507 isolate->set_long_jump_base(base); | 525 isolate->set_long_jump_base(base); |
| 508 return result.raw(); | 526 return result.raw(); |
| 509 } | 527 } |
| 510 UNREACHABLE(); | 528 UNREACHABLE(); |
| 511 return Object::null(); | 529 return Object::null(); |
| 512 } | 530 } |
| 513 | 531 |
| 514 } // namespace dart | 532 } // namespace dart |
| OLD | NEW |