Flutter Engine
The Flutter Engine
class_finalizer.h
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
5#ifndef RUNTIME_VM_CLASS_FINALIZER_H_
6#define RUNTIME_VM_CLASS_FINALIZER_H_
7
8#include <memory>
9
10#include "vm/allocation.h"
11#include "vm/growable_array.h"
12#include "vm/object.h"
13
14namespace dart {
15
16// Traverses all pending, unfinalized classes, validates and marks them as
17// finalized.
18class ClassFinalizer : public AllStatic {
19 public:
20 // Modes for finalization. The ordering is relevant.
22 kFinalize, // Finalize type and type arguments.
23 kCanonicalize // Finalize and canonicalize.
24 };
25
26 // Finalize given type.
27 static AbstractTypePtr FinalizeType(
28 const AbstractType& type,
29 FinalizationKind finalization = kCanonicalize);
30
31 // Return false if we still have classes pending to be finalized.
32 static bool AllClassesFinalized();
33
34#if !defined(DART_PRECOMPILED_RUNTIME)
35 // Useful for sorting classes to make dispatch faster.
36 static void SortClasses();
37 static void RemapClassIds(intptr_t* old_to_new_cid);
38 static void RehashTypes();
39 static void ClearAllCode(bool including_nonchanging_cids = false);
40#endif // !defined(DART_PRECOMPILED_RUNTIME)
41
42 // Return whether processing pending classes (ObjectStore::pending_classes_)
43 // failed. The function returns true if the processing was successful.
44 // If processing fails, an error message is set in the sticky error field
45 // in the object store.
46 static bool ProcessPendingClasses();
47
48 // Finalize the types appearing in the declaration of class 'cls', i.e. its
49 // type parameters and their upper bounds, its super type and interfaces.
50 // Note that the fields and functions have not been parsed yet (unless cls
51 // is an anonymous top level class).
52 static void FinalizeTypesInClass(const Class& cls);
53
54#if !defined(DART_PRECOMPILED_RUNTIME)
55 // Register class in the lists of direct subclasses and direct implementors.
56 static void RegisterClassInHierarchy(Zone* zone, const Class& cls);
57
58 // Mark [cls], its superclass and superinterfaces as can_be_future().
59 static void MarkClassCanBeFuture(Zone* zone, const Class& cls);
60
61 // Mark [cls] and all its superclasses and superinterfaces as
62 // has_dynamically_extendable_subtypes().
64 const Class& cls);
65#endif // !defined(DART_PRECOMPILED_RUNTIME)
66
67 // Ensures members of the class are loaded, class layout is finalized and size
68 // registered in class table.
69 static void FinalizeClass(const Class& cls);
70
71#if !defined(DART_PRECOMPILED_RUNTIME)
72 // Makes class instantiatable and usable by generated code.
73 static ErrorPtr AllocateFinalizeClass(const Class& cls);
74
75 // Completes loading of the class, this populates the function
76 // and fields of the class.
77 //
78 // Returns Error::null() if there is no loading error.
79 static ErrorPtr LoadClassMembers(const Class& cls);
80
81 // Verify that the classes have been properly prefinalized. This is
82 // needed during bootstrapping where the classes have been preloaded.
83 static void VerifyBootstrapClasses();
84#endif // !defined(DART_PRECOMPILED_RUNTIME)
85
86 private:
87 // Finalize given type argument vector.
88 static TypeArgumentsPtr FinalizeTypeArguments(
89 Zone* zone,
90 const TypeArguments& type_args,
91 FinalizationKind finalization = kCanonicalize);
92
93 static void FinalizeTypeParameters(Zone* zone,
94 const TypeParameters& type_params,
95 FinalizationKind finalization);
96
97#if !defined(DART_PRECOMPILED_RUNTIME)
98 static void FinalizeMemberTypes(const Class& cls);
99 static void PrintClassInformation(const Class& cls);
100#endif // !defined(DART_PRECOMPILED_RUNTIME)
101
102 static void ReportError(const Error& error);
103 static void ReportError(const char* format, ...) PRINTF_ATTRIBUTE(1, 2);
104
105#if !defined(DART_PRECOMPILED_RUNTIME)
106 // Verify implicit offsets recorded in the VM for direct access to fields of
107 // Dart instances (e.g: _TypedListView, _ByteDataView).
108 static void VerifyImplicitFieldOffsets();
109#endif // !defined(DART_PRECOMPILED_RUNTIME)
110};
111
112} // namespace dart
113
114#endif // RUNTIME_VM_CLASS_FINALIZER_H_
GLenum type
static AbstractTypePtr FinalizeType(const AbstractType &type, FinalizationKind finalization=kCanonicalize)
static bool ProcessPendingClasses()
static void MarkClassHasDynamicallyExtendableSubtypes(Zone *zone, const Class &cls)
static void MarkClassCanBeFuture(Zone *zone, const Class &cls)
static void VerifyBootstrapClasses()
static bool AllClassesFinalized()
static void FinalizeTypesInClass(const Class &cls)
static void RegisterClassInHierarchy(Zone *zone, const Class &cls)
static ErrorPtr AllocateFinalizeClass(const Class &cls)
static void FinalizeClass(const Class &cls)
static void ClearAllCode(bool including_nonchanging_cids=false)
static void RemapClassIds(intptr_t *old_to_new_cid)
static void SortClasses()
static ErrorPtr LoadClassMembers(const Class &cls)
const uint8_t uint32_t uint32_t GError ** error
uint32_t uint32_t * format
Definition: dart_vm.cc:33
#define PRINTF_ATTRIBUTE(string_index, first_to_check)
Definition: globals.h:697