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

Side by Side Diff: src/runtime.cc

Issue 8951013: Remove bogus writability check in DefineGetterSetter. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Addressed comments by Andreas Rossberg. Created 9 years 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/test262/test262.status » ('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 2011 the V8 project authors. All rights reserved. 1 // Copyright 2011 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 4230 matching lines...) Expand 10 before | Expand all | Expand 10 after
4241 // Steps 9c & 12 - replace an existing data property with an accessor property. 4241 // Steps 9c & 12 - replace an existing data property with an accessor property.
4242 // Step 12 - update an existing accessor property with an accessor or generic 4242 // Step 12 - update an existing accessor property with an accessor or generic
4243 // descriptor. 4243 // descriptor.
4244 RUNTIME_FUNCTION(MaybeObject*, Runtime_DefineOrRedefineAccessorProperty) { 4244 RUNTIME_FUNCTION(MaybeObject*, Runtime_DefineOrRedefineAccessorProperty) {
4245 ASSERT(args.length() == 5); 4245 ASSERT(args.length() == 5);
4246 HandleScope scope(isolate); 4246 HandleScope scope(isolate);
4247 CONVERT_ARG_CHECKED(JSObject, obj, 0); 4247 CONVERT_ARG_CHECKED(JSObject, obj, 0);
4248 CONVERT_CHECKED(String, name, args[1]); 4248 CONVERT_CHECKED(String, name, args[1]);
4249 CONVERT_CHECKED(Smi, flag_setter, args[2]); 4249 CONVERT_CHECKED(Smi, flag_setter, args[2]);
4250 Object* fun = args[3]; 4250 Object* fun = args[3];
4251 RUNTIME_ASSERT(fun->IsSpecFunction() || fun->IsUndefined());
4252 CONVERT_CHECKED(Smi, flag_attr, args[4]); 4251 CONVERT_CHECKED(Smi, flag_attr, args[4]);
4252
4253 int unchecked = flag_attr->value(); 4253 int unchecked = flag_attr->value();
4254 RUNTIME_ASSERT((unchecked & ~(READ_ONLY | DONT_ENUM | DONT_DELETE)) == 0); 4254 RUNTIME_ASSERT((unchecked & ~(READ_ONLY | DONT_ENUM | DONT_DELETE)) == 0);
4255 PropertyAttributes attr = static_cast<PropertyAttributes>(unchecked);
4256
4255 RUNTIME_ASSERT(!obj->IsNull()); 4257 RUNTIME_ASSERT(!obj->IsNull());
4256 LookupResult result(isolate); 4258 RUNTIME_ASSERT(fun->IsSpecFunction() || fun->IsUndefined());
4257 obj->LocalLookupRealNamedProperty(name, &result);
4258
4259 PropertyAttributes attr = static_cast<PropertyAttributes>(unchecked);
4260 // If an existing property is either FIELD, NORMAL or CONSTANT_FUNCTION
4261 // delete it to avoid running into trouble in DefineAccessor, which
4262 // handles this incorrectly if the property is readonly (does nothing)
4263 if (result.IsProperty() &&
4264 (result.type() == FIELD || result.type() == NORMAL
4265 || result.type() == CONSTANT_FUNCTION)) {
4266 Object* ok;
4267 { MaybeObject* maybe_ok =
4268 obj->DeleteProperty(name, JSReceiver::NORMAL_DELETION);
4269 if (!maybe_ok->ToObject(&ok)) return maybe_ok;
4270 }
4271 }
4272 return obj->DefineAccessor(name, flag_setter->value() == 0, fun, attr); 4259 return obj->DefineAccessor(name, flag_setter->value() == 0, fun, attr);
4273 } 4260 }
4274 4261
4275 // Implements part of 8.12.9 DefineOwnProperty. 4262 // Implements part of 8.12.9 DefineOwnProperty.
4276 // There are 3 cases that lead here: 4263 // There are 3 cases that lead here:
4277 // Step 4a - define a new data property. 4264 // Step 4a - define a new data property.
4278 // Steps 9b & 12 - replace an existing accessor property with a data property. 4265 // Steps 9b & 12 - replace an existing accessor property with a data property.
4279 // Step 12 - update an existing data property with a data or generic 4266 // Step 12 - update an existing data property with a data or generic
4280 // descriptor. 4267 // descriptor.
4281 RUNTIME_FUNCTION(MaybeObject*, Runtime_DefineOrRedefineDataProperty) { 4268 RUNTIME_FUNCTION(MaybeObject*, Runtime_DefineOrRedefineDataProperty) {
4282 ASSERT(args.length() == 4); 4269 ASSERT(args.length() == 4);
4283 HandleScope scope(isolate); 4270 HandleScope scope(isolate);
4284 CONVERT_ARG_CHECKED(JSObject, js_object, 0); 4271 CONVERT_ARG_CHECKED(JSObject, js_object, 0);
4285 CONVERT_ARG_CHECKED(String, name, 1); 4272 CONVERT_ARG_CHECKED(String, name, 1);
4286 Handle<Object> obj_value = args.at<Object>(2); 4273 Handle<Object> obj_value = args.at<Object>(2);
4274 CONVERT_CHECKED(Smi, flag, args[3]);
4287 4275
4288 CONVERT_CHECKED(Smi, flag, args[3]);
4289 int unchecked = flag->value(); 4276 int unchecked = flag->value();
4290 RUNTIME_ASSERT((unchecked & ~(READ_ONLY | DONT_ENUM | DONT_DELETE)) == 0); 4277 RUNTIME_ASSERT((unchecked & ~(READ_ONLY | DONT_ENUM | DONT_DELETE)) == 0);
4291
4292 PropertyAttributes attr = static_cast<PropertyAttributes>(unchecked); 4278 PropertyAttributes attr = static_cast<PropertyAttributes>(unchecked);
4293 4279
4294 // Check if this is an element. 4280 // Check if this is an element.
4295 uint32_t index; 4281 uint32_t index;
4296 bool is_element = name->AsArrayIndex(&index); 4282 bool is_element = name->AsArrayIndex(&index);
4297 4283
4298 // Special case for elements if any of the flags might be involved. 4284 // Special case for elements if any of the flags might be involved.
4299 // If elements are in fast case we always implicitly assume that: 4285 // If elements are in fast case we always implicitly assume that:
4300 // DONT_DELETE: false, DONT_ENUM: false, READ_ONLY: false. 4286 // DONT_DELETE: false, DONT_ENUM: false, READ_ONLY: false.
4301 if (is_element && (attr != NONE || 4287 if (is_element && (attr != NONE ||
(...skipping 9283 matching lines...) Expand 10 before | Expand all | Expand 10 after
13585 } else { 13571 } else {
13586 // Handle last resort GC and make sure to allow future allocations 13572 // Handle last resort GC and make sure to allow future allocations
13587 // to grow the heap without causing GCs (if possible). 13573 // to grow the heap without causing GCs (if possible).
13588 isolate->counters()->gc_last_resort_from_js()->Increment(); 13574 isolate->counters()->gc_last_resort_from_js()->Increment();
13589 isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags); 13575 isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags);
13590 } 13576 }
13591 } 13577 }
13592 13578
13593 13579
13594 } } // namespace v8::internal 13580 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/objects.cc ('k') | test/test262/test262.status » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698