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 1375 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1386 scavenge_visitor.VisitPointer(reinterpret_cast<Object**>(value_address)); | 1386 scavenge_visitor.VisitPointer(reinterpret_cast<Object**>(value_address)); |
1387 } | 1387 } |
1388 } | 1388 } |
1389 | 1389 |
1390 // Copy objects reachable from global property cells by scavenging global | 1390 // Copy objects reachable from global property cells by scavenging global |
1391 // property cell values directly. | 1391 // property cell values directly. |
1392 HeapObjectIterator js_global_property_cell_iterator(property_cell_space_); | 1392 HeapObjectIterator js_global_property_cell_iterator(property_cell_space_); |
1393 for (HeapObject* heap_object = js_global_property_cell_iterator.Next(); | 1393 for (HeapObject* heap_object = js_global_property_cell_iterator.Next(); |
1394 heap_object != NULL; | 1394 heap_object != NULL; |
1395 heap_object = js_global_property_cell_iterator.Next()) { | 1395 heap_object = js_global_property_cell_iterator.Next()) { |
1396 if (heap_object->IsJSGlobalPropertyCell()) { | 1396 if (heap_object->IsPropertyCell()) { |
1397 JSGlobalPropertyCell* cell = JSGlobalPropertyCell::cast(heap_object); | 1397 PropertyCell* cell = PropertyCell::cast(heap_object); |
1398 Address value_address = cell->ValueAddress(); | 1398 Address value_address = cell->ValueAddress(); |
1399 scavenge_visitor.VisitPointer(reinterpret_cast<Object**>(value_address)); | 1399 scavenge_visitor.VisitPointer(reinterpret_cast<Object**>(value_address)); |
1400 Address type_address = cell->TypeAddress(); | 1400 Address type_address = cell->TypeAddress(); |
1401 scavenge_visitor.VisitPointer(reinterpret_cast<Object**>(type_address)); | 1401 scavenge_visitor.VisitPointer(reinterpret_cast<Object**>(type_address)); |
1402 } | 1402 } |
1403 } | 1403 } |
1404 | 1404 |
1405 // Copy objects reachable from the code flushing candidates list. | 1405 // Copy objects reachable from the code flushing candidates list. |
1406 MarkCompactCollector* collector = mark_compact_collector(); | 1406 MarkCompactCollector* collector = mark_compact_collector(); |
1407 if (collector->is_code_flushing_enabled()) { | 1407 if (collector->is_code_flushing_enabled()) { |
(...skipping 1262 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2670 if (!maybe_obj->ToObject(&obj)) return false; | 2670 if (!maybe_obj->ToObject(&obj)) return false; |
2671 } | 2671 } |
2672 set_code_map(Map::cast(obj)); | 2672 set_code_map(Map::cast(obj)); |
2673 | 2673 |
2674 { MaybeObject* maybe_obj = AllocateMap(CELL_TYPE, Cell::kSize); | 2674 { MaybeObject* maybe_obj = AllocateMap(CELL_TYPE, Cell::kSize); |
2675 if (!maybe_obj->ToObject(&obj)) return false; | 2675 if (!maybe_obj->ToObject(&obj)) return false; |
2676 } | 2676 } |
2677 set_cell_map(Map::cast(obj)); | 2677 set_cell_map(Map::cast(obj)); |
2678 | 2678 |
2679 { MaybeObject* maybe_obj = AllocateMap(PROPERTY_CELL_TYPE, | 2679 { MaybeObject* maybe_obj = AllocateMap(PROPERTY_CELL_TYPE, |
2680 JSGlobalPropertyCell::kSize); | 2680 PropertyCell::kSize); |
2681 if (!maybe_obj->ToObject(&obj)) return false; | 2681 if (!maybe_obj->ToObject(&obj)) return false; |
2682 } | 2682 } |
2683 set_global_property_cell_map(Map::cast(obj)); | 2683 set_global_property_cell_map(Map::cast(obj)); |
2684 | 2684 |
2685 { MaybeObject* maybe_obj = AllocateMap(FILLER_TYPE, kPointerSize); | 2685 { MaybeObject* maybe_obj = AllocateMap(FILLER_TYPE, kPointerSize); |
2686 if (!maybe_obj->ToObject(&obj)) return false; | 2686 if (!maybe_obj->ToObject(&obj)) return false; |
2687 } | 2687 } |
2688 set_one_pointer_filler_map(Map::cast(obj)); | 2688 set_one_pointer_filler_map(Map::cast(obj)); |
2689 | 2689 |
2690 { MaybeObject* maybe_obj = AllocateMap(FILLER_TYPE, 2 * kPointerSize); | 2690 { MaybeObject* maybe_obj = AllocateMap(FILLER_TYPE, 2 * kPointerSize); |
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2815 Object* result; | 2815 Object* result; |
2816 { MaybeObject* maybe_result = AllocateRawCell(); | 2816 { MaybeObject* maybe_result = AllocateRawCell(); |
2817 if (!maybe_result->ToObject(&result)) return maybe_result; | 2817 if (!maybe_result->ToObject(&result)) return maybe_result; |
2818 } | 2818 } |
2819 HeapObject::cast(result)->set_map_no_write_barrier(cell_map()); | 2819 HeapObject::cast(result)->set_map_no_write_barrier(cell_map()); |
2820 Cell::cast(result)->set_value(value); | 2820 Cell::cast(result)->set_value(value); |
2821 return result; | 2821 return result; |
2822 } | 2822 } |
2823 | 2823 |
2824 | 2824 |
2825 MaybeObject* Heap::AllocateJSGlobalPropertyCell(Object* value) { | 2825 MaybeObject* Heap::AllocatePropertyCell(Object* value) { |
2826 Object* result; | 2826 Object* result; |
2827 { MaybeObject* maybe_result = AllocateRawJSGlobalPropertyCell(); | 2827 { MaybeObject* maybe_result = AllocateRawPropertyCell(); |
2828 if (!maybe_result->ToObject(&result)) return maybe_result; | 2828 if (!maybe_result->ToObject(&result)) return maybe_result; |
2829 } | 2829 } |
2830 HeapObject::cast(result)->set_map_no_write_barrier( | 2830 HeapObject::cast(result)->set_map_no_write_barrier( |
2831 global_property_cell_map()); | 2831 global_property_cell_map()); |
2832 JSGlobalPropertyCell::cast(result)->set_value(value); | 2832 PropertyCell::cast(result)->set_value(value); |
2833 JSGlobalPropertyCell::cast(result)->set_type(Type::None()); | 2833 PropertyCell::cast(result)->set_type(Type::None()); |
2834 return result; | 2834 return result; |
2835 } | 2835 } |
2836 | 2836 |
2837 | 2837 |
2838 MaybeObject* Heap::AllocateBox(Object* value, PretenureFlag pretenure) { | 2838 MaybeObject* Heap::AllocateBox(Object* value, PretenureFlag pretenure) { |
2839 Box* result; | 2839 Box* result; |
2840 MaybeObject* maybe_result = AllocateStruct(BOX_TYPE); | 2840 MaybeObject* maybe_result = AllocateStruct(BOX_TYPE); |
2841 if (!maybe_result->To(&result)) return maybe_result; | 2841 if (!maybe_result->To(&result)) return maybe_result; |
2842 result->set_value(value); | 2842 result->set_value(value); |
2843 return result; | 2843 return result; |
(...skipping 1872 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4716 } | 4716 } |
4717 | 4717 |
4718 | 4718 |
4719 MaybeObject* Heap::AllocateGlobalObject(JSFunction* constructor) { | 4719 MaybeObject* Heap::AllocateGlobalObject(JSFunction* constructor) { |
4720 ASSERT(constructor->has_initial_map()); | 4720 ASSERT(constructor->has_initial_map()); |
4721 Map* map = constructor->initial_map(); | 4721 Map* map = constructor->initial_map(); |
4722 ASSERT(map->is_dictionary_map()); | 4722 ASSERT(map->is_dictionary_map()); |
4723 | 4723 |
4724 // Make sure no field properties are described in the initial map. | 4724 // Make sure no field properties are described in the initial map. |
4725 // This guarantees us that normalizing the properties does not | 4725 // This guarantees us that normalizing the properties does not |
4726 // require us to change property values to JSGlobalPropertyCells. | 4726 // require us to change property values to PropertyCells. |
4727 ASSERT(map->NextFreePropertyIndex() == 0); | 4727 ASSERT(map->NextFreePropertyIndex() == 0); |
4728 | 4728 |
4729 // Make sure we don't have a ton of pre-allocated slots in the | 4729 // Make sure we don't have a ton of pre-allocated slots in the |
4730 // global objects. They will be unused once we normalize the object. | 4730 // global objects. They will be unused once we normalize the object. |
4731 ASSERT(map->unused_property_fields() == 0); | 4731 ASSERT(map->unused_property_fields() == 0); |
4732 ASSERT(map->inobject_properties() == 0); | 4732 ASSERT(map->inobject_properties() == 0); |
4733 | 4733 |
4734 // Initial size of the backing store to avoid resize of the storage during | 4734 // Initial size of the backing store to avoid resize of the storage during |
4735 // bootstrapping. The size differs between the JS global object ad the | 4735 // bootstrapping. The size differs between the JS global object ad the |
4736 // builtins object. | 4736 // builtins object. |
4737 int initial_size = map->instance_type() == JS_GLOBAL_OBJECT_TYPE ? 64 : 512; | 4737 int initial_size = map->instance_type() == JS_GLOBAL_OBJECT_TYPE ? 64 : 512; |
4738 | 4738 |
4739 // Allocate a dictionary object for backing storage. | 4739 // Allocate a dictionary object for backing storage. |
4740 NameDictionary* dictionary; | 4740 NameDictionary* dictionary; |
4741 MaybeObject* maybe_dictionary = | 4741 MaybeObject* maybe_dictionary = |
4742 NameDictionary::Allocate( | 4742 NameDictionary::Allocate( |
4743 this, | 4743 this, |
4744 map->NumberOfOwnDescriptors() * 2 + initial_size); | 4744 map->NumberOfOwnDescriptors() * 2 + initial_size); |
4745 if (!maybe_dictionary->To(&dictionary)) return maybe_dictionary; | 4745 if (!maybe_dictionary->To(&dictionary)) return maybe_dictionary; |
4746 | 4746 |
4747 // The global object might be created from an object template with accessors. | 4747 // The global object might be created from an object template with accessors. |
4748 // Fill these accessors into the dictionary. | 4748 // Fill these accessors into the dictionary. |
4749 DescriptorArray* descs = map->instance_descriptors(); | 4749 DescriptorArray* descs = map->instance_descriptors(); |
4750 for (int i = 0; i < map->NumberOfOwnDescriptors(); i++) { | 4750 for (int i = 0; i < map->NumberOfOwnDescriptors(); i++) { |
4751 PropertyDetails details = descs->GetDetails(i); | 4751 PropertyDetails details = descs->GetDetails(i); |
4752 ASSERT(details.type() == CALLBACKS); // Only accessors are expected. | 4752 ASSERT(details.type() == CALLBACKS); // Only accessors are expected. |
4753 PropertyDetails d = PropertyDetails(details.attributes(), CALLBACKS, i + 1); | 4753 PropertyDetails d = PropertyDetails(details.attributes(), CALLBACKS, i + 1); |
4754 Object* value = descs->GetCallbacksObject(i); | 4754 Object* value = descs->GetCallbacksObject(i); |
4755 MaybeObject* maybe_value = AllocateJSGlobalPropertyCell(value); | 4755 MaybeObject* maybe_value = AllocatePropertyCell(value); |
4756 if (!maybe_value->ToObject(&value)) return maybe_value; | 4756 if (!maybe_value->ToObject(&value)) return maybe_value; |
4757 | 4757 |
4758 MaybeObject* maybe_added = dictionary->Add(descs->GetKey(i), value, d); | 4758 MaybeObject* maybe_added = dictionary->Add(descs->GetKey(i), value, d); |
4759 if (!maybe_added->To(&dictionary)) return maybe_added; | 4759 if (!maybe_added->To(&dictionary)) return maybe_added; |
4760 } | 4760 } |
4761 | 4761 |
4762 // Allocate the global object and initialize it with the backing store. | 4762 // Allocate the global object and initialize it with the backing store. |
4763 JSObject* global; | 4763 JSObject* global; |
4764 MaybeObject* maybe_global = Allocate(map, OLD_POINTER_SPACE); | 4764 MaybeObject* maybe_global = Allocate(map, OLD_POINTER_SPACE); |
4765 if (!maybe_global->To(&global)) return maybe_global; | 4765 if (!maybe_global->To(&global)) return maybe_global; |
(...skipping 1303 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6069 PrintF("Old pointer space : "); | 6069 PrintF("Old pointer space : "); |
6070 old_pointer_space_->ReportStatistics(); | 6070 old_pointer_space_->ReportStatistics(); |
6071 PrintF("Old data space : "); | 6071 PrintF("Old data space : "); |
6072 old_data_space_->ReportStatistics(); | 6072 old_data_space_->ReportStatistics(); |
6073 PrintF("Code space : "); | 6073 PrintF("Code space : "); |
6074 code_space_->ReportStatistics(); | 6074 code_space_->ReportStatistics(); |
6075 PrintF("Map space : "); | 6075 PrintF("Map space : "); |
6076 map_space_->ReportStatistics(); | 6076 map_space_->ReportStatistics(); |
6077 PrintF("Cell space : "); | 6077 PrintF("Cell space : "); |
6078 cell_space_->ReportStatistics(); | 6078 cell_space_->ReportStatistics(); |
6079 PrintF("JSGlobalPropertyCell space : "); | 6079 PrintF("PropertyCell space : "); |
6080 property_cell_space_->ReportStatistics(); | 6080 property_cell_space_->ReportStatistics(); |
6081 PrintF("Large object space : "); | 6081 PrintF("Large object space : "); |
6082 lo_space_->ReportStatistics(); | 6082 lo_space_->ReportStatistics(); |
6083 PrintF(">>>>>> ========================================= >>>>>>\n"); | 6083 PrintF(">>>>>> ========================================= >>>>>>\n"); |
6084 } | 6084 } |
6085 | 6085 |
6086 #endif // DEBUG | 6086 #endif // DEBUG |
6087 | 6087 |
6088 bool Heap::Contains(HeapObject* value) { | 6088 bool Heap::Contains(HeapObject* value) { |
6089 return Contains(value->address()); | 6089 return Contains(value->address()); |
(...skipping 1978 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8068 if (FLAG_parallel_recompilation) { | 8068 if (FLAG_parallel_recompilation) { |
8069 heap_->relocation_mutex_->Lock(); | 8069 heap_->relocation_mutex_->Lock(); |
8070 #ifdef DEBUG | 8070 #ifdef DEBUG |
8071 heap_->relocation_mutex_locked_by_optimizer_thread_ = | 8071 heap_->relocation_mutex_locked_by_optimizer_thread_ = |
8072 heap_->isolate()->optimizing_compiler_thread()->IsOptimizerThread(); | 8072 heap_->isolate()->optimizing_compiler_thread()->IsOptimizerThread(); |
8073 #endif // DEBUG | 8073 #endif // DEBUG |
8074 } | 8074 } |
8075 } | 8075 } |
8076 | 8076 |
8077 } } // namespace v8::internal | 8077 } } // namespace v8::internal |
OLD | NEW |