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

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

Issue 1149863005: Move hash code from hidden string to a private symbol (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Fix global object hash code. This eated about 5% of weak collection performance Created 5 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
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 var $observeNotifyChange; 5 var $observeNotifyChange;
6 var $observeEnqueueSpliceRecord; 6 var $observeEnqueueSpliceRecord;
7 var $observeBeginPerformSplice; 7 var $observeBeginPerformSplice;
8 var $observeEndPerformSplice; 8 var $observeEndPerformSplice;
9 var $observeNativeObjectObserve; 9 var $observeNativeObjectObserve;
10 var $observeNativeObjectGetNotifier; 10 var $observeNativeObjectGetNotifier;
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after
193 %SetIsObserved(object); 193 %SetIsObserved(object);
194 } 194 }
195 objectInfo = { 195 objectInfo = {
196 object: object, 196 object: object,
197 changeObservers: null, 197 changeObservers: null,
198 notifier: null, 198 notifier: null,
199 performing: null, 199 performing: null,
200 performingCount: 0, 200 performingCount: 0,
201 }; 201 };
202 %WeakCollectionSet(GetObservationStateJS().objectInfoMap, 202 %WeakCollectionSet(GetObservationStateJS().objectInfoMap,
203 object, objectInfo); 203 object, objectInfo, $gethash(object));
204 } 204 }
205 return objectInfo; 205 return objectInfo;
206 } 206 }
207 207
208 208
209 function ObjectInfoGet(object) { 209 function ObjectInfoGet(object) {
210 return %WeakCollectionGet(GetObservationStateJS().objectInfoMap, object); 210 return %WeakCollectionGet(GetObservationStateJS().objectInfoMap, object, $geth ash(object));
adamk 2015/05/21 19:11:32 Style nit: over 80 characters here and below.
Erik Corry 2015/05/21 20:19:02 I've come to rely too much on git cl format.
Erik Corry 2015/05/22 06:20:25 Done.
211 } 211 }
212 212
213 213
214 function ObjectInfoGetFromNotifier(notifier) { 214 function ObjectInfoGetFromNotifier(notifier) {
215 return %WeakCollectionGet(GetObservationStateJS().notifierObjectInfoMap, 215 return %WeakCollectionGet(GetObservationStateJS().notifierObjectInfoMap,
216 notifier); 216 notifier, $gethash(notifier));
217 } 217 }
218 218
219 219
220 function ObjectInfoGetNotifier(objectInfo) { 220 function ObjectInfoGetNotifier(objectInfo) {
221 if (IS_NULL(objectInfo.notifier)) { 221 if (IS_NULL(objectInfo.notifier)) {
222 objectInfo.notifier = { __proto__: notifierPrototype }; 222 var notifier = { __proto__: notifierPrototype };
223 objectInfo.notifier = notifier;
223 %WeakCollectionSet(GetObservationStateJS().notifierObjectInfoMap, 224 %WeakCollectionSet(GetObservationStateJS().notifierObjectInfoMap,
224 objectInfo.notifier, objectInfo); 225 notifier, objectInfo, $gethash(notifier));
225 } 226 }
226 227
227 return objectInfo.notifier; 228 return objectInfo.notifier;
228 } 229 }
229 230
230 231
231 function ChangeObserversIsOptimized(changeObservers) { 232 function ChangeObserversIsOptimized(changeObservers) {
232 return IS_SPEC_FUNCTION(changeObservers) || 233 return IS_SPEC_FUNCTION(changeObservers) ||
233 IS_SPEC_FUNCTION(changeObservers.callback); 234 IS_SPEC_FUNCTION(changeObservers.callback);
234 } 235 }
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
325 if (len < 0) len = 0; 326 if (len < 0) len = 0;
326 327
327 return TypeMapCreateFromList(arg, len); 328 return TypeMapCreateFromList(arg, len);
328 } 329 }
329 330
330 331
331 // CallbackInfo's optimized state is just a number which represents its global 332 // CallbackInfo's optimized state is just a number which represents its global
332 // priority. When a change record must be enqueued for the callback, it 333 // priority. When a change record must be enqueued for the callback, it
333 // normalizes. When delivery clears any pending change records, it re-optimizes. 334 // normalizes. When delivery clears any pending change records, it re-optimizes.
334 function CallbackInfoGet(callback) { 335 function CallbackInfoGet(callback) {
335 return %WeakCollectionGet(GetObservationStateJS().callbackInfoMap, callback); 336 return %WeakCollectionGet(GetObservationStateJS().callbackInfoMap, callback, $ gethash(callback));
336 } 337 }
337 338
338 339
339 function CallbackInfoSet(callback, callbackInfo) { 340 function CallbackInfoSet(callback, callbackInfo) {
340 %WeakCollectionSet(GetObservationStateJS().callbackInfoMap, 341 %WeakCollectionSet(GetObservationStateJS().callbackInfoMap,
341 callback, callbackInfo); 342 callback, callbackInfo, $gethash(callback));
342 } 343 }
343 344
344 345
345 function CallbackInfoGetOrCreate(callback) { 346 function CallbackInfoGetOrCreate(callback) {
346 var callbackInfo = CallbackInfoGet(callback); 347 var callbackInfo = CallbackInfoGet(callback);
347 if (!IS_UNDEFINED(callbackInfo)) 348 if (!IS_UNDEFINED(callbackInfo))
348 return callbackInfo; 349 return callbackInfo;
349 350
350 var priority = GetNextCallbackPriority(); 351 var priority = GetNextCallbackPriority();
351 CallbackInfoSet(callback, priority); 352 CallbackInfoSet(callback, priority);
(...skipping 330 matching lines...) Expand 10 before | Expand all | Expand 10 after
682 683
683 $observeNotifyChange = NotifyChange; 684 $observeNotifyChange = NotifyChange;
684 $observeEnqueueSpliceRecord = EnqueueSpliceRecord; 685 $observeEnqueueSpliceRecord = EnqueueSpliceRecord;
685 $observeBeginPerformSplice = BeginPerformSplice; 686 $observeBeginPerformSplice = BeginPerformSplice;
686 $observeEndPerformSplice = EndPerformSplice; 687 $observeEndPerformSplice = EndPerformSplice;
687 $observeNativeObjectObserve = NativeObjectObserve; 688 $observeNativeObjectObserve = NativeObjectObserve;
688 $observeNativeObjectGetNotifier = NativeObjectGetNotifier; 689 $observeNativeObjectGetNotifier = NativeObjectGetNotifier;
689 $observeNativeObjectNotifierPerformChange = NativeObjectNotifierPerformChange; 690 $observeNativeObjectNotifierPerformChange = NativeObjectNotifierPerformChange;
690 691
691 }) 692 })
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698