| 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 #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 1776 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1787 | 1787 |
| 1788 TEST_CASE(ExternalTypedDataCallback) { | 1788 TEST_CASE(ExternalTypedDataCallback) { |
| 1789 int peer = 0; | 1789 int peer = 0; |
| 1790 { | 1790 { |
| 1791 Dart_EnterScope(); | 1791 Dart_EnterScope(); |
| 1792 uint8_t data[] = { 1, 2, 3, 4 }; | 1792 uint8_t data[] = { 1, 2, 3, 4 }; |
| 1793 Dart_Handle obj = Dart_NewExternalTypedData( | 1793 Dart_Handle obj = Dart_NewExternalTypedData( |
| 1794 Dart_TypedData_kUint8, | 1794 Dart_TypedData_kUint8, |
| 1795 data, | 1795 data, |
| 1796 ARRAY_SIZE(data)); | 1796 ARRAY_SIZE(data)); |
| 1797 Dart_NewWeakPersistentHandle(obj, &peer, ExternalTypedDataFinalizer); | 1797 Dart_NewWeakPersistentHandle( |
| 1798 obj, &peer, sizeof(data), ExternalTypedDataFinalizer); |
| 1798 EXPECT_VALID(obj); | 1799 EXPECT_VALID(obj); |
| 1799 Dart_ExitScope(); | 1800 Dart_ExitScope(); |
| 1800 } | 1801 } |
| 1801 EXPECT(peer == 0); | 1802 EXPECT(peer == 0); |
| 1802 Isolate::Current()->heap()->CollectGarbage(Heap::kOld); | 1803 Isolate::Current()->heap()->CollectGarbage(Heap::kOld); |
| 1803 EXPECT(peer == 0); | 1804 EXPECT(peer == 0); |
| 1804 Isolate::Current()->heap()->CollectGarbage(Heap::kNew); | 1805 Isolate::Current()->heap()->CollectGarbage(Heap::kNew); |
| 1805 EXPECT(peer == 42); | 1806 EXPECT(peer == 42); |
| 1806 } | 1807 } |
| 1807 | 1808 |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1842 float data[] = { 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, | 1843 float data[] = { 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, |
| 1843 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, | 1844 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, |
| 1844 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, | 1845 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, |
| 1845 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 }; | 1846 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 }; |
| 1846 // Push a scope so that we can collect the local handle created as part of | 1847 // Push a scope so that we can collect the local handle created as part of |
| 1847 // Dart_NewExternalTypedData. | 1848 // Dart_NewExternalTypedData. |
| 1848 Dart_EnterScope(); | 1849 Dart_EnterScope(); |
| 1849 { | 1850 { |
| 1850 Dart_Handle lcl = Dart_NewExternalTypedData( | 1851 Dart_Handle lcl = Dart_NewExternalTypedData( |
| 1851 Dart_TypedData_kFloat32x4, data, 10); | 1852 Dart_TypedData_kFloat32x4, data, 10); |
| 1852 Dart_NewWeakPersistentHandle(lcl, &peer, ExternalTypedDataFinalizer); | 1853 Dart_NewWeakPersistentHandle( |
| 1854 lcl, &peer, sizeof(data), ExternalTypedDataFinalizer); |
| 1853 CheckFloat32x4Data(lcl); | 1855 CheckFloat32x4Data(lcl); |
| 1854 } | 1856 } |
| 1855 Dart_ExitScope(); | 1857 Dart_ExitScope(); |
| 1856 Isolate::Current()->heap()->CollectGarbage(Heap::kNew); | 1858 Isolate::Current()->heap()->CollectGarbage(Heap::kNew); |
| 1857 EXPECT(peer == 42); | 1859 EXPECT(peer == 42); |
| 1858 } | 1860 } |
| 1859 | 1861 |
| 1860 | 1862 |
| 1861 // Unit test for entering a scope, creating a local handle and exiting | 1863 // Unit test for entering a scope, creating a local handle and exiting |
| 1862 // the scope. | 1864 // the scope. |
| (...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2030 | 2032 |
| 2031 | 2033 |
| 2032 static Dart_Handle AsHandle(Dart_WeakPersistentHandle weak) { | 2034 static Dart_Handle AsHandle(Dart_WeakPersistentHandle weak) { |
| 2033 return Dart_HandleFromWeakPersistent(weak); | 2035 return Dart_HandleFromWeakPersistent(weak); |
| 2034 } | 2036 } |
| 2035 | 2037 |
| 2036 | 2038 |
| 2037 TEST_CASE(WeakPersistentHandle) { | 2039 TEST_CASE(WeakPersistentHandle) { |
| 2038 Dart_Handle local_new_ref = Dart_Null(); | 2040 Dart_Handle local_new_ref = Dart_Null(); |
| 2039 Dart_WeakPersistentHandle weak_new_ref = Dart_NewWeakPersistentHandle( | 2041 Dart_WeakPersistentHandle weak_new_ref = Dart_NewWeakPersistentHandle( |
| 2040 local_new_ref, NULL, NULL); | 2042 local_new_ref, NULL, 0, NULL); |
| 2041 | 2043 |
| 2042 Dart_Handle local_old_ref = Dart_Null(); | 2044 Dart_Handle local_old_ref = Dart_Null(); |
| 2043 Dart_WeakPersistentHandle weak_old_ref = Dart_NewWeakPersistentHandle( | 2045 Dart_WeakPersistentHandle weak_old_ref = Dart_NewWeakPersistentHandle( |
| 2044 local_old_ref, NULL, NULL); | 2046 local_old_ref, NULL, 0, NULL); |
| 2045 | 2047 |
| 2046 { | 2048 { |
| 2047 Dart_EnterScope(); | 2049 Dart_EnterScope(); |
| 2048 | 2050 |
| 2049 // Create an object in new space. | 2051 // Create an object in new space. |
| 2050 Dart_Handle new_ref = NewString("new string"); | 2052 Dart_Handle new_ref = NewString("new string"); |
| 2051 EXPECT_VALID(new_ref); | 2053 EXPECT_VALID(new_ref); |
| 2052 | 2054 |
| 2053 // Create an object in old space. | 2055 // Create an object in old space. |
| 2054 Dart_Handle old_ref; | 2056 Dart_Handle old_ref; |
| 2055 { | 2057 { |
| 2056 Isolate* isolate = Isolate::Current(); | 2058 Isolate* isolate = Isolate::Current(); |
| 2057 DARTSCOPE(isolate); | 2059 DARTSCOPE(isolate); |
| 2058 old_ref = Api::NewHandle(isolate, String::New("old string", Heap::kOld)); | 2060 old_ref = Api::NewHandle(isolate, String::New("old string", Heap::kOld)); |
| 2059 EXPECT_VALID(old_ref); | 2061 EXPECT_VALID(old_ref); |
| 2060 } | 2062 } |
| 2061 | 2063 |
| 2062 // Create a weak ref to the new space object. | 2064 // Create a weak ref to the new space object. |
| 2063 weak_new_ref = Dart_NewWeakPersistentHandle(new_ref, NULL, NULL); | 2065 weak_new_ref = Dart_NewWeakPersistentHandle(new_ref, NULL, 0, NULL); |
| 2064 EXPECT_VALID(AsHandle(weak_new_ref)); | 2066 EXPECT_VALID(AsHandle(weak_new_ref)); |
| 2065 EXPECT(!Dart_IsNull(AsHandle(weak_new_ref))); | 2067 EXPECT(!Dart_IsNull(AsHandle(weak_new_ref))); |
| 2066 | 2068 |
| 2067 // Create a weak ref to the old space object. | 2069 // Create a weak ref to the old space object. |
| 2068 weak_old_ref = Dart_NewWeakPersistentHandle(old_ref, NULL, NULL); | 2070 weak_old_ref = Dart_NewWeakPersistentHandle(old_ref, NULL, 0, NULL); |
| 2069 EXPECT_VALID(AsHandle(weak_old_ref)); | 2071 EXPECT_VALID(AsHandle(weak_old_ref)); |
| 2070 EXPECT(!Dart_IsNull(AsHandle(weak_old_ref))); | 2072 EXPECT(!Dart_IsNull(AsHandle(weak_old_ref))); |
| 2071 | 2073 |
| 2072 // Garbage collect new space. | 2074 // Garbage collect new space. |
| 2073 GCTestHelper::CollectNewSpace(Heap::kIgnoreApiCallbacks); | 2075 GCTestHelper::CollectNewSpace(Heap::kIgnoreApiCallbacks); |
| 2074 | 2076 |
| 2075 // Nothing should be invalidated or cleared. | 2077 // Nothing should be invalidated or cleared. |
| 2076 EXPECT_VALID(new_ref); | 2078 EXPECT_VALID(new_ref); |
| 2077 EXPECT(!Dart_IsNull(new_ref)); | 2079 EXPECT(!Dart_IsNull(new_ref)); |
| 2078 EXPECT_VALID(old_ref); | 2080 EXPECT_VALID(old_ref); |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2150 } | 2152 } |
| 2151 | 2153 |
| 2152 | 2154 |
| 2153 TEST_CASE(WeakPersistentHandleCallback) { | 2155 TEST_CASE(WeakPersistentHandleCallback) { |
| 2154 Dart_WeakPersistentHandle weak_ref = NULL; | 2156 Dart_WeakPersistentHandle weak_ref = NULL; |
| 2155 int peer = 0; | 2157 int peer = 0; |
| 2156 { | 2158 { |
| 2157 Dart_EnterScope(); | 2159 Dart_EnterScope(); |
| 2158 Dart_Handle obj = NewString("new string"); | 2160 Dart_Handle obj = NewString("new string"); |
| 2159 EXPECT_VALID(obj); | 2161 EXPECT_VALID(obj); |
| 2160 weak_ref = Dart_NewWeakPersistentHandle(obj, &peer, | 2162 weak_ref = Dart_NewWeakPersistentHandle(obj, &peer, 0, |
| 2161 WeakPersistentHandlePeerFinalizer); | 2163 WeakPersistentHandlePeerFinalizer); |
| 2162 EXPECT_VALID(AsHandle(weak_ref)); | 2164 EXPECT_VALID(AsHandle(weak_ref)); |
| 2163 EXPECT(peer == 0); | 2165 EXPECT(peer == 0); |
| 2164 Dart_ExitScope(); | 2166 Dart_ExitScope(); |
| 2165 } | 2167 } |
| 2166 Isolate::Current()->heap()->CollectGarbage(Heap::kOld); | 2168 Isolate::Current()->heap()->CollectGarbage(Heap::kOld); |
| 2167 EXPECT(peer == 0); | 2169 EXPECT(peer == 0); |
| 2168 GCTestHelper::CollectNewSpace(Heap::kIgnoreApiCallbacks); | 2170 GCTestHelper::CollectNewSpace(Heap::kIgnoreApiCallbacks); |
| 2169 EXPECT(peer == 42); | 2171 EXPECT(peer == 42); |
| 2170 Dart_Isolate isolate = reinterpret_cast<Dart_Isolate>(Isolate::Current()); | 2172 Dart_Isolate isolate = reinterpret_cast<Dart_Isolate>(Isolate::Current()); |
| 2171 Dart_DeleteWeakPersistentHandle(isolate, weak_ref); | 2173 Dart_DeleteWeakPersistentHandle(isolate, weak_ref); |
| 2172 } | 2174 } |
| 2173 | 2175 |
| 2174 | 2176 |
| 2175 TEST_CASE(WeakPersistentHandleNoCallback) { | 2177 TEST_CASE(WeakPersistentHandleNoCallback) { |
| 2176 Dart_WeakPersistentHandle weak_ref = NULL; | 2178 Dart_WeakPersistentHandle weak_ref = NULL; |
| 2177 int peer = 0; | 2179 int peer = 0; |
| 2178 { | 2180 { |
| 2179 Dart_EnterScope(); | 2181 Dart_EnterScope(); |
| 2180 Dart_Handle obj = NewString("new string"); | 2182 Dart_Handle obj = NewString("new string"); |
| 2181 EXPECT_VALID(obj); | 2183 EXPECT_VALID(obj); |
| 2182 weak_ref = Dart_NewWeakPersistentHandle(obj, &peer, | 2184 weak_ref = Dart_NewWeakPersistentHandle(obj, &peer, 0, |
| 2183 WeakPersistentHandlePeerFinalizer); | 2185 WeakPersistentHandlePeerFinalizer); |
| 2184 Dart_ExitScope(); | 2186 Dart_ExitScope(); |
| 2185 } | 2187 } |
| 2186 // A finalizer is not invoked on a deleted handle. Therefore, the | 2188 // A finalizer is not invoked on a deleted handle. Therefore, the |
| 2187 // peer value should not change after the referent is collected. | 2189 // peer value should not change after the referent is collected. |
| 2188 Dart_Isolate isolate = reinterpret_cast<Dart_Isolate>(Isolate::Current()); | 2190 Dart_Isolate isolate = reinterpret_cast<Dart_Isolate>(Isolate::Current()); |
| 2189 Dart_DeleteWeakPersistentHandle(isolate, weak_ref); | 2191 Dart_DeleteWeakPersistentHandle(isolate, weak_ref); |
| 2190 EXPECT(peer == 0); | 2192 EXPECT(peer == 0); |
| 2191 Isolate::Current()->heap()->CollectGarbage(Heap::kOld); | 2193 Isolate::Current()->heap()->CollectGarbage(Heap::kOld); |
| 2192 EXPECT(peer == 0); | 2194 EXPECT(peer == 0); |
| 2193 GCTestHelper::CollectNewSpace(Heap::kIgnoreApiCallbacks); | 2195 GCTestHelper::CollectNewSpace(Heap::kIgnoreApiCallbacks); |
| 2194 EXPECT(peer == 0); | 2196 EXPECT(peer == 0); |
| 2195 } | 2197 } |
| 2196 | 2198 |
| 2197 | 2199 |
| 2198 UNIT_TEST_CASE(WeakPersistentHandlesCallbackShutdown) { | 2200 UNIT_TEST_CASE(WeakPersistentHandlesCallbackShutdown) { |
| 2199 TestCase::CreateTestIsolate(); | 2201 TestCase::CreateTestIsolate(); |
| 2200 Dart_EnterScope(); | 2202 Dart_EnterScope(); |
| 2201 Dart_Handle ref = Dart_True(); | 2203 Dart_Handle ref = Dart_True(); |
| 2202 int peer = 1234; | 2204 int peer = 1234; |
| 2203 Dart_NewWeakPersistentHandle(ref, | 2205 Dart_NewWeakPersistentHandle(ref, |
| 2204 &peer, | 2206 &peer, |
| 2207 0, |
| 2205 WeakPersistentHandlePeerFinalizer); | 2208 WeakPersistentHandlePeerFinalizer); |
| 2206 Dart_ShutdownIsolate(); | 2209 Dart_ShutdownIsolate(); |
| 2207 EXPECT(peer == 42); | 2210 EXPECT(peer == 42); |
| 2208 } | 2211 } |
| 2209 | 2212 |
| 2210 | 2213 |
| 2214 TEST_CASE(WeakPersistentHandleExternalAllocationSize) { |
| 2215 Heap* heap = Isolate::Current()->heap(); |
| 2216 EXPECT(heap->ExternalInWords(Heap::kNew) == 0); |
| 2217 EXPECT(heap->ExternalInWords(Heap::kOld) == 0); |
| 2218 Dart_WeakPersistentHandle weak1 = NULL; |
| 2219 static const intptr_t kWeak1ExternalSize = 1 * KB; |
| 2220 { |
| 2221 Dart_EnterScope(); |
| 2222 Dart_Handle obj = NewString("weakly referenced string"); |
| 2223 EXPECT_VALID(obj); |
| 2224 weak1 = Dart_NewWeakPersistentHandle(obj, NULL, kWeak1ExternalSize, NULL); |
| 2225 EXPECT_VALID(AsHandle(weak1)); |
| 2226 EXPECT(!Dart_IsPrologueWeakPersistentHandle(weak1)); |
| 2227 Dart_ExitScope(); |
| 2228 } |
| 2229 Dart_PersistentHandle strong_ref = NULL; |
| 2230 Dart_WeakPersistentHandle weak2 = NULL; |
| 2231 static const intptr_t kWeak2ExternalSize = 2 * KB; |
| 2232 { |
| 2233 Dart_EnterScope(); |
| 2234 Dart_Handle obj = NewString("strongly referenced string"); |
| 2235 EXPECT_VALID(obj); |
| 2236 strong_ref = Dart_NewPersistentHandle(obj); |
| 2237 weak2 = Dart_NewWeakPersistentHandle(obj, NULL, kWeak2ExternalSize, NULL); |
| 2238 EXPECT_VALID(AsHandle(strong_ref)); |
| 2239 Dart_ExitScope(); |
| 2240 } |
| 2241 Isolate::Current()->heap()->CollectGarbage(Heap::kOld); |
| 2242 EXPECT(heap->ExternalInWords(Heap::kNew) == |
| 2243 (kWeak1ExternalSize + kWeak2ExternalSize) / kWordSize); |
| 2244 // Collect weakly referenced string, and promote strongly referenced string. |
| 2245 GCTestHelper::CollectNewSpace(Heap::kIgnoreApiCallbacks); |
| 2246 GCTestHelper::CollectNewSpace(Heap::kIgnoreApiCallbacks); |
| 2247 EXPECT(heap->ExternalInWords(Heap::kNew) == 0); |
| 2248 EXPECT(heap->ExternalInWords(Heap::kOld) == kWeak2ExternalSize / kWordSize); |
| 2249 Dart_Isolate isolate = reinterpret_cast<Dart_Isolate>(Isolate::Current()); |
| 2250 Dart_DeleteWeakPersistentHandle(isolate, weak1); |
| 2251 Dart_DeleteWeakPersistentHandle(isolate, weak2); |
| 2252 Dart_DeletePersistentHandle(strong_ref); |
| 2253 Isolate::Current()->heap()->CollectGarbage(Heap::kOld); |
| 2254 EXPECT(heap->ExternalInWords(Heap::kOld) == 0); |
| 2255 } |
| 2256 |
| 2257 |
| 2258 TEST_CASE(WeakPersistentHandleExternalAllocationSizeOversized) { |
| 2259 Heap* heap = Isolate::Current()->heap(); |
| 2260 Dart_WeakPersistentHandle weak1 = NULL; |
| 2261 const intptr_t kWeak1ExternalSize = 100 * MB; |
| 2262 { |
| 2263 Dart_EnterScope(); |
| 2264 Dart_Handle obj = NewString("weakly referenced string"); |
| 2265 EXPECT_VALID(obj); |
| 2266 weak1 = Dart_NewWeakPersistentHandle(obj, NULL, kWeak1ExternalSize, NULL); |
| 2267 EXPECT_VALID(AsHandle(weak1)); |
| 2268 // While new space is "full" of external data, any allocation will |
| 2269 // trigger GC, so after two of them, obj should be promoted. |
| 2270 Dart_Handle trigger1 = NewString("trigger1"); |
| 2271 EXPECT_VALID(trigger1); |
| 2272 Dart_Handle trigger2 = NewString("trigger2"); |
| 2273 EXPECT_VALID(trigger2); |
| 2274 { |
| 2275 DARTSCOPE(Isolate::Current()); |
| 2276 String& handle = String::Handle(); |
| 2277 handle ^= Api::UnwrapHandle(obj); |
| 2278 EXPECT(handle.IsOld()); |
| 2279 } |
| 2280 EXPECT(heap->ExternalInWords(Heap::kNew) == 0); |
| 2281 EXPECT(heap->ExternalInWords(Heap::kOld) == kWeak1ExternalSize / kWordSize); |
| 2282 Dart_ExitScope(); |
| 2283 } |
| 2284 Dart_Isolate isolate = reinterpret_cast<Dart_Isolate>(Isolate::Current()); |
| 2285 Dart_DeleteWeakPersistentHandle(isolate, weak1); |
| 2286 Isolate::Current()->heap()->CollectGarbage(Heap::kOld); |
| 2287 EXPECT(heap->ExternalInWords(Heap::kOld) == 0); |
| 2288 } |
| 2289 |
| 2290 |
| 2291 TEST_CASE(WeakPersistentHandleExternalAllocationSizeOddReferents) { |
| 2292 Heap* heap = Isolate::Current()->heap(); |
| 2293 Dart_WeakPersistentHandle weak1 = NULL; |
| 2294 static const intptr_t kWeak1ExternalSize = 1 * KB; |
| 2295 Dart_WeakPersistentHandle weak2 = NULL; |
| 2296 static const intptr_t kWeak2ExternalSize = 2 * KB; |
| 2297 { |
| 2298 Dart_EnterScope(); |
| 2299 Dart_Handle dart_null = Dart_Null(); // VM heap object. |
| 2300 EXPECT_VALID(dart_null); |
| 2301 weak1 = Dart_NewWeakPersistentHandle( |
| 2302 dart_null, NULL, kWeak1ExternalSize, NULL); |
| 2303 EXPECT_VALID(AsHandle(weak1)); |
| 2304 Dart_Handle zero = Dart_NewInteger(0); // Smi. |
| 2305 EXPECT_VALID(dart_null); |
| 2306 weak2 = Dart_NewWeakPersistentHandle( |
| 2307 zero, NULL, kWeak2ExternalSize, NULL); |
| 2308 EXPECT_VALID(AsHandle(weak2)); |
| 2309 // Both should be charged to old space. |
| 2310 EXPECT(heap->ExternalInWords(Heap::kOld) == |
| 2311 (kWeak1ExternalSize + kWeak2ExternalSize) / kWordSize); |
| 2312 Dart_ExitScope(); |
| 2313 } |
| 2314 Dart_Isolate isolate = reinterpret_cast<Dart_Isolate>(Isolate::Current()); |
| 2315 Dart_DeleteWeakPersistentHandle(isolate, weak1); |
| 2316 Dart_DeleteWeakPersistentHandle(isolate, weak2); |
| 2317 Isolate::Current()->heap()->CollectGarbage(Heap::kOld); |
| 2318 EXPECT(heap->ExternalInWords(Heap::kOld) == 0); |
| 2319 } |
| 2320 |
| 2321 |
| 2211 TEST_CASE(ObjectGroups) { | 2322 TEST_CASE(ObjectGroups) { |
| 2212 Dart_PersistentHandle strong = NULL; | 2323 Dart_PersistentHandle strong = NULL; |
| 2213 Dart_WeakPersistentHandle strong_weak = NULL; | 2324 Dart_WeakPersistentHandle strong_weak = NULL; |
| 2214 | 2325 |
| 2215 Dart_WeakPersistentHandle weak1 = NULL; | 2326 Dart_WeakPersistentHandle weak1 = NULL; |
| 2216 Dart_WeakPersistentHandle weak2 = NULL; | 2327 Dart_WeakPersistentHandle weak2 = NULL; |
| 2217 Dart_WeakPersistentHandle weak3 = NULL; | 2328 Dart_WeakPersistentHandle weak3 = NULL; |
| 2218 Dart_WeakPersistentHandle weak4 = NULL; | 2329 Dart_WeakPersistentHandle weak4 = NULL; |
| 2219 | 2330 |
| 2220 Dart_EnterScope(); | 2331 Dart_EnterScope(); |
| 2221 { | 2332 { |
| 2222 Isolate* isolate = Isolate::Current(); | 2333 Isolate* isolate = Isolate::Current(); |
| 2223 DARTSCOPE(isolate); | 2334 DARTSCOPE(isolate); |
| 2224 | 2335 |
| 2225 Dart_Handle local = Api::NewHandle( | 2336 Dart_Handle local = Api::NewHandle( |
| 2226 isolate, String::New("strongly reachable", Heap::kOld)); | 2337 isolate, String::New("strongly reachable", Heap::kOld)); |
| 2227 strong = Dart_NewPersistentHandle(local); | 2338 strong = Dart_NewPersistentHandle(local); |
| 2228 strong_weak = Dart_NewWeakPersistentHandle(local, NULL, NULL); | 2339 strong_weak = Dart_NewWeakPersistentHandle(local, NULL, 0, NULL); |
| 2229 EXPECT_VALID(AsHandle(strong)); | 2340 EXPECT_VALID(AsHandle(strong)); |
| 2230 EXPECT(!Dart_IsNull(AsHandle(strong))); | 2341 EXPECT(!Dart_IsNull(AsHandle(strong))); |
| 2231 | 2342 |
| 2232 weak1 = Dart_NewWeakPersistentHandle( | 2343 weak1 = Dart_NewWeakPersistentHandle( |
| 2233 Api::NewHandle(isolate, String::New("weakly reachable 1", Heap::kOld)), | 2344 Api::NewHandle(isolate, String::New("weakly reachable 1", Heap::kOld)), |
| 2234 NULL, NULL); | 2345 NULL, 0, NULL); |
| 2235 EXPECT_VALID(AsHandle(weak1)); | 2346 EXPECT_VALID(AsHandle(weak1)); |
| 2236 EXPECT(!Dart_IsNull(AsHandle(weak1))); | 2347 EXPECT(!Dart_IsNull(AsHandle(weak1))); |
| 2237 | 2348 |
| 2238 weak2 = Dart_NewWeakPersistentHandle( | 2349 weak2 = Dart_NewWeakPersistentHandle( |
| 2239 Api::NewHandle(isolate, String::New("weakly reachable 2", Heap::kOld)), | 2350 Api::NewHandle(isolate, String::New("weakly reachable 2", Heap::kOld)), |
| 2240 NULL, NULL); | 2351 NULL, 0, NULL); |
| 2241 EXPECT_VALID(AsHandle(weak2)); | 2352 EXPECT_VALID(AsHandle(weak2)); |
| 2242 EXPECT(!Dart_IsNull(AsHandle(weak2))); | 2353 EXPECT(!Dart_IsNull(AsHandle(weak2))); |
| 2243 | 2354 |
| 2244 weak3 = Dart_NewWeakPersistentHandle( | 2355 weak3 = Dart_NewWeakPersistentHandle( |
| 2245 Api::NewHandle(isolate, String::New("weakly reachable 3", Heap::kOld)), | 2356 Api::NewHandle(isolate, String::New("weakly reachable 3", Heap::kOld)), |
| 2246 NULL, NULL); | 2357 NULL, 0, NULL); |
| 2247 EXPECT_VALID(AsHandle(weak3)); | 2358 EXPECT_VALID(AsHandle(weak3)); |
| 2248 EXPECT(!Dart_IsNull(AsHandle(weak3))); | 2359 EXPECT(!Dart_IsNull(AsHandle(weak3))); |
| 2249 | 2360 |
| 2250 weak4 = Dart_NewWeakPersistentHandle( | 2361 weak4 = Dart_NewWeakPersistentHandle( |
| 2251 Api::NewHandle(isolate, String::New("weakly reachable 4", Heap::kOld)), | 2362 Api::NewHandle(isolate, String::New("weakly reachable 4", Heap::kOld)), |
| 2252 NULL, NULL); | 2363 NULL, 0, NULL); |
| 2253 EXPECT_VALID(AsHandle(weak4)); | 2364 EXPECT_VALID(AsHandle(weak4)); |
| 2254 EXPECT(!Dart_IsNull(AsHandle(weak4))); | 2365 EXPECT(!Dart_IsNull(AsHandle(weak4))); |
| 2255 } | 2366 } |
| 2256 Dart_ExitScope(); | 2367 Dart_ExitScope(); |
| 2257 | 2368 |
| 2258 { | 2369 { |
| 2259 Dart_EnterScope(); | 2370 Dart_EnterScope(); |
| 2260 EXPECT_VALID(AsHandle(strong)); | 2371 EXPECT_VALID(AsHandle(strong)); |
| 2261 EXPECT_VALID(AsHandle(weak1)); | 2372 EXPECT_VALID(AsHandle(weak1)); |
| 2262 EXPECT_VALID(AsHandle(weak2)); | 2373 EXPECT_VALID(AsHandle(weak2)); |
| (...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2435 Dart_WeakPersistentHandle old_pwph = NULL; | 2546 Dart_WeakPersistentHandle old_pwph = NULL; |
| 2436 Dart_WeakPersistentHandle new_pwph = NULL; | 2547 Dart_WeakPersistentHandle new_pwph = NULL; |
| 2437 | 2548 |
| 2438 Dart_EnterScope(); | 2549 Dart_EnterScope(); |
| 2439 { | 2550 { |
| 2440 Isolate* isolate = Isolate::Current(); | 2551 Isolate* isolate = Isolate::Current(); |
| 2441 DARTSCOPE(isolate); | 2552 DARTSCOPE(isolate); |
| 2442 new_pwph = Dart_NewPrologueWeakPersistentHandle( | 2553 new_pwph = Dart_NewPrologueWeakPersistentHandle( |
| 2443 Api::NewHandle(isolate, | 2554 Api::NewHandle(isolate, |
| 2444 String::New("new space prologue weak", Heap::kNew)), | 2555 String::New("new space prologue weak", Heap::kNew)), |
| 2445 NULL, NULL); | 2556 NULL, 0, NULL); |
| 2446 EXPECT_VALID(AsHandle(new_pwph)); | 2557 EXPECT_VALID(AsHandle(new_pwph)); |
| 2447 EXPECT(!Dart_IsNull(AsHandle(new_pwph))); | 2558 EXPECT(!Dart_IsNull(AsHandle(new_pwph))); |
| 2448 old_pwph = Dart_NewPrologueWeakPersistentHandle( | 2559 old_pwph = Dart_NewPrologueWeakPersistentHandle( |
| 2449 Api::NewHandle(isolate, | 2560 Api::NewHandle(isolate, |
| 2450 String::New("old space prologue weak", Heap::kOld)), | 2561 String::New("old space prologue weak", Heap::kOld)), |
| 2451 NULL, NULL); | 2562 NULL, 0, NULL); |
| 2452 EXPECT_VALID(AsHandle(old_pwph)); | 2563 EXPECT_VALID(AsHandle(old_pwph)); |
| 2453 EXPECT(!Dart_IsNull(AsHandle(old_pwph))); | 2564 EXPECT(!Dart_IsNull(AsHandle(old_pwph))); |
| 2454 } | 2565 } |
| 2455 Dart_ExitScope(); | 2566 Dart_ExitScope(); |
| 2456 | 2567 |
| 2457 { | 2568 { |
| 2458 Dart_EnterScope(); | 2569 Dart_EnterScope(); |
| 2459 EXPECT_VALID(AsHandle(new_pwph)); | 2570 EXPECT_VALID(AsHandle(new_pwph)); |
| 2460 EXPECT(!Dart_IsNull(AsHandle(new_pwph))); | 2571 EXPECT(!Dart_IsNull(AsHandle(new_pwph))); |
| 2461 EXPECT(Dart_IsPrologueWeakPersistentHandle(new_pwph)); | 2572 EXPECT(Dart_IsPrologueWeakPersistentHandle(new_pwph)); |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2523 Dart_WeakPersistentHandle weak3 = NULL; | 2634 Dart_WeakPersistentHandle weak3 = NULL; |
| 2524 | 2635 |
| 2525 Dart_EnterScope(); | 2636 Dart_EnterScope(); |
| 2526 { | 2637 { |
| 2527 Isolate* isolate = Isolate::Current(); | 2638 Isolate* isolate = Isolate::Current(); |
| 2528 DARTSCOPE(isolate); | 2639 DARTSCOPE(isolate); |
| 2529 | 2640 |
| 2530 Dart_Handle local = Api::NewHandle( | 2641 Dart_Handle local = Api::NewHandle( |
| 2531 isolate, String::New("strongly reachable", Heap::kOld)); | 2642 isolate, String::New("strongly reachable", Heap::kOld)); |
| 2532 strong = Dart_NewPersistentHandle(local); | 2643 strong = Dart_NewPersistentHandle(local); |
| 2533 strong_weak = Dart_NewWeakPersistentHandle(local, NULL, NULL); | 2644 strong_weak = Dart_NewWeakPersistentHandle(local, NULL, 0, NULL); |
| 2534 | 2645 |
| 2535 EXPECT(!Dart_IsNull(AsHandle(strong))); | 2646 EXPECT(!Dart_IsNull(AsHandle(strong))); |
| 2536 EXPECT_VALID(AsHandle(strong)); | 2647 EXPECT_VALID(AsHandle(strong)); |
| 2537 EXPECT(!Dart_IsNull(AsHandle(strong_weak))); | 2648 EXPECT(!Dart_IsNull(AsHandle(strong_weak))); |
| 2538 EXPECT_VALID(AsHandle(strong_weak)); | 2649 EXPECT_VALID(AsHandle(strong_weak)); |
| 2539 EXPECT(Dart_IdentityEquals(AsHandle(strong), AsHandle(strong_weak))) | 2650 EXPECT(Dart_IdentityEquals(AsHandle(strong), AsHandle(strong_weak))) |
| 2540 | 2651 |
| 2541 weak1 = Dart_NewWeakPersistentHandle( | 2652 weak1 = Dart_NewWeakPersistentHandle( |
| 2542 Api::NewHandle(isolate, String::New("weakly reachable 1", Heap::kOld)), | 2653 Api::NewHandle(isolate, String::New("weakly reachable 1", Heap::kOld)), |
| 2543 NULL, NULL); | 2654 NULL, 0, NULL); |
| 2544 EXPECT(!Dart_IsNull(AsHandle(weak1))); | 2655 EXPECT(!Dart_IsNull(AsHandle(weak1))); |
| 2545 EXPECT_VALID(AsHandle(weak1)); | 2656 EXPECT_VALID(AsHandle(weak1)); |
| 2546 | 2657 |
| 2547 weak2 = Dart_NewWeakPersistentHandle( | 2658 weak2 = Dart_NewWeakPersistentHandle( |
| 2548 Api::NewHandle(isolate, String::New("weakly reachable 2", Heap::kOld)), | 2659 Api::NewHandle(isolate, String::New("weakly reachable 2", Heap::kOld)), |
| 2549 NULL, NULL); | 2660 NULL, 0, NULL); |
| 2550 EXPECT(!Dart_IsNull(AsHandle(weak2))); | 2661 EXPECT(!Dart_IsNull(AsHandle(weak2))); |
| 2551 EXPECT_VALID(AsHandle(weak2)); | 2662 EXPECT_VALID(AsHandle(weak2)); |
| 2552 | 2663 |
| 2553 weak3 = Dart_NewWeakPersistentHandle( | 2664 weak3 = Dart_NewWeakPersistentHandle( |
| 2554 Api::NewHandle(isolate, String::New("weakly reachable 3", Heap::kOld)), | 2665 Api::NewHandle(isolate, String::New("weakly reachable 3", Heap::kOld)), |
| 2555 NULL, NULL); | 2666 NULL, 0, NULL); |
| 2556 EXPECT(!Dart_IsNull(AsHandle(weak3))); | 2667 EXPECT(!Dart_IsNull(AsHandle(weak3))); |
| 2557 EXPECT_VALID(AsHandle(weak3)); | 2668 EXPECT_VALID(AsHandle(weak3)); |
| 2558 } | 2669 } |
| 2559 Dart_ExitScope(); | 2670 Dart_ExitScope(); |
| 2560 | 2671 |
| 2561 { | 2672 { |
| 2562 Dart_EnterScope(); | 2673 Dart_EnterScope(); |
| 2563 EXPECT_VALID(AsHandle(strong_weak)); | 2674 EXPECT_VALID(AsHandle(strong_weak)); |
| 2564 EXPECT_VALID(AsHandle(weak1)); | 2675 EXPECT_VALID(AsHandle(weak1)); |
| 2565 EXPECT_VALID(AsHandle(weak2)); | 2676 EXPECT_VALID(AsHandle(weak2)); |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2629 Dart_WeakPersistentHandle weak3 = NULL; | 2740 Dart_WeakPersistentHandle weak3 = NULL; |
| 2630 | 2741 |
| 2631 Dart_EnterScope(); | 2742 Dart_EnterScope(); |
| 2632 { | 2743 { |
| 2633 Isolate* isolate = Isolate::Current(); | 2744 Isolate* isolate = Isolate::Current(); |
| 2634 DARTSCOPE(isolate); | 2745 DARTSCOPE(isolate); |
| 2635 | 2746 |
| 2636 Dart_Handle local = Api::NewHandle( | 2747 Dart_Handle local = Api::NewHandle( |
| 2637 isolate, String::New("strongly reachable", Heap::kOld)); | 2748 isolate, String::New("strongly reachable", Heap::kOld)); |
| 2638 strong = Dart_NewPersistentHandle(local); | 2749 strong = Dart_NewPersistentHandle(local); |
| 2639 strong_weak = Dart_NewWeakPersistentHandle(local, NULL, NULL); | 2750 strong_weak = Dart_NewWeakPersistentHandle(local, NULL, 0, NULL); |
| 2640 | 2751 |
| 2641 EXPECT(!Dart_IsNull(AsHandle(strong))); | 2752 EXPECT(!Dart_IsNull(AsHandle(strong))); |
| 2642 EXPECT_VALID(AsHandle(strong)); | 2753 EXPECT_VALID(AsHandle(strong)); |
| 2643 EXPECT(!Dart_IsNull(AsHandle(strong_weak))); | 2754 EXPECT(!Dart_IsNull(AsHandle(strong_weak))); |
| 2644 EXPECT_VALID(AsHandle(strong_weak)); | 2755 EXPECT_VALID(AsHandle(strong_weak)); |
| 2645 EXPECT(Dart_IdentityEquals(AsHandle(strong), AsHandle(strong_weak))) | 2756 EXPECT(Dart_IdentityEquals(AsHandle(strong), AsHandle(strong_weak))) |
| 2646 | 2757 |
| 2647 weak1 = Dart_NewWeakPersistentHandle( | 2758 weak1 = Dart_NewWeakPersistentHandle( |
| 2648 Api::NewHandle(isolate, String::New("weakly reachable 1", Heap::kNew)), | 2759 Api::NewHandle(isolate, String::New("weakly reachable 1", Heap::kNew)), |
| 2649 NULL, NULL); | 2760 NULL, 0, NULL); |
| 2650 EXPECT(!Dart_IsNull(AsHandle(weak1))); | 2761 EXPECT(!Dart_IsNull(AsHandle(weak1))); |
| 2651 EXPECT_VALID(AsHandle(weak1)); | 2762 EXPECT_VALID(AsHandle(weak1)); |
| 2652 | 2763 |
| 2653 weak2 = Dart_NewWeakPersistentHandle( | 2764 weak2 = Dart_NewWeakPersistentHandle( |
| 2654 Api::NewHandle(isolate, String::New("weakly reachable 2", Heap::kNew)), | 2765 Api::NewHandle(isolate, String::New("weakly reachable 2", Heap::kNew)), |
| 2655 NULL, NULL); | 2766 NULL, 0, NULL); |
| 2656 EXPECT(!Dart_IsNull(AsHandle(weak2))); | 2767 EXPECT(!Dart_IsNull(AsHandle(weak2))); |
| 2657 EXPECT_VALID(AsHandle(weak2)); | 2768 EXPECT_VALID(AsHandle(weak2)); |
| 2658 | 2769 |
| 2659 weak3 = Dart_NewWeakPersistentHandle( | 2770 weak3 = Dart_NewWeakPersistentHandle( |
| 2660 Api::NewHandle(isolate, String::New("weakly reachable 3", Heap::kNew)), | 2771 Api::NewHandle(isolate, String::New("weakly reachable 3", Heap::kNew)), |
| 2661 NULL, NULL); | 2772 NULL, 0, NULL); |
| 2662 EXPECT(!Dart_IsNull(AsHandle(weak3))); | 2773 EXPECT(!Dart_IsNull(AsHandle(weak3))); |
| 2663 EXPECT_VALID(AsHandle(weak3)); | 2774 EXPECT_VALID(AsHandle(weak3)); |
| 2664 } | 2775 } |
| 2665 Dart_ExitScope(); | 2776 Dart_ExitScope(); |
| 2666 | 2777 |
| 2667 { | 2778 { |
| 2668 Dart_EnterScope(); | 2779 Dart_EnterScope(); |
| 2669 EXPECT_VALID(AsHandle(strong_weak)); | 2780 EXPECT_VALID(AsHandle(strong_weak)); |
| 2670 EXPECT_VALID(AsHandle(weak1)); | 2781 EXPECT_VALID(AsHandle(weak1)); |
| 2671 EXPECT_VALID(AsHandle(weak2)); | 2782 EXPECT_VALID(AsHandle(weak2)); |
| (...skipping 5326 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7998 NewString("main"), | 8109 NewString("main"), |
| 7999 1, | 8110 1, |
| 8000 dart_args); | 8111 dart_args); |
| 8001 int64_t value = 0; | 8112 int64_t value = 0; |
| 8002 result = Dart_IntegerToInt64(result, &value); | 8113 result = Dart_IntegerToInt64(result, &value); |
| 8003 EXPECT_VALID(result); | 8114 EXPECT_VALID(result); |
| 8004 EXPECT_EQ(6, value); | 8115 EXPECT_EQ(6, value); |
| 8005 } | 8116 } |
| 8006 | 8117 |
| 8007 } // namespace dart | 8118 } // namespace dart |
| OLD | NEW |