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

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

Issue 1531843003: Rename IS_SPEC_OBJECT macro to IS_RECEIVER. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 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
« no previous file with comments | « src/js/messages.js ('k') | src/js/promise.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 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 (function(global, utils) { 5 (function(global, utils) {
6 6
7 "use strict"; 7 "use strict";
8 8
9 %CheckIsBootstrapping(); 9 %CheckIsBootstrapping();
10 10
(...skipping 306 matching lines...) Expand 10 before | Expand all | Expand 10 after
317 function ObjectInfoGetPerformingTypes(objectInfo) { 317 function ObjectInfoGetPerformingTypes(objectInfo) {
318 return objectInfo.performingCount > 0 ? objectInfo.performing : null; 318 return objectInfo.performingCount > 0 ? objectInfo.performing : null;
319 } 319 }
320 320
321 321
322 function ConvertAcceptListToTypeMap(arg) { 322 function ConvertAcceptListToTypeMap(arg) {
323 // We use undefined as a sentinel for the default accept list. 323 // We use undefined as a sentinel for the default accept list.
324 if (IS_UNDEFINED(arg)) 324 if (IS_UNDEFINED(arg))
325 return arg; 325 return arg;
326 326
327 if (!IS_SPEC_OBJECT(arg)) throw MakeTypeError(kObserveInvalidAccept); 327 if (!IS_RECEIVER(arg)) throw MakeTypeError(kObserveInvalidAccept);
328 328
329 var len = TO_INTEGER(arg.length); 329 var len = TO_INTEGER(arg.length);
330 if (len < 0) len = 0; 330 if (len < 0) len = 0;
331 331
332 return TypeMapCreateFromList(arg, len); 332 return TypeMapCreateFromList(arg, len);
333 } 333 }
334 334
335 335
336 // CallbackInfo's optimized state is just a number which represents its global 336 // CallbackInfo's optimized state is just a number which represents its global
337 // priority. When a change record must be enqueued for the callback, it 337 // priority. When a change record must be enqueued for the callback, it
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
373 var priority = callbackInfo; 373 var priority = callbackInfo;
374 callbackInfo = new InternalArray; 374 callbackInfo = new InternalArray;
375 callbackInfo.priority = priority; 375 callbackInfo.priority = priority;
376 CallbackInfoSet(callback, callbackInfo); 376 CallbackInfoSet(callback, callbackInfo);
377 } 377 }
378 return callbackInfo; 378 return callbackInfo;
379 } 379 }
380 380
381 381
382 function ObjectObserve(object, callback, acceptList) { 382 function ObjectObserve(object, callback, acceptList) {
383 if (!IS_SPEC_OBJECT(object)) 383 if (!IS_RECEIVER(object))
384 throw MakeTypeError(kObserveNonObject, "observe", "observe"); 384 throw MakeTypeError(kObserveNonObject, "observe", "observe");
385 if (%IsJSGlobalProxy(object)) 385 if (%IsJSGlobalProxy(object))
386 throw MakeTypeError(kObserveGlobalProxy, "observe"); 386 throw MakeTypeError(kObserveGlobalProxy, "observe");
387 if (%IsAccessCheckNeeded(object)) 387 if (%IsAccessCheckNeeded(object))
388 throw MakeTypeError(kObserveAccessChecked, "observe"); 388 throw MakeTypeError(kObserveAccessChecked, "observe");
389 if (!IS_CALLABLE(callback)) 389 if (!IS_CALLABLE(callback))
390 throw MakeTypeError(kObserveNonFunction, "observe"); 390 throw MakeTypeError(kObserveNonFunction, "observe");
391 if (ObjectIsFrozen(callback)) 391 if (ObjectIsFrozen(callback))
392 throw MakeTypeError(kObserveCallbackFrozen); 392 throw MakeTypeError(kObserveCallbackFrozen);
393 393
394 var objectObserveFn = %GetObjectContextObjectObserve(object); 394 var objectObserveFn = %GetObjectContextObjectObserve(object);
395 return objectObserveFn(object, callback, acceptList); 395 return objectObserveFn(object, callback, acceptList);
396 } 396 }
397 397
398 398
399 function NativeObjectObserve(object, callback, acceptList) { 399 function NativeObjectObserve(object, callback, acceptList) {
400 var objectInfo = ObjectInfoGetOrCreate(object); 400 var objectInfo = ObjectInfoGetOrCreate(object);
401 var typeList = ConvertAcceptListToTypeMap(acceptList); 401 var typeList = ConvertAcceptListToTypeMap(acceptList);
402 ObjectInfoAddObserver(objectInfo, callback, typeList); 402 ObjectInfoAddObserver(objectInfo, callback, typeList);
403 return object; 403 return object;
404 } 404 }
405 405
406 406
407 function ObjectUnobserve(object, callback) { 407 function ObjectUnobserve(object, callback) {
408 if (!IS_SPEC_OBJECT(object)) 408 if (!IS_RECEIVER(object))
409 throw MakeTypeError(kObserveNonObject, "unobserve", "unobserve"); 409 throw MakeTypeError(kObserveNonObject, "unobserve", "unobserve");
410 if (%IsJSGlobalProxy(object)) 410 if (%IsJSGlobalProxy(object))
411 throw MakeTypeError(kObserveGlobalProxy, "unobserve"); 411 throw MakeTypeError(kObserveGlobalProxy, "unobserve");
412 if (!IS_CALLABLE(callback)) 412 if (!IS_CALLABLE(callback))
413 throw MakeTypeError(kObserveNonFunction, "unobserve"); 413 throw MakeTypeError(kObserveNonFunction, "unobserve");
414 414
415 var objectInfo = ObjectInfoGet(object); 415 var objectInfo = ObjectInfoGet(object);
416 if (IS_UNDEFINED(objectInfo)) 416 if (IS_UNDEFINED(objectInfo))
417 return object; 417 return object;
418 418
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after
557 oldValue: oldValue 557 oldValue: oldValue
558 }; 558 };
559 } 559 }
560 560
561 ObjectFreeze(changeRecord); 561 ObjectFreeze(changeRecord);
562 ObjectInfoEnqueueInternalChangeRecord(objectInfo, changeRecord); 562 ObjectInfoEnqueueInternalChangeRecord(objectInfo, changeRecord);
563 } 563 }
564 564
565 565
566 function ObjectNotifierNotify(changeRecord) { 566 function ObjectNotifierNotify(changeRecord) {
567 if (!IS_SPEC_OBJECT(this)) 567 if (!IS_RECEIVER(this))
568 throw MakeTypeError(kCalledOnNonObject, "notify"); 568 throw MakeTypeError(kCalledOnNonObject, "notify");
569 569
570 var objectInfo = ObjectInfoGetFromNotifier(this); 570 var objectInfo = ObjectInfoGetFromNotifier(this);
571 if (IS_UNDEFINED(objectInfo)) 571 if (IS_UNDEFINED(objectInfo))
572 throw MakeTypeError(kObserveNotifyNonNotifier); 572 throw MakeTypeError(kObserveNotifyNonNotifier);
573 if (!IS_STRING(changeRecord.type)) 573 if (!IS_STRING(changeRecord.type))
574 throw MakeTypeError(kObserveTypeNonString); 574 throw MakeTypeError(kObserveTypeNonString);
575 575
576 ObjectInfoEnqueueExternalChangeRecord(objectInfo, changeRecord); 576 ObjectInfoEnqueueExternalChangeRecord(objectInfo, changeRecord);
577 } 577 }
578 578
579 579
580 function ObjectNotifierPerformChange(changeType, changeFn) { 580 function ObjectNotifierPerformChange(changeType, changeFn) {
581 if (!IS_SPEC_OBJECT(this)) 581 if (!IS_RECEIVER(this))
582 throw MakeTypeError(kCalledOnNonObject, "performChange"); 582 throw MakeTypeError(kCalledOnNonObject, "performChange");
583 583
584 var objectInfo = ObjectInfoGetFromNotifier(this); 584 var objectInfo = ObjectInfoGetFromNotifier(this);
585 if (IS_UNDEFINED(objectInfo)) 585 if (IS_UNDEFINED(objectInfo))
586 throw MakeTypeError(kObserveNotifyNonNotifier); 586 throw MakeTypeError(kObserveNotifyNonNotifier);
587 if (!IS_STRING(changeType)) 587 if (!IS_STRING(changeType))
588 throw MakeTypeError(kObservePerformNonString); 588 throw MakeTypeError(kObservePerformNonString);
589 if (!IS_CALLABLE(changeFn)) 589 if (!IS_CALLABLE(changeFn))
590 throw MakeTypeError(kObservePerformNonFunction); 590 throw MakeTypeError(kObservePerformNonFunction);
591 591
592 var performChangeFn = %GetObjectContextNotifierPerformChange(objectInfo); 592 var performChangeFn = %GetObjectContextNotifierPerformChange(objectInfo);
593 performChangeFn(objectInfo, changeType, changeFn); 593 performChangeFn(objectInfo, changeType, changeFn);
594 } 594 }
595 595
596 596
597 function NativeObjectNotifierPerformChange(objectInfo, changeType, changeFn) { 597 function NativeObjectNotifierPerformChange(objectInfo, changeType, changeFn) {
598 ObjectInfoAddPerformingType(objectInfo, changeType); 598 ObjectInfoAddPerformingType(objectInfo, changeType);
599 599
600 var changeRecord; 600 var changeRecord;
601 try { 601 try {
602 changeRecord = changeFn(); 602 changeRecord = changeFn();
603 } finally { 603 } finally {
604 ObjectInfoRemovePerformingType(objectInfo, changeType); 604 ObjectInfoRemovePerformingType(objectInfo, changeType);
605 } 605 }
606 606
607 if (IS_SPEC_OBJECT(changeRecord)) 607 if (IS_RECEIVER(changeRecord))
608 ObjectInfoEnqueueExternalChangeRecord(objectInfo, changeRecord, changeType); 608 ObjectInfoEnqueueExternalChangeRecord(objectInfo, changeRecord, changeType);
609 } 609 }
610 610
611 611
612 function ObjectGetNotifier(object) { 612 function ObjectGetNotifier(object) {
613 if (!IS_SPEC_OBJECT(object)) 613 if (!IS_RECEIVER(object))
614 throw MakeTypeError(kObserveNonObject, "getNotifier", "getNotifier"); 614 throw MakeTypeError(kObserveNonObject, "getNotifier", "getNotifier");
615 if (%IsJSGlobalProxy(object)) 615 if (%IsJSGlobalProxy(object))
616 throw MakeTypeError(kObserveGlobalProxy, "getNotifier"); 616 throw MakeTypeError(kObserveGlobalProxy, "getNotifier");
617 if (%IsAccessCheckNeeded(object)) 617 if (%IsAccessCheckNeeded(object))
618 throw MakeTypeError(kObserveAccessChecked, "getNotifier"); 618 throw MakeTypeError(kObserveAccessChecked, "getNotifier");
619 619
620 if (ObjectIsFrozen(object)) return null; 620 if (ObjectIsFrozen(object)) return null;
621 621
622 if (!%ObjectWasCreatedInCurrentOrigin(object)) return null; 622 if (!%ObjectWasCreatedInCurrentOrigin(object)) return null;
623 623
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
712 712
713 utils.Export(function(to) { 713 utils.Export(function(to) {
714 to.ObserveArrayMethods = ObserveArrayMethods; 714 to.ObserveArrayMethods = ObserveArrayMethods;
715 to.ObserveBeginPerformSplice = BeginPerformSplice; 715 to.ObserveBeginPerformSplice = BeginPerformSplice;
716 to.ObserveEndPerformSplice = EndPerformSplice; 716 to.ObserveEndPerformSplice = EndPerformSplice;
717 to.ObserveEnqueueSpliceRecord = EnqueueSpliceRecord; 717 to.ObserveEnqueueSpliceRecord = EnqueueSpliceRecord;
718 to.ObserveObjectMethods = ObserveObjectMethods; 718 to.ObserveObjectMethods = ObserveObjectMethods;
719 }); 719 });
720 720
721 }) 721 })
OLDNEW
« no previous file with comments | « src/js/messages.js ('k') | src/js/promise.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698