OLD | NEW |
1 // Copyright 2010 the V8 project authors. All rights reserved. | 1 // Copyright 2010 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 2050 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2061 share->set_expected_nof_properties(0); | 2061 share->set_expected_nof_properties(0); |
2062 share->set_length(0); | 2062 share->set_length(0); |
2063 share->set_formal_parameter_count(0); | 2063 share->set_formal_parameter_count(0); |
2064 share->set_instance_class_name(Object_symbol()); | 2064 share->set_instance_class_name(Object_symbol()); |
2065 share->set_function_data(undefined_value()); | 2065 share->set_function_data(undefined_value()); |
2066 share->set_script(undefined_value()); | 2066 share->set_script(undefined_value()); |
2067 share->set_start_position_and_type(0); | 2067 share->set_start_position_and_type(0); |
2068 share->set_debug_info(undefined_value()); | 2068 share->set_debug_info(undefined_value()); |
2069 share->set_inferred_name(empty_string()); | 2069 share->set_inferred_name(empty_string()); |
2070 share->set_compiler_hints(0); | 2070 share->set_compiler_hints(0); |
| 2071 share->set_initial_map(undefined_value()); |
2071 share->set_this_property_assignments_count(0); | 2072 share->set_this_property_assignments_count(0); |
2072 share->set_this_property_assignments(undefined_value()); | 2073 share->set_this_property_assignments(undefined_value()); |
2073 share->set_num_literals(0); | 2074 share->set_num_literals(0); |
2074 share->set_end_position(0); | 2075 share->set_end_position(0); |
2075 share->set_function_token_position(0); | 2076 share->set_function_token_position(0); |
2076 return result; | 2077 return result; |
2077 } | 2078 } |
2078 | 2079 |
2079 | 2080 |
2080 // Returns true for a character in a range. Both limits are inclusive. | 2081 // Returns true for a character in a range. Both limits are inclusive. |
(...skipping 638 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2719 // duplicates in linear time. | 2720 // duplicates in linear time. |
2720 if (HasDuplicates(descriptors)) { | 2721 if (HasDuplicates(descriptors)) { |
2721 fun->shared()->ForbidInlineConstructor(); | 2722 fun->shared()->ForbidInlineConstructor(); |
2722 } else { | 2723 } else { |
2723 map->set_instance_descriptors(descriptors); | 2724 map->set_instance_descriptors(descriptors); |
2724 map->set_pre_allocated_property_fields(count); | 2725 map->set_pre_allocated_property_fields(count); |
2725 map->set_unused_property_fields(in_object_properties - count); | 2726 map->set_unused_property_fields(in_object_properties - count); |
2726 } | 2727 } |
2727 } | 2728 } |
2728 } | 2729 } |
| 2730 |
| 2731 fun->shared()->StartInobjectSlackTracking(map); |
| 2732 |
2729 return map; | 2733 return map; |
2730 } | 2734 } |
2731 | 2735 |
2732 | 2736 |
2733 void Heap::InitializeJSObjectFromMap(JSObject* obj, | 2737 void Heap::InitializeJSObjectFromMap(JSObject* obj, |
2734 FixedArray* properties, | 2738 FixedArray* properties, |
2735 Map* map) { | 2739 Map* map) { |
2736 obj->set_properties(properties); | 2740 obj->set_properties(properties); |
2737 obj->initialize_elements(); | 2741 obj->initialize_elements(); |
2738 // TODO(1240798): Initialize the object's body using valid initial values | 2742 // TODO(1240798): Initialize the object's body using valid initial values |
2739 // according to the object's initial map. For example, if the map's | 2743 // according to the object's initial map. For example, if the map's |
2740 // instance type is JS_ARRAY_TYPE, the length field should be initialized | 2744 // instance type is JS_ARRAY_TYPE, the length field should be initialized |
2741 // to a number (eg, Smi::FromInt(0)) and the elements initialized to a | 2745 // to a number (eg, Smi::FromInt(0)) and the elements initialized to a |
2742 // fixed array (eg, Heap::empty_fixed_array()). Currently, the object | 2746 // fixed array (eg, Heap::empty_fixed_array()). Currently, the object |
2743 // verification code has to cope with (temporarily) invalid objects. See | 2747 // verification code has to cope with (temporarily) invalid objects. See |
2744 // for example, JSArray::JSArrayVerify). | 2748 // for example, JSArray::JSArrayVerify). |
2745 obj->InitializeBody(map->instance_size()); | 2749 Object* filler; |
| 2750 // We cannot always fill with one_pointer_filler_map because objects |
| 2751 // created from API functions expect their internal fields to be initialized |
| 2752 // with undefined_value. |
| 2753 if (map->constructor()->IsJSFunction() && |
| 2754 JSFunction::cast(map->constructor())->shared()-> |
| 2755 IsInobjectSlackTrackingInProgress()) { |
| 2756 // We might want to shrink the object later. |
| 2757 ASSERT(obj->GetInternalFieldCount() == 0); |
| 2758 filler = Heap::one_pointer_filler_map(); |
| 2759 } else { |
| 2760 filler = Heap::undefined_value(); |
| 2761 } |
| 2762 obj->InitializeBody(map->instance_size(), filler); |
2746 } | 2763 } |
2747 | 2764 |
2748 | 2765 |
2749 Object* Heap::AllocateJSObjectFromMap(Map* map, PretenureFlag pretenure) { | 2766 Object* Heap::AllocateJSObjectFromMap(Map* map, PretenureFlag pretenure) { |
2750 // JSFunctions should be allocated using AllocateFunction to be | 2767 // JSFunctions should be allocated using AllocateFunction to be |
2751 // properly initialized. | 2768 // properly initialized. |
2752 ASSERT(map->instance_type() != JS_FUNCTION_TYPE); | 2769 ASSERT(map->instance_type() != JS_FUNCTION_TYPE); |
2753 | 2770 |
2754 // Both types of global objects should be allocated using | 2771 // Both types of global objects should be allocated using |
2755 // AllocateGlobalObject to be properly initialized. | 2772 // AllocateGlobalObject to be properly initialized. |
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2918 // Return the new clone. | 2935 // Return the new clone. |
2919 #ifdef ENABLE_LOGGING_AND_PROFILING | 2936 #ifdef ENABLE_LOGGING_AND_PROFILING |
2920 ProducerHeapProfile::RecordJSObjectAllocation(clone); | 2937 ProducerHeapProfile::RecordJSObjectAllocation(clone); |
2921 #endif | 2938 #endif |
2922 return clone; | 2939 return clone; |
2923 } | 2940 } |
2924 | 2941 |
2925 | 2942 |
2926 Object* Heap::ReinitializeJSGlobalProxy(JSFunction* constructor, | 2943 Object* Heap::ReinitializeJSGlobalProxy(JSFunction* constructor, |
2927 JSGlobalProxy* object) { | 2944 JSGlobalProxy* object) { |
2928 // Allocate initial map if absent. | 2945 ASSERT(constructor->has_initial_map()); |
2929 if (!constructor->has_initial_map()) { | |
2930 Object* initial_map = AllocateInitialMap(constructor); | |
2931 if (initial_map->IsFailure()) return initial_map; | |
2932 constructor->set_initial_map(Map::cast(initial_map)); | |
2933 Map::cast(initial_map)->set_constructor(constructor); | |
2934 } | |
2935 | |
2936 Map* map = constructor->initial_map(); | 2946 Map* map = constructor->initial_map(); |
2937 | 2947 |
2938 // Check that the already allocated object has the same size as | 2948 // Check that the already allocated object has the same size and type as |
2939 // objects allocated using the constructor. | 2949 // objects allocated using the constructor. |
2940 ASSERT(map->instance_size() == object->map()->instance_size()); | 2950 ASSERT(map->instance_size() == object->map()->instance_size()); |
| 2951 ASSERT(map->instance_type() == object->map()->instance_type()); |
2941 | 2952 |
2942 // Allocate the backing storage for the properties. | 2953 // Allocate the backing storage for the properties. |
2943 int prop_size = map->unused_property_fields() - map->inobject_properties(); | 2954 int prop_size = map->unused_property_fields() - map->inobject_properties(); |
2944 Object* properties = AllocateFixedArray(prop_size, TENURED); | 2955 Object* properties = AllocateFixedArray(prop_size, TENURED); |
2945 if (properties->IsFailure()) return properties; | 2956 if (properties->IsFailure()) return properties; |
2946 | 2957 |
2947 // Reset the map for the object. | 2958 // Reset the map for the object. |
2948 object->set_map(constructor->initial_map()); | 2959 object->set_map(constructor->initial_map()); |
2949 | 2960 |
2950 // Reinitialize the object from the constructor map. | 2961 // Reinitialize the object from the constructor map. |
(...skipping 2003 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4954 void ExternalStringTable::TearDown() { | 4965 void ExternalStringTable::TearDown() { |
4955 new_space_strings_.Free(); | 4966 new_space_strings_.Free(); |
4956 old_space_strings_.Free(); | 4967 old_space_strings_.Free(); |
4957 } | 4968 } |
4958 | 4969 |
4959 | 4970 |
4960 List<Object*> ExternalStringTable::new_space_strings_; | 4971 List<Object*> ExternalStringTable::new_space_strings_; |
4961 List<Object*> ExternalStringTable::old_space_strings_; | 4972 List<Object*> ExternalStringTable::old_space_strings_; |
4962 | 4973 |
4963 } } // namespace v8::internal | 4974 } } // namespace v8::internal |
OLD | NEW |