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

Side by Side Diff: src/objects.cc

Issue 661181: - Pushed source code for functions into old space.... (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: Created 10 years, 10 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/objects.h ('k') | src/objects-inl.h » ('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 2006-2009 the V8 project authors. All rights reserved. 1 // Copyright 2006-2009 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 655 matching lines...) Expand 10 before | Expand all | Expand 10 after
666 return true; // An Ape, an ABCBook. 666 return true; // An Ape, an ABCBook.
667 } else if ((c1 == 0 || (c1 >= 'A' && c1 <= 'Z')) && 667 } else if ((c1 == 0 || (c1 >= 'A' && c1 <= 'Z')) &&
668 (c0 == 'F' || c0 == 'H' || c0 == 'M' || c0 == 'N' || c0 == 'R' || 668 (c0 == 'F' || c0 == 'H' || c0 == 'M' || c0 == 'N' || c0 == 'R' ||
669 c0 == 'S' || c0 == 'X')) { 669 c0 == 'S' || c0 == 'X')) {
670 return true; // An MP3File, an M. 670 return true; // An MP3File, an M.
671 } 671 }
672 return false; 672 return false;
673 } 673 }
674 674
675 675
676 Object* String::TryFlatten() { 676 Object* String::SlowTryFlatten(PretenureFlag pretenure) {
677 #ifdef DEBUG 677 #ifdef DEBUG
678 // Do not attempt to flatten in debug mode when allocation is not 678 // Do not attempt to flatten in debug mode when allocation is not
679 // allowed. This is to avoid an assertion failure when allocating. 679 // allowed. This is to avoid an assertion failure when allocating.
680 // Flattening strings is the only case where we always allow 680 // Flattening strings is the only case where we always allow
681 // allocation because no GC is performed if the allocation fails. 681 // allocation because no GC is performed if the allocation fails.
682 if (!Heap::IsAllocationAllowed()) return this; 682 if (!Heap::IsAllocationAllowed()) return this;
683 #endif 683 #endif
684 684
685 switch (StringShape(this).representation_tag()) { 685 switch (StringShape(this).representation_tag()) {
686 case kConsStringTag: { 686 case kConsStringTag: {
687 ConsString* cs = ConsString::cast(this); 687 ConsString* cs = ConsString::cast(this);
688 if (cs->second()->length() == 0) { 688 if (cs->second()->length() == 0) {
689 return this; 689 return this;
690 } 690 }
691 // There's little point in putting the flat string in new space if the 691 // There's little point in putting the flat string in new space if the
692 // cons string is in old space. It can never get GCed until there is 692 // cons string is in old space. It can never get GCed until there is
693 // an old space GC. 693 // an old space GC.
694 PretenureFlag tenure = Heap::InNewSpace(this) ? NOT_TENURED : TENURED; 694 PretenureFlag tenure = Heap::InNewSpace(this) ? pretenure : TENURED;
695 int len = length(); 695 int len = length();
696 Object* object; 696 Object* object;
697 String* result; 697 String* result;
698 if (IsAsciiRepresentation()) { 698 if (IsAsciiRepresentation()) {
699 object = Heap::AllocateRawAsciiString(len, tenure); 699 object = Heap::AllocateRawAsciiString(len, tenure);
700 if (object->IsFailure()) return object; 700 if (object->IsFailure()) return object;
701 result = String::cast(object); 701 result = String::cast(object);
702 String* first = cs->first(); 702 String* first = cs->first();
703 int first_length = first->length(); 703 int first_length = first->length();
704 char* dest = SeqAsciiString::cast(result)->GetChars(); 704 char* dest = SeqAsciiString::cast(result)->GetChars();
(...skipping 2056 matching lines...) Expand 10 before | Expand all | Expand 10 after
2761 AssertNoContextChange ncc; 2761 AssertNoContextChange ncc;
2762 2762
2763 // Check access rights if needed. 2763 // Check access rights if needed.
2764 if (IsAccessCheckNeeded() && 2764 if (IsAccessCheckNeeded() &&
2765 !Top::MayNamedAccess(this, name, v8::ACCESS_SET)) { 2765 !Top::MayNamedAccess(this, name, v8::ACCESS_SET)) {
2766 Top::ReportFailedAccessCheck(this, v8::ACCESS_SET); 2766 Top::ReportFailedAccessCheck(this, v8::ACCESS_SET);
2767 return Heap::undefined_value(); 2767 return Heap::undefined_value();
2768 } 2768 }
2769 2769
2770 // Try to flatten before operating on the string. 2770 // Try to flatten before operating on the string.
2771 name->TryFlattenIfNotFlat(); 2771 name->TryFlatten();
2772 2772
2773 // Check if there is an API defined callback object which prohibits 2773 // Check if there is an API defined callback object which prohibits
2774 // callback overwriting in this object or it's prototype chain. 2774 // callback overwriting in this object or it's prototype chain.
2775 // This mechanism is needed for instance in a browser setting, where 2775 // This mechanism is needed for instance in a browser setting, where
2776 // certain accessors such as window.location should not be allowed 2776 // certain accessors such as window.location should not be allowed
2777 // to be overwritten because allowing overwriting could potentially 2777 // to be overwritten because allowing overwriting could potentially
2778 // cause security problems. 2778 // cause security problems.
2779 LookupResult callback_result; 2779 LookupResult callback_result;
2780 LookupCallback(name, &callback_result); 2780 LookupCallback(name, &callback_result);
2781 if (callback_result.IsFound()) { 2781 if (callback_result.IsFound()) {
(...skipping 757 matching lines...) Expand 10 before | Expand all | Expand 10 after
3539 return true; 3539 return true;
3540 } 3540 }
3541 3541
3542 3542
3543 int String::Utf8Length() { 3543 int String::Utf8Length() {
3544 if (IsAsciiRepresentation()) return length(); 3544 if (IsAsciiRepresentation()) return length();
3545 // Attempt to flatten before accessing the string. It probably 3545 // Attempt to flatten before accessing the string. It probably
3546 // doesn't make Utf8Length faster, but it is very likely that 3546 // doesn't make Utf8Length faster, but it is very likely that
3547 // the string will be accessed later (for example by WriteUtf8) 3547 // the string will be accessed later (for example by WriteUtf8)
3548 // so it's still a good idea. 3548 // so it's still a good idea.
3549 TryFlattenIfNotFlat(); 3549 TryFlatten();
3550 Access<StringInputBuffer> buffer(&string_input_buffer); 3550 Access<StringInputBuffer> buffer(&string_input_buffer);
3551 buffer->Reset(0, this); 3551 buffer->Reset(0, this);
3552 int result = 0; 3552 int result = 0;
3553 while (buffer->has_more()) 3553 while (buffer->has_more())
3554 result += unibrow::Utf8::Length(buffer->GetNext()); 3554 result += unibrow::Utf8::Length(buffer->GetNext());
3555 return result; 3555 return result;
3556 } 3556 }
3557 3557
3558 3558
3559 Vector<const char> String::ToAsciiVector() { 3559 Vector<const char> String::ToAsciiVector() {
(...skipping 1070 matching lines...) Expand 10 before | Expand all | Expand 10 after
4630 // Process the remaining characters without updating the array 4630 // Process the remaining characters without updating the array
4631 // index. 4631 // index.
4632 while (buffer->has_more()) { 4632 while (buffer->has_more()) {
4633 hasher.AddCharacterNoIndex(buffer->GetNext()); 4633 hasher.AddCharacterNoIndex(buffer->GetNext());
4634 } 4634 }
4635 4635
4636 return hasher.GetHashField(); 4636 return hasher.GetHashField();
4637 } 4637 }
4638 4638
4639 4639
4640 Object* String::SubString(int start, int end) { 4640 Object* String::SubString(int start, int end, PretenureFlag pretenure) {
4641 if (start == 0 && end == length()) return this; 4641 if (start == 0 && end == length()) return this;
4642 Object* result = Heap::AllocateSubString(this, start, end); 4642 Object* result = Heap::AllocateSubString(this, start, end, pretenure);
4643 return result; 4643 return result;
4644 } 4644 }
4645 4645
4646 4646
4647 void String::PrintOn(FILE* file) { 4647 void String::PrintOn(FILE* file) {
4648 int length = this->length(); 4648 int length = this->length();
4649 for (int i = 0; i < length; i++) { 4649 for (int i = 0; i < length; i++) {
4650 fprintf(file, "%c", Get(i)); 4650 fprintf(file, "%c", Get(i));
4651 } 4651 }
4652 } 4652 }
(...skipping 3708 matching lines...) Expand 10 before | Expand all | Expand 10 after
8361 if (break_point_objects()->IsUndefined()) return 0; 8361 if (break_point_objects()->IsUndefined()) return 0;
8362 // Single beak point. 8362 // Single beak point.
8363 if (!break_point_objects()->IsFixedArray()) return 1; 8363 if (!break_point_objects()->IsFixedArray()) return 1;
8364 // Multiple break points. 8364 // Multiple break points.
8365 return FixedArray::cast(break_point_objects())->length(); 8365 return FixedArray::cast(break_point_objects())->length();
8366 } 8366 }
8367 #endif 8367 #endif
8368 8368
8369 8369
8370 } } // namespace v8::internal 8370 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/objects.h ('k') | src/objects-inl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698