Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(584)

Side by Side Diff: runtime/vm/dart_api_impl_test.cc

Issue 187113003: Track external allocated memory for weak persistent handles. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 6 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 #include "bin/builtin.h" 5 #include "bin/builtin.h"
6 #include "include/dart_api.h" 6 #include "include/dart_api.h"
7 #include "include/dart_debugger_api.h" 7 #include "include/dart_debugger_api.h"
8 #include "include/dart_mirrors_api.h" 8 #include "include/dart_mirrors_api.h"
9 #include "include/dart_native_api.h" 9 #include "include/dart_native_api.h"
10 #include "platform/assert.h" 10 #include "platform/assert.h"
(...skipping 1694 matching lines...) Expand 10 before | Expand all | Expand 10 after
1705 1705
1706 TEST_CASE(ExternalTypedDataCallback) { 1706 TEST_CASE(ExternalTypedDataCallback) {
1707 int peer = 0; 1707 int peer = 0;
1708 { 1708 {
1709 Dart_EnterScope(); 1709 Dart_EnterScope();
1710 uint8_t data[] = { 1, 2, 3, 4 }; 1710 uint8_t data[] = { 1, 2, 3, 4 };
1711 Dart_Handle obj = Dart_NewExternalTypedData( 1711 Dart_Handle obj = Dart_NewExternalTypedData(
1712 Dart_TypedData_kUint8, 1712 Dart_TypedData_kUint8,
1713 data, 1713 data,
1714 ARRAY_SIZE(data)); 1714 ARRAY_SIZE(data));
1715 Dart_NewWeakPersistentHandle(obj, &peer, ExternalTypedDataFinalizer); 1715 Dart_NewWeakPersistentHandle(
1716 obj, &peer, sizeof(data), ExternalTypedDataFinalizer);
1716 EXPECT_VALID(obj); 1717 EXPECT_VALID(obj);
1717 Dart_ExitScope(); 1718 Dart_ExitScope();
1718 } 1719 }
1719 EXPECT(peer == 0); 1720 EXPECT(peer == 0);
1720 Isolate::Current()->heap()->CollectGarbage(Heap::kOld); 1721 Isolate::Current()->heap()->CollectGarbage(Heap::kOld);
1721 EXPECT(peer == 0); 1722 EXPECT(peer == 0);
1722 Isolate::Current()->heap()->CollectGarbage(Heap::kNew); 1723 Isolate::Current()->heap()->CollectGarbage(Heap::kNew);
1723 EXPECT(peer == 42); 1724 EXPECT(peer == 42);
1724 } 1725 }
1725 1726
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
1760 float data[] = { 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1761 float data[] = { 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
1761 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1762 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
1762 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1763 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
1763 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 }; 1764 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 };
1764 // Push a scope so that we can collect the local handle created as part of 1765 // Push a scope so that we can collect the local handle created as part of
1765 // Dart_NewExternalTypedData. 1766 // Dart_NewExternalTypedData.
1766 Dart_EnterScope(); 1767 Dart_EnterScope();
1767 { 1768 {
1768 Dart_Handle lcl = Dart_NewExternalTypedData( 1769 Dart_Handle lcl = Dart_NewExternalTypedData(
1769 Dart_TypedData_kFloat32x4, data, 10); 1770 Dart_TypedData_kFloat32x4, data, 10);
1770 Dart_NewWeakPersistentHandle(lcl, &peer, ExternalTypedDataFinalizer); 1771 Dart_NewWeakPersistentHandle(
1772 lcl, &peer, sizeof(data), ExternalTypedDataFinalizer);
1771 CheckFloat32x4Data(lcl); 1773 CheckFloat32x4Data(lcl);
1772 } 1774 }
1773 Dart_ExitScope(); 1775 Dart_ExitScope();
1774 Isolate::Current()->heap()->CollectGarbage(Heap::kNew); 1776 Isolate::Current()->heap()->CollectGarbage(Heap::kNew);
1775 EXPECT(peer == 42); 1777 EXPECT(peer == 42);
1776 } 1778 }
1777 1779
1778 1780
1779 // Unit test for entering a scope, creating a local handle and exiting 1781 // Unit test for entering a scope, creating a local handle and exiting
1780 // the scope. 1782 // the scope.
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after
1948 1950
1949 1951
1950 static Dart_Handle AsHandle(Dart_WeakPersistentHandle weak) { 1952 static Dart_Handle AsHandle(Dart_WeakPersistentHandle weak) {
1951 return Dart_HandleFromWeakPersistent(weak); 1953 return Dart_HandleFromWeakPersistent(weak);
1952 } 1954 }
1953 1955
1954 1956
1955 TEST_CASE(WeakPersistentHandle) { 1957 TEST_CASE(WeakPersistentHandle) {
1956 Dart_Handle local_new_ref = Dart_Null(); 1958 Dart_Handle local_new_ref = Dart_Null();
1957 Dart_WeakPersistentHandle weak_new_ref = Dart_NewWeakPersistentHandle( 1959 Dart_WeakPersistentHandle weak_new_ref = Dart_NewWeakPersistentHandle(
1958 local_new_ref, NULL, NULL); 1960 local_new_ref, NULL, 0, NULL);
1959 1961
1960 Dart_Handle local_old_ref = Dart_Null(); 1962 Dart_Handle local_old_ref = Dart_Null();
1961 Dart_WeakPersistentHandle weak_old_ref = Dart_NewWeakPersistentHandle( 1963 Dart_WeakPersistentHandle weak_old_ref = Dart_NewWeakPersistentHandle(
1962 local_old_ref, NULL, NULL); 1964 local_old_ref, NULL, 0, NULL);
1963 1965
1964 { 1966 {
1965 Dart_EnterScope(); 1967 Dart_EnterScope();
1966 1968
1967 // Create an object in new space. 1969 // Create an object in new space.
1968 Dart_Handle new_ref = NewString("new string"); 1970 Dart_Handle new_ref = NewString("new string");
1969 EXPECT_VALID(new_ref); 1971 EXPECT_VALID(new_ref);
1970 1972
1971 // Create an object in old space. 1973 // Create an object in old space.
1972 Dart_Handle old_ref; 1974 Dart_Handle old_ref;
1973 { 1975 {
1974 Isolate* isolate = Isolate::Current(); 1976 Isolate* isolate = Isolate::Current();
1975 DARTSCOPE(isolate); 1977 DARTSCOPE(isolate);
1976 old_ref = Api::NewHandle(isolate, String::New("old string", Heap::kOld)); 1978 old_ref = Api::NewHandle(isolate, String::New("old string", Heap::kOld));
1977 EXPECT_VALID(old_ref); 1979 EXPECT_VALID(old_ref);
1978 } 1980 }
1979 1981
1980 // Create a weak ref to the new space object. 1982 // Create a weak ref to the new space object.
1981 weak_new_ref = Dart_NewWeakPersistentHandle(new_ref, NULL, NULL); 1983 weak_new_ref = Dart_NewWeakPersistentHandle(new_ref, NULL, 0, NULL);
1982 EXPECT_VALID(AsHandle(weak_new_ref)); 1984 EXPECT_VALID(AsHandle(weak_new_ref));
1983 EXPECT(!Dart_IsNull(AsHandle(weak_new_ref))); 1985 EXPECT(!Dart_IsNull(AsHandle(weak_new_ref)));
1984 1986
1985 // Create a weak ref to the old space object. 1987 // Create a weak ref to the old space object.
1986 weak_old_ref = Dart_NewWeakPersistentHandle(old_ref, NULL, NULL); 1988 weak_old_ref = Dart_NewWeakPersistentHandle(old_ref, NULL, 0, NULL);
1987 EXPECT_VALID(AsHandle(weak_old_ref)); 1989 EXPECT_VALID(AsHandle(weak_old_ref));
1988 EXPECT(!Dart_IsNull(AsHandle(weak_old_ref))); 1990 EXPECT(!Dart_IsNull(AsHandle(weak_old_ref)));
1989 1991
1990 // Garbage collect new space. 1992 // Garbage collect new space.
1991 GCTestHelper::CollectNewSpace(Heap::kIgnoreApiCallbacks); 1993 GCTestHelper::CollectNewSpace(Heap::kIgnoreApiCallbacks);
1992 1994
1993 // Nothing should be invalidated or cleared. 1995 // Nothing should be invalidated or cleared.
1994 EXPECT_VALID(new_ref); 1996 EXPECT_VALID(new_ref);
1995 EXPECT(!Dart_IsNull(new_ref)); 1997 EXPECT(!Dart_IsNull(new_ref));
1996 EXPECT_VALID(old_ref); 1998 EXPECT_VALID(old_ref);
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
2066 } 2068 }
2067 2069
2068 2070
2069 TEST_CASE(WeakPersistentHandleCallback) { 2071 TEST_CASE(WeakPersistentHandleCallback) {
2070 Dart_WeakPersistentHandle weak_ref = NULL; 2072 Dart_WeakPersistentHandle weak_ref = NULL;
2071 int peer = 0; 2073 int peer = 0;
2072 { 2074 {
2073 Dart_EnterScope(); 2075 Dart_EnterScope();
2074 Dart_Handle obj = NewString("new string"); 2076 Dart_Handle obj = NewString("new string");
2075 EXPECT_VALID(obj); 2077 EXPECT_VALID(obj);
2076 weak_ref = Dart_NewWeakPersistentHandle(obj, &peer, 2078 weak_ref = Dart_NewWeakPersistentHandle(obj, &peer, 0,
2077 WeakPersistentHandlePeerFinalizer); 2079 WeakPersistentHandlePeerFinalizer);
2078 EXPECT_VALID(AsHandle(weak_ref)); 2080 EXPECT_VALID(AsHandle(weak_ref));
2079 EXPECT(peer == 0); 2081 EXPECT(peer == 0);
2080 Dart_ExitScope(); 2082 Dart_ExitScope();
2081 } 2083 }
2082 Isolate::Current()->heap()->CollectGarbage(Heap::kOld); 2084 Isolate::Current()->heap()->CollectGarbage(Heap::kOld);
2083 EXPECT(peer == 0); 2085 EXPECT(peer == 0);
2084 GCTestHelper::CollectNewSpace(Heap::kIgnoreApiCallbacks); 2086 GCTestHelper::CollectNewSpace(Heap::kIgnoreApiCallbacks);
2085 EXPECT(peer == 42); 2087 EXPECT(peer == 42);
2086 Dart_DeleteWeakPersistentHandle(weak_ref); 2088 Dart_DeleteWeakPersistentHandle(weak_ref);
2087 } 2089 }
2088 2090
2089 2091
2090 TEST_CASE(WeakPersistentHandleNoCallback) { 2092 TEST_CASE(WeakPersistentHandleNoCallback) {
2091 Dart_WeakPersistentHandle weak_ref = NULL; 2093 Dart_WeakPersistentHandle weak_ref = NULL;
2092 int peer = 0; 2094 int peer = 0;
2093 { 2095 {
2094 Dart_EnterScope(); 2096 Dart_EnterScope();
2095 Dart_Handle obj = NewString("new string"); 2097 Dart_Handle obj = NewString("new string");
2096 EXPECT_VALID(obj); 2098 EXPECT_VALID(obj);
2097 weak_ref = Dart_NewWeakPersistentHandle(obj, &peer, 2099 weak_ref = Dart_NewWeakPersistentHandle(obj, &peer, 0,
2098 WeakPersistentHandlePeerFinalizer); 2100 WeakPersistentHandlePeerFinalizer);
2099 Dart_ExitScope(); 2101 Dart_ExitScope();
2100 } 2102 }
2101 // A finalizer is not invoked on a deleted handle. Therefore, the 2103 // A finalizer is not invoked on a deleted handle. Therefore, the
2102 // peer value should not change after the referent is collected. 2104 // peer value should not change after the referent is collected.
2103 Dart_DeleteWeakPersistentHandle(weak_ref); 2105 Dart_DeleteWeakPersistentHandle(weak_ref);
2104 EXPECT(peer == 0); 2106 EXPECT(peer == 0);
2105 Isolate::Current()->heap()->CollectGarbage(Heap::kOld); 2107 Isolate::Current()->heap()->CollectGarbage(Heap::kOld);
2106 EXPECT(peer == 0); 2108 EXPECT(peer == 0);
2107 GCTestHelper::CollectNewSpace(Heap::kIgnoreApiCallbacks); 2109 GCTestHelper::CollectNewSpace(Heap::kIgnoreApiCallbacks);
2108 EXPECT(peer == 0); 2110 EXPECT(peer == 0);
2109 } 2111 }
2110 2112
2111 2113
2112 UNIT_TEST_CASE(WeakPersistentHandlesCallbackShutdown) { 2114 UNIT_TEST_CASE(WeakPersistentHandlesCallbackShutdown) {
2113 TestCase::CreateTestIsolate(); 2115 TestCase::CreateTestIsolate();
2114 Dart_EnterScope(); 2116 Dart_EnterScope();
2115 Dart_Handle ref = Dart_True(); 2117 Dart_Handle ref = Dart_True();
2116 int peer = 1234; 2118 int peer = 1234;
2117 Dart_NewWeakPersistentHandle(ref, 2119 Dart_NewWeakPersistentHandle(ref,
2118 &peer, 2120 &peer,
2121 0,
2119 WeakPersistentHandlePeerFinalizer); 2122 WeakPersistentHandlePeerFinalizer);
2120 Dart_ShutdownIsolate(); 2123 Dart_ShutdownIsolate();
2121 EXPECT(peer == 42); 2124 EXPECT(peer == 42);
2122 } 2125 }
2123 2126
2124 2127
2128 TEST_CASE(WeakPersistentHandleExternalAllocationSize) {
2129 Heap* heap = Isolate::Current()->heap();
2130 EXPECT(heap->ExternalAllocatedInWords(Heap::kNew) == 0);
2131 EXPECT(heap->ExternalAllocatedInWords(Heap::kOld) == 0);
2132 Dart_WeakPersistentHandle weak1 = NULL;
2133 {
2134 Dart_EnterScope();
2135 Dart_Handle obj = NewString("weakly referenced string");
2136 EXPECT_VALID(obj);
2137 weak1 = Dart_NewWeakPersistentHandle(obj, NULL, 1024, NULL);
2138 EXPECT_VALID(AsHandle(weak1));
2139 Dart_ExitScope();
2140 }
2141 Dart_PersistentHandle strong_ref = NULL;
2142 Dart_WeakPersistentHandle weak2 = NULL;
2143 {
2144 Dart_EnterScope();
2145 Dart_Handle obj = NewString("strongly referenced string");
2146 EXPECT_VALID(obj);
2147 strong_ref = Dart_NewPersistentHandle(obj);
2148 weak2 = Dart_NewWeakPersistentHandle(obj, NULL, 2048, NULL);
2149 EXPECT_VALID(AsHandle(strong_ref));
2150 Dart_ExitScope();
2151 }
2152 Isolate::Current()->heap()->CollectGarbage(Heap::kOld);
2153 EXPECT(heap->ExternalAllocatedInWords(Heap::kNew) == (1024 + 2048)/kWordSize);
2154 // Collect weakly referenced string, and promote strongly referenced string.
2155 GCTestHelper::CollectNewSpace(Heap::kIgnoreApiCallbacks);
2156 GCTestHelper::CollectNewSpace(Heap::kIgnoreApiCallbacks);
2157 EXPECT(heap->ExternalAllocatedInWords(Heap::kNew) == 0);
2158 EXPECT(heap->ExternalAllocatedInWords(Heap::kOld) == 2048/kWordSize);
2159 Dart_DeleteWeakPersistentHandle(weak1);
2160 Dart_DeleteWeakPersistentHandle(weak2);
2161 Dart_DeletePersistentHandle(strong_ref);
2162 }
2163
2164
2165 TEST_CASE(WeakPersistentHandleExternalAllocationSizeOversized) {
2166 Heap* heap = Isolate::Current()->heap();
2167 Dart_WeakPersistentHandle weak1 = NULL;
2168 {
2169 Dart_EnterScope();
2170 Dart_Handle obj = NewString("weakly referenced string");
2171 EXPECT_VALID(obj);
2172 weak1 = Dart_NewWeakPersistentHandle(obj, NULL, 100*MB, NULL);
2173 EXPECT_VALID(AsHandle(weak1));
2174 // While new space is "full" of external data, any allocation will
2175 // trigger GC, so after two of them, obj should be promoted.
2176 Dart_Handle trigger1 = NewString("trigger1");
2177 EXPECT_VALID(trigger1);
2178 Dart_Handle trigger2 = NewString("trigger2");
2179 EXPECT_VALID(trigger2);
2180 {
2181 DARTSCOPE(Isolate::Current());
2182 String& handle = String::Handle();
2183 handle ^= Api::UnwrapHandle(obj);
2184 EXPECT(handle.IsOld());
2185 }
2186 EXPECT(heap->ExternalAllocatedInWords(Heap::kNew) == 0);
2187 EXPECT(heap->ExternalAllocatedInWords(Heap::kOld) == 100*MBInWords);
2188 Dart_ExitScope();
2189 }
2190 Dart_DeleteWeakPersistentHandle(weak1);
2191 }
2192
2193
2194 TEST_CASE(WeakPersistentHandleExternalAllocationSizeOddReferents) {
2195 Heap* heap = Isolate::Current()->heap();
2196 Dart_WeakPersistentHandle weak1 = NULL;
2197 Dart_WeakPersistentHandle weak2 = NULL;
2198 {
2199 Dart_EnterScope();
2200 Dart_Handle dart_null = Dart_Null(); // VM heap object.
2201 EXPECT_VALID(dart_null);
2202 weak1 = Dart_NewWeakPersistentHandle(dart_null, NULL, 1024, NULL);
2203 EXPECT_VALID(AsHandle(weak1));
2204 Dart_Handle zero = Dart_NewInteger(0); // Smi.
2205 EXPECT_VALID(dart_null);
2206 weak2 = Dart_NewWeakPersistentHandle(zero, NULL, 2048, NULL);
2207 EXPECT_VALID(AsHandle(weak2));
2208 // Both should be charged to old space.
2209 EXPECT(heap->ExternalAllocatedInWords(Heap::kOld) ==
2210 (1024 + 2048)/kWordSize);
2211 Dart_ExitScope();
2212 }
2213 Dart_DeleteWeakPersistentHandle(weak1);
2214 Dart_DeleteWeakPersistentHandle(weak2);
2215 }
2216
2217
2125 TEST_CASE(ObjectGroups) { 2218 TEST_CASE(ObjectGroups) {
2126 Dart_PersistentHandle strong = NULL; 2219 Dart_PersistentHandle strong = NULL;
2127 Dart_WeakPersistentHandle strong_weak = NULL; 2220 Dart_WeakPersistentHandle strong_weak = NULL;
2128 2221
2129 Dart_WeakPersistentHandle weak1 = NULL; 2222 Dart_WeakPersistentHandle weak1 = NULL;
2130 Dart_WeakPersistentHandle weak2 = NULL; 2223 Dart_WeakPersistentHandle weak2 = NULL;
2131 Dart_WeakPersistentHandle weak3 = NULL; 2224 Dart_WeakPersistentHandle weak3 = NULL;
2132 Dart_WeakPersistentHandle weak4 = NULL; 2225 Dart_WeakPersistentHandle weak4 = NULL;
2133 2226
2134 Dart_EnterScope(); 2227 Dart_EnterScope();
2135 { 2228 {
2136 Isolate* isolate = Isolate::Current(); 2229 Isolate* isolate = Isolate::Current();
2137 DARTSCOPE(isolate); 2230 DARTSCOPE(isolate);
2138 2231
2139 Dart_Handle local = Api::NewHandle( 2232 Dart_Handle local = Api::NewHandle(
2140 isolate, String::New("strongly reachable", Heap::kOld)); 2233 isolate, String::New("strongly reachable", Heap::kOld));
2141 strong = Dart_NewPersistentHandle(local); 2234 strong = Dart_NewPersistentHandle(local);
2142 strong_weak = Dart_NewWeakPersistentHandle(local, NULL, NULL); 2235 strong_weak = Dart_NewWeakPersistentHandle(local, NULL, 0, NULL);
2143 EXPECT_VALID(AsHandle(strong)); 2236 EXPECT_VALID(AsHandle(strong));
2144 EXPECT(!Dart_IsNull(AsHandle(strong))); 2237 EXPECT(!Dart_IsNull(AsHandle(strong)));
2145 2238
2146 weak1 = Dart_NewWeakPersistentHandle( 2239 weak1 = Dart_NewWeakPersistentHandle(
2147 Api::NewHandle(isolate, String::New("weakly reachable 1", Heap::kOld)), 2240 Api::NewHandle(isolate, String::New("weakly reachable 1", Heap::kOld)),
2148 NULL, NULL); 2241 NULL, 0, NULL);
2149 EXPECT_VALID(AsHandle(weak1)); 2242 EXPECT_VALID(AsHandle(weak1));
2150 EXPECT(!Dart_IsNull(AsHandle(weak1))); 2243 EXPECT(!Dart_IsNull(AsHandle(weak1)));
2151 2244
2152 weak2 = Dart_NewWeakPersistentHandle( 2245 weak2 = Dart_NewWeakPersistentHandle(
2153 Api::NewHandle(isolate, String::New("weakly reachable 2", Heap::kOld)), 2246 Api::NewHandle(isolate, String::New("weakly reachable 2", Heap::kOld)),
2154 NULL, NULL); 2247 NULL, 0, NULL);
2155 EXPECT_VALID(AsHandle(weak2)); 2248 EXPECT_VALID(AsHandle(weak2));
2156 EXPECT(!Dart_IsNull(AsHandle(weak2))); 2249 EXPECT(!Dart_IsNull(AsHandle(weak2)));
2157 2250
2158 weak3 = Dart_NewWeakPersistentHandle( 2251 weak3 = Dart_NewWeakPersistentHandle(
2159 Api::NewHandle(isolate, String::New("weakly reachable 3", Heap::kOld)), 2252 Api::NewHandle(isolate, String::New("weakly reachable 3", Heap::kOld)),
2160 NULL, NULL); 2253 NULL, 0, NULL);
2161 EXPECT_VALID(AsHandle(weak3)); 2254 EXPECT_VALID(AsHandle(weak3));
2162 EXPECT(!Dart_IsNull(AsHandle(weak3))); 2255 EXPECT(!Dart_IsNull(AsHandle(weak3)));
2163 2256
2164 weak4 = Dart_NewWeakPersistentHandle( 2257 weak4 = Dart_NewWeakPersistentHandle(
2165 Api::NewHandle(isolate, String::New("weakly reachable 4", Heap::kOld)), 2258 Api::NewHandle(isolate, String::New("weakly reachable 4", Heap::kOld)),
2166 NULL, NULL); 2259 NULL, 0, NULL);
2167 EXPECT_VALID(AsHandle(weak4)); 2260 EXPECT_VALID(AsHandle(weak4));
2168 EXPECT(!Dart_IsNull(AsHandle(weak4))); 2261 EXPECT(!Dart_IsNull(AsHandle(weak4)));
2169 } 2262 }
2170 Dart_ExitScope(); 2263 Dart_ExitScope();
2171 2264
2172 { 2265 {
2173 Dart_EnterScope(); 2266 Dart_EnterScope();
2174 EXPECT_VALID(AsHandle(strong)); 2267 EXPECT_VALID(AsHandle(strong));
2175 EXPECT_VALID(AsHandle(weak1)); 2268 EXPECT_VALID(AsHandle(weak1));
2176 EXPECT_VALID(AsHandle(weak2)); 2269 EXPECT_VALID(AsHandle(weak2));
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after
2349 Dart_WeakPersistentHandle old_pwph = NULL; 2442 Dart_WeakPersistentHandle old_pwph = NULL;
2350 Dart_WeakPersistentHandle new_pwph = NULL; 2443 Dart_WeakPersistentHandle new_pwph = NULL;
2351 2444
2352 Dart_EnterScope(); 2445 Dart_EnterScope();
2353 { 2446 {
2354 Isolate* isolate = Isolate::Current(); 2447 Isolate* isolate = Isolate::Current();
2355 DARTSCOPE(isolate); 2448 DARTSCOPE(isolate);
2356 new_pwph = Dart_NewPrologueWeakPersistentHandle( 2449 new_pwph = Dart_NewPrologueWeakPersistentHandle(
2357 Api::NewHandle(isolate, 2450 Api::NewHandle(isolate,
2358 String::New("new space prologue weak", Heap::kNew)), 2451 String::New("new space prologue weak", Heap::kNew)),
2359 NULL, NULL); 2452 NULL, 0, NULL);
2360 EXPECT_VALID(AsHandle(new_pwph)); 2453 EXPECT_VALID(AsHandle(new_pwph));
2361 EXPECT(!Dart_IsNull(AsHandle(new_pwph))); 2454 EXPECT(!Dart_IsNull(AsHandle(new_pwph)));
2362 old_pwph = Dart_NewPrologueWeakPersistentHandle( 2455 old_pwph = Dart_NewPrologueWeakPersistentHandle(
2363 Api::NewHandle(isolate, 2456 Api::NewHandle(isolate,
2364 String::New("old space prologue weak", Heap::kOld)), 2457 String::New("old space prologue weak", Heap::kOld)),
2365 NULL, NULL); 2458 NULL, 0, NULL);
2366 EXPECT_VALID(AsHandle(old_pwph)); 2459 EXPECT_VALID(AsHandle(old_pwph));
2367 EXPECT(!Dart_IsNull(AsHandle(old_pwph))); 2460 EXPECT(!Dart_IsNull(AsHandle(old_pwph)));
2368 } 2461 }
2369 Dart_ExitScope(); 2462 Dart_ExitScope();
2370 2463
2371 { 2464 {
2372 Dart_EnterScope(); 2465 Dart_EnterScope();
2373 EXPECT_VALID(AsHandle(new_pwph)); 2466 EXPECT_VALID(AsHandle(new_pwph));
2374 EXPECT(!Dart_IsNull(AsHandle(new_pwph))); 2467 EXPECT(!Dart_IsNull(AsHandle(new_pwph)));
2375 EXPECT(Dart_IsPrologueWeakPersistentHandle(new_pwph)); 2468 EXPECT(Dart_IsPrologueWeakPersistentHandle(new_pwph));
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
2437 Dart_WeakPersistentHandle weak3 = NULL; 2530 Dart_WeakPersistentHandle weak3 = NULL;
2438 2531
2439 Dart_EnterScope(); 2532 Dart_EnterScope();
2440 { 2533 {
2441 Isolate* isolate = Isolate::Current(); 2534 Isolate* isolate = Isolate::Current();
2442 DARTSCOPE(isolate); 2535 DARTSCOPE(isolate);
2443 2536
2444 Dart_Handle local = Api::NewHandle( 2537 Dart_Handle local = Api::NewHandle(
2445 isolate, String::New("strongly reachable", Heap::kOld)); 2538 isolate, String::New("strongly reachable", Heap::kOld));
2446 strong = Dart_NewPersistentHandle(local); 2539 strong = Dart_NewPersistentHandle(local);
2447 strong_weak = Dart_NewWeakPersistentHandle(local, NULL, NULL); 2540 strong_weak = Dart_NewWeakPersistentHandle(local, NULL, 0, NULL);
2448 2541
2449 EXPECT(!Dart_IsNull(AsHandle(strong))); 2542 EXPECT(!Dart_IsNull(AsHandle(strong)));
2450 EXPECT_VALID(AsHandle(strong)); 2543 EXPECT_VALID(AsHandle(strong));
2451 EXPECT(!Dart_IsNull(AsHandle(strong_weak))); 2544 EXPECT(!Dart_IsNull(AsHandle(strong_weak)));
2452 EXPECT_VALID(AsHandle(strong_weak)); 2545 EXPECT_VALID(AsHandle(strong_weak));
2453 EXPECT(Dart_IdentityEquals(AsHandle(strong), AsHandle(strong_weak))) 2546 EXPECT(Dart_IdentityEquals(AsHandle(strong), AsHandle(strong_weak)))
2454 2547
2455 weak1 = Dart_NewWeakPersistentHandle( 2548 weak1 = Dart_NewWeakPersistentHandle(
2456 Api::NewHandle(isolate, String::New("weakly reachable 1", Heap::kOld)), 2549 Api::NewHandle(isolate, String::New("weakly reachable 1", Heap::kOld)),
2457 NULL, NULL); 2550 NULL, 0, NULL);
2458 EXPECT(!Dart_IsNull(AsHandle(weak1))); 2551 EXPECT(!Dart_IsNull(AsHandle(weak1)));
2459 EXPECT_VALID(AsHandle(weak1)); 2552 EXPECT_VALID(AsHandle(weak1));
2460 2553
2461 weak2 = Dart_NewWeakPersistentHandle( 2554 weak2 = Dart_NewWeakPersistentHandle(
2462 Api::NewHandle(isolate, String::New("weakly reachable 2", Heap::kOld)), 2555 Api::NewHandle(isolate, String::New("weakly reachable 2", Heap::kOld)),
2463 NULL, NULL); 2556 NULL, 0, NULL);
2464 EXPECT(!Dart_IsNull(AsHandle(weak2))); 2557 EXPECT(!Dart_IsNull(AsHandle(weak2)));
2465 EXPECT_VALID(AsHandle(weak2)); 2558 EXPECT_VALID(AsHandle(weak2));
2466 2559
2467 weak3 = Dart_NewWeakPersistentHandle( 2560 weak3 = Dart_NewWeakPersistentHandle(
2468 Api::NewHandle(isolate, String::New("weakly reachable 3", Heap::kOld)), 2561 Api::NewHandle(isolate, String::New("weakly reachable 3", Heap::kOld)),
2469 NULL, NULL); 2562 NULL, 0, NULL);
2470 EXPECT(!Dart_IsNull(AsHandle(weak3))); 2563 EXPECT(!Dart_IsNull(AsHandle(weak3)));
2471 EXPECT_VALID(AsHandle(weak3)); 2564 EXPECT_VALID(AsHandle(weak3));
2472 } 2565 }
2473 Dart_ExitScope(); 2566 Dart_ExitScope();
2474 2567
2475 { 2568 {
2476 Dart_EnterScope(); 2569 Dart_EnterScope();
2477 EXPECT_VALID(AsHandle(strong_weak)); 2570 EXPECT_VALID(AsHandle(strong_weak));
2478 EXPECT_VALID(AsHandle(weak1)); 2571 EXPECT_VALID(AsHandle(weak1));
2479 EXPECT_VALID(AsHandle(weak2)); 2572 EXPECT_VALID(AsHandle(weak2));
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
2543 Dart_WeakPersistentHandle weak3 = NULL; 2636 Dart_WeakPersistentHandle weak3 = NULL;
2544 2637
2545 Dart_EnterScope(); 2638 Dart_EnterScope();
2546 { 2639 {
2547 Isolate* isolate = Isolate::Current(); 2640 Isolate* isolate = Isolate::Current();
2548 DARTSCOPE(isolate); 2641 DARTSCOPE(isolate);
2549 2642
2550 Dart_Handle local = Api::NewHandle( 2643 Dart_Handle local = Api::NewHandle(
2551 isolate, String::New("strongly reachable", Heap::kOld)); 2644 isolate, String::New("strongly reachable", Heap::kOld));
2552 strong = Dart_NewPersistentHandle(local); 2645 strong = Dart_NewPersistentHandle(local);
2553 strong_weak = Dart_NewWeakPersistentHandle(local, NULL, NULL); 2646 strong_weak = Dart_NewWeakPersistentHandle(local, NULL, 0, NULL);
2554 2647
2555 EXPECT(!Dart_IsNull(AsHandle(strong))); 2648 EXPECT(!Dart_IsNull(AsHandle(strong)));
2556 EXPECT_VALID(AsHandle(strong)); 2649 EXPECT_VALID(AsHandle(strong));
2557 EXPECT(!Dart_IsNull(AsHandle(strong_weak))); 2650 EXPECT(!Dart_IsNull(AsHandle(strong_weak)));
2558 EXPECT_VALID(AsHandle(strong_weak)); 2651 EXPECT_VALID(AsHandle(strong_weak));
2559 EXPECT(Dart_IdentityEquals(AsHandle(strong), AsHandle(strong_weak))) 2652 EXPECT(Dart_IdentityEquals(AsHandle(strong), AsHandle(strong_weak)))
2560 2653
2561 weak1 = Dart_NewWeakPersistentHandle( 2654 weak1 = Dart_NewWeakPersistentHandle(
2562 Api::NewHandle(isolate, String::New("weakly reachable 1", Heap::kNew)), 2655 Api::NewHandle(isolate, String::New("weakly reachable 1", Heap::kNew)),
2563 NULL, NULL); 2656 NULL, 0, NULL);
2564 EXPECT(!Dart_IsNull(AsHandle(weak1))); 2657 EXPECT(!Dart_IsNull(AsHandle(weak1)));
2565 EXPECT_VALID(AsHandle(weak1)); 2658 EXPECT_VALID(AsHandle(weak1));
2566 2659
2567 weak2 = Dart_NewWeakPersistentHandle( 2660 weak2 = Dart_NewWeakPersistentHandle(
2568 Api::NewHandle(isolate, String::New("weakly reachable 2", Heap::kNew)), 2661 Api::NewHandle(isolate, String::New("weakly reachable 2", Heap::kNew)),
2569 NULL, NULL); 2662 NULL, 0, NULL);
2570 EXPECT(!Dart_IsNull(AsHandle(weak2))); 2663 EXPECT(!Dart_IsNull(AsHandle(weak2)));
2571 EXPECT_VALID(AsHandle(weak2)); 2664 EXPECT_VALID(AsHandle(weak2));
2572 2665
2573 weak3 = Dart_NewWeakPersistentHandle( 2666 weak3 = Dart_NewWeakPersistentHandle(
2574 Api::NewHandle(isolate, String::New("weakly reachable 3", Heap::kNew)), 2667 Api::NewHandle(isolate, String::New("weakly reachable 3", Heap::kNew)),
2575 NULL, NULL); 2668 NULL, 0, NULL);
2576 EXPECT(!Dart_IsNull(AsHandle(weak3))); 2669 EXPECT(!Dart_IsNull(AsHandle(weak3)));
2577 EXPECT_VALID(AsHandle(weak3)); 2670 EXPECT_VALID(AsHandle(weak3));
2578 } 2671 }
2579 Dart_ExitScope(); 2672 Dart_ExitScope();
2580 2673
2581 { 2674 {
2582 Dart_EnterScope(); 2675 Dart_EnterScope();
2583 EXPECT_VALID(AsHandle(strong_weak)); 2676 EXPECT_VALID(AsHandle(strong_weak));
2584 EXPECT_VALID(AsHandle(weak1)); 2677 EXPECT_VALID(AsHandle(weak1));
2585 EXPECT_VALID(AsHandle(weak2)); 2678 EXPECT_VALID(AsHandle(weak2));
(...skipping 5326 matching lines...) Expand 10 before | Expand all | Expand 10 after
7912 NewString("main"), 8005 NewString("main"),
7913 1, 8006 1,
7914 dart_args); 8007 dart_args);
7915 int64_t value = 0; 8008 int64_t value = 0;
7916 result = Dart_IntegerToInt64(result, &value); 8009 result = Dart_IntegerToInt64(result, &value);
7917 EXPECT_VALID(result); 8010 EXPECT_VALID(result);
7918 EXPECT_EQ(6, value); 8011 EXPECT_EQ(6, value);
7919 } 8012 }
7920 8013
7921 } // namespace dart 8014 } // namespace dart
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698