| 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 "include/dart_api.h" | 5 #include "include/dart_api.h" |
| 6 #include "platform/assert.h" | 6 #include "platform/assert.h" |
| 7 #include "platform/json.h" | 7 #include "platform/json.h" |
| 8 #include "platform/utils.h" | 8 #include "platform/utils.h" |
| 9 #include "vm/class_finalizer.h" | 9 #include "vm/class_finalizer.h" |
| 10 #include "vm/dart_api_impl.h" | 10 #include "vm/dart_api_impl.h" |
| (...skipping 1224 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1235 handles[i] = Dart_NewPersistentHandle(ref2); | 1235 handles[i] = Dart_NewPersistentHandle(ref2); |
| 1236 } | 1236 } |
| 1237 for (int i = 1000; i < 1500; i++) { | 1237 for (int i = 1000; i < 1500; i++) { |
| 1238 handles[i] = Dart_NewPersistentHandle(ref1); | 1238 handles[i] = Dart_NewPersistentHandle(ref1); |
| 1239 } | 1239 } |
| 1240 VERIFY_ON_TRANSITION; | 1240 VERIFY_ON_TRANSITION; |
| 1241 Dart_ExitScope(); | 1241 Dart_ExitScope(); |
| 1242 } | 1242 } |
| 1243 Dart_ExitScope(); | 1243 Dart_ExitScope(); |
| 1244 { | 1244 { |
| 1245 StackZone zone(isolate); |
| 1245 DARTSCOPE_NOCHECKS(isolate); | 1246 DARTSCOPE_NOCHECKS(isolate); |
| 1246 for (int i = 0; i < 500; i++) { | 1247 for (int i = 0; i < 500; i++) { |
| 1247 String& str = String::Handle(); | 1248 String& str = String::Handle(); |
| 1248 str ^= Api::UnwrapHandle(handles[i]); | 1249 str ^= Api::UnwrapHandle(handles[i]); |
| 1249 EXPECT(str.Equals(kTestString1)); | 1250 EXPECT(str.Equals(kTestString1)); |
| 1250 } | 1251 } |
| 1251 for (int i = 500; i < 1000; i++) { | 1252 for (int i = 500; i < 1000; i++) { |
| 1252 String& str = String::Handle(); | 1253 String& str = String::Handle(); |
| 1253 str ^= Api::UnwrapHandle(handles[i]); | 1254 str ^= Api::UnwrapHandle(handles[i]); |
| 1254 EXPECT(str.Equals(kTestString2)); | 1255 EXPECT(str.Equals(kTestString2)); |
| (...skipping 931 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2186 // scope. | 2187 // scope. |
| 2187 UNIT_TEST_CASE(LocalHandles) { | 2188 UNIT_TEST_CASE(LocalHandles) { |
| 2188 TestCase::CreateTestIsolate(); | 2189 TestCase::CreateTestIsolate(); |
| 2189 Isolate* isolate = Isolate::Current(); | 2190 Isolate* isolate = Isolate::Current(); |
| 2190 EXPECT(isolate != NULL); | 2191 EXPECT(isolate != NULL); |
| 2191 ApiState* state = isolate->api_state(); | 2192 ApiState* state = isolate->api_state(); |
| 2192 EXPECT(state != NULL); | 2193 EXPECT(state != NULL); |
| 2193 ApiLocalScope* scope = state->top_scope(); | 2194 ApiLocalScope* scope = state->top_scope(); |
| 2194 Dart_Handle handles[300]; | 2195 Dart_Handle handles[300]; |
| 2195 { | 2196 { |
| 2197 StackZone zone(isolate); |
| 2196 DARTSCOPE_NOCHECKS(isolate); | 2198 DARTSCOPE_NOCHECKS(isolate); |
| 2197 Smi& val = Smi::Handle(); | 2199 Smi& val = Smi::Handle(); |
| 2198 | 2200 |
| 2199 // Start a new scope and allocate some local handles. | 2201 // Start a new scope and allocate some local handles. |
| 2200 Dart_EnterScope(); | 2202 Dart_EnterScope(); |
| 2201 for (int i = 0; i < 100; i++) { | 2203 for (int i = 0; i < 100; i++) { |
| 2202 handles[i] = Api::NewHandle(isolate, Smi::New(i)); | 2204 handles[i] = Api::NewHandle(isolate, Smi::New(i)); |
| 2203 } | 2205 } |
| 2204 EXPECT_EQ(100, state->CountLocalHandles()); | 2206 EXPECT_EQ(100, state->CountLocalHandles()); |
| 2205 for (int i = 0; i < 100; i++) { | 2207 for (int i = 0; i < 100; i++) { |
| (...skipping 4938 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7144 EXPECT(o2 == reinterpret_cast<void*>(&p2)); | 7146 EXPECT(o2 == reinterpret_cast<void*>(&p2)); |
| 7145 } | 7147 } |
| 7146 Dart_ExitScope(); | 7148 Dart_ExitScope(); |
| 7147 isolate->heap()->CollectGarbage(Heap::kOld); | 7149 isolate->heap()->CollectGarbage(Heap::kOld); |
| 7148 EXPECT_EQ(0, isolate->heap()->PeerCount()); | 7150 EXPECT_EQ(0, isolate->heap()->PeerCount()); |
| 7149 } | 7151 } |
| 7150 | 7152 |
| 7151 #endif // defined(TARGET_ARCH_IA32) || defined(TARGET_ARCH_X64). | 7153 #endif // defined(TARGET_ARCH_IA32) || defined(TARGET_ARCH_X64). |
| 7152 | 7154 |
| 7153 } // namespace dart | 7155 } // namespace dart |
| OLD | NEW |