mirror of
https://github.com/openjdk/jdk.git
synced 2025-09-18 10:04:42 +02:00
8247755: Leaner and more versatile GrowableArray classes
Reviewed-by: kbarrett, coleenp
This commit is contained in:
parent
9d6aa42a7c
commit
ef3b0ec567
13 changed files with 1124 additions and 353 deletions
|
@ -3307,7 +3307,7 @@ class ScopedVMInitArgs : public StackObj {
|
|||
// allocated memory is deleted by the destructor. If this method
|
||||
// returns anything other than JNI_OK, then this object is in a
|
||||
// partially constructed state, and should be abandoned.
|
||||
jint set_args(GrowableArray<JavaVMOption>* options) {
|
||||
jint set_args(const GrowableArrayView<JavaVMOption>* options) {
|
||||
_is_set = true;
|
||||
JavaVMOption* options_arr = NEW_C_HEAP_ARRAY_RETURN_NULL(
|
||||
JavaVMOption, options->length(), mtArguments);
|
||||
|
@ -3365,23 +3365,21 @@ class ScopedVMInitArgs : public StackObj {
|
|||
assert(vm_options_file_pos != -1, "vm_options_file_pos should be set");
|
||||
|
||||
int length = args->nOptions + args_to_insert->nOptions - 1;
|
||||
GrowableArray<JavaVMOption> *options = new (ResourceObj::C_HEAP, mtArguments)
|
||||
GrowableArray<JavaVMOption>(length, mtArguments); // Construct new option array
|
||||
// Construct new option array
|
||||
GrowableArrayCHeap<JavaVMOption, mtArguments> options(length);
|
||||
for (int i = 0; i < args->nOptions; i++) {
|
||||
if (i == vm_options_file_pos) {
|
||||
// insert the new options starting at the same place as the
|
||||
// -XX:VMOptionsFile option
|
||||
for (int j = 0; j < args_to_insert->nOptions; j++) {
|
||||
options->push(args_to_insert->options[j]);
|
||||
options.push(args_to_insert->options[j]);
|
||||
}
|
||||
} else {
|
||||
options->push(args->options[i]);
|
||||
options.push(args->options[i]);
|
||||
}
|
||||
}
|
||||
// make into options array
|
||||
jint result = set_args(options);
|
||||
delete options;
|
||||
return result;
|
||||
return set_args(&options);
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -3478,7 +3476,8 @@ jint Arguments::parse_vm_options_file(const char* file_name, ScopedVMInitArgs* v
|
|||
}
|
||||
|
||||
jint Arguments::parse_options_buffer(const char* name, char* buffer, const size_t buf_len, ScopedVMInitArgs* vm_args) {
|
||||
GrowableArray<JavaVMOption> *options = new (ResourceObj::C_HEAP, mtArguments) GrowableArray<JavaVMOption>(2, mtArguments); // Construct option array
|
||||
// Construct option array
|
||||
GrowableArrayCHeap<JavaVMOption, mtArguments> options(2);
|
||||
|
||||
// some pointers to help with parsing
|
||||
char *buffer_end = buffer + buf_len;
|
||||
|
@ -3518,7 +3517,6 @@ jint Arguments::parse_options_buffer(const char* name, char* buffer, const size_
|
|||
// did not see closing quote
|
||||
jio_fprintf(defaultStream::error_stream(),
|
||||
"Unmatched quote in %s\n", name);
|
||||
delete options;
|
||||
return JNI_ERR;
|
||||
}
|
||||
} else {
|
||||
|
@ -3534,16 +3532,13 @@ jint Arguments::parse_options_buffer(const char* name, char* buffer, const size_
|
|||
option.optionString = opt_hd;
|
||||
option.extraInfo = NULL;
|
||||
|
||||
options->append(option); // Fill in option
|
||||
options.append(option); // Fill in option
|
||||
|
||||
rd++; // Advance to next character
|
||||
}
|
||||
|
||||
// Fill out JavaVMInitArgs structure.
|
||||
jint status = vm_args->set_args(options);
|
||||
|
||||
delete options;
|
||||
return status;
|
||||
return vm_args->set_args(&options);
|
||||
}
|
||||
|
||||
jint Arguments::set_shared_spaces_flags_and_archive_paths() {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue