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

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

Issue 193473002: Fix external size accounting for prologue 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
« no previous file with comments | « no previous file | runtime/vm/dart_api_state.h » ('j') | runtime/vm/scavenger.cc » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 2237 matching lines...) Expand 10 before | Expand all | Expand 10 after
2248 EXPECT(heap->ExternalInWords(Heap::kOld) == kWeak2ExternalSize / kWordSize); 2248 EXPECT(heap->ExternalInWords(Heap::kOld) == kWeak2ExternalSize / kWordSize);
2249 Dart_Isolate isolate = reinterpret_cast<Dart_Isolate>(Isolate::Current()); 2249 Dart_Isolate isolate = reinterpret_cast<Dart_Isolate>(Isolate::Current());
2250 Dart_DeleteWeakPersistentHandle(isolate, weak1); 2250 Dart_DeleteWeakPersistentHandle(isolate, weak1);
2251 Dart_DeleteWeakPersistentHandle(isolate, weak2); 2251 Dart_DeleteWeakPersistentHandle(isolate, weak2);
2252 Dart_DeletePersistentHandle(strong_ref); 2252 Dart_DeletePersistentHandle(strong_ref);
2253 Isolate::Current()->heap()->CollectGarbage(Heap::kOld); 2253 Isolate::Current()->heap()->CollectGarbage(Heap::kOld);
2254 EXPECT(heap->ExternalInWords(Heap::kOld) == 0); 2254 EXPECT(heap->ExternalInWords(Heap::kOld) == 0);
2255 } 2255 }
2256 2256
2257 2257
2258 TEST_CASE(PrologueWeakPersistentHandleExternalAllocationSize) {
2259 Heap* heap = Isolate::Current()->heap();
2260 EXPECT(heap->ExternalInWords(Heap::kNew) == 0);
2261 EXPECT(heap->ExternalInWords(Heap::kOld) == 0);
2262 Dart_WeakPersistentHandle pwph = NULL;
2263 static const intptr_t kWeakExternalSize = 1 * KB;
2264 {
2265 Dart_EnterScope();
2266 Dart_Handle obj = NewString("a string");
2267 EXPECT_VALID(obj);
2268 pwph = Dart_NewPrologueWeakPersistentHandle(
2269 obj, NULL, kWeakExternalSize, NULL);
2270 EXPECT_VALID(AsHandle(pwph));
2271 Dart_ExitScope();
2272 }
2273 EXPECT(heap->ExternalInWords(Heap::kNew) == kWeakExternalSize / kWordSize);
2274 EXPECT(heap->ExternalInWords(Heap::kOld) == 0);
2275 // Promoting the string should transfer the external size to old.
2276 GCTestHelper::CollectNewSpace(Heap::kIgnoreApiCallbacks);
2277 GCTestHelper::CollectNewSpace(Heap::kIgnoreApiCallbacks);
2278 EXPECT(heap->ExternalInWords(Heap::kNew) == 0);
2279 EXPECT(heap->ExternalInWords(Heap::kOld) == kWeakExternalSize / kWordSize);
2280 Isolate::Current()->heap()->CollectGarbage(Heap::kOld);
2281 EXPECT(heap->ExternalInWords(Heap::kOld) == 0);
2282 }
2283
2284
2258 TEST_CASE(WeakPersistentHandleExternalAllocationSizeOversized) { 2285 TEST_CASE(WeakPersistentHandleExternalAllocationSizeOversized) {
2259 Heap* heap = Isolate::Current()->heap(); 2286 Heap* heap = Isolate::Current()->heap();
2260 Dart_WeakPersistentHandle weak1 = NULL; 2287 Dart_WeakPersistentHandle weak1 = NULL;
2261 const intptr_t kWeak1ExternalSize = 100 * MB; 2288 const intptr_t kWeak1ExternalSize = 100 * MB;
2262 { 2289 {
2263 Dart_EnterScope(); 2290 Dart_EnterScope();
2264 Dart_Handle obj = NewString("weakly referenced string"); 2291 Dart_Handle obj = NewString("weakly referenced string");
2265 EXPECT_VALID(obj); 2292 EXPECT_VALID(obj);
2266 weak1 = Dart_NewWeakPersistentHandle(obj, NULL, kWeak1ExternalSize, NULL); 2293 weak1 = Dart_NewWeakPersistentHandle(obj, NULL, kWeak1ExternalSize, NULL);
2267 EXPECT_VALID(AsHandle(weak1)); 2294 EXPECT_VALID(AsHandle(weak1));
(...skipping 5841 matching lines...) Expand 10 before | Expand all | Expand 10 after
8109 NewString("main"), 8136 NewString("main"),
8110 1, 8137 1,
8111 dart_args); 8138 dart_args);
8112 int64_t value = 0; 8139 int64_t value = 0;
8113 result = Dart_IntegerToInt64(result, &value); 8140 result = Dart_IntegerToInt64(result, &value);
8114 EXPECT_VALID(result); 8141 EXPECT_VALID(result);
8115 EXPECT_EQ(6, value); 8142 EXPECT_EQ(6, value);
8116 } 8143 }
8117 8144
8118 } // namespace dart 8145 } // namespace dart
OLDNEW
« no previous file with comments | « no previous file | runtime/vm/dart_api_state.h » ('j') | runtime/vm/scavenger.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698