OLD | NEW |
1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 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 18 matching lines...) Expand all Loading... |
29 | 29 |
30 #include <ctype.h> | 30 #include <ctype.h> |
31 #include <stdlib.h> | 31 #include <stdlib.h> |
32 | 32 |
33 #include "v8.h" | 33 #include "v8.h" |
34 | 34 |
35 #include "checks.h" | 35 #include "checks.h" |
36 #include "global-handles.h" | 36 #include "global-handles.h" |
37 #include "heap.h" | 37 #include "heap.h" |
38 #include "inspector.h" | 38 #include "inspector.h" |
| 39 #include "isolate.h" |
39 #include "list-inl.h" | 40 #include "list-inl.h" |
40 #include "liveobjectlist-inl.h" | 41 #include "liveobjectlist-inl.h" |
41 #include "string-stream.h" | 42 #include "string-stream.h" |
42 #include "top.h" | |
43 #include "v8utils.h" | 43 #include "v8utils.h" |
| 44 #include "v8conversions.h" |
44 | 45 |
45 namespace v8 { | 46 namespace v8 { |
46 namespace internal { | 47 namespace internal { |
47 | 48 |
48 | 49 |
49 typedef int (*RawComparer)(const void*, const void*); | 50 typedef int (*RawComparer)(const void*, const void*); |
50 | 51 |
51 | 52 |
52 #ifdef CHECK_ALL_OBJECT_TYPES | 53 #ifdef CHECK_ALL_OBJECT_TYPES |
53 | 54 |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
102 v(JSRegExp, "JSRegExp") \ | 103 v(JSRegExp, "JSRegExp") \ |
103 v(JSFunction, "JSFunction") \ | 104 v(JSFunction, "JSFunction") \ |
104 v(JSGlobalObject, "JSGlobal") \ | 105 v(JSGlobalObject, "JSGlobal") \ |
105 v(JSBuiltinsObject, "JSBuiltins") \ | 106 v(JSBuiltinsObject, "JSBuiltins") \ |
106 v(GlobalObject, "Global") \ | 107 v(GlobalObject, "Global") \ |
107 v(JSGlobalProxy, "JSGlobalProxy") \ | 108 v(JSGlobalProxy, "JSGlobalProxy") \ |
108 v(JSObject, "JSObject") \ | 109 v(JSObject, "JSObject") \ |
109 \ | 110 \ |
110 v(Context, "meta: Context") \ | 111 v(Context, "meta: Context") \ |
111 v(ByteArray, "meta: ByteArray") \ | 112 v(ByteArray, "meta: ByteArray") \ |
112 v(PixelArray, "meta: PixelArray") \ | 113 v(ExternalPixelArray, "meta: PixelArray") \ |
113 v(ExternalArray, "meta: ExternalArray") \ | 114 v(ExternalArray, "meta: ExternalArray") \ |
114 v(FixedArray, "meta: FixedArray") \ | 115 v(FixedArray, "meta: FixedArray") \ |
115 v(String, "String") \ | 116 v(String, "String") \ |
116 v(HeapNumber, "HeapNumber") \ | 117 v(HeapNumber, "HeapNumber") \ |
117 \ | 118 \ |
118 v(Code, "meta: Code") \ | 119 v(Code, "meta: Code") \ |
119 v(Map, "meta: Map") \ | 120 v(Map, "meta: Map") \ |
120 v(Oddball, "Oddball") \ | 121 v(Oddball, "Oddball") \ |
121 v(Foreign, "meta: Foreign") \ | 122 v(Foreign, "meta: Foreign") \ |
122 v(SharedFunctionInfo, "meta: SharedFunctionInfo") \ | 123 v(SharedFunctionInfo, "meta: SharedFunctionInfo") \ |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
204 case 'o': | 205 case 'o': |
205 if (strcmp(key_str, "old-pointer") == 0) return OLD_POINTER_SPACE; | 206 if (strcmp(key_str, "old-pointer") == 0) return OLD_POINTER_SPACE; |
206 if (strcmp(key_str, "old-data") == 0) return OLD_DATA_SPACE; | 207 if (strcmp(key_str, "old-data") == 0) return OLD_DATA_SPACE; |
207 break; | 208 break; |
208 } | 209 } |
209 return kInvalidSpace; | 210 return kInvalidSpace; |
210 } | 211 } |
211 | 212 |
212 | 213 |
213 static bool InSpace(AllocationSpace space, HeapObject *heap_obj) { | 214 static bool InSpace(AllocationSpace space, HeapObject *heap_obj) { |
| 215 Heap* heap = ISOLATE->heap(); |
214 if (space != LO_SPACE) { | 216 if (space != LO_SPACE) { |
215 return Heap::InSpace(heap_obj, space); | 217 return heap->InSpace(heap_obj, space); |
216 } | 218 } |
217 | 219 |
218 // This is an optimization to speed up the check for an object in the LO | 220 // This is an optimization to speed up the check for an object in the LO |
219 // space by exclusion because we know that all object pointers passed in | 221 // space by exclusion because we know that all object pointers passed in |
220 // here are guaranteed to be in the heap. Hence, it is safe to infer | 222 // here are guaranteed to be in the heap. Hence, it is safe to infer |
221 // using an exclusion test. | 223 // using an exclusion test. |
222 // Note: calling Heap::InSpace(heap_obj, LO_SPACE) is too slow for our | 224 // Note: calling Heap::InSpace(heap_obj, LO_SPACE) is too slow for our |
223 // filters. | 225 // filters. |
224 int first_space = static_cast<int>(FIRST_SPACE); | 226 int first_space = static_cast<int>(FIRST_SPACE); |
225 int last_space = static_cast<int>(LO_SPACE); | 227 int last_space = static_cast<int>(LO_SPACE); |
226 for (int sp = first_space; sp < last_space; sp++) { | 228 for (int sp = first_space; sp < last_space; sp++) { |
227 if (Heap::InSpace(heap_obj, static_cast<AllocationSpace>(sp))) { | 229 if (heap->InSpace(heap_obj, static_cast<AllocationSpace>(sp))) { |
228 return false; | 230 return false; |
229 } | 231 } |
230 } | 232 } |
231 SLOW_ASSERT(Heap::InSpace(heap_obj, LO_SPACE)); | 233 SLOW_ASSERT(heap->InSpace(heap_obj, LO_SPACE)); |
232 return true; | 234 return true; |
233 } | 235 } |
234 | 236 |
235 | 237 |
236 static LiveObjectType FindTypeFor(String* type_str) { | 238 static LiveObjectType FindTypeFor(String* type_str) { |
237 SmartPointer<char> s = | 239 SmartPointer<char> s = |
238 type_str->ToCString(DISALLOW_NULLS, ROBUST_STRING_TRAVERSAL); | 240 type_str->ToCString(DISALLOW_NULLS, ROBUST_STRING_TRAVERSAL); |
239 | 241 |
240 #define CHECK_OBJECT_TYPE(type_, name) { \ | 242 #define CHECK_OBJECT_TYPE(type_, name) { \ |
241 const char* type_desc = GetObjectTypeDesc(kType##type_); \ | 243 const char* type_desc = GetObjectTypeDesc(kType##type_); \ |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
278 prop_() { | 280 prop_() { |
279 if (filter_obj.is_null()) return; | 281 if (filter_obj.is_null()) return; |
280 | 282 |
281 InitTypeFilter(filter_obj); | 283 InitTypeFilter(filter_obj); |
282 InitSpaceFilter(filter_obj); | 284 InitSpaceFilter(filter_obj); |
283 InitPropertyFilter(filter_obj); | 285 InitPropertyFilter(filter_obj); |
284 } | 286 } |
285 | 287 |
286 | 288 |
287 void LolFilter::InitTypeFilter(Handle<JSObject> filter_obj) { | 289 void LolFilter::InitTypeFilter(Handle<JSObject> filter_obj) { |
288 Handle<String> type_sym = Factory::LookupAsciiSymbol("type"); | 290 Handle<String> type_sym = FACTORY->LookupAsciiSymbol("type"); |
289 MaybeObject* maybe_result = filter_obj->GetProperty(*type_sym); | 291 MaybeObject* maybe_result = filter_obj->GetProperty(*type_sym); |
290 Object* type_obj; | 292 Object* type_obj; |
291 if (maybe_result->ToObject(&type_obj)) { | 293 if (maybe_result->ToObject(&type_obj)) { |
292 if (type_obj->IsString()) { | 294 if (type_obj->IsString()) { |
293 String* type_str = String::cast(type_obj); | 295 String* type_str = String::cast(type_obj); |
294 type_ = FindTypeFor(type_str); | 296 type_ = FindTypeFor(type_str); |
295 if (type_ != kInvalidLiveObjType) { | 297 if (type_ != kInvalidLiveObjType) { |
296 is_active_ = true; | 298 is_active_ = true; |
297 } | 299 } |
298 } | 300 } |
299 } | 301 } |
300 } | 302 } |
301 | 303 |
302 | 304 |
303 void LolFilter::InitSpaceFilter(Handle<JSObject> filter_obj) { | 305 void LolFilter::InitSpaceFilter(Handle<JSObject> filter_obj) { |
304 Handle<String> space_sym = Factory::LookupAsciiSymbol("space"); | 306 Handle<String> space_sym = FACTORY->LookupAsciiSymbol("space"); |
305 MaybeObject* maybe_result = filter_obj->GetProperty(*space_sym); | 307 MaybeObject* maybe_result = filter_obj->GetProperty(*space_sym); |
306 Object* space_obj; | 308 Object* space_obj; |
307 if (maybe_result->ToObject(&space_obj)) { | 309 if (maybe_result->ToObject(&space_obj)) { |
308 if (space_obj->IsString()) { | 310 if (space_obj->IsString()) { |
309 String* space_str = String::cast(space_obj); | 311 String* space_str = String::cast(space_obj); |
310 space_ = FindSpaceFor(space_str); | 312 space_ = FindSpaceFor(space_str); |
311 if (space_ != kInvalidSpace) { | 313 if (space_ != kInvalidSpace) { |
312 is_active_ = true; | 314 is_active_ = true; |
313 } | 315 } |
314 } | 316 } |
315 } | 317 } |
316 } | 318 } |
317 | 319 |
318 | 320 |
319 void LolFilter::InitPropertyFilter(Handle<JSObject> filter_obj) { | 321 void LolFilter::InitPropertyFilter(Handle<JSObject> filter_obj) { |
320 Handle<String> prop_sym = Factory::LookupAsciiSymbol("prop"); | 322 Handle<String> prop_sym = FACTORY->LookupAsciiSymbol("prop"); |
321 MaybeObject* maybe_result = filter_obj->GetProperty(*prop_sym); | 323 MaybeObject* maybe_result = filter_obj->GetProperty(*prop_sym); |
322 Object* prop_obj; | 324 Object* prop_obj; |
323 if (maybe_result->ToObject(&prop_obj)) { | 325 if (maybe_result->ToObject(&prop_obj)) { |
324 if (prop_obj->IsString()) { | 326 if (prop_obj->IsString()) { |
325 prop_ = Handle<String>(String::cast(prop_obj)); | 327 prop_ = Handle<String>(String::cast(prop_obj)); |
326 is_active_ = true; | 328 is_active_ = true; |
327 } | 329 } |
328 } | 330 } |
329 } | 331 } |
330 | 332 |
(...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
564 int index, | 566 int index, |
565 int obj_id, | 567 int obj_id, |
566 Handle<HeapObject> target, | 568 Handle<HeapObject> target, |
567 const char* desc_str, | 569 const char* desc_str, |
568 Handle<String> id_sym, | 570 Handle<String> id_sym, |
569 Handle<String> desc_sym, | 571 Handle<String> desc_sym, |
570 Handle<String> size_sym, | 572 Handle<String> size_sym, |
571 Handle<JSObject> detail, | 573 Handle<JSObject> detail, |
572 Handle<String> desc, | 574 Handle<String> desc, |
573 Handle<Object> error) { | 575 Handle<Object> error) { |
574 detail = Factory::NewJSObject(Top::object_function()); | 576 Isolate* isolate = Isolate::Current(); |
| 577 Factory* factory = isolate->factory(); |
| 578 detail = factory->NewJSObject(isolate->object_function()); |
575 if (detail->IsFailure()) { | 579 if (detail->IsFailure()) { |
576 error = detail; | 580 error = detail; |
577 return false; | 581 return false; |
578 } | 582 } |
579 | 583 |
580 int size = 0; | 584 int size = 0; |
581 char buffer[512]; | 585 char buffer[512]; |
582 if (desc_str == NULL) { | 586 if (desc_str == NULL) { |
583 ASSERT(!target.is_null()); | 587 ASSERT(!target.is_null()); |
584 HeapObject* obj = *target; | 588 HeapObject* obj = *target; |
585 GenerateObjectDesc(obj, buffer, sizeof(buffer)); | 589 GenerateObjectDesc(obj, buffer, sizeof(buffer)); |
586 desc_str = buffer; | 590 desc_str = buffer; |
587 size = obj->Size(); | 591 size = obj->Size(); |
588 } | 592 } |
589 desc = Factory::NewStringFromAscii(CStrVector(desc_str)); | 593 desc = factory->NewStringFromAscii(CStrVector(desc_str)); |
590 if (desc->IsFailure()) { | 594 if (desc->IsFailure()) { |
591 error = desc; | 595 error = desc; |
592 return false; | 596 return false; |
593 } | 597 } |
594 | 598 |
595 { MaybeObject* maybe_result = detail->SetProperty(*id_sym, | 599 { MaybeObject* maybe_result = detail->SetProperty(*id_sym, |
596 Smi::FromInt(obj_id), | 600 Smi::FromInt(obj_id), |
597 NONE, | 601 NONE, |
598 kNonStrictMode); | 602 kNonStrictMode); |
599 if (maybe_result->IsFailure()) return false; | 603 if (maybe_result->IsFailure()) return false; |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
656 bool Write(Handle<FixedArray> elements_arr, | 660 bool Write(Handle<FixedArray> elements_arr, |
657 int start, | 661 int start, |
658 int dump_limit, | 662 int dump_limit, |
659 LolFilter* filter, | 663 LolFilter* filter, |
660 Handle<Object> error) { | 664 Handle<Object> error) { |
661 // The lols are listed in latest to earliest. We want to dump from | 665 // The lols are listed in latest to earliest. We want to dump from |
662 // earliest to latest. So, compute the last element to start with. | 666 // earliest to latest. So, compute the last element to start with. |
663 int index = 0; | 667 int index = 0; |
664 int count = 0; | 668 int count = 0; |
665 | 669 |
| 670 Isolate* isolate = Isolate::Current(); |
| 671 Factory* factory = isolate->factory(); |
| 672 |
666 // Prefetch some needed symbols. | 673 // Prefetch some needed symbols. |
667 Handle<String> id_sym = Factory::LookupAsciiSymbol("id"); | 674 Handle<String> id_sym = factory->LookupAsciiSymbol("id"); |
668 Handle<String> desc_sym = Factory::LookupAsciiSymbol("desc"); | 675 Handle<String> desc_sym = factory->LookupAsciiSymbol("desc"); |
669 Handle<String> size_sym = Factory::LookupAsciiSymbol("size"); | 676 Handle<String> size_sym = factory->LookupAsciiSymbol("size"); |
670 | 677 |
671 // Fill the array with the lol object details. | 678 // Fill the array with the lol object details. |
672 Handle<JSObject> detail; | 679 Handle<JSObject> detail; |
673 Handle<String> desc; | 680 Handle<String> desc; |
674 Handle<HeapObject> target; | 681 Handle<HeapObject> target; |
675 | 682 |
676 LiveObjectList* first_lol = (older_ != NULL) ? | 683 LiveObjectList* first_lol = (older_ != NULL) ? |
677 older_->next_ : LiveObjectList::first_; | 684 older_->next_ : LiveObjectList::first_; |
678 LiveObjectList* last_lol = (newer_ != NULL) ? newer_->next_ : NULL; | 685 LiveObjectList* last_lol = (newer_ != NULL) ? newer_->next_ : NULL; |
679 | 686 |
(...skipping 402 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1082 HeapObject* heap_obj = NULL; | 1089 HeapObject* heap_obj = NULL; |
1083 while ((heap_obj = iterator.next()) != NULL) { | 1090 while ((heap_obj = iterator.next()) != NULL) { |
1084 count++; | 1091 count++; |
1085 } | 1092 } |
1086 return count; | 1093 return count; |
1087 } | 1094 } |
1088 | 1095 |
1089 | 1096 |
1090 // Captures a current snapshot of all objects in the heap. | 1097 // Captures a current snapshot of all objects in the heap. |
1091 MaybeObject* LiveObjectList::Capture() { | 1098 MaybeObject* LiveObjectList::Capture() { |
1092 HandleScope scope; | 1099 Isolate* isolate = Isolate::Current(); |
| 1100 Factory* factory = isolate->factory(); |
| 1101 HandleScope scope(isolate); |
1093 | 1102 |
1094 // Count the number of objects in the heap. | 1103 // Count the number of objects in the heap. |
1095 int total_count = CountHeapObjects(); | 1104 int total_count = CountHeapObjects(); |
1096 int count = total_count; | 1105 int count = total_count; |
1097 int size = 0; | 1106 int size = 0; |
1098 | 1107 |
1099 LiveObjectList* last_lol = last(); | 1108 LiveObjectList* last_lol = last(); |
1100 if (last_lol != NULL) { | 1109 if (last_lol != NULL) { |
1101 count -= last_lol->TotalObjCount(); | 1110 count -= last_lol->TotalObjCount(); |
1102 } | 1111 } |
(...skipping 29 matching lines...) Expand all Loading... |
1132 } | 1141 } |
1133 last_ = lol; | 1142 last_ = lol; |
1134 | 1143 |
1135 #ifdef VERIFY_LOL | 1144 #ifdef VERIFY_LOL |
1136 if (FLAG_verify_lol) { | 1145 if (FLAG_verify_lol) { |
1137 Verify(true); | 1146 Verify(true); |
1138 } | 1147 } |
1139 #endif | 1148 #endif |
1140 } | 1149 } |
1141 | 1150 |
1142 Handle<String> id_sym = Factory::LookupAsciiSymbol("id"); | 1151 Handle<String> id_sym = factory->LookupAsciiSymbol("id"); |
1143 Handle<String> count_sym = Factory::LookupAsciiSymbol("count"); | 1152 Handle<String> count_sym = factory->LookupAsciiSymbol("count"); |
1144 Handle<String> size_sym = Factory::LookupAsciiSymbol("size"); | 1153 Handle<String> size_sym = factory->LookupAsciiSymbol("size"); |
1145 | 1154 |
1146 Handle<JSObject> result = Factory::NewJSObject(Top::object_function()); | 1155 Handle<JSObject> result = factory->NewJSObject(isolate->object_function()); |
1147 if (result->IsFailure()) return Object::cast(*result); | 1156 if (result->IsFailure()) return Object::cast(*result); |
1148 | 1157 |
1149 { MaybeObject* maybe_result = result->SetProperty(*id_sym, | 1158 { MaybeObject* maybe_result = result->SetProperty(*id_sym, |
1150 Smi::FromInt(lol->id()), | 1159 Smi::FromInt(lol->id()), |
1151 NONE, | 1160 NONE, |
1152 kNonStrictMode); | 1161 kNonStrictMode); |
1153 if (maybe_result->IsFailure()) return maybe_result; | 1162 if (maybe_result->IsFailure()) return maybe_result; |
1154 } | 1163 } |
1155 { MaybeObject* maybe_result = result->SetProperty(*count_sym, | 1164 { MaybeObject* maybe_result = result->SetProperty(*count_sym, |
1156 Smi::FromInt(total_count), | 1165 Smi::FromInt(total_count), |
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1252 LolFilter filter(filter_obj); | 1261 LolFilter filter(filter_obj); |
1253 LolDumpWriter writer(older_lol, newer_lol); | 1262 LolDumpWriter writer(older_lol, newer_lol); |
1254 return DumpPrivate(&writer, start_idx, dump_limit, &filter); | 1263 return DumpPrivate(&writer, start_idx, dump_limit, &filter); |
1255 } | 1264 } |
1256 | 1265 |
1257 | 1266 |
1258 MaybeObject* LiveObjectList::DumpPrivate(DumpWriter* writer, | 1267 MaybeObject* LiveObjectList::DumpPrivate(DumpWriter* writer, |
1259 int start, | 1268 int start, |
1260 int dump_limit, | 1269 int dump_limit, |
1261 LolFilter* filter) { | 1270 LolFilter* filter) { |
1262 HandleScope scope; | 1271 Isolate* isolate = Isolate::Current(); |
| 1272 Factory* factory = isolate->factory(); |
| 1273 |
| 1274 HandleScope scope(isolate); |
1263 | 1275 |
1264 // Calculate the number of entries of the dump. | 1276 // Calculate the number of entries of the dump. |
1265 int count = -1; | 1277 int count = -1; |
1266 int size = -1; | 1278 int size = -1; |
1267 writer->ComputeTotalCountAndSize(filter, &count, &size); | 1279 writer->ComputeTotalCountAndSize(filter, &count, &size); |
1268 | 1280 |
1269 // Adjust for where to start the dump. | 1281 // Adjust for where to start the dump. |
1270 if ((start < 0) || (start >= count)) { | 1282 if ((start < 0) || (start >= count)) { |
1271 return Failure::Exception(); // invalid start. | 1283 return Failure::Exception(); // invalid start. |
1272 } | 1284 } |
1273 | 1285 |
1274 int remaining_count = count - start; | 1286 int remaining_count = count - start; |
1275 if (dump_limit > remaining_count) { | 1287 if (dump_limit > remaining_count) { |
1276 dump_limit = remaining_count; | 1288 dump_limit = remaining_count; |
1277 } | 1289 } |
1278 | 1290 |
1279 // Allocate an array to hold the result. | 1291 // Allocate an array to hold the result. |
1280 Handle<FixedArray> elements_arr = Factory::NewFixedArray(dump_limit); | 1292 Handle<FixedArray> elements_arr = factory->NewFixedArray(dump_limit); |
1281 if (elements_arr->IsFailure()) return Object::cast(*elements_arr); | 1293 if (elements_arr->IsFailure()) return Object::cast(*elements_arr); |
1282 | 1294 |
1283 // Fill in the dump. | 1295 // Fill in the dump. |
1284 Handle<Object> error; | 1296 Handle<Object> error; |
1285 bool success = writer->Write(elements_arr, | 1297 bool success = writer->Write(elements_arr, |
1286 start, | 1298 start, |
1287 dump_limit, | 1299 dump_limit, |
1288 filter, | 1300 filter, |
1289 error); | 1301 error); |
1290 if (!success) return Object::cast(*error); | 1302 if (!success) return Object::cast(*error); |
1291 | 1303 |
1292 MaybeObject* maybe_result; | 1304 MaybeObject* maybe_result; |
1293 | 1305 |
1294 // Allocate the result body. | 1306 // Allocate the result body. |
1295 Handle<JSObject> body = Factory::NewJSObject(Top::object_function()); | 1307 Handle<JSObject> body = factory->NewJSObject(isolate->object_function()); |
1296 if (body->IsFailure()) return Object::cast(*body); | 1308 if (body->IsFailure()) return Object::cast(*body); |
1297 | 1309 |
1298 // Set the updated body.count. | 1310 // Set the updated body.count. |
1299 Handle<String> count_sym = Factory::LookupAsciiSymbol("count"); | 1311 Handle<String> count_sym = factory->LookupAsciiSymbol("count"); |
1300 maybe_result = body->SetProperty(*count_sym, | 1312 maybe_result = body->SetProperty(*count_sym, |
1301 Smi::FromInt(count), | 1313 Smi::FromInt(count), |
1302 NONE, | 1314 NONE, |
1303 kNonStrictMode); | 1315 kNonStrictMode); |
1304 if (maybe_result->IsFailure()) return maybe_result; | 1316 if (maybe_result->IsFailure()) return maybe_result; |
1305 | 1317 |
1306 // Set the updated body.size if appropriate. | 1318 // Set the updated body.size if appropriate. |
1307 if (size >= 0) { | 1319 if (size >= 0) { |
1308 Handle<String> size_sym = Factory::LookupAsciiSymbol("size"); | 1320 Handle<String> size_sym = factory->LookupAsciiSymbol("size"); |
1309 maybe_result = body->SetProperty(*size_sym, | 1321 maybe_result = body->SetProperty(*size_sym, |
1310 Smi::FromInt(size), | 1322 Smi::FromInt(size), |
1311 NONE, | 1323 NONE, |
1312 kNonStrictMode); | 1324 kNonStrictMode); |
1313 if (maybe_result->IsFailure()) return maybe_result; | 1325 if (maybe_result->IsFailure()) return maybe_result; |
1314 } | 1326 } |
1315 | 1327 |
1316 // Set body.first_index. | 1328 // Set body.first_index. |
1317 Handle<String> first_sym = Factory::LookupAsciiSymbol("first_index"); | 1329 Handle<String> first_sym = factory->LookupAsciiSymbol("first_index"); |
1318 maybe_result = body->SetProperty(*first_sym, | 1330 maybe_result = body->SetProperty(*first_sym, |
1319 Smi::FromInt(start), | 1331 Smi::FromInt(start), |
1320 NONE, | 1332 NONE, |
1321 kNonStrictMode); | 1333 kNonStrictMode); |
1322 if (maybe_result->IsFailure()) return maybe_result; | 1334 if (maybe_result->IsFailure()) return maybe_result; |
1323 | 1335 |
1324 // Allocate the JSArray of the elements. | 1336 // Allocate the JSArray of the elements. |
1325 Handle<JSObject> elements = Factory::NewJSObject(Top::array_function()); | 1337 Handle<JSObject> elements = factory->NewJSObject(isolate->array_function()); |
1326 if (elements->IsFailure()) return Object::cast(*elements); | 1338 if (elements->IsFailure()) return Object::cast(*elements); |
1327 Handle<JSArray>::cast(elements)->SetContent(*elements_arr); | 1339 Handle<JSArray>::cast(elements)->SetContent(*elements_arr); |
1328 | 1340 |
1329 // Set body.elements. | 1341 // Set body.elements. |
1330 Handle<String> elements_sym = Factory::LookupAsciiSymbol("elements"); | 1342 Handle<String> elements_sym = factory->LookupAsciiSymbol("elements"); |
1331 maybe_result = body->SetProperty(*elements_sym, | 1343 maybe_result = body->SetProperty(*elements_sym, |
1332 *elements, | 1344 *elements, |
1333 NONE, | 1345 NONE, |
1334 kNonStrictMode); | 1346 kNonStrictMode); |
1335 if (maybe_result->IsFailure()) return maybe_result; | 1347 if (maybe_result->IsFailure()) return maybe_result; |
1336 | 1348 |
1337 return *body; | 1349 return *body; |
1338 } | 1350 } |
1339 | 1351 |
1340 | 1352 |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1374 // the summary. | 1386 // the summary. |
1375 MaybeObject* LiveObjectList::SummarizePrivate(SummaryWriter* writer, | 1387 MaybeObject* LiveObjectList::SummarizePrivate(SummaryWriter* writer, |
1376 LolFilter* filter, | 1388 LolFilter* filter, |
1377 bool is_tracking_roots) { | 1389 bool is_tracking_roots) { |
1378 HandleScope scope; | 1390 HandleScope scope; |
1379 MaybeObject* maybe_result; | 1391 MaybeObject* maybe_result; |
1380 | 1392 |
1381 LiveObjectSummary summary(filter); | 1393 LiveObjectSummary summary(filter); |
1382 writer->Write(&summary); | 1394 writer->Write(&summary); |
1383 | 1395 |
| 1396 Isolate* isolate = Isolate::Current(); |
| 1397 Factory* factory = isolate->factory(); |
| 1398 |
1384 // The result body will look like this: | 1399 // The result body will look like this: |
1385 // body: { | 1400 // body: { |
1386 // count: <total_count>, | 1401 // count: <total_count>, |
1387 // size: <total_size>, | 1402 // size: <total_size>, |
1388 // found_root: <boolean>, // optional. | 1403 // found_root: <boolean>, // optional. |
1389 // found_weak_root: <boolean>, // optional. | 1404 // found_weak_root: <boolean>, // optional. |
1390 // summary: [ | 1405 // summary: [ |
1391 // { | 1406 // { |
1392 // desc: "<object type name>", | 1407 // desc: "<object type name>", |
1393 // count: <count>, | 1408 // count: <count>, |
1394 // size: size | 1409 // size: size |
1395 // }, | 1410 // }, |
1396 // ... | 1411 // ... |
1397 // ] | 1412 // ] |
1398 // } | 1413 // } |
1399 | 1414 |
1400 // Prefetch some needed symbols. | 1415 // Prefetch some needed symbols. |
1401 Handle<String> desc_sym = Factory::LookupAsciiSymbol("desc"); | 1416 Handle<String> desc_sym = factory->LookupAsciiSymbol("desc"); |
1402 Handle<String> count_sym = Factory::LookupAsciiSymbol("count"); | 1417 Handle<String> count_sym = factory->LookupAsciiSymbol("count"); |
1403 Handle<String> size_sym = Factory::LookupAsciiSymbol("size"); | 1418 Handle<String> size_sym = factory->LookupAsciiSymbol("size"); |
1404 Handle<String> summary_sym = Factory::LookupAsciiSymbol("summary"); | 1419 Handle<String> summary_sym = factory->LookupAsciiSymbol("summary"); |
1405 | 1420 |
1406 // Allocate the summary array. | 1421 // Allocate the summary array. |
1407 int entries_count = summary.GetNumberOfEntries(); | 1422 int entries_count = summary.GetNumberOfEntries(); |
1408 Handle<FixedArray> summary_arr = | 1423 Handle<FixedArray> summary_arr = |
1409 Factory::NewFixedArray(entries_count); | 1424 factory->NewFixedArray(entries_count); |
1410 if (summary_arr->IsFailure()) return Object::cast(*summary_arr); | 1425 if (summary_arr->IsFailure()) return Object::cast(*summary_arr); |
1411 | 1426 |
1412 int idx = 0; | 1427 int idx = 0; |
1413 for (int i = 0; i < LiveObjectSummary::kNumberOfEntries; i++) { | 1428 for (int i = 0; i < LiveObjectSummary::kNumberOfEntries; i++) { |
1414 // Allocate the summary record. | 1429 // Allocate the summary record. |
1415 Handle<JSObject> detail = Factory::NewJSObject(Top::object_function()); | 1430 Handle<JSObject> detail = factory->NewJSObject(isolate->object_function()); |
1416 if (detail->IsFailure()) return Object::cast(*detail); | 1431 if (detail->IsFailure()) return Object::cast(*detail); |
1417 | 1432 |
1418 // Fill in the summary record. | 1433 // Fill in the summary record. |
1419 LiveObjectType type = static_cast<LiveObjectType>(i); | 1434 LiveObjectType type = static_cast<LiveObjectType>(i); |
1420 int count = summary.Count(type); | 1435 int count = summary.Count(type); |
1421 if (count) { | 1436 if (count) { |
1422 const char* desc_cstr = GetObjectTypeDesc(type); | 1437 const char* desc_cstr = GetObjectTypeDesc(type); |
1423 Handle<String> desc = Factory::LookupAsciiSymbol(desc_cstr); | 1438 Handle<String> desc = factory->LookupAsciiSymbol(desc_cstr); |
1424 int size = summary.Size(type); | 1439 int size = summary.Size(type); |
1425 | 1440 |
1426 maybe_result = detail->SetProperty(*desc_sym, | 1441 maybe_result = detail->SetProperty(*desc_sym, |
1427 *desc, | 1442 *desc, |
1428 NONE, | 1443 NONE, |
1429 kNonStrictMode); | 1444 kNonStrictMode); |
1430 if (maybe_result->IsFailure()) return maybe_result; | 1445 if (maybe_result->IsFailure()) return maybe_result; |
1431 maybe_result = detail->SetProperty(*count_sym, | 1446 maybe_result = detail->SetProperty(*count_sym, |
1432 Smi::FromInt(count), | 1447 Smi::FromInt(count), |
1433 NONE, | 1448 NONE, |
1434 kNonStrictMode); | 1449 kNonStrictMode); |
1435 if (maybe_result->IsFailure()) return maybe_result; | 1450 if (maybe_result->IsFailure()) return maybe_result; |
1436 maybe_result = detail->SetProperty(*size_sym, | 1451 maybe_result = detail->SetProperty(*size_sym, |
1437 Smi::FromInt(size), | 1452 Smi::FromInt(size), |
1438 NONE, | 1453 NONE, |
1439 kNonStrictMode); | 1454 kNonStrictMode); |
1440 if (maybe_result->IsFailure()) return maybe_result; | 1455 if (maybe_result->IsFailure()) return maybe_result; |
1441 | 1456 |
1442 summary_arr->set(idx++, *detail); | 1457 summary_arr->set(idx++, *detail); |
1443 } | 1458 } |
1444 } | 1459 } |
1445 | 1460 |
1446 // Wrap the summary fixed array in a JS array. | 1461 // Wrap the summary fixed array in a JS array. |
1447 Handle<JSObject> summary_obj = Factory::NewJSObject(Top::array_function()); | 1462 Handle<JSObject> summary_obj = |
| 1463 factory->NewJSObject(isolate->array_function()); |
1448 if (summary_obj->IsFailure()) return Object::cast(*summary_obj); | 1464 if (summary_obj->IsFailure()) return Object::cast(*summary_obj); |
1449 Handle<JSArray>::cast(summary_obj)->SetContent(*summary_arr); | 1465 Handle<JSArray>::cast(summary_obj)->SetContent(*summary_arr); |
1450 | 1466 |
1451 // Create the body object. | 1467 // Create the body object. |
1452 Handle<JSObject> body = Factory::NewJSObject(Top::object_function()); | 1468 Handle<JSObject> body = factory->NewJSObject(isolate->object_function()); |
1453 if (body->IsFailure()) return Object::cast(*body); | 1469 if (body->IsFailure()) return Object::cast(*body); |
1454 | 1470 |
1455 // Fill out the body object. | 1471 // Fill out the body object. |
1456 int total_count = summary.total_count(); | 1472 int total_count = summary.total_count(); |
1457 int total_size = summary.total_size(); | 1473 int total_size = summary.total_size(); |
1458 maybe_result = body->SetProperty(*count_sym, | 1474 maybe_result = body->SetProperty(*count_sym, |
1459 Smi::FromInt(total_count), | 1475 Smi::FromInt(total_count), |
1460 NONE, | 1476 NONE, |
1461 kNonStrictMode); | 1477 kNonStrictMode); |
1462 if (maybe_result->IsFailure()) return maybe_result; | 1478 if (maybe_result->IsFailure()) return maybe_result; |
1463 | 1479 |
1464 maybe_result = body->SetProperty(*size_sym, | 1480 maybe_result = body->SetProperty(*size_sym, |
1465 Smi::FromInt(total_size), | 1481 Smi::FromInt(total_size), |
1466 NONE, | 1482 NONE, |
1467 kNonStrictMode); | 1483 kNonStrictMode); |
1468 if (maybe_result->IsFailure()) return maybe_result; | 1484 if (maybe_result->IsFailure()) return maybe_result; |
1469 | 1485 |
1470 if (is_tracking_roots) { | 1486 if (is_tracking_roots) { |
1471 int found_root = summary.found_root(); | 1487 int found_root = summary.found_root(); |
1472 int found_weak_root = summary.found_weak_root(); | 1488 int found_weak_root = summary.found_weak_root(); |
1473 Handle<String> root_sym = Factory::LookupAsciiSymbol("found_root"); | 1489 Handle<String> root_sym = factory->LookupAsciiSymbol("found_root"); |
1474 Handle<String> weak_root_sym = | 1490 Handle<String> weak_root_sym = |
1475 Factory::LookupAsciiSymbol("found_weak_root"); | 1491 factory->LookupAsciiSymbol("found_weak_root"); |
1476 maybe_result = body->SetProperty(*root_sym, | 1492 maybe_result = body->SetProperty(*root_sym, |
1477 Smi::FromInt(found_root), | 1493 Smi::FromInt(found_root), |
1478 NONE, | 1494 NONE, |
1479 kNonStrictMode); | 1495 kNonStrictMode); |
1480 if (maybe_result->IsFailure()) return maybe_result; | 1496 if (maybe_result->IsFailure()) return maybe_result; |
1481 maybe_result = body->SetProperty(*weak_root_sym, | 1497 maybe_result = body->SetProperty(*weak_root_sym, |
1482 Smi::FromInt(found_weak_root), | 1498 Smi::FromInt(found_weak_root), |
1483 NONE, | 1499 NONE, |
1484 kNonStrictMode); | 1500 kNonStrictMode); |
1485 if (maybe_result->IsFailure()) return maybe_result; | 1501 if (maybe_result->IsFailure()) return maybe_result; |
1486 } | 1502 } |
1487 | 1503 |
1488 maybe_result = body->SetProperty(*summary_sym, | 1504 maybe_result = body->SetProperty(*summary_sym, |
1489 *summary_obj, | 1505 *summary_obj, |
1490 NONE, | 1506 NONE, |
1491 kNonStrictMode); | 1507 kNonStrictMode); |
1492 if (maybe_result->IsFailure()) return maybe_result; | 1508 if (maybe_result->IsFailure()) return maybe_result; |
1493 | 1509 |
1494 return *body; | 1510 return *body; |
1495 } | 1511 } |
1496 | 1512 |
1497 | 1513 |
1498 // Returns an array listing the captured lols. | 1514 // Returns an array listing the captured lols. |
1499 // Note: only dumps the section starting at start_idx and only up to | 1515 // Note: only dumps the section starting at start_idx and only up to |
1500 // dump_limit entries. | 1516 // dump_limit entries. |
1501 MaybeObject* LiveObjectList::Info(int start_idx, int dump_limit) { | 1517 MaybeObject* LiveObjectList::Info(int start_idx, int dump_limit) { |
1502 HandleScope scope; | 1518 Isolate* isolate = Isolate::Current(); |
| 1519 Factory* factory = isolate->factory(); |
| 1520 |
| 1521 HandleScope scope(isolate); |
1503 MaybeObject* maybe_result; | 1522 MaybeObject* maybe_result; |
1504 | 1523 |
1505 int total_count = LiveObjectList::list_count(); | 1524 int total_count = LiveObjectList::list_count(); |
1506 int dump_count = total_count; | 1525 int dump_count = total_count; |
1507 | 1526 |
1508 // Adjust for where to start the dump. | 1527 // Adjust for where to start the dump. |
1509 if (total_count == 0) { | 1528 if (total_count == 0) { |
1510 start_idx = 0; // Ensure this to get an empty list. | 1529 start_idx = 0; // Ensure this to get an empty list. |
1511 } else if ((start_idx < 0) || (start_idx >= total_count)) { | 1530 } else if ((start_idx < 0) || (start_idx >= total_count)) { |
1512 return Failure::Exception(); // invalid start. | 1531 return Failure::Exception(); // invalid start. |
1513 } | 1532 } |
1514 dump_count -= start_idx; | 1533 dump_count -= start_idx; |
1515 | 1534 |
1516 // Adjust for the dump limit. | 1535 // Adjust for the dump limit. |
1517 if (dump_count > dump_limit) { | 1536 if (dump_count > dump_limit) { |
1518 dump_count = dump_limit; | 1537 dump_count = dump_limit; |
1519 } | 1538 } |
1520 | 1539 |
1521 // Allocate an array to hold the result. | 1540 // Allocate an array to hold the result. |
1522 Handle<FixedArray> list = Factory::NewFixedArray(dump_count); | 1541 Handle<FixedArray> list = factory->NewFixedArray(dump_count); |
1523 if (list->IsFailure()) return Object::cast(*list); | 1542 if (list->IsFailure()) return Object::cast(*list); |
1524 | 1543 |
1525 // Prefetch some needed symbols. | 1544 // Prefetch some needed symbols. |
1526 Handle<String> id_sym = Factory::LookupAsciiSymbol("id"); | 1545 Handle<String> id_sym = factory->LookupAsciiSymbol("id"); |
1527 Handle<String> count_sym = Factory::LookupAsciiSymbol("count"); | 1546 Handle<String> count_sym = factory->LookupAsciiSymbol("count"); |
1528 Handle<String> size_sym = Factory::LookupAsciiSymbol("size"); | 1547 Handle<String> size_sym = factory->LookupAsciiSymbol("size"); |
1529 | 1548 |
1530 // Fill the array with the lol details. | 1549 // Fill the array with the lol details. |
1531 int idx = 0; | 1550 int idx = 0; |
1532 LiveObjectList* lol = first_; | 1551 LiveObjectList* lol = first_; |
1533 while ((lol != NULL) && (idx < start_idx)) { // Skip tail entries. | 1552 while ((lol != NULL) && (idx < start_idx)) { // Skip tail entries. |
1534 if (lol->id() != 0) { | 1553 if (lol->id() != 0) { |
1535 idx++; | 1554 idx++; |
1536 } | 1555 } |
1537 lol = lol->next(); | 1556 lol = lol->next(); |
1538 } | 1557 } |
1539 idx = 0; | 1558 idx = 0; |
1540 while ((lol != NULL) && (dump_limit != 0)) { | 1559 while ((lol != NULL) && (dump_limit != 0)) { |
1541 if (lol->id() != 0) { | 1560 if (lol->id() != 0) { |
1542 int count; | 1561 int count; |
1543 int size; | 1562 int size; |
1544 count = lol->GetTotalObjCountAndSize(&size); | 1563 count = lol->GetTotalObjCountAndSize(&size); |
1545 | 1564 |
1546 Handle<JSObject> detail = Factory::NewJSObject(Top::object_function()); | 1565 Handle<JSObject> detail = |
| 1566 factory->NewJSObject(isolate->object_function()); |
1547 if (detail->IsFailure()) return Object::cast(*detail); | 1567 if (detail->IsFailure()) return Object::cast(*detail); |
1548 | 1568 |
1549 maybe_result = detail->SetProperty(*id_sym, | 1569 maybe_result = detail->SetProperty(*id_sym, |
1550 Smi::FromInt(lol->id()), | 1570 Smi::FromInt(lol->id()), |
1551 NONE, | 1571 NONE, |
1552 kNonStrictMode); | 1572 kNonStrictMode); |
1553 if (maybe_result->IsFailure()) return maybe_result; | 1573 if (maybe_result->IsFailure()) return maybe_result; |
1554 maybe_result = detail->SetProperty(*count_sym, | 1574 maybe_result = detail->SetProperty(*count_sym, |
1555 Smi::FromInt(count), | 1575 Smi::FromInt(count), |
1556 NONE, | 1576 NONE, |
1557 kNonStrictMode); | 1577 kNonStrictMode); |
1558 if (maybe_result->IsFailure()) return maybe_result; | 1578 if (maybe_result->IsFailure()) return maybe_result; |
1559 maybe_result = detail->SetProperty(*size_sym, | 1579 maybe_result = detail->SetProperty(*size_sym, |
1560 Smi::FromInt(size), | 1580 Smi::FromInt(size), |
1561 NONE, | 1581 NONE, |
1562 kNonStrictMode); | 1582 kNonStrictMode); |
1563 if (maybe_result->IsFailure()) return maybe_result; | 1583 if (maybe_result->IsFailure()) return maybe_result; |
1564 list->set(idx++, *detail); | 1584 list->set(idx++, *detail); |
1565 dump_limit--; | 1585 dump_limit--; |
1566 } | 1586 } |
1567 lol = lol->next(); | 1587 lol = lol->next(); |
1568 } | 1588 } |
1569 | 1589 |
1570 // Return the result as a JS array. | 1590 // Return the result as a JS array. |
1571 Handle<JSObject> lols = Factory::NewJSObject(Top::array_function()); | 1591 Handle<JSObject> lols = factory->NewJSObject(isolate->array_function()); |
1572 Handle<JSArray>::cast(lols)->SetContent(*list); | 1592 Handle<JSArray>::cast(lols)->SetContent(*list); |
1573 | 1593 |
1574 Handle<JSObject> result = Factory::NewJSObject(Top::object_function()); | 1594 Handle<JSObject> result = factory->NewJSObject(isolate->object_function()); |
1575 if (result->IsFailure()) return Object::cast(*result); | 1595 if (result->IsFailure()) return Object::cast(*result); |
1576 | 1596 |
1577 maybe_result = result->SetProperty(*count_sym, | 1597 maybe_result = result->SetProperty(*count_sym, |
1578 Smi::FromInt(total_count), | 1598 Smi::FromInt(total_count), |
1579 NONE, | 1599 NONE, |
1580 kNonStrictMode); | 1600 kNonStrictMode); |
1581 if (maybe_result->IsFailure()) return maybe_result; | 1601 if (maybe_result->IsFailure()) return maybe_result; |
1582 | 1602 |
1583 Handle<String> first_sym = Factory::LookupAsciiSymbol("first_index"); | 1603 Handle<String> first_sym = factory->LookupAsciiSymbol("first_index"); |
1584 maybe_result = result->SetProperty(*first_sym, | 1604 maybe_result = result->SetProperty(*first_sym, |
1585 Smi::FromInt(start_idx), | 1605 Smi::FromInt(start_idx), |
1586 NONE, | 1606 NONE, |
1587 kNonStrictMode); | 1607 kNonStrictMode); |
1588 if (maybe_result->IsFailure()) return maybe_result; | 1608 if (maybe_result->IsFailure()) return maybe_result; |
1589 | 1609 |
1590 Handle<String> lists_sym = Factory::LookupAsciiSymbol("lists"); | 1610 Handle<String> lists_sym = factory->LookupAsciiSymbol("lists"); |
1591 maybe_result = result->SetProperty(*lists_sym, | 1611 maybe_result = result->SetProperty(*lists_sym, |
1592 *lols, | 1612 *lols, |
1593 NONE, | 1613 NONE, |
1594 kNonStrictMode); | 1614 kNonStrictMode); |
1595 if (maybe_result->IsFailure()) return maybe_result; | 1615 if (maybe_result->IsFailure()) return maybe_result; |
1596 | 1616 |
1597 return *result; | 1617 return *result; |
1598 } | 1618 } |
1599 | 1619 |
1600 | 1620 |
(...skipping 10 matching lines...) Expand all Loading... |
1611 last_ = NULL; | 1631 last_ = NULL; |
1612 } | 1632 } |
1613 | 1633 |
1614 | 1634 |
1615 // Gets the object for the specified obj id. | 1635 // Gets the object for the specified obj id. |
1616 Object* LiveObjectList::GetObj(int obj_id) { | 1636 Object* LiveObjectList::GetObj(int obj_id) { |
1617 Element* element = FindElementFor<int>(GetElementId, obj_id); | 1637 Element* element = FindElementFor<int>(GetElementId, obj_id); |
1618 if (element != NULL) { | 1638 if (element != NULL) { |
1619 return Object::cast(element->obj_); | 1639 return Object::cast(element->obj_); |
1620 } | 1640 } |
1621 return Heap::undefined_value(); | 1641 return HEAP->undefined_value(); |
1622 } | 1642 } |
1623 | 1643 |
1624 | 1644 |
1625 // Gets the obj id for the specified address if valid. | 1645 // Gets the obj id for the specified address if valid. |
1626 int LiveObjectList::GetObjId(Object* obj) { | 1646 int LiveObjectList::GetObjId(Object* obj) { |
1627 // Make a heap object pointer from the address. | 1647 // Make a heap object pointer from the address. |
1628 HeapObject* hobj = HeapObject::cast(obj); | 1648 HeapObject* hobj = HeapObject::cast(obj); |
1629 Element* element = FindElementFor<HeapObject*>(GetElementObj, hobj); | 1649 Element* element = FindElementFor<HeapObject*>(GetElementObj, hobj); |
1630 if (element != NULL) { | 1650 if (element != NULL) { |
1631 return element->id_; | 1651 return element->id_; |
1632 } | 1652 } |
1633 return 0; // Invalid address. | 1653 return 0; // Invalid address. |
1634 } | 1654 } |
1635 | 1655 |
1636 | 1656 |
1637 // Gets the obj id for the specified address if valid. | 1657 // Gets the obj id for the specified address if valid. |
1638 Object* LiveObjectList::GetObjId(Handle<String> address) { | 1658 Object* LiveObjectList::GetObjId(Handle<String> address) { |
1639 SmartPointer<char> addr_str = | 1659 SmartPointer<char> addr_str = |
1640 address->ToCString(DISALLOW_NULLS, ROBUST_STRING_TRAVERSAL); | 1660 address->ToCString(DISALLOW_NULLS, ROBUST_STRING_TRAVERSAL); |
1641 | 1661 |
| 1662 Isolate* isolate = Isolate::Current(); |
| 1663 |
1642 // Extract the address value from the string. | 1664 // Extract the address value from the string. |
1643 int value = static_cast<int>(StringToInt(*address, 16)); | 1665 int value = |
| 1666 static_cast<int>(StringToInt(isolate->unicode_cache(), *address, 16)); |
1644 Object* obj = reinterpret_cast<Object*>(value); | 1667 Object* obj = reinterpret_cast<Object*>(value); |
1645 return Smi::FromInt(GetObjId(obj)); | 1668 return Smi::FromInt(GetObjId(obj)); |
1646 } | 1669 } |
1647 | 1670 |
1648 | 1671 |
1649 // Helper class for copying HeapObjects. | 1672 // Helper class for copying HeapObjects. |
1650 class LolVisitor: public ObjectVisitor { | 1673 class LolVisitor: public ObjectVisitor { |
1651 public: | 1674 public: |
1652 LolVisitor(HeapObject* target, Handle<HeapObject> handle_to_skip) | 1675 LolVisitor(HeapObject* target, Handle<HeapObject> handle_to_skip) |
1653 : target_(target), handle_to_skip_(handle_to_skip), found_(false) {} | 1676 : target_(target), handle_to_skip_(handle_to_skip), found_(false) {} |
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1753 LiveObjectSummary *summary, | 1776 LiveObjectSummary *summary, |
1754 JSFunction* arguments_function, | 1777 JSFunction* arguments_function, |
1755 Handle<Object> error) { | 1778 Handle<Object> error) { |
1756 HandleScope scope; | 1779 HandleScope scope; |
1757 | 1780 |
1758 // Scratch handles. | 1781 // Scratch handles. |
1759 Handle<JSObject> detail; | 1782 Handle<JSObject> detail; |
1760 Handle<String> desc; | 1783 Handle<String> desc; |
1761 Handle<HeapObject> retainer; | 1784 Handle<HeapObject> retainer; |
1762 | 1785 |
| 1786 Isolate* isolate = Isolate::Current(); |
| 1787 Factory* factory = isolate->factory(); |
| 1788 |
1763 // Prefetch some needed symbols. | 1789 // Prefetch some needed symbols. |
1764 Handle<String> id_sym = Factory::LookupAsciiSymbol("id"); | 1790 Handle<String> id_sym = factory->LookupAsciiSymbol("id"); |
1765 Handle<String> desc_sym = Factory::LookupAsciiSymbol("desc"); | 1791 Handle<String> desc_sym = factory->LookupAsciiSymbol("desc"); |
1766 Handle<String> size_sym = Factory::LookupAsciiSymbol("size"); | 1792 Handle<String> size_sym = factory->LookupAsciiSymbol("size"); |
1767 | 1793 |
1768 NoHandleAllocation ha; | 1794 NoHandleAllocation ha; |
1769 int count = 0; | 1795 int count = 0; |
1770 int index = 0; | 1796 int index = 0; |
1771 Handle<JSObject> last_obj; | 1797 Handle<JSObject> last_obj; |
1772 | 1798 |
1773 *total_count = 0; | 1799 *total_count = 0; |
1774 | 1800 |
1775 // Iterate roots. | 1801 // Iterate roots. |
1776 LolVisitor lol_visitor(*target, target); | 1802 LolVisitor lol_visitor(*target, target); |
1777 Heap::IterateStrongRoots(&lol_visitor, VISIT_ALL); | 1803 isolate->heap()->IterateStrongRoots(&lol_visitor, VISIT_ALL); |
1778 if (!AddRootRetainerIfFound(lol_visitor, | 1804 if (!AddRootRetainerIfFound(lol_visitor, |
1779 filter, | 1805 filter, |
1780 summary, | 1806 summary, |
1781 SetFoundRoot, | 1807 SetFoundRoot, |
1782 start, | 1808 start, |
1783 dump_limit, | 1809 dump_limit, |
1784 total_count, | 1810 total_count, |
1785 retainers_arr, | 1811 retainers_arr, |
1786 &count, | 1812 &count, |
1787 &index, | 1813 &index, |
1788 "<root>", | 1814 "<root>", |
1789 id_sym, | 1815 id_sym, |
1790 desc_sym, | 1816 desc_sym, |
1791 size_sym, | 1817 size_sym, |
1792 error)) { | 1818 error)) { |
1793 return -1; | 1819 return -1; |
1794 } | 1820 } |
1795 | 1821 |
1796 lol_visitor.reset(); | 1822 lol_visitor.reset(); |
1797 Heap::IterateWeakRoots(&lol_visitor, VISIT_ALL); | 1823 isolate->heap()->IterateWeakRoots(&lol_visitor, VISIT_ALL); |
1798 if (!AddRootRetainerIfFound(lol_visitor, | 1824 if (!AddRootRetainerIfFound(lol_visitor, |
1799 filter, | 1825 filter, |
1800 summary, | 1826 summary, |
1801 SetFoundWeakRoot, | 1827 SetFoundWeakRoot, |
1802 start, | 1828 start, |
1803 dump_limit, | 1829 dump_limit, |
1804 total_count, | 1830 total_count, |
1805 retainers_arr, | 1831 retainers_arr, |
1806 &count, | 1832 &count, |
1807 &index, | 1833 &index, |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1896 return count; | 1922 return count; |
1897 } | 1923 } |
1898 | 1924 |
1899 | 1925 |
1900 MaybeObject* LiveObjectList::GetObjRetainers(int obj_id, | 1926 MaybeObject* LiveObjectList::GetObjRetainers(int obj_id, |
1901 Handle<JSObject> instance_filter, | 1927 Handle<JSObject> instance_filter, |
1902 bool verbose, | 1928 bool verbose, |
1903 int start, | 1929 int start, |
1904 int dump_limit, | 1930 int dump_limit, |
1905 Handle<JSObject> filter_obj) { | 1931 Handle<JSObject> filter_obj) { |
1906 HandleScope scope; | 1932 Isolate* isolate = Isolate::Current(); |
| 1933 Factory* factory = isolate->factory(); |
| 1934 Heap* heap = isolate->heap(); |
| 1935 |
| 1936 HandleScope scope(isolate); |
1907 | 1937 |
1908 // Get the target object. | 1938 // Get the target object. |
1909 HeapObject* heap_obj = HeapObject::cast(GetObj(obj_id)); | 1939 HeapObject* heap_obj = HeapObject::cast(GetObj(obj_id)); |
1910 if (heap_obj == Heap::undefined_value()) { | 1940 if (heap_obj == heap->undefined_value()) { |
1911 return heap_obj; | 1941 return heap_obj; |
1912 } | 1942 } |
1913 | 1943 |
1914 Handle<HeapObject> target = Handle<HeapObject>(heap_obj); | 1944 Handle<HeapObject> target = Handle<HeapObject>(heap_obj); |
1915 | 1945 |
1916 // Get the constructor function for context extension and arguments array. | 1946 // Get the constructor function for context extension and arguments array. |
1917 JSObject* arguments_boilerplate = | 1947 JSObject* arguments_boilerplate = |
1918 Top::context()->global_context()->arguments_boilerplate(); | 1948 isolate->context()->global_context()->arguments_boilerplate(); |
1919 JSFunction* arguments_function = | 1949 JSFunction* arguments_function = |
1920 JSFunction::cast(arguments_boilerplate->map()->constructor()); | 1950 JSFunction::cast(arguments_boilerplate->map()->constructor()); |
1921 | 1951 |
1922 Handle<JSFunction> args_function = Handle<JSFunction>(arguments_function); | 1952 Handle<JSFunction> args_function = Handle<JSFunction>(arguments_function); |
1923 LolFilter filter(filter_obj); | 1953 LolFilter filter(filter_obj); |
1924 | 1954 |
1925 if (!verbose) { | 1955 if (!verbose) { |
1926 RetainersSummaryWriter writer(target, instance_filter, args_function); | 1956 RetainersSummaryWriter writer(target, instance_filter, args_function); |
1927 return SummarizePrivate(&writer, &filter, true); | 1957 return SummarizePrivate(&writer, &filter, true); |
1928 | 1958 |
1929 } else { | 1959 } else { |
1930 RetainersDumpWriter writer(target, instance_filter, args_function); | 1960 RetainersDumpWriter writer(target, instance_filter, args_function); |
1931 Object* body_obj; | 1961 Object* body_obj; |
1932 MaybeObject* maybe_result = | 1962 MaybeObject* maybe_result = |
1933 DumpPrivate(&writer, start, dump_limit, &filter); | 1963 DumpPrivate(&writer, start, dump_limit, &filter); |
1934 if (!maybe_result->ToObject(&body_obj)) { | 1964 if (!maybe_result->ToObject(&body_obj)) { |
1935 return maybe_result; | 1965 return maybe_result; |
1936 } | 1966 } |
1937 | 1967 |
1938 // Set body.id. | 1968 // Set body.id. |
1939 Handle<JSObject> body = Handle<JSObject>(JSObject::cast(body_obj)); | 1969 Handle<JSObject> body = Handle<JSObject>(JSObject::cast(body_obj)); |
1940 Handle<String> id_sym = Factory::LookupAsciiSymbol("id"); | 1970 Handle<String> id_sym = factory->LookupAsciiSymbol("id"); |
1941 maybe_result = body->SetProperty(*id_sym, | 1971 maybe_result = body->SetProperty(*id_sym, |
1942 Smi::FromInt(obj_id), | 1972 Smi::FromInt(obj_id), |
1943 NONE, | 1973 NONE, |
1944 kNonStrictMode); | 1974 kNonStrictMode); |
1945 if (maybe_result->IsFailure()) return maybe_result; | 1975 if (maybe_result->IsFailure()) return maybe_result; |
1946 | 1976 |
1947 return *body; | 1977 return *body; |
1948 } | 1978 } |
1949 } | 1979 } |
1950 | 1980 |
1951 | 1981 |
1952 Object* LiveObjectList::PrintObj(int obj_id) { | 1982 Object* LiveObjectList::PrintObj(int obj_id) { |
1953 Object* obj = GetObj(obj_id); | 1983 Object* obj = GetObj(obj_id); |
1954 if (!obj) { | 1984 if (!obj) { |
1955 return Heap::undefined_value(); | 1985 return HEAP->undefined_value(); |
1956 } | 1986 } |
1957 | 1987 |
1958 EmbeddedVector<char, 128> temp_filename; | 1988 EmbeddedVector<char, 128> temp_filename; |
1959 static int temp_count = 0; | 1989 static int temp_count = 0; |
1960 const char* path_prefix = "."; | 1990 const char* path_prefix = "."; |
1961 | 1991 |
| 1992 Isolate* isolate = Isolate::Current(); |
| 1993 Factory* factory = isolate->factory(); |
| 1994 Heap* heap = isolate->heap(); |
| 1995 |
1962 if (FLAG_lol_workdir) { | 1996 if (FLAG_lol_workdir) { |
1963 path_prefix = FLAG_lol_workdir; | 1997 path_prefix = FLAG_lol_workdir; |
1964 } | 1998 } |
1965 OS::SNPrintF(temp_filename, "%s/lol-print-%d", path_prefix, ++temp_count); | 1999 OS::SNPrintF(temp_filename, "%s/lol-print-%d", path_prefix, ++temp_count); |
1966 | 2000 |
1967 FILE* f = OS::FOpen(temp_filename.start(), "w+"); | 2001 FILE* f = OS::FOpen(temp_filename.start(), "w+"); |
1968 | 2002 |
1969 PrintF(f, "@%d ", LiveObjectList::GetObjId(obj)); | 2003 PrintF(f, "@%d ", LiveObjectList::GetObjId(obj)); |
1970 #ifdef OBJECT_PRINT | 2004 #ifdef OBJECT_PRINT |
1971 #ifdef INSPECTOR | 2005 #ifdef INSPECTOR |
1972 Inspector::DumpObjectType(f, obj); | 2006 Inspector::DumpObjectType(f, obj); |
1973 #endif // INSPECTOR | 2007 #endif // INSPECTOR |
1974 PrintF(f, "\n"); | 2008 PrintF(f, "\n"); |
1975 obj->Print(f); | 2009 obj->Print(f); |
1976 #else // !OBJECT_PRINT | 2010 #else // !OBJECT_PRINT |
1977 obj->ShortPrint(f); | 2011 obj->ShortPrint(f); |
1978 #endif // !OBJECT_PRINT | 2012 #endif // !OBJECT_PRINT |
1979 PrintF(f, "\n"); | 2013 PrintF(f, "\n"); |
1980 Flush(f); | 2014 Flush(f); |
1981 fclose(f); | 2015 fclose(f); |
1982 | 2016 |
1983 // Create a string from the temp_file. | 2017 // Create a string from the temp_file. |
1984 // Note: the mmapped resource will take care of closing the file. | 2018 // Note: the mmapped resource will take care of closing the file. |
1985 MemoryMappedExternalResource* resource = | 2019 MemoryMappedExternalResource* resource = |
1986 new MemoryMappedExternalResource(temp_filename.start(), true); | 2020 new MemoryMappedExternalResource(temp_filename.start(), true); |
1987 if (resource->exists() && !resource->is_empty()) { | 2021 if (resource->exists() && !resource->is_empty()) { |
1988 ASSERT(resource->IsAscii()); | 2022 ASSERT(resource->IsAscii()); |
1989 Handle<String> dump_string = | 2023 Handle<String> dump_string = |
1990 Factory::NewExternalStringFromAscii(resource); | 2024 factory->NewExternalStringFromAscii(resource); |
1991 ExternalStringTable::AddString(*dump_string); | 2025 heap->external_string_table()->AddString(*dump_string); |
1992 return *dump_string; | 2026 return *dump_string; |
1993 } else { | 2027 } else { |
1994 delete resource; | 2028 delete resource; |
1995 } | 2029 } |
1996 return Heap::undefined_value(); | 2030 return HEAP->undefined_value(); |
1997 } | 2031 } |
1998 | 2032 |
1999 | 2033 |
2000 class LolPathTracer: public PathTracer { | 2034 class LolPathTracer: public PathTracer { |
2001 public: | 2035 public: |
2002 LolPathTracer(FILE* out, | 2036 LolPathTracer(FILE* out, |
2003 Object* search_target, | 2037 Object* search_target, |
2004 WhatToFind what_to_find) | 2038 WhatToFind what_to_find) |
2005 : PathTracer(search_target, what_to_find, VISIT_ONLY_STRONG), out_(out) {} | 2039 : PathTracer(search_target, what_to_find, VISIT_ONLY_STRONG), out_(out) {} |
2006 | 2040 |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2074 static int temp_count = 0; | 2108 static int temp_count = 0; |
2075 const char* path_prefix = "."; | 2109 const char* path_prefix = "."; |
2076 | 2110 |
2077 if (FLAG_lol_workdir) { | 2111 if (FLAG_lol_workdir) { |
2078 path_prefix = FLAG_lol_workdir; | 2112 path_prefix = FLAG_lol_workdir; |
2079 } | 2113 } |
2080 OS::SNPrintF(temp_filename, "%s/lol-getpath-%d", path_prefix, ++temp_count); | 2114 OS::SNPrintF(temp_filename, "%s/lol-getpath-%d", path_prefix, ++temp_count); |
2081 | 2115 |
2082 FILE* f = OS::FOpen(temp_filename.start(), "w+"); | 2116 FILE* f = OS::FOpen(temp_filename.start(), "w+"); |
2083 | 2117 |
| 2118 Isolate* isolate = Isolate::Current(); |
| 2119 Factory* factory = isolate->factory(); |
| 2120 Heap* heap = isolate->heap(); |
| 2121 |
2084 // Save the previous verbosity. | 2122 // Save the previous verbosity. |
2085 bool prev_verbosity = FLAG_use_verbose_printer; | 2123 bool prev_verbosity = FLAG_use_verbose_printer; |
2086 FLAG_use_verbose_printer = false; | 2124 FLAG_use_verbose_printer = false; |
2087 | 2125 |
2088 // Dump the paths. | 2126 // Dump the paths. |
2089 { | 2127 { |
2090 // The tracer needs to be scoped because its usage asserts no allocation, | 2128 // The tracer needs to be scoped because its usage asserts no allocation, |
2091 // and we need to allocate the result string below. | 2129 // and we need to allocate the result string below. |
2092 LolPathTracer tracer(f, obj2, LolPathTracer::FIND_FIRST); | 2130 LolPathTracer tracer(f, obj2, LolPathTracer::FIND_FIRST); |
2093 | 2131 |
2094 bool found = false; | 2132 bool found = false; |
2095 if (obj1 == NULL) { | 2133 if (obj1 == NULL) { |
2096 // Check for ObjectGroups that references this object. | 2134 // Check for ObjectGroups that references this object. |
2097 // TODO(mlam): refactor this to be more modular. | 2135 // TODO(mlam): refactor this to be more modular. |
2098 { | 2136 { |
2099 List<ObjectGroup*>* groups = GlobalHandles::ObjectGroups(); | 2137 List<ObjectGroup*>* groups = isolate->global_handles()->object_groups(); |
2100 for (int i = 0; i < groups->length(); i++) { | 2138 for (int i = 0; i < groups->length(); i++) { |
2101 ObjectGroup* group = groups->at(i); | 2139 ObjectGroup* group = groups->at(i); |
2102 if (group == NULL) continue; | 2140 if (group == NULL) continue; |
2103 | 2141 |
2104 bool found_group = false; | 2142 bool found_group = false; |
2105 List<Object**>& objects = group->objects_; | 2143 for (size_t j = 0; j < group->length_; j++) { |
2106 for (int j = 0; j < objects.length(); j++) { | 2144 Object* object = *(group->objects_[j]); |
2107 Object* object = *objects[j]; | |
2108 HeapObject* hobj = HeapObject::cast(object); | 2145 HeapObject* hobj = HeapObject::cast(object); |
2109 if (obj2 == hobj) { | 2146 if (obj2 == hobj) { |
2110 found_group = true; | 2147 found_group = true; |
2111 break; | 2148 break; |
2112 } | 2149 } |
2113 } | 2150 } |
2114 | 2151 |
2115 if (found_group) { | 2152 if (found_group) { |
2116 PrintF(f, | 2153 PrintF(f, |
2117 "obj %p is a member of object group %p {\n", | 2154 "obj %p is a member of object group %p {\n", |
2118 reinterpret_cast<void*>(obj2), | 2155 reinterpret_cast<void*>(obj2), |
2119 reinterpret_cast<void*>(group)); | 2156 reinterpret_cast<void*>(group)); |
2120 for (int j = 0; j < objects.length(); j++) { | 2157 for (size_t j = 0; j < group->length_; j++) { |
2121 Object* object = *objects[j]; | 2158 Object* object = *(group->objects_[j]); |
2122 if (!object->IsHeapObject()) continue; | 2159 if (!object->IsHeapObject()) continue; |
2123 | 2160 |
2124 HeapObject* hobj = HeapObject::cast(object); | 2161 HeapObject* hobj = HeapObject::cast(object); |
2125 int id = GetObjId(hobj); | 2162 int id = GetObjId(hobj); |
2126 if (id != 0) { | 2163 if (id != 0) { |
2127 PrintF(f, " @%d:", id); | 2164 PrintF(f, " @%d:", id); |
2128 } else { | 2165 } else { |
2129 PrintF(f, " <no id>:"); | 2166 PrintF(f, " <no id>:"); |
2130 } | 2167 } |
2131 | 2168 |
2132 char buffer[512]; | 2169 char buffer[512]; |
2133 GenerateObjectDesc(hobj, buffer, sizeof(buffer)); | 2170 GenerateObjectDesc(hobj, buffer, sizeof(buffer)); |
2134 PrintF(f, " %s", buffer); | 2171 PrintF(f, " %s", buffer); |
2135 if (hobj == obj2) { | 2172 if (hobj == obj2) { |
2136 PrintF(f, " <==="); | 2173 PrintF(f, " <==="); |
2137 } | 2174 } |
2138 PrintF(f, "\n"); | 2175 PrintF(f, "\n"); |
2139 } | 2176 } |
2140 PrintF(f, "}\n"); | 2177 PrintF(f, "}\n"); |
2141 } | 2178 } |
2142 } | 2179 } |
2143 } | 2180 } |
2144 | 2181 |
2145 PrintF(f, "path from roots to obj %p\n", reinterpret_cast<void*>(obj2)); | 2182 PrintF(f, "path from roots to obj %p\n", reinterpret_cast<void*>(obj2)); |
2146 Heap::IterateRoots(&tracer, VISIT_ONLY_STRONG); | 2183 heap->IterateRoots(&tracer, VISIT_ONLY_STRONG); |
2147 found = tracer.found(); | 2184 found = tracer.found(); |
2148 | 2185 |
2149 if (!found) { | 2186 if (!found) { |
2150 PrintF(f, " No paths found. Checking symbol tables ...\n"); | 2187 PrintF(f, " No paths found. Checking symbol tables ...\n"); |
2151 SymbolTable* symbol_table = Heap::raw_unchecked_symbol_table(); | 2188 SymbolTable* symbol_table = HEAP->raw_unchecked_symbol_table(); |
2152 tracer.VisitPointers(reinterpret_cast<Object**>(&symbol_table), | 2189 tracer.VisitPointers(reinterpret_cast<Object**>(&symbol_table), |
2153 reinterpret_cast<Object**>(&symbol_table)+1); | 2190 reinterpret_cast<Object**>(&symbol_table)+1); |
2154 found = tracer.found(); | 2191 found = tracer.found(); |
2155 if (!found) { | 2192 if (!found) { |
2156 symbol_table->IteratePrefix(&tracer); | 2193 symbol_table->IteratePrefix(&tracer); |
2157 found = tracer.found(); | 2194 found = tracer.found(); |
2158 } | 2195 } |
2159 } | 2196 } |
2160 | 2197 |
2161 if (!found) { | 2198 if (!found) { |
2162 PrintF(f, " No paths found. Checking weak roots ...\n"); | 2199 PrintF(f, " No paths found. Checking weak roots ...\n"); |
2163 // Check weak refs next. | 2200 // Check weak refs next. |
2164 GlobalHandles::IterateWeakRoots(&tracer); | 2201 isolate->global_handles()->IterateWeakRoots(&tracer); |
2165 found = tracer.found(); | 2202 found = tracer.found(); |
2166 } | 2203 } |
2167 | 2204 |
2168 } else { | 2205 } else { |
2169 PrintF(f, "path from obj %p to obj %p:\n", | 2206 PrintF(f, "path from obj %p to obj %p:\n", |
2170 reinterpret_cast<void*>(obj1), reinterpret_cast<void*>(obj2)); | 2207 reinterpret_cast<void*>(obj1), reinterpret_cast<void*>(obj2)); |
2171 tracer.TracePathFrom(reinterpret_cast<Object**>(&obj1)); | 2208 tracer.TracePathFrom(reinterpret_cast<Object**>(&obj1)); |
2172 found = tracer.found(); | 2209 found = tracer.found(); |
2173 } | 2210 } |
2174 | 2211 |
2175 if (!found) { | 2212 if (!found) { |
2176 PrintF(f, " No paths found\n\n"); | 2213 PrintF(f, " No paths found\n\n"); |
2177 } | 2214 } |
2178 } | 2215 } |
2179 | 2216 |
2180 // Flush and clean up the dumped file. | 2217 // Flush and clean up the dumped file. |
2181 Flush(f); | 2218 Flush(f); |
2182 fclose(f); | 2219 fclose(f); |
2183 | 2220 |
2184 // Restore the previous verbosity. | 2221 // Restore the previous verbosity. |
2185 FLAG_use_verbose_printer = prev_verbosity; | 2222 FLAG_use_verbose_printer = prev_verbosity; |
2186 | 2223 |
2187 // Create a string from the temp_file. | 2224 // Create a string from the temp_file. |
2188 // Note: the mmapped resource will take care of closing the file. | 2225 // Note: the mmapped resource will take care of closing the file. |
2189 MemoryMappedExternalResource* resource = | 2226 MemoryMappedExternalResource* resource = |
2190 new MemoryMappedExternalResource(temp_filename.start(), true); | 2227 new MemoryMappedExternalResource(temp_filename.start(), true); |
2191 if (resource->exists() && !resource->is_empty()) { | 2228 if (resource->exists() && !resource->is_empty()) { |
2192 ASSERT(resource->IsAscii()); | 2229 ASSERT(resource->IsAscii()); |
2193 Handle<String> path_string = | 2230 Handle<String> path_string = |
2194 Factory::NewExternalStringFromAscii(resource); | 2231 factory->NewExternalStringFromAscii(resource); |
2195 ExternalStringTable::AddString(*path_string); | 2232 heap->external_string_table()->AddString(*path_string); |
2196 return *path_string; | 2233 return *path_string; |
2197 } else { | 2234 } else { |
2198 delete resource; | 2235 delete resource; |
2199 } | 2236 } |
2200 return Heap::undefined_value(); | 2237 return heap->undefined_value(); |
2201 } | 2238 } |
2202 | 2239 |
2203 | 2240 |
2204 Object* LiveObjectList::GetPath(int obj_id1, | 2241 Object* LiveObjectList::GetPath(int obj_id1, |
2205 int obj_id2, | 2242 int obj_id2, |
2206 Handle<JSObject> instance_filter) { | 2243 Handle<JSObject> instance_filter) { |
2207 HandleScope scope; | 2244 HandleScope scope; |
2208 | 2245 |
2209 // Get the target object. | 2246 // Get the target object. |
2210 HeapObject* obj1 = NULL; | 2247 HeapObject* obj1 = NULL; |
2211 if (obj_id1 != 0) { | 2248 if (obj_id1 != 0) { |
2212 obj1 = HeapObject::cast(GetObj(obj_id1)); | 2249 obj1 = HeapObject::cast(GetObj(obj_id1)); |
2213 if (obj1 == Heap::undefined_value()) { | 2250 if (obj1 == HEAP->undefined_value()) { |
2214 return obj1; | 2251 return obj1; |
2215 } | 2252 } |
2216 } | 2253 } |
2217 | 2254 |
2218 HeapObject* obj2 = HeapObject::cast(GetObj(obj_id2)); | 2255 HeapObject* obj2 = HeapObject::cast(GetObj(obj_id2)); |
2219 if (obj2 == Heap::undefined_value()) { | 2256 if (obj2 == HEAP->undefined_value()) { |
2220 return obj2; | 2257 return obj2; |
2221 } | 2258 } |
2222 | 2259 |
2223 return GetPathPrivate(obj1, obj2); | 2260 return GetPathPrivate(obj1, obj2); |
2224 } | 2261 } |
2225 | 2262 |
2226 | 2263 |
2227 void LiveObjectList::DoProcessNonLive(HeapObject *obj) { | 2264 void LiveObjectList::DoProcessNonLive(HeapObject *obj) { |
2228 // We should only be called if we have at least one lol to search. | 2265 // We should only be called if we have at least one lol to search. |
2229 ASSERT(last() != NULL); | 2266 ASSERT(last() != NULL); |
(...skipping 333 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2563 lol = lol->prev_; | 2600 lol = lol->prev_; |
2564 } | 2601 } |
2565 | 2602 |
2566 OS::Print(" DONE verifying.\n\n\n"); | 2603 OS::Print(" DONE verifying.\n\n\n"); |
2567 } | 2604 } |
2568 | 2605 |
2569 | 2606 |
2570 void LiveObjectList::VerifyNotInFromSpace() { | 2607 void LiveObjectList::VerifyNotInFromSpace() { |
2571 OS::Print("VerifyNotInFromSpace() ...\n"); | 2608 OS::Print("VerifyNotInFromSpace() ...\n"); |
2572 LolIterator it(NULL, last()); | 2609 LolIterator it(NULL, last()); |
| 2610 Heap* heap = ISOLATE->heap(); |
2573 int i = 0; | 2611 int i = 0; |
2574 for (it.Init(); !it.Done(); it.Next()) { | 2612 for (it.Init(); !it.Done(); it.Next()) { |
2575 HeapObject* heap_obj = it.Obj(); | 2613 HeapObject* heap_obj = it.Obj(); |
2576 if (Heap::InFromSpace(heap_obj)) { | 2614 if (heap->InFromSpace(heap_obj)) { |
2577 OS::Print(" ERROR: VerifyNotInFromSpace: [%d] obj %p in From space %p\n", | 2615 OS::Print(" ERROR: VerifyNotInFromSpace: [%d] obj %p in From space %p\n", |
2578 i++, heap_obj, Heap::new_space()->FromSpaceLow()); | 2616 i++, heap_obj, heap->new_space()->FromSpaceLow()); |
2579 } | 2617 } |
2580 } | 2618 } |
2581 } | 2619 } |
2582 #endif // VERIFY_LOL | 2620 #endif // VERIFY_LOL |
2583 | 2621 |
2584 | 2622 |
2585 } } // namespace v8::internal | 2623 } } // namespace v8::internal |
2586 | 2624 |
2587 #endif // LIVE_OBJECT_LIST | 2625 #endif // LIVE_OBJECT_LIST |
OLD | NEW |