OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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 30 matching lines...) Expand all Loading... |
41 #include "debug.h" | 41 #include "debug.h" |
42 #include "deoptimizer.h" | 42 #include "deoptimizer.h" |
43 #include "date.h" | 43 #include "date.h" |
44 #include "execution.h" | 44 #include "execution.h" |
45 #include "global-handles.h" | 45 #include "global-handles.h" |
46 #include "isolate-inl.h" | 46 #include "isolate-inl.h" |
47 #include "jsregexp.h" | 47 #include "jsregexp.h" |
48 #include "json-parser.h" | 48 #include "json-parser.h" |
49 #include "json-stringifier.h" | 49 #include "json-stringifier.h" |
50 #include "liveedit.h" | 50 #include "liveedit.h" |
51 #include "liveobjectlist-inl.h" | |
52 #include "misc-intrinsics.h" | 51 #include "misc-intrinsics.h" |
53 #include "parser.h" | 52 #include "parser.h" |
54 #include "platform.h" | 53 #include "platform.h" |
55 #include "runtime-profiler.h" | 54 #include "runtime-profiler.h" |
56 #include "runtime.h" | 55 #include "runtime.h" |
57 #include "scopeinfo.h" | 56 #include "scopeinfo.h" |
58 #include "smart-pointers.h" | 57 #include "smart-pointers.h" |
59 #include "string-search.h" | 58 #include "string-search.h" |
60 #include "stub-cache.h" | 59 #include "stub-cache.h" |
61 #include "v8threads.h" | 60 #include "v8threads.h" |
(...skipping 12908 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
12970 | 12969 |
12971 // Gets the current heap usage. | 12970 // Gets the current heap usage. |
12972 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetHeapUsage) { | 12971 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetHeapUsage) { |
12973 int usage = static_cast<int>(isolate->heap()->SizeOfObjects()); | 12972 int usage = static_cast<int>(isolate->heap()->SizeOfObjects()); |
12974 if (!Smi::IsValid(usage)) { | 12973 if (!Smi::IsValid(usage)) { |
12975 return *isolate->factory()->NewNumberFromInt(usage); | 12974 return *isolate->factory()->NewNumberFromInt(usage); |
12976 } | 12975 } |
12977 return Smi::FromInt(usage); | 12976 return Smi::FromInt(usage); |
12978 } | 12977 } |
12979 | 12978 |
12980 | |
12981 // Captures a live object list from the present heap. | |
12982 RUNTIME_FUNCTION(MaybeObject*, Runtime_HasLOLEnabled) { | |
12983 #ifdef LIVE_OBJECT_LIST | |
12984 return isolate->heap()->true_value(); | |
12985 #else | |
12986 return isolate->heap()->false_value(); | |
12987 #endif | |
12988 } | |
12989 | |
12990 | |
12991 // Captures a live object list from the present heap. | |
12992 RUNTIME_FUNCTION(MaybeObject*, Runtime_CaptureLOL) { | |
12993 #ifdef LIVE_OBJECT_LIST | |
12994 return LiveObjectList::Capture(); | |
12995 #else | |
12996 return isolate->heap()->undefined_value(); | |
12997 #endif | |
12998 } | |
12999 | |
13000 | |
13001 // Deletes the specified live object list. | |
13002 RUNTIME_FUNCTION(MaybeObject*, Runtime_DeleteLOL) { | |
13003 #ifdef LIVE_OBJECT_LIST | |
13004 CONVERT_SMI_ARG_CHECKED(id, 0); | |
13005 bool success = LiveObjectList::Delete(id); | |
13006 return isolate->heap()->ToBoolean(success); | |
13007 #else | |
13008 return isolate->heap()->undefined_value(); | |
13009 #endif | |
13010 } | |
13011 | |
13012 | |
13013 // Generates the response to a debugger request for a dump of the objects | |
13014 // contained in the difference between the captured live object lists | |
13015 // specified by id1 and id2. | |
13016 // If id1 is 0 (i.e. not a valid lol), then the whole of lol id2 will be | |
13017 // dumped. | |
13018 RUNTIME_FUNCTION(MaybeObject*, Runtime_DumpLOL) { | |
13019 #ifdef LIVE_OBJECT_LIST | |
13020 HandleScope scope; | |
13021 CONVERT_SMI_ARG_CHECKED(id1, 0); | |
13022 CONVERT_SMI_ARG_CHECKED(id2, 1); | |
13023 CONVERT_SMI_ARG_CHECKED(start, 2); | |
13024 CONVERT_SMI_ARG_CHECKED(count, 3); | |
13025 CONVERT_ARG_HANDLE_CHECKED(JSObject, filter_obj, 4); | |
13026 EnterDebugger enter_debugger; | |
13027 return LiveObjectList::Dump(id1, id2, start, count, filter_obj); | |
13028 #else | |
13029 return isolate->heap()->undefined_value(); | |
13030 #endif | |
13031 } | |
13032 | |
13033 | |
13034 // Gets the specified object as requested by the debugger. | |
13035 // This is only used for obj ids shown in live object lists. | |
13036 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetLOLObj) { | |
13037 #ifdef LIVE_OBJECT_LIST | |
13038 CONVERT_SMI_ARG_CHECKED(obj_id, 0); | |
13039 Object* result = LiveObjectList::GetObj(obj_id); | |
13040 return result; | |
13041 #else | |
13042 return isolate->heap()->undefined_value(); | |
13043 #endif | |
13044 } | |
13045 | |
13046 | |
13047 // Gets the obj id for the specified address if valid. | |
13048 // This is only used for obj ids shown in live object lists. | |
13049 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetLOLObjId) { | |
13050 #ifdef LIVE_OBJECT_LIST | |
13051 HandleScope scope; | |
13052 CONVERT_ARG_HANDLE_CHECKED(String, address, 0); | |
13053 Object* result = LiveObjectList::GetObjId(address); | |
13054 return result; | |
13055 #else | |
13056 return isolate->heap()->undefined_value(); | |
13057 #endif | |
13058 } | |
13059 | |
13060 | |
13061 // Gets the retainers that references the specified object alive. | |
13062 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetLOLObjRetainers) { | |
13063 #ifdef LIVE_OBJECT_LIST | |
13064 HandleScope scope; | |
13065 CONVERT_SMI_ARG_CHECKED(obj_id, 0); | |
13066 RUNTIME_ASSERT(args[1]->IsUndefined() || args[1]->IsJSObject()); | |
13067 RUNTIME_ASSERT(args[2]->IsUndefined() || args[2]->IsBoolean()); | |
13068 RUNTIME_ASSERT(args[3]->IsUndefined() || args[3]->IsSmi()); | |
13069 RUNTIME_ASSERT(args[4]->IsUndefined() || args[4]->IsSmi()); | |
13070 CONVERT_ARG_HANDLE_CHECKED(JSObject, filter_obj, 5); | |
13071 | |
13072 Handle<JSObject> instance_filter; | |
13073 if (args[1]->IsJSObject()) { | |
13074 instance_filter = args.at<JSObject>(1); | |
13075 } | |
13076 bool verbose = false; | |
13077 if (args[2]->IsBoolean()) { | |
13078 verbose = args[2]->IsTrue(); | |
13079 } | |
13080 int start = 0; | |
13081 if (args[3]->IsSmi()) { | |
13082 start = args.smi_at(3); | |
13083 } | |
13084 int limit = Smi::kMaxValue; | |
13085 if (args[4]->IsSmi()) { | |
13086 limit = args.smi_at(4); | |
13087 } | |
13088 | |
13089 return LiveObjectList::GetObjRetainers(obj_id, | |
13090 instance_filter, | |
13091 verbose, | |
13092 start, | |
13093 limit, | |
13094 filter_obj); | |
13095 #else | |
13096 return isolate->heap()->undefined_value(); | |
13097 #endif | |
13098 } | |
13099 | |
13100 | |
13101 // Gets the reference path between 2 objects. | |
13102 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetLOLPath) { | |
13103 #ifdef LIVE_OBJECT_LIST | |
13104 HandleScope scope; | |
13105 CONVERT_SMI_ARG_CHECKED(obj_id1, 0); | |
13106 CONVERT_SMI_ARG_CHECKED(obj_id2, 1); | |
13107 RUNTIME_ASSERT(args[2]->IsUndefined() || args[2]->IsJSObject()); | |
13108 | |
13109 Handle<JSObject> instance_filter; | |
13110 if (args[2]->IsJSObject()) { | |
13111 instance_filter = args.at<JSObject>(2); | |
13112 } | |
13113 | |
13114 Object* result = | |
13115 LiveObjectList::GetPath(obj_id1, obj_id2, instance_filter); | |
13116 return result; | |
13117 #else | |
13118 return isolate->heap()->undefined_value(); | |
13119 #endif | |
13120 } | |
13121 | |
13122 | |
13123 // Generates the response to a debugger request for a list of all | |
13124 // previously captured live object lists. | |
13125 RUNTIME_FUNCTION(MaybeObject*, Runtime_InfoLOL) { | |
13126 #ifdef LIVE_OBJECT_LIST | |
13127 CONVERT_SMI_ARG_CHECKED(start, 0); | |
13128 CONVERT_SMI_ARG_CHECKED(count, 1); | |
13129 return LiveObjectList::Info(start, count); | |
13130 #else | |
13131 return isolate->heap()->undefined_value(); | |
13132 #endif | |
13133 } | |
13134 | |
13135 | |
13136 // Gets a dump of the specified object as requested by the debugger. | |
13137 // This is only used for obj ids shown in live object lists. | |
13138 RUNTIME_FUNCTION(MaybeObject*, Runtime_PrintLOLObj) { | |
13139 #ifdef LIVE_OBJECT_LIST | |
13140 HandleScope scope; | |
13141 CONVERT_SMI_ARG_CHECKED(obj_id, 0); | |
13142 Object* result = LiveObjectList::PrintObj(obj_id); | |
13143 return result; | |
13144 #else | |
13145 return isolate->heap()->undefined_value(); | |
13146 #endif | |
13147 } | |
13148 | |
13149 | |
13150 // Resets and releases all previously captured live object lists. | |
13151 RUNTIME_FUNCTION(MaybeObject*, Runtime_ResetLOL) { | |
13152 #ifdef LIVE_OBJECT_LIST | |
13153 LiveObjectList::Reset(); | |
13154 return isolate->heap()->undefined_value(); | |
13155 #else | |
13156 return isolate->heap()->undefined_value(); | |
13157 #endif | |
13158 } | |
13159 | |
13160 | |
13161 // Generates the response to a debugger request for a summary of the types | |
13162 // of objects in the difference between the captured live object lists | |
13163 // specified by id1 and id2. | |
13164 // If id1 is 0 (i.e. not a valid lol), then the whole of lol id2 will be | |
13165 // summarized. | |
13166 RUNTIME_FUNCTION(MaybeObject*, Runtime_SummarizeLOL) { | |
13167 #ifdef LIVE_OBJECT_LIST | |
13168 HandleScope scope; | |
13169 CONVERT_SMI_ARG_CHECKED(id1, 0); | |
13170 CONVERT_SMI_ARG_CHECKED(id2, 1); | |
13171 CONVERT_ARG_HANDLE_CHECKED(JSObject, filter_obj, 2); | |
13172 | |
13173 EnterDebugger enter_debugger; | |
13174 return LiveObjectList::Summarize(id1, id2, filter_obj); | |
13175 #else | |
13176 return isolate->heap()->undefined_value(); | |
13177 #endif | |
13178 } | |
13179 | |
13180 #endif // ENABLE_DEBUGGER_SUPPORT | 12979 #endif // ENABLE_DEBUGGER_SUPPORT |
13181 | 12980 |
13182 | 12981 |
13183 RUNTIME_FUNCTION(MaybeObject*, Runtime_ProfilerResume) { | 12982 RUNTIME_FUNCTION(MaybeObject*, Runtime_ProfilerResume) { |
13184 NoHandleAllocation ha; | 12983 NoHandleAllocation ha; |
13185 v8::V8::ResumeProfiler(); | 12984 v8::V8::ResumeProfiler(); |
13186 return isolate->heap()->undefined_value(); | 12985 return isolate->heap()->undefined_value(); |
13187 } | 12986 } |
13188 | 12987 |
13189 | 12988 |
(...skipping 526 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
13716 // Handle last resort GC and make sure to allow future allocations | 13515 // Handle last resort GC and make sure to allow future allocations |
13717 // to grow the heap without causing GCs (if possible). | 13516 // to grow the heap without causing GCs (if possible). |
13718 isolate->counters()->gc_last_resort_from_js()->Increment(); | 13517 isolate->counters()->gc_last_resort_from_js()->Increment(); |
13719 isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags, | 13518 isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags, |
13720 "Runtime::PerformGC"); | 13519 "Runtime::PerformGC"); |
13721 } | 13520 } |
13722 } | 13521 } |
13723 | 13522 |
13724 | 13523 |
13725 } } // namespace v8::internal | 13524 } } // namespace v8::internal |
OLD | NEW |