Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
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#endif // !defined(DART_PRECOMPILED_RUNTIME)
61
62 // Ensures members of the class are loaded, class layout is finalized and size
63 // registered in class table.
64 static void FinalizeClass(const Class& cls);
65
66#if !defined(DART_PRECOMPILED_RUNTIME)
67 // Makes class instantiatable and usable by generated code.
68 static ErrorPtr AllocateFinalizeClass(const Class& cls);
69
70 // Completes loading of the class, this populates the function
71 // and fields of the class.
72 //
73 // Returns Error::null() if there is no loading error.
74 static ErrorPtr LoadClassMembers(const Class& cls);
75
76 // Verify that the classes have been properly prefinalized. This is
77 // needed during bootstrapping where the classes have been preloaded.
78 static void VerifyBootstrapClasses();
79#endif // !defined(DART_PRECOMPILED_RUNTIME)
80
81 private:
82 // Finalize given type argument vector.
83 static TypeArgumentsPtr FinalizeTypeArguments(
84 Zone* zone,
85 const TypeArguments& type_args,
86 FinalizationKind finalization = kCanonicalize);
87
88 static void FinalizeTypeParameters(Zone* zone,
89 const TypeParameters& type_params,
90 FinalizationKind finalization);
91
92#if !defined(DART_PRECOMPILED_RUNTIME)
93 static void FinalizeMemberTypes(const Class& cls);
94 static void PrintClassInformation(const Class& cls);
95#endif // !defined(DART_PRECOMPILED_RUNTIME)
96
97 static void ReportError(const Error& error);
98 static void ReportError(const char* format, ...) PRINTF_ATTRIBUTE(1, 2);
99
100#if !defined(DART_PRECOMPILED_RUNTIME)
101 // Verify implicit offsets recorded in the VM for direct access to fields of
102 // Dart instances (e.g: _TypedListView, _ByteDataView).
103 static void VerifyImplicitFieldOffsets();
104#endif // !defined(DART_PRECOMPILED_RUNTIME)
105};
106
107} // namespace dart
108
109#endif // RUNTIME_VM_CLASS_FINALIZER_H_
static AbstractTypePtr FinalizeType(const AbstractType &type, FinalizationKind finalization=kCanonicalize)
static bool ProcessPendingClasses()
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 ErrorPtr LoadClassMembers(const Class &cls)
const uint8_t uint32_t uint32_t GError ** error
uint32_t uint32_t * format
#define PRINTF_ATTRIBUTE(string_index, first_to_check)
Definition globals.h:697