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/once.h" | 9 #include "src/base/once.h" |
10 #include "src/base/utils/random-number-generator.h" | 10 #include "src/base/utils/random-number-generator.h" |
(...skipping 3666 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3677 #ifdef DEBUG | 3677 #ifdef DEBUG |
3678 // Make sure result is NOT a global object if valid. | 3678 // Make sure result is NOT a global object if valid. |
3679 HeapObject* obj; | 3679 HeapObject* obj; |
3680 DCHECK(!allocation.To(&obj) || !obj->IsGlobalObject()); | 3680 DCHECK(!allocation.To(&obj) || !obj->IsGlobalObject()); |
3681 #endif | 3681 #endif |
3682 return allocation; | 3682 return allocation; |
3683 } | 3683 } |
3684 | 3684 |
3685 | 3685 |
3686 AllocationResult Heap::CopyJSObject(JSObject* source, AllocationSite* site) { | 3686 AllocationResult Heap::CopyJSObject(JSObject* source, AllocationSite* site) { |
3687 // Never used to copy functions. If functions need to be copied we | |
3688 // have to be careful to clear the literals array. | |
3689 SLOW_DCHECK(!source->IsJSFunction()); | |
3690 | |
3691 // Make the clone. | 3687 // Make the clone. |
3692 Map* map = source->map(); | 3688 Map* map = source->map(); |
| 3689 |
| 3690 // We can only clone normal objects or arrays. Copying anything else |
| 3691 // will break invariants. |
| 3692 CHECK(map->instance_type() == JS_OBJECT_TYPE || |
| 3693 map->instance_type() == JS_ARRAY_TYPE); |
| 3694 |
3693 int object_size = map->instance_size(); | 3695 int object_size = map->instance_size(); |
3694 HeapObject* clone; | 3696 HeapObject* clone; |
3695 | 3697 |
3696 DCHECK(site == NULL || AllocationSite::CanTrack(map->instance_type())); | 3698 DCHECK(site == NULL || AllocationSite::CanTrack(map->instance_type())); |
3697 | 3699 |
3698 WriteBarrierMode wb_mode = UPDATE_WRITE_BARRIER; | 3700 WriteBarrierMode wb_mode = UPDATE_WRITE_BARRIER; |
3699 | 3701 |
3700 // If we're forced to always allocate, we use the general allocation | 3702 // If we're forced to always allocate, we use the general allocation |
3701 // functions which may leave us with an object in old space. | 3703 // functions which may leave us with an object in old space. |
3702 if (always_allocate()) { | 3704 if (always_allocate()) { |
(...skipping 2440 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6143 static_cast<int>(object_sizes_last_time_[index])); | 6145 static_cast<int>(object_sizes_last_time_[index])); |
6144 CODE_AGE_LIST_COMPLETE(ADJUST_LAST_TIME_OBJECT_COUNT) | 6146 CODE_AGE_LIST_COMPLETE(ADJUST_LAST_TIME_OBJECT_COUNT) |
6145 #undef ADJUST_LAST_TIME_OBJECT_COUNT | 6147 #undef ADJUST_LAST_TIME_OBJECT_COUNT |
6146 | 6148 |
6147 MemCopy(object_counts_last_time_, object_counts_, sizeof(object_counts_)); | 6149 MemCopy(object_counts_last_time_, object_counts_, sizeof(object_counts_)); |
6148 MemCopy(object_sizes_last_time_, object_sizes_, sizeof(object_sizes_)); | 6150 MemCopy(object_sizes_last_time_, object_sizes_, sizeof(object_sizes_)); |
6149 ClearObjectStats(); | 6151 ClearObjectStats(); |
6150 } | 6152 } |
6151 } | 6153 } |
6152 } // namespace v8::internal | 6154 } // namespace v8::internal |
OLD | NEW |