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

Unified Diff: src/objects-inl.h

Issue 11477006: Object.observe: prevent observed objects from using fast elements. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Tweaked comment Created 8 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 side-by-side diff with in-line comments
Download patch
Index: src/objects-inl.h
diff --git a/src/objects-inl.h b/src/objects-inl.h
index b25af33c77a59d14f2d92a40b422297242c9cc90..53e12b2f043e71a89fbbdcd0b5c8b3a5a43e8866 100644
--- a/src/objects-inl.h
+++ b/src/objects-inl.h
@@ -1426,6 +1426,13 @@ MaybeObject* JSObject::ResetElements() {
if (!maybe_obj->ToObject(&obj)) return maybe_obj;
set_map(Map::cast(obj));
initialize_elements();
+ if (FLAG_harmony_observation && map()->is_observed()) {
+ // Maintain invariant that observed elements are always in dictionary mode.
+ // For this to work on arrays, we have to make sure to reset length first.
+ if (IsJSArray()) JSArray::cast(this)->set_length(Smi::FromInt(0));
Michael Starzinger 2012/12/11 15:20:19 OMG, having to set the JSArray length to 0 here is
rossberg 2012/12/11 15:29:35 Yeah, the whole "abstraction" we have here is bogu
+ maybe_obj = NormalizeElements();
+ if (maybe_obj->IsFailure()) return maybe_obj;
+ }
return this;
}
« no previous file with comments | « src/objects.cc ('k') | src/runtime.cc » ('j') | test/mjsunit/harmony/object-observe.js » ('J')

Powered by Google App Engine
This is Rietveld 408576698