| OLD | NEW |
| 1 // Copyright 2010 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 |
| 11 // with the distribution. | 11 // with the distribution. |
| (...skipping 271 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 283 case FAST_ELEMENTS: { | 283 case FAST_ELEMENTS: { |
| 284 // Print in array notation for non-sparse arrays. | 284 // Print in array notation for non-sparse arrays. |
| 285 FixedArray* p = FixedArray::cast(elements()); | 285 FixedArray* p = FixedArray::cast(elements()); |
| 286 for (int i = 0; i < p->length(); i++) { | 286 for (int i = 0; i < p->length(); i++) { |
| 287 PrintF(out, " %d: ", i); | 287 PrintF(out, " %d: ", i); |
| 288 p->get(i)->ShortPrint(out); | 288 p->get(i)->ShortPrint(out); |
| 289 PrintF(out, "\n"); | 289 PrintF(out, "\n"); |
| 290 } | 290 } |
| 291 break; | 291 break; |
| 292 } | 292 } |
| 293 case FAST_DOUBLE_ELEMENTS: { |
| 294 // Print in array notation for non-sparse arrays. |
| 295 FixedDoubleArray* p = FixedDoubleArray::cast(elements()); |
| 296 for (int i = 0; i < p->length(); i++) { |
| 297 if (p->is_the_hole(i)) { |
| 298 PrintF(out, " %d: <the hole>", i); |
| 299 } else { |
| 300 PrintF(out, " %d: %g", i, p->get(i)); |
| 301 } |
| 302 PrintF(out, "\n"); |
| 303 } |
| 304 break; |
| 305 } |
| 293 case EXTERNAL_PIXEL_ELEMENTS: { | 306 case EXTERNAL_PIXEL_ELEMENTS: { |
| 294 ExternalPixelArray* p = ExternalPixelArray::cast(elements()); | 307 ExternalPixelArray* p = ExternalPixelArray::cast(elements()); |
| 295 for (int i = 0; i < p->length(); i++) { | 308 for (int i = 0; i < p->length(); i++) { |
| 296 PrintF(out, " %d: %d\n", i, p->get(i)); | 309 PrintF(out, " %d: %d\n", i, p->get(i)); |
| 297 } | 310 } |
| 298 break; | 311 break; |
| 299 } | 312 } |
| 300 case EXTERNAL_BYTE_ELEMENTS: { | 313 case EXTERNAL_BYTE_ELEMENTS: { |
| 301 ExternalByteArray* p = ExternalByteArray::cast(elements()); | 314 ExternalByteArray* p = ExternalByteArray::cast(elements()); |
| 302 for (int i = 0; i < p->length(); i++) { | 315 for (int i = 0; i < p->length(); i++) { |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 361 break; | 374 break; |
| 362 case NON_STRICT_ARGUMENTS_ELEMENTS: { | 375 case NON_STRICT_ARGUMENTS_ELEMENTS: { |
| 363 FixedArray* p = FixedArray::cast(elements()); | 376 FixedArray* p = FixedArray::cast(elements()); |
| 364 for (int i = 2; i < p->length(); i++) { | 377 for (int i = 2; i < p->length(); i++) { |
| 365 PrintF(out, " %d: ", i); | 378 PrintF(out, " %d: ", i); |
| 366 p->get(i)->ShortPrint(out); | 379 p->get(i)->ShortPrint(out); |
| 367 PrintF(out, "\n"); | 380 PrintF(out, "\n"); |
| 368 } | 381 } |
| 369 break; | 382 break; |
| 370 } | 383 } |
| 371 default: | |
| 372 UNREACHABLE(); | |
| 373 break; | |
| 374 } | 384 } |
| 375 } | 385 } |
| 376 | 386 |
| 377 | 387 |
| 378 void JSObject::JSObjectPrint(FILE* out) { | 388 void JSObject::JSObjectPrint(FILE* out) { |
| 379 PrintF(out, "%p: [JSObject]\n", reinterpret_cast<void*>(this)); | 389 PrintF(out, "%p: [JSObject]\n", reinterpret_cast<void*>(this)); |
| 380 PrintF(out, " - map = %p\n", reinterpret_cast<void*>(map())); | 390 PrintF(out, " - map = %p\n", reinterpret_cast<void*>(map())); |
| 381 PrintF(out, " - prototype = %p\n", reinterpret_cast<void*>(GetPrototype())); | 391 PrintF(out, " - prototype = %p\n", reinterpret_cast<void*>(GetPrototype())); |
| 382 PrintF(out, " {\n"); | 392 PrintF(out, " {\n"); |
| 383 PrintProperties(out); | 393 PrintProperties(out); |
| (...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 552 PrintF(out, "%c", Get(i)); | 562 PrintF(out, "%c", Get(i)); |
| 553 } | 563 } |
| 554 if (len != length()) { | 564 if (len != length()) { |
| 555 PrintF(out, "%s", truncated_epilogue); | 565 PrintF(out, "%s", truncated_epilogue); |
| 556 } | 566 } |
| 557 | 567 |
| 558 if (!StringShape(this).IsSymbol()) PrintF(out, "\""); | 568 if (!StringShape(this).IsSymbol()) PrintF(out, "\""); |
| 559 } | 569 } |
| 560 | 570 |
| 561 | 571 |
| 572 // This method is only meant to be called from gdb for debugging purposes. |
| 573 // Since the string can also be in two-byte encoding, non-ascii characters |
| 574 // will be ignored in the output. |
| 575 char* String::ToAsciiArray() { |
| 576 // Static so that subsequent calls frees previously allocated space. |
| 577 // This also means that previous results will be overwritten. |
| 578 static char* buffer = NULL; |
| 579 if (buffer != NULL) free(buffer); |
| 580 buffer = new char[length()+1]; |
| 581 WriteToFlat(this, buffer, 0, length()); |
| 582 buffer[length()] = 0; |
| 583 return buffer; |
| 584 } |
| 585 |
| 586 |
| 562 void JSProxy::JSProxyPrint(FILE* out) { | 587 void JSProxy::JSProxyPrint(FILE* out) { |
| 563 HeapObject::PrintHeader(out, "JSProxy"); | 588 HeapObject::PrintHeader(out, "JSProxy"); |
| 564 PrintF(out, " - map = 0x%p\n", reinterpret_cast<void*>(map())); | 589 PrintF(out, " - map = 0x%p\n", reinterpret_cast<void*>(map())); |
| 565 PrintF(out, " - handler = "); | 590 PrintF(out, " - handler = "); |
| 566 handler()->Print(out); | 591 handler()->Print(out); |
| 567 PrintF(out, "\n"); | 592 PrintF(out, "\n"); |
| 568 } | 593 } |
| 569 | 594 |
| 570 | 595 |
| 571 void JSFunction::JSFunctionPrint(FILE* out) { | 596 void JSFunction::JSFunctionPrint(FILE* out) { |
| (...skipping 273 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 845 desc.Print(out); | 870 desc.Print(out); |
| 846 } | 871 } |
| 847 PrintF(out, "\n"); | 872 PrintF(out, "\n"); |
| 848 } | 873 } |
| 849 | 874 |
| 850 | 875 |
| 851 #endif // OBJECT_PRINT | 876 #endif // OBJECT_PRINT |
| 852 | 877 |
| 853 | 878 |
| 854 } } // namespace v8::internal | 879 } } // namespace v8::internal |
| OLD | NEW |