| 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 19 matching lines...) Expand all Loading... |
| 30 #include "api.h" | 30 #include "api.h" |
| 31 #include "bootstrapper.h" | 31 #include "bootstrapper.h" |
| 32 #include "debug.h" | 32 #include "debug.h" |
| 33 #include "execution.h" | 33 #include "execution.h" |
| 34 #include "string-stream.h" | 34 #include "string-stream.h" |
| 35 #include "platform.h" | 35 #include "platform.h" |
| 36 | 36 |
| 37 namespace v8 { namespace internal { | 37 namespace v8 { namespace internal { |
| 38 | 38 |
| 39 ThreadLocalTop Top::thread_local_; | 39 ThreadLocalTop Top::thread_local_; |
| 40 Mutex* Top::break_access_; | 40 Mutex* Top::break_access_ = OS::CreateMutex(); |
| 41 StackFrame::Id Top::break_frame_id_; | 41 StackFrame::Id Top::break_frame_id_; |
| 42 int Top::break_count_; | 42 int Top::break_count_; |
| 43 int Top::break_id_; | 43 int Top::break_id_; |
| 44 | 44 |
| 45 NoAllocationStringAllocator* preallocated_message_space = NULL; | 45 NoAllocationStringAllocator* preallocated_message_space = NULL; |
| 46 | 46 |
| 47 Address top_addresses[] = { | 47 Address top_addresses[] = { |
| 48 #define C(name) reinterpret_cast<Address>(Top::name()), | 48 #define C(name) reinterpret_cast<Address>(Top::name()), |
| 49 TOP_ADDRESS_LIST(C) | 49 TOP_ADDRESS_LIST(C) |
| 50 #undef C | 50 #undef C |
| (...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 218 char* PreallocatedMemoryThread::data_ = NULL; | 218 char* PreallocatedMemoryThread::data_ = NULL; |
| 219 unsigned PreallocatedMemoryThread::length_ = 0; | 219 unsigned PreallocatedMemoryThread::length_ = 0; |
| 220 | 220 |
| 221 static bool initialized = false; | 221 static bool initialized = false; |
| 222 | 222 |
| 223 void Top::Initialize() { | 223 void Top::Initialize() { |
| 224 CHECK(!initialized); | 224 CHECK(!initialized); |
| 225 | 225 |
| 226 InitializeThreadLocal(); | 226 InitializeThreadLocal(); |
| 227 | 227 |
| 228 break_access_ = OS::CreateMutex(); | |
| 229 break_frame_id_ = StackFrame::NO_ID; | 228 break_frame_id_ = StackFrame::NO_ID; |
| 230 break_count_ = 0; | 229 break_count_ = 0; |
| 231 break_id_ = 0; | 230 break_id_ = 0; |
| 232 | 231 |
| 233 // Only preallocate on the first initialization. | 232 // Only preallocate on the first initialization. |
| 234 if (FLAG_preallocate_message_memory && (preallocated_message_space == NULL)) { | 233 if (FLAG_preallocate_message_memory && (preallocated_message_space == NULL)) { |
| 235 // Start the thread which will set aside some memory. | 234 // Start the thread which will set aside some memory. |
| 236 PreallocatedMemoryThread::StartThread(); | 235 PreallocatedMemoryThread::StartThread(); |
| 237 preallocated_message_space = | 236 preallocated_message_space = |
| 238 new NoAllocationStringAllocator(PreallocatedMemoryThread::data(), | 237 new NoAllocationStringAllocator(PreallocatedMemoryThread::data(), |
| (...skipping 398 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 637 } | 636 } |
| 638 | 637 |
| 639 | 638 |
| 640 Failure* Top::Throw(Object* exception, MessageLocation* location) { | 639 Failure* Top::Throw(Object* exception, MessageLocation* location) { |
| 641 DoThrow(exception, location, NULL); | 640 DoThrow(exception, location, NULL); |
| 642 return Failure::Exception(); | 641 return Failure::Exception(); |
| 643 } | 642 } |
| 644 | 643 |
| 645 | 644 |
| 646 Failure* Top::ReThrow(Object* exception, MessageLocation* location) { | 645 Failure* Top::ReThrow(Object* exception, MessageLocation* location) { |
| 647 // Set the exception beeing re-thrown. | 646 // Set the exception being re-thrown. |
| 648 set_pending_exception(exception); | 647 set_pending_exception(exception); |
| 649 return Failure::Exception(); | 648 return Failure::Exception(); |
| 650 } | 649 } |
| 651 | 650 |
| 652 | 651 |
| 653 void Top::ScheduleThrow(Object* exception) { | 652 void Top::ScheduleThrow(Object* exception) { |
| 654 // When scheduling a throw we first throw the exception to get the | 653 // When scheduling a throw we first throw the exception to get the |
| 655 // error reporting if it is uncaught before rescheduling it. | 654 // error reporting if it is uncaught before rescheduling it. |
| 656 Throw(exception); | 655 Throw(exception); |
| 657 thread_local_.scheduled_exception_ = pending_exception(); | 656 thread_local_.scheduled_exception_ = pending_exception(); |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 698 Handle<Object> pos_obj(Smi::FromInt(pos)); | 697 Handle<Object> pos_obj(Smi::FromInt(pos)); |
| 699 // Fetch function and receiver. | 698 // Fetch function and receiver. |
| 700 Handle<JSFunction> fun(JSFunction::cast(frame->function())); | 699 Handle<JSFunction> fun(JSFunction::cast(frame->function())); |
| 701 Handle<Object> recv(frame->receiver()); | 700 Handle<Object> recv(frame->receiver()); |
| 702 // Advance to the next JavaScript frame and determine if the | 701 // Advance to the next JavaScript frame and determine if the |
| 703 // current frame is the top-level frame. | 702 // current frame is the top-level frame. |
| 704 it.Advance(); | 703 it.Advance(); |
| 705 Handle<Object> is_top_level = it.done() | 704 Handle<Object> is_top_level = it.done() |
| 706 ? Factory::true_value() | 705 ? Factory::true_value() |
| 707 : Factory::false_value(); | 706 : Factory::false_value(); |
| 708 // Generate and print strack trace line. | 707 // Generate and print stack trace line. |
| 709 Handle<String> line = | 708 Handle<String> line = |
| 710 Execution::GetStackTraceLine(recv, fun, pos_obj, is_top_level); | 709 Execution::GetStackTraceLine(recv, fun, pos_obj, is_top_level); |
| 711 if (line->length() > 0) { | 710 if (line->length() > 0) { |
| 712 line->PrintOn(out); | 711 line->PrintOn(out); |
| 713 fprintf(out, "\n"); | 712 fprintf(out, "\n"); |
| 714 } | 713 } |
| 715 } | 714 } |
| 716 } | 715 } |
| 717 | 716 |
| 718 | 717 |
| (...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 957 Top::break_access_->Lock(); | 956 Top::break_access_->Lock(); |
| 958 } | 957 } |
| 959 | 958 |
| 960 | 959 |
| 961 ExecutionAccess::~ExecutionAccess() { | 960 ExecutionAccess::~ExecutionAccess() { |
| 962 Top::break_access_->Unlock(); | 961 Top::break_access_->Unlock(); |
| 963 } | 962 } |
| 964 | 963 |
| 965 | 964 |
| 966 } } // namespace v8::internal | 965 } } // namespace v8::internal |
| OLD | NEW |