OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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 2627 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2638 AllocatePartialMap(FIXED_ARRAY_TYPE, kVariableSizeSentinel); | 2638 AllocatePartialMap(FIXED_ARRAY_TYPE, kVariableSizeSentinel); |
2639 if (!maybe_obj->ToObject(&obj)) return false; | 2639 if (!maybe_obj->ToObject(&obj)) return false; |
2640 } | 2640 } |
2641 set_fixed_array_map(Map::cast(obj)); | 2641 set_fixed_array_map(Map::cast(obj)); |
2642 | 2642 |
2643 { MaybeObject* maybe_obj = AllocatePartialMap(ODDBALL_TYPE, Oddball::kSize); | 2643 { MaybeObject* maybe_obj = AllocatePartialMap(ODDBALL_TYPE, Oddball::kSize); |
2644 if (!maybe_obj->ToObject(&obj)) return false; | 2644 if (!maybe_obj->ToObject(&obj)) return false; |
2645 } | 2645 } |
2646 set_oddball_map(Map::cast(obj)); | 2646 set_oddball_map(Map::cast(obj)); |
2647 | 2647 |
| 2648 { MaybeObject* maybe_obj = |
| 2649 AllocatePartialMap(CONSTANT_POOL_ARRAY_TYPE, kVariableSizeSentinel); |
| 2650 if (!maybe_obj->ToObject(&obj)) return false; |
| 2651 } |
| 2652 set_constant_pool_array_map(Map::cast(obj)); |
| 2653 |
2648 // Allocate the empty array. | 2654 // Allocate the empty array. |
2649 { MaybeObject* maybe_obj = AllocateEmptyFixedArray(); | 2655 { MaybeObject* maybe_obj = AllocateEmptyFixedArray(); |
2650 if (!maybe_obj->ToObject(&obj)) return false; | 2656 if (!maybe_obj->ToObject(&obj)) return false; |
2651 } | 2657 } |
2652 set_empty_fixed_array(FixedArray::cast(obj)); | 2658 set_empty_fixed_array(FixedArray::cast(obj)); |
2653 | 2659 |
2654 { MaybeObject* maybe_obj = Allocate(oddball_map(), OLD_POINTER_SPACE); | 2660 { MaybeObject* maybe_obj = Allocate(oddball_map(), OLD_POINTER_SPACE); |
2655 if (!maybe_obj->ToObject(&obj)) return false; | 2661 if (!maybe_obj->ToObject(&obj)) return false; |
2656 } | 2662 } |
2657 set_null_value(Oddball::cast(obj)); | 2663 set_null_value(Oddball::cast(obj)); |
2658 Oddball::cast(obj)->set_kind(Oddball::kNull); | 2664 Oddball::cast(obj)->set_kind(Oddball::kNull); |
2659 | 2665 |
2660 { MaybeObject* maybe_obj = Allocate(oddball_map(), OLD_POINTER_SPACE); | 2666 { MaybeObject* maybe_obj = Allocate(oddball_map(), OLD_POINTER_SPACE); |
2661 if (!maybe_obj->ToObject(&obj)) return false; | 2667 if (!maybe_obj->ToObject(&obj)) return false; |
2662 } | 2668 } |
2663 set_undefined_value(Oddball::cast(obj)); | 2669 set_undefined_value(Oddball::cast(obj)); |
2664 Oddball::cast(obj)->set_kind(Oddball::kUndefined); | 2670 Oddball::cast(obj)->set_kind(Oddball::kUndefined); |
2665 ASSERT(!InNewSpace(undefined_value())); | 2671 ASSERT(!InNewSpace(undefined_value())); |
2666 | 2672 |
2667 // Allocate the empty descriptor array. | 2673 // Allocate the empty descriptor array. |
2668 { MaybeObject* maybe_obj = AllocateEmptyFixedArray(); | 2674 { MaybeObject* maybe_obj = AllocateEmptyFixedArray(); |
2669 if (!maybe_obj->ToObject(&obj)) return false; | 2675 if (!maybe_obj->ToObject(&obj)) return false; |
2670 } | 2676 } |
2671 set_empty_descriptor_array(DescriptorArray::cast(obj)); | 2677 set_empty_descriptor_array(DescriptorArray::cast(obj)); |
2672 | 2678 |
| 2679 // Allocate the constant pool array. |
| 2680 { MaybeObject* maybe_obj = AllocateEmptyConstantPoolArray(); |
| 2681 if (!maybe_obj->ToObject(&obj)) return false; |
| 2682 } |
| 2683 set_empty_constant_pool_array(ConstantPoolArray::cast(obj)); |
| 2684 |
2673 // Fix the instance_descriptors for the existing maps. | 2685 // Fix the instance_descriptors for the existing maps. |
2674 meta_map()->set_code_cache(empty_fixed_array()); | 2686 meta_map()->set_code_cache(empty_fixed_array()); |
2675 meta_map()->set_dependent_code(DependentCode::cast(empty_fixed_array())); | 2687 meta_map()->set_dependent_code(DependentCode::cast(empty_fixed_array())); |
2676 meta_map()->init_back_pointer(undefined_value()); | 2688 meta_map()->init_back_pointer(undefined_value()); |
2677 meta_map()->set_instance_descriptors(empty_descriptor_array()); | 2689 meta_map()->set_instance_descriptors(empty_descriptor_array()); |
2678 | 2690 |
2679 fixed_array_map()->set_code_cache(empty_fixed_array()); | 2691 fixed_array_map()->set_code_cache(empty_fixed_array()); |
2680 fixed_array_map()->set_dependent_code( | 2692 fixed_array_map()->set_dependent_code( |
2681 DependentCode::cast(empty_fixed_array())); | 2693 DependentCode::cast(empty_fixed_array())); |
2682 fixed_array_map()->init_back_pointer(undefined_value()); | 2694 fixed_array_map()->init_back_pointer(undefined_value()); |
2683 fixed_array_map()->set_instance_descriptors(empty_descriptor_array()); | 2695 fixed_array_map()->set_instance_descriptors(empty_descriptor_array()); |
2684 | 2696 |
2685 oddball_map()->set_code_cache(empty_fixed_array()); | 2697 oddball_map()->set_code_cache(empty_fixed_array()); |
2686 oddball_map()->set_dependent_code(DependentCode::cast(empty_fixed_array())); | 2698 oddball_map()->set_dependent_code(DependentCode::cast(empty_fixed_array())); |
2687 oddball_map()->init_back_pointer(undefined_value()); | 2699 oddball_map()->init_back_pointer(undefined_value()); |
2688 oddball_map()->set_instance_descriptors(empty_descriptor_array()); | 2700 oddball_map()->set_instance_descriptors(empty_descriptor_array()); |
2689 | 2701 |
| 2702 constant_pool_array_map()->set_code_cache(empty_fixed_array()); |
| 2703 constant_pool_array_map()->set_dependent_code( |
| 2704 DependentCode::cast(empty_fixed_array())); |
| 2705 constant_pool_array_map()->init_back_pointer(undefined_value()); |
| 2706 constant_pool_array_map()->set_instance_descriptors(empty_descriptor_array()); |
| 2707 |
2690 // Fix prototype object for existing maps. | 2708 // Fix prototype object for existing maps. |
2691 meta_map()->set_prototype(null_value()); | 2709 meta_map()->set_prototype(null_value()); |
2692 meta_map()->set_constructor(null_value()); | 2710 meta_map()->set_constructor(null_value()); |
2693 | 2711 |
2694 fixed_array_map()->set_prototype(null_value()); | 2712 fixed_array_map()->set_prototype(null_value()); |
2695 fixed_array_map()->set_constructor(null_value()); | 2713 fixed_array_map()->set_constructor(null_value()); |
2696 | 2714 |
2697 oddball_map()->set_prototype(null_value()); | 2715 oddball_map()->set_prototype(null_value()); |
2698 oddball_map()->set_constructor(null_value()); | 2716 oddball_map()->set_constructor(null_value()); |
2699 | 2717 |
| 2718 constant_pool_array_map()->set_prototype(null_value()); |
| 2719 constant_pool_array_map()->set_constructor(null_value()); |
| 2720 |
2700 { MaybeObject* maybe_obj = | 2721 { MaybeObject* maybe_obj = |
2701 AllocateMap(FIXED_ARRAY_TYPE, kVariableSizeSentinel); | 2722 AllocateMap(FIXED_ARRAY_TYPE, kVariableSizeSentinel); |
2702 if (!maybe_obj->ToObject(&obj)) return false; | 2723 if (!maybe_obj->ToObject(&obj)) return false; |
2703 } | 2724 } |
2704 set_fixed_cow_array_map(Map::cast(obj)); | 2725 set_fixed_cow_array_map(Map::cast(obj)); |
2705 ASSERT(fixed_array_map() != fixed_cow_array_map()); | 2726 ASSERT(fixed_array_map() != fixed_cow_array_map()); |
2706 | 2727 |
2707 { MaybeObject* maybe_obj = | 2728 { MaybeObject* maybe_obj = |
2708 AllocateMap(FIXED_ARRAY_TYPE, kVariableSizeSentinel); | 2729 AllocateMap(FIXED_ARRAY_TYPE, kVariableSizeSentinel); |
2709 if (!maybe_obj->ToObject(&obj)) return false; | 2730 if (!maybe_obj->ToObject(&obj)) return false; |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2746 set_undetectable_ascii_string_map(Map::cast(obj)); | 2767 set_undetectable_ascii_string_map(Map::cast(obj)); |
2747 Map::cast(obj)->set_is_undetectable(); | 2768 Map::cast(obj)->set_is_undetectable(); |
2748 | 2769 |
2749 { MaybeObject* maybe_obj = | 2770 { MaybeObject* maybe_obj = |
2750 AllocateMap(FIXED_DOUBLE_ARRAY_TYPE, kVariableSizeSentinel); | 2771 AllocateMap(FIXED_DOUBLE_ARRAY_TYPE, kVariableSizeSentinel); |
2751 if (!maybe_obj->ToObject(&obj)) return false; | 2772 if (!maybe_obj->ToObject(&obj)) return false; |
2752 } | 2773 } |
2753 set_fixed_double_array_map(Map::cast(obj)); | 2774 set_fixed_double_array_map(Map::cast(obj)); |
2754 | 2775 |
2755 { MaybeObject* maybe_obj = | 2776 { MaybeObject* maybe_obj = |
2756 AllocateMap(CONSTANT_POOL_ARRAY_TYPE, kVariableSizeSentinel); | |
2757 if (!maybe_obj->ToObject(&obj)) return false; | |
2758 } | |
2759 set_constant_pool_array_map(Map::cast(obj)); | |
2760 | |
2761 { MaybeObject* maybe_obj = | |
2762 AllocateMap(BYTE_ARRAY_TYPE, kVariableSizeSentinel); | 2777 AllocateMap(BYTE_ARRAY_TYPE, kVariableSizeSentinel); |
2763 if (!maybe_obj->ToObject(&obj)) return false; | 2778 if (!maybe_obj->ToObject(&obj)) return false; |
2764 } | 2779 } |
2765 set_byte_array_map(Map::cast(obj)); | 2780 set_byte_array_map(Map::cast(obj)); |
2766 | 2781 |
2767 { MaybeObject* maybe_obj = | 2782 { MaybeObject* maybe_obj = |
2768 AllocateMap(FREE_SPACE_TYPE, kVariableSizeSentinel); | 2783 AllocateMap(FREE_SPACE_TYPE, kVariableSizeSentinel); |
2769 if (!maybe_obj->ToObject(&obj)) return false; | 2784 if (!maybe_obj->ToObject(&obj)) return false; |
2770 } | 2785 } |
2771 set_free_space_map(Map::cast(obj)); | 2786 set_free_space_map(Map::cast(obj)); |
(...skipping 1232 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4004 code->set_is_crankshafted(crankshafted); | 4019 code->set_is_crankshafted(crankshafted); |
4005 code->set_deoptimization_data(empty_fixed_array(), SKIP_WRITE_BARRIER); | 4020 code->set_deoptimization_data(empty_fixed_array(), SKIP_WRITE_BARRIER); |
4006 code->set_raw_type_feedback_info(undefined_value()); | 4021 code->set_raw_type_feedback_info(undefined_value()); |
4007 code->set_handler_table(empty_fixed_array(), SKIP_WRITE_BARRIER); | 4022 code->set_handler_table(empty_fixed_array(), SKIP_WRITE_BARRIER); |
4008 code->set_gc_metadata(Smi::FromInt(0)); | 4023 code->set_gc_metadata(Smi::FromInt(0)); |
4009 code->set_ic_age(global_ic_age_); | 4024 code->set_ic_age(global_ic_age_); |
4010 code->set_prologue_offset(prologue_offset); | 4025 code->set_prologue_offset(prologue_offset); |
4011 if (code->kind() == Code::OPTIMIZED_FUNCTION) { | 4026 if (code->kind() == Code::OPTIMIZED_FUNCTION) { |
4012 code->set_marked_for_deoptimization(false); | 4027 code->set_marked_for_deoptimization(false); |
4013 } | 4028 } |
| 4029 code->set_constant_pool(empty_constant_pool_array()); |
4014 | 4030 |
4015 #ifdef ENABLE_DEBUGGER_SUPPORT | 4031 #ifdef ENABLE_DEBUGGER_SUPPORT |
4016 if (code->kind() == Code::FUNCTION) { | 4032 if (code->kind() == Code::FUNCTION) { |
4017 code->set_has_debug_break_slots( | 4033 code->set_has_debug_break_slots( |
4018 isolate_->debugger()->IsDebuggerActive()); | 4034 isolate_->debugger()->IsDebuggerActive()); |
4019 } | 4035 } |
4020 #endif | 4036 #endif |
4021 | 4037 |
4022 // Allow self references to created code object by patching the handle to | 4038 // Allow self references to created code object by patching the handle to |
4023 // point to the newly allocated Code object. | 4039 // point to the newly allocated Code object. |
(...skipping 1219 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5243 if (!maybe_object->To<HeapObject>(&object)) return maybe_object; | 5259 if (!maybe_object->To<HeapObject>(&object)) return maybe_object; |
5244 } | 5260 } |
5245 object = EnsureDoubleAligned(this, object, size); | 5261 object = EnsureDoubleAligned(this, object, size); |
5246 HeapObject::cast(object)->set_map_no_write_barrier(constant_pool_array_map()); | 5262 HeapObject::cast(object)->set_map_no_write_barrier(constant_pool_array_map()); |
5247 | 5263 |
5248 ConstantPoolArray* constant_pool = | 5264 ConstantPoolArray* constant_pool = |
5249 reinterpret_cast<ConstantPoolArray*>(object); | 5265 reinterpret_cast<ConstantPoolArray*>(object); |
5250 constant_pool->SetEntryCounts(number_of_int64_entries, | 5266 constant_pool->SetEntryCounts(number_of_int64_entries, |
5251 number_of_ptr_entries, | 5267 number_of_ptr_entries, |
5252 number_of_int32_entries); | 5268 number_of_int32_entries); |
5253 MemsetPointer( | 5269 if (number_of_ptr_entries > 0) { |
5254 HeapObject::RawField( | 5270 MemsetPointer( |
5255 constant_pool, | 5271 HeapObject::RawField( |
5256 constant_pool->OffsetOfElementAt(constant_pool->first_ptr_index())), | 5272 constant_pool, |
5257 undefined_value(), | 5273 constant_pool->OffsetOfElementAt(constant_pool->first_ptr_index())), |
5258 number_of_ptr_entries); | 5274 undefined_value(), |
| 5275 number_of_ptr_entries); |
| 5276 } |
5259 return constant_pool; | 5277 return constant_pool; |
5260 } | 5278 } |
5261 | 5279 |
5262 | 5280 |
| 5281 MaybeObject* Heap::AllocateEmptyConstantPoolArray() { |
| 5282 int size = ConstantPoolArray::SizeFor(0, 0, 0); |
| 5283 Object* result; |
| 5284 { MaybeObject* maybe_result = |
| 5285 AllocateRaw(size, OLD_DATA_SPACE, OLD_DATA_SPACE); |
| 5286 if (!maybe_result->ToObject(&result)) return maybe_result; |
| 5287 } |
| 5288 HeapObject::cast(result)->set_map_no_write_barrier(constant_pool_array_map()); |
| 5289 ConstantPoolArray::cast(result)->SetEntryCounts(0, 0, 0); |
| 5290 return result; |
| 5291 } |
| 5292 |
| 5293 |
5263 MaybeObject* Heap::AllocateHashTable(int length, PretenureFlag pretenure) { | 5294 MaybeObject* Heap::AllocateHashTable(int length, PretenureFlag pretenure) { |
5264 Object* result; | 5295 Object* result; |
5265 { MaybeObject* maybe_result = AllocateFixedArray(length, pretenure); | 5296 { MaybeObject* maybe_result = AllocateFixedArray(length, pretenure); |
5266 if (!maybe_result->ToObject(&result)) return maybe_result; | 5297 if (!maybe_result->ToObject(&result)) return maybe_result; |
5267 } | 5298 } |
5268 reinterpret_cast<HeapObject*>(result)->set_map_no_write_barrier( | 5299 reinterpret_cast<HeapObject*>(result)->set_map_no_write_barrier( |
5269 hash_table_map()); | 5300 hash_table_map()); |
5270 ASSERT(result->IsHashTable()); | 5301 ASSERT(result->IsHashTable()); |
5271 return result; | 5302 return result; |
5272 } | 5303 } |
(...skipping 2431 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7704 static_cast<int>(object_sizes_last_time_[index])); | 7735 static_cast<int>(object_sizes_last_time_[index])); |
7705 CODE_AGE_LIST_COMPLETE(ADJUST_LAST_TIME_OBJECT_COUNT) | 7736 CODE_AGE_LIST_COMPLETE(ADJUST_LAST_TIME_OBJECT_COUNT) |
7706 #undef ADJUST_LAST_TIME_OBJECT_COUNT | 7737 #undef ADJUST_LAST_TIME_OBJECT_COUNT |
7707 | 7738 |
7708 OS::MemCopy(object_counts_last_time_, object_counts_, sizeof(object_counts_)); | 7739 OS::MemCopy(object_counts_last_time_, object_counts_, sizeof(object_counts_)); |
7709 OS::MemCopy(object_sizes_last_time_, object_sizes_, sizeof(object_sizes_)); | 7740 OS::MemCopy(object_sizes_last_time_, object_sizes_, sizeof(object_sizes_)); |
7710 ClearObjectStats(); | 7741 ClearObjectStats(); |
7711 } | 7742 } |
7712 | 7743 |
7713 } } // namespace v8::internal | 7744 } } // namespace v8::internal |
OLD | NEW |