summaryrefslogtreecommitdiff
path: root/src/ToolBox/superpmi/superpmi-shared/icorjithostimpl.h
blob: 8bd09e53316790fa35490bffbb14fa124d80c100 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.

#ifndef _ICorJitHostImpl
#define _ICorJitHostImpl

// ICorJitHost
//
// ICorJitHost provides the interface that the JIT uses to access some functionality that
// would normally be provided by the operating system. This is intended to allow for
// host-specific policies re: memory allocation, configuration value access, etc. It is
// expected that the `ICorJitHost` value provided to `jitStartup` lives at least as
// long as the JIT itself.

// ICorJitHostImpl: declare for implementation all the members of the ICorJitHost interface (which are
// specified as pure virtual methods). This is done once, here, and all implementations share it,
// to avoid duplicated declarations. This file is #include'd within all the ICorJitHost implementation
// classes.
//
// NOTE: this file is in exactly the same order, with exactly the same whitespace, as the ICorJitHost
// interface declaration (with the "virtual" and "= 0" syntax removed). This is to make it easy to compare
// against the interface declaration.

public:
    // Allocate memory of the given size in bytes. All bytes of the returned block
    // must be initialized to zero. If `usePageAllocator` is true, the implementation
    // should use an allocator that deals in OS pages if one exists.
    void* allocateMemory(size_t size, bool usePageAllocator = false);

    // Frees memory previous obtained by a call to `ICorJitHost::allocateMemory`. The
    // value of the `usePageAllocator` parameter must match the value that was
    // provided to the call to used to allocate the memory.
    void freeMemory(void* block, bool usePageAllocator = false);

    // Return an integer config value for the given key, if any exists.
    int getIntConfigValue(
        const wchar_t* name, 
        int defaultValue
        );

    // Return a string config value for the given key, if any exists.
    const wchar_t* getStringConfigValue(
        const wchar_t* name
        );

    // Free a string ConfigValue returned by the runtime.
    // JITs using the getStringConfigValue query are required
    // to return the string values to the runtime for deletion.
    // This avoids leaking the memory in the JIT.
    void freeStringConfigValue(
        const wchar_t* value
        );

#endif