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

Side by Side Diff: src/objects-printer.cc

Issue 7901016: Basic support for tracking smi-only arrays on ia32. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: fix remaining failing tests 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 | Annotate | Revision Log
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 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
75 return; 75 return;
76 } 76 }
77 77
78 switch (instance_type) { 78 switch (instance_type) {
79 case MAP_TYPE: 79 case MAP_TYPE:
80 Map::cast(this)->MapPrint(out); 80 Map::cast(this)->MapPrint(out);
81 break; 81 break;
82 case HEAP_NUMBER_TYPE: 82 case HEAP_NUMBER_TYPE:
83 HeapNumber::cast(this)->HeapNumberPrint(out); 83 HeapNumber::cast(this)->HeapNumberPrint(out);
84 break; 84 break;
85 case FIXED_DOUBLE_ARRAY_TYPE:
86 FixedDoubleArray::cast(this)->FixedDoubleArrayPrint(out);
87 break;
85 case FIXED_ARRAY_TYPE: 88 case FIXED_ARRAY_TYPE:
86 FixedArray::cast(this)->FixedArrayPrint(out); 89 FixedArray::cast(this)->FixedArrayPrint(out);
87 break; 90 break;
88 case BYTE_ARRAY_TYPE: 91 case BYTE_ARRAY_TYPE:
89 ByteArray::cast(this)->ByteArrayPrint(out); 92 ByteArray::cast(this)->ByteArrayPrint(out);
90 break; 93 break;
91 case FREE_SPACE_TYPE: 94 case FREE_SPACE_TYPE:
92 FreeSpace::cast(this)->FreeSpacePrint(out); 95 FreeSpace::cast(this)->FreeSpacePrint(out);
93 break; 96 break;
94 case EXTERNAL_PIXEL_ARRAY_TYPE: 97 case EXTERNAL_PIXEL_ARRAY_TYPE:
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after
234 237
235 void ExternalFloatArray::ExternalFloatArrayPrint(FILE* out) { 238 void ExternalFloatArray::ExternalFloatArrayPrint(FILE* out) {
236 PrintF(out, "external float array"); 239 PrintF(out, "external float array");
237 } 240 }
238 241
239 242
240 void ExternalDoubleArray::ExternalDoubleArrayPrint(FILE* out) { 243 void ExternalDoubleArray::ExternalDoubleArrayPrint(FILE* out) {
241 PrintF(out, "external double array"); 244 PrintF(out, "external double array");
242 } 245 }
243 246
247 static void PrintElementsKind(FILE* out, ElementsKind kind) {
248 switch (kind) {
249 case FAST_SMI_ONLY_ELEMENTS:
250 PrintF(out, "FAST_SMI_ONLY_ELEMENTS");
251 break;
252 case FAST_ELEMENTS:
253 PrintF(out, "FAST_ELEMENTS");
254 break;
255 case FAST_DOUBLE_ELEMENTS:
256 PrintF(out, "FAST_DOUBLE_ELEMENTS");
257 break;
258 case DICTIONARY_ELEMENTS:
259 PrintF(out, "DICTIONARY_ELEMENTS");
260 break;
261 case NON_STRICT_ARGUMENTS_ELEMENTS:
262 PrintF(out, "NON_STRICT_ARGUMENTS_ELEMENTS");
263 break;
264 case EXTERNAL_BYTE_ELEMENTS:
265 PrintF(out, "EXTERNAL_BYTE_ELEMENTS");
266 break;
267 case EXTERNAL_UNSIGNED_BYTE_ELEMENTS:
268 PrintF(out, "EXTERNAL_UNSIGNED_BYTE_ELEMENTS");
269 break;
270 case EXTERNAL_SHORT_ELEMENTS:
271 PrintF(out, "EXTERNAL_SHORT_ELEMENTS");
272 break;
273 case EXTERNAL_UNSIGNED_SHORT_ELEMENTS:
274 PrintF(out, "EXTERNAL_UNSIGNED_SHORT_ELEMENTS");
275 break;
276 case EXTERNAL_INT_ELEMENTS:
277 PrintF(out, "EXTERNAL_INT_ELEMENTS");
278 break;
279 case EXTERNAL_UNSIGNED_INT_ELEMENTS:
280 PrintF(out, "EXTERNAL_UNSIGNED_INT_ELEMENTS");
281 break;
282 case EXTERNAL_FLOAT_ELEMENTS:
283 PrintF(out, "EXTERNAL_FLOAT_ELEMENTS");
284 break;
285 case EXTERNAL_DOUBLE_ELEMENTS:
286 PrintF(out, "EXTERNAL_DOUBLE_ELEMENTS");
287 break;
288 case EXTERNAL_PIXEL_ELEMENTS:
289 PrintF(out, "EXTERNAL_DOUBLE_ELEMENTS");
290 break;
291 }
292 }
293
244 294
245 void JSObject::PrintProperties(FILE* out) { 295 void JSObject::PrintProperties(FILE* out) {
246 if (HasFastProperties()) { 296 if (HasFastProperties()) {
247 DescriptorArray* descs = map()->instance_descriptors(); 297 DescriptorArray* descs = map()->instance_descriptors();
248 for (int i = 0; i < descs->number_of_descriptors(); i++) { 298 for (int i = 0; i < descs->number_of_descriptors(); i++) {
249 PrintF(out, " "); 299 PrintF(out, " ");
250 descs->GetKey(i)->StringPrint(out); 300 descs->GetKey(i)->StringPrint(out);
251 PrintF(out, ": "); 301 PrintF(out, ": ");
252 switch (descs->GetType(i)) { 302 switch (descs->GetType(i)) {
253 case FIELD: { 303 case FIELD: {
254 int index = descs->GetFieldIndex(i); 304 int index = descs->GetFieldIndex(i);
255 FastPropertyAt(index)->ShortPrint(out); 305 FastPropertyAt(index)->ShortPrint(out);
256 PrintF(out, " (field at offset %d)\n", index); 306 PrintF(out, " (field at offset %d)\n", index);
257 break; 307 break;
258 } 308 }
259 case CONSTANT_FUNCTION: 309 case CONSTANT_FUNCTION:
260 descs->GetConstantFunction(i)->ShortPrint(out); 310 descs->GetConstantFunction(i)->ShortPrint(out);
261 PrintF(out, " (constant function)\n"); 311 PrintF(out, " (constant function)\n");
262 break; 312 break;
263 case CALLBACKS: 313 case CALLBACKS:
264 descs->GetCallbacksObject(i)->ShortPrint(out); 314 descs->GetCallbacksObject(i)->ShortPrint(out);
265 PrintF(out, " (callback)\n"); 315 PrintF(out, " (callback)\n");
266 break; 316 break;
267 case ELEMENTS_TRANSITION: 317 case ELEMENTS_TRANSITION:
268 PrintF(out, " (elements transition)\n"); 318 PrintF(out, "(elements transition to ");
319 PrintElementsKind(out,
320 Map::cast(descs->GetValue(i))->elements_kind());
321 PrintF(out, ")\n");
269 break; 322 break;
270 case MAP_TRANSITION: 323 case MAP_TRANSITION:
271 PrintF(out, " (map transition)\n"); 324 PrintF(out, "(map transition)\n");
272 break; 325 break;
273 case CONSTANT_TRANSITION: 326 case CONSTANT_TRANSITION:
274 PrintF(out, " (constant transition)\n"); 327 PrintF(out, "(constant transition)\n");
275 break; 328 break;
276 case NULL_DESCRIPTOR: 329 case NULL_DESCRIPTOR:
277 PrintF(out, " (null descriptor)\n"); 330 PrintF(out, "(null descriptor)\n");
278 break; 331 break;
279 default: 332 default:
280 UNREACHABLE(); 333 UNREACHABLE();
281 break; 334 break;
282 } 335 }
283 } 336 }
284 } else { 337 } else {
285 property_dictionary()->Print(out); 338 property_dictionary()->Print(out);
286 } 339 }
287 } 340 }
288 341
289 342
290 void JSObject::PrintElements(FILE* out) { 343 void JSObject::PrintElements(FILE* out) {
291 switch (GetElementsKind()) { 344 // Don't call GetElementsKind, it's validate code can cause the printer to
345 // fail when debugging.
346 switch (map()->elements_kind()) {
347 case FAST_SMI_ONLY_ELEMENTS:
292 case FAST_ELEMENTS: { 348 case FAST_ELEMENTS: {
293 // Print in array notation for non-sparse arrays. 349 // Print in array notation for non-sparse arrays.
294 FixedArray* p = FixedArray::cast(elements()); 350 FixedArray* p = FixedArray::cast(elements());
295 for (int i = 0; i < p->length(); i++) { 351 for (int i = 0; i < p->length(); i++) {
296 PrintF(out, " %d: ", i); 352 PrintF(out, " %d: ", i);
297 p->get(i)->ShortPrint(out); 353 p->get(i)->ShortPrint(out);
298 PrintF(out, "\n"); 354 PrintF(out, "\n");
299 } 355 }
300 break; 356 break;
301 } 357 }
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
389 PrintF(out, "\n"); 445 PrintF(out, "\n");
390 } 446 }
391 break; 447 break;
392 } 448 }
393 } 449 }
394 } 450 }
395 451
396 452
397 void JSObject::JSObjectPrint(FILE* out) { 453 void JSObject::JSObjectPrint(FILE* out) {
398 PrintF(out, "%p: [JSObject]\n", reinterpret_cast<void*>(this)); 454 PrintF(out, "%p: [JSObject]\n", reinterpret_cast<void*>(this));
399 PrintF(out, " - map = %p\n", reinterpret_cast<void*>(map())); 455 PrintF(out, " - map = %p [", reinterpret_cast<void*>(map()));
400 PrintF(out, " - prototype = %p\n", reinterpret_cast<void*>(GetPrototype())); 456 // Don't call GetElementsKind, it's validate code can cause the printer to
457 // fail when debugging.
458 PrintElementsKind(out, this->map()->elements_kind());
459 PrintF(out,
460 "]\n - prototype = %p\n",
461 reinterpret_cast<void*>(GetPrototype()));
401 PrintF(out, " {\n"); 462 PrintF(out, " {\n");
402 PrintProperties(out); 463 PrintProperties(out);
403 PrintElements(out); 464 PrintElements(out);
404 PrintF(out, " }\n"); 465 PrintF(out, " }\n");
405 } 466 }
406 467
407 468
408 static const char* TypeToString(InstanceType type) { 469 static const char* TypeToString(InstanceType type) {
409 switch (type) { 470 switch (type) {
410 case INVALID_TYPE: return "INVALID"; 471 case INVALID_TYPE: return "INVALID";
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
521 HeapObject::PrintHeader(out, "FixedArray"); 582 HeapObject::PrintHeader(out, "FixedArray");
522 PrintF(out, " - length: %d", length()); 583 PrintF(out, " - length: %d", length());
523 for (int i = 0; i < length(); i++) { 584 for (int i = 0; i < length(); i++) {
524 PrintF(out, "\n [%d]: ", i); 585 PrintF(out, "\n [%d]: ", i);
525 get(i)->ShortPrint(out); 586 get(i)->ShortPrint(out);
526 } 587 }
527 PrintF(out, "\n"); 588 PrintF(out, "\n");
528 } 589 }
529 590
530 591
592 void FixedDoubleArray::FixedDoubleArrayPrint(FILE* out) {
593 HeapObject::PrintHeader(out, "FixedDoubleArray");
594 PrintF(out, " - length: %d", length());
595 for (int i = 0; i < length(); i++) {
596 PrintF(out, "\n [%d]: %g", i, get_scalar(i));
597 }
598 PrintF(out, "\n");
599 }
600
601
531 void JSValue::JSValuePrint(FILE* out) { 602 void JSValue::JSValuePrint(FILE* out) {
532 HeapObject::PrintHeader(out, "ValueObject"); 603 HeapObject::PrintHeader(out, "ValueObject");
533 value()->Print(out); 604 value()->Print(out);
534 } 605 }
535 606
536 607
537 void JSMessageObject::JSMessageObjectPrint(FILE* out) { 608 void JSMessageObject::JSMessageObjectPrint(FILE* out) {
538 HeapObject::PrintHeader(out, "JSMessageObject"); 609 HeapObject::PrintHeader(out, "JSMessageObject");
539 PrintF(out, " - type: "); 610 PrintF(out, " - type: ");
540 type()->ShortPrint(out); 611 type()->ShortPrint(out);
(...skipping 367 matching lines...) Expand 10 before | Expand all | Expand 10 after
908 desc.Print(out); 979 desc.Print(out);
909 } 980 }
910 PrintF(out, "\n"); 981 PrintF(out, "\n");
911 } 982 }
912 983
913 984
914 #endif // OBJECT_PRINT 985 #endif // OBJECT_PRINT
915 986
916 987
917 } } // namespace v8::internal 988 } } // namespace v8::internal
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698