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

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

Issue 348313002: Introduce a PrototypeIterator template and use it all over the place (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: rebase Created 6 years, 6 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') | src/stub-cache.cc » ('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-iterator.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 481 matching lines...) Expand 10 before | Expand all | Expand 10 after
499 Add("%o", f); 500 Add("%o", f);
500 Add("/* warning: no JSFunction object or function name found */ "); 501 Add("/* warning: no JSFunction object or function name found */ ");
501 } 502 }
502 } 503 }
503 504
504 505
505 void StringStream::PrintPrototype(JSFunction* fun, Object* receiver) { 506 void StringStream::PrintPrototype(JSFunction* fun, Object* receiver) {
506 Object* name = fun->shared()->name(); 507 Object* name = fun->shared()->name();
507 bool print_name = false; 508 bool print_name = false;
508 Isolate* isolate = fun->GetIsolate(); 509 Isolate* isolate = fun->GetIsolate();
509 for (Object* p = receiver; 510 for (PrototypeIterator<STORE_AS_POINTER, TYPE_BASED_WALK, END_AT_NULL_VALUE>
510 p != isolate->heap()->null_value(); 511 iter(isolate, receiver); !iter.IsAtEnd(); iter.Advance()) {
511 p = p->GetPrototype(isolate)) { 512 if (iter.GetCurrent()->IsJSObject()) {
512 if (p->IsJSObject()) { 513 Object* key = JSObject::cast(iter.GetCurrent())->SlowReverseLookup(fun);
513 Object* key = JSObject::cast(p)->SlowReverseLookup(fun);
514 if (key != isolate->heap()->undefined_value()) { 514 if (key != isolate->heap()->undefined_value()) {
515 if (!name->IsString() || 515 if (!name->IsString() ||
516 !key->IsString() || 516 !key->IsString() ||
517 !String::cast(name)->Equals(String::cast(key))) { 517 !String::cast(name)->Equals(String::cast(key))) {
518 print_name = true; 518 print_name = true;
519 } 519 }
520 if (name->IsString() && String::cast(name)->length() == 0) { 520 if (name->IsString() && String::cast(name)->length() == 0) {
521 print_name = false; 521 print_name = false;
522 } 522 }
523 name = key; 523 name = key;
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
557 557
558 // Only grow once to the maximum allowable size. 558 // Only grow once to the maximum allowable size.
559 char* NoAllocationStringAllocator::grow(unsigned* bytes) { 559 char* NoAllocationStringAllocator::grow(unsigned* bytes) {
560 ASSERT(size_ >= *bytes); 560 ASSERT(size_ >= *bytes);
561 *bytes = size_; 561 *bytes = size_;
562 return space_; 562 return space_;
563 } 563 }
564 564
565 565
566 } } // namespace v8::internal 566 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/runtime.cc ('k') | src/stub-cache.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698