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 1173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1184 | 1184 |
1185 obj = AllocateMap(LONG_ASCII_STRING_TYPE, SeqAsciiString::kAlignedSize); | 1185 obj = AllocateMap(LONG_ASCII_STRING_TYPE, SeqAsciiString::kAlignedSize); |
1186 if (obj->IsFailure()) return false; | 1186 if (obj->IsFailure()) return false; |
1187 set_undetectable_long_ascii_string_map(Map::cast(obj)); | 1187 set_undetectable_long_ascii_string_map(Map::cast(obj)); |
1188 Map::cast(obj)->set_is_undetectable(); | 1188 Map::cast(obj)->set_is_undetectable(); |
1189 | 1189 |
1190 obj = AllocateMap(BYTE_ARRAY_TYPE, ByteArray::kAlignedSize); | 1190 obj = AllocateMap(BYTE_ARRAY_TYPE, ByteArray::kAlignedSize); |
1191 if (obj->IsFailure()) return false; | 1191 if (obj->IsFailure()) return false; |
1192 set_byte_array_map(Map::cast(obj)); | 1192 set_byte_array_map(Map::cast(obj)); |
1193 | 1193 |
| 1194 obj = AllocateMap(PIXEL_ARRAY_TYPE, PixelArray::kAlignedSize); |
| 1195 if (obj->IsFailure()) return false; |
| 1196 set_pixel_array_map(Map::cast(obj)); |
| 1197 |
1194 obj = AllocateMap(CODE_TYPE, Code::kHeaderSize); | 1198 obj = AllocateMap(CODE_TYPE, Code::kHeaderSize); |
1195 if (obj->IsFailure()) return false; | 1199 if (obj->IsFailure()) return false; |
1196 set_code_map(Map::cast(obj)); | 1200 set_code_map(Map::cast(obj)); |
1197 | 1201 |
1198 obj = AllocateMap(JS_GLOBAL_PROPERTY_CELL_TYPE, | 1202 obj = AllocateMap(JS_GLOBAL_PROPERTY_CELL_TYPE, |
1199 JSGlobalPropertyCell::kSize); | 1203 JSGlobalPropertyCell::kSize); |
1200 if (obj->IsFailure()) return false; | 1204 if (obj->IsFailure()) return false; |
1201 set_global_property_cell_map(Map::cast(obj)); | 1205 set_global_property_cell_map(Map::cast(obj)); |
1202 | 1206 |
1203 obj = AllocateMap(FILLER_TYPE, kPointerSize); | 1207 obj = AllocateMap(FILLER_TYPE, kPointerSize); |
(...skipping 365 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1569 Object* Heap::NumberFromDouble(double value, PretenureFlag pretenure) { | 1573 Object* Heap::NumberFromDouble(double value, PretenureFlag pretenure) { |
1570 return SmiOrNumberFromDouble(value, | 1574 return SmiOrNumberFromDouble(value, |
1571 false /* use preallocated NaN, -0.0 */, | 1575 false /* use preallocated NaN, -0.0 */, |
1572 pretenure); | 1576 pretenure); |
1573 } | 1577 } |
1574 | 1578 |
1575 | 1579 |
1576 Object* Heap::AllocateProxy(Address proxy, PretenureFlag pretenure) { | 1580 Object* Heap::AllocateProxy(Address proxy, PretenureFlag pretenure) { |
1577 // Statically ensure that it is safe to allocate proxies in paged spaces. | 1581 // Statically ensure that it is safe to allocate proxies in paged spaces. |
1578 STATIC_ASSERT(Proxy::kSize <= Page::kMaxHeapObjectSize); | 1582 STATIC_ASSERT(Proxy::kSize <= Page::kMaxHeapObjectSize); |
1579 AllocationSpace space = | 1583 AllocationSpace space = (pretenure == TENURED) ? OLD_DATA_SPACE : NEW_SPACE; |
1580 (pretenure == TENURED) ? OLD_DATA_SPACE : NEW_SPACE; | |
1581 Object* result = Allocate(proxy_map(), space); | 1584 Object* result = Allocate(proxy_map(), space); |
1582 if (result->IsFailure()) return result; | 1585 if (result->IsFailure()) return result; |
1583 | 1586 |
1584 Proxy::cast(result)->set_proxy(proxy); | 1587 Proxy::cast(result)->set_proxy(proxy); |
1585 return result; | 1588 return result; |
1586 } | 1589 } |
1587 | 1590 |
1588 | 1591 |
1589 Object* Heap::AllocateSharedFunctionInfo(Object* name) { | 1592 Object* Heap::AllocateSharedFunctionInfo(Object* name) { |
1590 Object* result = Allocate(shared_function_info_map(), OLD_POINTER_SPACE); | 1593 Object* result = Allocate(shared_function_info_map(), OLD_POINTER_SPACE); |
(...skipping 261 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1852 HeapObject* filler = HeapObject::FromAddress(addr); | 1855 HeapObject* filler = HeapObject::FromAddress(addr); |
1853 if (size == kPointerSize) { | 1856 if (size == kPointerSize) { |
1854 filler->set_map(Heap::one_pointer_filler_map()); | 1857 filler->set_map(Heap::one_pointer_filler_map()); |
1855 } else { | 1858 } else { |
1856 filler->set_map(Heap::byte_array_map()); | 1859 filler->set_map(Heap::byte_array_map()); |
1857 ByteArray::cast(filler)->set_length(ByteArray::LengthFor(size)); | 1860 ByteArray::cast(filler)->set_length(ByteArray::LengthFor(size)); |
1858 } | 1861 } |
1859 } | 1862 } |
1860 | 1863 |
1861 | 1864 |
| 1865 Object* Heap::AllocatePixelArray(int length, |
| 1866 uint8_t* external_pointer, |
| 1867 PretenureFlag pretenure) { |
| 1868 AllocationSpace space = (pretenure == TENURED) ? OLD_DATA_SPACE : NEW_SPACE; |
| 1869 |
| 1870 Object* result = AllocateRaw(PixelArray::kAlignedSize, space, OLD_DATA_SPACE); |
| 1871 |
| 1872 if (result->IsFailure()) return result; |
| 1873 |
| 1874 reinterpret_cast<PixelArray*>(result)->set_map(pixel_array_map()); |
| 1875 reinterpret_cast<PixelArray*>(result)->set_length(length); |
| 1876 reinterpret_cast<PixelArray*>(result)->set_external_pointer(external_pointer); |
| 1877 |
| 1878 return result; |
| 1879 } |
| 1880 |
| 1881 |
1862 Object* Heap::CreateCode(const CodeDesc& desc, | 1882 Object* Heap::CreateCode(const CodeDesc& desc, |
1863 ZoneScopeInfo* sinfo, | 1883 ZoneScopeInfo* sinfo, |
1864 Code::Flags flags, | 1884 Code::Flags flags, |
1865 Handle<Object> self_reference) { | 1885 Handle<Object> self_reference) { |
1866 // Compute size | 1886 // Compute size |
1867 int body_size = RoundUp(desc.instr_size + desc.reloc_size, kObjectAlignment); | 1887 int body_size = RoundUp(desc.instr_size + desc.reloc_size, kObjectAlignment); |
1868 int sinfo_size = 0; | 1888 int sinfo_size = 0; |
1869 if (sinfo != NULL) sinfo_size = sinfo->Serialize(NULL); | 1889 if (sinfo != NULL) sinfo_size = sinfo->Serialize(NULL); |
1870 int obj_size = Code::SizeFor(body_size, sinfo_size); | 1890 int obj_size = Code::SizeFor(body_size, sinfo_size); |
1871 ASSERT(IsAligned(obj_size, Code::kCodeAlignment)); | 1891 ASSERT(IsAligned(obj_size, Code::kCodeAlignment)); |
(...skipping 1846 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3718 #ifdef DEBUG | 3738 #ifdef DEBUG |
3719 bool Heap::GarbageCollectionGreedyCheck() { | 3739 bool Heap::GarbageCollectionGreedyCheck() { |
3720 ASSERT(FLAG_gc_greedy); | 3740 ASSERT(FLAG_gc_greedy); |
3721 if (Bootstrapper::IsActive()) return true; | 3741 if (Bootstrapper::IsActive()) return true; |
3722 if (disallow_allocation_failure()) return true; | 3742 if (disallow_allocation_failure()) return true; |
3723 return CollectGarbage(0, NEW_SPACE); | 3743 return CollectGarbage(0, NEW_SPACE); |
3724 } | 3744 } |
3725 #endif | 3745 #endif |
3726 | 3746 |
3727 } } // namespace v8::internal | 3747 } } // namespace v8::internal |
OLD | NEW |