OLD | NEW |
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 2888 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2899 int unchecked = flag_attr->value(); | 2899 int unchecked = flag_attr->value(); |
2900 RUNTIME_ASSERT((unchecked & ~(READ_ONLY | DONT_ENUM | DONT_DELETE)) == 0); | 2900 RUNTIME_ASSERT((unchecked & ~(READ_ONLY | DONT_ENUM | DONT_DELETE)) == 0); |
2901 | 2901 |
2902 LookupResult result; | 2902 LookupResult result; |
2903 obj->LocalLookupRealNamedProperty(name, &result); | 2903 obj->LocalLookupRealNamedProperty(name, &result); |
2904 | 2904 |
2905 PropertyAttributes attr = static_cast<PropertyAttributes>(unchecked); | 2905 PropertyAttributes attr = static_cast<PropertyAttributes>(unchecked); |
2906 // If an existing property is either FIELD, NORMAL or CONSTANT_FUNCTION | 2906 // If an existing property is either FIELD, NORMAL or CONSTANT_FUNCTION |
2907 // delete it to avoid running into trouble in DefineAccessor, which | 2907 // delete it to avoid running into trouble in DefineAccessor, which |
2908 // handles this incorrectly if the property is readonly (does nothing) | 2908 // handles this incorrectly if the property is readonly (does nothing) |
2909 if (result.type() == FIELD || result.type() == NORMAL | 2909 if (result.IsValid() && |
2910 || result.type() == CONSTANT_FUNCTION) | 2910 (result.type() == FIELD || result.type() == NORMAL |
| 2911 || result.type() == CONSTANT_FUNCTION)) { |
2911 obj->DeleteProperty(name, JSObject::NORMAL_DELETION); | 2912 obj->DeleteProperty(name, JSObject::NORMAL_DELETION); |
2912 | 2913 } |
2913 return obj->DefineAccessor(name, flag_setter->value() == 0, fun, attr); | 2914 return obj->DefineAccessor(name, flag_setter->value() == 0, fun, attr); |
2914 } | 2915 } |
2915 | 2916 |
2916 static Object* Runtime_DefineOrRedefineDataProperty(Arguments args) { | 2917 static Object* Runtime_DefineOrRedefineDataProperty(Arguments args) { |
2917 ASSERT(args.length() == 4); | 2918 ASSERT(args.length() == 4); |
2918 HandleScope scope; | 2919 HandleScope scope; |
2919 Handle<Object> obj = args.at<Object>(0); | 2920 Handle<Object> obj = args.at<Object>(0); |
2920 Handle<Object> name = args.at<Object>(1); | 2921 Handle<Object> name = args.at<Object>(1); |
2921 Handle<Object> obj_value = args.at<Object>(2); | 2922 Handle<Object> obj_value = args.at<Object>(2); |
2922 Handle<JSObject> js_object = Handle<JSObject>::cast(obj); | 2923 Handle<JSObject> js_object = Handle<JSObject>::cast(obj); |
(...skipping 5319 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8242 } else { | 8243 } else { |
8243 // Handle last resort GC and make sure to allow future allocations | 8244 // Handle last resort GC and make sure to allow future allocations |
8244 // to grow the heap without causing GCs (if possible). | 8245 // to grow the heap without causing GCs (if possible). |
8245 Counters::gc_last_resort_from_js.Increment(); | 8246 Counters::gc_last_resort_from_js.Increment(); |
8246 Heap::CollectAllGarbage(false); | 8247 Heap::CollectAllGarbage(false); |
8247 } | 8248 } |
8248 } | 8249 } |
8249 | 8250 |
8250 | 8251 |
8251 } } // namespace v8::internal | 8252 } } // namespace v8::internal |
OLD | NEW |