| 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 2602 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2613 AllocatePartialMap(FIXED_ARRAY_TYPE, kVariableSizeSentinel); | 2613 AllocatePartialMap(FIXED_ARRAY_TYPE, kVariableSizeSentinel); |
| 2614 if (!maybe_obj->ToObject(&obj)) return false; | 2614 if (!maybe_obj->ToObject(&obj)) return false; |
| 2615 } | 2615 } |
| 2616 set_fixed_array_map(Map::cast(obj)); | 2616 set_fixed_array_map(Map::cast(obj)); |
| 2617 | 2617 |
| 2618 { MaybeObject* maybe_obj = AllocatePartialMap(ODDBALL_TYPE, Oddball::kSize); | 2618 { MaybeObject* maybe_obj = AllocatePartialMap(ODDBALL_TYPE, Oddball::kSize); |
| 2619 if (!maybe_obj->ToObject(&obj)) return false; | 2619 if (!maybe_obj->ToObject(&obj)) return false; |
| 2620 } | 2620 } |
| 2621 set_oddball_map(Map::cast(obj)); | 2621 set_oddball_map(Map::cast(obj)); |
| 2622 | 2622 |
| 2623 { MaybeObject* maybe_obj = |
| 2624 AllocatePartialMap(CONSTANT_POOL_ARRAY_TYPE, kVariableSizeSentinel); |
| 2625 if (!maybe_obj->ToObject(&obj)) return false; |
| 2626 } |
| 2627 set_constant_pool_array_map(Map::cast(obj)); |
| 2628 |
| 2623 // Allocate the empty array. | 2629 // Allocate the empty array. |
| 2624 { MaybeObject* maybe_obj = AllocateEmptyFixedArray(); | 2630 { MaybeObject* maybe_obj = AllocateEmptyFixedArray(); |
| 2625 if (!maybe_obj->ToObject(&obj)) return false; | 2631 if (!maybe_obj->ToObject(&obj)) return false; |
| 2626 } | 2632 } |
| 2627 set_empty_fixed_array(FixedArray::cast(obj)); | 2633 set_empty_fixed_array(FixedArray::cast(obj)); |
| 2628 | 2634 |
| 2629 { MaybeObject* maybe_obj = Allocate(oddball_map(), OLD_POINTER_SPACE); | 2635 { MaybeObject* maybe_obj = Allocate(oddball_map(), OLD_POINTER_SPACE); |
| 2630 if (!maybe_obj->ToObject(&obj)) return false; | 2636 if (!maybe_obj->ToObject(&obj)) return false; |
| 2631 } | 2637 } |
| 2632 set_null_value(Oddball::cast(obj)); | 2638 set_null_value(Oddball::cast(obj)); |
| 2633 Oddball::cast(obj)->set_kind(Oddball::kNull); | 2639 Oddball::cast(obj)->set_kind(Oddball::kNull); |
| 2634 | 2640 |
| 2635 { MaybeObject* maybe_obj = Allocate(oddball_map(), OLD_POINTER_SPACE); | 2641 { MaybeObject* maybe_obj = Allocate(oddball_map(), OLD_POINTER_SPACE); |
| 2636 if (!maybe_obj->ToObject(&obj)) return false; | 2642 if (!maybe_obj->ToObject(&obj)) return false; |
| 2637 } | 2643 } |
| 2638 set_undefined_value(Oddball::cast(obj)); | 2644 set_undefined_value(Oddball::cast(obj)); |
| 2639 Oddball::cast(obj)->set_kind(Oddball::kUndefined); | 2645 Oddball::cast(obj)->set_kind(Oddball::kUndefined); |
| 2640 ASSERT(!InNewSpace(undefined_value())); | 2646 ASSERT(!InNewSpace(undefined_value())); |
| 2641 | 2647 |
| 2642 // Allocate the empty descriptor array. | 2648 // Allocate the empty descriptor array. |
| 2643 { MaybeObject* maybe_obj = AllocateEmptyFixedArray(); | 2649 { MaybeObject* maybe_obj = AllocateEmptyFixedArray(); |
| 2644 if (!maybe_obj->ToObject(&obj)) return false; | 2650 if (!maybe_obj->ToObject(&obj)) return false; |
| 2645 } | 2651 } |
| 2646 set_empty_descriptor_array(DescriptorArray::cast(obj)); | 2652 set_empty_descriptor_array(DescriptorArray::cast(obj)); |
| 2647 | 2653 |
| 2654 // Allocate the constant pool array. |
| 2655 { MaybeObject* maybe_obj = AllocateEmptyConstantPoolArray(); |
| 2656 if (!maybe_obj->ToObject(&obj)) return false; |
| 2657 } |
| 2658 set_empty_constant_pool_array(ConstantPoolArray::cast(obj)); |
| 2659 |
| 2648 // Fix the instance_descriptors for the existing maps. | 2660 // Fix the instance_descriptors for the existing maps. |
| 2649 meta_map()->set_code_cache(empty_fixed_array()); | 2661 meta_map()->set_code_cache(empty_fixed_array()); |
| 2650 meta_map()->set_dependent_code(DependentCode::cast(empty_fixed_array())); | 2662 meta_map()->set_dependent_code(DependentCode::cast(empty_fixed_array())); |
| 2651 meta_map()->init_back_pointer(undefined_value()); | 2663 meta_map()->init_back_pointer(undefined_value()); |
| 2652 meta_map()->set_instance_descriptors(empty_descriptor_array()); | 2664 meta_map()->set_instance_descriptors(empty_descriptor_array()); |
| 2653 | 2665 |
| 2654 fixed_array_map()->set_code_cache(empty_fixed_array()); | 2666 fixed_array_map()->set_code_cache(empty_fixed_array()); |
| 2655 fixed_array_map()->set_dependent_code( | 2667 fixed_array_map()->set_dependent_code( |
| 2656 DependentCode::cast(empty_fixed_array())); | 2668 DependentCode::cast(empty_fixed_array())); |
| 2657 fixed_array_map()->init_back_pointer(undefined_value()); | 2669 fixed_array_map()->init_back_pointer(undefined_value()); |
| 2658 fixed_array_map()->set_instance_descriptors(empty_descriptor_array()); | 2670 fixed_array_map()->set_instance_descriptors(empty_descriptor_array()); |
| 2659 | 2671 |
| 2660 oddball_map()->set_code_cache(empty_fixed_array()); | 2672 oddball_map()->set_code_cache(empty_fixed_array()); |
| 2661 oddball_map()->set_dependent_code(DependentCode::cast(empty_fixed_array())); | 2673 oddball_map()->set_dependent_code(DependentCode::cast(empty_fixed_array())); |
| 2662 oddball_map()->init_back_pointer(undefined_value()); | 2674 oddball_map()->init_back_pointer(undefined_value()); |
| 2663 oddball_map()->set_instance_descriptors(empty_descriptor_array()); | 2675 oddball_map()->set_instance_descriptors(empty_descriptor_array()); |
| 2664 | 2676 |
| 2677 constant_pool_array_map()->set_code_cache(empty_fixed_array()); |
| 2678 constant_pool_array_map()->set_dependent_code( |
| 2679 DependentCode::cast(empty_fixed_array())); |
| 2680 constant_pool_array_map()->init_back_pointer(undefined_value()); |
| 2681 constant_pool_array_map()->set_instance_descriptors(empty_descriptor_array()); |
| 2682 |
| 2665 // Fix prototype object for existing maps. | 2683 // Fix prototype object for existing maps. |
| 2666 meta_map()->set_prototype(null_value()); | 2684 meta_map()->set_prototype(null_value()); |
| 2667 meta_map()->set_constructor(null_value()); | 2685 meta_map()->set_constructor(null_value()); |
| 2668 | 2686 |
| 2669 fixed_array_map()->set_prototype(null_value()); | 2687 fixed_array_map()->set_prototype(null_value()); |
| 2670 fixed_array_map()->set_constructor(null_value()); | 2688 fixed_array_map()->set_constructor(null_value()); |
| 2671 | 2689 |
| 2672 oddball_map()->set_prototype(null_value()); | 2690 oddball_map()->set_prototype(null_value()); |
| 2673 oddball_map()->set_constructor(null_value()); | 2691 oddball_map()->set_constructor(null_value()); |
| 2674 | 2692 |
| 2693 constant_pool_array_map()->set_prototype(null_value()); |
| 2694 constant_pool_array_map()->set_constructor(null_value()); |
| 2695 |
| 2675 { MaybeObject* maybe_obj = | 2696 { MaybeObject* maybe_obj = |
| 2676 AllocateMap(FIXED_ARRAY_TYPE, kVariableSizeSentinel); | 2697 AllocateMap(FIXED_ARRAY_TYPE, kVariableSizeSentinel); |
| 2677 if (!maybe_obj->ToObject(&obj)) return false; | 2698 if (!maybe_obj->ToObject(&obj)) return false; |
| 2678 } | 2699 } |
| 2679 set_fixed_cow_array_map(Map::cast(obj)); | 2700 set_fixed_cow_array_map(Map::cast(obj)); |
| 2680 ASSERT(fixed_array_map() != fixed_cow_array_map()); | 2701 ASSERT(fixed_array_map() != fixed_cow_array_map()); |
| 2681 | 2702 |
| 2682 { MaybeObject* maybe_obj = | 2703 { MaybeObject* maybe_obj = |
| 2683 AllocateMap(FIXED_ARRAY_TYPE, kVariableSizeSentinel); | 2704 AllocateMap(FIXED_ARRAY_TYPE, kVariableSizeSentinel); |
| 2684 if (!maybe_obj->ToObject(&obj)) return false; | 2705 if (!maybe_obj->ToObject(&obj)) return false; |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2721 set_undetectable_ascii_string_map(Map::cast(obj)); | 2742 set_undetectable_ascii_string_map(Map::cast(obj)); |
| 2722 Map::cast(obj)->set_is_undetectable(); | 2743 Map::cast(obj)->set_is_undetectable(); |
| 2723 | 2744 |
| 2724 { MaybeObject* maybe_obj = | 2745 { MaybeObject* maybe_obj = |
| 2725 AllocateMap(FIXED_DOUBLE_ARRAY_TYPE, kVariableSizeSentinel); | 2746 AllocateMap(FIXED_DOUBLE_ARRAY_TYPE, kVariableSizeSentinel); |
| 2726 if (!maybe_obj->ToObject(&obj)) return false; | 2747 if (!maybe_obj->ToObject(&obj)) return false; |
| 2727 } | 2748 } |
| 2728 set_fixed_double_array_map(Map::cast(obj)); | 2749 set_fixed_double_array_map(Map::cast(obj)); |
| 2729 | 2750 |
| 2730 { MaybeObject* maybe_obj = | 2751 { MaybeObject* maybe_obj = |
| 2731 AllocateMap(CONSTANT_POOL_ARRAY_TYPE, kVariableSizeSentinel); | |
| 2732 if (!maybe_obj->ToObject(&obj)) return false; | |
| 2733 } | |
| 2734 set_constant_pool_array_map(Map::cast(obj)); | |
| 2735 | |
| 2736 { MaybeObject* maybe_obj = | |
| 2737 AllocateMap(BYTE_ARRAY_TYPE, kVariableSizeSentinel); | 2752 AllocateMap(BYTE_ARRAY_TYPE, kVariableSizeSentinel); |
| 2738 if (!maybe_obj->ToObject(&obj)) return false; | 2753 if (!maybe_obj->ToObject(&obj)) return false; |
| 2739 } | 2754 } |
| 2740 set_byte_array_map(Map::cast(obj)); | 2755 set_byte_array_map(Map::cast(obj)); |
| 2741 | 2756 |
| 2742 { MaybeObject* maybe_obj = | 2757 { MaybeObject* maybe_obj = |
| 2743 AllocateMap(FREE_SPACE_TYPE, kVariableSizeSentinel); | 2758 AllocateMap(FREE_SPACE_TYPE, kVariableSizeSentinel); |
| 2744 if (!maybe_obj->ToObject(&obj)) return false; | 2759 if (!maybe_obj->ToObject(&obj)) return false; |
| 2745 } | 2760 } |
| 2746 set_free_space_map(Map::cast(obj)); | 2761 set_free_space_map(Map::cast(obj)); |
| (...skipping 1653 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4400 void Heap::InitializeFunction(JSFunction* function, | 4415 void Heap::InitializeFunction(JSFunction* function, |
| 4401 SharedFunctionInfo* shared, | 4416 SharedFunctionInfo* shared, |
| 4402 Object* prototype) { | 4417 Object* prototype) { |
| 4403 ASSERT(!prototype->IsMap()); | 4418 ASSERT(!prototype->IsMap()); |
| 4404 function->initialize_properties(); | 4419 function->initialize_properties(); |
| 4405 function->initialize_elements(); | 4420 function->initialize_elements(); |
| 4406 function->set_shared(shared); | 4421 function->set_shared(shared); |
| 4407 function->set_code(shared->code()); | 4422 function->set_code(shared->code()); |
| 4408 function->set_prototype_or_initial_map(prototype); | 4423 function->set_prototype_or_initial_map(prototype); |
| 4409 function->set_context(undefined_value()); | 4424 function->set_context(undefined_value()); |
| 4425 function->set_constant_pool(empty_constant_pool_array()); |
| 4410 function->set_literals_or_bindings(empty_fixed_array()); | 4426 function->set_literals_or_bindings(empty_fixed_array()); |
| 4411 function->set_next_function_link(undefined_value()); | 4427 function->set_next_function_link(undefined_value()); |
| 4412 } | 4428 } |
| 4413 | 4429 |
| 4414 | 4430 |
| 4415 MaybeObject* Heap::AllocateFunction(Map* function_map, | 4431 MaybeObject* Heap::AllocateFunction(Map* function_map, |
| 4416 SharedFunctionInfo* shared, | 4432 SharedFunctionInfo* shared, |
| 4417 Object* prototype, | 4433 Object* prototype, |
| 4418 PretenureFlag pretenure) { | 4434 PretenureFlag pretenure) { |
| 4419 AllocationSpace space = | 4435 AllocationSpace space = |
| (...skipping 1057 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5477 if (!maybe_object->To<HeapObject>(&object)) return maybe_object; | 5493 if (!maybe_object->To<HeapObject>(&object)) return maybe_object; |
| 5478 } | 5494 } |
| 5479 object = EnsureDoubleAligned(this, object, size); | 5495 object = EnsureDoubleAligned(this, object, size); |
| 5480 HeapObject::cast(object)->set_map_no_write_barrier(constant_pool_array_map()); | 5496 HeapObject::cast(object)->set_map_no_write_barrier(constant_pool_array_map()); |
| 5481 | 5497 |
| 5482 ConstantPoolArray* constant_pool = | 5498 ConstantPoolArray* constant_pool = |
| 5483 reinterpret_cast<ConstantPoolArray*>(object); | 5499 reinterpret_cast<ConstantPoolArray*>(object); |
| 5484 constant_pool->SetEntryCounts(number_of_int64_entries, | 5500 constant_pool->SetEntryCounts(number_of_int64_entries, |
| 5485 number_of_ptr_entries, | 5501 number_of_ptr_entries, |
| 5486 number_of_int32_entries); | 5502 number_of_int32_entries); |
| 5487 MemsetPointer( | 5503 if (number_of_ptr_entries > 0) { |
| 5488 HeapObject::RawField( | 5504 MemsetPointer( |
| 5489 constant_pool, | 5505 HeapObject::RawField( |
| 5490 constant_pool->OffsetOfElementAt(constant_pool->first_ptr_index())), | 5506 constant_pool, |
| 5491 undefined_value(), | 5507 constant_pool->OffsetOfElementAt(constant_pool->first_ptr_index())), |
| 5492 number_of_ptr_entries); | 5508 undefined_value(), |
| 5509 number_of_ptr_entries); |
| 5510 } |
| 5493 return constant_pool; | 5511 return constant_pool; |
| 5494 } | 5512 } |
| 5495 | 5513 |
| 5496 | 5514 |
| 5515 MaybeObject* Heap::AllocateEmptyConstantPoolArray() { |
| 5516 int size = ConstantPoolArray::SizeFor(0, 0, 0); |
| 5517 Object* result; |
| 5518 { MaybeObject* maybe_result = |
| 5519 AllocateRaw(size, OLD_DATA_SPACE, OLD_DATA_SPACE); |
| 5520 if (!maybe_result->ToObject(&result)) return maybe_result; |
| 5521 } |
| 5522 HeapObject::cast(result)->set_map_no_write_barrier(constant_pool_array_map()); |
| 5523 ConstantPoolArray::cast(result)->SetEntryCounts(0, 0, 0); |
| 5524 return result; |
| 5525 } |
| 5526 |
| 5527 |
| 5497 MaybeObject* Heap::AllocateHashTable(int length, PretenureFlag pretenure) { | 5528 MaybeObject* Heap::AllocateHashTable(int length, PretenureFlag pretenure) { |
| 5498 Object* result; | 5529 Object* result; |
| 5499 { MaybeObject* maybe_result = AllocateFixedArray(length, pretenure); | 5530 { MaybeObject* maybe_result = AllocateFixedArray(length, pretenure); |
| 5500 if (!maybe_result->ToObject(&result)) return maybe_result; | 5531 if (!maybe_result->ToObject(&result)) return maybe_result; |
| 5501 } | 5532 } |
| 5502 reinterpret_cast<HeapObject*>(result)->set_map_no_write_barrier( | 5533 reinterpret_cast<HeapObject*>(result)->set_map_no_write_barrier( |
| 5503 hash_table_map()); | 5534 hash_table_map()); |
| 5504 ASSERT(result->IsHashTable()); | 5535 ASSERT(result->IsHashTable()); |
| 5505 return result; | 5536 return result; |
| 5506 } | 5537 } |
| (...skipping 2454 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7961 static_cast<int>(object_sizes_last_time_[index])); | 7992 static_cast<int>(object_sizes_last_time_[index])); |
| 7962 CODE_AGE_LIST_COMPLETE(ADJUST_LAST_TIME_OBJECT_COUNT) | 7993 CODE_AGE_LIST_COMPLETE(ADJUST_LAST_TIME_OBJECT_COUNT) |
| 7963 #undef ADJUST_LAST_TIME_OBJECT_COUNT | 7994 #undef ADJUST_LAST_TIME_OBJECT_COUNT |
| 7964 | 7995 |
| 7965 OS::MemCopy(object_counts_last_time_, object_counts_, sizeof(object_counts_)); | 7996 OS::MemCopy(object_counts_last_time_, object_counts_, sizeof(object_counts_)); |
| 7966 OS::MemCopy(object_sizes_last_time_, object_sizes_, sizeof(object_sizes_)); | 7997 OS::MemCopy(object_sizes_last_time_, object_sizes_, sizeof(object_sizes_)); |
| 7967 ClearObjectStats(); | 7998 ClearObjectStats(); |
| 7968 } | 7999 } |
| 7969 | 8000 |
| 7970 } } // namespace v8::internal | 8001 } } // namespace v8::internal |
| OLD | NEW |