OLD | NEW |
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
4 | 4 |
5 // TODO(zra): Remove when tests are ready to enable. | 5 // TODO(zra): Remove when tests are ready to enable. |
6 #include "platform/globals.h" | 6 #include "platform/globals.h" |
7 | 7 |
8 #include "vm/assembler.h" | 8 #include "vm/assembler.h" |
9 #include "vm/bigint_operations.h" | 9 #include "vm/bigint_operations.h" |
10 #include "vm/class_finalizer.h" | 10 #include "vm/class_finalizer.h" |
(...skipping 2043 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2054 left_over_array ^= obj.raw(); | 2054 left_over_array ^= obj.raw(); |
2055 EXPECT_EQ((6 * kWordSize), left_over_array.Length()); | 2055 EXPECT_EQ((6 * kWordSize), left_over_array.Length()); |
2056 | 2056 |
2057 // 4. Verify that GC can handle the filler object for a large array. | 2057 // 4. Verify that GC can handle the filler object for a large array. |
2058 array = GrowableObjectArray::New((1 * MB) >> kWordSizeLog2); | 2058 array = GrowableObjectArray::New((1 * MB) >> kWordSizeLog2); |
2059 EXPECT_EQ(0, array.Length()); | 2059 EXPECT_EQ(0, array.Length()); |
2060 for (intptr_t i = 0; i < 1; i++) { | 2060 for (intptr_t i = 0; i < 1; i++) { |
2061 value = Smi::New(i); | 2061 value = Smi::New(i); |
2062 array.Add(value); | 2062 array.Add(value); |
2063 } | 2063 } |
| 2064 Heap* heap = Isolate::Current()->heap(); |
| 2065 heap->CollectAllGarbage(); |
| 2066 intptr_t capacity_before = heap->CapacityInWords(Heap::kOld); |
2064 new_array = Array::MakeArray(array); | 2067 new_array = Array::MakeArray(array); |
2065 EXPECT_EQ(1, new_array.Length()); | 2068 EXPECT_EQ(1, new_array.Length()); |
2066 Isolate::Current()->heap()->CollectAllGarbage(); | 2069 heap->CollectAllGarbage(); |
| 2070 intptr_t capacity_after = heap->CapacityInWords(Heap::kOld); |
| 2071 // Page should shrink. |
| 2072 EXPECT_LT(capacity_after, capacity_before); |
2067 EXPECT_EQ(1, new_array.Length()); | 2073 EXPECT_EQ(1, new_array.Length()); |
2068 } | 2074 } |
2069 | 2075 |
2070 | 2076 |
2071 TEST_CASE(InternalTypedData) { | 2077 TEST_CASE(InternalTypedData) { |
2072 uint8_t data[] = { 253, 254, 255, 0, 1, 2, 3, 4 }; | 2078 uint8_t data[] = { 253, 254, 255, 0, 1, 2, 3, 4 }; |
2073 intptr_t data_length = ARRAY_SIZE(data); | 2079 intptr_t data_length = ARRAY_SIZE(data); |
2074 | 2080 |
2075 const TypedData& int8_array = | 2081 const TypedData& int8_array = |
2076 TypedData::Handle(TypedData::New(kTypedDataInt8ArrayCid, data_length)); | 2082 TypedData::Handle(TypedData::New(kTypedDataInt8ArrayCid, data_length)); |
(...skipping 2030 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4107 EXPECT_VALID(h_result); | 4113 EXPECT_VALID(h_result); |
4108 Integer& result = Integer::Handle(); | 4114 Integer& result = Integer::Handle(); |
4109 result ^= Api::UnwrapHandle(h_result); | 4115 result ^= Api::UnwrapHandle(h_result); |
4110 String& foo = String::Handle(String::New("foo")); | 4116 String& foo = String::Handle(String::New("foo")); |
4111 Integer& expected = Integer::Handle(); | 4117 Integer& expected = Integer::Handle(); |
4112 expected ^= foo.HashCode(); | 4118 expected ^= foo.HashCode(); |
4113 EXPECT(result.IsIdenticalTo(expected)); | 4119 EXPECT(result.IsIdenticalTo(expected)); |
4114 } | 4120 } |
4115 | 4121 |
4116 } // namespace dart | 4122 } // namespace dart |
OLD | NEW |