OLD | NEW |
1 // Copyright 2006-2008 the V8 project authors. All rights reserved. | 1 // Copyright 2006-2008 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 514 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
525 HandleScope scope; | 525 HandleScope scope; |
526 Object* receiver = this->receiver(); | 526 Object* receiver = this->receiver(); |
527 Object* function = this->function(); | 527 Object* function = this->function(); |
528 | 528 |
529 accumulator->PrintSecurityTokenIfChanged(function); | 529 accumulator->PrintSecurityTokenIfChanged(function); |
530 PrintIndex(accumulator, mode, index); | 530 PrintIndex(accumulator, mode, index); |
531 Code* code = NULL; | 531 Code* code = NULL; |
532 if (IsConstructor()) accumulator->Add("new "); | 532 if (IsConstructor()) accumulator->Add("new "); |
533 accumulator->PrintFunction(function, receiver, &code); | 533 accumulator->PrintFunction(function, receiver, &code); |
534 | 534 |
| 535 Handle<Object> scope_info(ScopeInfo<>::EmptyHeapObject()); |
| 536 |
535 if (function->IsJSFunction()) { | 537 if (function->IsJSFunction()) { |
536 Handle<SharedFunctionInfo> shared(JSFunction::cast(function)->shared()); | 538 Handle<SharedFunctionInfo> shared(JSFunction::cast(function)->shared()); |
| 539 scope_info = Handle<Object>(shared->scope_info()); |
537 Object* script_obj = shared->script(); | 540 Object* script_obj = shared->script(); |
538 if (script_obj->IsScript()) { | 541 if (script_obj->IsScript()) { |
539 Handle<Script> script(Script::cast(script_obj)); | 542 Handle<Script> script(Script::cast(script_obj)); |
540 accumulator->Add(" ["); | 543 accumulator->Add(" ["); |
541 accumulator->PrintName(script->name()); | 544 accumulator->PrintName(script->name()); |
542 | 545 |
543 Address pc = this->pc(); | 546 Address pc = this->pc(); |
544 if (code != NULL && code->kind() == Code::FUNCTION && | 547 if (code != NULL && code->kind() == Code::FUNCTION && |
545 pc >= code->instruction_start() && pc < code->instruction_end()) { | 548 pc >= code->instruction_start() && pc < code->instruction_end()) { |
546 int source_pos = code->SourcePosition(pc); | 549 int source_pos = code->SourcePosition(pc); |
547 int line = GetScriptLineNumberSafe(script, source_pos) + 1; | 550 int line = GetScriptLineNumberSafe(script, source_pos) + 1; |
548 accumulator->Add(":%d", line); | 551 accumulator->Add(":%d", line); |
549 } else { | 552 } else { |
550 int function_start_pos = shared->start_position(); | 553 int function_start_pos = shared->start_position(); |
551 int line = GetScriptLineNumberSafe(script, function_start_pos) + 1; | 554 int line = GetScriptLineNumberSafe(script, function_start_pos) + 1; |
552 accumulator->Add(":~%d", line); | 555 accumulator->Add(":~%d", line); |
553 } | 556 } |
554 | 557 |
555 accumulator->Add("] "); | 558 accumulator->Add("] "); |
556 } | 559 } |
557 } | 560 } |
558 | 561 |
559 accumulator->Add("(this=%o", receiver); | 562 accumulator->Add("(this=%o", receiver); |
560 | 563 |
561 // Get scope information for nicer output, if possible. If code is | 564 // Get scope information for nicer output, if possible. If code is |
562 // NULL, or doesn't contain scope info, info will return 0 for the | 565 // NULL, or doesn't contain scope info, info will return 0 for the |
563 // number of parameters, stack slots, or context slots. | 566 // number of parameters, stack slots, or context slots. |
564 ScopeInfo<PreallocatedStorage> info(code); | 567 ScopeInfo<PreallocatedStorage> info(*scope_info); |
565 | 568 |
566 // Print the parameters. | 569 // Print the parameters. |
567 int parameters_count = ComputeParametersCount(); | 570 int parameters_count = ComputeParametersCount(); |
568 for (int i = 0; i < parameters_count; i++) { | 571 for (int i = 0; i < parameters_count; i++) { |
569 accumulator->Add(","); | 572 accumulator->Add(","); |
570 // If we have a name for the parameter we print it. Nameless | 573 // If we have a name for the parameter we print it. Nameless |
571 // parameters are either because we have more actual parameters | 574 // parameters are either because we have more actual parameters |
572 // than formal parameters or because we have no scope information. | 575 // than formal parameters or because we have no scope information. |
573 if (i < info.number_of_parameters()) { | 576 if (i < info.number_of_parameters()) { |
574 accumulator->PrintName(*info.parameter_name(i)); | 577 accumulator->PrintName(*info.parameter_name(i)); |
(...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
814 ZoneList<StackFrame*> list(10); | 817 ZoneList<StackFrame*> list(10); |
815 for (StackFrameIterator it; !it.done(); it.Advance()) { | 818 for (StackFrameIterator it; !it.done(); it.Advance()) { |
816 StackFrame* frame = AllocateFrameCopy(it.frame()); | 819 StackFrame* frame = AllocateFrameCopy(it.frame()); |
817 list.Add(frame); | 820 list.Add(frame); |
818 } | 821 } |
819 return list.ToVector(); | 822 return list.ToVector(); |
820 } | 823 } |
821 | 824 |
822 | 825 |
823 } } // namespace v8::internal | 826 } } // namespace v8::internal |
OLD | NEW |