Path: blob/master/runtime/bcutil/SuppliedBufferAllocationStrategy.hpp
5985 views
/*******************************************************************************1* Copyright (c) 2001, 2017 IBM Corp. and others2*3* This program and the accompanying materials are made available under4* the terms of the Eclipse Public License 2.0 which accompanies this5* distribution and is available at https://www.eclipse.org/legal/epl-2.0/6* or the Apache License, Version 2.0 which accompanies this distribution and7* is available at https://www.apache.org/licenses/LICENSE-2.0.8*9* This Source Code may also be made available under the following10* Secondary Licenses when the conditions for such availability set11* forth in the Eclipse Public License, v. 2.0 are satisfied: GNU12* General Public License, version 2 with the GNU Classpath13* Exception [1] and GNU General Public License, version 2 with the14* OpenJDK Assembly Exception [2].15*16* [1] https://www.gnu.org/software/classpath/license.html17* [2] http://openjdk.java.net/legal/assembly-exception.html18*19* 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-exception20*******************************************************************************/2122/*23* SuppliedBufferAllocationStrategy.hpp24*/2526#ifndef SUPPLIEDBUFFERALLOCATIONSTRATEGY_HPP_27#define SUPPLIEDBUFFERALLOCATIONSTRATEGY_HPP_2829/* @ddr_namespace: default */30#include "AllocationStrategy.hpp"3132class SuppliedBufferAllocationStrategy: public AllocationStrategy33{34public:35SuppliedBufferAllocationStrategy(U_8 * buffer, UDATA bufferSize) :36_buffer(buffer),37_bufferSize(bufferSize),38_lineNumberBuffer(NULL),39_lineNumberBufferSize(0),40_variableInfoBuffer(NULL),41_variableInfoBufferSize(0)42{43}4445SuppliedBufferAllocationStrategy(U_8 * buffer, UDATA bufferSize,46U_8 *lineNumberBuffer, UDATA lineNumberBufferSize,47U_8 * variableInfoBuffer, UDATA variableInfoBufferSize) :48_buffer(buffer),49_bufferSize(bufferSize),50_lineNumberBuffer(lineNumberBuffer),51_lineNumberBufferSize(lineNumberBufferSize),52_variableInfoBuffer(variableInfoBuffer),53_variableInfoBufferSize(variableInfoBufferSize)54{55}5657virtual U_8* allocate(UDATA byteAmount) {58if (byteAmount <= _bufferSize) {59return _buffer;60}61return NULL;62}6364virtual bool allocateWithOutOfLineData(AllocatedBuffers *allocatedBuffers, UDATA byteAmount, UDATA lineNumberByteAmount, UDATA variableInfoByteAmount)65{66if (byteAmount > _bufferSize) {67return false;68}69if (lineNumberByteAmount > _lineNumberBufferSize) {70return false;71}72if (variableInfoByteAmount > _variableInfoBufferSize) {73return false;74}75allocatedBuffers->romClassBuffer = _buffer;76allocatedBuffers->lineNumberBuffer = _lineNumberBuffer;77allocatedBuffers->variableInfoBuffer = _variableInfoBuffer;78return true;79}808182void updateFinalROMSize(UDATA finalSize) { /* do nothing */ }8384virtual bool canStoreDebugDataOutOfLine() { return true; }8586private:87U_8 * _buffer;88UDATA _bufferSize;89U_8 * _lineNumberBuffer;90UDATA _lineNumberBufferSize;91U_8 * _variableInfoBuffer;92UDATA _variableInfoBufferSize;93};9495#endif /* SUPPLIEDBUFFERALLOCATIONSTRATEGY_HPP_ */969798