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

Side by Side Diff: src/string-stream.cc

Issue 376233002: Introduce a PrototypeIterator class and use it for prototype access (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: updates Created 6 years, 5 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
« no previous file with comments | « src/runtime.cc ('k') | tools/gyp/v8.gyp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 9
9 namespace v8 { 10 namespace v8 {
10 namespace internal { 11 namespace internal {
11 12
12 static const int kMentionedObjectCacheMaxSize = 256; 13 static const int kMentionedObjectCacheMaxSize = 256;
13 14
14 char* HeapStringAllocator::allocate(unsigned bytes) { 15 char* HeapStringAllocator::allocate(unsigned bytes) {
15 space_ = NewArray<char>(bytes); 16 space_ = NewArray<char>(bytes);
16 return space_; 17 return space_;
17 } 18 }
(...skipping 474 matching lines...) Expand 10 before | Expand all | Expand 10 after
492 Add("%o", f); 493 Add("%o", f);
493 Add("/* warning: no JSFunction object or function name found */ "); 494 Add("/* warning: no JSFunction object or function name found */ ");
494 } 495 }
495 } 496 }
496 497
497 498
498 void StringStream::PrintPrototype(JSFunction* fun, Object* receiver) { 499 void StringStream::PrintPrototype(JSFunction* fun, Object* receiver) {
499 Object* name = fun->shared()->name(); 500 Object* name = fun->shared()->name();
500 bool print_name = false; 501 bool print_name = false;
501 Isolate* isolate = fun->GetIsolate(); 502 Isolate* isolate = fun->GetIsolate();
502 for (Object* p = receiver; 503 for (PrototypeIterator iter(isolate, receiver,
503 p != isolate->heap()->null_value(); 504 PrototypeIterator::START_AT_RECEIVER);
504 p = p->GetPrototype(isolate)) { 505 !iter.IsAtEnd(); iter.Advance()) {
505 if (p->IsJSObject()) { 506 if (iter.GetCurrent()->IsJSObject()) {
506 Object* key = JSObject::cast(p)->SlowReverseLookup(fun); 507 Object* key = JSObject::cast(iter.GetCurrent())->SlowReverseLookup(fun);
507 if (key != isolate->heap()->undefined_value()) { 508 if (key != isolate->heap()->undefined_value()) {
508 if (!name->IsString() || 509 if (!name->IsString() ||
509 !key->IsString() || 510 !key->IsString() ||
510 !String::cast(name)->Equals(String::cast(key))) { 511 !String::cast(name)->Equals(String::cast(key))) {
511 print_name = true; 512 print_name = true;
512 } 513 }
513 if (name->IsString() && String::cast(name)->length() == 0) { 514 if (name->IsString() && String::cast(name)->length() == 0) {
514 print_name = false; 515 print_name = false;
515 } 516 }
516 name = key; 517 name = key;
(...skipping 25 matching lines...) Expand all
542 } 543 }
543 MemCopy(new_space, space_, *bytes); 544 MemCopy(new_space, space_, *bytes);
544 *bytes = new_bytes; 545 *bytes = new_bytes;
545 DeleteArray(space_); 546 DeleteArray(space_);
546 space_ = new_space; 547 space_ = new_space;
547 return new_space; 548 return new_space;
548 } 549 }
549 550
550 551
551 } } // namespace v8::internal 552 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/runtime.cc ('k') | tools/gyp/v8.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698