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

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

Issue 264793015: Fix ObjectNotifierPerformChange leak after r21126 (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Tighten acceptList argument type requirements, remove fuzz-natives blacklist Created 6 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 | src/runtime.h » ('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 "use strict"; 5 "use strict";
6 6
7 // Overview: 7 // Overview:
8 // 8 //
9 // This file contains all of the routing and accounting for Object.observe. 9 // This file contains all of the routing and accounting for Object.observe.
10 // User code will interact with these mechanisms via the Object.observe APIs 10 // User code will interact with these mechanisms via the Object.observe APIs
(...skipping 347 matching lines...) Expand 10 before | Expand all | Expand 10 after
358 throw MakeTypeError("observe_non_object", ["observe"]); 358 throw MakeTypeError("observe_non_object", ["observe"]);
359 if (%IsJSGlobalProxy(object)) 359 if (%IsJSGlobalProxy(object))
360 throw MakeTypeError("observe_global_proxy", ["observe"]); 360 throw MakeTypeError("observe_global_proxy", ["observe"]);
361 if (!IS_SPEC_FUNCTION(callback)) 361 if (!IS_SPEC_FUNCTION(callback))
362 throw MakeTypeError("observe_non_function", ["observe"]); 362 throw MakeTypeError("observe_non_function", ["observe"]);
363 if (ObjectIsFrozen(callback)) 363 if (ObjectIsFrozen(callback))
364 throw MakeTypeError("observe_callback_frozen"); 364 throw MakeTypeError("observe_callback_frozen");
365 if (!AcceptArgIsValid(acceptList)) 365 if (!AcceptArgIsValid(acceptList))
366 throw MakeTypeError("observe_accept_invalid"); 366 throw MakeTypeError("observe_accept_invalid");
367 367
368 return %NativeObjectObserve(object, callback, acceptList); 368 return %ObjectObserveInObjectContext(object, callback, acceptList);
369 } 369 }
370 370
371 function NativeObjectObserve(object, callback, acceptList) { 371 function NativeObjectObserve(object, callback, acceptList) {
372 var objectInfo = ObjectInfoGetOrCreate(object); 372 var objectInfo = ObjectInfoGetOrCreate(object);
373 ObjectInfoAddObserver(objectInfo, callback, acceptList); 373 ObjectInfoAddObserver(objectInfo, callback, acceptList);
374 return object; 374 return object;
375 } 375 }
376 376
377 function ObjectUnobserve(object, callback) { 377 function ObjectUnobserve(object, callback) {
378 if (!IS_SPEC_OBJECT(object)) 378 if (!IS_SPEC_OBJECT(object))
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after
532 throw MakeTypeError("called_on_non_object", ["performChange"]); 532 throw MakeTypeError("called_on_non_object", ["performChange"]);
533 533
534 var objectInfo = ObjectInfoGetFromNotifier(this); 534 var objectInfo = ObjectInfoGetFromNotifier(this);
535 if (IS_UNDEFINED(objectInfo)) 535 if (IS_UNDEFINED(objectInfo))
536 throw MakeTypeError("observe_notify_non_notifier"); 536 throw MakeTypeError("observe_notify_non_notifier");
537 if (!IS_STRING(changeType)) 537 if (!IS_STRING(changeType))
538 throw MakeTypeError("observe_perform_non_string"); 538 throw MakeTypeError("observe_perform_non_string");
539 if (!IS_SPEC_FUNCTION(changeFn)) 539 if (!IS_SPEC_FUNCTION(changeFn))
540 throw MakeTypeError("observe_perform_non_function"); 540 throw MakeTypeError("observe_perform_non_function");
541 541
542 return %NativeObjectNotifierPerformChange(objectInfo, changeType, changeFn) 542 return %ObjectNotifierPerformChangeInObjectContext(
543 objectInfo, changeType, changeFn);
543 } 544 }
544 545
545 function NativeObjectNotifierPerformChange(objectInfo, changeType, changeFn) { 546 function NativeObjectNotifierPerformChange(objectInfo, changeType, changeFn) {
546 ObjectInfoAddPerformingType(objectInfo, changeType); 547 ObjectInfoAddPerformingType(objectInfo, changeType);
547 548
548 var changeRecord; 549 var changeRecord;
549 try { 550 try {
550 changeRecord = %_CallFunction(UNDEFINED, changeFn); 551 changeRecord = %_CallFunction(UNDEFINED, changeFn);
551 } finally { 552 } finally {
552 ObjectInfoRemovePerformingType(objectInfo, changeType); 553 ObjectInfoRemovePerformingType(objectInfo, changeType);
553 } 554 }
554 555
555 if (IS_SPEC_OBJECT(changeRecord)) 556 if (IS_SPEC_OBJECT(changeRecord))
556 ObjectInfoEnqueueExternalChangeRecord(objectInfo, changeRecord, changeType); 557 ObjectInfoEnqueueExternalChangeRecord(objectInfo, changeRecord, changeType);
557 } 558 }
558 559
559 function ObjectGetNotifier(object) { 560 function ObjectGetNotifier(object) {
560 if (!IS_SPEC_OBJECT(object)) 561 if (!IS_SPEC_OBJECT(object))
561 throw MakeTypeError("observe_non_object", ["getNotifier"]); 562 throw MakeTypeError("observe_non_object", ["getNotifier"]);
562 if (%IsJSGlobalProxy(object)) 563 if (%IsJSGlobalProxy(object))
563 throw MakeTypeError("observe_global_proxy", ["getNotifier"]); 564 throw MakeTypeError("observe_global_proxy", ["getNotifier"]);
564 565
565 if (ObjectIsFrozen(object)) return null; 566 if (ObjectIsFrozen(object)) return null;
566 567
567 if (!%ObjectWasCreatedInCurrentOrigin(object)) return null; 568 if (!%ObjectWasCreatedInCurrentOrigin(object)) return null;
568 569
569 return %NativeObjectGetNotifier(object); 570 return %ObjectGetNotifierInObjectContext(object);
570 } 571 }
571 572
572 function NativeObjectGetNotifier(object) { 573 function NativeObjectGetNotifier(object) {
573 var objectInfo = ObjectInfoGetOrCreate(object); 574 var objectInfo = ObjectInfoGetOrCreate(object);
574 return ObjectInfoGetNotifier(objectInfo); 575 return ObjectInfoGetNotifier(objectInfo);
575 } 576 }
576 577
577 function CallbackDeliverPending(callback) { 578 function CallbackDeliverPending(callback) {
578 var callbackInfo = GetCallbackInfoMap().get(callback); 579 var callbackInfo = GetCallbackInfoMap().get(callback);
579 if (IS_UNDEFINED(callbackInfo) || IS_NUMBER(callbackInfo)) 580 if (IS_UNDEFINED(callbackInfo) || IS_NUMBER(callbackInfo))
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
625 "observe", ArrayObserve, 626 "observe", ArrayObserve,
626 "unobserve", ArrayUnobserve 627 "unobserve", ArrayUnobserve
627 )); 628 ));
628 InstallFunctions(notifierPrototype, DONT_ENUM, $Array( 629 InstallFunctions(notifierPrototype, DONT_ENUM, $Array(
629 "notify", ObjectNotifierNotify, 630 "notify", ObjectNotifierNotify,
630 "performChange", ObjectNotifierPerformChange 631 "performChange", ObjectNotifierPerformChange
631 )); 632 ));
632 } 633 }
633 634
634 SetupObjectObserve(); 635 SetupObjectObserve();
OLDNEW
« no previous file with comments | « no previous file | src/runtime.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698