Chromium Code Reviews| 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 1694 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 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 Loading... | |
| 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 Loading... | |
| 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 Loading... | |
| 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->ExternalInWords(Heap::kNew) == 0); | |
| 2131 EXPECT(heap->ExternalInWords(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); | |
|
siva
2014/03/06 17:17:39
could we have constants
const intptr_t kWeak1Exter
koda
2014/03/06 22:55:07
Done.
| |
| 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->ExternalInWords(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->ExternalInWords(Heap::kNew) == 0); | |
| 2158 EXPECT(heap->ExternalInWords(Heap::kOld) == 2048/kWordSize); | |
| 2159 Dart_DeleteWeakPersistentHandle(weak1); | |
| 2160 Dart_DeleteWeakPersistentHandle(weak2); | |
| 2161 Dart_DeletePersistentHandle(strong_ref); | |
|
siva
2014/03/06 17:17:39
Should we invoke the garbage collector here and ch
koda
2014/03/06 22:55:07
Done.
| |
| 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); | |
|
siva
2014/03/06 17:17:39
ditto comment here about use of constants.
koda
2014/03/06 22:55:07
Done.
| |
| 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->ExternalInWords(Heap::kNew) == 0); | |
| 2187 EXPECT(heap->ExternalInWords(Heap::kOld) == 100*MBInWords); | |
| 2188 Dart_ExitScope(); | |
| 2189 } | |
| 2190 Dart_DeleteWeakPersistentHandle(weak1); | |
|
siva
2014/03/06 17:17:39
Ditto comment regarding check.
koda
2014/03/06 22:55:07
Done.
| |
| 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); | |
|
siva
2014/03/06 17:17:39
Ditto.
koda
2014/03/06 22:55:07
Done.
| |
| 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->ExternalInWords(Heap::kOld) == (1024 + 2048)/kWordSize); | |
| 2210 Dart_ExitScope(); | |
| 2211 } | |
| 2212 Dart_DeleteWeakPersistentHandle(weak1); | |
| 2213 Dart_DeleteWeakPersistentHandle(weak2); | |
|
siva
2014/03/06 17:17:39
Ditto comment regarding check.
koda
2014/03/06 22:55:07
Done.
| |
| 2214 } | |
| 2215 | |
| 2216 | |
| 2125 TEST_CASE(ObjectGroups) { | 2217 TEST_CASE(ObjectGroups) { |
| 2126 Dart_PersistentHandle strong = NULL; | 2218 Dart_PersistentHandle strong = NULL; |
| 2127 Dart_WeakPersistentHandle strong_weak = NULL; | 2219 Dart_WeakPersistentHandle strong_weak = NULL; |
| 2128 | 2220 |
| 2129 Dart_WeakPersistentHandle weak1 = NULL; | 2221 Dart_WeakPersistentHandle weak1 = NULL; |
| 2130 Dart_WeakPersistentHandle weak2 = NULL; | 2222 Dart_WeakPersistentHandle weak2 = NULL; |
| 2131 Dart_WeakPersistentHandle weak3 = NULL; | 2223 Dart_WeakPersistentHandle weak3 = NULL; |
| 2132 Dart_WeakPersistentHandle weak4 = NULL; | 2224 Dart_WeakPersistentHandle weak4 = NULL; |
| 2133 | 2225 |
| 2134 Dart_EnterScope(); | 2226 Dart_EnterScope(); |
| 2135 { | 2227 { |
| 2136 Isolate* isolate = Isolate::Current(); | 2228 Isolate* isolate = Isolate::Current(); |
| 2137 DARTSCOPE(isolate); | 2229 DARTSCOPE(isolate); |
| 2138 | 2230 |
| 2139 Dart_Handle local = Api::NewHandle( | 2231 Dart_Handle local = Api::NewHandle( |
| 2140 isolate, String::New("strongly reachable", Heap::kOld)); | 2232 isolate, String::New("strongly reachable", Heap::kOld)); |
| 2141 strong = Dart_NewPersistentHandle(local); | 2233 strong = Dart_NewPersistentHandle(local); |
| 2142 strong_weak = Dart_NewWeakPersistentHandle(local, NULL, NULL); | 2234 strong_weak = Dart_NewWeakPersistentHandle(local, NULL, 0, NULL); |
| 2143 EXPECT_VALID(AsHandle(strong)); | 2235 EXPECT_VALID(AsHandle(strong)); |
| 2144 EXPECT(!Dart_IsNull(AsHandle(strong))); | 2236 EXPECT(!Dart_IsNull(AsHandle(strong))); |
| 2145 | 2237 |
| 2146 weak1 = Dart_NewWeakPersistentHandle( | 2238 weak1 = Dart_NewWeakPersistentHandle( |
| 2147 Api::NewHandle(isolate, String::New("weakly reachable 1", Heap::kOld)), | 2239 Api::NewHandle(isolate, String::New("weakly reachable 1", Heap::kOld)), |
| 2148 NULL, NULL); | 2240 NULL, 0, NULL); |
| 2149 EXPECT_VALID(AsHandle(weak1)); | 2241 EXPECT_VALID(AsHandle(weak1)); |
| 2150 EXPECT(!Dart_IsNull(AsHandle(weak1))); | 2242 EXPECT(!Dart_IsNull(AsHandle(weak1))); |
| 2151 | 2243 |
| 2152 weak2 = Dart_NewWeakPersistentHandle( | 2244 weak2 = Dart_NewWeakPersistentHandle( |
| 2153 Api::NewHandle(isolate, String::New("weakly reachable 2", Heap::kOld)), | 2245 Api::NewHandle(isolate, String::New("weakly reachable 2", Heap::kOld)), |
| 2154 NULL, NULL); | 2246 NULL, 0, NULL); |
| 2155 EXPECT_VALID(AsHandle(weak2)); | 2247 EXPECT_VALID(AsHandle(weak2)); |
| 2156 EXPECT(!Dart_IsNull(AsHandle(weak2))); | 2248 EXPECT(!Dart_IsNull(AsHandle(weak2))); |
| 2157 | 2249 |
| 2158 weak3 = Dart_NewWeakPersistentHandle( | 2250 weak3 = Dart_NewWeakPersistentHandle( |
| 2159 Api::NewHandle(isolate, String::New("weakly reachable 3", Heap::kOld)), | 2251 Api::NewHandle(isolate, String::New("weakly reachable 3", Heap::kOld)), |
| 2160 NULL, NULL); | 2252 NULL, 0, NULL); |
| 2161 EXPECT_VALID(AsHandle(weak3)); | 2253 EXPECT_VALID(AsHandle(weak3)); |
| 2162 EXPECT(!Dart_IsNull(AsHandle(weak3))); | 2254 EXPECT(!Dart_IsNull(AsHandle(weak3))); |
| 2163 | 2255 |
| 2164 weak4 = Dart_NewWeakPersistentHandle( | 2256 weak4 = Dart_NewWeakPersistentHandle( |
| 2165 Api::NewHandle(isolate, String::New("weakly reachable 4", Heap::kOld)), | 2257 Api::NewHandle(isolate, String::New("weakly reachable 4", Heap::kOld)), |
| 2166 NULL, NULL); | 2258 NULL, 0, NULL); |
| 2167 EXPECT_VALID(AsHandle(weak4)); | 2259 EXPECT_VALID(AsHandle(weak4)); |
| 2168 EXPECT(!Dart_IsNull(AsHandle(weak4))); | 2260 EXPECT(!Dart_IsNull(AsHandle(weak4))); |
| 2169 } | 2261 } |
| 2170 Dart_ExitScope(); | 2262 Dart_ExitScope(); |
| 2171 | 2263 |
| 2172 { | 2264 { |
| 2173 Dart_EnterScope(); | 2265 Dart_EnterScope(); |
| 2174 EXPECT_VALID(AsHandle(strong)); | 2266 EXPECT_VALID(AsHandle(strong)); |
| 2175 EXPECT_VALID(AsHandle(weak1)); | 2267 EXPECT_VALID(AsHandle(weak1)); |
| 2176 EXPECT_VALID(AsHandle(weak2)); | 2268 EXPECT_VALID(AsHandle(weak2)); |
| (...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2349 Dart_WeakPersistentHandle old_pwph = NULL; | 2441 Dart_WeakPersistentHandle old_pwph = NULL; |
| 2350 Dart_WeakPersistentHandle new_pwph = NULL; | 2442 Dart_WeakPersistentHandle new_pwph = NULL; |
| 2351 | 2443 |
| 2352 Dart_EnterScope(); | 2444 Dart_EnterScope(); |
| 2353 { | 2445 { |
| 2354 Isolate* isolate = Isolate::Current(); | 2446 Isolate* isolate = Isolate::Current(); |
| 2355 DARTSCOPE(isolate); | 2447 DARTSCOPE(isolate); |
| 2356 new_pwph = Dart_NewPrologueWeakPersistentHandle( | 2448 new_pwph = Dart_NewPrologueWeakPersistentHandle( |
| 2357 Api::NewHandle(isolate, | 2449 Api::NewHandle(isolate, |
| 2358 String::New("new space prologue weak", Heap::kNew)), | 2450 String::New("new space prologue weak", Heap::kNew)), |
| 2359 NULL, NULL); | 2451 NULL, 0, NULL); |
| 2360 EXPECT_VALID(AsHandle(new_pwph)); | 2452 EXPECT_VALID(AsHandle(new_pwph)); |
| 2361 EXPECT(!Dart_IsNull(AsHandle(new_pwph))); | 2453 EXPECT(!Dart_IsNull(AsHandle(new_pwph))); |
| 2362 old_pwph = Dart_NewPrologueWeakPersistentHandle( | 2454 old_pwph = Dart_NewPrologueWeakPersistentHandle( |
| 2363 Api::NewHandle(isolate, | 2455 Api::NewHandle(isolate, |
| 2364 String::New("old space prologue weak", Heap::kOld)), | 2456 String::New("old space prologue weak", Heap::kOld)), |
| 2365 NULL, NULL); | 2457 NULL, 0, NULL); |
| 2366 EXPECT_VALID(AsHandle(old_pwph)); | 2458 EXPECT_VALID(AsHandle(old_pwph)); |
| 2367 EXPECT(!Dart_IsNull(AsHandle(old_pwph))); | 2459 EXPECT(!Dart_IsNull(AsHandle(old_pwph))); |
| 2368 } | 2460 } |
| 2369 Dart_ExitScope(); | 2461 Dart_ExitScope(); |
| 2370 | 2462 |
| 2371 { | 2463 { |
| 2372 Dart_EnterScope(); | 2464 Dart_EnterScope(); |
| 2373 EXPECT_VALID(AsHandle(new_pwph)); | 2465 EXPECT_VALID(AsHandle(new_pwph)); |
| 2374 EXPECT(!Dart_IsNull(AsHandle(new_pwph))); | 2466 EXPECT(!Dart_IsNull(AsHandle(new_pwph))); |
| 2375 EXPECT(Dart_IsPrologueWeakPersistentHandle(new_pwph)); | 2467 EXPECT(Dart_IsPrologueWeakPersistentHandle(new_pwph)); |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2437 Dart_WeakPersistentHandle weak3 = NULL; | 2529 Dart_WeakPersistentHandle weak3 = NULL; |
| 2438 | 2530 |
| 2439 Dart_EnterScope(); | 2531 Dart_EnterScope(); |
| 2440 { | 2532 { |
| 2441 Isolate* isolate = Isolate::Current(); | 2533 Isolate* isolate = Isolate::Current(); |
| 2442 DARTSCOPE(isolate); | 2534 DARTSCOPE(isolate); |
| 2443 | 2535 |
| 2444 Dart_Handle local = Api::NewHandle( | 2536 Dart_Handle local = Api::NewHandle( |
| 2445 isolate, String::New("strongly reachable", Heap::kOld)); | 2537 isolate, String::New("strongly reachable", Heap::kOld)); |
| 2446 strong = Dart_NewPersistentHandle(local); | 2538 strong = Dart_NewPersistentHandle(local); |
| 2447 strong_weak = Dart_NewWeakPersistentHandle(local, NULL, NULL); | 2539 strong_weak = Dart_NewWeakPersistentHandle(local, NULL, 0, NULL); |
| 2448 | 2540 |
| 2449 EXPECT(!Dart_IsNull(AsHandle(strong))); | 2541 EXPECT(!Dart_IsNull(AsHandle(strong))); |
| 2450 EXPECT_VALID(AsHandle(strong)); | 2542 EXPECT_VALID(AsHandle(strong)); |
| 2451 EXPECT(!Dart_IsNull(AsHandle(strong_weak))); | 2543 EXPECT(!Dart_IsNull(AsHandle(strong_weak))); |
| 2452 EXPECT_VALID(AsHandle(strong_weak)); | 2544 EXPECT_VALID(AsHandle(strong_weak)); |
| 2453 EXPECT(Dart_IdentityEquals(AsHandle(strong), AsHandle(strong_weak))) | 2545 EXPECT(Dart_IdentityEquals(AsHandle(strong), AsHandle(strong_weak))) |
| 2454 | 2546 |
| 2455 weak1 = Dart_NewWeakPersistentHandle( | 2547 weak1 = Dart_NewWeakPersistentHandle( |
| 2456 Api::NewHandle(isolate, String::New("weakly reachable 1", Heap::kOld)), | 2548 Api::NewHandle(isolate, String::New("weakly reachable 1", Heap::kOld)), |
| 2457 NULL, NULL); | 2549 NULL, 0, NULL); |
| 2458 EXPECT(!Dart_IsNull(AsHandle(weak1))); | 2550 EXPECT(!Dart_IsNull(AsHandle(weak1))); |
| 2459 EXPECT_VALID(AsHandle(weak1)); | 2551 EXPECT_VALID(AsHandle(weak1)); |
| 2460 | 2552 |
| 2461 weak2 = Dart_NewWeakPersistentHandle( | 2553 weak2 = Dart_NewWeakPersistentHandle( |
| 2462 Api::NewHandle(isolate, String::New("weakly reachable 2", Heap::kOld)), | 2554 Api::NewHandle(isolate, String::New("weakly reachable 2", Heap::kOld)), |
| 2463 NULL, NULL); | 2555 NULL, 0, NULL); |
| 2464 EXPECT(!Dart_IsNull(AsHandle(weak2))); | 2556 EXPECT(!Dart_IsNull(AsHandle(weak2))); |
| 2465 EXPECT_VALID(AsHandle(weak2)); | 2557 EXPECT_VALID(AsHandle(weak2)); |
| 2466 | 2558 |
| 2467 weak3 = Dart_NewWeakPersistentHandle( | 2559 weak3 = Dart_NewWeakPersistentHandle( |
| 2468 Api::NewHandle(isolate, String::New("weakly reachable 3", Heap::kOld)), | 2560 Api::NewHandle(isolate, String::New("weakly reachable 3", Heap::kOld)), |
| 2469 NULL, NULL); | 2561 NULL, 0, NULL); |
| 2470 EXPECT(!Dart_IsNull(AsHandle(weak3))); | 2562 EXPECT(!Dart_IsNull(AsHandle(weak3))); |
| 2471 EXPECT_VALID(AsHandle(weak3)); | 2563 EXPECT_VALID(AsHandle(weak3)); |
| 2472 } | 2564 } |
| 2473 Dart_ExitScope(); | 2565 Dart_ExitScope(); |
| 2474 | 2566 |
| 2475 { | 2567 { |
| 2476 Dart_EnterScope(); | 2568 Dart_EnterScope(); |
| 2477 EXPECT_VALID(AsHandle(strong_weak)); | 2569 EXPECT_VALID(AsHandle(strong_weak)); |
| 2478 EXPECT_VALID(AsHandle(weak1)); | 2570 EXPECT_VALID(AsHandle(weak1)); |
| 2479 EXPECT_VALID(AsHandle(weak2)); | 2571 EXPECT_VALID(AsHandle(weak2)); |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2543 Dart_WeakPersistentHandle weak3 = NULL; | 2635 Dart_WeakPersistentHandle weak3 = NULL; |
| 2544 | 2636 |
| 2545 Dart_EnterScope(); | 2637 Dart_EnterScope(); |
| 2546 { | 2638 { |
| 2547 Isolate* isolate = Isolate::Current(); | 2639 Isolate* isolate = Isolate::Current(); |
| 2548 DARTSCOPE(isolate); | 2640 DARTSCOPE(isolate); |
| 2549 | 2641 |
| 2550 Dart_Handle local = Api::NewHandle( | 2642 Dart_Handle local = Api::NewHandle( |
| 2551 isolate, String::New("strongly reachable", Heap::kOld)); | 2643 isolate, String::New("strongly reachable", Heap::kOld)); |
| 2552 strong = Dart_NewPersistentHandle(local); | 2644 strong = Dart_NewPersistentHandle(local); |
| 2553 strong_weak = Dart_NewWeakPersistentHandle(local, NULL, NULL); | 2645 strong_weak = Dart_NewWeakPersistentHandle(local, NULL, 0, NULL); |
| 2554 | 2646 |
| 2555 EXPECT(!Dart_IsNull(AsHandle(strong))); | 2647 EXPECT(!Dart_IsNull(AsHandle(strong))); |
| 2556 EXPECT_VALID(AsHandle(strong)); | 2648 EXPECT_VALID(AsHandle(strong)); |
| 2557 EXPECT(!Dart_IsNull(AsHandle(strong_weak))); | 2649 EXPECT(!Dart_IsNull(AsHandle(strong_weak))); |
| 2558 EXPECT_VALID(AsHandle(strong_weak)); | 2650 EXPECT_VALID(AsHandle(strong_weak)); |
| 2559 EXPECT(Dart_IdentityEquals(AsHandle(strong), AsHandle(strong_weak))) | 2651 EXPECT(Dart_IdentityEquals(AsHandle(strong), AsHandle(strong_weak))) |
| 2560 | 2652 |
| 2561 weak1 = Dart_NewWeakPersistentHandle( | 2653 weak1 = Dart_NewWeakPersistentHandle( |
| 2562 Api::NewHandle(isolate, String::New("weakly reachable 1", Heap::kNew)), | 2654 Api::NewHandle(isolate, String::New("weakly reachable 1", Heap::kNew)), |
| 2563 NULL, NULL); | 2655 NULL, 0, NULL); |
| 2564 EXPECT(!Dart_IsNull(AsHandle(weak1))); | 2656 EXPECT(!Dart_IsNull(AsHandle(weak1))); |
| 2565 EXPECT_VALID(AsHandle(weak1)); | 2657 EXPECT_VALID(AsHandle(weak1)); |
| 2566 | 2658 |
| 2567 weak2 = Dart_NewWeakPersistentHandle( | 2659 weak2 = Dart_NewWeakPersistentHandle( |
| 2568 Api::NewHandle(isolate, String::New("weakly reachable 2", Heap::kNew)), | 2660 Api::NewHandle(isolate, String::New("weakly reachable 2", Heap::kNew)), |
| 2569 NULL, NULL); | 2661 NULL, 0, NULL); |
| 2570 EXPECT(!Dart_IsNull(AsHandle(weak2))); | 2662 EXPECT(!Dart_IsNull(AsHandle(weak2))); |
| 2571 EXPECT_VALID(AsHandle(weak2)); | 2663 EXPECT_VALID(AsHandle(weak2)); |
| 2572 | 2664 |
| 2573 weak3 = Dart_NewWeakPersistentHandle( | 2665 weak3 = Dart_NewWeakPersistentHandle( |
| 2574 Api::NewHandle(isolate, String::New("weakly reachable 3", Heap::kNew)), | 2666 Api::NewHandle(isolate, String::New("weakly reachable 3", Heap::kNew)), |
| 2575 NULL, NULL); | 2667 NULL, 0, NULL); |
| 2576 EXPECT(!Dart_IsNull(AsHandle(weak3))); | 2668 EXPECT(!Dart_IsNull(AsHandle(weak3))); |
| 2577 EXPECT_VALID(AsHandle(weak3)); | 2669 EXPECT_VALID(AsHandle(weak3)); |
| 2578 } | 2670 } |
| 2579 Dart_ExitScope(); | 2671 Dart_ExitScope(); |
| 2580 | 2672 |
| 2581 { | 2673 { |
| 2582 Dart_EnterScope(); | 2674 Dart_EnterScope(); |
| 2583 EXPECT_VALID(AsHandle(strong_weak)); | 2675 EXPECT_VALID(AsHandle(strong_weak)); |
| 2584 EXPECT_VALID(AsHandle(weak1)); | 2676 EXPECT_VALID(AsHandle(weak1)); |
| 2585 EXPECT_VALID(AsHandle(weak2)); | 2677 EXPECT_VALID(AsHandle(weak2)); |
| (...skipping 5326 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 7912 NewString("main"), | 8004 NewString("main"), |
| 7913 1, | 8005 1, |
| 7914 dart_args); | 8006 dart_args); |
| 7915 int64_t value = 0; | 8007 int64_t value = 0; |
| 7916 result = Dart_IntegerToInt64(result, &value); | 8008 result = Dart_IntegerToInt64(result, &value); |
| 7917 EXPECT_VALID(result); | 8009 EXPECT_VALID(result); |
| 7918 EXPECT_EQ(6, value); | 8010 EXPECT_EQ(6, value); |
| 7919 } | 8011 } |
| 7920 | 8012 |
| 7921 } // namespace dart | 8013 } // namespace dart |
| OLD | NEW |