| 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 2032 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2043 MapWord first_word = object->map_word(); | 2043 MapWord first_word = object->map_word(); |
| 2044 SLOW_ASSERT(!first_word.IsForwardingAddress()); | 2044 SLOW_ASSERT(!first_word.IsForwardingAddress()); |
| 2045 Map* map = first_word.ToMap(); | 2045 Map* map = first_word.ToMap(); |
| 2046 map->GetHeap()->DoScavengeObject(map, p, object); | 2046 map->GetHeap()->DoScavengeObject(map, p, object); |
| 2047 } | 2047 } |
| 2048 | 2048 |
| 2049 | 2049 |
| 2050 MaybeObject* Heap::AllocatePartialMap(InstanceType instance_type, | 2050 MaybeObject* Heap::AllocatePartialMap(InstanceType instance_type, |
| 2051 int instance_size) { | 2051 int instance_size) { |
| 2052 Object* result; | 2052 Object* result; |
| 2053 { MaybeObject* maybe_result = AllocateRawMap(); | 2053 MaybeObject* maybe_result = AllocateRawMap(); |
| 2054 if (!maybe_result->ToObject(&result)) return maybe_result; | 2054 if (!maybe_result->ToObject(&result)) return maybe_result; |
| 2055 } | |
| 2056 | 2055 |
| 2057 // Map::cast cannot be used due to uninitialized map field. | 2056 // Map::cast cannot be used due to uninitialized map field. |
| 2058 reinterpret_cast<Map*>(result)->set_map(raw_unchecked_meta_map()); | 2057 reinterpret_cast<Map*>(result)->set_map(raw_unchecked_meta_map()); |
| 2059 reinterpret_cast<Map*>(result)->set_instance_type(instance_type); | 2058 reinterpret_cast<Map*>(result)->set_instance_type(instance_type); |
| 2060 reinterpret_cast<Map*>(result)->set_instance_size(instance_size); | 2059 reinterpret_cast<Map*>(result)->set_instance_size(instance_size); |
| 2061 reinterpret_cast<Map*>(result)->set_visitor_id( | 2060 reinterpret_cast<Map*>(result)->set_visitor_id( |
| 2062 StaticVisitorBase::GetVisitorId(instance_type, instance_size)); | 2061 StaticVisitorBase::GetVisitorId(instance_type, instance_size)); |
| 2063 reinterpret_cast<Map*>(result)->set_inobject_properties(0); | 2062 reinterpret_cast<Map*>(result)->set_inobject_properties(0); |
| 2064 reinterpret_cast<Map*>(result)->set_pre_allocated_property_fields(0); | 2063 reinterpret_cast<Map*>(result)->set_pre_allocated_property_fields(0); |
| 2065 reinterpret_cast<Map*>(result)->set_unused_property_fields(0); | 2064 reinterpret_cast<Map*>(result)->set_unused_property_fields(0); |
| 2066 reinterpret_cast<Map*>(result)->set_bit_field(0); | 2065 reinterpret_cast<Map*>(result)->set_bit_field(0); |
| 2067 reinterpret_cast<Map*>(result)->set_bit_field2(0); | 2066 reinterpret_cast<Map*>(result)->set_bit_field2(0); |
| 2068 reinterpret_cast<Map*>(result)->set_bit_field3( | 2067 reinterpret_cast<Map*>(result)->set_bit_field3(0); |
| 2069 Map::LastAddedBits::encode(Map::kNoneAdded)); | |
| 2070 return result; | 2068 return result; |
| 2071 } | 2069 } |
| 2072 | 2070 |
| 2073 | 2071 |
| 2074 MaybeObject* Heap::AllocateMap(InstanceType instance_type, | 2072 MaybeObject* Heap::AllocateMap(InstanceType instance_type, |
| 2075 int instance_size, | 2073 int instance_size, |
| 2076 ElementsKind elements_kind) { | 2074 ElementsKind elements_kind) { |
| 2077 Object* result; | 2075 Object* result; |
| 2078 MaybeObject* maybe_result = AllocateRawMap(); | 2076 MaybeObject* maybe_result = AllocateRawMap(); |
| 2079 if (!maybe_result->To(&result)) return maybe_result; | 2077 if (!maybe_result->To(&result)) return maybe_result; |
| 2080 | 2078 |
| 2081 Map* map = reinterpret_cast<Map*>(result); | 2079 Map* map = reinterpret_cast<Map*>(result); |
| 2082 map->set_map_no_write_barrier(meta_map()); | 2080 map->set_map_no_write_barrier(meta_map()); |
| 2083 map->set_instance_type(instance_type); | 2081 map->set_instance_type(instance_type); |
| 2084 map->set_visitor_id( | 2082 map->set_visitor_id( |
| 2085 StaticVisitorBase::GetVisitorId(instance_type, instance_size)); | 2083 StaticVisitorBase::GetVisitorId(instance_type, instance_size)); |
| 2086 map->set_prototype(null_value(), SKIP_WRITE_BARRIER); | 2084 map->set_prototype(null_value(), SKIP_WRITE_BARRIER); |
| 2087 map->set_constructor(null_value(), SKIP_WRITE_BARRIER); | 2085 map->set_constructor(null_value(), SKIP_WRITE_BARRIER); |
| 2088 map->set_instance_size(instance_size); | 2086 map->set_instance_size(instance_size); |
| 2089 map->set_inobject_properties(0); | 2087 map->set_inobject_properties(0); |
| 2090 map->set_pre_allocated_property_fields(0); | 2088 map->set_pre_allocated_property_fields(0); |
| 2091 map->set_code_cache(empty_fixed_array(), SKIP_WRITE_BARRIER); | 2089 map->set_code_cache(empty_fixed_array(), SKIP_WRITE_BARRIER); |
| 2092 map->init_back_pointer(undefined_value()); | 2090 map->init_back_pointer(undefined_value()); |
| 2093 map->set_unused_property_fields(0); | 2091 map->set_unused_property_fields(0); |
| 2094 map->set_bit_field(0); | 2092 map->set_bit_field(0); |
| 2095 map->set_bit_field2(1 << Map::kIsExtensible); | 2093 map->set_bit_field2(1 << Map::kIsExtensible); |
| 2096 map->set_bit_field3(Map::LastAddedBits::encode(Map::kNoneAdded)); | 2094 map->set_bit_field3(0); |
| 2097 map->set_elements_kind(elements_kind); | 2095 map->set_elements_kind(elements_kind); |
| 2098 | 2096 |
| 2099 // If the map object is aligned fill the padding area with Smi 0 objects. | 2097 // If the map object is aligned fill the padding area with Smi 0 objects. |
| 2100 if (Map::kPadStart < Map::kSize) { | 2098 if (Map::kPadStart < Map::kSize) { |
| 2101 memset(reinterpret_cast<byte*>(map) + Map::kPadStart - kHeapObjectTag, | 2099 memset(reinterpret_cast<byte*>(map) + Map::kPadStart - kHeapObjectTag, |
| 2102 0, | 2100 0, |
| 2103 Map::kSize - Map::kPadStart); | 2101 Map::kSize - Map::kPadStart); |
| 2104 } | 2102 } |
| 2105 return map; | 2103 return map; |
| 2106 } | 2104 } |
| (...skipping 1771 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3878 MaybeObject* maybe_descriptors = DescriptorArray::Allocate(count); | 3876 MaybeObject* maybe_descriptors = DescriptorArray::Allocate(count); |
| 3879 if (!maybe_descriptors->To(&descriptors)) return maybe_descriptors; | 3877 if (!maybe_descriptors->To(&descriptors)) return maybe_descriptors; |
| 3880 | 3878 |
| 3881 DescriptorArray::WhitenessWitness witness(descriptors); | 3879 DescriptorArray::WhitenessWitness witness(descriptors); |
| 3882 for (int i = 0; i < count; i++) { | 3880 for (int i = 0; i < count; i++) { |
| 3883 String* name = fun->shared()->GetThisPropertyAssignmentName(i); | 3881 String* name = fun->shared()->GetThisPropertyAssignmentName(i); |
| 3884 ASSERT(name->IsSymbol()); | 3882 ASSERT(name->IsSymbol()); |
| 3885 FieldDescriptor field(name, i, NONE, i + 1); | 3883 FieldDescriptor field(name, i, NONE, i + 1); |
| 3886 descriptors->Set(i, &field, witness); | 3884 descriptors->Set(i, &field, witness); |
| 3887 } | 3885 } |
| 3888 descriptors->Sort(witness); | 3886 descriptors->Sort(); |
| 3889 | 3887 |
| 3890 // The descriptors may contain duplicates because the compiler does not | 3888 // The descriptors may contain duplicates because the compiler does not |
| 3891 // guarantee the uniqueness of property names (it would have required | 3889 // guarantee the uniqueness of property names (it would have required |
| 3892 // quadratic time). Once the descriptors are sorted we can check for | 3890 // quadratic time). Once the descriptors are sorted we can check for |
| 3893 // duplicates in linear time. | 3891 // duplicates in linear time. |
| 3894 if (HasDuplicates(descriptors)) { | 3892 if (HasDuplicates(descriptors)) { |
| 3895 fun->shared()->ForbidInlineConstructor(); | 3893 fun->shared()->ForbidInlineConstructor(); |
| 3896 } else { | 3894 } else { |
| 3897 MaybeObject* maybe_failure = map->InitializeDescriptors(descriptors); | 3895 MaybeObject* maybe_failure = map->InitializeDescriptors(descriptors); |
| 3898 if (maybe_failure->IsFailure()) return maybe_failure; | 3896 if (maybe_failure->IsFailure()) return maybe_failure; |
| (...skipping 251 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4150 StringDictionary::Allocate( | 4148 StringDictionary::Allocate( |
| 4151 map->NumberOfDescribedProperties() * 2 + initial_size); | 4149 map->NumberOfDescribedProperties() * 2 + initial_size); |
| 4152 if (!maybe_dictionary->To(&dictionary)) return maybe_dictionary; | 4150 if (!maybe_dictionary->To(&dictionary)) return maybe_dictionary; |
| 4153 | 4151 |
| 4154 // The global object might be created from an object template with accessors. | 4152 // The global object might be created from an object template with accessors. |
| 4155 // Fill these accessors into the dictionary. | 4153 // Fill these accessors into the dictionary. |
| 4156 DescriptorArray* descs = map->instance_descriptors(); | 4154 DescriptorArray* descs = map->instance_descriptors(); |
| 4157 for (int i = 0; i < descs->number_of_descriptors(); i++) { | 4155 for (int i = 0; i < descs->number_of_descriptors(); i++) { |
| 4158 PropertyDetails details = descs->GetDetails(i); | 4156 PropertyDetails details = descs->GetDetails(i); |
| 4159 ASSERT(details.type() == CALLBACKS); // Only accessors are expected. | 4157 ASSERT(details.type() == CALLBACKS); // Only accessors are expected. |
| 4160 PropertyDetails d = | 4158 PropertyDetails d = PropertyDetails(details.attributes(), |
| 4161 PropertyDetails(details.attributes(), CALLBACKS, details.index()); | 4159 CALLBACKS, |
| 4160 details.descriptor_index()); |
| 4162 Object* value = descs->GetCallbacksObject(i); | 4161 Object* value = descs->GetCallbacksObject(i); |
| 4163 MaybeObject* maybe_value = AllocateJSGlobalPropertyCell(value); | 4162 MaybeObject* maybe_value = AllocateJSGlobalPropertyCell(value); |
| 4164 if (!maybe_value->ToObject(&value)) return maybe_value; | 4163 if (!maybe_value->ToObject(&value)) return maybe_value; |
| 4165 | 4164 |
| 4166 MaybeObject* maybe_added = dictionary->Add(descs->GetKey(i), value, d); | 4165 MaybeObject* maybe_added = dictionary->Add(descs->GetKey(i), value, d); |
| 4167 if (!maybe_added->To(&dictionary)) return maybe_added; | 4166 if (!maybe_added->To(&dictionary)) return maybe_added; |
| 4168 } | 4167 } |
| 4169 | 4168 |
| 4170 // Allocate the global object and initialize it with the backing store. | 4169 // Allocate the global object and initialize it with the backing store. |
| 4171 JSObject* global; | 4170 JSObject* global; |
| (...skipping 3091 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7263 static_cast<int>(object_sizes_last_time_[index])); | 7262 static_cast<int>(object_sizes_last_time_[index])); |
| 7264 FIXED_ARRAY_SUB_INSTANCE_TYPE_LIST(ADJUST_LAST_TIME_OBJECT_COUNT) | 7263 FIXED_ARRAY_SUB_INSTANCE_TYPE_LIST(ADJUST_LAST_TIME_OBJECT_COUNT) |
| 7265 #undef ADJUST_LAST_TIME_OBJECT_COUNT | 7264 #undef ADJUST_LAST_TIME_OBJECT_COUNT |
| 7266 | 7265 |
| 7267 memcpy(object_counts_last_time_, object_counts_, sizeof(object_counts_)); | 7266 memcpy(object_counts_last_time_, object_counts_, sizeof(object_counts_)); |
| 7268 memcpy(object_sizes_last_time_, object_sizes_, sizeof(object_sizes_)); | 7267 memcpy(object_sizes_last_time_, object_sizes_, sizeof(object_sizes_)); |
| 7269 ClearObjectStats(); | 7268 ClearObjectStats(); |
| 7270 } | 7269 } |
| 7271 | 7270 |
| 7272 } } // namespace v8::internal | 7271 } } // namespace v8::internal |
| OLD | NEW |