OLD | NEW |
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 1709 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1720 return SmiOrNumberFromDouble(value, | 1720 return SmiOrNumberFromDouble(value, |
1721 false /* use preallocated NaN, -0.0 */, | 1721 false /* use preallocated NaN, -0.0 */, |
1722 pretenure); | 1722 pretenure); |
1723 } | 1723 } |
1724 | 1724 |
1725 | 1725 |
1726 Object* Heap::AllocateProxy(Address proxy, PretenureFlag pretenure) { | 1726 Object* Heap::AllocateProxy(Address proxy, PretenureFlag pretenure) { |
1727 // Statically ensure that it is safe to allocate proxies in paged spaces. | 1727 // Statically ensure that it is safe to allocate proxies in paged spaces. |
1728 STATIC_ASSERT(Proxy::kSize <= Page::kMaxHeapObjectSize); | 1728 STATIC_ASSERT(Proxy::kSize <= Page::kMaxHeapObjectSize); |
1729 AllocationSpace space = (pretenure == TENURED) ? OLD_DATA_SPACE : NEW_SPACE; | 1729 AllocationSpace space = (pretenure == TENURED) ? OLD_DATA_SPACE : NEW_SPACE; |
| 1730 if (always_allocate()) space = OLD_DATA_SPACE; |
1730 Object* result = Allocate(proxy_map(), space); | 1731 Object* result = Allocate(proxy_map(), space); |
1731 if (result->IsFailure()) return result; | 1732 if (result->IsFailure()) return result; |
1732 | 1733 |
1733 Proxy::cast(result)->set_proxy(proxy); | 1734 Proxy::cast(result)->set_proxy(proxy); |
1734 return result; | 1735 return result; |
1735 } | 1736 } |
1736 | 1737 |
1737 | 1738 |
1738 Object* Heap::AllocateSharedFunctionInfo(Object* name) { | 1739 Object* Heap::AllocateSharedFunctionInfo(Object* name) { |
1739 Object* result = Allocate(shared_function_info_map(), OLD_POINTER_SPACE); | 1740 Object* result = Allocate(shared_function_info_map(), OLD_POINTER_SPACE); |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1815 map = is_ascii ? short_cons_ascii_string_map() | 1816 map = is_ascii ? short_cons_ascii_string_map() |
1816 : short_cons_string_map(); | 1817 : short_cons_string_map(); |
1817 } else if (length <= String::kMaxMediumSize) { | 1818 } else if (length <= String::kMaxMediumSize) { |
1818 map = is_ascii ? medium_cons_ascii_string_map() | 1819 map = is_ascii ? medium_cons_ascii_string_map() |
1819 : medium_cons_string_map(); | 1820 : medium_cons_string_map(); |
1820 } else { | 1821 } else { |
1821 map = is_ascii ? long_cons_ascii_string_map() | 1822 map = is_ascii ? long_cons_ascii_string_map() |
1822 : long_cons_string_map(); | 1823 : long_cons_string_map(); |
1823 } | 1824 } |
1824 | 1825 |
1825 Object* result = Allocate(map, NEW_SPACE); | 1826 Object* result = Allocate(map, |
| 1827 always_allocate() ? OLD_POINTER_SPACE : NEW_SPACE); |
1826 if (result->IsFailure()) return result; | 1828 if (result->IsFailure()) return result; |
1827 ASSERT(InNewSpace(result)); | |
1828 ConsString* cons_string = ConsString::cast(result); | 1829 ConsString* cons_string = ConsString::cast(result); |
1829 cons_string->set_first(first, SKIP_WRITE_BARRIER); | 1830 WriteBarrierMode mode = cons_string->GetWriteBarrierMode(); |
1830 cons_string->set_second(second, SKIP_WRITE_BARRIER); | 1831 cons_string->set_first(first, mode); |
| 1832 cons_string->set_second(second, mode); |
1831 cons_string->set_length(length); | 1833 cons_string->set_length(length); |
1832 return result; | 1834 return result; |
1833 } | 1835 } |
1834 | 1836 |
1835 | 1837 |
1836 Object* Heap::AllocateSubString(String* buffer, | 1838 Object* Heap::AllocateSubString(String* buffer, |
1837 int start, | 1839 int start, |
1838 int end) { | 1840 int end) { |
1839 int length = end - start; | 1841 int length = end - start; |
1840 | 1842 |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1877 map = short_external_ascii_string_map(); | 1879 map = short_external_ascii_string_map(); |
1878 } else if (length <= static_cast<size_t>(String::kMaxMediumSize)) { | 1880 } else if (length <= static_cast<size_t>(String::kMaxMediumSize)) { |
1879 map = medium_external_ascii_string_map(); | 1881 map = medium_external_ascii_string_map(); |
1880 } else if (length <= static_cast<size_t>(String::kMaxLength)) { | 1882 } else if (length <= static_cast<size_t>(String::kMaxLength)) { |
1881 map = long_external_ascii_string_map(); | 1883 map = long_external_ascii_string_map(); |
1882 } else { | 1884 } else { |
1883 Top::context()->mark_out_of_memory(); | 1885 Top::context()->mark_out_of_memory(); |
1884 return Failure::OutOfMemoryException(); | 1886 return Failure::OutOfMemoryException(); |
1885 } | 1887 } |
1886 | 1888 |
1887 Object* result = Allocate(map, NEW_SPACE); | 1889 Object* result = Allocate(map, |
| 1890 always_allocate() ? OLD_DATA_SPACE : NEW_SPACE); |
1888 if (result->IsFailure()) return result; | 1891 if (result->IsFailure()) return result; |
1889 | 1892 |
1890 ExternalAsciiString* external_string = ExternalAsciiString::cast(result); | 1893 ExternalAsciiString* external_string = ExternalAsciiString::cast(result); |
1891 external_string->set_length(static_cast<int>(length)); | 1894 external_string->set_length(static_cast<int>(length)); |
1892 external_string->set_resource(resource); | 1895 external_string->set_resource(resource); |
1893 | 1896 |
1894 return result; | 1897 return result; |
1895 } | 1898 } |
1896 | 1899 |
1897 | 1900 |
1898 Object* Heap::AllocateExternalStringFromTwoByte( | 1901 Object* Heap::AllocateExternalStringFromTwoByte( |
1899 ExternalTwoByteString::Resource* resource) { | 1902 ExternalTwoByteString::Resource* resource) { |
1900 size_t length = resource->length(); | 1903 size_t length = resource->length(); |
1901 if (length > static_cast<size_t>(String::kMaxLength)) { | 1904 if (length > static_cast<size_t>(String::kMaxLength)) { |
1902 Top::context()->mark_out_of_memory(); | 1905 Top::context()->mark_out_of_memory(); |
1903 return Failure::OutOfMemoryException(); | 1906 return Failure::OutOfMemoryException(); |
1904 } | 1907 } |
1905 Map* map = ExternalTwoByteString::StringMap(static_cast<int>(length)); | 1908 Map* map = ExternalTwoByteString::StringMap(static_cast<int>(length)); |
1906 Object* result = Allocate(map, NEW_SPACE); | 1909 Object* result = Allocate(map, |
| 1910 always_allocate() ? OLD_DATA_SPACE : NEW_SPACE); |
1907 if (result->IsFailure()) return result; | 1911 if (result->IsFailure()) return result; |
1908 | 1912 |
1909 ExternalTwoByteString* external_string = ExternalTwoByteString::cast(result); | 1913 ExternalTwoByteString* external_string = ExternalTwoByteString::cast(result); |
1910 external_string->set_length(static_cast<int>(length)); | 1914 external_string->set_length(static_cast<int>(length)); |
1911 external_string->set_resource(resource); | 1915 external_string->set_resource(resource); |
1912 | 1916 |
1913 return result; | 1917 return result; |
1914 } | 1918 } |
1915 | 1919 |
1916 | 1920 |
(...skipping 364 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2281 map->unused_property_fields() - | 2285 map->unused_property_fields() - |
2282 map->inobject_properties(); | 2286 map->inobject_properties(); |
2283 ASSERT(prop_size >= 0); | 2287 ASSERT(prop_size >= 0); |
2284 Object* properties = AllocateFixedArray(prop_size, pretenure); | 2288 Object* properties = AllocateFixedArray(prop_size, pretenure); |
2285 if (properties->IsFailure()) return properties; | 2289 if (properties->IsFailure()) return properties; |
2286 | 2290 |
2287 // Allocate the JSObject. | 2291 // Allocate the JSObject. |
2288 AllocationSpace space = | 2292 AllocationSpace space = |
2289 (pretenure == TENURED) ? OLD_POINTER_SPACE : NEW_SPACE; | 2293 (pretenure == TENURED) ? OLD_POINTER_SPACE : NEW_SPACE; |
2290 if (map->instance_size() > MaxObjectSizeInPagedSpace()) space = LO_SPACE; | 2294 if (map->instance_size() > MaxObjectSizeInPagedSpace()) space = LO_SPACE; |
| 2295 if (always_allocate()) space = OLD_POINTER_SPACE; |
2291 Object* obj = Allocate(map, space); | 2296 Object* obj = Allocate(map, space); |
2292 if (obj->IsFailure()) return obj; | 2297 if (obj->IsFailure()) return obj; |
2293 | 2298 |
2294 // Initialize the JSObject. | 2299 // Initialize the JSObject. |
2295 InitializeJSObjectFromMap(JSObject::cast(obj), | 2300 InitializeJSObjectFromMap(JSObject::cast(obj), |
2296 FixedArray::cast(properties), | 2301 FixedArray::cast(properties), |
2297 map); | 2302 map); |
2298 return obj; | 2303 return obj; |
2299 } | 2304 } |
2300 | 2305 |
(...skipping 1690 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3991 for (int i = 0; i < kNumberOfCaches; i++) { | 3996 for (int i = 0; i < kNumberOfCaches; i++) { |
3992 if (caches_[i] != NULL) { | 3997 if (caches_[i] != NULL) { |
3993 delete caches_[i]; | 3998 delete caches_[i]; |
3994 caches_[i] = NULL; | 3999 caches_[i] = NULL; |
3995 } | 4000 } |
3996 } | 4001 } |
3997 } | 4002 } |
3998 | 4003 |
3999 | 4004 |
4000 } } // namespace v8::internal | 4005 } } // namespace v8::internal |
OLD | NEW |