--- a/src/hotspot/share/runtime/javaCalls.cpp Wed May 16 10:27:25 2018 -0700
+++ b/src/hotspot/share/runtime/javaCalls.cpp Tue May 15 14:49:10 2018 -0700
@@ -199,13 +199,13 @@
void JavaCalls::call_virtual(JavaValue* result, Handle receiver, Klass* spec_klass, Symbol* name, Symbol* signature, TRAPS) {
- JavaCallArguments args(receiver); // One oop argument
+ JavaCallArguments args(receiver);
call_virtual(result, spec_klass, name, signature, &args, CHECK);
}
void JavaCalls::call_virtual(JavaValue* result, Handle receiver, Klass* spec_klass, Symbol* name, Symbol* signature, Handle arg1, TRAPS) {
- JavaCallArguments args(receiver); // One oop argument
+ JavaCallArguments args(receiver);
args.push_oop(arg1);
call_virtual(result, spec_klass, name, signature, &args, CHECK);
}
@@ -213,7 +213,7 @@
void JavaCalls::call_virtual(JavaValue* result, Handle receiver, Klass* spec_klass, Symbol* name, Symbol* signature, Handle arg1, Handle arg2, TRAPS) {
- JavaCallArguments args(receiver); // One oop argument
+ JavaCallArguments args(receiver);
args.push_oop(arg1);
args.push_oop(arg2);
call_virtual(result, spec_klass, name, signature, &args, CHECK);
@@ -235,20 +235,20 @@
void JavaCalls::call_special(JavaValue* result, Handle receiver, Klass* klass, Symbol* name, Symbol* signature, TRAPS) {
- JavaCallArguments args(receiver); // One oop argument
+ JavaCallArguments args(receiver);
call_special(result, klass, name, signature, &args, CHECK);
}
void JavaCalls::call_special(JavaValue* result, Handle receiver, Klass* klass, Symbol* name, Symbol* signature, Handle arg1, TRAPS) {
- JavaCallArguments args(receiver); // One oop argument
+ JavaCallArguments args(receiver);
args.push_oop(arg1);
call_special(result, klass, name, signature, &args, CHECK);
}
void JavaCalls::call_special(JavaValue* result, Handle receiver, Klass* klass, Symbol* name, Symbol* signature, Handle arg1, Handle arg2, TRAPS) {
- JavaCallArguments args(receiver); // One oop argument
+ JavaCallArguments args(receiver);
args.push_oop(arg1);
args.push_oop(arg2);
call_special(result, klass, name, signature, &args, CHECK);
@@ -270,19 +270,19 @@
void JavaCalls::call_static(JavaValue* result, Klass* klass, Symbol* name, Symbol* signature, TRAPS) {
- JavaCallArguments args; // No argument
+ JavaCallArguments args;
call_static(result, klass, name, signature, &args, CHECK);
}
void JavaCalls::call_static(JavaValue* result, Klass* klass, Symbol* name, Symbol* signature, Handle arg1, TRAPS) {
- JavaCallArguments args(arg1); // One oop argument
+ JavaCallArguments args(arg1);
call_static(result, klass, name, signature, &args, CHECK);
}
void JavaCalls::call_static(JavaValue* result, Klass* klass, Symbol* name, Symbol* signature, Handle arg1, Handle arg2, TRAPS) {
- JavaCallArguments args; // One oop argument
+ JavaCallArguments args;
args.push_oop(arg1);
args.push_oop(arg2);
call_static(result, klass, name, signature, &args, CHECK);
@@ -290,13 +290,44 @@
void JavaCalls::call_static(JavaValue* result, Klass* klass, Symbol* name, Symbol* signature, Handle arg1, Handle arg2, Handle arg3, TRAPS) {
- JavaCallArguments args; // One oop argument
+ JavaCallArguments args;
args.push_oop(arg1);
args.push_oop(arg2);
args.push_oop(arg3);
call_static(result, klass, name, signature, &args, CHECK);
}
+// ============ allocate and initialize new object instance ============
+
+Handle JavaCalls::construct_new_instance(InstanceKlass* klass, Symbol* constructor_signature, JavaCallArguments* args, TRAPS) {
+ klass->initialize(CHECK_NH); // Quick no-op if already initialized.
+ Handle obj = klass->allocate_instance_handle(CHECK_NH);
+ JavaValue void_result(T_VOID);
+ args->set_receiver(obj); // inserts <obj> as the first argument.
+ JavaCalls::call_special(&void_result, klass,
+ vmSymbols::object_initializer_name(),
+ constructor_signature, args, CHECK_NH);
+ return obj;
+}
+
+Handle JavaCalls::construct_new_instance(InstanceKlass* klass, Symbol* constructor_signature, TRAPS) {
+ JavaCallArguments args;
+ return JavaCalls::construct_new_instance(klass, constructor_signature, &args, CHECK_NH);
+}
+
+Handle JavaCalls::construct_new_instance(InstanceKlass* klass, Symbol* constructor_signature, Handle arg1, TRAPS) {
+ JavaCallArguments args;
+ args.push_oop(arg1);
+ return JavaCalls::construct_new_instance(klass, constructor_signature, &args, CHECK_NH);
+}
+
+Handle JavaCalls::construct_new_instance(InstanceKlass* klass, Symbol* constructor_signature, Handle arg1, Handle arg2, TRAPS) {
+ JavaCallArguments args;
+ args.push_oop(arg1);
+ args.push_oop(arg2);
+ return JavaCalls::construct_new_instance(klass, constructor_signature, &args, CHECK_NH);
+}
+
// -------------------------------------------------
// Implementation of JavaCalls (low level)