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 6529 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6540 a->Set(v8_str("x"), b); | 6540 a->Set(v8_str("x"), b); |
6541 b->Set(v8_str("x"), a); | 6541 b->Set(v8_str("x"), a); |
6542 } | 6542 } |
6543 if (global_gc) { | 6543 if (global_gc) { |
6544 CcTest::heap()->CollectAllGarbage(); | 6544 CcTest::heap()->CollectAllGarbage(); |
6545 } else { | 6545 } else { |
6546 CcTest::heap()->CollectGarbage(i::NEW_SPACE); | 6546 CcTest::heap()->CollectGarbage(i::NEW_SPACE); |
6547 } | 6547 } |
6548 // We are relying on this creating a big flag array and reserving the space | 6548 // We are relying on this creating a big flag array and reserving the space |
6549 // up front. | 6549 // up front. |
6550 v8::Handle<Value> big_array = CompileRun("new Array(50000)"); | 6550 v8::Handle<Value> big_array = CompileRun("new Array(5000)"); |
6551 a->Set(v8_str("y"), big_array); | 6551 a->Set(v8_str("y"), big_array); |
6552 big_heap_size = CcTest::heap()->SizeOfObjects(); | 6552 big_heap_size = CcTest::heap()->SizeOfObjects(); |
6553 } | 6553 } |
6554 | 6554 |
6555 object_a.flag = false; | 6555 object_a.flag = false; |
6556 object_b.flag = false; | 6556 object_b.flag = false; |
6557 object_a.handle.SetWeak(&object_a, &SetFlag, | 6557 object_a.handle.SetWeak(&object_a, &SetFlag, |
6558 v8::WeakCallbackType::kParameter); | 6558 v8::WeakCallbackType::kParameter); |
6559 object_b.handle.SetWeak(&object_b, &SetFlag, | 6559 object_b.handle.SetWeak(&object_b, &SetFlag, |
6560 v8::WeakCallbackType::kParameter); | 6560 v8::WeakCallbackType::kParameter); |
6561 CHECK(!object_b.handle.IsIndependent()); | 6561 CHECK(!object_b.handle.IsIndependent()); |
6562 object_a.handle.MarkIndependent(); | 6562 object_a.handle.MarkIndependent(); |
6563 object_b.handle.MarkIndependent(); | 6563 object_b.handle.MarkIndependent(); |
6564 CHECK(object_b.handle.IsIndependent()); | 6564 CHECK(object_b.handle.IsIndependent()); |
6565 if (global_gc) { | 6565 if (global_gc) { |
6566 CcTest::heap()->CollectAllGarbage(); | 6566 CcTest::heap()->CollectAllGarbage(); |
6567 } else { | 6567 } else { |
6568 CcTest::heap()->CollectGarbage(i::NEW_SPACE); | 6568 CcTest::heap()->CollectGarbage(i::NEW_SPACE); |
6569 } | 6569 } |
6570 // A single GC should be enough to reclaim the memory, since we are using | 6570 // A single GC should be enough to reclaim the memory, since we are using |
6571 // phantom handles. | 6571 // phantom handles. |
6572 CHECK_LT(CcTest::heap()->SizeOfObjects(), big_heap_size - 200000); | 6572 CHECK_LT(CcTest::heap()->SizeOfObjects(), big_heap_size - 20000); |
6573 CHECK(object_a.flag); | 6573 CHECK(object_a.flag); |
6574 CHECK(object_b.flag); | 6574 CHECK(object_b.flag); |
6575 } | 6575 } |
6576 | 6576 |
6577 | 6577 |
6578 TEST(IndependentWeakHandle) { | 6578 TEST(IndependentWeakHandle) { |
6579 IndependentWeakHandle(false, false); | 6579 IndependentWeakHandle(false, false); |
6580 IndependentWeakHandle(false, true); | 6580 IndependentWeakHandle(false, true); |
6581 IndependentWeakHandle(true, false); | 6581 IndependentWeakHandle(true, false); |
6582 IndependentWeakHandle(true, true); | 6582 IndependentWeakHandle(true, true); |
(...skipping 15310 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
21893 ExpectTrue("object[Symbol.isConcatSpreadable]"); | 21893 ExpectTrue("object[Symbol.isConcatSpreadable]"); |
21894 | 21894 |
21895 // If access check fails, the value of @@isConcatSpreadable is ignored | 21895 // If access check fails, the value of @@isConcatSpreadable is ignored |
21896 allowed_access = false; | 21896 allowed_access = false; |
21897 CompileRun("var result = [].concat(object)"); | 21897 CompileRun("var result = [].concat(object)"); |
21898 ExpectTrue("Array.isArray(result)"); | 21898 ExpectTrue("Array.isArray(result)"); |
21899 ExpectTrue("result[0] === object"); | 21899 ExpectTrue("result[0] === object"); |
21900 ExpectTrue("result.length === 1"); | 21900 ExpectTrue("result.length === 1"); |
21901 ExpectTrue("object[Symbol.isConcatSpreadable] === undefined"); | 21901 ExpectTrue("object[Symbol.isConcatSpreadable] === undefined"); |
21902 } | 21902 } |
OLD | NEW |