d573d5437d
Review URL: https://chromiumcodereview.appspot.com//9242025 git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@3376 260f80e4-7a28-3924-810f-c04153c831b5
64 lines
1.9 KiB
C++
64 lines
1.9 KiB
C++
// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
|
|
// for details. All rights reserved. Use of this source code is governed by a
|
|
// BSD-style license that can be found in the LICENSE file.
|
|
|
|
#include "platform/assert.h"
|
|
#include "vm/globals.h"
|
|
#include "vm/heap.h"
|
|
#include "vm/unit_test.h"
|
|
|
|
namespace dart {
|
|
|
|
// Only ia32 and x64 can run execution tests.
|
|
#if defined(TARGET_ARCH_IA32) || defined(TARGET_ARCH_X64)
|
|
TEST_CASE(OldGC) {
|
|
const char* kScriptChars =
|
|
"class HeapTester {\n"
|
|
" static void main() {\n"
|
|
" return [1, 2, 3];\n"
|
|
" }\n"
|
|
"}\n";
|
|
FLAG_verbose_gc = true;
|
|
Dart_Handle lib = TestCase::LoadTestScript(kScriptChars, NULL);
|
|
Dart_Handle result = Dart_InvokeStatic(lib,
|
|
Dart_NewString("HeapTester"),
|
|
Dart_NewString("main"),
|
|
0, NULL);
|
|
|
|
EXPECT_VALID(result);
|
|
EXPECT(!Dart_IsNull(result));
|
|
EXPECT(Dart_IsList(result));
|
|
Isolate* isolate = Isolate::Current();
|
|
Heap* heap = isolate->heap();
|
|
heap->CollectGarbage(Heap::kOld);
|
|
}
|
|
|
|
|
|
TEST_CASE(LargeSweep) {
|
|
const char* kScriptChars =
|
|
"class HeapTester {\n"
|
|
" static void main() {\n"
|
|
" return new List(8 * 1024 * 1024);\n"
|
|
" }\n"
|
|
"}\n";
|
|
FLAG_verbose_gc = true;
|
|
Dart_Handle lib = TestCase::LoadTestScript(kScriptChars, NULL);
|
|
Dart_EnterScope();
|
|
Dart_Handle result = Dart_InvokeStatic(lib,
|
|
Dart_NewString("HeapTester"),
|
|
Dart_NewString("main"),
|
|
0, NULL);
|
|
|
|
EXPECT_VALID(result);
|
|
EXPECT(!Dart_IsNull(result));
|
|
EXPECT(Dart_IsList(result));
|
|
Isolate* isolate = Isolate::Current();
|
|
Heap* heap = isolate->heap();
|
|
heap->CollectGarbage(Heap::kOld);
|
|
Dart_ExitScope();
|
|
heap->CollectGarbage(Heap::kOld);
|
|
}
|
|
|
|
#endif // defined(TARGET_ARCH_IA32) || defined(TARGET_ARCH_X64).
|
|
}
|