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 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
43 #include "src/base/smart-pointers.h" | 43 #include "src/base/smart-pointers.h" |
44 #include "src/compilation-cache.h" | 44 #include "src/compilation-cache.h" |
45 #include "src/debug/debug.h" | 45 #include "src/debug/debug.h" |
46 #include "src/execution.h" | 46 #include "src/execution.h" |
47 #include "src/futex-emulation.h" | 47 #include "src/futex-emulation.h" |
48 #include "src/objects.h" | 48 #include "src/objects.h" |
49 #include "src/parser.h" | 49 #include "src/parser.h" |
50 #include "src/unicode-inl.h" | 50 #include "src/unicode-inl.h" |
51 #include "src/utils.h" | 51 #include "src/utils.h" |
52 #include "src/vm-state.h" | 52 #include "src/vm-state.h" |
| 53 #include "test/cctest/heap-tester.h" |
53 | 54 |
54 static const bool kLogThreading = false; | 55 static const bool kLogThreading = false; |
55 | 56 |
56 using ::v8::Boolean; | 57 using ::v8::Boolean; |
57 using ::v8::BooleanObject; | 58 using ::v8::BooleanObject; |
58 using ::v8::Context; | 59 using ::v8::Context; |
59 using ::v8::Extension; | 60 using ::v8::Extension; |
60 using ::v8::Function; | 61 using ::v8::Function; |
61 using ::v8::FunctionTemplate; | 62 using ::v8::FunctionTemplate; |
62 using ::v8::Handle; | 63 using ::v8::Handle; |
(...skipping 6616 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6679 | 6680 |
6680 static void ResetUseValueAndSetFlag( | 6681 static void ResetUseValueAndSetFlag( |
6681 const v8::WeakCallbackInfo<FlagAndPersistent>& data) { | 6682 const v8::WeakCallbackInfo<FlagAndPersistent>& data) { |
6682 // Blink will reset the handle, and then use the other handle, so they | 6683 // Blink will reset the handle, and then use the other handle, so they |
6683 // can't use the same backing slot. | 6684 // can't use the same backing slot. |
6684 data.GetParameter()->handle.Reset(); | 6685 data.GetParameter()->handle.Reset(); |
6685 data.GetParameter()->flag = true; | 6686 data.GetParameter()->flag = true; |
6686 } | 6687 } |
6687 | 6688 |
6688 | 6689 |
6689 static void ResetWeakHandle(bool global_gc) { | 6690 void v8::internal::HeapTester::ResetWeakHandle(bool global_gc) { |
| 6691 using v8::Context; |
| 6692 using v8::Local; |
| 6693 using v8::Object; |
| 6694 |
6690 v8::Isolate* iso = CcTest::isolate(); | 6695 v8::Isolate* iso = CcTest::isolate(); |
6691 v8::HandleScope scope(iso); | 6696 v8::HandleScope scope(iso); |
6692 v8::Handle<Context> context = Context::New(iso); | 6697 v8::Handle<Context> context = Context::New(iso); |
6693 Context::Scope context_scope(context); | 6698 Context::Scope context_scope(context); |
6694 | 6699 |
6695 FlagAndPersistent object_a, object_b; | 6700 FlagAndPersistent object_a, object_b; |
6696 | 6701 |
6697 { | 6702 { |
6698 v8::HandleScope handle_scope(iso); | 6703 v8::HandleScope handle_scope(iso); |
6699 Local<Object> a(v8::Object::New(iso)); | 6704 Local<Object> a(v8::Object::New(iso)); |
6700 Local<Object> b(v8::Object::New(iso)); | 6705 Local<Object> b(v8::Object::New(iso)); |
6701 object_a.handle.Reset(iso, a); | 6706 object_a.handle.Reset(iso, a); |
6702 object_b.handle.Reset(iso, b); | 6707 object_b.handle.Reset(iso, b); |
6703 if (global_gc) { | 6708 if (global_gc) { |
6704 CcTest::heap()->CollectAllGarbage( | 6709 CcTest::heap()->CollectAllGarbage(Heap::kAbortIncrementalMarkingMask); |
6705 TestHeap::Heap::kAbortIncrementalMarkingMask); | |
6706 } else { | 6710 } else { |
6707 CcTest::heap()->CollectGarbage(i::NEW_SPACE); | 6711 CcTest::heap()->CollectGarbage(i::NEW_SPACE); |
6708 } | 6712 } |
6709 } | 6713 } |
6710 | 6714 |
6711 object_a.flag = false; | 6715 object_a.flag = false; |
6712 object_b.flag = false; | 6716 object_b.flag = false; |
6713 object_a.handle.SetWeak(&object_a, &ResetUseValueAndSetFlag, | 6717 object_a.handle.SetWeak(&object_a, &ResetUseValueAndSetFlag, |
6714 v8::WeakCallbackType::kParameter); | 6718 v8::WeakCallbackType::kParameter); |
6715 object_b.handle.SetWeak(&object_b, &ResetUseValueAndSetFlag, | 6719 object_b.handle.SetWeak(&object_b, &ResetUseValueAndSetFlag, |
6716 v8::WeakCallbackType::kParameter); | 6720 v8::WeakCallbackType::kParameter); |
6717 if (!global_gc) { | 6721 if (!global_gc) { |
6718 object_a.handle.MarkIndependent(); | 6722 object_a.handle.MarkIndependent(); |
6719 object_b.handle.MarkIndependent(); | 6723 object_b.handle.MarkIndependent(); |
6720 CHECK(object_b.handle.IsIndependent()); | 6724 CHECK(object_b.handle.IsIndependent()); |
6721 } | 6725 } |
6722 if (global_gc) { | 6726 if (global_gc) { |
6723 CcTest::heap()->CollectAllGarbage( | 6727 CcTest::heap()->CollectAllGarbage(Heap::kAbortIncrementalMarkingMask); |
6724 TestHeap::Heap::kAbortIncrementalMarkingMask); | |
6725 } else { | 6728 } else { |
6726 CcTest::heap()->CollectGarbage(i::NEW_SPACE); | 6729 CcTest::heap()->CollectGarbage(i::NEW_SPACE); |
6727 } | 6730 } |
6728 CHECK(object_a.flag); | 6731 CHECK(object_a.flag); |
6729 CHECK(object_b.flag); | 6732 CHECK(object_b.flag); |
6730 } | 6733 } |
6731 | 6734 |
6732 | 6735 |
6733 THREADED_TEST(ResetWeakHandle) { | 6736 THREADED_HEAP_TEST(ResetWeakHandle) { |
6734 ResetWeakHandle(false); | 6737 v8::internal::HeapTester::ResetWeakHandle(false); |
6735 ResetWeakHandle(true); | 6738 v8::internal::HeapTester::ResetWeakHandle(true); |
6736 } | 6739 } |
6737 | 6740 |
6738 | 6741 |
6739 static void InvokeScavenge() { CcTest::heap()->CollectGarbage(i::NEW_SPACE); } | 6742 static void InvokeScavenge() { CcTest::heap()->CollectGarbage(i::NEW_SPACE); } |
6740 | 6743 |
6741 | 6744 |
6742 static void InvokeMarkSweep() { CcTest::heap()->CollectAllGarbage(); } | 6745 static void InvokeMarkSweep() { CcTest::heap()->CollectAllGarbage(); } |
6743 | 6746 |
6744 | 6747 |
6745 static void ForceScavenge2( | 6748 static void ForceScavenge2( |
(...skipping 15101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
21847 CHECK(try_catch.HasTerminated()); | 21850 CHECK(try_catch.HasTerminated()); |
21848 } | 21851 } |
21849 | 21852 |
21850 | 21853 |
21851 TEST(EstimatedContextSize) { | 21854 TEST(EstimatedContextSize) { |
21852 v8::Isolate* isolate = CcTest::isolate(); | 21855 v8::Isolate* isolate = CcTest::isolate(); |
21853 v8::HandleScope scope(isolate); | 21856 v8::HandleScope scope(isolate); |
21854 LocalContext env; | 21857 LocalContext env; |
21855 CHECK(50000 < env->EstimatedSize()); | 21858 CHECK(50000 < env->EstimatedSize()); |
21856 } | 21859 } |
OLD | NEW |