| OLD | NEW |
| 1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 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 854 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 865 CHECK_EQ(observer1.count(), 20); | 865 CHECK_EQ(observer1.count(), 20); |
| 866 CHECK_EQ(observer2.count(), 2); | 866 CHECK_EQ(observer2.count(), 2); |
| 867 | 867 |
| 868 // Callback should stop getting called after an observer is removed. | 868 // Callback should stop getting called after an observer is removed. |
| 869 new_space->RemoveInlineAllocationObserver(&observer1); | 869 new_space->RemoveInlineAllocationObserver(&observer1); |
| 870 | 870 |
| 871 AllocateUnaligned(new_space, 384); | 871 AllocateUnaligned(new_space, 384); |
| 872 CHECK_EQ(observer1.count(), 20); // no more notifications. | 872 CHECK_EQ(observer1.count(), 20); // no more notifications. |
| 873 CHECK_EQ(observer2.count(), 3); // this one is still active. | 873 CHECK_EQ(observer2.count(), 3); // this one is still active. |
| 874 | 874 |
| 875 // Ensure that Pause/ResumeInlineAllocationObservers work correctly. | 875 // Ensure that PauseInlineAllocationObserversScope work correctly. |
| 876 AllocateUnaligned(new_space, 48); | 876 AllocateUnaligned(new_space, 48); |
| 877 CHECK_EQ(observer2.count(), 3); | 877 CHECK_EQ(observer2.count(), 3); |
| 878 new_space->PauseInlineAllocationObservers(); | 878 { |
| 879 CHECK_EQ(observer2.count(), 3); | 879 PauseInlineAllocationObserversScope pause_observers(new_space); |
| 880 AllocateUnaligned(new_space, 384); | 880 CHECK_EQ(observer2.count(), 3); |
| 881 CHECK_EQ(observer2.count(), 3); | 881 AllocateUnaligned(new_space, 384); |
| 882 new_space->ResumeInlineAllocationObservers(); | 882 CHECK_EQ(observer2.count(), 3); |
| 883 } |
| 883 CHECK_EQ(observer2.count(), 3); | 884 CHECK_EQ(observer2.count(), 3); |
| 884 // Coupled with the 48 bytes allocated before the pause, another 48 bytes | 885 // Coupled with the 48 bytes allocated before the pause, another 48 bytes |
| 885 // allocated here should trigger a notification. | 886 // allocated here should trigger a notification. |
| 886 AllocateUnaligned(new_space, 48); | 887 AllocateUnaligned(new_space, 48); |
| 887 CHECK_EQ(observer2.count(), 4); | 888 CHECK_EQ(observer2.count(), 4); |
| 888 | 889 |
| 889 new_space->RemoveInlineAllocationObserver(&observer2); | 890 new_space->RemoveInlineAllocationObserver(&observer2); |
| 890 AllocateUnaligned(new_space, 384); | 891 AllocateUnaligned(new_space, 384); |
| 891 CHECK_EQ(observer1.count(), 20); | 892 CHECK_EQ(observer1.count(), 20); |
| 892 CHECK_EQ(observer2.count(), 4); | 893 CHECK_EQ(observer2.count(), 4); |
| (...skipping 28 matching lines...) Expand all Loading... |
| 921 new_space->RemoveInlineAllocationObserver(&observer2); | 922 new_space->RemoveInlineAllocationObserver(&observer2); |
| 922 | 923 |
| 923 CHECK_EQ(observer1.count(), 32); | 924 CHECK_EQ(observer1.count(), 32); |
| 924 CHECK_EQ(observer2.count(), 28); | 925 CHECK_EQ(observer2.count(), 28); |
| 925 } | 926 } |
| 926 isolate->Dispose(); | 927 isolate->Dispose(); |
| 927 } | 928 } |
| 928 | 929 |
| 929 } // namespace internal | 930 } // namespace internal |
| 930 } // namespace v8 | 931 } // namespace v8 |
| OLD | NEW |