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

Side by Side Diff: src/runtime.cc

Issue 8996008: Fix handling of foreign callbacks in DefineOwnProperty. (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 | « no previous file | test/mjsunit/regress/regress-1530.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 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 4308 matching lines...) Expand 10 before | Expand all | Expand 10 after
4319 } else { 4319 } else {
4320 js_object->set_elements(*extended_dictionary); 4320 js_object->set_elements(*extended_dictionary);
4321 } 4321 }
4322 } 4322 }
4323 return *obj_value; 4323 return *obj_value;
4324 } 4324 }
4325 4325
4326 LookupResult result(isolate); 4326 LookupResult result(isolate);
4327 js_object->LocalLookupRealNamedProperty(*name, &result); 4327 js_object->LocalLookupRealNamedProperty(*name, &result);
4328 4328
4329 // To be compatible with safari we do not change the value on API objects 4329 // Special case for callback properties.
4330 // in defineProperty. Firefox disagrees here, and actually changes the value. 4330 if (result.IsProperty() && result.type() == CALLBACKS) {
4331 if (result.IsProperty() && 4331 Object* callback = result.GetCallbackObject();
4332 (result.type() == CALLBACKS) && 4332 // To be compatible with Safari we do not change the value on API objects
4333 result.GetCallbackObject()->IsAccessorInfo()) { 4333 // in Object.defineProperty(). Firefox disagrees here, and actually changes
4334 return isolate->heap()->undefined_value(); 4334 // the value.
4335 if (callback->IsAccessorInfo()) {
4336 return isolate->heap()->undefined_value();
4337 }
4338 // Avoid redefining foreign callback as data property, just use the stored
4339 // setter to update the value instead.
4340 // TODO(mstarzinger): So far this only works if property attributes don't
4341 // change, this should be fixed once we cleanup the underlying code.
4342 if (callback->IsForeign() && result.GetAttributes() == attr) {
4343 return js_object->SetPropertyWithCallback(callback,
4344 *name,
4345 *obj_value,
4346 result.holder(),
4347 kStrictMode);
4348 }
4335 } 4349 }
4336 4350
4337 // Take special care when attributes are different and there is already 4351 // Take special care when attributes are different and there is already
4338 // a property. For simplicity we normalize the property which enables us 4352 // a property. For simplicity we normalize the property which enables us
4339 // to not worry about changing the instance_descriptor and creating a new 4353 // to not worry about changing the instance_descriptor and creating a new
4340 // map. The current version of SetObjectProperty does not handle attributes 4354 // map. The current version of SetObjectProperty does not handle attributes
4341 // correctly in the case where a property is a field and is reset with 4355 // correctly in the case where a property is a field and is reset with
4342 // new attributes. 4356 // new attributes.
4343 if (result.IsProperty() && 4357 if (result.IsProperty() &&
4344 (attr != result.GetAttributes() || result.type() == CALLBACKS)) { 4358 (attr != result.GetAttributes() || result.type() == CALLBACKS)) {
(...skipping 9226 matching lines...) Expand 10 before | Expand all | Expand 10 after
13571 } else { 13585 } else {
13572 // Handle last resort GC and make sure to allow future allocations 13586 // Handle last resort GC and make sure to allow future allocations
13573 // to grow the heap without causing GCs (if possible). 13587 // to grow the heap without causing GCs (if possible).
13574 isolate->counters()->gc_last_resort_from_js()->Increment(); 13588 isolate->counters()->gc_last_resort_from_js()->Increment();
13575 isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags); 13589 isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags);
13576 } 13590 }
13577 } 13591 }
13578 13592
13579 13593
13580 } } // namespace v8::internal 13594 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « no previous file | test/mjsunit/regress/regress-1530.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698