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 509 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 for (PrototypeIterator iter(isolate, receiver, | 530 if (receiver->IsNull() || receiver->IsUndefined() || receiver->IsJSProxy()) { |
531 PrototypeIterator::START_AT_RECEIVER); | 531 print_name = true; |
532 !iter.IsAtEnd(); iter.Advance()) { | 532 } else { |
533 if (iter.GetCurrent()->IsJSObject()) { | 533 if (!receiver->IsJSObject()) { |
| 534 receiver = receiver->GetRootMap(isolate)->prototype(); |
| 535 } |
| 536 |
| 537 for (PrototypeIterator iter(isolate, JSObject::cast(receiver), |
| 538 PrototypeIterator::START_AT_RECEIVER); |
| 539 !iter.IsAtEnd(); iter.Advance()) { |
534 Object* key = iter.GetCurrent<JSObject>()->SlowReverseLookup(fun); | 540 Object* key = iter.GetCurrent<JSObject>()->SlowReverseLookup(fun); |
535 if (key != isolate->heap()->undefined_value()) { | 541 if (!key->IsUndefined()) { |
536 if (!name->IsString() || | 542 if (!name->IsString() || |
537 !key->IsString() || | 543 !key->IsString() || |
538 !String::cast(name)->Equals(String::cast(key))) { | 544 !String::cast(name)->Equals(String::cast(key))) { |
539 print_name = true; | 545 print_name = true; |
540 } | 546 } |
541 if (name->IsString() && String::cast(name)->length() == 0) { | 547 if (name->IsString() && String::cast(name)->length() == 0) { |
542 print_name = false; | 548 print_name = false; |
543 } | 549 } |
544 name = key; | 550 name = key; |
| 551 break; |
545 } | 552 } |
546 } else { | |
547 print_name = true; | |
548 } | 553 } |
549 } | 554 } |
550 PrintName(name); | 555 PrintName(name); |
551 // Also known as - if the name in the function doesn't match the name under | 556 // Also known as - if the name in the function doesn't match the name under |
552 // which it was looked up. | 557 // which it was looked up. |
553 if (print_name) { | 558 if (print_name) { |
554 Add("(aka "); | 559 Add("(aka "); |
555 PrintName(fun->shared()->name()); | 560 PrintName(fun->shared()->name()); |
556 Put(')'); | 561 Put(')'); |
557 } | 562 } |
(...skipping 13 matching lines...) Expand all Loading... |
571 MemCopy(new_space, space_, *bytes); | 576 MemCopy(new_space, space_, *bytes); |
572 *bytes = new_bytes; | 577 *bytes = new_bytes; |
573 DeleteArray(space_); | 578 DeleteArray(space_); |
574 space_ = new_space; | 579 space_ = new_space; |
575 return new_space; | 580 return new_space; |
576 } | 581 } |
577 | 582 |
578 | 583 |
579 } // namespace internal | 584 } // namespace internal |
580 } // namespace v8 | 585 } // namespace v8 |
OLD | NEW |