Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/openj9
Path: blob/master/runtime/bcutil/SuppliedBufferAllocationStrategy.hpp
5985 views
1
/*******************************************************************************
2
* Copyright (c) 2001, 2017 IBM Corp. and others
3
*
4
* This program and the accompanying materials are made available under
5
* the terms of the Eclipse Public License 2.0 which accompanies this
6
* distribution and is available at https://www.eclipse.org/legal/epl-2.0/
7
* or the Apache License, Version 2.0 which accompanies this distribution and
8
* is available at https://www.apache.org/licenses/LICENSE-2.0.
9
*
10
* This Source Code may also be made available under the following
11
* Secondary Licenses when the conditions for such availability set
12
* forth in the Eclipse Public License, v. 2.0 are satisfied: GNU
13
* General Public License, version 2 with the GNU Classpath
14
* Exception [1] and GNU General Public License, version 2 with the
15
* OpenJDK Assembly Exception [2].
16
*
17
* [1] https://www.gnu.org/software/classpath/license.html
18
* [2] http://openjdk.java.net/legal/assembly-exception.html
19
*
20
* SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 OR LicenseRef-GPL-2.0 WITH Assembly-exception
21
*******************************************************************************/
22
23
/*
24
* SuppliedBufferAllocationStrategy.hpp
25
*/
26
27
#ifndef SUPPLIEDBUFFERALLOCATIONSTRATEGY_HPP_
28
#define SUPPLIEDBUFFERALLOCATIONSTRATEGY_HPP_
29
30
/* @ddr_namespace: default */
31
#include "AllocationStrategy.hpp"
32
33
class SuppliedBufferAllocationStrategy: public AllocationStrategy
34
{
35
public:
36
SuppliedBufferAllocationStrategy(U_8 * buffer, UDATA bufferSize) :
37
_buffer(buffer),
38
_bufferSize(bufferSize),
39
_lineNumberBuffer(NULL),
40
_lineNumberBufferSize(0),
41
_variableInfoBuffer(NULL),
42
_variableInfoBufferSize(0)
43
{
44
}
45
46
SuppliedBufferAllocationStrategy(U_8 * buffer, UDATA bufferSize,
47
U_8 *lineNumberBuffer, UDATA lineNumberBufferSize,
48
U_8 * variableInfoBuffer, UDATA variableInfoBufferSize) :
49
_buffer(buffer),
50
_bufferSize(bufferSize),
51
_lineNumberBuffer(lineNumberBuffer),
52
_lineNumberBufferSize(lineNumberBufferSize),
53
_variableInfoBuffer(variableInfoBuffer),
54
_variableInfoBufferSize(variableInfoBufferSize)
55
{
56
}
57
58
virtual U_8* allocate(UDATA byteAmount) {
59
if (byteAmount <= _bufferSize) {
60
return _buffer;
61
}
62
return NULL;
63
}
64
65
virtual bool allocateWithOutOfLineData(AllocatedBuffers *allocatedBuffers, UDATA byteAmount, UDATA lineNumberByteAmount, UDATA variableInfoByteAmount)
66
{
67
if (byteAmount > _bufferSize) {
68
return false;
69
}
70
if (lineNumberByteAmount > _lineNumberBufferSize) {
71
return false;
72
}
73
if (variableInfoByteAmount > _variableInfoBufferSize) {
74
return false;
75
}
76
allocatedBuffers->romClassBuffer = _buffer;
77
allocatedBuffers->lineNumberBuffer = _lineNumberBuffer;
78
allocatedBuffers->variableInfoBuffer = _variableInfoBuffer;
79
return true;
80
}
81
82
83
void updateFinalROMSize(UDATA finalSize) { /* do nothing */ }
84
85
virtual bool canStoreDebugDataOutOfLine() { return true; }
86
87
private:
88
U_8 * _buffer;
89
UDATA _bufferSize;
90
U_8 * _lineNumberBuffer;
91
UDATA _lineNumberBufferSize;
92
U_8 * _variableInfoBuffer;
93
UDATA _variableInfoBufferSize;
94
};
95
96
#endif /* SUPPLIEDBUFFERALLOCATIONSTRATEGY_HPP_ */
97
98