diff --git a/src/hotspot/share/classfile/modules.cpp b/src/hotspot/share/classfile/modules.cpp index 74a9e01eec974..b890d51d3b725 100644 --- a/src/hotspot/share/classfile/modules.cpp +++ b/src/hotspot/share/classfile/modules.cpp @@ -453,7 +453,7 @@ void Modules::define_module(Handle module, jboolean is_open, jstring version, ClassLoader::add_to_exploded_build_list(THREAD, module_symbol); } -#ifdef COMPILER2 +#if COMPILER2_OR_JVMCI // Special handling of jdk.incubator.vector if (strcmp(module_name, "jdk.incubator.vector") == 0) { if (FLAG_IS_DEFAULT(EnableVectorSupport)) { @@ -473,7 +473,7 @@ void Modules::define_module(Handle module, jboolean is_open, jstring version, log_info(compilation)("EnableVectorAggressiveReboxing=%s", (EnableVectorAggressiveReboxing ? "true" : "false")); log_info(compilation)("UseVectorStubs=%s", (UseVectorStubs ? "true" : "false")); } -#endif // COMPILER2 +#endif // COMPILER2_OR_JVMCI } #if INCLUDE_CDS_JAVA_HEAP diff --git a/src/hotspot/share/jvmci/jvmciCodeInstaller.cpp b/src/hotspot/share/jvmci/jvmciCodeInstaller.cpp index dd8badcecdc93..bea118c94299f 100644 --- a/src/hotspot/share/jvmci/jvmciCodeInstaller.cpp +++ b/src/hotspot/share/jvmci/jvmciCodeInstaller.cpp @@ -396,7 +396,8 @@ ScopeValue* CodeInstaller::get_scope_value(HotSpotCompiledCodeStream* stream, u1 } case REGISTER_PRIMITIVE: case REGISTER_NARROW_OOP: - case REGISTER_OOP: { + case REGISTER_OOP: + case REGISTER_VECTOR: { u2 number = stream->read_u2("register"); VMReg hotspotRegister = get_hotspot_reg(number, JVMCI_CHECK_NULL); if (is_general_purpose_reg(hotspotRegister)) { @@ -422,6 +423,8 @@ ScopeValue* CodeInstaller::get_scope_value(HotSpotCompiledCodeStream* stream, u1 locationType = Location::normal; } else if (type == T_DOUBLE) { locationType = Location::dbl; + } else if (type == T_OBJECT && tag == REGISTER_VECTOR) { + locationType = Location::vector; } else { JVMCI_ERROR_NULL("unexpected type %s in floating point register%s", basictype_to_str(type), stream->context()); } @@ -434,14 +437,15 @@ ScopeValue* CodeInstaller::get_scope_value(HotSpotCompiledCodeStream* stream, u1 } case STACK_SLOT_PRIMITIVE: case STACK_SLOT_NARROW_OOP: - case STACK_SLOT_OOP: { + case STACK_SLOT_OOP: + case STACK_SLOT_VECTOR: { jint offset = (jshort) stream->read_s2("offset"); if (stream->read_bool("addRawFrameSize")) { offset += _total_frame_size; } Location::Type locationType; if (type == T_OBJECT) { - locationType = tag == STACK_SLOT_NARROW_OOP ? Location::narrowoop : Location::oop; + locationType = tag == STACK_SLOT_VECTOR ? Location::vector : tag == STACK_SLOT_NARROW_OOP ? Location::narrowoop : Location::oop; } else if (type == T_LONG) { locationType = Location::lng; } else if (type == T_DOUBLE) { diff --git a/src/hotspot/share/jvmci/jvmciCodeInstaller.hpp b/src/hotspot/share/jvmci/jvmciCodeInstaller.hpp index b0186a3a8de1b..74244b59bb3d6 100644 --- a/src/hotspot/share/jvmci/jvmciCodeInstaller.hpp +++ b/src/hotspot/share/jvmci/jvmciCodeInstaller.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 2023, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -185,9 +185,11 @@ class CodeInstaller : public StackObj { REGISTER_PRIMITIVE, REGISTER_OOP, REGISTER_NARROW_OOP, + REGISTER_VECTOR, STACK_SLOT_PRIMITIVE, STACK_SLOT_OOP, STACK_SLOT_NARROW_OOP, + STACK_SLOT_VECTOR, VIRTUAL_OBJECT_ID, VIRTUAL_OBJECT_ID2, NULL_CONSTANT, diff --git a/src/hotspot/share/jvmci/vmStructs_jvmci.cpp b/src/hotspot/share/jvmci/vmStructs_jvmci.cpp index a4195a04f1866..312eee25b5a6a 100644 --- a/src/hotspot/share/jvmci/vmStructs_jvmci.cpp +++ b/src/hotspot/share/jvmci/vmStructs_jvmci.cpp @@ -530,9 +530,11 @@ declare_constant(CodeInstaller::REGISTER_PRIMITIVE) \ declare_constant(CodeInstaller::REGISTER_OOP) \ declare_constant(CodeInstaller::REGISTER_NARROW_OOP) \ + declare_constant(CodeInstaller::REGISTER_VECTOR) \ declare_constant(CodeInstaller::STACK_SLOT_PRIMITIVE) \ declare_constant(CodeInstaller::STACK_SLOT_OOP) \ declare_constant(CodeInstaller::STACK_SLOT_NARROW_OOP) \ + declare_constant(CodeInstaller::STACK_SLOT_VECTOR) \ declare_constant(CodeInstaller::VIRTUAL_OBJECT_ID) \ declare_constant(CodeInstaller::VIRTUAL_OBJECT_ID2) \ declare_constant(CodeInstaller::NULL_CONSTANT) \ diff --git a/src/hotspot/share/runtime/arguments.cpp b/src/hotspot/share/runtime/arguments.cpp index bce581ab70da8..4d7975b3a5bf1 100644 --- a/src/hotspot/share/runtime/arguments.cpp +++ b/src/hotspot/share/runtime/arguments.cpp @@ -4041,7 +4041,7 @@ jint Arguments::apply_ergo() { JVMFlag::printSetFlags(tty); } -#ifdef COMPILER2 +#if COMPILER2_OR_JVMCI if (!FLAG_IS_DEFAULT(EnableVectorSupport) && !EnableVectorSupport) { if (!FLAG_IS_DEFAULT(EnableVectorReboxing) && EnableVectorReboxing) { warning("Disabling EnableVectorReboxing since EnableVectorSupport is turned off."); @@ -4062,7 +4062,7 @@ jint Arguments::apply_ergo() { } FLAG_SET_DEFAULT(UseVectorStubs, false); } -#endif // COMPILER2 +#endif // COMPILER2_OR_JVMCI if (FLAG_IS_CMDLINE(DiagnoseSyncOnValueBasedClasses)) { if (DiagnoseSyncOnValueBasedClasses == ObjectSynchronizer::LOG_WARNING && !log_is_enabled(Info, valuebasedclasses)) { diff --git a/src/hotspot/share/runtime/deoptimization.cpp b/src/hotspot/share/runtime/deoptimization.cpp index 39afc56d9b677..6cfbacce5e70c 100644 --- a/src/hotspot/share/runtime/deoptimization.cpp +++ b/src/hotspot/share/runtime/deoptimization.cpp @@ -1235,7 +1235,7 @@ bool Deoptimization::realloc_objects(JavaThread* thread, frame* fr, RegisterMap* InstanceKlass* ik = InstanceKlass::cast(k); if (obj == nullptr && !cache_init_error) { -#ifdef COMPILER2 +#if COMPILER2_OR_JVMCI if (EnableVectorSupport && VectorSupport::is_vector(ik)) { obj = VectorSupport::allocate_vector(ik, fr, reg_map, sv, THREAD); } else { @@ -1243,7 +1243,7 @@ bool Deoptimization::realloc_objects(JavaThread* thread, frame* fr, RegisterMap* } #else obj = ik->allocate_instance(THREAD); -#endif // COMPILER2 +#endif // COMPILER2_OR_JVMCI } } else if (k->is_typeArray_klass()) { TypeArrayKlass* ak = TypeArrayKlass::cast(k); @@ -1585,7 +1585,7 @@ void Deoptimization::reassign_fields(frame* fr, RegisterMap* reg_map, GrowableAr continue; } #endif // INCLUDE_JVMCI -#ifdef COMPILER2 +#if COMPILER2_OR_JVMCI if (EnableVectorSupport && VectorSupport::is_vector(k)) { assert(sv->field_size() == 1, "%s not a vector", k->name()->as_C_string()); ScopeValue* payload = sv->field_at(0); @@ -1605,7 +1605,7 @@ void Deoptimization::reassign_fields(frame* fr, RegisterMap* reg_map, GrowableAr // Else fall-through to do assignment for scalar-replaced boxed vector representation // which could be restored after vector object allocation. } -#endif /* !COMPILER2 */ +#endif /* !COMPILER2_OR_JVMCI */ if (k->is_instance_klass()) { InstanceKlass* ik = InstanceKlass::cast(k); reassign_fields_by_klass(ik, fr, reg_map, sv, 0, obj(), skip_internal); diff --git a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/HotSpotCompiledCodeStream.java b/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/HotSpotCompiledCodeStream.java index f8b0585098bc3..87c6ecde07b6e 100644 --- a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/HotSpotCompiledCodeStream.java +++ b/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/HotSpotCompiledCodeStream.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2022, 2023, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -48,6 +48,7 @@ import static jdk.vm.ci.hotspot.HotSpotCompiledCodeStream.Tag.REGISTER_NARROW_OOP; import static jdk.vm.ci.hotspot.HotSpotCompiledCodeStream.Tag.REGISTER_OOP; import static jdk.vm.ci.hotspot.HotSpotCompiledCodeStream.Tag.REGISTER_PRIMITIVE; +import static jdk.vm.ci.hotspot.HotSpotCompiledCodeStream.Tag.REGISTER_VECTOR; import static jdk.vm.ci.hotspot.HotSpotCompiledCodeStream.Tag.SITE_CALL; import static jdk.vm.ci.hotspot.HotSpotCompiledCodeStream.Tag.SITE_DATA_PATCH; import static jdk.vm.ci.hotspot.HotSpotCompiledCodeStream.Tag.SITE_EXCEPTION_HANDLER; @@ -61,6 +62,7 @@ import static jdk.vm.ci.hotspot.HotSpotCompiledCodeStream.Tag.STACK_SLOT_NARROW_OOP; import static jdk.vm.ci.hotspot.HotSpotCompiledCodeStream.Tag.STACK_SLOT_OOP; import static jdk.vm.ci.hotspot.HotSpotCompiledCodeStream.Tag.STACK_SLOT_PRIMITIVE; +import static jdk.vm.ci.hotspot.HotSpotCompiledCodeStream.Tag.STACK_SLOT_VECTOR; import static jdk.vm.ci.hotspot.HotSpotCompiledCodeStream.Tag.VIRTUAL_OBJECT_ID; import static jdk.vm.ci.hotspot.HotSpotCompiledCodeStream.Tag.VIRTUAL_OBJECT_ID2; @@ -171,9 +173,11 @@ enum Tag { REGISTER_PRIMITIVE, REGISTER_OOP, REGISTER_NARROW_OOP, + REGISTER_VECTOR, STACK_SLOT_PRIMITIVE, STACK_SLOT_OOP, STACK_SLOT_NARROW_OOP, + STACK_SLOT_VECTOR, VIRTUAL_OBJECT_ID, VIRTUAL_OBJECT_ID2, NULL_CONSTANT, @@ -1029,6 +1033,10 @@ private boolean isNarrowOop(Value oopValue) { return oopValue.getPlatformKind() != runtime.getHostJVMCIBackend().getTarget().arch.getWordKind(); } + private boolean isVector(Value value) { + return value.getPlatformKind().getVectorLength() > 1; + } + private void writeJavaValue(JavaValue value, JavaKind kind) { if (value == Value.ILLEGAL) { writeTag(ILLEGAL); @@ -1039,12 +1047,30 @@ private void writeJavaValue(JavaValue value, JavaKind kind) { writeTag(NULL_CONSTANT); } else if (value instanceof RegisterValue) { RegisterValue reg = (RegisterValue) value; - Tag tag = kind == JavaKind.Object ? (isNarrowOop(reg) ? REGISTER_NARROW_OOP : REGISTER_OOP) : REGISTER_PRIMITIVE; + Tag tag; + if (kind == JavaKind.Object) { + if (isVector(reg)) { + tag = REGISTER_VECTOR; + } else { + tag = isNarrowOop(reg) ? REGISTER_NARROW_OOP : REGISTER_OOP; + } + } else { + tag = REGISTER_PRIMITIVE; + } writeTag(tag); writeRegister(reg.getRegister()); } else if (value instanceof StackSlot) { StackSlot slot = (StackSlot) value; - Tag tag = kind == JavaKind.Object ? (isNarrowOop(slot) ? STACK_SLOT_NARROW_OOP : STACK_SLOT_OOP) : STACK_SLOT_PRIMITIVE; + Tag tag; + if (kind == JavaKind.Object) { + if (isVector(slot)) { + tag = STACK_SLOT_VECTOR; + } else { + tag = isNarrowOop(slot) ? STACK_SLOT_NARROW_OOP : STACK_SLOT_OOP; + } + } else { + tag = STACK_SLOT_PRIMITIVE; + } writeTag(tag); writeS2("offset", slot.getRawOffset()); writeBoolean("addRawFrameSize", slot.getRawAddFrameSize());