| OLD | NEW |
| 1 // Copyright 2014 the V8 project authors. All rights reserved. | 1 // Copyright 2014 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/string-stream.h" | 5 #include "src/string-stream.h" |
| 6 | 6 |
| 7 #include "src/handles-inl.h" | 7 #include "src/handles-inl.h" |
| 8 #include "src/prototype.h" | 8 #include "src/prototype.h" |
| 9 | 9 |
| 10 namespace v8 { | 10 namespace v8 { |
| (...skipping 360 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 371 Object* value = js_object->RawFastPropertyAt(index); | 371 Object* value = js_object->RawFastPropertyAt(index); |
| 372 Add("%o\n", value); | 372 Add("%o\n", value); |
| 373 } | 373 } |
| 374 } | 374 } |
| 375 } | 375 } |
| 376 } | 376 } |
| 377 } | 377 } |
| 378 | 378 |
| 379 | 379 |
| 380 void StringStream::PrintFixedArray(FixedArray* array, unsigned int limit) { | 380 void StringStream::PrintFixedArray(FixedArray* array, unsigned int limit) { |
| 381 Heap* heap = array->GetHeap(); | 381 Isolate* isolate = array->GetIsolate(); |
| 382 for (unsigned int i = 0; i < 10 && i < limit; i++) { | 382 for (unsigned int i = 0; i < 10 && i < limit; i++) { |
| 383 Object* element = array->get(i); | 383 Object* element = array->get(i); |
| 384 if (element != heap->the_hole_value()) { | 384 if (element->IsTheHole(isolate)) continue; |
| 385 for (int len = 1; len < 18; len++) | 385 for (int len = 1; len < 18; len++) { |
| 386 Put(' '); | 386 Put(' '); |
| 387 Add("%d: %o\n", i, array->get(i)); | |
| 388 } | 387 } |
| 388 Add("%d: %o\n", i, array->get(i)); |
| 389 } | 389 } |
| 390 if (limit >= 10) { | 390 if (limit >= 10) { |
| 391 Add(" ...\n"); | 391 Add(" ...\n"); |
| 392 } | 392 } |
| 393 } | 393 } |
| 394 | 394 |
| 395 | 395 |
| 396 void StringStream::PrintByteArray(ByteArray* byte_array) { | 396 void StringStream::PrintByteArray(ByteArray* byte_array) { |
| 397 unsigned int limit = byte_array->length(); | 397 unsigned int limit = byte_array->length(); |
| 398 for (unsigned int i = 0; i < 10 && i < limit; i++) { | 398 for (unsigned int i = 0; i < 10 && i < limit; i++) { |
| (...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 520 Add("%o", f); | 520 Add("%o", f); |
| 521 Add("/* warning: no JSFunction object or function name found */ "); | 521 Add("/* warning: no JSFunction object or function name found */ "); |
| 522 } | 522 } |
| 523 } | 523 } |
| 524 | 524 |
| 525 | 525 |
| 526 void StringStream::PrintPrototype(JSFunction* fun, Object* receiver) { | 526 void StringStream::PrintPrototype(JSFunction* fun, Object* receiver) { |
| 527 Object* name = fun->shared()->name(); | 527 Object* name = fun->shared()->name(); |
| 528 bool print_name = false; | 528 bool print_name = false; |
| 529 Isolate* isolate = fun->GetIsolate(); | 529 Isolate* isolate = fun->GetIsolate(); |
| 530 if (receiver->IsNull() || receiver->IsUndefined() || receiver->IsJSProxy()) { | 530 if (receiver->IsNull() || receiver->IsUndefined(isolate) || |
| 531 receiver->IsJSProxy()) { |
| 531 print_name = true; | 532 print_name = true; |
| 532 } else if (isolate->context() != nullptr) { | 533 } else if (isolate->context() != nullptr) { |
| 533 if (!receiver->IsJSObject()) { | 534 if (!receiver->IsJSObject()) { |
| 534 receiver = receiver->GetRootMap(isolate)->prototype(); | 535 receiver = receiver->GetRootMap(isolate)->prototype(); |
| 535 } | 536 } |
| 536 | 537 |
| 537 for (PrototypeIterator iter(isolate, JSObject::cast(receiver), | 538 for (PrototypeIterator iter(isolate, JSObject::cast(receiver), |
| 538 PrototypeIterator::START_AT_RECEIVER); | 539 PrototypeIterator::START_AT_RECEIVER); |
| 539 !iter.IsAtEnd(); iter.Advance()) { | 540 !iter.IsAtEnd(); iter.Advance()) { |
| 540 if (iter.GetCurrent()->IsJSProxy()) break; | 541 if (iter.GetCurrent()->IsJSProxy()) break; |
| 541 Object* key = iter.GetCurrent<JSObject>()->SlowReverseLookup(fun); | 542 Object* key = iter.GetCurrent<JSObject>()->SlowReverseLookup(fun); |
| 542 if (!key->IsUndefined()) { | 543 if (!key->IsUndefined(isolate)) { |
| 543 if (!name->IsString() || | 544 if (!name->IsString() || |
| 544 !key->IsString() || | 545 !key->IsString() || |
| 545 !String::cast(name)->Equals(String::cast(key))) { | 546 !String::cast(name)->Equals(String::cast(key))) { |
| 546 print_name = true; | 547 print_name = true; |
| 547 } | 548 } |
| 548 if (name->IsString() && String::cast(name)->length() == 0) { | 549 if (name->IsString() && String::cast(name)->length() == 0) { |
| 549 print_name = false; | 550 print_name = false; |
| 550 } | 551 } |
| 551 name = key; | 552 name = key; |
| 552 break; | 553 break; |
| (...skipping 24 matching lines...) Expand all Loading... |
| 577 MemCopy(new_space, space_, *bytes); | 578 MemCopy(new_space, space_, *bytes); |
| 578 *bytes = new_bytes; | 579 *bytes = new_bytes; |
| 579 DeleteArray(space_); | 580 DeleteArray(space_); |
| 580 space_ = new_space; | 581 space_ = new_space; |
| 581 return new_space; | 582 return new_space; |
| 582 } | 583 } |
| 583 | 584 |
| 584 | 585 |
| 585 } // namespace internal | 586 } // namespace internal |
| 586 } // namespace v8 | 587 } // namespace v8 |
| OLD | NEW |