hotspot/.mx.jvmci/mx_jvmci.py
author brutisso
Wed, 03 Feb 2016 18:21:43 +0100
changeset 35930 722866f5e209
parent 35598 8d7bc466f490
child 38663 03fe0752bb2f
permissions -rw-r--r--
8148951: Remove unused method Generation::performs_in_place_marking() Reviewed-by: david, jwilhelm
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
34505
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
     1
#
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
     2
# ----------------------------------------------------------------------------------------------------
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
     3
#
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
     4
# Copyright (c) 2007, 2015, Oracle and/or its affiliates. All rights reserved.
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
     5
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
     6
#
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
     7
# This code is free software; you can redistribute it and/or modify it
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
     8
# under the terms of the GNU General Public License version 2 only, as
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
     9
# published by the Free Software Foundation.
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
    10
#
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
    11
# This code is distributed in the hope that it will be useful, but WITHOUT
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
    12
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
    13
# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
    14
# version 2 for more details (a copy is included in the LICENSE file that
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
    15
# accompanied this code).
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
    16
#
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
    17
# You should have received a copy of the GNU General Public License version
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
    18
# 2 along with this work; if not, write to the Free Software Foundation,
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
    19
# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
    20
#
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
    21
# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
    22
# or visit www.oracle.com if you need additional information or have any
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
    23
# questions.
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
    24
#
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
    25
# ----------------------------------------------------------------------------------------------------
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
    26
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
    27
import os, shutil, zipfile, re, time, sys, datetime, platform
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
    28
from os.path import join, exists, dirname, isdir
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
    29
from argparse import ArgumentParser, REMAINDER
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
    30
import StringIO
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
    31
import xml.dom.minidom
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
    32
import subprocess
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
    33
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
    34
import mx
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
    35
import mx_gate
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
    36
import mx_unittest
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
    37
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
    38
from mx_gate import Task
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
    39
from mx_unittest import unittest
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
    40
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
    41
_suite = mx.suite('jvmci')
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
    42
35598
8d7bc466f490 8147470: update JVMCI mx extensions
dnsimon
parents: 35564
diff changeset
    43
JVMCI_VERSION = 9
8d7bc466f490 8147470: update JVMCI mx extensions
dnsimon
parents: 35564
diff changeset
    44
34505
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
    45
"""
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
    46
Top level directory of the JDK source workspace.
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
    47
"""
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
    48
_jdkSourceRoot = dirname(_suite.dir)
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
    49
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
    50
_JVMCI_JDK_TAG = 'jvmci'
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
    51
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
    52
_minVersion = mx.VersionSpec('1.9')
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
    53
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
    54
# max version (first _unsupported_ version)
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
    55
_untilVersion = None
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
    56
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
    57
_jvmciModes = {
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
    58
    'hosted' : ['-XX:+UnlockExperimentalVMOptions', '-XX:+EnableJVMCI'],
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
    59
    'jit' : ['-XX:+UnlockExperimentalVMOptions', '-XX:+EnableJVMCI', '-XX:+UseJVMCICompiler'],
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
    60
    'disabled' : []
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
    61
}
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
    62
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
    63
# TODO: can optimized be built without overriding release build?
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
    64
_jdkDebugLevels = ['release', 'fastdebug', 'slowdebug']
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
    65
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
    66
# TODO: add client once/if it can be built on 64-bit platforms
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
    67
_jdkJvmVariants = ['server']
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
    68
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
    69
"""
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
    70
Translation table from mx_jvmci:8 --vmbuild values to mx_jvmci:9 --jdk-debug-level values.
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
    71
"""
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
    72
_legacyVmbuilds = {
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
    73
    'product' : 'release',
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
    74
    'debug' : 'slowdebug'
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
    75
}
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
    76
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
    77
"""
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
    78
Translates a mx_jvmci:8 --vmbuild value to a mx_jvmci:9 --jdk-debug-level value.
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
    79
"""
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
    80
def _translateLegacyDebugLevel(debugLevel):
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
    81
    return _legacyVmbuilds.get(debugLevel, debugLevel)
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
    82
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
    83
"""
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
    84
Translation table from mx_jvmci:8 --vm values to mx_jvmci:9 (--jdk-jvm-variant, --jvmci-mode) tuples.
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
    85
"""
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
    86
_legacyVms = {
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
    87
    'jvmci' : ('server', 'jit')
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
    88
}
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
    89
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
    90
"""
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
    91
A VM configuration composed of a JDK debug level, JVM variant and a JVMCI mode.
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
    92
This is also a context manager that can be used with the 'with' statement to set/change
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
    93
a VM configuration within a dynamic scope. For example:
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
    94
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
    95
    with ConfiguredJDK(debugLevel='fastdebug'):
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
    96
        dacapo(['pmd'])
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
    97
"""
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
    98
class VM:
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
    99
    def __init__(self, jvmVariant=None, debugLevel=None, jvmciMode=None):
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   100
        self.update(jvmVariant, debugLevel, jvmciMode)
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   101
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   102
    def update(self, jvmVariant=None, debugLevel=None, jvmciMode=None):
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   103
        if jvmVariant in _legacyVms:
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   104
            # Backwards compatibility for mx_jvmci:8 API
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   105
            jvmVariant, newJvmciMode = _legacyVms[jvmVariant]
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   106
            if jvmciMode is not None and jvmciMode != newJvmciMode:
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   107
                mx.abort('JVM variant "' + jvmVariant + '" implies JVMCI mode "' + newJvmciMode +
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   108
                         '" which conflicts with explicitly specified JVMCI mode of "' + jvmciMode + '"')
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   109
            jvmciMode = newJvmciMode
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   110
        debugLevel = _translateLegacyDebugLevel(debugLevel)
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   111
        assert jvmVariant is None or jvmVariant in _jdkJvmVariants, jvmVariant
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   112
        assert debugLevel is None or debugLevel in _jdkDebugLevels, debugLevel
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   113
        assert jvmciMode is None or jvmciMode in _jvmciModes, jvmciMode
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   114
        self.jvmVariant = jvmVariant or _vm.jvmVariant
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   115
        self.debugLevel = debugLevel or _vm.debugLevel
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   116
        self.jvmciMode = jvmciMode or _vm.jvmciMode
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   117
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   118
    def __enter__(self):
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   119
        global _vm
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   120
        self.previousVm = _vm
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   121
        _vm = self
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   122
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   123
    def __exit__(self, exc_type, exc_value, traceback):
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   124
        global _vm
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   125
        _vm = self.previousVm
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   126
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   127
_vm = VM(jvmVariant=_jdkJvmVariants[0], debugLevel=_jdkDebugLevels[0], jvmciMode='hosted')
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   128
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   129
def get_vm():
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   130
    """
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   131
    Gets the configured VM.
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   132
    """
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   133
    return _vm
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   134
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   135
def relativeVmLibDirInJdk():
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   136
    mxos = mx.get_os()
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   137
    if mxos == 'darwin':
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   138
        return join('lib')
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   139
    if mxos == 'windows' or mxos == 'cygwin':
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   140
        return join('bin')
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   141
    return join('lib', mx.get_arch())
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   142
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   143
def isJVMCIEnabled(vm):
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   144
    assert vm in _jdkJvmVariants
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   145
    return True
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   146
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   147
class JvmciJDKDeployedDist(object):
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   148
    def __init__(self, name, compilers=False):
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   149
        self._name = name
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   150
        self._compilers = compilers
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   151
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   152
    def dist(self):
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   153
        return mx.distribution(self._name)
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   154
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   155
    def deploy(self, jdkDir):
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   156
        mx.nyi('deploy', self)
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   157
35564
3485bf43b924 8146364: Remove @ServiceProvider mechanism from JVMCI
dnsimon
parents: 35160
diff changeset
   158
    def post_parse_cmd_line(self):
