| 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 4692 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4703 Handle<HeapObject> value = factory->NewFixedArray(1, NOT_TENURED); | 4703 Handle<HeapObject> value = factory->NewFixedArray(1, NOT_TENURED); |
| 4704 weak_cell1 = inner_scope.CloseAndEscape(factory->NewWeakCell(value)); | 4704 weak_cell1 = inner_scope.CloseAndEscape(factory->NewWeakCell(value)); |
| 4705 } | 4705 } |
| 4706 | 4706 |
| 4707 Handle<FixedArray> survivor = factory->NewFixedArray(1, NOT_TENURED); | 4707 Handle<FixedArray> survivor = factory->NewFixedArray(1, NOT_TENURED); |
| 4708 Handle<WeakCell> weak_cell2; | 4708 Handle<WeakCell> weak_cell2; |
| 4709 { | 4709 { |
| 4710 HandleScope inner_scope(isolate); | 4710 HandleScope inner_scope(isolate); |
| 4711 weak_cell2 = inner_scope.CloseAndEscape(factory->NewWeakCell(survivor)); | 4711 weak_cell2 = inner_scope.CloseAndEscape(factory->NewWeakCell(survivor)); |
| 4712 } | 4712 } |
| 4713 CHECK(weak_cell1->value()->IsFixedArray()); | 4713 CHECK(weak_cell1->ValueNoReadBarrier()->IsFixedArray()); |
| 4714 CHECK_EQ(*survivor, weak_cell2->value()); | 4714 CHECK_EQ(*survivor, weak_cell2->ValueNoReadBarrier()); |
| 4715 heap->CollectGarbage(NEW_SPACE); | 4715 heap->CollectGarbage(NEW_SPACE); |
| 4716 CHECK(weak_cell1->value()->IsFixedArray()); | 4716 CHECK(weak_cell1->ValueNoReadBarrier()->IsFixedArray()); |
| 4717 CHECK_EQ(*survivor, weak_cell2->value()); | 4717 CHECK_EQ(*survivor, weak_cell2->ValueNoReadBarrier()); |
| 4718 heap->CollectGarbage(NEW_SPACE); | 4718 heap->CollectGarbage(NEW_SPACE); |
| 4719 CHECK(weak_cell1->value()->IsFixedArray()); | 4719 CHECK(weak_cell1->ValueNoReadBarrier()->IsFixedArray()); |
| 4720 CHECK_EQ(*survivor, weak_cell2->value()); | 4720 CHECK_EQ(*survivor, weak_cell2->ValueNoReadBarrier()); |
| 4721 heap->CollectAllAvailableGarbage(); | 4721 heap->CollectAllAvailableGarbage(); |
| 4722 CHECK(weak_cell1->cleared()); | 4722 CHECK(weak_cell1->cleared()); |
| 4723 CHECK_EQ(*survivor, weak_cell2->value()); | 4723 CHECK_EQ(*survivor, weak_cell2->ValueNoReadBarrier()); |
| 4724 } | 4724 } |
| 4725 | 4725 |
| 4726 | 4726 |
| 4727 TEST(WeakCellsWithIncrementalMarking) { | 4727 TEST(WeakCellsWithIncrementalMarking) { |
| 4728 CcTest::InitializeVM(); | 4728 CcTest::InitializeVM(); |
| 4729 Isolate* isolate = CcTest::i_isolate(); | 4729 Isolate* isolate = CcTest::i_isolate(); |
| 4730 v8::internal::Heap* heap = CcTest::heap(); | 4730 v8::internal::Heap* heap = CcTest::heap(); |
| 4731 v8::internal::Factory* factory = isolate->factory(); | 4731 v8::internal::Factory* factory = isolate->factory(); |
| 4732 | 4732 |
| 4733 const int N = 16; | 4733 const int N = 16; |
| 4734 HandleScope outer_scope(isolate); | 4734 HandleScope outer_scope(isolate); |
| 4735 Handle<FixedArray> survivor = factory->NewFixedArray(1, NOT_TENURED); | 4735 Handle<FixedArray> survivor = factory->NewFixedArray(1, NOT_TENURED); |
| 4736 Handle<WeakCell> weak_cells[N]; | 4736 Handle<WeakCell> weak_cells[N]; |
| 4737 | 4737 |
| 4738 for (int i = 0; i < N; i++) { | 4738 for (int i = 0; i < N; i++) { |
| 4739 HandleScope inner_scope(isolate); | 4739 HandleScope inner_scope(isolate); |
| 4740 Handle<HeapObject> value = | 4740 Handle<HeapObject> value = |
| 4741 i == 0 ? survivor : factory->NewFixedArray(1, NOT_TENURED); | 4741 i == 0 ? survivor : factory->NewFixedArray(1, NOT_TENURED); |
| 4742 Handle<WeakCell> weak_cell = factory->NewWeakCell(value); | 4742 Handle<WeakCell> weak_cell = factory->NewWeakCell(value); |
| 4743 CHECK(weak_cell->value()->IsFixedArray()); | 4743 CHECK(weak_cell->ValueNoReadBarrier()->IsFixedArray()); |
| 4744 IncrementalMarking* marking = heap->incremental_marking(); | 4744 IncrementalMarking* marking = heap->incremental_marking(); |
| 4745 if (marking->IsStopped()) marking->Start(); | 4745 if (marking->IsStopped()) marking->Start(); |
| 4746 marking->Step(128, IncrementalMarking::NO_GC_VIA_STACK_GUARD); | 4746 marking->Step(128, IncrementalMarking::NO_GC_VIA_STACK_GUARD); |
| 4747 heap->CollectGarbage(NEW_SPACE); | 4747 heap->CollectGarbage(NEW_SPACE); |
| 4748 CHECK(weak_cell->value()->IsFixedArray()); | 4748 CHECK(weak_cell->ValueNoReadBarrier()->IsFixedArray()); |
| 4749 weak_cells[i] = inner_scope.CloseAndEscape(weak_cell); | 4749 weak_cells[i] = inner_scope.CloseAndEscape(weak_cell); |
| 4750 } | 4750 } |
| 4751 heap->CollectAllGarbage(Heap::kNoGCFlags); | 4751 heap->CollectAllGarbage(Heap::kNoGCFlags); |
| 4752 CHECK_EQ(*survivor, weak_cells[0]->value()); | 4752 CHECK_EQ(*survivor, weak_cells[0]->ValueNoReadBarrier()); |
| 4753 for (int i = 1; i < N; i++) { | 4753 for (int i = 1; i < N; i++) { |
| 4754 CHECK(weak_cells[i]->cleared()); | 4754 CHECK(weak_cells[i]->cleared()); |
| 4755 } | 4755 } |
| 4756 } | 4756 } |
| 4757 | 4757 |
| 4758 | 4758 |
| 4759 #ifdef DEBUG | 4759 #ifdef DEBUG |
| 4760 TEST(AddInstructionChangesNewSpacePromotion) { | 4760 TEST(AddInstructionChangesNewSpacePromotion) { |
| 4761 i::FLAG_allow_natives_syntax = true; | 4761 i::FLAG_allow_natives_syntax = true; |
| 4762 i::FLAG_expose_gc = true; | 4762 i::FLAG_expose_gc = true; |
| (...skipping 325 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5088 #ifdef DEBUG | 5088 #ifdef DEBUG |
| 5089 TEST(PathTracer) { | 5089 TEST(PathTracer) { |
| 5090 CcTest::InitializeVM(); | 5090 CcTest::InitializeVM(); |
| 5091 v8::HandleScope scope(CcTest::isolate()); | 5091 v8::HandleScope scope(CcTest::isolate()); |
| 5092 | 5092 |
| 5093 v8::Local<v8::Value> result = CompileRun("'abc'"); | 5093 v8::Local<v8::Value> result = CompileRun("'abc'"); |
| 5094 Handle<Object> o = v8::Utils::OpenHandle(*result); | 5094 Handle<Object> o = v8::Utils::OpenHandle(*result); |
| 5095 CcTest::i_isolate()->heap()->TracePathToObject(*o); | 5095 CcTest::i_isolate()->heap()->TracePathToObject(*o); |
| 5096 } | 5096 } |
| 5097 #endif // DEBUG | 5097 #endif // DEBUG |
| OLD | NEW |