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

Side by Side Diff: src/liveobjectlist.cc

Issue 7860011: Rename SmartPointer to SmartArrayPointer. (Closed) Base URL: git://github.com/v8/v8.git@bleeding_edge
Patch Set: rebase it again to get more fixes Created 9 years, 3 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
« no previous file with comments | « src/ia32/lithium-ia32.cc ('k') | src/log.cc » ('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 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 166 matching lines...) Expand 10 before | Expand all | Expand 10 after
177 FOR_EACH_LIVE_OBJECT_TYPE(CHECK_OBJECT_TYPE) 177 FOR_EACH_LIVE_OBJECT_TYPE(CHECK_OBJECT_TYPE)
178 #undef CHECK_OBJECT_TYPE 178 #undef CHECK_OBJECT_TYPE
179 179
180 return false; 180 return false;
181 } 181 }
182 182
183 183
184 const AllocationSpace kInvalidSpace = static_cast<AllocationSpace>(-1); 184 const AllocationSpace kInvalidSpace = static_cast<AllocationSpace>(-1);
185 185
186 static AllocationSpace FindSpaceFor(String* space_str) { 186 static AllocationSpace FindSpaceFor(String* space_str) {
187 SmartPointer<char> s = 187 SmartArrayPointer<char> s =
188 space_str->ToCString(DISALLOW_NULLS, ROBUST_STRING_TRAVERSAL); 188 space_str->ToCString(DISALLOW_NULLS, ROBUST_STRING_TRAVERSAL);
189 189
190 const char* key_str = *s; 190 const char* key_str = *s;
191 switch (key_str[0]) { 191 switch (key_str[0]) {
192 case 'c': 192 case 'c':
193 if (strcmp(key_str, "cell") == 0) return CELL_SPACE; 193 if (strcmp(key_str, "cell") == 0) return CELL_SPACE;
194 if (strcmp(key_str, "code") == 0) return CODE_SPACE; 194 if (strcmp(key_str, "code") == 0) return CODE_SPACE;
195 break; 195 break;
196 case 'l': 196 case 'l':
197 if (strcmp(key_str, "lo") == 0) return LO_SPACE; 197 if (strcmp(key_str, "lo") == 0) return LO_SPACE;
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
229 if (heap->InSpace(heap_obj, static_cast<AllocationSpace>(sp))) { 229 if (heap->InSpace(heap_obj, static_cast<AllocationSpace>(sp))) {
230 return false; 230 return false;
231 } 231 }
232 } 232 }
233 SLOW_ASSERT(heap->InSpace(heap_obj, LO_SPACE)); 233 SLOW_ASSERT(heap->InSpace(heap_obj, LO_SPACE));
234 return true; 234 return true;
235 } 235 }
236 236
237 237
238 static LiveObjectType FindTypeFor(String* type_str) { 238 static LiveObjectType FindTypeFor(String* type_str) {
239 SmartPointer<char> s = 239 SmartArrayPointer<char> s =
240 type_str->ToCString(DISALLOW_NULLS, ROBUST_STRING_TRAVERSAL); 240 type_str->ToCString(DISALLOW_NULLS, ROBUST_STRING_TRAVERSAL);
241 241
242 #define CHECK_OBJECT_TYPE(type_, name) { \ 242 #define CHECK_OBJECT_TYPE(type_, name) { \
243 const char* type_desc = GetObjectTypeDesc(kType##type_); \ 243 const char* type_desc = GetObjectTypeDesc(kType##type_); \
244 const char* key_str = *s; \ 244 const char* key_str = *s; \
245 if (strstr(type_desc, key_str) != NULL) return kType##type_; \ 245 if (strstr(type_desc, key_str) != NULL) return kType##type_; \
246 } 246 }
247 FOR_EACH_LIVE_OBJECT_TYPE(CHECK_OBJECT_TYPE) 247 FOR_EACH_LIVE_OBJECT_TYPE(CHECK_OBJECT_TYPE)
248 #undef CHECK_OBJECT_TYPE 248 #undef CHECK_OBJECT_TYPE
249 249
(...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after
496 reinterpret_cast<void*>(obj), 496 reinterpret_cast<void*>(obj),
497 GetObjectTypeDesc(obj), 497 GetObjectTypeDesc(obj),
498 length); 498 length);
499 499
500 } else if (obj->IsString()) { 500 } else if (obj->IsString()) {
501 String *str = String::cast(obj); 501 String *str = String::cast(obj);
502 // Only grab up to 160 chars in case they are double byte. 502 // Only grab up to 160 chars in case they are double byte.
503 // We'll only dump 80 of them after we compact them. 503 // We'll only dump 80 of them after we compact them.
504 const int kMaxCharToDump = 80; 504 const int kMaxCharToDump = 80;
505 const int kMaxBufferSize = kMaxCharToDump * 2; 505 const int kMaxBufferSize = kMaxCharToDump * 2;
506 SmartPointer<char> str_sp = str->ToCString(DISALLOW_NULLS, 506 SmartArrayPointer<char> str_sp = str->ToCString(DISALLOW_NULLS,
507 ROBUST_STRING_TRAVERSAL, 507 ROBUST_STRING_TRAVERSAL,
508 0, 508 0,
509 kMaxBufferSize); 509 kMaxBufferSize);
510 char* str_cstr = *str_sp; 510 char* str_cstr = *str_sp;
511 int length = CompactString(str_cstr); 511 int length = CompactString(str_cstr);
512 OS::SNPrintF(buffer_v, 512 OS::SNPrintF(buffer_v,
513 "%p <%s> '%.80s%s'", 513 "%p <%s> '%.80s%s'",
514 reinterpret_cast<void*>(obj), 514 reinterpret_cast<void*>(obj),
515 GetObjectTypeDesc(obj), 515 GetObjectTypeDesc(obj),
516 str_cstr, 516 str_cstr,
517 (length > kMaxCharToDump) ? "..." : ""); 517 (length > kMaxCharToDump) ? "..." : "");
518 518
519 } else if (obj->IsJSFunction() || obj->IsSharedFunctionInfo()) { 519 } else if (obj->IsJSFunction() || obj->IsSharedFunctionInfo()) {
520 SharedFunctionInfo* sinfo; 520 SharedFunctionInfo* sinfo;
521 if (obj->IsJSFunction()) { 521 if (obj->IsJSFunction()) {
522 JSFunction* func = JSFunction::cast(obj); 522 JSFunction* func = JSFunction::cast(obj);
523 sinfo = func->shared(); 523 sinfo = func->shared();
524 } else { 524 } else {
525 sinfo = SharedFunctionInfo::cast(obj); 525 sinfo = SharedFunctionInfo::cast(obj);
526 } 526 }
527 527
528 String* name = sinfo->DebugName(); 528 String* name = sinfo->DebugName();
529 SmartPointer<char> name_sp = 529 SmartArrayPointer<char> name_sp =
530 name->ToCString(DISALLOW_NULLS, ROBUST_STRING_TRAVERSAL); 530 name->ToCString(DISALLOW_NULLS, ROBUST_STRING_TRAVERSAL);
531 char* name_cstr = *name_sp; 531 char* name_cstr = *name_sp;
532 532
533 HeapStringAllocator string_allocator; 533 HeapStringAllocator string_allocator;
534 StringStream stream(&string_allocator); 534 StringStream stream(&string_allocator);
535 sinfo->SourceCodePrint(&stream, 50); 535 sinfo->SourceCodePrint(&stream, 50);
536 SmartPointer<const char> source_sp = stream.ToCString(); 536 SmartArrayPointer<const char> source_sp = stream.ToCString();
537 const char* source_cstr = *source_sp; 537 const char* source_cstr = *source_sp;
538 538
539 OS::SNPrintF(buffer_v, 539 OS::SNPrintF(buffer_v,
540 "%p <%s> '%s' %s", 540 "%p <%s> '%s' %s",
541 reinterpret_cast<void*>(obj), 541 reinterpret_cast<void*>(obj),
542 GetObjectTypeDesc(obj), 542 GetObjectTypeDesc(obj),
543 name_cstr, 543 name_cstr,
544 source_cstr); 544 source_cstr);
545 545
546 } else if (obj->IsFixedArray()) { 546 } else if (obj->IsFixedArray()) {
(...skipping 1102 matching lines...) Expand 10 before | Expand all | Expand 10 after
1649 Element* element = FindElementFor<HeapObject*>(GetElementObj, hobj); 1649 Element* element = FindElementFor<HeapObject*>(GetElementObj, hobj);
1650 if (element != NULL) { 1650 if (element != NULL) {
1651 return element->id_; 1651 return element->id_;
1652 } 1652 }
1653 return 0; // Invalid address. 1653 return 0; // Invalid address.
1654 } 1654 }
1655 1655
1656 1656
1657 // Gets the obj id for the specified address if valid. 1657 // Gets the obj id for the specified address if valid.
1658 Object* LiveObjectList::GetObjId(Handle<String> address) { 1658 Object* LiveObjectList::GetObjId(Handle<String> address) {
1659 SmartPointer<char> addr_str = 1659 SmartArrayPointer<char> addr_str =
1660 address->ToCString(DISALLOW_NULLS, ROBUST_STRING_TRAVERSAL); 1660 address->ToCString(DISALLOW_NULLS, ROBUST_STRING_TRAVERSAL);
1661 1661
1662 Isolate* isolate = Isolate::Current(); 1662 Isolate* isolate = Isolate::Current();
1663 1663
1664 // Extract the address value from the string. 1664 // Extract the address value from the string.
1665 int value = 1665 int value =
1666 static_cast<int>(StringToInt(isolate->unicode_cache(), *address, 16)); 1666 static_cast<int>(StringToInt(isolate->unicode_cache(), *address, 16));
1667 Object* obj = reinterpret_cast<Object*>(value); 1667 Object* obj = reinterpret_cast<Object*>(value);
1668 return Smi::FromInt(GetObjId(obj)); 1668 return Smi::FromInt(GetObjId(obj));
1669 } 1669 }
(...skipping 946 matching lines...) Expand 10 before | Expand all | Expand 10 after
2616 i++, heap_obj, heap->new_space()->FromSpaceLow()); 2616 i++, heap_obj, heap->new_space()->FromSpaceLow());
2617 } 2617 }
2618 } 2618 }
2619 } 2619 }
2620 #endif // VERIFY_LOL 2620 #endif // VERIFY_LOL
2621 2621
2622 2622
2623 } } // namespace v8::internal 2623 } } // namespace v8::internal
2624 2624
2625 #endif // LIVE_OBJECT_LIST 2625 #endif // LIVE_OBJECT_LIST
OLDNEW
« no previous file with comments | « src/ia32/lithium-ia32.cc ('k') | src/log.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698