OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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 13693 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
13704 CHECK(CompileRun(source)->IsUndefined()); | 13704 CHECK(CompileRun(source)->IsUndefined()); |
13705 } | 13705 } |
13706 | 13706 |
13707 | 13707 |
13708 // Test that idle notification can be handled and eventually returns true. | 13708 // Test that idle notification can be handled and eventually returns true. |
13709 // This just checks the contract of the IdleNotification() function, | 13709 // This just checks the contract of the IdleNotification() function, |
13710 // and does not verify that it does reasonable work. | 13710 // and does not verify that it does reasonable work. |
13711 THREADED_TEST(IdleNotification) { | 13711 THREADED_TEST(IdleNotification) { |
13712 v8::HandleScope scope; | 13712 v8::HandleScope scope; |
13713 LocalContext env; | 13713 LocalContext env; |
13714 CompileRun("function binom(n, m) {" | 13714 { |
13715 " var C = [[1]];" | 13715 // Create garbage in old-space to generate work for idle notification. |
13716 " for (var i = 1; i <= n; ++i) {" | 13716 i::AlwaysAllocateScope always_allocate; |
13717 " C[i] = [1];" | 13717 for (int i = 0; i < 100; i++) { |
13718 " for (var j = 1; j < i; ++j) {" | 13718 FACTORY->NewFixedArray(1000, i::TENURED); |
13719 " C[i][j] = C[i-1][j-1] + C[i-1][j];" | 13719 } |
13720 " }" | |
13721 " C[i][i] = 1;" | |
13722 " }" | |
13723 " return C[n][m];" | |
13724 "};" | |
13725 "binom(1000, 500)"); | |
13726 bool rv = false; | |
13727 for (int i = 0; i < 100; i++) { | |
13728 rv = v8::V8::IdleNotification(); | |
13729 if (rv) | |
13730 break; | |
13731 } | 13720 } |
13732 CHECK(rv == true); | 13721 bool finshed_idle_work = false; |
| 13722 for (int i = 0; i < 100 && !finshed_idle_work; i++) { |
| 13723 finshed_idle_work = v8::V8::IdleNotification(); |
| 13724 } |
| 13725 CHECK(finshed_idle_work); |
13733 } | 13726 } |
13734 | 13727 |
13735 // Test that idle notification can be handled and eventually returns true. | 13728 // Test that idle notification can be handled and eventually returns true. |
13736 // This just checks the contract of the IdleNotification() function, | 13729 // This just checks the contract of the IdleNotification() function, |
13737 // and does not verify that it does reasonable work. | 13730 // and does not verify that it does reasonable work. |
13738 TEST(IdleNotificationWithHint) { | 13731 TEST(IdleNotificationWithSmallHint) { |
13739 v8::HandleScope scope; | 13732 v8::HandleScope scope; |
13740 LocalContext env; | 13733 LocalContext env; |
13741 { | 13734 { |
| 13735 // Create garbage in old-space to generate work for idle notification. |
13742 i::AlwaysAllocateScope always_allocate; | 13736 i::AlwaysAllocateScope always_allocate; |
13743 CompileRun("function binom(n, m) {" | 13737 for (int i = 0; i < 100; i++) { |
13744 " var C = [[1]];" | 13738 FACTORY->NewFixedArray(1000, i::TENURED); |
13745 " for (var i = 1; i <= n; ++i) {" | 13739 } |
13746 " C[i] = [1];" | |
13747 " for (var j = 1; j < i; ++j) {" | |
13748 " C[i][j] = C[i-1][j-1] + C[i-1][j];" | |
13749 " }" | |
13750 " C[i][i] = 1;" | |
13751 " }" | |
13752 " return C[n][m];" | |
13753 "};" | |
13754 "binom(1000, 500)"); | |
13755 } | 13740 } |
13756 bool rv = false; | |
13757 intptr_t old_size = HEAP->SizeOfObjects(); | 13741 intptr_t old_size = HEAP->SizeOfObjects(); |
| 13742 bool finshed_idle_work = false; |
13758 bool no_idle_work = v8::V8::IdleNotification(10); | 13743 bool no_idle_work = v8::V8::IdleNotification(10); |
13759 for (int i = 0; i < 200; i++) { | 13744 for (int i = 0; i < 200 && !finshed_idle_work; i++) { |
13760 rv = v8::V8::IdleNotification(10); | 13745 finshed_idle_work = v8::V8::IdleNotification(10); |
13761 if (rv) | |
13762 break; | |
13763 } | 13746 } |
13764 CHECK(rv == true); | |
13765 intptr_t new_size = HEAP->SizeOfObjects(); | 13747 intptr_t new_size = HEAP->SizeOfObjects(); |
| 13748 CHECK(finshed_idle_work); |
13766 CHECK(no_idle_work || new_size < old_size); | 13749 CHECK(no_idle_work || new_size < old_size); |
13767 } | 13750 } |
13768 | 13751 |
| 13752 |
| 13753 // This just checks the contract of the IdleNotification() function, |
| 13754 // and does not verify that it does reasonable work. |
| 13755 TEST(IdleNotificationWithLargeHint) { |
| 13756 v8::HandleScope scope; |
| 13757 LocalContext env; |
| 13758 { |
| 13759 // Create garbage in old-space to generate work for idle notification. |
| 13760 i::AlwaysAllocateScope always_allocate; |
| 13761 for (int i = 0; i < 100; i++) { |
| 13762 FACTORY->NewFixedArray(1000, i::TENURED); |
| 13763 } |
| 13764 } |
| 13765 intptr_t old_size = HEAP->SizeOfObjects(); |
| 13766 bool finshed_idle_work = false; |
| 13767 bool no_idle_work = v8::V8::IdleNotification(900); |
| 13768 for (int i = 0; i < 200 && !finshed_idle_work; i++) { |
| 13769 finshed_idle_work = v8::V8::IdleNotification(900); |
| 13770 } |
| 13771 intptr_t new_size = HEAP->SizeOfObjects(); |
| 13772 CHECK(finshed_idle_work); |
| 13773 CHECK(no_idle_work || new_size < old_size); |
| 13774 } |
| 13775 |
13769 | 13776 |
13770 static uint32_t* stack_limit; | 13777 static uint32_t* stack_limit; |
13771 | 13778 |
13772 static v8::Handle<Value> GetStackLimitCallback(const v8::Arguments& args) { | 13779 static v8::Handle<Value> GetStackLimitCallback(const v8::Arguments& args) { |
13773 stack_limit = reinterpret_cast<uint32_t*>( | 13780 stack_limit = reinterpret_cast<uint32_t*>( |
13774 i::Isolate::Current()->stack_guard()->real_climit()); | 13781 i::Isolate::Current()->stack_guard()->real_climit()); |
13775 return v8::Undefined(); | 13782 return v8::Undefined(); |
13776 } | 13783 } |
13777 | 13784 |
13778 | 13785 |
(...skipping 2297 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
16076 CompileRun("throw 'exception';"); | 16083 CompileRun("throw 'exception';"); |
16077 } | 16084 } |
16078 | 16085 |
16079 | 16086 |
16080 TEST(CallCompletedCallbackTwoExceptions) { | 16087 TEST(CallCompletedCallbackTwoExceptions) { |
16081 v8::HandleScope scope; | 16088 v8::HandleScope scope; |
16082 LocalContext env; | 16089 LocalContext env; |
16083 v8::V8::AddCallCompletedCallback(CallCompletedCallbackException); | 16090 v8::V8::AddCallCompletedCallback(CallCompletedCallbackException); |
16084 CompileRun("throw 'first exception';"); | 16091 CompileRun("throw 'first exception';"); |
16085 } | 16092 } |
OLD | NEW |