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

Side by Side Diff: src/objects.cc

Issue 9430048: When redefining accessor properties, defensively copy AccessorPairs. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: When redefining accessor properties, defensively copy AccessorPairs. Created 8 years, 10 months 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 | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 4453 matching lines...) Expand 10 before | Expand all | Expand 10 after
4464 // Lookup the name. 4464 // Lookup the name.
4465 LookupResult result(GetHeap()->isolate()); 4465 LookupResult result(GetHeap()->isolate());
4466 LocalLookupRealNamedProperty(name, &result); 4466 LocalLookupRealNamedProperty(name, &result);
4467 if (result.IsFound()) { 4467 if (result.IsFound()) {
4468 // TODO(mstarzinger): We should check for result.IsDontDelete() here once 4468 // TODO(mstarzinger): We should check for result.IsDontDelete() here once
4469 // we only call into the runtime once to set both getter and setter. 4469 // we only call into the runtime once to set both getter and setter.
4470 if (result.type() == CALLBACKS) { 4470 if (result.type() == CALLBACKS) {
4471 Object* obj = result.GetCallbackObject(); 4471 Object* obj = result.GetCallbackObject();
4472 // Need to preserve old getters/setters. 4472 // Need to preserve old getters/setters.
4473 if (obj->IsAccessorPair()) { 4473 if (obj->IsAccessorPair()) {
4474 AccessorPair::cast(obj)->set(is_getter, fun); 4474 AccessorPair* copy;
4475 { MaybeObject* maybe_copy =
4476 AccessorPair::cast(obj)->CopyWithoutTransitions();
4477 if (!maybe_copy->To(&copy)) return maybe_copy;
4478 }
4479 copy->set(is_getter, fun);
4475 // Use set to update attributes. 4480 // Use set to update attributes.
4476 { MaybeObject* maybe_ok = SetPropertyCallback(name, obj, attributes); 4481 { MaybeObject* maybe_ok = SetPropertyCallback(name, copy, attributes);
4477 if (maybe_ok->IsFailure()) return maybe_ok; 4482 if (maybe_ok->IsFailure()) return maybe_ok;
4478 } 4483 }
4479 return GetHeap()->undefined_value(); 4484 return GetHeap()->undefined_value();
4480 } 4485 }
4481 } 4486 }
4482 } 4487 }
4483 4488
4484 AccessorPair* accessors; 4489 AccessorPair* accessors;
4485 { MaybeObject* maybe_accessors = GetHeap()->AllocateAccessorPair(); 4490 { MaybeObject* maybe_accessors = GetHeap()->AllocateAccessorPair();
4486 if (!maybe_accessors->To(&accessors)) return maybe_accessors; 4491 if (!maybe_accessors->To(&accessors)) return maybe_accessors;
(...skipping 8592 matching lines...) Expand 10 before | Expand all | Expand 10 after
13079 if (break_point_objects()->IsUndefined()) return 0; 13084 if (break_point_objects()->IsUndefined()) return 0;
13080 // Single break point. 13085 // Single break point.
13081 if (!break_point_objects()->IsFixedArray()) return 1; 13086 if (!break_point_objects()->IsFixedArray()) return 1;
13082 // Multiple break points. 13087 // Multiple break points.
13083 return FixedArray::cast(break_point_objects())->length(); 13088 return FixedArray::cast(break_point_objects())->length();
13084 } 13089 }
13085 #endif // ENABLE_DEBUGGER_SUPPORT 13090 #endif // ENABLE_DEBUGGER_SUPPORT
13086 13091
13087 13092
13088 } } // namespace v8::internal 13093 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698