OLD | NEW |
1 // Copyright 2010 the V8 project authors. All rights reserved. | 1 // Copyright 2010 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 25 matching lines...) Expand all Loading... |
36 #include "compilation-cache.h" | 36 #include "compilation-cache.h" |
37 #include "compiler.h" | 37 #include "compiler.h" |
38 #include "cpu.h" | 38 #include "cpu.h" |
39 #include "dateparser-inl.h" | 39 #include "dateparser-inl.h" |
40 #include "debug.h" | 40 #include "debug.h" |
41 #include "deoptimizer.h" | 41 #include "deoptimizer.h" |
42 #include "execution.h" | 42 #include "execution.h" |
43 #include "global-handles.h" | 43 #include "global-handles.h" |
44 #include "jsregexp.h" | 44 #include "jsregexp.h" |
45 #include "liveedit.h" | 45 #include "liveedit.h" |
| 46 #include "liveobjectlist-inl.h" |
46 #include "parser.h" | 47 #include "parser.h" |
47 #include "platform.h" | 48 #include "platform.h" |
48 #include "runtime.h" | 49 #include "runtime.h" |
49 #include "runtime-profiler.h" | 50 #include "runtime-profiler.h" |
50 #include "scopeinfo.h" | 51 #include "scopeinfo.h" |
51 #include "smart-pointer.h" | 52 #include "smart-pointer.h" |
52 #include "stub-cache.h" | 53 #include "stub-cache.h" |
53 #include "v8threads.h" | 54 #include "v8threads.h" |
54 #include "string-search.h" | 55 #include "string-search.h" |
55 | 56 |
(...skipping 10827 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
10883 | 10884 |
10884 | 10885 |
10885 // Gets the current heap usage. | 10886 // Gets the current heap usage. |
10886 static MaybeObject* Runtime_GetHeapUsage(Arguments args) { | 10887 static MaybeObject* Runtime_GetHeapUsage(Arguments args) { |
10887 int usage = static_cast<int>(Heap::SizeOfObjects()); | 10888 int usage = static_cast<int>(Heap::SizeOfObjects()); |
10888 if (!Smi::IsValid(usage)) { | 10889 if (!Smi::IsValid(usage)) { |
10889 return *Factory::NewNumberFromInt(usage); | 10890 return *Factory::NewNumberFromInt(usage); |
10890 } | 10891 } |
10891 return Smi::FromInt(usage); | 10892 return Smi::FromInt(usage); |
10892 } | 10893 } |
| 10894 |
| 10895 |
| 10896 // Captures a live object list from the present heap. |
| 10897 static MaybeObject* Runtime_HasLOLEnabled(Arguments args) { |
| 10898 #ifdef LIVE_OBJECT_LIST |
| 10899 return Heap::true_value(); |
| 10900 #else |
| 10901 return Heap::false_value(); |
| 10902 #endif |
| 10903 } |
| 10904 |
| 10905 |
| 10906 // Captures a live object list from the present heap. |
| 10907 static MaybeObject* Runtime_CaptureLOL(Arguments args) { |
| 10908 #ifdef LIVE_OBJECT_LIST |
| 10909 return LiveObjectList::Capture(); |
| 10910 #else |
| 10911 return Heap::undefined_value(); |
| 10912 #endif |
| 10913 } |
| 10914 |
| 10915 |
| 10916 // Deletes the specified live object list. |
| 10917 static MaybeObject* Runtime_DeleteLOL(Arguments args) { |
| 10918 #ifdef LIVE_OBJECT_LIST |
| 10919 CONVERT_SMI_CHECKED(id, args[0]); |
| 10920 bool success = LiveObjectList::Delete(id); |
| 10921 return success ? Heap::true_value() : Heap::false_value(); |
| 10922 #else |
| 10923 return Heap::undefined_value(); |
| 10924 #endif |
| 10925 } |
| 10926 |
| 10927 |
| 10928 // Generates the response to a debugger request for a dump of the objects |
| 10929 // contained in the difference between the captured live object lists |
| 10930 // specified by id1 and id2. |
| 10931 // If id1 is 0 (i.e. not a valid lol), then the whole of lol id2 will be |
| 10932 // dumped. |
| 10933 static MaybeObject* Runtime_DumpLOL(Arguments args) { |
| 10934 #ifdef LIVE_OBJECT_LIST |
| 10935 HandleScope scope; |
| 10936 CONVERT_SMI_CHECKED(id1, args[0]); |
| 10937 CONVERT_SMI_CHECKED(id2, args[1]); |
| 10938 CONVERT_SMI_CHECKED(start, args[2]); |
| 10939 CONVERT_SMI_CHECKED(count, args[3]); |
| 10940 CONVERT_ARG_CHECKED(JSObject, filter_obj, 4); |
| 10941 EnterDebugger enter_debugger; |
| 10942 return LiveObjectList::Dump(id1, id2, start, count, filter_obj); |
| 10943 #else |
| 10944 return Heap::undefined_value(); |
| 10945 #endif |
| 10946 } |
| 10947 |
| 10948 |
| 10949 // Gets the specified object as requested by the debugger. |
| 10950 // This is only used for obj ids shown in live object lists. |
| 10951 static MaybeObject* Runtime_GetLOLObj(Arguments args) { |
| 10952 #ifdef LIVE_OBJECT_LIST |
| 10953 CONVERT_SMI_CHECKED(obj_id, args[0]); |
| 10954 Object* result = LiveObjectList::GetObj(obj_id); |
| 10955 return result; |
| 10956 #else |
| 10957 return Heap::undefined_value(); |
| 10958 #endif |
| 10959 } |
| 10960 |
| 10961 |
| 10962 // Gets the obj id for the specified address if valid. |
| 10963 // This is only used for obj ids shown in live object lists. |
| 10964 static MaybeObject* Runtime_GetLOLObjId(Arguments args) { |
| 10965 #ifdef LIVE_OBJECT_LIST |
| 10966 HandleScope scope; |
| 10967 CONVERT_ARG_CHECKED(String, address, 0); |
| 10968 Object* result = LiveObjectList::GetObjId(address); |
| 10969 return result; |
| 10970 #else |
| 10971 return Heap::undefined_value(); |
| 10972 #endif |
| 10973 } |
| 10974 |
| 10975 |
| 10976 // Gets the retainers that references the specified object alive. |
| 10977 static MaybeObject* Runtime_GetLOLObjRetainers(Arguments args) { |
| 10978 #ifdef LIVE_OBJECT_LIST |
| 10979 HandleScope scope; |
| 10980 CONVERT_SMI_CHECKED(obj_id, args[0]); |
| 10981 RUNTIME_ASSERT(args[1]->IsUndefined() || args[1]->IsJSObject()); |
| 10982 RUNTIME_ASSERT(args[2]->IsUndefined() || args[2]->IsBoolean()); |
| 10983 RUNTIME_ASSERT(args[3]->IsUndefined() || args[3]->IsSmi()); |
| 10984 RUNTIME_ASSERT(args[4]->IsUndefined() || args[4]->IsSmi()); |
| 10985 CONVERT_ARG_CHECKED(JSObject, filter_obj, 5); |
| 10986 |
| 10987 Handle<JSObject> instance_filter; |
| 10988 if (args[1]->IsJSObject()) { |
| 10989 instance_filter = args.at<JSObject>(1); |
| 10990 } |
| 10991 bool verbose = false; |
| 10992 if (args[2]->IsBoolean()) { |
| 10993 verbose = args[2]->IsTrue(); |
| 10994 } |
| 10995 int start = 0; |
| 10996 if (args[3]->IsSmi()) { |
| 10997 start = Smi::cast(args[3])->value(); |
| 10998 } |
| 10999 int limit = Smi::kMaxValue; |
| 11000 if (args[4]->IsSmi()) { |
| 11001 limit = Smi::cast(args[4])->value(); |
| 11002 } |
| 11003 |
| 11004 return LiveObjectList::GetObjRetainers(obj_id, |
| 11005 instance_filter, |
| 11006 verbose, |
| 11007 start, |
| 11008 limit, |
| 11009 filter_obj); |
| 11010 #else |
| 11011 return Heap::undefined_value(); |
| 11012 #endif |
| 11013 } |
| 11014 |
| 11015 |
| 11016 // Gets the reference path between 2 objects. |
| 11017 static MaybeObject* Runtime_GetLOLPath(Arguments args) { |
| 11018 #ifdef LIVE_OBJECT_LIST |
| 11019 HandleScope scope; |
| 11020 CONVERT_SMI_CHECKED(obj_id1, args[0]); |
| 11021 CONVERT_SMI_CHECKED(obj_id2, args[1]); |
| 11022 RUNTIME_ASSERT(args[2]->IsUndefined() || args[2]->IsJSObject()); |
| 11023 |
| 11024 Handle<JSObject> instance_filter; |
| 11025 if (args[2]->IsJSObject()) { |
| 11026 instance_filter = args.at<JSObject>(2); |
| 11027 } |
| 11028 |
| 11029 Object* result = |
| 11030 LiveObjectList::GetPath(obj_id1, obj_id2, instance_filter); |
| 11031 return result; |
| 11032 #else |
| 11033 return Heap::undefined_value(); |
| 11034 #endif |
| 11035 } |
| 11036 |
| 11037 |
| 11038 // Generates the response to a debugger request for a list of all |
| 11039 // previously captured live object lists. |
| 11040 static MaybeObject* Runtime_InfoLOL(Arguments args) { |
| 11041 #ifdef LIVE_OBJECT_LIST |
| 11042 CONVERT_SMI_CHECKED(start, args[0]); |
| 11043 CONVERT_SMI_CHECKED(count, args[1]); |
| 11044 return LiveObjectList::Info(start, count); |
| 11045 #else |
| 11046 return Heap::undefined_value(); |
| 11047 #endif |
| 11048 } |
| 11049 |
| 11050 |
| 11051 // Gets a dump of the specified object as requested by the debugger. |
| 11052 // This is only used for obj ids shown in live object lists. |
| 11053 static MaybeObject* Runtime_PrintLOLObj(Arguments args) { |
| 11054 #ifdef LIVE_OBJECT_LIST |
| 11055 HandleScope scope; |
| 11056 CONVERT_SMI_CHECKED(obj_id, args[0]); |
| 11057 Object* result = LiveObjectList::PrintObj(obj_id); |
| 11058 return result; |
| 11059 #else |
| 11060 return Heap::undefined_value(); |
| 11061 #endif |
| 11062 } |
| 11063 |
| 11064 |
| 11065 // Resets and releases all previously captured live object lists. |
| 11066 static MaybeObject* Runtime_ResetLOL(Arguments args) { |
| 11067 #ifdef LIVE_OBJECT_LIST |
| 11068 LiveObjectList::Reset(); |
| 11069 return Heap::undefined_value(); |
| 11070 #else |
| 11071 return Heap::undefined_value(); |
| 11072 #endif |
| 11073 } |
| 11074 |
| 11075 |
| 11076 // Generates the response to a debugger request for a summary of the types |
| 11077 // of objects in the difference between the captured live object lists |
| 11078 // specified by id1 and id2. |
| 11079 // If id1 is 0 (i.e. not a valid lol), then the whole of lol id2 will be |
| 11080 // summarized. |
| 11081 static MaybeObject* Runtime_SummarizeLOL(Arguments args) { |
| 11082 #ifdef LIVE_OBJECT_LIST |
| 11083 HandleScope scope; |
| 11084 CONVERT_SMI_CHECKED(id1, args[0]); |
| 11085 CONVERT_SMI_CHECKED(id2, args[1]); |
| 11086 CONVERT_ARG_CHECKED(JSObject, filter_obj, 2); |
| 11087 |
| 11088 EnterDebugger enter_debugger; |
| 11089 return LiveObjectList::Summarize(id1, id2, filter_obj); |
| 11090 #else |
| 11091 return Heap::undefined_value(); |
| 11092 #endif |
| 11093 } |
| 11094 |
10893 #endif // ENABLE_DEBUGGER_SUPPORT | 11095 #endif // ENABLE_DEBUGGER_SUPPORT |
10894 | 11096 |
10895 | 11097 |
10896 #ifdef ENABLE_LOGGING_AND_PROFILING | 11098 #ifdef ENABLE_LOGGING_AND_PROFILING |
10897 static MaybeObject* Runtime_ProfilerResume(Arguments args) { | 11099 static MaybeObject* Runtime_ProfilerResume(Arguments args) { |
10898 NoHandleAllocation ha; | 11100 NoHandleAllocation ha; |
10899 ASSERT(args.length() == 2); | 11101 ASSERT(args.length() == 2); |
10900 | 11102 |
10901 CONVERT_CHECKED(Smi, smi_modules, args[0]); | 11103 CONVERT_CHECKED(Smi, smi_modules, args[0]); |
10902 CONVERT_CHECKED(Smi, smi_tag, args[1]); | 11104 CONVERT_CHECKED(Smi, smi_tag, args[1]); |
(...skipping 420 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
11323 } else { | 11525 } else { |
11324 // Handle last resort GC and make sure to allow future allocations | 11526 // Handle last resort GC and make sure to allow future allocations |
11325 // to grow the heap without causing GCs (if possible). | 11527 // to grow the heap without causing GCs (if possible). |
11326 Counters::gc_last_resort_from_js.Increment(); | 11528 Counters::gc_last_resort_from_js.Increment(); |
11327 Heap::CollectAllGarbage(false); | 11529 Heap::CollectAllGarbage(false); |
11328 } | 11530 } |
11329 } | 11531 } |
11330 | 11532 |
11331 | 11533 |
11332 } } // namespace v8::internal | 11534 } } // namespace v8::internal |
OLD | NEW |