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

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

Issue 2656903003: PrintFixedArrayElements should avoid peeking into empty arrays. (Closed)
Patch Set: Created 3 years, 11 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 | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "src/objects.h" 5 #include "src/objects.h"
6 6
7 #include <iomanip> 7 #include <iomanip>
8 #include <memory> 8 #include <memory>
9 9
10 #include "src/bootstrapper.h" 10 #include "src/bootstrapper.h"
(...skipping 399 matching lines...) Expand 10 before | Expand all | Expand 10 after
410 } else { 410 } else {
411 os << previous_value; 411 os << previous_value;
412 } 412 }
413 previous_index = i; 413 previous_index = i;
414 previous_value = value; 414 previous_value = value;
415 } 415 }
416 } 416 }
417 417
418 void PrintFixedArrayElements(std::ostream& os, FixedArray* array) { 418 void PrintFixedArrayElements(std::ostream& os, FixedArray* array) {
419 // Print in array notation for non-sparse arrays. 419 // Print in array notation for non-sparse arrays.
420 Object* previous_value = array->get(0); 420 Object* previous_value = array->length() > 0 ? array->get(0) : nullptr;
421 Object* value = nullptr; 421 Object* value = nullptr;
422 int previous_index = 0; 422 int previous_index = 0;
423 int i; 423 int i;
424 for (i = 1; i <= array->length(); i++) { 424 for (i = 1; i <= array->length(); i++) {
425 if (i < array->length()) value = array->get(i); 425 if (i < array->length()) value = array->get(i);
426 if (previous_value == value && i != array->length()) { 426 if (previous_value == value && i != array->length()) {
427 continue; 427 continue;
428 } 428 }
429 os << "\n"; 429 os << "\n";
430 std::stringstream ss; 430 std::stringstream ss;
(...skipping 1293 matching lines...) Expand 10 before | Expand all | Expand 10 after
1724 printf("Not a transition array\n"); 1724 printf("Not a transition array\n");
1725 } else { 1725 } else {
1726 reinterpret_cast<i::TransitionArray*>(object)->Print(); 1726 reinterpret_cast<i::TransitionArray*>(object)->Print();
1727 } 1727 }
1728 } 1728 }
1729 1729
1730 extern void _v8_internal_Print_StackTrace() { 1730 extern void _v8_internal_Print_StackTrace() {
1731 i::Isolate* isolate = i::Isolate::Current(); 1731 i::Isolate* isolate = i::Isolate::Current();
1732 isolate->PrintStack(stdout); 1732 isolate->PrintStack(stdout);
1733 } 1733 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698