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

Side by Side Diff: src/heap.cc

Issue 243051: the idea is that often times in code, you will see something like this:... (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: '' Created 11 years, 2 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/heap.h ('k') | src/parser.cc » ('j') | src/parser.cc » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2009 the V8 project authors. All rights reserved. 1 // Copyright 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 1646 matching lines...) Expand 10 before | Expand all | Expand 10 after
1657 share->set_start_position_and_type(0); 1657 share->set_start_position_and_type(0);
1658 share->set_debug_info(undefined_value()); 1658 share->set_debug_info(undefined_value());
1659 share->set_inferred_name(empty_string()); 1659 share->set_inferred_name(empty_string());
1660 share->set_compiler_hints(0); 1660 share->set_compiler_hints(0);
1661 share->set_this_property_assignments_count(0); 1661 share->set_this_property_assignments_count(0);
1662 share->set_this_property_assignments(undefined_value()); 1662 share->set_this_property_assignments(undefined_value());
1663 return result; 1663 return result;
1664 } 1664 }
1665 1665
1666 1666
1667 Object* Heap::AllocateConsString(String* first, String* second) { 1667 Object* Heap::AllocateConsString(String* first,
1668 String* second,
1669 PretenureFlag pretenure) {
1668 int first_length = first->length(); 1670 int first_length = first->length();
1669 if (first_length == 0) return second; 1671 if (first_length == 0) return second;
1670 1672
1671 int second_length = second->length(); 1673 int second_length = second->length();
1672 if (second_length == 0) return first; 1674 if (second_length == 0) return first;
1673 1675
1674 int length = first_length + second_length; 1676 int length = first_length + second_length;
1675 bool is_ascii = first->IsAsciiRepresentation() 1677 bool is_ascii = first->IsAsciiRepresentation()
1676 && second->IsAsciiRepresentation(); 1678 && second->IsAsciiRepresentation();
1677 1679
1678 // Make sure that an out of memory exception is thrown if the length 1680 // Make sure that an out of memory exception is thrown if the length
1679 // of the new cons string is too large to fit in a Smi. 1681 // of the new cons string is too large to fit in a Smi.
1680 if (length > Smi::kMaxValue || length < -0) { 1682 if (length > Smi::kMaxValue || length < -0) {
1681 Top::context()->mark_out_of_memory(); 1683 Top::context()->mark_out_of_memory();
1682 return Failure::OutOfMemoryException(); 1684 return Failure::OutOfMemoryException();
1683 } 1685 }
1684 1686
1685 // If the resulting string is small make a flat string. 1687 // If the resulting string is small make a flat string.
1686 if (length < String::kMinNonFlatLength) { 1688 if (length < String::kMinNonFlatLength) {
1687 ASSERT(first->IsFlat()); 1689 ASSERT(first->IsFlat());
1688 ASSERT(second->IsFlat()); 1690 ASSERT(second->IsFlat());
1689 if (is_ascii) { 1691 if (is_ascii) {
1690 Object* result = AllocateRawAsciiString(length); 1692 Object* result = AllocateRawAsciiString(length, pretenure);
1691 if (result->IsFailure()) return result; 1693 if (result->IsFailure()) return result;
1692 // Copy the characters into the new object. 1694 // Copy the characters into the new object.
1693 char* dest = SeqAsciiString::cast(result)->GetChars(); 1695 char* dest = SeqAsciiString::cast(result)->GetChars();
1694 // Copy first part. 1696 // Copy first part.
1695 char* src = SeqAsciiString::cast(first)->GetChars(); 1697 char* src = SeqAsciiString::cast(first)->GetChars();
1696 for (int i = 0; i < first_length; i++) *dest++ = src[i]; 1698 for (int i = 0; i < first_length; i++) *dest++ = src[i];
1697 // Copy second part. 1699 // Copy second part.
1698 src = SeqAsciiString::cast(second)->GetChars(); 1700 src = SeqAsciiString::cast(second)->GetChars();
1699 for (int i = 0; i < second_length; i++) *dest++ = src[i]; 1701 for (int i = 0; i < second_length; i++) *dest++ = src[i];
1700 return result; 1702 return result;
1701 } else { 1703 } else {
1702 Object* result = AllocateRawTwoByteString(length); 1704 Object* result = AllocateRawTwoByteString(length, pretenure);
1703 if (result->IsFailure()) return result; 1705 if (result->IsFailure()) return result;
1704 // Copy the characters into the new object. 1706 // Copy the characters into the new object.
1705 uc16* dest = SeqTwoByteString::cast(result)->GetChars(); 1707 uc16* dest = SeqTwoByteString::cast(result)->GetChars();
1706 String::WriteToFlat(first, dest, 0, first_length); 1708 String::WriteToFlat(first, dest, 0, first_length);
1707 String::WriteToFlat(second, dest + first_length, 0, second_length); 1709 String::WriteToFlat(second, dest + first_length, 0, second_length);
1708 return result; 1710 return result;
1709 } 1711 }
1710 } 1712 }
1711 1713
1712 Map* map; 1714 Map* map;
1713 if (length <= String::kMaxShortStringSize) { 1715 if (length <= String::kMaxShortStringSize) {
1714 map = is_ascii ? short_cons_ascii_string_map() 1716 map = is_ascii ? short_cons_ascii_string_map()
1715 : short_cons_string_map(); 1717 : short_cons_string_map();
1716 } else if (length <= String::kMaxMediumStringSize) { 1718 } else if (length <= String::kMaxMediumStringSize) {
1717 map = is_ascii ? medium_cons_ascii_string_map() 1719 map = is_ascii ? medium_cons_ascii_string_map()
1718 : medium_cons_string_map(); 1720 : medium_cons_string_map();
1719 } else { 1721 } else {
1720 map = is_ascii ? long_cons_ascii_string_map() 1722 map = is_ascii ? long_cons_ascii_string_map()
1721 : long_cons_string_map(); 1723 : long_cons_string_map();
1722 } 1724 }
1723 1725
1724 Object* result = Allocate(map, NEW_SPACE); 1726 AllocationSpace space =
1727 (pretenure == TENURED) ? OLD_POINTER_SPACE : NEW_SPACE;
1728 if (map->instance_size() > MaxObjectSizeInPagedSpace()) space = LO_SPACE;
1729 Object* result = Allocate(map, space);
1725 if (result->IsFailure()) return result; 1730 if (result->IsFailure()) return result;
1726 ASSERT(InNewSpace(result)); 1731 ASSERT(pretenure == TENURED ? !InNewSpace(result) : InNewSpace(result));
1727 ConsString* cons_string = ConsString::cast(result); 1732 ConsString* cons_string = ConsString::cast(result);
1728 cons_string->set_first(first, SKIP_WRITE_BARRIER); 1733 WriteBarrierMode write_barrier_mode =
1729 cons_string->set_second(second, SKIP_WRITE_BARRIER); 1734 (pretenure == TENURED) ? UPDATE_WRITE_BARRIER : SKIP_WRITE_BARRIER;
1735 cons_string->set_first(first, write_barrier_mode);
1736 cons_string->set_second(second, write_barrier_mode);
1730 cons_string->set_length(length); 1737 cons_string->set_length(length);
1731 return result; 1738 return result;
1732 } 1739 }
1733 1740
1734 1741
1735 Object* Heap::AllocateSlicedString(String* buffer, 1742 Object* Heap::AllocateSlicedString(String* buffer,
1736 int start, 1743 int start,
1737 int end) { 1744 int end) {
1738 int length = end - start; 1745 int length = end - start;
1739 1746
(...skipping 2134 matching lines...) Expand 10 before | Expand all | Expand 10 after
3874 for (int i = 0; i < kNumberOfCaches; i++) { 3881 for (int i = 0; i < kNumberOfCaches; i++) {
3875 if (caches_[i] != NULL) { 3882 if (caches_[i] != NULL) {
3876 delete caches_[i]; 3883 delete caches_[i];
3877 caches_[i] = NULL; 3884 caches_[i] = NULL;
3878 } 3885 }
3879 } 3886 }
3880 } 3887 }
3881 3888
3882 3889
3883 } } // namespace v8::internal 3890 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/heap.h ('k') | src/parser.cc » ('j') | src/parser.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698