3485bf43b924 8146364: Remove @ServiceProvider mechanism from JVMCI
dnsimon
parents: 35160
diff changeset
   159
        self.set_archiveparticipant()
3485bf43b924 8146364: Remove @ServiceProvider mechanism from JVMCI
dnsimon
parents: 35160
diff changeset
   160
3485bf43b924 8146364: Remove @ServiceProvider mechanism from JVMCI
dnsimon
parents: 35160
diff changeset
   161
    def set_archiveparticipant(self):
3485bf43b924 8146364: Remove @ServiceProvider mechanism from JVMCI
dnsimon
parents: 35160
diff changeset
   162
        dist = self.dist()
3485bf43b924 8146364: Remove @ServiceProvider mechanism from JVMCI
dnsimon
parents: 35160
diff changeset
   163
        dist.set_archiveparticipant(JVMCIArchiveParticipant(dist))
3485bf43b924 8146364: Remove @ServiceProvider mechanism from JVMCI
dnsimon
parents: 35160
diff changeset
   164
34505
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   165
class ExtJDKDeployedDist(JvmciJDKDeployedDist):
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   166
    def __init__(self, name):
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   167
        JvmciJDKDeployedDist.__init__(self, name)
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   168
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   169
"""
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   170
The monolithic JVMCI distribution is deployed through use of -Xbootclasspath/p
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   171
so that it's not necessary to run JDK make after editing JVMCI sources.
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   172
The latter causes all JDK Java sources to be rebuilt since JVMCI is
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   173
(currently) in java.base.
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   174
"""
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   175
_monolithicJvmci = JvmciJDKDeployedDist('JVMCI')
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   176
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   177
"""
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   178
List of distributions that are deployed on the boot class path.
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   179
Note: In jvmci-8, they were deployed directly into the JDK directory.
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   180
"""
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   181
jdkDeployedDists = [_monolithicJvmci]
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   182
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   183
def _makehelp():
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   184
    return subprocess.check_output([mx.gmake_cmd(), 'help'], cwd=_jdkSourceRoot)
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   185
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   186
def _runmake(args):
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   187
    """run the JDK make process
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   188
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   189
To build hotspot and import it into the JDK: "mx make hotspot import-hotspot"
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   190
{0}"""
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   191
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   192
    jdkBuildDir = _get_jdk_build_dir()
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   193
    if not exists(jdkBuildDir):
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   194
        # JDK9 must be bootstrapped with a JDK8
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   195
        compliance = mx.JavaCompliance('8')
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   196
        jdk8 = mx.get_jdk(compliance.exactMatch, versionDescription=compliance.value)
35598
8d7bc466f490 8147470: update JVMCI mx extensions
dnsimon
parents: 35564
diff changeset
   197
        cmd = ['sh', 'configure', '--with-debug-level=' + _vm.debugLevel, '--with-native-debug-symbols=none', '--disable-precompiled-headers',
34505
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   198
               '--with-jvm-variants=' + _vm.jvmVariant, '--disable-warnings-as-errors', '--with-boot-jdk=' + jdk8.home]
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   199
        mx.run(cmd, cwd=_jdkSourceRoot)
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   200
    cmd = [mx.gmake_cmd(), 'CONF=' + _vm.debugLevel]
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   201
    if mx.get_opts().verbose:
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   202
        cmd.append('LOG=debug')
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   203
    cmd.extend(args)
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   204
    if mx.get_opts().use_jdk_image and 'images' not in args:
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   205
        cmd.append('images')
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   206
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   207
    if not mx.get_opts().verbose:
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   208
        mx.log('--------------- make execution ----------------------')
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   209
        mx.log('Working directory: ' + _jdkSourceRoot)
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   210
        mx.log('Command line: ' + ' '.join(cmd))
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   211
        mx.log('-----------------------------------------------------')
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   212
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   213
    mx.run(cmd, cwd=_jdkSourceRoot)
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   214
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   215
    if 'images' in cmd:
35598
8d7bc466f490 8147470: update JVMCI mx extensions
dnsimon
parents: 35564
diff changeset
   216
        jdkImageDir = join(jdkBuildDir, 'images', 'jdk')
8d7bc466f490 8147470: update JVMCI mx extensions
dnsimon
parents: 35564
diff changeset
   217
8d7bc466f490 8147470: update JVMCI mx extensions
dnsimon
parents: 35564
diff changeset
   218
        # The OpenJDK build creates an empty cacerts file so copy one from
8d7bc466f490 8147470: update JVMCI mx extensions
dnsimon
parents: 35564
diff changeset
   219
        # the default JDK (which is assumed to be an OracleJDK)
8d7bc466f490 8147470: update JVMCI mx extensions
dnsimon
parents: 35564
diff changeset
   220
        srcCerts = join(mx.get_jdk(tag='default').home, 'jre', 'lib', 'security', 'cacerts')
8d7bc466f490 8147470: update JVMCI mx extensions
dnsimon
parents: 35564
diff changeset
   221
        dstCerts = join(jdkImageDir, 'lib', 'security', 'cacerts')
8d7bc466f490 8147470: update JVMCI mx extensions
dnsimon
parents: 35564
diff changeset
   222
        shutil.copyfile(srcCerts, dstCerts)
8d7bc466f490 8147470: update JVMCI mx extensions
dnsimon
parents: 35564
diff changeset
   223
8d7bc466f490 8147470: update JVMCI mx extensions
dnsimon
parents: 35564
diff changeset
   224
        _create_jdk_bundle(jdkBuildDir, _vm.debugLevel, jdkImageDir)
34505
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   225
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   226
def _get_jdk_bundle_arches():
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   227
    """
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   228
    Gets a list of names that will be the part of a JDK bundle's file name denoting the architecture.
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   229
    The first element in the list is the canonical name. Symlinks should be created for the
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   230
    remaining names.
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   231
    """
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   232
    cpu = mx.get_arch()
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   233
    if cpu == 'amd64':
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   234
        return ['x64', 'x86_64', 'amd64']
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   235
    elif cpu == 'sparcv9':
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   236
        return ['sparcv9']
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   237
    mx.abort('Unsupported JDK bundle arch: ' + cpu)
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   238
35598
8d7bc466f490 8147470: update JVMCI mx extensions
dnsimon
parents: 35564
diff changeset
   239
def _create_jdk_bundle(jdkBuildDir, debugLevel, jdkImageDir):
34505
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   240
    """
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   241
    Creates a tar.gz JDK archive, an accompanying tar.gz.sha1 file with its
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   242
    SHA1 signature plus symlinks to the archive for non-canonical architecture names.
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   243
    """
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   244
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   245
    arches = _get_jdk_bundle_arches()
