aoqi@1: /* aoqi@1: * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved. aoqi@1: * Copyright (c) 2015, 2016, Loongson Technology. All rights reserved. aoqi@1: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. aoqi@1: * aoqi@1: * This code is free software; you can redistribute it and/or modify it aoqi@1: * under the terms of the GNU General Public License version 2 only, as aoqi@1: * published by the Free Software Foundation. aoqi@1: * aoqi@1: * This code is distributed in the hope that it will be useful, but WITHOUT aoqi@1: * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or aoqi@1: * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License aoqi@1: * version 2 for more details (a copy is included in the LICENSE file that aoqi@1: * accompanied this code). aoqi@1: * aoqi@1: * You should have received a copy of the GNU General Public License version aoqi@1: * 2 along with this work; if not, write to the Free Software Foundation, aoqi@1: * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. aoqi@1: * aoqi@1: * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA aoqi@1: * or visit www.oracle.com if you need additional information or have any aoqi@1: * questions. aoqi@1: * aoqi@1: */ aoqi@1: aoqi@1: #include "precompiled.hpp" aoqi@1: #include "asm/macroAssembler.hpp" aoqi@1: #include "asm/macroAssembler.inline.hpp" aoqi@1: #include "memory/resourceArea.hpp" aoqi@1: #include "runtime/java.hpp" aoqi@1: #include "runtime/stubCodeGenerator.hpp" aoqi@1: #include "vm_version_mips.hpp" aoqi@1: #ifdef TARGET_OS_FAMILY_linux aoqi@1: # include "os_linux.inline.hpp" aoqi@1: #endif aoqi@1: #ifdef TARGET_OS_FAMILY_solaris aoqi@1: # include "os_solaris.inline.hpp" aoqi@1: #endif aoqi@1: #ifdef TARGET_OS_FAMILY_windows aoqi@1: # include "os_windows.inline.hpp" aoqi@1: #endif aoqi@1: #ifdef TARGET_OS_FAMILY_bsd aoqi@1: # include "os_bsd.inline.hpp" aoqi@1: #endif aoqi@1: /* aoqi@1: int VM_Version::_cpu; aoqi@1: int VM_Version::_model; aoqi@1: int VM_Version::_stepping; aoqi@1: int VM_Version::_cpuFeatures; aoqi@1: const char* VM_Version::_features_str = ""; aoqi@1: VM_Version::CpuidInfo VM_Version::_cpuid_info = { 0, }; aoqi@1: aoqi@1: static BufferBlob* stub_blob; aoqi@1: static const int stub_size = 300; aoqi@1: aoqi@1: extern "C" { aoqi@1: typedef void (*getPsrInfo_stub_t)(void*); aoqi@1: } aoqi@1: static getPsrInfo_stub_t getPsrInfo_stub = NULL; aoqi@1: */ aoqi@1: int VM_Version::_features = VM_Version::unknown_m; aoqi@1: const char* VM_Version::_features_str = ""; aoqi@1: /* aoqi@1: class VM_Version_StubGenerator: public StubCodeGenerator { aoqi@1: public: aoqi@1: aoqi@1: VM_Version_StubGenerator(CodeBuffer *c) : StubCodeGenerator(c) {} aoqi@1: aoqi@1: address generate_getPsrInfo() { aoqi@1: }; aoqi@1: }; aoqi@1: aoqi@1: aoqi@1: void VM_Version::get_processor_features() { aoqi@1: } aoqi@1: */ aoqi@1: void VM_Version::initialize() { chenhaoxuan@358: fujie@254: _features = determine_features(); fujie@254: //no need, Abstract_VM_Version already define it as false fujie@254: _supports_cx8 = true; chenhaoxuan@358: chenhaoxuan@358: //////////////////////add some other feature here////////////////// aoqi@203: #ifdef COMPILER2 aoqi@209: if (MaxVectorSize > 0) { aoqi@209: if (!is_power_of_2(MaxVectorSize)) { aoqi@209: warning("MaxVectorSize must be a power of 2"); aoqi@209: MaxVectorSize = 8; aoqi@209: } aoqi@209: if (MaxVectorSize > 0 && supports_ps()) { aoqi@209: MaxVectorSize = 8; aoqi@209: } aoqi@209: } chenhaoxuan@358: chenhaoxuan@358: if (is_gs464e()) { chenhaoxuan@358: if (FLAG_IS_DEFAULT(UseCountTrailingZerosInstruction)) { chenhaoxuan@358: FLAG_SET_DEFAULT(UseCountTrailingZerosInstruction, 1); chenhaoxuan@358: } chenhaoxuan@358: } else if (UseCountTrailingZerosInstruction) { chenhaoxuan@358: if (!FLAG_IS_DEFAULT(UseCountTrailingZerosInstruction)) chenhaoxuan@358: warning("Only 3A2000/3000 CPUs support UseCountTrailingZerosInstruction"); chenhaoxuan@358: FLAG_SET_DEFAULT(UseCountTrailingZerosInstruction, 0); chenhaoxuan@358: } aoqi@203: #endif aoqi@209: UseSSE = 0; // Only on x86 and x64 fujie@254: chenhaoxuan@358: if (is_loongson()) { chenhaoxuan@358: if (FLAG_IS_DEFAULT(UseLoongsonISA)) { chenhaoxuan@358: FLAG_SET_DEFAULT(UseLoongsonISA, 1); chenhaoxuan@358: } chenhaoxuan@358: } else if (UseLoongsonISA) { chenhaoxuan@358: if (!FLAG_IS_DEFAULT(UseLoongsonISA)) chenhaoxuan@358: warning("Only Loongson CPUs support LoongISA"); chenhaoxuan@358: FLAG_SET_DEFAULT(UseLoongsonISA, 0); chenhaoxuan@358: } chenhaoxuan@358: chenhaoxuan@358: if (is_gs464e()) { chenhaoxuan@358: if (FLAG_IS_DEFAULT(Use3A2000)) { chenhaoxuan@358: FLAG_SET_DEFAULT(Use3A2000, 1); chenhaoxuan@358: } chenhaoxuan@358: } else if (Use3A2000) { chenhaoxuan@358: if (!FLAG_IS_DEFAULT(Use3A2000)) chenhaoxuan@358: warning("Only 3A2000/3000 CPUs support this option"); chenhaoxuan@358: FLAG_SET_DEFAULT(Use3A2000, 0); chenhaoxuan@358: } chenhaoxuan@358: chenhaoxuan@358: char buf[256]; chenhaoxuan@358: jio_snprintf(buf, sizeof(buf), "%s%s%s%s%s%s%s%s%s", chenhaoxuan@358: (has_l2_cache() ? ", has_l2_cache" : ""), chenhaoxuan@358: (has_16k_page() ? ", has_16k_page" : ""), chenhaoxuan@358: (is_loongson() ? ", on_loongson" : ""), chenhaoxuan@358: (is_gs464() ? ", 3A1000" : ""), chenhaoxuan@358: (is_gs464v() ? ", 3B1500" : "" ), chenhaoxuan@358: (is_gs464e() ? ", 3A2000/3A3000" : ""), chenhaoxuan@358: (UseLoongsonISA ? ", UseLoongsonISA" : ""), chenhaoxuan@358: (UseCountTrailingZerosInstruction ? ", UseCountTrailingZerosInstruction" : ""), chenhaoxuan@358: (Use3A2000 ? ", Use3A2000" : "")); chenhaoxuan@358: chenhaoxuan@358: // buf is started with ", " or is empty chenhaoxuan@358: _features_str = strdup(strlen(buf) > 2 ? buf + 2 : buf); chenhaoxuan@358: fujie@254: if (FLAG_IS_DEFAULT(AllocatePrefetchStyle)) { fujie@254: FLAG_SET_DEFAULT(AllocatePrefetchStyle, 1); fujie@254: } fujie@254: fujie@254: if (FLAG_IS_DEFAULT(AllocatePrefetchLines)) { fujie@254: FLAG_SET_DEFAULT(AllocatePrefetchLines, 1); fujie@254: } fujie@254: fujie@254: if (FLAG_IS_DEFAULT(AllocatePrefetchStepSize)) { fujie@254: FLAG_SET_DEFAULT(AllocatePrefetchStepSize, 64); fujie@254: } chenhaoxuan@358: fujie@254: if (FLAG_IS_DEFAULT(AllocatePrefetchDistance)) { fujie@254: FLAG_SET_DEFAULT(AllocatePrefetchDistance, 64); fujie@254: } fujie@254: fujie@254: if (FLAG_IS_DEFAULT(AllocateInstancePrefetchLines)) { fujie@254: FLAG_SET_DEFAULT(AllocateInstancePrefetchLines, 1); fujie@254: } fujie@254: fujie@254: NOT_PRODUCT( if (PrintMiscellaneous && Verbose) print_features(); ); aoqi@1: } aoqi@1: aoqi@1: void VM_Version::print_features() { chenhaoxuan@358: tty->print_cr("Version:%s", cpu_features()); aoqi@1: } aoqi@1: aoqi@1: int VM_Version::determine_features() { chenhaoxuan@358: //////////////////////add some other feature here////////////////// chenhaoxuan@358: int features = platform_features(unknown_m); chenhaoxuan@358: //spt_16k_page_m; chenhaoxuan@358: return features; aoqi@1: } aoqi@1: aoqi@1: static int saved_features = 0; aoqi@1: aoqi@1: void VM_Version::allow_all() { chenhaoxuan@358: saved_features = _features; chenhaoxuan@358: _features = all_features_m; aoqi@1: } aoqi@1: aoqi@1: void VM_Version::revert() { chenhaoxuan@358: _features = saved_features; aoqi@1: }