| 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 294 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 305 function_fullname); | 305 function_fullname); |
| 306 const Code& code = Code::Handle(function.CurrentCode()); | 306 const Code& code = Code::Handle(function.CurrentCode()); |
| 307 const Instructions& instructions = | 307 const Instructions& instructions = |
| 308 Instructions::Handle(code.instructions()); | 308 Instructions::Handle(code.instructions()); |
| 309 uword start = instructions.EntryPoint(); | 309 uword start = instructions.EntryPoint(); |
| 310 Disassembler::Disassemble(start, | 310 Disassembler::Disassemble(start, |
| 311 start + instructions.size(), | 311 start + instructions.size(), |
| 312 code.comments()); | 312 code.comments()); |
| 313 OS::Print("}\n"); | 313 OS::Print("}\n"); |
| 314 OS::Print("Pointer offsets for function: {\n"); | 314 OS::Print("Pointer offsets for function: {\n"); |
| 315 for (intptr_t i = 0; i < code.pointer_offsets_length(); i++) { | 315 // Pointer offsets are stored in descending order. |
| 316 for (intptr_t i = code.pointer_offsets_length() - 1; i >= 0; i--) { |
| 316 const uword addr = code.GetPointerOffsetAt(i) + code.EntryPoint(); | 317 const uword addr = code.GetPointerOffsetAt(i) + code.EntryPoint(); |
| 317 Object& obj = Object::Handle(); | 318 Object& obj = Object::Handle(); |
| 318 obj = *reinterpret_cast<RawObject**>(addr); | 319 obj = *reinterpret_cast<RawObject**>(addr); |
| 319 OS::Print(" %d : 0x%x '%s'\n", | 320 OS::Print(" %" PRIdPTR " : 0x%" PRIxPTR " '%s'\n", |
| 320 code.GetPointerOffsetAt(i), addr, obj.ToCString()); | 321 code.GetPointerOffsetAt(i), addr, obj.ToCString()); |
| 321 } | 322 } |
| 322 OS::Print("}\n"); | 323 OS::Print("}\n"); |
| 323 OS::Print("PC Descriptors for function '%s' {\n", function_fullname); | 324 OS::Print("PC Descriptors for function '%s' {\n", function_fullname); |
| 324 OS::Print("(pc\t\tkind\tid\ttry-ix\ttoken-index)\n"); | 325 OS::Print("pc\t\tkind\tid\ttry-ix\ttoken-index\n"); |
| 325 const PcDescriptors& descriptors = | 326 const PcDescriptors& descriptors = |
| 326 PcDescriptors::Handle(code.pc_descriptors()); | 327 PcDescriptors::Handle(code.pc_descriptors()); |
| 327 OS::Print("%s", descriptors.ToCString()); | 328 OS::Print("%s}\n", descriptors.ToCString()); |
| 328 OS::Print("}\n"); | |
| 329 OS::Print("Variable Descriptors for function '%s' {\n", | 329 OS::Print("Variable Descriptors for function '%s' {\n", |
| 330 function_fullname); | 330 function_fullname); |
| 331 const LocalVarDescriptors& var_descriptors = | 331 const LocalVarDescriptors& var_descriptors = |
| 332 LocalVarDescriptors::Handle(code.var_descriptors()); | 332 LocalVarDescriptors::Handle(code.var_descriptors()); |
| 333 intptr_t var_desc_length = | 333 intptr_t var_desc_length = |
| 334 var_descriptors.IsNull() ? 0 : var_descriptors.Length(); | 334 var_descriptors.IsNull() ? 0 : var_descriptors.Length(); |
| 335 String& var_name = String::Handle(); | 335 String& var_name = String::Handle(); |
| 336 for (intptr_t i = 0; i < var_desc_length; i++) { | 336 for (intptr_t i = 0; i < var_desc_length; i++) { |
| 337 var_name = var_descriptors.GetName(i); | 337 var_name = var_descriptors.GetName(i); |
| 338 RawLocalVarDescriptors::VarInfo var_info; | 338 RawLocalVarDescriptors::VarInfo var_info; |
| 339 var_descriptors.GetInfo(i, &var_info); | 339 var_descriptors.GetInfo(i, &var_info); |
| 340 if (var_info.kind == RawLocalVarDescriptors::kContextLevel) { | 340 if (var_info.kind == RawLocalVarDescriptors::kContextChain) { |
| 341 OS::Print(" context level %d scope %d (valid %d-%d)\n", | 341 OS::Print(" saved CTX reg offset %" PRIdPTR "\n", var_info.index); |
| 342 var_info.index, | 342 } else { |
| 343 var_info.scope_id, | 343 if (var_info.kind == RawLocalVarDescriptors::kContextLevel) { |
| 344 var_info.begin_pos, | 344 OS::Print(" context level %" PRIdPTR " scope %d", |
| 345 var_info.end_pos); | 345 var_info.index, var_info.scope_id); |
| 346 } else if (var_info.kind == RawLocalVarDescriptors::kContextChain) { | 346 } else if (var_info.kind == RawLocalVarDescriptors::kStackVar) { |
| 347 OS::Print(" saved CTX reg offset %d\n", var_info.index); | 347 OS::Print(" stack var '%s' offset %" PRIdPTR, |
| 348 } else if (var_info.kind == RawLocalVarDescriptors::kStackVar) { | 348 var_name.ToCString(), var_info.index); |
| 349 OS::Print(" stack var '%s' offset %d (valid %d-%d) \n", | 349 } else { |
| 350 var_name.ToCString(), | 350 ASSERT(var_info.kind == RawLocalVarDescriptors::kContextVar); |
| 351 var_info.index, | 351 OS::Print(" context var '%s' level %d offset %" PRIdPTR, |
| 352 var_info.begin_pos, | 352 var_name.ToCString(), var_info.scope_id, var_info.index); |
| 353 var_info.end_pos); | 353 } |
| 354 } else if (var_info.kind == RawLocalVarDescriptors::kContextVar) { | 354 OS::Print(" (valid %" PRIdPTR "-%" PRIdPTR ")\n", |
| 355 OS::Print(" context var '%s' level %d offset %d (valid %d-%d)\n", | 355 var_info.begin_pos, var_info.end_pos); |
| 356 var_name.ToCString(), | |
| 357 var_info.scope_id, | |
| 358 var_info.index, | |
| 359 var_info.begin_pos, | |
| 360 var_info.end_pos); | |
| 361 } | 356 } |
| 362 } | 357 } |
| 363 OS::Print("}\n"); | 358 OS::Print("}\n"); |
| 364 OS::Print("Exception Handlers for function '%s' {\n", function_fullname); | 359 OS::Print("Exception Handlers for function '%s' {\n", function_fullname); |
| 365 const ExceptionHandlers& handlers = | 360 const ExceptionHandlers& handlers = |
| 366 ExceptionHandlers::Handle(code.exception_handlers()); | 361 ExceptionHandlers::Handle(code.exception_handlers()); |
| 367 OS::Print("%s", handlers.ToCString()); | 362 OS::Print("%s}\n", handlers.ToCString()); |
| 368 OS::Print("}\n"); | |
| 369 } | 363 } |
| 370 isolate->set_long_jump_base(base); | 364 isolate->set_long_jump_base(base); |
| 371 return Error::null(); | 365 return Error::null(); |
| 372 } else { | 366 } else { |
| 373 Error& error = Error::Handle(); | 367 Error& error = Error::Handle(); |
| 374 // We got an error during compilation. | 368 // We got an error during compilation. |
| 375 error = isolate->object_store()->sticky_error(); | 369 error = isolate->object_store()->sticky_error(); |
| 376 isolate->object_store()->clear_sticky_error(); | 370 isolate->object_store()->clear_sticky_error(); |
| 377 isolate->set_long_jump_base(base); | 371 isolate->set_long_jump_base(base); |
| 378 return error.raw(); | 372 return error.raw(); |
| (...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 491 isolate->object_store()->clear_sticky_error(); | 485 isolate->object_store()->clear_sticky_error(); |
| 492 isolate->set_long_jump_base(base); | 486 isolate->set_long_jump_base(base); |
| 493 return result.raw(); | 487 return result.raw(); |
| 494 } | 488 } |
| 495 UNREACHABLE(); | 489 UNREACHABLE(); |
| 496 return Object::null(); | 490 return Object::null(); |
| 497 } | 491 } |
| 498 | 492 |
| 499 | 493 |
| 500 } // namespace dart | 494 } // namespace dart |
| OLD | NEW |