35598
8d7bc466f490 8147470: update JVMCI mx extensions
dnsimon
parents: 35564
diff changeset
   246
    jdkTgzPath = join(_suite.get_output_root(), 'jdk-bundles', 'jdk9-{}-{}-{}.tar.gz'.format(debugLevel, _get_openjdk_os(), arches[0]))
34505
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   247
    with mx.Archiver(jdkTgzPath, kind='tgz') as arc:
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   248
        mx.log('Creating ' + jdkTgzPath)
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   249
        for root, _, filenames in os.walk(jdkImageDir):
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   250
            for name in filenames:
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   251
                f = join(root, name)
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   252
                arcname = 'jdk1.9.0/' + os.path.relpath(f, jdkImageDir)
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   253
                arc.zf.add(name=f, arcname=arcname, recursive=False)
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   254
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   255
    with open(jdkTgzPath + '.sha1', 'w') as fp:
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   256
        mx.log('Creating ' + jdkTgzPath + '.sha1')
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   257
        fp.write(mx.sha1OfFile(jdkTgzPath))
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   258
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   259
    def _create_link(source, link_name):
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   260
        if exists(link_name):
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   261
            os.remove(link_name)
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   262
        mx.log('Creating ' + link_name + ' -> ' + source)
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   263
        os.symlink(source, link_name)
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   264
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   265
    for arch in arches[1:]:
35598
8d7bc466f490 8147470: update JVMCI mx extensions
dnsimon
parents: 35564
diff changeset
   266
        link_name = join(_suite.get_output_root(), 'jdk-bundles', 'jdk9-{}-{}-{}.tar.gz'.format(debugLevel, _get_openjdk_os(), arch))
