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

Side by Side Diff: src/object-observe.js

Issue 15017003: Object.observe: disable freezing changeRecords until it can be made fast (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 7 years, 7 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 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
131 observerInfo.pendingChangeRecords.push(changeRecord); 131 observerInfo.pendingChangeRecords.push(changeRecord);
132 } 132 }
133 } 133 }
134 } 134 }
135 135
136 function NotifyChange(type, object, name, oldValue) { 136 function NotifyChange(type, object, name, oldValue) {
137 var objectInfo = objectInfoMap.get(object); 137 var objectInfo = objectInfoMap.get(object);
138 var changeRecord = (arguments.length < 4) ? 138 var changeRecord = (arguments.length < 4) ?
139 { type: type, object: object, name: name } : 139 { type: type, object: object, name: name } :
140 { type: type, object: object, name: name, oldValue: oldValue }; 140 { type: type, object: object, name: name, oldValue: oldValue };
141 ObjectFreeze(changeRecord); 141 // TODO(rafaelw): This breaks spec-compliance. Re-enable when freezing isn't
142 // slow.
143 // ObjectFreeze(changeRecord);
142 EnqueueChangeRecord(changeRecord, objectInfo.changeObservers); 144 EnqueueChangeRecord(changeRecord, objectInfo.changeObservers);
143 } 145 }
144 146
145 var notifierPrototype = {}; 147 var notifierPrototype = {};
146 148
147 function ObjectNotifierNotify(changeRecord) { 149 function ObjectNotifierNotify(changeRecord) {
148 if (!IS_SPEC_OBJECT(this)) 150 if (!IS_SPEC_OBJECT(this))
149 throw MakeTypeError("called_on_non_object", ["notify"]); 151 throw MakeTypeError("called_on_non_object", ["notify"]);
150 152
151 var target = notifierTargetMap.get(this); 153 var target = notifierTargetMap.get(this);
152 if (IS_UNDEFINED(target)) 154 if (IS_UNDEFINED(target))
153 throw MakeTypeError("observe_notify_non_notifier"); 155 throw MakeTypeError("observe_notify_non_notifier");
154 if (!IS_STRING(changeRecord.type)) 156 if (!IS_STRING(changeRecord.type))
155 throw MakeTypeError("observe_type_non_string"); 157 throw MakeTypeError("observe_type_non_string");
156 158
157 var objectInfo = objectInfoMap.get(target); 159 var objectInfo = objectInfoMap.get(target);
158 if (IS_UNDEFINED(objectInfo) || objectInfo.changeObservers.length === 0) 160 if (IS_UNDEFINED(objectInfo) || objectInfo.changeObservers.length === 0)
159 return; 161 return;
160 162
161 var newRecord = { object: target }; 163 var newRecord = { object: target };
162 for (var prop in changeRecord) { 164 for (var prop in changeRecord) {
163 if (prop === 'object') continue; 165 if (prop === 'object') continue;
164 %DefineOrRedefineDataProperty(newRecord, prop, changeRecord[prop], 166 %DefineOrRedefineDataProperty(newRecord, prop, changeRecord[prop],
165 READ_ONLY + DONT_DELETE); 167 READ_ONLY + DONT_DELETE);
166 } 168 }
167 ObjectFreeze(newRecord); 169 // TODO(rafaelw): This breaks spec-compliance. Re-enable when freezing isn't
170 // slow.
171 // ObjectFreeze(newRecord);
168 172
169 EnqueueChangeRecord(newRecord, objectInfo.changeObservers); 173 EnqueueChangeRecord(newRecord, objectInfo.changeObservers);
170 } 174 }
171 175
172 function ObjectGetNotifier(object) { 176 function ObjectGetNotifier(object) {
173 if (!IS_SPEC_OBJECT(object)) 177 if (!IS_SPEC_OBJECT(object))
174 throw MakeTypeError("observe_non_object", ["getNotifier"]); 178 throw MakeTypeError("observe_non_object", ["getNotifier"]);
175 179
176 if (ObjectIsFrozen(object)) return null; 180 if (ObjectIsFrozen(object)) return null;
177 181
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
229 "getNotifier", ObjectGetNotifier, 233 "getNotifier", ObjectGetNotifier,
230 "observe", ObjectObserve, 234 "observe", ObjectObserve,
231 "unobserve", ObjectUnobserve 235 "unobserve", ObjectUnobserve
232 )); 236 ));
233 InstallFunctions(notifierPrototype, DONT_ENUM, $Array( 237 InstallFunctions(notifierPrototype, DONT_ENUM, $Array(
234 "notify", ObjectNotifierNotify 238 "notify", ObjectNotifierNotify
235 )); 239 ));
236 } 240 }
237 241
238 SetupObjectObserve(); 242 SetupObjectObserve();
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