OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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/v8.h" | 5 #include "src/v8.h" |
6 | 6 |
7 #include "src/accessors.h" | 7 #include "src/accessors.h" |
8 #include "src/api.h" | 8 #include "src/api.h" |
9 #include "src/base/bits.h" | 9 #include "src/base/bits.h" |
10 #include "src/base/once.h" | 10 #include "src/base/once.h" |
(...skipping 3084 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3095 AllocationResult Heap::AllocateWeakCell(HeapObject* value) { | 3095 AllocationResult Heap::AllocateWeakCell(HeapObject* value) { |
3096 int size = WeakCell::kSize; | 3096 int size = WeakCell::kSize; |
3097 STATIC_ASSERT(WeakCell::kSize <= Page::kMaxRegularHeapObjectSize); | 3097 STATIC_ASSERT(WeakCell::kSize <= Page::kMaxRegularHeapObjectSize); |
3098 HeapObject* result = NULL; | 3098 HeapObject* result = NULL; |
3099 { | 3099 { |
3100 AllocationResult allocation = AllocateRaw(size, OLD_SPACE, OLD_SPACE); | 3100 AllocationResult allocation = AllocateRaw(size, OLD_SPACE, OLD_SPACE); |
3101 if (!allocation.To(&result)) return allocation; | 3101 if (!allocation.To(&result)) return allocation; |
3102 } | 3102 } |
3103 result->set_map_no_write_barrier(weak_cell_map()); | 3103 result->set_map_no_write_barrier(weak_cell_map()); |
3104 WeakCell::cast(result)->initialize(value); | 3104 WeakCell::cast(result)->initialize(value); |
3105 WeakCell::cast(result)->set_next(the_hole_value(), SKIP_WRITE_BARRIER); | 3105 WeakCell::cast(result)->set_next(undefined_value(), SKIP_WRITE_BARRIER); |
3106 return result; | 3106 return result; |
3107 } | 3107 } |
3108 | 3108 |
3109 | 3109 |
3110 void Heap::CreateApiObjects() { | 3110 void Heap::CreateApiObjects() { |
3111 HandleScope scope(isolate()); | 3111 HandleScope scope(isolate()); |
3112 Factory* factory = isolate()->factory(); | 3112 Factory* factory = isolate()->factory(); |
3113 Handle<Map> new_neander_map = | 3113 Handle<Map> new_neander_map = |
3114 factory->NewMap(JS_OBJECT_TYPE, JSObject::kHeaderSize); | 3114 factory->NewMap(JS_OBJECT_TYPE, JSObject::kHeaderSize); |
3115 | 3115 |
(...skipping 583 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3699 | 3699 |
3700 result->set_map_no_write_barrier(byte_array_map()); | 3700 result->set_map_no_write_barrier(byte_array_map()); |
3701 ByteArray::cast(result)->set_length(length); | 3701 ByteArray::cast(result)->set_length(length); |
3702 return result; | 3702 return result; |
3703 } | 3703 } |
3704 | 3704 |
3705 | 3705 |
3706 void Heap::CreateFillerObjectAt(Address addr, int size) { | 3706 void Heap::CreateFillerObjectAt(Address addr, int size) { |
3707 if (size == 0) return; | 3707 if (size == 0) return; |
3708 HeapObject* filler = HeapObject::FromAddress(addr); | 3708 HeapObject* filler = HeapObject::FromAddress(addr); |
| 3709 // At this point, we may be deserializing the heap from a snapshot, and |
| 3710 // none of the maps have been created yet and are NULL. |
3709 if (size == kPointerSize) { | 3711 if (size == kPointerSize) { |
3710 filler->set_map_no_write_barrier(raw_unchecked_one_pointer_filler_map()); | 3712 filler->set_map_no_write_barrier(raw_unchecked_one_pointer_filler_map()); |
| 3713 DCHECK(filler->map() == NULL || filler->map() == one_pointer_filler_map()); |
3711 } else if (size == 2 * kPointerSize) { | 3714 } else if (size == 2 * kPointerSize) { |
3712 filler->set_map_no_write_barrier(raw_unchecked_two_pointer_filler_map()); | 3715 filler->set_map_no_write_barrier(raw_unchecked_two_pointer_filler_map()); |
| 3716 DCHECK(filler->map() == NULL || filler->map() == two_pointer_filler_map()); |
3713 } else { | 3717 } else { |
3714 filler->set_map_no_write_barrier(raw_unchecked_free_space_map()); | 3718 filler->set_map_no_write_barrier(raw_unchecked_free_space_map()); |
| 3719 DCHECK(filler->map() == NULL || filler->map() == free_space_map()); |
3715 FreeSpace::cast(filler)->nobarrier_set_size(size); | 3720 FreeSpace::cast(filler)->nobarrier_set_size(size); |
3716 } | 3721 } |
3717 // At this point, we may be deserializing the heap from a snapshot, and | |
3718 // none of the maps have been created yet and are NULL. | |
3719 DCHECK(filler->map() == NULL && !deserialization_complete_ || | |
3720 filler->map()->IsMap()); | |
3721 } | 3722 } |
3722 | 3723 |
3723 | 3724 |
3724 bool Heap::CanMoveObjectStart(HeapObject* object) { | 3725 bool Heap::CanMoveObjectStart(HeapObject* object) { |
3725 Address address = object->address(); | 3726 Address address = object->address(); |
3726 | 3727 |
3727 if (lo_space()->Contains(object)) return false; | 3728 if (lo_space()->Contains(object)) return false; |
3728 | 3729 |
3729 Page* page = Page::FromAddress(address); | 3730 Page* page = Page::FromAddress(address); |
3730 // We can move the object start if: | 3731 // We can move the object start if: |
(...skipping 3056 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6787 *object_type = "CODE_TYPE"; \ | 6788 *object_type = "CODE_TYPE"; \ |
6788 *object_sub_type = "CODE_AGE/" #name; \ | 6789 *object_sub_type = "CODE_AGE/" #name; \ |
6789 return true; | 6790 return true; |
6790 CODE_AGE_LIST_COMPLETE(COMPARE_AND_RETURN_NAME) | 6791 CODE_AGE_LIST_COMPLETE(COMPARE_AND_RETURN_NAME) |
6791 #undef COMPARE_AND_RETURN_NAME | 6792 #undef COMPARE_AND_RETURN_NAME |
6792 } | 6793 } |
6793 return false; | 6794 return false; |
6794 } | 6795 } |
6795 } // namespace internal | 6796 } // namespace internal |
6796 } // namespace v8 | 6797 } // namespace v8 |
OLD | NEW |