34505
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   267
        jdkTgzName = os.path.basename(jdkTgzPath)
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   268
        _create_link(jdkTgzName, link_name)
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   269
        _create_link(jdkTgzName + '.sha1', link_name + '.sha1')
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   270
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   271
def _runmultimake(args):
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   272
    """run the JDK make process for one or more configurations"""
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   273
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   274
    jvmVariantsDefault = ','.join(_jdkJvmVariants)
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   275
    debugLevelsDefault = ','.join(_jdkDebugLevels)
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   276
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   277
    parser = ArgumentParser(prog='mx multimake')
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   278
    parser.add_argument('--jdk-jvm-variants', '--vms', help='a comma separated list of VMs to build (default: ' + jvmVariantsDefault + ')', metavar='<args>', default=jvmVariantsDefault)
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   279
    parser.add_argument('--jdk-debug-levels', '--builds', help='a comma separated list of JDK debug levels (default: ' + debugLevelsDefault + ')', metavar='<args>', default=debugLevelsDefault)
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   280
    parser.add_argument('-n', '--no-check', action='store_true', help='omit running "java -version" after each build')
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   281
    select = parser.add_mutually_exclusive_group()
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   282
    select.add_argument('-c', '--console', action='store_true', help='send build output to console instead of log files')
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   283
    select.add_argument('-d', '--output-dir', help='directory for log files instead of current working directory', default=os.getcwd(), metavar='<dir>')
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   284
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   285
    args = parser.parse_args(args)
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   286
    jvmVariants = args.jdk_jvm_variants.split(',')
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   287
    debugLevels = [_translateLegacyDebugLevel(dl) for dl in args.jdk_debug_levels.split(',')]
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   288
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   289
    allStart = time.time()
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   290
    for jvmVariant in jvmVariants:
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   291
        for debugLevel in debugLevels:
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   292
            if not args.console:
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   293
                logFile = join(mx.ensure_dir_exists(args.output_dir), jvmVariant + '-' + debugLevel + '.log')
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   294
                log = open(logFile, 'wb')
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   295
                start = time.time()
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   296
                mx.log('BEGIN: ' + jvmVariant + '-' + debugLevel + '\t(see: ' + logFile + ')')
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   297
                verbose = ['-v'] if mx.get_opts().verbose else []
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   298
                # Run as subprocess so that output can be directed to a file
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   299
                cmd = [sys.executable, '-u', mx.__file__] + verbose + ['--jdk-jvm-variant=' + jvmVariant, '--jdk-debug-level=' + debugLevel, 'make']
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   300
                mx.logv("executing command: " + str(cmd))
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   301
                subprocess.check_call(cmd, cwd=_suite.dir, stdout=log, stderr=subprocess.STDOUT)
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   302
                duration = datetime.timedelta(seconds=time.time() - start)
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   303
                mx.log('END:   ' + jvmVariant + '-' + debugLevel + '\t[' + str(duration) + ']')
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   304
            else:
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   305
                with VM(jvmVariant=jvmVariant, debugLevel=debugLevel):
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   306
                    _runmake([])
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   307
            if not args.no_check:
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   308
                with VM(jvmciMode='jit'):
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   309
                    run_vm(['-XX:-BootstrapJVMCI', '-version'])
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   310
    allDuration = datetime.timedelta(seconds=time.time() - allStart)
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   311
    mx.log('TOTAL TIME:   ' + '[' + str(allDuration) + ']')
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   312
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   313
class HotSpotProject(mx.NativeProject):
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   314
    """
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   315
    Defines a NativeProject representing the HotSpot binaries built via make.
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   316
    """
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   317
    def __init__(self, suite, name, deps, workingSets, **args):
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   318
        assert name == 'hotspot'
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   319
        mx.NativeProject.__init__(self, suite, name, "", [], deps, workingSets, None, None, join(suite.mxDir, name))
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   320
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   321
    def eclipse_config_up_to_date(self, configZip):
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   322
        # Assume that any change to this module might imply changes to the generated IDE files
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   323
        if configZip.isOlderThan(__file__):
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   324
            return False
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   325
        for _, source in self._get_eclipse_settings_sources().iteritems():
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   326
            if configZip.isOlderThan(source):
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   327
                return False
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   328
        return True
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   329
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   330
    def _get_eclipse_settings_sources(self):
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   331
        """
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   332
        Gets a dictionary from the name of an Eclipse settings file to
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   333
        the file providing its generated content.
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   334
        """
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   335
        if not hasattr(self, '_eclipse_settings'):
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   336
            esdict = {}
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   337
            templateSettingsDir = join(self.dir, 'templates', 'eclipse', 'settings')
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   338
            if exists(templateSettingsDir):
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   339
                for name in os.listdir(templateSettingsDir):
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   340
                    source = join(templateSettingsDir, name)
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   341
                    esdict[name] = source
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   342
            self._eclipse_settings = esdict
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   343
        return self._eclipse_settings
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   344
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   345
    def _eclipseinit(self, files=None, libFiles=None):
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   346
        """
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   347
        Generates an Eclipse project for each HotSpot build configuration.
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   348
        """
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   349
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   350
        roots = [
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   351
            'ASSEMBLY_EXCEPTION',
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   352
            'LICENSE',
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   353
            'README',
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   354
            'THIRD_PARTY_README',
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   355
            'agent',
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   356
            'make',
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   357
            'src',
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   358
            'test'
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   359
        ]
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   360
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   361
        for jvmVariant in _jdkJvmVariants:
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   362
            for debugLevel in _jdkDebugLevels:
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   363
                name = jvmVariant + '-' + debugLevel
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   364
                eclProjectDir = join(self.dir, 'eclipse', name)
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   365
                mx.ensure_dir_exists(eclProjectDir)
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   366
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   367
                out = mx.XMLDoc()
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   368
                out.open('projectDescription')
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   369
                out.element('name', data='hotspot:' + name)
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   370
                out.element('comment', data='')
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   371
                out.element('projects', data='')
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   372
                out.open('buildSpec')
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   373
                out.open('buildCommand')
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   374
                out.element('name', data='org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder')
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   375
                out.element('triggers', data='full,incremental')
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   376
                out.element('arguments', data='')
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   377
                out.close('buildCommand')
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   378
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   379
                out.close('buildSpec')
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   380
                out.open('natures')
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   381
                out.element('nature', data='org.eclipse.cdt.core.cnature')
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   382
                out.element('nature', data='org.eclipse.cdt.core.ccnature')
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   383
                out.element('nature', data='org.eclipse.cdt.managedbuilder.core.managedBuildNature')
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   384
                out.element('nature', data='org.eclipse.cdt.managedbuilder.core.ScannerConfigNature')
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   385
                out.close('natures')
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   386
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   387
                if roots:
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   388
                    out.open('linkedResources')
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   389
                    for r in roots:
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   390
                        f = join(_suite.dir, r)
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   391
                        out.open('link')
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   392
                        out.element('name', data=r)
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   393
                        out.element('type', data='2' if isdir(f) else '1')
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   394
                        out.element('locationURI', data=mx.get_eclipse_project_rel_locationURI(f, eclProjectDir))
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   395
                        out.close('link')
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   396
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   397
                    out.open('link')
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   398
                    out.element('name', data='generated')
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   399
                    out.element('type', data='2')
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   400
                    generated = join(_get_hotspot_build_dir(jvmVariant, debugLevel), 'generated')
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   401
                    out.element('locationURI', data=mx.get_eclipse_project_rel_locationURI(generated, eclProjectDir))
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   402
                    out.close('link')
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   403
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   404
                    out.close('linkedResources')
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   405
                out.close('projectDescription')
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   406
                projectFile = join(eclProjectDir, '.project')
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   407
                mx.update_file(projectFile, out.xml(indent='\t', newl='\n'))
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   408
                if files:
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   409
                    files.append(projectFile)
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   410
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   411
                cprojectTemplate = join(self.dir, 'templates', 'eclipse', 'cproject')
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   412
                cprojectFile = join(eclProjectDir, '.cproject')
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   413
                with open(cprojectTemplate) as f:
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   414
                    content = f.read()
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   415
                mx.update_file(cprojectFile, content)
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   416
                if files:
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   417
                    files.append(cprojectFile)
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   418
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   419
                settingsDir = join(eclProjectDir, ".settings")
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   420
                mx.ensure_dir_exists(settingsDir)
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   421
                for name, source in self._get_eclipse_settings_sources().iteritems():
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   422
                    out = StringIO.StringIO()
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   423
                    print >> out, '# GENERATED -- DO NOT EDIT'
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   424
                    print >> out, '# Source:', source
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   425
                    with open(source) as f:
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   426
                        print >> out, f.read()
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   427
                    content = out.getvalue()
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   428
                    mx.update_file(join(settingsDir, name), content)
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   429
                    if files:
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   430
                        files.append(join(settingsDir, name))
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   431
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   432
    def getBuildTask(self, args):
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   433
        return JDKBuildTask(self, args, _vm.debugLevel, _vm.jvmVariant)
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   434
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   435
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   436
class JDKBuildTask(mx.NativeBuildTask):
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   437
    def __init__(self, project, args, debugLevel, jvmVariant):
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   438
        mx.NativeBuildTask.__init__(self, args, project)
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   439
        self.jvmVariant = jvmVariant
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   440
        self.debugLevel = debugLevel
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   441
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   442
    def __str__(self):
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   443
        return 'Building JDK[{}, {}]'.format(self.debugLevel, self.jvmVariant)
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   444
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   445
    def build(self):
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   446
        if mx.get_opts().use_jdk_image:
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   447
            _runmake(['images'])
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   448
        else:
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   449
            _runmake([])
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   450
        self._newestOutput = None
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   451
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   452
    def clean(self, forBuild=False):
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   453
        if forBuild:  # Let make handle incremental builds
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   454
            return
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   455
        if exists(_get_jdk_build_dir(self.debugLevel)):
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   456
            _runmake(['clean'])
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   457
        self._newestOutput = None
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   458
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   459
# Backwards compatibility for mx_jvmci:8 API
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   460
def buildvms(args):
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   461
    _runmultimake(args)
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   462
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   463
def run_vm(args, vm=None, nonZeroIsFatal=True, out=None, err=None, cwd=None, timeout=None, debugLevel=None, vmbuild=None):
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   464
    """run a Java program by executing the java executable in a JVMCI JDK"""
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   465
    jdkTag = mx.get_jdk_option().tag
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   466
    if jdkTag and jdkTag != _JVMCI_JDK_TAG:
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   467
        mx.abort('The "--jdk" option must have the tag "' + _JVMCI_JDK_TAG + '" when running a command requiring a JVMCI VM')
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   468
    jdk = get_jvmci_jdk(debugLevel=debugLevel or _translateLegacyDebugLevel(vmbuild))
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   469
    return jdk.run_java(args, nonZeroIsFatal=nonZeroIsFatal, out=out, err=err, cwd=cwd, timeout=timeout)
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   470
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   471
def _unittest_vm_launcher(vmArgs, mainClass, mainClassArgs):
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   472
    run_vm(vmArgs + [mainClass] + mainClassArgs)
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   473
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   474
mx_unittest.set_vm_launcher('JVMCI VM launcher', _unittest_vm_launcher)
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   475
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   476
def _jvmci_gate_runner(args, tasks):
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   477
    # Build release server VM now so we can run the unit tests
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   478
    with Task('BuildHotSpotJVMCIHosted: release', tasks) as t:
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   479
        if t: _runmultimake(['--jdk-jvm-variants', 'server', '--jdk-debug-levels', 'release'])
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   480
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   481
    # Run unit tests in hosted mode
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   482
    with VM(jvmVariant='server', debugLevel='release', jvmciMode='hosted'):
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   483
        with Task('JVMCI UnitTests: hosted-release', tasks) as t:
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   484
            if t: unittest(['--suite', 'jvmci', '--enable-timing', '--verbose', '--fail-fast'])
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   485
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   486
    # Build the other VM flavors
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   487
    with Task('BuildHotSpotJVMCIOthers: fastdebug', tasks) as t:
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   488
        if t: _runmultimake(['--jdk-jvm-variants', 'server', '--jdk-debug-levels', 'fastdebug'])
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   489
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   490
    with Task('CleanAndBuildIdealGraphVisualizer', tasks, disableJacoco=True) as t:
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   491
        if t and platform.processor() != 'sparc':
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   492
            buildxml = mx._cygpathU2W(join(_suite.dir, 'src', 'share', 'tools', 'IdealGraphVisualizer', 'build.xml'))
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   493
            mx.run(['ant', '-f', buildxml, '-q', 'clean', 'build'], env=_igvBuildEnv())
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   494
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   495
mx_gate.add_gate_runner(_suite, _jvmci_gate_runner)
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   496
mx_gate.add_gate_argument('-g', '--only-build-jvmci', action='store_false', dest='buildNonJVMCI', help='only build the JVMCI VM')
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   497
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   498
def _igvJdk():
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   499
    v8u20 = mx.VersionSpec("1.8.0_20")
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   500
    v8u40 = mx.VersionSpec("1.8.0_40")
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   501
    v8 = mx.VersionSpec("1.8")
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   502
    def _igvJdkVersionCheck(version):
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   503
        return version >= v8 and (version < v8u20 or version >= v8u40)
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   504
    return mx.get_jdk(_igvJdkVersionCheck, versionDescription='>= 1.8 and < 1.8.0u20 or >= 1.8.0u40', purpose="building & running IGV").home
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   505
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   506
def _igvBuildEnv():
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   507
        # When the http_proxy environment variable is set, convert it to the proxy settings that ant needs
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   508
    env = dict(os.environ)
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   509
    proxy = os.environ.get('http_proxy')
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   510
    if not (proxy is None) and len(proxy) > 0:
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   511
        if '://' in proxy:
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   512
            # Remove the http:// prefix (or any other protocol prefix)
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   513
            proxy = proxy.split('://', 1)[1]
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   514
        # Separate proxy server name and port number
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   515
        proxyName, proxyPort = proxy.split(':', 1)
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   516
        proxyEnv = '-DproxyHost="' + proxyName + '" -DproxyPort=' + proxyPort
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   517
        env['ANT_OPTS'] = proxyEnv
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   518
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   519
    env['JAVA_HOME'] = _igvJdk()
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   520
    return env
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   521
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   522
def igv(args):
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   523
    """run the Ideal Graph Visualizer"""
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   524
    logFile = '.ideal_graph_visualizer.log'
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   525
    with open(join(_suite.dir, logFile), 'w') as fp:
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   526
        mx.logv('[Ideal Graph Visualizer log is in ' + fp.name + ']')
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   527
        nbplatform = join(_suite.dir, 'src', 'share', 'tools', 'IdealGraphVisualizer', 'nbplatform')
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   528
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   529
        # Remove NetBeans platform if it is earlier than the current supported version
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   530
        if exists(nbplatform):
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   531
            updateTrackingFile = join(nbplatform, 'platform', 'update_tracking', 'org-netbeans-core.xml')
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   532
            if not exists(updateTrackingFile):
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   533
                mx.log('Could not find \'' + updateTrackingFile + '\', removing NetBeans platform')
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   534
                shutil.rmtree(nbplatform)
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   535
            else:
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   536
                dom = xml.dom.minidom.parse(updateTrackingFile)
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   537
                currentVersion = mx.VersionSpec(dom.getElementsByTagName('module_version')[0].getAttribute('specification_version'))
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   538
                supportedVersion = mx.VersionSpec('3.43.1')
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   539
                if currentVersion < supportedVersion:
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   540
                    mx.log('Replacing NetBeans platform version ' + str(currentVersion) + ' with version ' + str(supportedVersion))
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   541
                    shutil.rmtree(nbplatform)
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   542
                elif supportedVersion < currentVersion:
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   543
                    mx.log('Supported NetBeans version in igv command should be updated to ' + str(currentVersion))
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   544
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   545
        if not exists(nbplatform):
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   546
            mx.logv('[This execution may take a while as the NetBeans platform needs to be downloaded]')
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   547
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   548
        env = _igvBuildEnv()
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   549
        # make the jar for Batik 1.7 available.
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   550
        env['IGV_BATIK_JAR'] = mx.library('BATIK').get_path(True)
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   551
        if mx.run(['ant', '-f', mx._cygpathU2W(join(_suite.dir, 'src', 'share', 'tools', 'IdealGraphVisualizer', 'build.xml')), '-l', mx._cygpathU2W(fp.name), 'run'], env=env, nonZeroIsFatal=False):
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   552
            mx.abort("IGV ant build & launch failed. Check '" + logFile + "'. You can also try to delete 'src/share/tools/IdealGraphVisualizer/nbplatform'.")
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   553
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   554
def c1visualizer(args):
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   555
    """run the Cl Compiler Visualizer"""
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   556
    libpath = join(_suite.dir, 'lib')
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   557
    if mx.get_os() == 'windows':
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   558
        executable = join(libpath, 'c1visualizer', 'bin', 'c1visualizer.exe')
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   559
    else:
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   560
        executable = join(libpath, 'c1visualizer', 'bin', 'c1visualizer')
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   561
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   562
    # Check whether the current C1Visualizer installation is the up-to-date
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   563
    if exists(executable) and not exists(mx.library('C1VISUALIZER_DIST').get_path(resolve=False)):
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   564
        mx.log('Updating C1Visualizer')
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   565
        shutil.rmtree(join(libpath, 'c1visualizer'))
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   566
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   567
    archive = mx.library('C1VISUALIZER_DIST').get_path(resolve=True)
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   568
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   569
    if not exists(executable):
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   570
        zf = zipfile.ZipFile(archive, 'r')
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   571
        zf.extractall(libpath)
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   572
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   573
    if not exists(executable):
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   574
        mx.abort('C1Visualizer binary does not exist: ' + executable)
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   575
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   576
    if mx.get_os() != 'windows':
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   577
        # Make sure that execution is allowed. The zip file does not always specfiy that correctly
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   578
        os.chmod(executable, 0777)
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   579
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   580
    mx.run([executable])
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   581
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   582
def hsdis(args, copyToDir=None):
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   583
    """download the hsdis library
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   584
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   585
    This is needed to support HotSpot's assembly dumping features.
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   586
    By default it downloads the Intel syntax version, use the 'att' argument to install AT&T syntax."""
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   587
    flavor = 'intel'
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   588
    if 'att' in args:
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   589
        flavor = 'att'
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   590
    if mx.get_arch() == "sparcv9":
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   591
        flavor = "sparcv9"
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   592
    lib = mx.add_lib_suffix('hsdis-' + mx.get_arch())
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   593
    path = join(_suite.dir, 'lib', lib)
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   594
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   595
    sha1s = {
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   596
        'att/hsdis-amd64.dll' : 'bcbd535a9568b5075ab41e96205e26a2bac64f72',
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   597
        'att/hsdis-amd64.so' : '58919ba085d4ef7a513f25bae75e7e54ee73c049',
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   598
        'intel/hsdis-amd64.dll' : '6a388372cdd5fe905c1a26ced614334e405d1f30',
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   599
        'intel/hsdis-amd64.so' : '844ed9ffed64fe9599638f29a8450c50140e3192',
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   600
        'intel/hsdis-amd64.dylib' : 'fdb13ef0d7d23d93dacaae9c98837bea0d4fc5a2',
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   601
        'sparcv9/hsdis-sparcv9.so': '970640a9af0bd63641f9063c11275b371a59ee60',
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   602
    }
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   603
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   604
    flavoredLib = flavor + "/" + lib
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   605
    if flavoredLib not in sha1s:
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   606
        mx.logv("hsdis not supported on this plattform or architecture")
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   607
        return
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   608
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   609
    if not exists(path):
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   610
        sha1 = sha1s[flavoredLib]
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   611
        sha1path = path + '.sha1'
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   612
        mx.download_file_with_sha1('hsdis', path, ['https://lafo.ssw.uni-linz.ac.at/pub/hsdis/' + flavoredLib], sha1, sha1path, True, True, sources=False)
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   613
    if copyToDir is not None and exists(copyToDir):
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   614
        shutil.copy(path, copyToDir)
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   615
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   616
def hcfdis(args):
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   617
    """disassemble HexCodeFiles embedded in text files
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   618
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   619
    Run a tool over the input files to convert all embedded HexCodeFiles
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   620
    to a disassembled format."""
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   621
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   622
    parser = ArgumentParser(prog='mx hcfdis')
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   623
    parser.add_argument('-m', '--map', help='address to symbol map applied to disassembler output')
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   624
    parser.add_argument('files', nargs=REMAINDER, metavar='files...')
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   625
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   626
    args = parser.parse_args(args)
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   627
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   628
    path = mx.library('HCFDIS').get_path(resolve=True)
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   629
    mx.run_java(['-cp', path, 'com.oracle.max.hcfdis.HexCodeFileDis'] + args.files)
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   630
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   631
    if args.map is not None:
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   632
        addressRE = re.compile(r'0[xX]([A-Fa-f0-9]+)')
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   633
        with open(args.map) as fp:
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   634
            lines = fp.read().splitlines()
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   635
        symbols = dict()
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   636
        for l in lines:
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   637
            addressAndSymbol = l.split(' ', 1)
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   638
            if len(addressAndSymbol) == 2:
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   639
                address, symbol = addressAndSymbol
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   640
                if address.startswith('0x'):
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   641
                    address = long(address, 16)
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   642
                    symbols[address] = symbol
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   643
        for f in args.files:
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   644
            with open(f) as fp:
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   645
                lines = fp.read().splitlines()
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   646
            updated = False
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   647
            for i in range(0, len(lines)):
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   648
                l = lines[i]
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   649
                for m in addressRE.finditer(l):
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   650
                    sval = m.group(0)
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   651
                    val = long(sval, 16)
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   652
                    sym = symbols.get(val)
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   653
                    if sym:
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   654
                        l = l.replace(sval, sym)
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   655
                        updated = True
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   656
                        lines[i] = l
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   657
            if updated:
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   658
                mx.log('updating ' + f)
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   659
                with open('new_' + f, "w") as fp:
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   660
                    for l in lines:
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   661
                        print >> fp, l
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   662
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   663
def jol(args):
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   664
    """Java Object Layout"""
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   665
    joljar = mx.library('JOL_INTERNALS').get_path(resolve=True)
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   666
    candidates = mx.findclass(args, logToConsole=False, matcher=lambda s, classname: s == classname or classname.endswith('.' + s) or classname.endswith('$' + s))
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   667
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   668
    if len(candidates) > 0:
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   669
        candidates = mx.select_items(sorted(candidates))
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   670
    else:
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   671
        # mx.findclass can be mistaken, don't give up yet
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   672
        candidates = args
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   673
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   674
    run_vm(['-javaagent:' + joljar, '-cp', os.pathsep.join([mx.classpath(), joljar]), "org.openjdk.jol.MainObjectInternals"] + candidates)
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   675
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   676
class JVMCIArchiveParticipant:
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   677
    def __init__(self, dist):
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   678
        self.dist = dist
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   679
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   680
    def __opened__(self, arc, srcArc, services):
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   681
        self.services = services
