Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(624)

Side by Side Diff: src/runtime.cc

Issue 48009: Add thread information to the debugger (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: Created 11 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/runtime.h ('k') | src/v8threads.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2006-2009 the V8 project authors. All rights reserved. 1 // Copyright 2006-2009 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 5753 matching lines...) Expand 10 before | Expand all | Expand 10 after
5764 if (!frame_text.is_null()) { 5764 if (!frame_text.is_null()) {
5765 frame_value->SetProperty(*text_str, *frame_text, NONE); 5765 frame_value->SetProperty(*text_str, *frame_text, NONE);
5766 } 5766 }
5767 5767
5768 frames_array->set(i, *frame_value); 5768 frames_array->set(i, *frame_value);
5769 } 5769 }
5770 return *Factory::NewJSArrayWithElements(frames_array); 5770 return *Factory::NewJSArrayWithElements(frames_array);
5771 } 5771 }
5772 5772
5773 5773
5774 static Object* Runtime_GetThreadCount(Arguments args) {
5775 HandleScope scope;
5776 ASSERT(args.length() == 1);
5777
5778 // Check arguments.
Erik Corry 2009/03/17 09:44:13 Wrong comment
Søren Thygesen Gjesse 2009/03/17 09:54:29 The comment is correct. All debugger runtime calls
5779 Object* result = Runtime_CheckExecutionState(args);
5780 if (result->IsFailure()) return result;
5781
5782 // Count all archived V8 threads.
5783 int n = 0;
5784 for (ThreadState* thread = ThreadState::FirstInUse();
5785 thread != NULL;
5786 thread = thread->Next()) {
5787 n++;
5788 }
5789
5790 // Total number of threads is current thread and archived threads.
5791 return Smi::FromInt(n + 1);
5792 }
5793
5794
5795 static const int kThreadDetailsCurrentThreadIndex = 0;
5796 static const int kThreadDetailsThreadIdIndex = 1;
5797 static const int kThreadDetailsSize = 2;
5798
5799 // Return an array with thread details
5800 // args[0]: number: break id
5801 // args[1]: number: thread index
5802 //
5803 // The array returned contains the following information:
5804 // 0: Is current thread?
5805 // 1: Thread id
5806 static Object* Runtime_GetThreadDetails(Arguments args) {
5807 HandleScope scope;
5808 ASSERT(args.length() == 2);
5809
5810 // Check arguments.
5811 Object* check = Runtime_CheckExecutionState(args);
5812 if (check->IsFailure()) return check;
5813 CONVERT_NUMBER_CHECKED(int, index, Int32, args[1]);
5814
5815 // Allocate array for result.
5816 Handle<FixedArray> details = Factory::NewFixedArray(kThreadDetailsSize);
5817
5818 // Thread index 0 is current thread.
5819 if (index == 0) {
5820 // Fill the details.
5821 details->set(kThreadDetailsCurrentThreadIndex, Heap::true_value());
5822 details->set(kThreadDetailsThreadIdIndex,
5823 Smi::FromInt(ThreadManager::CurrentId()));
5824 } else {
5825 // Find the thread with the requested index.
5826 int n = 1;
5827 ThreadState* thread = ThreadState::FirstInUse();
5828 while (index != n && thread != NULL) {
5829 thread = thread->Next();
5830 n++;
5831 }
5832 if (thread == NULL) {
5833 return Heap::undefined_value();
5834 }
5835
5836 // Fill the details.
5837 details->set(kThreadDetailsCurrentThreadIndex, Heap::false_value());
5838 details->set(kThreadDetailsThreadIdIndex, Smi::FromInt(thread->id()));
5839 }
5840
5841 // Convert to JS array and return.
5842 return *Factory::NewJSArrayWithElements(details);
5843 }
5844
5845
5774 static Object* Runtime_GetBreakLocations(Arguments args) { 5846 static Object* Runtime_GetBreakLocations(Arguments args) {
5775 HandleScope scope; 5847 HandleScope scope;
5776 ASSERT(args.length() == 1); 5848 ASSERT(args.length() == 1);
5777 5849
5778 CONVERT_ARG_CHECKED(JSFunction, raw_fun, 0); 5850 CONVERT_ARG_CHECKED(JSFunction, raw_fun, 0);
5779 Handle<SharedFunctionInfo> shared(raw_fun->shared()); 5851 Handle<SharedFunctionInfo> shared(raw_fun->shared());
5780 // Find the number of break points 5852 // Find the number of break points
5781 Handle<Object> break_locations = Debug::GetSourceBreakLocations(shared); 5853 Handle<Object> break_locations = Debug::GetSourceBreakLocations(shared);
5782 if (break_locations->IsUndefined()) return Heap::undefined_value(); 5854 if (break_locations->IsUndefined()) return Heap::undefined_value();
5783 // Return array as JS array 5855 // Return array as JS array
(...skipping 889 matching lines...) Expand 10 before | Expand all | Expand 10 after
6673 } else { 6745 } else {
6674 // Handle last resort GC and make sure to allow future allocations 6746 // Handle last resort GC and make sure to allow future allocations
6675 // to grow the heap without causing GCs (if possible). 6747 // to grow the heap without causing GCs (if possible).
6676 Counters::gc_last_resort_from_js.Increment(); 6748 Counters::gc_last_resort_from_js.Increment();
6677 Heap::CollectAllGarbage(); 6749 Heap::CollectAllGarbage();
6678 } 6750 }
6679 } 6751 }
6680 6752
6681 6753
6682 } } // namespace v8::internal 6754 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/runtime.h ('k') | src/v8threads.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698