Flutter Engine
The Flutter Engine
class_finalizer_test.cc
Go to the documentation of this 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
3// BSD-style license that can be found in the LICENSE file.
4
6#include "platform/assert.h"
7#include "vm/symbols.h"
8#include "vm/unit_test.h"
9
10namespace dart {
11
12static ClassPtr CreateTestClass(const char* name) {
13 Thread* thread = Thread::Current();
15 const Script& script = Script::Handle();
16 const Class& cls = Class::Handle(Class::New(
17 Library::Handle(), class_name, script, TokenPosition::kNoSource));
18 cls.set_interfaces(Object::empty_array());
19 SafepointWriteRwLocker ml(thread, thread->isolate_group()->program_lock());
21 cls.SetFunctions(Object::empty_array());
22 cls.SetFields(Object::empty_array());
23 return cls.ptr();
24}
25
27 Zone* zone = thread->zone();
28 auto isolate_group = thread->isolate_group();
29 ObjectStore* object_store = isolate_group->object_store();
30 const auto& pending_classes =
31 GrowableObjectArray::Handle(zone, object_store->pending_classes());
33 classes_1.Add(&Class::Handle(CreateTestClass("BMW")));
34 pending_classes.Add(*classes_1[0]);
35 classes_1.Add(&Class::Handle(CreateTestClass("Porsche")));
36 pending_classes.Add(*classes_1[1]);
37
39 classes_2.Add(&Class::ZoneHandle(CreateTestClass("Ferrari")));
40 pending_classes.Add(*classes_2[0]);
41 classes_2.Add(&Class::ZoneHandle(CreateTestClass("Fiat")));
42 pending_classes.Add(*classes_2[1]);
43 classes_2.Add(&Class::ZoneHandle(CreateTestClass("Alfa")));
44 pending_classes.Add(*classes_2[2]);
46 for (int i = 0; i < classes_1.length(); i++) {
47 EXPECT(classes_1[i]->is_type_finalized());
48 }
49 for (int i = 0; i < classes_2.length(); i++) {
50 EXPECT(classes_2[i]->is_type_finalized());
51 }
54}
55
56} // namespace dart
#define EXPECT(type, expectedAlignment, expectedSize)
void Add(const T &value)
intptr_t length() const
static bool ProcessPendingClasses()
static bool AllClassesFinalized()
void SetFields(const Array &value) const
Definition: object.cc:4984
void set_is_declaration_loaded() const
Definition: object.cc:5627
void set_interfaces(const Array &value) const
Definition: object.cc:5739
static ClassPtr New(IsolateGroup *isolate_group, bool register_class=true)
Definition: object.cc:3053
void SetFunctions(const Array &value) const
Definition: object.cc:3264
SafepointRwLock * program_lock()
Definition: isolate.h:537
ObjectPtr ptr() const
Definition: object.h:332
static Object & Handle()
Definition: object.h:407
static Object & ZoneHandle()
Definition: object.h:419
static StringPtr New(Thread *thread, const char *cstr)
Definition: symbols.h:723
static Thread * Current()
Definition: thread.h:362
IsolateGroup * isolate_group() const
Definition: thread.h:541
Definition: dart_vm.cc:33
const char *const name
const char *const class_name
ISOLATE_UNIT_TEST_CASE(StackAllocatedDestruction)
static ClassPtr CreateTestClass(const char *name)