35564
3485bf43b924 8146364: Remove @ServiceProvider mechanism from JVMCI
dnsimon
parents: 35160
diff changeset
   682
        self.jvmciServices = services
34505
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   683
        self.arc = arc
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   684
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   685
    def __add__(self, arcname, contents):
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   686
        return False
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   687
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   688
    def __addsrc__(self, arcname, contents):
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   689
        return False
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   690
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   691
    def __closing__(self):
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   692
        pass
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   693
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   694
def _get_openjdk_os():
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   695
    # See: common/autoconf/platform.m4
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   696
    os = mx.get_os()
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   697
    if 'darwin' in os:
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   698
        os = 'macosx'
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   699
    elif 'linux' in os:
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   700
        os = 'linux'
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   701
    elif 'solaris' in os:
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   702
        os = 'solaris'
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   703
    elif 'cygwin' in os or 'mingw' in os:
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   704
        os = 'windows'
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   705
    return os
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   706
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   707
def _get_openjdk_cpu():
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   708
    cpu = mx.get_arch()
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   709
    if cpu == 'amd64':
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   710
        cpu = 'x86_64'
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   711
    elif cpu == 'sparcv9':
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   712
        cpu = 'sparcv9'
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   713
    return cpu
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   714
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   715
def _get_openjdk_os_cpu():
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   716
    return _get_openjdk_os() + '-' + _get_openjdk_cpu()
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   717
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   718
def _get_jdk_build_dir(debugLevel=None):
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   719
    """
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   720
    Gets the directory into which the JDK is built. This directory contains
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   721
    the exploded JDK under jdk/ and the JDK image under images/jdk/.
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   722
    """
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   723
    if debugLevel is None:
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   724
        debugLevel = _vm.debugLevel
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   725
    name = '{}-{}-{}-{}'.format(_get_openjdk_os_cpu(), 'normal', _vm.jvmVariant, debugLevel)
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   726
    return join(dirname(_suite.dir), 'build', name)
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   727
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   728
_jvmci_bootclasspath_prepends = []
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   729
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   730
def _get_hotspot_build_dir(jvmVariant=None, debugLevel=None):
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   731
    """
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   732
    Gets the directory in which a particular HotSpot configuration is built
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   733
    (e.g., <JDK_REPO_ROOT>/build/macosx-x86_64-normal-server-release/hotspot/bsd_amd64_compiler2)
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   734
    """
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   735
    if jvmVariant is None:
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   736
        jvmVariant = _vm.jvmVariant
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   737
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   738
    os = mx.get_os()
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   739
    if os == 'darwin':
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   740
        os = 'bsd'
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   741
    arch = mx.get_arch()
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   742
    buildname = {'client': 'compiler1', 'server': 'compiler2'}.get(jvmVariant, jvmVariant)
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   743
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   744
    name = '{}_{}_{}'.format(os, arch, buildname)
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   745
    return join(_get_jdk_build_dir(debugLevel=debugLevel), 'hotspot', name)
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   746
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   747
def add_bootclasspath_prepend(dep):
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   748
    assert isinstance(dep, mx.ClasspathDependency)
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   749
    _jvmci_bootclasspath_prepends.append(dep)
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   750
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   751
class JVMCI9JDKConfig(mx.JDKConfig):
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   752
    def __init__(self, debugLevel):
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   753
        self.debugLevel = debugLevel
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   754
        jdkBuildDir = _get_jdk_build_dir(debugLevel)
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   755
        jdkDir = join(jdkBuildDir, 'images', 'jdk') if mx.get_opts().use_jdk_image else join(jdkBuildDir, 'jdk')
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   756
        mx.JDKConfig.__init__(self, jdkDir, tag=_JVMCI_JDK_TAG)
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   757
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   758
    def parseVmArgs(self, args, addDefaultArgs=True):
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   759
        args = mx.expand_project_in_args(args, insitu=False)
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   760
        jacocoArgs = mx_gate.get_jacoco_agent_args()
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   761
        if jacocoArgs:
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   762
            args = jacocoArgs + args
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   763
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   764
        args = ['-Xbootclasspath/p:' + dep.classpath_repr() for dep in _jvmci_bootclasspath_prepends] + args
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   765
35598
8d7bc466f490 8147470: update JVMCI mx extensions
dnsimon
parents: 35564
diff changeset
   766
        # Remove JVMCI jars from class path. They are only necessary when
