| 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. |
| 876 AllocateUnaligned(new_space, 48); |
| 877 CHECK_EQ(observer2.count(), 3); |
| 878 new_space->PauseInlineAllocationObservers(); |
| 879 CHECK_EQ(observer2.count(), 3); |
| 880 AllocateUnaligned(new_space, 384); |
| 881 CHECK_EQ(observer2.count(), 3); |
| 882 new_space->ResumeInlineAllocationObservers(); |
| 883 CHECK_EQ(observer2.count(), 3); |
| 884 // Coupled with the 48 bytes allocated before the pause, another 48 bytes |
| 885 // allocated here should trigger a notification. |
| 886 AllocateUnaligned(new_space, 48); |
| 887 CHECK_EQ(observer2.count(), 4); |
| 888 |
| 875 new_space->RemoveInlineAllocationObserver(&observer2); | 889 new_space->RemoveInlineAllocationObserver(&observer2); |
| 876 AllocateUnaligned(new_space, 384); | 890 AllocateUnaligned(new_space, 384); |
| 877 CHECK_EQ(observer1.count(), 20); | 891 CHECK_EQ(observer1.count(), 20); |
| 878 CHECK_EQ(observer2.count(), 3); | 892 CHECK_EQ(observer2.count(), 4); |
| 879 } | 893 } |
| 880 isolate->Dispose(); | 894 isolate->Dispose(); |
| 881 } | 895 } |
| 882 | 896 |
| 883 | 897 |
| 884 UNINITIALIZED_TEST(InlineAllocationObserverCadence) { | 898 UNINITIALIZED_TEST(InlineAllocationObserverCadence) { |
| 885 v8::Isolate::CreateParams create_params; | 899 v8::Isolate::CreateParams create_params; |
| 886 create_params.array_buffer_allocator = CcTest::array_buffer_allocator(); | 900 create_params.array_buffer_allocator = CcTest::array_buffer_allocator(); |
| 887 v8::Isolate* isolate = v8::Isolate::New(create_params); | 901 v8::Isolate* isolate = v8::Isolate::New(create_params); |
| 888 { | 902 { |
| (...skipping 18 matching lines...) Expand all Loading... |
| 907 new_space->RemoveInlineAllocationObserver(&observer2); | 921 new_space->RemoveInlineAllocationObserver(&observer2); |
| 908 | 922 |
| 909 CHECK_EQ(observer1.count(), 32); | 923 CHECK_EQ(observer1.count(), 32); |
| 910 CHECK_EQ(observer2.count(), 28); | 924 CHECK_EQ(observer2.count(), 28); |
| 911 } | 925 } |
| 912 isolate->Dispose(); | 926 isolate->Dispose(); |
| 913 } | 927 } |
| 914 | 928 |
| 915 } // namespace internal | 929 } // namespace internal |
| 916 } // namespace v8 | 930 } // namespace v8 |
| OLD | NEW |