Skip to content
This repository has been archived by the owner. It is now read-only.
Permalink
Browse files
8259894: refactor parts of jvm.h into jvm_io.h and jvm_constants.h
Reviewed-by: dholmes, coleenp
  • Loading branch information
iklam committed Jan 25, 2021
1 parent 764111f commit 5898ab6545ada0669ad8623310500f973dfc639f
Show file tree
Hide file tree
Showing 17 changed files with 166 additions and 107 deletions.
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2012, 2020, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2012, 2021, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -24,6 +24,7 @@

#include "precompiled.hpp"
#include "iphlp_interface.hpp"
#include "jvm_io.h"
#include "logging/log.hpp"
#include "memory/allocation.inline.hpp"
#include "memory/resourceArea.hpp"
@@ -1,5 +1,5 @@
/*
* Copyright (c) 1999, 2019, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1999, 2021, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -25,7 +25,7 @@
#ifndef SHARE_CI_CIFLAGS_HPP
#define SHARE_CI_CIFLAGS_HPP

#include "jvm.h"
#include "jvm_constants.h"
#include "ci/ciClassList.hpp"
#include "utilities/accessFlags.hpp"
#include "utilities/ostream.hpp"
@@ -23,6 +23,7 @@
*/

#include "precompiled.hpp"
#include "jvm.h"
#include "classfile/altHashing.hpp"
#include "classfile/classLoaderData.inline.hpp"
#include "classfile/javaClasses.inline.hpp"
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2020, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2020, 2021, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -23,6 +23,8 @@
*/

#include "precompiled.hpp"
#include "jvm_constants.h"
#include "jvm_io.h"
#include "classfile/vmIntrinsics.hpp"
#include "classfile/vmSymbols.hpp"
#include "compiler/compilerDirectives.hpp"
@@ -1,5 +1,5 @@
/*
* Copyright (c) 1997, 2020, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1997, 2021, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -30,6 +30,8 @@

#include "jni.h"
#include "jvm_md.h"
#include "jvm_constants.h"
#include "jvm_io.h"

#ifdef __cplusplus
extern "C" {
@@ -44,13 +46,14 @@ extern "C" {
* libraries in the standard Java API. For example, the java.lang.Object
* class needs VM-level functions that wait for and notify monitors.
*
* Second, this file contains the functions and constant definitions
* Second, (included from jvm_constants.h) constant definitions
* needed by the byte code verifier and class file format checker.
* These functions allow the verifier and format checker to be written
* These definitions allow the verifier and format checker to be written
* in a VM-independent way.
*
* Third, this file contains various I/O and network operations needed
* by the standard Java I/O and network APIs.
* by the standard Java I/O and network APIs. A part of these APIs,
* namely the jio_xxxprintf functions, are included from jvm_io.h.
*/

/*
@@ -1122,64 +1125,6 @@ JVM_ReleaseUTF(const char *utf);
JNIEXPORT jboolean JNICALL
JVM_IsSameClassPackage(JNIEnv *env, jclass class1, jclass class2);

/* Get classfile constants */
#include "classfile_constants.h"

/*
* Support for a VM-independent class format checker.
*/
typedef struct {
unsigned long code; /* byte code */
unsigned long excs; /* exceptions */
unsigned long etab; /* catch table */
unsigned long lnum; /* line number */
unsigned long lvar; /* local vars */
} method_size_info;

typedef struct {
unsigned int constants; /* constant pool */
unsigned int fields;
unsigned int methods;
unsigned int interfaces;
unsigned int fields2; /* number of static 2-word fields */
unsigned int innerclasses; /* # of records in InnerClasses attr */

method_size_info clinit; /* memory used in clinit */
method_size_info main; /* used everywhere else */
} class_size_info;

#define JVM_RECOGNIZED_CLASS_MODIFIERS (JVM_ACC_PUBLIC | \
JVM_ACC_FINAL | \
JVM_ACC_SUPER | \
JVM_ACC_INTERFACE | \
JVM_ACC_ABSTRACT | \
JVM_ACC_ANNOTATION | \
JVM_ACC_ENUM | \
JVM_ACC_SYNTHETIC)

#define JVM_RECOGNIZED_FIELD_MODIFIERS (JVM_ACC_PUBLIC | \
JVM_ACC_PRIVATE | \
JVM_ACC_PROTECTED | \
JVM_ACC_STATIC | \
JVM_ACC_FINAL | \
JVM_ACC_VOLATILE | \
JVM_ACC_TRANSIENT | \
JVM_ACC_ENUM | \
JVM_ACC_SYNTHETIC)

#define JVM_RECOGNIZED_METHOD_MODIFIERS (JVM_ACC_PUBLIC | \
JVM_ACC_PRIVATE | \
JVM_ACC_PROTECTED | \
JVM_ACC_STATIC | \
JVM_ACC_FINAL | \
JVM_ACC_SYNCHRONIZED | \
JVM_ACC_BRIDGE | \
JVM_ACC_VARARGS | \
JVM_ACC_NATIVE | \
JVM_ACC_ABSTRACT | \
JVM_ACC_STRICT | \
JVM_ACC_SYNTHETIC)


/*************************************************************************
PART 3: I/O and Network Support
@@ -1193,33 +1138,6 @@ typedef struct {
JNIEXPORT char * JNICALL
JVM_NativePath(char *);

/*
* The standard printing functions supported by the Java VM. (Should they
* be renamed to JVM_* in the future?
*/