8d7bc466f490 8147470: update JVMCI mx extensions
dnsimon
parents: 35564
diff changeset
   767
        # compiling with a javac from JDK8 or earlier.
8d7bc466f490 8147470: update JVMCI mx extensions
dnsimon
parents: 35564
diff changeset
   768
        cpIndex, cp = mx.find_classpath_arg(args)
8d7bc466f490 8147470: update JVMCI mx extensions
dnsimon
parents: 35564
diff changeset
   769
        if cp:
8d7bc466f490 8147470: update JVMCI mx extensions
dnsimon
parents: 35564
diff changeset
   770
            excluded = frozenset([dist.path for dist in _suite.dists])
8d7bc466f490 8147470: update JVMCI mx extensions
dnsimon
parents: 35564
diff changeset
   771
            cp = os.pathsep.join([e for e in cp.split(os.pathsep) if e not in excluded])
8d7bc466f490 8147470: update JVMCI mx extensions
dnsimon
parents: 35564
diff changeset
   772
            args[cpIndex] = cp
8d7bc466f490 8147470: update JVMCI mx extensions
dnsimon
parents: 35564
diff changeset
   773
34505
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   774
        jvmciModeArgs = _jvmciModes[_vm.jvmciMode]
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   775
        if jvmciModeArgs:
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   776
            bcpDeps = [jdkDist.dist() for jdkDist in jdkDeployedDists]
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   777
            if bcpDeps:
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   778
                args = ['-Xbootclasspath/p:' + os.pathsep.join([d.classpath_repr() for d in bcpDeps])] + args
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   779
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   780
        # Set the default JVMCI compiler
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   781
        for jdkDist in reversed(jdkDeployedDists):
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   782
            assert isinstance(jdkDist, JvmciJDKDeployedDist), jdkDist
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   783
            if jdkDist._compilers:
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   784
                jvmciCompiler = jdkDist._compilers[-1]
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   785
                args = ['-Djvmci.compiler=' + jvmciCompiler] + args
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   786
                break
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   787
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   788
        if '-version' in args:
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   789
            ignoredArgs = args[args.index('-version') + 1:]
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   790
            if  len(ignoredArgs) > 0:
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   791
                mx.log("Warning: The following options will be ignored by the vm because they come after the '-version' argument: " + ' '.join(ignoredArgs))
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   792
        return self.processArgs(args, addDefaultArgs=addDefaultArgs)
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   793
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   794
    # Overrides JDKConfig
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   795
    def run_java(self, args, vm=None, nonZeroIsFatal=True, out=None, err=None, cwd=None, timeout=None, env=None, addDefaultArgs=True):
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   796
        if vm is None:
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   797
            vm = 'server'
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   798
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   799
        args = self.parseVmArgs(args, addDefaultArgs=addDefaultArgs)
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   800
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   801
        jvmciModeArgs = _jvmciModes[_vm.jvmciMode]
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   802
        cmd = [self.java] + ['-' + vm] + jvmciModeArgs + args
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   803
        return mx.run(cmd, nonZeroIsFatal=nonZeroIsFatal, out=out, err=err, cwd=cwd)
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   804
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   805
"""
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   806
The dict of JVMCI JDKs indexed by debug-level names.
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   807
"""
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   808
_jvmci_jdks = {}
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   809
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   810
def get_jvmci_jdk(debugLevel=None):
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   811
    """
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   812
    Gets the JVMCI JDK corresponding to 'debugLevel'.
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   813
    """
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   814
    if not debugLevel:
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   815
        debugLevel = _vm.debugLevel
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   816
    jdk = _jvmci_jdks.get(debugLevel)
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   817
    if jdk is None:
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   818
        try:
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   819
            jdk = JVMCI9JDKConfig(debugLevel)
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   820
        except mx.JDKConfigException as e:
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   821
            jdkBuildDir = _get_jdk_build_dir(debugLevel)
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   822
            msg = 'Error with the JDK built into {}:\n{}\nTry (re)building it with: mx --jdk-debug-level={} make'
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   823
            if mx.get_opts().use_jdk_image:
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   824
                msg += ' images'
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   825
            mx.abort(msg.format(jdkBuildDir, e.message, debugLevel))
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   826
        _jvmci_jdks[debugLevel] = jdk
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   827
    return jdk
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   828
35598
8d7bc466f490 8147470: update JVMCI mx extensions
dnsimon
parents: 35564
diff changeset
   829
