| 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 15969 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  15980   i::Factory* factory = CcTest::i_isolate()->factory(); |  15980   i::Factory* factory = CcTest::i_isolate()->factory(); | 
|  15981   v8::HandleScope scope(CcTest::isolate()); |  15981   v8::HandleScope scope(CcTest::isolate()); | 
|  15982   i::AlwaysAllocateScope always_allocate(CcTest::i_isolate()); |  15982   i::AlwaysAllocateScope always_allocate(CcTest::i_isolate()); | 
|  15983   for (int i = 0; i < 1000; i++) { |  15983   for (int i = 0; i < 1000; i++) { | 
|  15984     factory->NewFixedArray(1000, i::TENURED); |  15984     factory->NewFixedArray(1000, i::TENURED); | 
|  15985   } |  15985   } | 
|  15986 } |  15986 } | 
|  15987  |  15987  | 
|  15988  |  15988  | 
|  15989 // Test that idle notification can be handled and eventually collects garbage. |  15989 // Test that idle notification can be handled and eventually collects garbage. | 
|  15990 TEST(IdleNotificationWithSmallHint) { |  15990 TEST(TestIdleNotification) { | 
|  15991   const intptr_t MB = 1024 * 1024; |  | 
|  15992   const double IdlePauseInSeconds = 0.9; |  | 
|  15993   LocalContext env; |  | 
|  15994   v8::HandleScope scope(env->GetIsolate()); |  | 
|  15995   intptr_t initial_size = CcTest::heap()->SizeOfObjects(); |  | 
|  15996   CreateGarbageInOldSpace(); |  | 
|  15997   intptr_t size_with_garbage = CcTest::heap()->SizeOfObjects(); |  | 
|  15998   CHECK_GT(size_with_garbage, initial_size + MB); |  | 
|  15999   bool finished = false; |  | 
|  16000   for (int i = 0; i < 200 && !finished; i++) { |  | 
|  16001     finished = env->GetIsolate()->IdleNotificationDeadline( |  | 
|  16002         (v8::base::TimeTicks::HighResolutionNow().ToInternalValue() / |  | 
|  16003          static_cast<double>(v8::base::Time::kMicrosecondsPerSecond)) + |  | 
|  16004         IdlePauseInSeconds); |  | 
|  16005   } |  | 
|  16006   intptr_t final_size = CcTest::heap()->SizeOfObjects(); |  | 
|  16007   CHECK(finished); |  | 
|  16008   CHECK_LT(final_size, initial_size + 1); |  | 
|  16009 } |  | 
|  16010  |  | 
|  16011  |  | 
|  16012 // Test that idle notification can be handled and eventually collects garbage. |  | 
|  16013 TEST(IdleNotificationWithLargeHint) { |  | 
|  16014   const intptr_t MB = 1024 * 1024; |  15991   const intptr_t MB = 1024 * 1024; | 
|  16015   const double IdlePauseInSeconds = 1.0; |  15992   const double IdlePauseInSeconds = 1.0; | 
|  16016   LocalContext env; |  15993   LocalContext env; | 
|  16017   v8::HandleScope scope(env->GetIsolate()); |  15994   v8::HandleScope scope(env->GetIsolate()); | 
|  16018   intptr_t initial_size = CcTest::heap()->SizeOfObjects(); |  15995   intptr_t initial_size = CcTest::heap()->SizeOfObjects(); | 
|  16019   CreateGarbageInOldSpace(); |  15996   CreateGarbageInOldSpace(); | 
|  16020   intptr_t size_with_garbage = CcTest::heap()->SizeOfObjects(); |  15997   intptr_t size_with_garbage = CcTest::heap()->SizeOfObjects(); | 
|  16021   CHECK_GT(size_with_garbage, initial_size + MB); |  15998   CHECK_GT(size_with_garbage, initial_size + MB); | 
|  16022   bool finished = false; |  15999   bool finished = false; | 
|  16023   for (int i = 0; i < 200 && !finished; i++) { |  16000   for (int i = 0; i < 200 && !finished; i++) { | 
| (...skipping 5869 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  21893   } |  21870   } | 
|  21894   { |  21871   { | 
|  21895     v8::TryCatch try_catch; |  21872     v8::TryCatch try_catch; | 
|  21896     uint16_t* data = reinterpret_cast<uint16_t*>(buffer); |  21873     uint16_t* data = reinterpret_cast<uint16_t*>(buffer); | 
|  21897     CHECK(v8::String::NewFromTwoByte(isolate, data, v8::String::kNormalString, |  21874     CHECK(v8::String::NewFromTwoByte(isolate, data, v8::String::kNormalString, | 
|  21898                                      length).IsEmpty()); |  21875                                      length).IsEmpty()); | 
|  21899     CHECK(!try_catch.HasCaught()); |  21876     CHECK(!try_catch.HasCaught()); | 
|  21900   } |  21877   } | 
|  21901   free(buffer); |  21878   free(buffer); | 
|  21902 } |  21879 } | 
| OLD | NEW |