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