Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(324)

Side by Side Diff: src/runtime.cc

Issue 4171002: Port some GC fixes from the bleeding edge to the 2.3 branch. These are:... (Closed) Base URL: http://v8.googlecode.com/svn/branches/2.3/
Patch Set: Created 10 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/objects.cc ('k') | test/mjsunit/define-property-gc.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2006-2009 the V8 project authors. All rights reserved. 1 // Copyright 2006-2009 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 4130 matching lines...) Expand 10 before | Expand all | Expand 10 after
4141 // Check if this is an element. 4141 // Check if this is an element.
4142 uint32_t index; 4142 uint32_t index;
4143 bool is_element = name->AsArrayIndex(&index); 4143 bool is_element = name->AsArrayIndex(&index);
4144 4144
4145 // Special case for elements if any of the flags are true. 4145 // Special case for elements if any of the flags are true.
4146 // If elements are in fast case we always implicitly assume that: 4146 // If elements are in fast case we always implicitly assume that:
4147 // DONT_DELETE: false, DONT_ENUM: false, READ_ONLY: false. 4147 // DONT_DELETE: false, DONT_ENUM: false, READ_ONLY: false.
4148 if (((unchecked & (DONT_DELETE | DONT_ENUM | READ_ONLY)) != 0) && 4148 if (((unchecked & (DONT_DELETE | DONT_ENUM | READ_ONLY)) != 0) &&
4149 is_element) { 4149 is_element) {
4150 // Normalize the elements to enable attributes on the property. 4150 // Normalize the elements to enable attributes on the property.
4151 js_object->NormalizeElements(); 4151 NormalizeElements(js_object);
4152 NumberDictionary* dictionary = js_object->element_dictionary(); 4152 Handle<NumberDictionary> dictionary(js_object->element_dictionary());
4153 // Make sure that we never go back to fast case. 4153 // Make sure that we never go back to fast case.
4154 dictionary->set_requires_slow_elements(); 4154 dictionary->set_requires_slow_elements();
4155 PropertyDetails details = PropertyDetails(attr, NORMAL); 4155 PropertyDetails details = PropertyDetails(attr, NORMAL);
4156 dictionary->Set(index, *obj_value, details); 4156 NumberDictionarySet(dictionary, index, obj_value, details);
4157 } 4157 }
4158 4158
4159 LookupResult result; 4159 LookupResult result;
4160 js_object->LocalLookupRealNamedProperty(*name, &result); 4160 js_object->LocalLookupRealNamedProperty(*name, &result);
4161 4161
4162 // Take special care when attributes are different and there is already 4162 // Take special care when attributes are different and there is already
4163 // a property. For simplicity we normalize the property which enables us 4163 // a property. For simplicity we normalize the property which enables us
4164 // to not worry about changing the instance_descriptor and creating a new 4164 // to not worry about changing the instance_descriptor and creating a new
4165 // map. The current version of SetObjectProperty does not handle attributes 4165 // map. The current version of SetObjectProperty does not handle attributes
4166 // correctly in the case where a property is a field and is reset with 4166 // correctly in the case where a property is a field and is reset with
4167 // new attributes. 4167 // new attributes.
4168 if (result.IsProperty() && attr != result.GetAttributes()) { 4168 if (result.IsProperty() && attr != result.GetAttributes()) {
4169 // New attributes - normalize to avoid writing to instance descriptor 4169 // New attributes - normalize to avoid writing to instance descriptor
4170 js_object->NormalizeProperties(CLEAR_INOBJECT_PROPERTIES, 0); 4170 NormalizeProperties(js_object, CLEAR_INOBJECT_PROPERTIES, 0);
4171 // Use IgnoreAttributes version since a readonly property may be 4171 // Use IgnoreAttributes version since a readonly property may be
4172 // overridden and SetProperty does not allow this. 4172 // overridden and SetProperty does not allow this.
4173 return js_object->IgnoreAttributesAndSetLocalProperty(*name, 4173 return js_object->IgnoreAttributesAndSetLocalProperty(*name,
4174 *obj_value, 4174 *obj_value,
4175 attr); 4175 attr);
4176 } 4176 }
4177 4177
4178 return Runtime::SetObjectProperty(js_object, name, obj_value, attr); 4178 return Runtime::SetObjectProperty(js_object, name, obj_value, attr);
4179 } 4179 }
4180 4180
(...skipping 576 matching lines...) Expand 10 before | Expand all | Expand 10 after
4757 } 4757 }
4758 4758
4759 4759
4760 static Object* Runtime_ToSlowProperties(Arguments args) { 4760 static Object* Runtime_ToSlowProperties(Arguments args) {
4761 HandleScope scope; 4761 HandleScope scope;
4762 4762
4763 ASSERT(args.length() == 1); 4763 ASSERT(args.length() == 1);
4764 Handle<Object> object = args.at<Object>(0); 4764 Handle<Object> object = args.at<Object>(0);
4765 if (object->IsJSObject()) { 4765 if (object->IsJSObject()) {
4766 Handle<JSObject> js_object = Handle<JSObject>::cast(object); 4766 Handle<JSObject> js_object = Handle<JSObject>::cast(object);
4767 js_object->NormalizeProperties(CLEAR_INOBJECT_PROPERTIES, 0); 4767 NormalizeProperties(js_object, CLEAR_INOBJECT_PROPERTIES, 0);
4768 } 4768 }
4769 return *object; 4769 return *object;
4770 } 4770 }
4771 4771
4772 4772
4773 static Object* Runtime_ToBool(Arguments args) { 4773 static Object* Runtime_ToBool(Arguments args) {
4774 NoHandleAllocation ha; 4774 NoHandleAllocation ha;
4775 ASSERT(args.length() == 1); 4775 ASSERT(args.length() == 1);
4776 4776
4777 return args[0]->ToBoolean(); 4777 return args[0]->ToBoolean();
(...skipping 5963 matching lines...) Expand 10 before | Expand all | Expand 10 after
10741 } else { 10741 } else {
10742 // Handle last resort GC and make sure to allow future allocations 10742 // Handle last resort GC and make sure to allow future allocations
10743 // to grow the heap without causing GCs (if possible). 10743 // to grow the heap without causing GCs (if possible).
10744 Counters::gc_last_resort_from_js.Increment(); 10744 Counters::gc_last_resort_from_js.Increment();
10745 Heap::CollectAllGarbage(false); 10745 Heap::CollectAllGarbage(false);
10746 } 10746 }
10747 } 10747 }
10748 10748
10749 10749
10750 } } // namespace v8::internal 10750 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/objects.cc ('k') | test/mjsunit/define-property-gc.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698