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 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
82 | 82 |
83 | 83 |
84 char* Isolate::Iterate(ObjectVisitor* v, char* thread_storage) { | 84 char* Isolate::Iterate(ObjectVisitor* v, char* thread_storage) { |
85 ThreadLocalTop* thread = reinterpret_cast<ThreadLocalTop*>(thread_storage); | 85 ThreadLocalTop* thread = reinterpret_cast<ThreadLocalTop*>(thread_storage); |
86 Iterate(v, thread); | 86 Iterate(v, thread); |
87 return thread_storage + sizeof(ThreadLocalTop); | 87 return thread_storage + sizeof(ThreadLocalTop); |
88 } | 88 } |
89 | 89 |
90 | 90 |
91 void Isolate::IterateThread(ThreadVisitor* v) { | 91 void Isolate::IterateThread(ThreadVisitor* v) { |
92 v->VisitThread(thread_local_top()); | 92 v->VisitThread(this, thread_local_top()); |
93 } | 93 } |
94 | 94 |
95 | 95 |
96 void Isolate::IterateThread(ThreadVisitor* v, char* t) { | 96 void Isolate::IterateThread(ThreadVisitor* v, char* t) { |
97 ThreadLocalTop* thread = reinterpret_cast<ThreadLocalTop*>(t); | 97 ThreadLocalTop* thread = reinterpret_cast<ThreadLocalTop*>(t); |
98 v->VisitThread(thread); | 98 v->VisitThread(this, thread); |
99 } | 99 } |
100 | 100 |
101 | 101 |
102 void Isolate::Iterate(ObjectVisitor* v, ThreadLocalTop* thread) { | 102 void Isolate::Iterate(ObjectVisitor* v, ThreadLocalTop* thread) { |
103 // Visit the roots from the top for a given thread. | 103 // Visit the roots from the top for a given thread. |
104 Object* pending; | 104 Object* pending; |
105 // The pending exception can sometimes be a failure. We can't show | 105 // The pending exception can sometimes be a failure. We can't show |
106 // that to the GC, which only understands objects. | 106 // that to the GC, which only understands objects. |
107 if (thread->pending_exception_->ToObject(&pending)) { | 107 if (thread->pending_exception_->ToObject(&pending)) { |
108 v->VisitPointer(&pending); | 108 v->VisitPointer(&pending); |
109 thread->pending_exception_ = pending; // In case GC updated it. | 109 thread->pending_exception_ = pending; // In case GC updated it. |
110 } | 110 } |
111 v->VisitPointer(&(thread->pending_message_obj_)); | 111 v->VisitPointer(&(thread->pending_message_obj_)); |
112 v->VisitPointer(BitCast<Object**>(&(thread->pending_message_script_))); | 112 v->VisitPointer(BitCast<Object**>(&(thread->pending_message_script_))); |
113 v->VisitPointer(BitCast<Object**>(&(thread->context_))); | 113 v->VisitPointer(BitCast<Object**>(&(thread->context_))); |
114 Object* scheduled; | 114 Object* scheduled; |
115 if (thread->scheduled_exception_->ToObject(&scheduled)) { | 115 if (thread->scheduled_exception_->ToObject(&scheduled)) { |
116 v->VisitPointer(&scheduled); | 116 v->VisitPointer(&scheduled); |
117 thread->scheduled_exception_ = scheduled; | 117 thread->scheduled_exception_ = scheduled; |
118 } | 118 } |
119 | 119 |
120 for (v8::TryCatch* block = thread->TryCatchHandler(); | 120 for (v8::TryCatch* block = thread->TryCatchHandler(); |
121 block != NULL; | 121 block != NULL; |
122 block = TRY_CATCH_FROM_ADDRESS(block->next_)) { | 122 block = TRY_CATCH_FROM_ADDRESS(block->next_)) { |
123 v->VisitPointer(BitCast<Object**>(&(block->exception_))); | 123 v->VisitPointer(BitCast<Object**>(&(block->exception_))); |
124 v->VisitPointer(BitCast<Object**>(&(block->message_))); | 124 v->VisitPointer(BitCast<Object**>(&(block->message_))); |
125 } | 125 } |
126 | 126 |
127 // Iterate over pointers on native execution stack. | 127 // Iterate over pointers on native execution stack. |
128 for (StackFrameIterator it(thread); !it.done(); it.Advance()) { | 128 for (StackFrameIterator it(this, thread); !it.done(); it.Advance()) { |
129 it.frame()->Iterate(v); | 129 it.frame()->Iterate(v); |
130 } | 130 } |
131 } | 131 } |
132 | 132 |
133 | 133 |
134 void Isolate::Iterate(ObjectVisitor* v) { | 134 void Isolate::Iterate(ObjectVisitor* v) { |
135 ThreadLocalTop* current_t = thread_local_top(); | 135 ThreadLocalTop* current_t = thread_local_top(); |
136 Iterate(v, current_t); | 136 Iterate(v, current_t); |
137 } | 137 } |
138 | 138 |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
197 Handle<String> script_key = factory()->LookupAsciiSymbol("scriptName"); | 197 Handle<String> script_key = factory()->LookupAsciiSymbol("scriptName"); |
198 Handle<String> name_or_source_url_key = | 198 Handle<String> name_or_source_url_key = |
199 factory()->LookupAsciiSymbol("nameOrSourceURL"); | 199 factory()->LookupAsciiSymbol("nameOrSourceURL"); |
200 Handle<String> script_name_or_source_url_key = | 200 Handle<String> script_name_or_source_url_key = |
201 factory()->LookupAsciiSymbol("scriptNameOrSourceURL"); | 201 factory()->LookupAsciiSymbol("scriptNameOrSourceURL"); |
202 Handle<String> function_key = factory()->LookupAsciiSymbol("functionName"); | 202 Handle<String> function_key = factory()->LookupAsciiSymbol("functionName"); |
203 Handle<String> eval_key = factory()->LookupAsciiSymbol("isEval"); | 203 Handle<String> eval_key = factory()->LookupAsciiSymbol("isEval"); |
204 Handle<String> constructor_key = | 204 Handle<String> constructor_key = |
205 factory()->LookupAsciiSymbol("isConstructor"); | 205 factory()->LookupAsciiSymbol("isConstructor"); |
206 | 206 |
207 StackTraceFrameIterator it; | 207 StackTraceFrameIterator it(this); |
208 int frames_seen = 0; | 208 int frames_seen = 0; |
209 while (!it.done() && (frames_seen < limit)) { | 209 while (!it.done() && (frames_seen < limit)) { |
210 JavaScriptFrame* frame = it.frame(); | 210 JavaScriptFrame* frame = it.frame(); |
211 | 211 |
212 List<FrameSummary> frames(3); // Max 2 levels of inlining. | 212 List<FrameSummary> frames(3); // Max 2 levels of inlining. |
213 frame->Summarize(&frames); | 213 frame->Summarize(&frames); |
214 for (int i = frames.length() - 1; i >= 0 && frames_seen < limit; i--) { | 214 for (int i = frames.length() - 1; i >= 0 && frames_seen < limit; i--) { |
215 // Create a JSObject to hold the information for the StackFrame. | 215 // Create a JSObject to hold the information for the StackFrame. |
216 Handle<JSObject> stackFrame = factory()->NewJSObject(object_function()); | 216 Handle<JSObject> stackFrame = factory()->NewJSObject(object_function()); |
217 | 217 |
(...skipping 359 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
577 | 577 |
578 Failure* Isolate::PromoteScheduledException() { | 578 Failure* Isolate::PromoteScheduledException() { |
579 MaybeObject* thrown = scheduled_exception(); | 579 MaybeObject* thrown = scheduled_exception(); |
580 clear_scheduled_exception(); | 580 clear_scheduled_exception(); |
581 // Re-throw the exception to avoid getting repeated error reporting. | 581 // Re-throw the exception to avoid getting repeated error reporting. |
582 return ReThrow(thrown); | 582 return ReThrow(thrown); |
583 } | 583 } |
584 | 584 |
585 | 585 |
586 void Isolate::PrintCurrentStackTrace(FILE* out) { | 586 void Isolate::PrintCurrentStackTrace(FILE* out) { |
587 StackTraceFrameIterator it; | 587 StackTraceFrameIterator it(this); |
588 while (!it.done()) { | 588 while (!it.done()) { |
589 HandleScope scope; | 589 HandleScope scope; |
590 // Find code position if recorded in relocation info. | 590 // Find code position if recorded in relocation info. |
591 JavaScriptFrame* frame = it.frame(); | 591 JavaScriptFrame* frame = it.frame(); |
592 int pos = frame->LookupCode(this)->SourcePosition(frame->pc()); | 592 int pos = frame->LookupCode()->SourcePosition(frame->pc()); |
593 Handle<Object> pos_obj(Smi::FromInt(pos)); | 593 Handle<Object> pos_obj(Smi::FromInt(pos)); |
594 // Fetch function and receiver. | 594 // Fetch function and receiver. |
595 Handle<JSFunction> fun(JSFunction::cast(frame->function())); | 595 Handle<JSFunction> fun(JSFunction::cast(frame->function())); |
596 Handle<Object> recv(frame->receiver()); | 596 Handle<Object> recv(frame->receiver()); |
597 // Advance to the next JavaScript frame and determine if the | 597 // Advance to the next JavaScript frame and determine if the |
598 // current frame is the top-level frame. | 598 // current frame is the top-level frame. |
599 it.Advance(); | 599 it.Advance(); |
600 Handle<Object> is_top_level = it.done() | 600 Handle<Object> is_top_level = it.done() |
601 ? factory()->true_value() | 601 ? factory()->true_value() |
602 : factory()->false_value(); | 602 : factory()->false_value(); |
603 // Generate and print stack trace line. | 603 // Generate and print stack trace line. |
604 Handle<String> line = | 604 Handle<String> line = |
605 Execution::GetStackTraceLine(recv, fun, pos_obj, is_top_level); | 605 Execution::GetStackTraceLine(recv, fun, pos_obj, is_top_level); |
606 if (line->length() > 0) { | 606 if (line->length() > 0) { |
607 line->PrintOn(out); | 607 line->PrintOn(out); |
608 fprintf(out, "\n"); | 608 fprintf(out, "\n"); |
609 } | 609 } |
610 } | 610 } |
611 } | 611 } |
612 | 612 |
613 | 613 |
614 void Isolate::ComputeLocation(MessageLocation* target) { | 614 void Isolate::ComputeLocation(MessageLocation* target) { |
615 *target = MessageLocation(Handle<Script>(heap_.empty_script()), -1, -1); | 615 *target = MessageLocation(Handle<Script>(heap_.empty_script()), -1, -1); |
616 StackTraceFrameIterator it; | 616 StackTraceFrameIterator it(this); |
617 if (!it.done()) { | 617 if (!it.done()) { |
618 JavaScriptFrame* frame = it.frame(); | 618 JavaScriptFrame* frame = it.frame(); |
619 JSFunction* fun = JSFunction::cast(frame->function()); | 619 JSFunction* fun = JSFunction::cast(frame->function()); |
620 Object* script = fun->shared()->script(); | 620 Object* script = fun->shared()->script(); |
621 if (script->IsScript() && | 621 if (script->IsScript() && |
622 !(Script::cast(script)->source()->IsUndefined())) { | 622 !(Script::cast(script)->source()->IsUndefined())) { |
623 int pos = frame->LookupCode(this)->SourcePosition(frame->pc()); | 623 int pos = frame->LookupCode()->SourcePosition(frame->pc()); |
624 // Compute the location from the function and the reloc info. | 624 // Compute the location from the function and the reloc info. |
625 Handle<Script> casted_script(Script::cast(script)); | 625 Handle<Script> casted_script(Script::cast(script)); |
626 *target = MessageLocation(casted_script, pos, pos + 1); | 626 *target = MessageLocation(casted_script, pos, pos + 1); |
627 } | 627 } |
628 } | 628 } |
629 } | 629 } |
630 | 630 |
631 | 631 |
632 bool Isolate::ShouldReportException(bool* can_be_caught_externally, | 632 bool Isolate::ShouldReportException(bool* can_be_caught_externally, |
633 bool catchable_by_javascript) { | 633 bool catchable_by_javascript) { |
(...skipping 337 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
971 thread_local_top()->simulator_ = Simulator::current(this); | 971 thread_local_top()->simulator_ = Simulator::current(this); |
972 #endif | 972 #endif |
973 #endif | 973 #endif |
974 if (RuntimeProfiler::IsEnabled() && current_vm_state() == JS) { | 974 if (RuntimeProfiler::IsEnabled() && current_vm_state() == JS) { |
975 RuntimeProfiler::IsolateEnteredJS(this); | 975 RuntimeProfiler::IsolateEnteredJS(this); |
976 } | 976 } |
977 return from + sizeof(ThreadLocalTop); | 977 return from + sizeof(ThreadLocalTop); |
978 } | 978 } |
979 | 979 |
980 } } // namespace v8::internal | 980 } } // namespace v8::internal |
OLD | NEW |