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 2162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2173 // Construct a new field descriptor with updated attributes. | 2173 // Construct a new field descriptor with updated attributes. |
2174 DescriptorArray* instance_desc = function->map()->instance_descriptors(); | 2174 DescriptorArray* instance_desc = function->map()->instance_descriptors(); |
2175 int index = instance_desc->Search(name); | 2175 int index = instance_desc->Search(name); |
2176 ASSERT(index != DescriptorArray::kNotFound); | 2176 ASSERT(index != DescriptorArray::kNotFound); |
2177 PropertyDetails details = instance_desc->GetDetails(index); | 2177 PropertyDetails details = instance_desc->GetDetails(index); |
2178 CallbacksDescriptor new_desc(name, | 2178 CallbacksDescriptor new_desc(name, |
2179 instance_desc->GetValue(index), | 2179 instance_desc->GetValue(index), |
2180 static_cast<PropertyAttributes>(details.attributes() | READ_ONLY), | 2180 static_cast<PropertyAttributes>(details.attributes() | READ_ONLY), |
2181 details.index()); | 2181 details.index()); |
2182 // Construct a new field descriptors array containing the new descriptor. | 2182 // Construct a new field descriptors array containing the new descriptor. |
2183 Object* descriptors_unchecked; | 2183 DescriptorArray* new_descriptors; |
2184 { MaybeObject* maybe_descriptors_unchecked = | 2184 { MaybeObject* maybe_descriptors = instance_desc->CopyInsert(&new_desc); |
2185 instance_desc->CopyInsert(&new_desc); | 2185 if (!maybe_descriptors->To(&new_descriptors)) return maybe_descriptors; |
2186 if (!maybe_descriptors_unchecked->ToObject(&descriptors_unchecked)) { | |
2187 return maybe_descriptors_unchecked; | |
2188 } | |
2189 } | 2186 } |
2190 DescriptorArray* new_descriptors = | |
2191 DescriptorArray::cast(descriptors_unchecked); | |
2192 // Create a new map featuring the new field descriptors array. | 2187 // Create a new map featuring the new field descriptors array. |
2193 Map* new_map; | 2188 Map* new_map; |
2194 { MaybeObject* maybe_map_unchecked = | 2189 { MaybeObject* maybe_map = |
2195 function->map()->CopyDropDescriptors(); | 2190 function->map()->CopyReplaceDescriptors(new_descriptors); |
2196 if (!maybe_map_unchecked->To(&new_map)) { | 2191 if (!maybe_map->To(&new_map)) return maybe_map; |
2197 return maybe_map_unchecked; | |
2198 } | |
2199 } | 2192 } |
2200 new_map->set_instance_descriptors(new_descriptors); | |
2201 function->set_map(new_map); | 2193 function->set_map(new_map); |
2202 } else { // Dictionary properties. | 2194 } else { // Dictionary properties. |
2203 // Directly manipulate the property details. | 2195 // Directly manipulate the property details. |
2204 int entry = function->property_dictionary()->FindEntry(name); | 2196 int entry = function->property_dictionary()->FindEntry(name); |
2205 ASSERT(entry != StringDictionary::kNotFound); | 2197 ASSERT(entry != StringDictionary::kNotFound); |
2206 PropertyDetails details = function->property_dictionary()->DetailsAt(entry); | 2198 PropertyDetails details = function->property_dictionary()->DetailsAt(entry); |
2207 PropertyDetails new_details( | 2199 PropertyDetails new_details( |
2208 static_cast<PropertyAttributes>(details.attributes() | READ_ONLY), | 2200 static_cast<PropertyAttributes>(details.attributes() | READ_ONLY), |
2209 details.type(), | 2201 details.type(), |
2210 details.index()); | 2202 details.index()); |
(...skipping 11508 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
13719 // Handle last resort GC and make sure to allow future allocations | 13711 // Handle last resort GC and make sure to allow future allocations |
13720 // to grow the heap without causing GCs (if possible). | 13712 // to grow the heap without causing GCs (if possible). |
13721 isolate->counters()->gc_last_resort_from_js()->Increment(); | 13713 isolate->counters()->gc_last_resort_from_js()->Increment(); |
13722 isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags, | 13714 isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags, |
13723 "Runtime::PerformGC"); | 13715 "Runtime::PerformGC"); |
13724 } | 13716 } |
13725 } | 13717 } |
13726 | 13718 |
13727 | 13719 |
13728 } } // namespace v8::internal | 13720 } } // namespace v8::internal |
OLD | NEW |