class JVMCI9JDKFactory(mx.JDKFactory):
34505
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   830
    def getJDKConfig(self):
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   831
        jdk = get_jvmci_jdk(_vm.debugLevel)
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   832
        return jdk
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   833
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   834
    def description(self):
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   835
        return "JVMCI JDK"
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   836
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   837
mx.update_commands(_suite, {
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   838
    'make': [_runmake, '[args...]', _makehelp],
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   839
    'multimake': [_runmultimake, '[options]'],
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   840
    'c1visualizer' : [c1visualizer, ''],
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   841
    'hsdis': [hsdis, '[att]'],
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   842
    'hcfdis': [hcfdis, ''],
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   843
    'igv' : [igv, ''],
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   844
    'jol' : [jol, ''],
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   845
    'vm': [run_vm, '[-options] class [args...]'],
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   846
})
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   847
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   848
mx.add_argument('-M', '--jvmci-mode', action='store', choices=sorted(_jvmciModes.viewkeys()), help='the JVM variant type to build/run (default: ' + _vm.jvmciMode + ')')
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   849
mx.add_argument('--jdk-jvm-variant', '--vm', action='store', choices=_jdkJvmVariants + sorted(_legacyVms.viewkeys()), help='the JVM variant type to build/run (default: ' + _vm.jvmVariant + ')')
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   850
mx.add_argument('--jdk-debug-level', '--vmbuild', action='store', choices=_jdkDebugLevels + sorted(_legacyVmbuilds.viewkeys()), help='the JDK debug level to build/run (default: ' + _vm.debugLevel + ')')
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   851
mx.add_argument('-I', '--use-jdk-image', action='store_true', help='build/run JDK image instead of exploded JDK')
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   852
35598
8d7bc466f490 8147470: update JVMCI mx extensions
dnsimon
parents: 35564
diff changeset
   853
mx.addJDKFactory(_JVMCI_JDK_TAG, mx.JavaCompliance('9'), JVMCI9JDKFactory())
8d7bc466f490 8147470: update JVMCI mx extensions
dnsimon
parents: 35564
diff changeset
   854
