Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/openj9
Path: blob/master/runtime/bcutil/ComparingCursor.hpp
5985 views
1
/*******************************************************************************
2
* Copyright (c) 2001, 2019 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
* ComparingCursor.hpp
25
*/
26
27
#ifndef COMPARINGCURSOR_HPP_
28
#define COMPARINGCURSOR_HPP_
29
30
/* @ddr_namespace: default */
31
#include "Cursor.hpp"
32
#include "ComparingCursorHelper.hpp"
33
34
class SRPKeyProducer;
35
class ClassFileOracle;
36
37
class ComparingCursor : public Cursor
38
{
39
public:
40
ComparingCursor(J9JavaVM *javaVM, SRPOffsetTable *srpOffsetTable, SRPKeyProducer *srpKeyProducer,
41
ClassFileOracle *classFileOracle, U_8 *romClass, bool romClassIsShared, ROMClassCreationContext * context, bool isComparingLambdaFromSCC);
42
~ComparingCursor();
43
44
UDATA getCount();
45
void writeU8(U_8 u8Value, DataType dataType);
46
void writeU16(U_16 u16Value, DataType dataType);
47
void writeU32(U_32 u32Value, DataType dataType);
48
void writeU64(U_32 u32ValueHigh, U_32 u32ValueLow, DataType dataType);
49
void writeData(U_8* bytes, UDATA length, DataType dataType);
50
void padToAlignment(UDATA byteAlignment, DataType dataType);
51
void writeSRP(UDATA srpKey, DataType dataType);
52
void writeWSRP(UDATA srpKey, DataType dataType);
53
void mark(UDATA srpKey) { /* do nothing */ }
54
void notifyDebugDataWriteStart();
55
void notifyVariableTableWriteEnd();
56
void notifyDebugDataWriteEnd() { _context->endDebugCompare(); }
57
U_32 peekU32(DataType dataType);
58
void skip(UDATA byteCount, DataType dataType = Cursor::GENERIC);
59
bool isEqual() const { return _isEqual; }
60
bool isComparingLambdaFromSCC() const { return _isComparingLambdaFromSCC; }
61
62
private:
63
J9JavaVM *_javaVM;
64
bool _checkRangeInSharedCache;
65
ClassFileOracle *_classFileOracle;
66
SRPKeyProducer *_srpKeyProducer;
67
U_8 *_romClass;
68
Cursor::Mode _mode;
69
U_8 * _storePointerToVariableInfo;
70
U_8 * _basePointerToVariableInfo;
71
ComparingCursorHelper _mainHelper;
72
ComparingCursorHelper _lineNumberHelper;
73
ComparingCursorHelper _varInfoHelper;
74
bool _isEqual;
75
bool _isComparingLambdaFromSCC;
76
void markUnEqual() { _isEqual = false; }
77
bool isRangeValidForPtr(U_8 *ptr, UDATA length);
78
UDATA getMaximumValidLengthForPtrInSegment(U_8 *ptr);
79
80
/*Helper verification methods*/
81
bool shouldCheckForEquality(DataType dataType, U_32 u32Value = 0);
82
bool isRangeValid(UDATA length, DataType dataType);
83
bool isRangeValidForUTF8Ptr(J9UTF8 *utf8);
84
85
/*Methods to get the correct helper (aka counter) for compare*/
86
ComparingCursorHelper * getCountingCursor(DataType dataType);
87
};
88
89
#endif /* COMPARINGCURSOR_HPP_ */
90
91