All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.adoptopenjdk.jitwatch.model.assembly.AssemblyMethod Maven / Gradle / Ivy

Go to download

A Maven plugin that scans the project artifact and its dependencies for methods that cannot be inlined by the JIT compiler. It uses the JarScan utility from the JITWatch project to do that. See https://github.com/AdoptOpenJDK/jitwatch .

The newest version!
/*
 * Copyright (c) 2013-2015 Chris Newland.
 * Licensed under https://github.com/AdoptOpenJDK/jitwatch/blob/master/LICENSE-BSD
 * Instructions: https://github.com/AdoptOpenJDK/jitwatch/wiki
 */
package org.adoptopenjdk.jitwatch.model.assembly;

import java.util.ArrayList;
import java.util.List;

import org.adoptopenjdk.jitwatch.util.StringUtil;

import static org.adoptopenjdk.jitwatch.core.JITWatchConstants.*;

public class AssemblyMethod
{
	private String header;

	private List blocks = new ArrayList<>();
	
	public AssemblyMethod()
	{
	}

	public void setHeader(String header)
	{
		this.header = header;
	}

	public String getHeader()
	{
		return header;
	}

	public void addBlock(AssemblyBlock block)
	{
		blocks.add(block);
	}

	public List getBlocks()
	{
		return blocks;
	}

	public int getMaxAnnotationWidth()
	{
		int width = 0;

		for (AssemblyBlock block : blocks)
		{
			for (AssemblyInstruction instruction : block.getInstructions())
			{
				int annoWidth = instruction.getAnnotation().length();

				width = Math.max(width, annoWidth);
			}
		}

		return width;
	}
	
	@Override
	public String toString()
	{
		StringBuilder builder = new StringBuilder();

		int maxAnnoWidth = getMaxAnnotationWidth();

		if (header != null)
		{
			String[] headerLines = header.split(S_NEWLINE);

			for (String headerLine : headerLines)
			{
				builder.append(StringUtil.repeat(C_SPACE, maxAnnoWidth));
				builder.append(headerLine).append(S_NEWLINE);
			}
		}

		for (AssemblyBlock block : blocks)
		{
			builder.append(block.toString(maxAnnoWidth));
		}

		return builder.toString();
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy