| OLD | NEW |
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "src/v8.h" | 5 #include "src/v8.h" |
| 6 | 6 |
| 7 #include "src/api.h" | 7 #include "src/api.h" |
| 8 #include "src/arguments.h" | 8 #include "src/arguments.h" |
| 9 #include "src/bootstrapper.h" | 9 #include "src/bootstrapper.h" |
| 10 #include "src/code-stubs.h" | 10 #include "src/code-stubs.h" |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 51 static v8::Handle<v8::Context> GetDebugEventContext(Isolate* isolate) { | 51 static v8::Handle<v8::Context> GetDebugEventContext(Isolate* isolate) { |
| 52 Handle<Context> context = isolate->debug()->debugger_entry()->GetContext(); | 52 Handle<Context> context = isolate->debug()->debugger_entry()->GetContext(); |
| 53 // Isolate::context() may have been NULL when "script collected" event | 53 // Isolate::context() may have been NULL when "script collected" event |
| 54 // occured. | 54 // occured. |
| 55 if (context.is_null()) return v8::Local<v8::Context>(); | 55 if (context.is_null()) return v8::Local<v8::Context>(); |
| 56 Handle<Context> native_context(context->native_context()); | 56 Handle<Context> native_context(context->native_context()); |
| 57 return v8::Utils::ToLocal(native_context); | 57 return v8::Utils::ToLocal(native_context); |
| 58 } | 58 } |
| 59 | 59 |
| 60 | 60 |
| 61 BreakLocation::BreakLocation(Handle<DebugInfo> debug_info, RelocInfo* rinfo, |
| 62 RelocInfo* original_rinfo, int position, |
| 63 int statement_position) |
| 64 : debug_info_(debug_info), |
| 65 pc_offset_(static_cast<int>(rinfo->pc() - debug_info->code()->entry())), |
| 66 original_pc_offset_(static_cast<int>( |
| 67 original_rinfo->pc() - debug_info->original_code()->entry())), |
| 68 rmode_(rinfo->rmode()), |
| 69 original_rmode_(original_rinfo->rmode()), |
| 70 data_(rinfo->data()), |
| 71 original_data_(original_rinfo->data()), |
| 72 position_(position), |
| 73 statement_position_(statement_position) { |
| 74 DCHECK(debug_info_->GetIsolate()->debug()->is_active()); |
| 75 } |
| 76 |
| 77 |
| 61 BreakLocation::Iterator::Iterator(Handle<DebugInfo> debug_info, | 78 BreakLocation::Iterator::Iterator(Handle<DebugInfo> debug_info, |
| 62 BreakLocatorType type) | 79 BreakLocatorType type) |
| 63 : debug_info_(debug_info), | 80 : debug_info_(debug_info), |
| 64 type_(type), | 81 type_(type), |
| 65 reloc_iterator_(debug_info->code(), | 82 reloc_iterator_(debug_info->code(), |
| 66 ~RelocInfo::ModeMask(RelocInfo::CODE_AGE_SEQUENCE)), | 83 ~RelocInfo::ModeMask(RelocInfo::CODE_AGE_SEQUENCE)), |
| 67 reloc_iterator_original_( | 84 reloc_iterator_original_( |
| 68 debug_info->original_code(), | 85 debug_info->original_code(), |
| 69 ~RelocInfo::ModeMask(RelocInfo::CODE_AGE_SEQUENCE)), | 86 ~RelocInfo::ModeMask(RelocInfo::CODE_AGE_SEQUENCE)), |
| 70 break_index_(-1), | 87 break_index_(-1), |
| (...skipping 425 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 496 | 513 |
| 497 int Debug::ArchiveSpacePerThread() { | 514 int Debug::ArchiveSpacePerThread() { |
| 498 return sizeof(ThreadLocal); | 515 return sizeof(ThreadLocal); |
| 499 } | 516 } |
| 500 | 517 |
| 501 | 518 |
| 502 ScriptCache::ScriptCache(Isolate* isolate) : isolate_(isolate) { | 519 ScriptCache::ScriptCache(Isolate* isolate) : isolate_(isolate) { |
| 503 Heap* heap = isolate_->heap(); | 520 Heap* heap = isolate_->heap(); |
| 504 HandleScope scope(isolate_); | 521 HandleScope scope(isolate_); |
| 505 | 522 |
| 523 DCHECK(isolate_->debug()->is_active()); |
| 524 |
| 506 // Perform a GC to get rid of all unreferenced scripts. | 525 // Perform a GC to get rid of all unreferenced scripts. |
| 507 heap->CollectAllGarbage(Heap::kMakeHeapIterableMask, "ScriptCache"); | 526 heap->CollectAllGarbage(Heap::kMakeHeapIterableMask, "ScriptCache"); |
| 508 | 527 |
| 509 // Scan heap for Script objects. | 528 // Scan heap for Script objects. |
| 510 List<Handle<Script> > scripts; | 529 List<Handle<Script> > scripts; |
| 511 { | 530 { |
| 512 HeapIterator iterator(heap, HeapIterator::kFilterUnreachable); | 531 HeapIterator iterator(heap, HeapIterator::kFilterUnreachable); |
| 513 DisallowHeapAllocation no_allocation; | 532 DisallowHeapAllocation no_allocation; |
| 514 for (HeapObject* obj = iterator.next(); obj != NULL; | 533 for (HeapObject* obj = iterator.next(); obj != NULL; |
| 515 obj = iterator.next()) { | 534 obj = iterator.next()) { |
| (...skipping 2418 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2934 if (handler == NULL && in_debug_scope()) { | 2953 if (handler == NULL && in_debug_scope()) { |
| 2935 // Send an empty command to the debugger if in a break to make JavaScript | 2954 // Send an empty command to the debugger if in a break to make JavaScript |
| 2936 // run again if the debugger is closed. | 2955 // run again if the debugger is closed. |
| 2937 EnqueueCommandMessage(Vector<const uint16_t>::empty()); | 2956 EnqueueCommandMessage(Vector<const uint16_t>::empty()); |
| 2938 } | 2957 } |
| 2939 } | 2958 } |
| 2940 | 2959 |
| 2941 | 2960 |
| 2942 | 2961 |
| 2943 void Debug::UpdateState() { | 2962 void Debug::UpdateState() { |
| 2944 is_active_ = message_handler_ != NULL || !event_listener_.is_null(); | 2963 bool is_active = message_handler_ != NULL || !event_listener_.is_null(); |
| 2945 if (is_active_ || in_debug_scope()) { | 2964 if (is_active || in_debug_scope()) { |
| 2946 // Note that the debug context could have already been loaded to | 2965 // Note that the debug context could have already been loaded to |
| 2947 // bootstrap test cases. | 2966 // bootstrap test cases. |
| 2948 isolate_->compilation_cache()->Disable(); | 2967 isolate_->compilation_cache()->Disable(); |
| 2949 is_active_ = Load(); | 2968 is_active = Load(); |
| 2950 } else if (is_loaded()) { | 2969 } else if (is_loaded()) { |
| 2951 isolate_->compilation_cache()->Enable(); | 2970 isolate_->compilation_cache()->Enable(); |
| 2952 Unload(); | 2971 Unload(); |
| 2953 } | 2972 } |
| 2973 is_active_ = is_active; |
| 2954 } | 2974 } |
| 2955 | 2975 |
| 2956 | 2976 |
| 2957 // Calls the registered debug message handler. This callback is part of the | 2977 // Calls the registered debug message handler. This callback is part of the |
| 2958 // public API. | 2978 // public API. |
| 2959 void Debug::InvokeMessageHandler(MessageImpl message) { | 2979 void Debug::InvokeMessageHandler(MessageImpl message) { |
| 2960 if (message_handler_ != NULL) message_handler_(message); | 2980 if (message_handler_ != NULL) message_handler_(message); |
| 2961 } | 2981 } |
| 2962 | 2982 |
| 2963 | 2983 |
| (...skipping 400 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3364 } | 3384 } |
| 3365 | 3385 |
| 3366 | 3386 |
| 3367 void LockingCommandMessageQueue::Clear() { | 3387 void LockingCommandMessageQueue::Clear() { |
| 3368 base::LockGuard<base::Mutex> lock_guard(&mutex_); | 3388 base::LockGuard<base::Mutex> lock_guard(&mutex_); |
| 3369 queue_.Clear(); | 3389 queue_.Clear(); |
| 3370 } | 3390 } |
| 3371 | 3391 |
| 3372 } // namespace internal | 3392 } // namespace internal |
| 3373 } // namespace v8 | 3393 } // namespace v8 |
| OLD | NEW |