/* jio_snprintf() and jio_vsnprintf() behave like snprintf(3) and vsnprintf(3),
* respectively, with the following differences:
* - The string written to str is always zero-terminated, also in case of
* truncation (count is too small to hold the result string), unless count
* is 0. In case of truncation count-1 characters are written and '\0'
* appendend.
* - If count is too small to hold the whole string, -1 is returned across
* all platforms. */

JNIEXPORT int
jio_vsnprintf(char *str, size_t count, const char *fmt, va_list args);

JNIEXPORT int
jio_snprintf(char *str, size_t count, const char *fmt, ...);

JNIEXPORT int
jio_fprintf(FILE *, const char *fmt, ...);

JNIEXPORT int
jio_vfprintf(FILE *, const char *fmt, va_list args);


JNIEXPORT void * JNICALL
JVM_RawMonitorCreate(void);

@@ -0,0 +1,63 @@
/*
* Copyright (c) 2021, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/

#ifndef _JVM_CONSTANTS_H_
#define _JVM_CONSTANTS_H_

#include "classfile_constants.h"

#define JVM_RECOGNIZED_CLASS_MODIFIERS (JVM_ACC_PUBLIC | \
JVM_ACC_FINAL | \
JVM_ACC_SUPER | \
JVM_ACC_INTERFACE | \
JVM_ACC_ABSTRACT | \
JVM_ACC_ANNOTATION | \
JVM_ACC_ENUM | \
JVM_ACC_SYNTHETIC)

#define JVM_RECOGNIZED_FIELD_MODIFIERS (JVM_ACC_PUBLIC | \
JVM_ACC_PRIVATE | \
JVM_ACC_PROTECTED | \
JVM_ACC_STATIC | \
JVM_ACC_FINAL | \
JVM_ACC_VOLATILE | \
JVM_ACC_TRANSIENT | \
JVM_ACC_ENUM | \
JVM_ACC_SYNTHETIC)

#define JVM_RECOGNIZED_METHOD_MODIFIERS (JVM_ACC_PUBLIC | \
JVM_ACC_PRIVATE | \
JVM_ACC_PROTECTED | \
JVM_ACC_STATIC | \
JVM_ACC_FINAL | \
JVM_ACC_SYNCHRONIZED | \
JVM_ACC_BRIDGE | \
JVM_ACC_VARARGS | \
JVM_ACC_NATIVE | \
JVM_ACC_ABSTRACT | \
JVM_ACC_STRICT | \
JVM_ACC_SYNTHETIC)

#endif /* _JVM_CONSTANTS_H_ */
@@ -0,0 +1,68 @@
/*
* Copyright (c) 2021, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/

#ifndef _JVM_IO_H_
#define _JVM_IO_H_

#include <sys/stat.h>

#include "jni.h"
#include "jvm_md.h"

#ifdef __cplusplus
extern "C" {
#endif

/*
* The standard printing functions supported by the Java VM. (Should they
* be renamed to JVM_* in the future?
*/

/* jio_snprintf() and jio_vsnprintf() behave like snprintf(3) and vsnprintf(3),
* respectively, with the following differences:
* - The string written to str is always zero-terminated, also in case of
* truncation (count is too small to hold the result string), unless count
* is 0. In case of truncation count-1 characters are written and '\0'
* appendend.
* - If count is too small to hold the whole string, -1 is returned across
* all platforms. */

JNIEXPORT int
jio_vsnprintf(char *str, size_t count, const char *fmt, va_list args);

JNIEXPORT int
jio_snprintf(char *str, size_t count, const char *fmt, ...);

JNIEXPORT int
jio_fprintf(FILE *, const char *fmt, ...);

JNIEXPORT int
jio_vfprintf(FILE *, const char *fmt, va_list args);

#ifdef __cplusplus
} /* extern "C" */
#endif /* __cplusplus */

#endif /* _JVM_IO_H_ */
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2018, 2021, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -22,6 +22,7 @@
*
*/
#include "precompiled.hpp"
#include "jvm_io.h"
#include "utilities/ostream.hpp"
#include "logging/log.hpp"
#include "logging/logSelection.hpp"
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2015, 2019, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2015, 2021, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -26,6 +26,7 @@
#ifndef SHARE_PRIMS_STACKWALK_HPP
#define SHARE_PRIMS_STACKWALK_HPP

#include "jvm.h"
#include "oops/oop.hpp"
#include "runtime/vframe.hpp"

@@ -1,5 +1,5 @@
/*
* Copyright (c) 1998, 2020, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1998, 2021, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -23,6 +23,7 @@
*/

#include "precompiled.hpp"
#include "jvm_io.h"
#include "compiler/compilerDefinitions.hpp"
#include "runtime/arguments.hpp"
#include "runtime/vm_version.hpp"
@@ -1,5 +1,5 @@
/*
* Copyright (c) 1997, 2020, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1997, 2021, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -23,6 +23,7 @@
*/

#include "precompiled.hpp"
#include "jvm_io.h"
#include "jfr/jfrEvents.hpp"
#include "memory/allocation.inline.hpp"
#include "runtime/arguments.hpp"
@@ -1,5 +1,5 @@
/*
* Copyright (c) 1997, 2020, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1997, 2021, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -25,7 +25,7 @@
#ifndef SHARE_RUNTIME_OS_HPP
#define SHARE_RUNTIME_OS_HPP

#include "jvm.h"
#include "jvm_md.h"
#include "metaprogramming/integralConstant.hpp"
#include "utilities/exceptions.hpp"
#include "utilities/ostream.hpp"

0 comments on commit 5898ab6

Please sign in to comment.