| OLD | NEW |
| 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 549 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 560 | 560 |
| 561 // Clear the pending change records from callback and return it to its | 561 // Clear the pending change records from callback and return it to its |
| 562 // "optimized" state. | 562 // "optimized" state. |
| 563 var priority = callbackInfo.priority; | 563 var priority = callbackInfo.priority; |
| 564 CallbackInfoSet(callback, priority); | 564 CallbackInfoSet(callback, priority); |
| 565 | 565 |
| 566 var pendingObservers = GetPendingObservers(); | 566 var pendingObservers = GetPendingObservers(); |
| 567 if (!IS_NULL(pendingObservers)) | 567 if (!IS_NULL(pendingObservers)) |
| 568 delete pendingObservers[priority]; | 568 delete pendingObservers[priority]; |
| 569 | 569 |
| 570 // TODO: combine the following runtime calls for perf optimization. |
| 570 var delivered = []; | 571 var delivered = []; |
| 571 %MoveArrayContents(callbackInfo, delivered); | 572 %MoveArrayContents(callbackInfo, delivered); |
| 573 %DeliverObservationChangeRecords(callback, delivered); |
| 572 | 574 |
| 573 try { | |
| 574 %_CallFunction(UNDEFINED, delivered, callback); | |
| 575 } catch (ex) {} // TODO(rossberg): perhaps log uncaught exceptions. | |
| 576 return true; | 575 return true; |
| 577 } | 576 } |
| 578 | 577 |
| 579 function ObjectDeliverChangeRecords(callback) { | 578 function ObjectDeliverChangeRecords(callback) { |
| 580 if (!IS_SPEC_FUNCTION(callback)) | 579 if (!IS_SPEC_FUNCTION(callback)) |
| 581 throw MakeTypeError("observe_non_function", ["deliverChangeRecords"]); | 580 throw MakeTypeError("observe_non_function", ["deliverChangeRecords"]); |
| 582 | 581 |
| 583 while (CallbackDeliverPending(callback)) {} | 582 while (CallbackDeliverPending(callback)) {} |
| 584 } | 583 } |
| 585 | 584 |
| (...skipping 19 matching lines...) Expand all Loading... |
| 605 "observe", ArrayObserve, | 604 "observe", ArrayObserve, |
| 606 "unobserve", ArrayUnobserve | 605 "unobserve", ArrayUnobserve |
| 607 )); | 606 )); |
| 608 InstallFunctions(notifierPrototype, DONT_ENUM, $Array( | 607 InstallFunctions(notifierPrototype, DONT_ENUM, $Array( |
| 609 "notify", ObjectNotifierNotify, | 608 "notify", ObjectNotifierNotify, |
| 610 "performChange", ObjectNotifierPerformChange | 609 "performChange", ObjectNotifierPerformChange |
| 611 )); | 610 )); |
| 612 } | 611 } |
| 613 | 612 |
| 614 SetupObjectObserve(); | 613 SetupObjectObserve(); |
| OLD | NEW |