34505
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   855
def mx_post_parse_cmd_line(opts):
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   856
    mx.set_java_command_default_jdk_tag(_JVMCI_JDK_TAG)
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   857
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   858
    jdkTag = mx.get_jdk_option().tag
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   859
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   860
    jvmVariant = None
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   861
    debugLevel = None
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   862
    jvmciMode = None
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   863
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   864
    if opts.jdk_jvm_variant is not None:
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   865
        jvmVariant = opts.jdk_jvm_variant
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   866
        if jdkTag and jdkTag != _JVMCI_JDK_TAG:
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   867
            mx.warn('Ignoring "--jdk-jvm-variant" option as "--jdk" tag is not "' + _JVMCI_JDK_TAG + '"')
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   868
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   869
    if opts.jdk_debug_level is not None:
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   870
        debugLevel = _translateLegacyDebugLevel(opts.jdk_debug_level)
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   871
        if jdkTag and jdkTag != _JVMCI_JDK_TAG:
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   872
            mx.warn('Ignoring "--jdk-debug-level" option as "--jdk" tag is not "' + _JVMCI_JDK_TAG + '"')
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   873
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   874
    if opts.jvmci_mode is not None:
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   875
        jvmciMode = opts.jvmci_mode
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   876
        if jdkTag and jdkTag != _JVMCI_JDK_TAG:
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   877
            mx.warn('Ignoring "--jvmci-mode" option as "--jdk" tag is not "' + _JVMCI_JDK_TAG + '"')
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   878
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   879
    _vm.update(jvmVariant, debugLevel, jvmciMode)
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   880
90f4fd15d739 8139921: add mx configuration files to support HotSpot IDE configuration generation
twisti
parents:
diff changeset
   881
    for jdkDist in jdkDeployedDists:
35564
3485bf43b924 8146364: Remove @ServiceProvider mechanism from JVMCI
dnsimon
parents: 35160
diff changeset
   882
        jdkDist.post_parse_cmd_line()
35598
8d7bc466f490 8147470: update JVMCI mx extensions
dnsimon
parents: 35564
diff changeset
   883
8d7bc466f490 8147470: update JVMCI mx extensions
dnsimon
parents: 35564
diff changeset
   884
def _update_JDK9_STUBS_library():
8d7bc466f490 8147470: update JVMCI mx extensions
dnsimon
parents: 35564
diff changeset
   885
    """
8d7bc466f490 8147470: update JVMCI mx extensions
dnsimon
parents: 35564
diff changeset
   886
    Sets the "path" and "sha1" attributes of the "JDK9_STUBS" library.
8d7bc466f490 8147470: update JVMCI mx extensions
dnsimon
parents: 35564
diff changeset
   887
    """
8d7bc466f490 8147470: update JVMCI mx extensions
dnsimon
parents: 35564
diff changeset
   888
    jdk9InternalLib = _suite.suiteDict['libraries']['JDK9_STUBS']
8d7bc466f490 8147470: update JVMCI mx extensions
dnsimon
parents: 35564
diff changeset
   889
    jarInputDir = join(_suite.get_output_root(), 'jdk9-stubs')
8d7bc466f490 8147470: update JVMCI mx extensions
dnsimon
parents: 35564
diff changeset
   890
    jarPath = join(_suite.get_output_root(), 'jdk9-stubs.jar')
8d7bc466f490 8147470: update JVMCI mx extensions
dnsimon
parents: 35564
diff changeset
   891
8d7bc466f490 8147470: update JVMCI mx extensions
dnsimon
parents: 35564
diff changeset
   892
    stubs = [
8d7bc466f490 8147470: update JVMCI mx extensions
dnsimon
parents: 35564
diff changeset
   893
        ('jdk.internal.misc', 'VM', """package jdk.internal.misc;
8d7bc466f490 8147470: update JVMCI mx extensions
dnsimon
parents: 35564
diff changeset
   894
public class VM {
8d7bc466f490 8147470: update JVMCI mx extensions
dnsimon
parents: 35564
diff changeset
   895
    public static String getSavedProperty(String key) {
8d7bc466f490 8147470: update JVMCI mx extensions
dnsimon
parents: 35564
diff changeset
   896
        throw new InternalError("should not reach here");
8d7bc466f490 8147470: update JVMCI mx extensions
dnsimon
parents: 35564
diff changeset
   897
    }
8d7bc466f490 8147470: update JVMCI mx extensions
dnsimon
parents: 35564
diff changeset
   898
}
8d7bc466f490 8147470: update JVMCI mx extensions
dnsimon
parents: 35564
diff changeset
   899
""")
8d7bc466f490 8147470: update JVMCI mx extensions
dnsimon
parents: 35564
diff changeset
   900
    ]
8d7bc466f490 8147470: update JVMCI mx extensions
dnsimon
parents: 35564
diff changeset
   901
8d7bc466f490 8147470: update JVMCI mx extensions
dnsimon
parents: 35564
diff changeset
   902
    if not exists(jarPath):
8d7bc466f490 8147470: update JVMCI mx extensions
dnsimon
parents: 35564
diff changeset
   903
        sourceFiles = []
8d7bc466f490 8147470: update JVMCI mx extensions
dnsimon
parents: 35564
diff changeset
   904
        for (package, className, source) in stubs:
8d7bc466f490 8147470: update JVMCI mx extensions
dnsimon
parents: 35564
diff changeset
   905
            sourceFile = join(jarInputDir, package.replace('.', os.sep), className + '.java')
8d7bc466f490 8147470: update JVMCI mx extensions
dnsimon
parents: 35564
diff changeset
   906
            mx.ensure_dir_exists(os.path.dirname(sourceFile))
8d7bc466f490 8147470: update JVMCI mx extensions
dnsimon
parents: 35564
diff changeset
   907
            with open(sourceFile, 'w') as fp:
8d7bc466f490 8147470: update JVMCI mx extensions
dnsimon
parents: 35564
diff changeset
   908
                fp.write(source)
8d7bc466f490 8147470: update JVMCI mx extensions
dnsimon
parents: 35564
diff changeset
   909
            sourceFiles.append(sourceFile)
8d7bc466f490 8147470: update JVMCI mx extensions
dnsimon
parents: 35564
diff changeset
   910
        jdk = mx.get_jdk(tag='default')
8d7bc466f490 8147470: update JVMCI mx extensions
dnsimon
parents: 35564
diff changeset
   911
        mx.run([jdk.javac, '-d', jarInputDir] + sourceFiles)
8d7bc466f490 8147470: update JVMCI mx extensions
dnsimon
parents: 35564
diff changeset
   912
        mx.run([jdk.jar, 'cf', jarPath, '.'], cwd=jarInputDir)
8d7bc466f490 8147470: update JVMCI mx extensions
dnsimon
parents: 35564
diff changeset
   913
8d7bc466f490 8147470: update JVMCI mx extensions
dnsimon
parents: 35564
diff changeset
   914
    jdk9InternalLib['path'] = jarPath
8d7bc466f490 8147470: update JVMCI mx extensions
dnsimon
parents: 35564
diff changeset
   915
    jdk9InternalLib['sha1'] = mx.sha1OfFile(jarPath)
8d7bc466f490 8147470: update JVMCI mx extensions
dnsimon
parents: 35564
diff changeset
   916
8d7bc466f490 8147470: update JVMCI mx extensions
dnsimon
parents: 35564
diff changeset
   917
_update_JDK9_STUBS_library()