author | david |
Thu, 04 Jun 2015 14:29:34 +0200 | |
changeset 31236 | d4d3011aa98e |
parent 29068 | 683bef04fb20 |
child 31371 | 311143309e73 |
permissions | -rw-r--r-- |
28949
c6f50d62ecef
8067447: Factor out the shared implementation of the VM flags manipulation code
jbachorik
parents:
diff
changeset
|
1 |
/* |
c6f50d62ecef
8067447: Factor out the shared implementation of the VM flags manipulation code
jbachorik
parents:
diff
changeset
|
2 |
* Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. |
c6f50d62ecef
8067447: Factor out the shared implementation of the VM flags manipulation code
jbachorik
parents:
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
c6f50d62ecef
8067447: Factor out the shared implementation of the VM flags manipulation code
jbachorik
parents:
diff
changeset
|
4 |
* |
c6f50d62ecef
8067447: Factor out the shared implementation of the VM flags manipulation code
jbachorik
parents:
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
c6f50d62ecef
8067447: Factor out the shared implementation of the VM flags manipulation code
jbachorik
parents:
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
c6f50d62ecef
8067447: Factor out the shared implementation of the VM flags manipulation code
jbachorik
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation. |
c6f50d62ecef
8067447: Factor out the shared implementation of the VM flags manipulation code
jbachorik
parents:
diff
changeset
|
8 |
* |
c6f50d62ecef
8067447: Factor out the shared implementation of the VM flags manipulation code
jbachorik
parents:
diff
changeset
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
c6f50d62ecef
8067447: Factor out the shared implementation of the VM flags manipulation code
jbachorik
parents:
diff
changeset
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
c6f50d62ecef
8067447: Factor out the shared implementation of the VM flags manipulation code
jbachorik
parents:
diff
changeset
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
c6f50d62ecef
8067447: Factor out the shared implementation of the VM flags manipulation code
jbachorik
parents:
diff
changeset
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
c6f50d62ecef
8067447: Factor out the shared implementation of the VM flags manipulation code
jbachorik
parents:
diff
changeset
|
13 |
* accompanied this code). |
c6f50d62ecef
8067447: Factor out the shared implementation of the VM flags manipulation code
jbachorik
parents:
diff
changeset
|
14 |
* |
c6f50d62ecef
8067447: Factor out the shared implementation of the VM flags manipulation code
jbachorik
parents:
diff
changeset
|
15 |
* You should have received a copy of the GNU General Public License version |
c6f50d62ecef
8067447: Factor out the shared implementation of the VM flags manipulation code
jbachorik
parents:
diff
changeset
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
c6f50d62ecef
8067447: Factor out the shared implementation of the VM flags manipulation code
jbachorik
parents:
diff
changeset
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
c6f50d62ecef
8067447: Factor out the shared implementation of the VM flags manipulation code
jbachorik
parents:
diff
changeset
|
18 |
* |
c6f50d62ecef
8067447: Factor out the shared implementation of the VM flags manipulation code
jbachorik
parents:
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
c6f50d62ecef
8067447: Factor out the shared implementation of the VM flags manipulation code
jbachorik
parents:
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
c6f50d62ecef
8067447: Factor out the shared implementation of the VM flags manipulation code
jbachorik
parents:
diff
changeset
|
21 |
* questions. |
c6f50d62ecef
8067447: Factor out the shared implementation of the VM flags manipulation code
jbachorik
parents:
diff
changeset
|
22 |
* |
c6f50d62ecef
8067447: Factor out the shared implementation of the VM flags manipulation code
jbachorik
parents:
diff
changeset
|
23 |
*/ |
c6f50d62ecef
8067447: Factor out the shared implementation of the VM flags manipulation code
jbachorik
parents:
diff
changeset
|
24 |
|
c6f50d62ecef
8067447: Factor out the shared implementation of the VM flags manipulation code
jbachorik
parents:
diff
changeset
|
25 |
#include "precompiled.hpp" |
c6f50d62ecef
8067447: Factor out the shared implementation of the VM flags manipulation code
jbachorik
parents:
diff
changeset
|
26 |
#include "classfile/javaClasses.hpp" |
c6f50d62ecef
8067447: Factor out the shared implementation of the VM flags manipulation code
jbachorik
parents:
diff
changeset
|
27 |
#include "runtime/arguments.hpp" |
c6f50d62ecef
8067447: Factor out the shared implementation of the VM flags manipulation code
jbachorik
parents:
diff
changeset
|
28 |
#include "runtime/java.hpp" |
c6f50d62ecef
8067447: Factor out the shared implementation of the VM flags manipulation code
jbachorik
parents:
diff
changeset
|
29 |
#include "runtime/jniHandles.hpp" |
c6f50d62ecef
8067447: Factor out the shared implementation of the VM flags manipulation code
jbachorik
parents:
diff
changeset
|
30 |
#include "services/writeableFlags.hpp" |
c6f50d62ecef
8067447: Factor out the shared implementation of the VM flags manipulation code
jbachorik
parents:
diff
changeset
|
31 |
|
c6f50d62ecef
8067447: Factor out the shared implementation of the VM flags manipulation code
jbachorik
parents:
diff
changeset
|
32 |
// set a boolean global flag |
c6f50d62ecef
8067447: Factor out the shared implementation of the VM flags manipulation code
jbachorik
parents:
diff
changeset
|
33 |
int WriteableFlags::set_bool_flag(const char* name, const char* arg, Flag::Flags origin, FormatBuffer<80>& err_msg) { |
c6f50d62ecef
8067447: Factor out the shared implementation of the VM flags manipulation code
jbachorik
parents:
diff
changeset
|
34 |
int value = true; |
c6f50d62ecef
8067447: Factor out the shared implementation of the VM flags manipulation code
jbachorik
parents:
diff
changeset
|
35 |
|
c6f50d62ecef
8067447: Factor out the shared implementation of the VM flags manipulation code
jbachorik
parents:
diff
changeset
|
36 |
if (sscanf(arg, "%d", &value)) { |
c6f50d62ecef
8067447: Factor out the shared implementation of the VM flags manipulation code
jbachorik
parents:
diff
changeset
|
37 |
return set_bool_flag(name, value != 0, origin, err_msg); |
c6f50d62ecef
8067447: Factor out the shared implementation of the VM flags manipulation code
jbachorik
parents:
diff
changeset
|
38 |
} |
c6f50d62ecef
8067447: Factor out the shared implementation of the VM flags manipulation code
jbachorik
parents:
diff
changeset
|
39 |
err_msg.print("flag value must be a boolean (1 or 0)"); |
c6f50d62ecef
8067447: Factor out the shared implementation of the VM flags manipulation code
jbachorik
parents:
diff
changeset
|
40 |
return WRONG_FORMAT; |
c6f50d62ecef
8067447: Factor out the shared implementation of the VM flags manipulation code
jbachorik
parents:
diff
changeset
|
41 |
} |
c6f50d62ecef
8067447: Factor out the shared implementation of the VM flags manipulation code
jbachorik
parents:
diff
changeset
|
42 |
|
c6f50d62ecef
8067447: Factor out the shared implementation of the VM flags manipulation code
jbachorik
parents:
diff
changeset
|
43 |
int WriteableFlags::set_bool_flag(const char* name, bool value, Flag::Flags origin, FormatBuffer<80>& err_msg) { |
c6f50d62ecef
8067447: Factor out the shared implementation of the VM flags manipulation code
jbachorik
parents:
diff
changeset
|
44 |
return CommandLineFlags::boolAtPut((char*)name, &value, origin) ? SUCCESS : ERR_OTHER; |
c6f50d62ecef
8067447: Factor out the shared implementation of the VM flags manipulation code
jbachorik
parents:
diff
changeset
|
45 |
} |
c6f50d62ecef
8067447: Factor out the shared implementation of the VM flags manipulation code
jbachorik
parents:
diff
changeset
|
46 |
|
31236 | 47 |
// set a int global flag |
48 |
int WriteableFlags::set_int_flag(const char* name, const char* arg, Flag::Flags origin, FormatBuffer<80>& err_msg) { |
|
49 |
int value; |
|
50 |
||
51 |
if (sscanf(arg, "%d", &value)) { |
|
52 |
return set_int_flag(name, value, origin, err_msg); |
|
53 |
} |
|
54 |
err_msg.print("flag value must be an integer"); |
|
55 |
return WRONG_FORMAT; |
|
56 |
} |
|
57 |
||
58 |
int WriteableFlags::set_int_flag(const char* name, int value, Flag::Flags origin, FormatBuffer<80>& err_msg) { |
|
59 |
return CommandLineFlags::intAtPut((char*)name, &value, origin) ? SUCCESS : ERR_OTHER; |
|
60 |
} |
|
61 |
||
62 |
// set a uint global flag |
|
63 |
int WriteableFlags::set_uint_flag(const char* name, const char* arg, Flag::Flags origin, FormatBuffer<80>& err_msg) { |
|
64 |
uint value; |
|
65 |
||
66 |
if (sscanf(arg, "%u", &value)) { |
|
67 |
return set_uint_flag(name, value, origin, err_msg); |
|
68 |
} |
|
69 |
err_msg.print("flag value must be an unsigned integer"); |
|
70 |
return WRONG_FORMAT; |
|
71 |
} |
|
72 |
||
73 |
int WriteableFlags::set_uint_flag(const char* name, uint value, Flag::Flags origin, FormatBuffer<80>& err_msg) { |
|
74 |
return CommandLineFlags::uintAtPut((char*)name, &value, origin) ? SUCCESS : ERR_OTHER; |
|
75 |
} |
|
76 |
||
28949
c6f50d62ecef
8067447: Factor out the shared implementation of the VM flags manipulation code
jbachorik
parents:
diff
changeset
|
77 |
// set a intx global flag |
c6f50d62ecef
8067447: Factor out the shared implementation of the VM flags manipulation code
jbachorik
parents:
diff
changeset
|
78 |
int WriteableFlags::set_intx_flag(const char* name, const char* arg, Flag::Flags origin, FormatBuffer<80>& err_msg) { |
c6f50d62ecef
8067447: Factor out the shared implementation of the VM flags manipulation code
jbachorik
parents:
diff
changeset
|
79 |
intx value; |
c6f50d62ecef
8067447: Factor out the shared implementation of the VM flags manipulation code
jbachorik
parents:
diff
changeset
|
80 |
|
c6f50d62ecef
8067447: Factor out the shared implementation of the VM flags manipulation code
jbachorik
parents:
diff
changeset
|
81 |
if (sscanf(arg, INTX_FORMAT, &value)) { |
c6f50d62ecef
8067447: Factor out the shared implementation of the VM flags manipulation code
jbachorik
parents:
diff
changeset
|
82 |
return set_intx_flag(name, value, origin, err_msg); |
c6f50d62ecef
8067447: Factor out the shared implementation of the VM flags manipulation code
jbachorik
parents:
diff
changeset
|
83 |
} |
c6f50d62ecef
8067447: Factor out the shared implementation of the VM flags manipulation code
jbachorik
parents:
diff
changeset
|
84 |
err_msg.print("flag value must be an integer"); |
c6f50d62ecef
8067447: Factor out the shared implementation of the VM flags manipulation code
jbachorik
parents:
diff
changeset
|
85 |
return WRONG_FORMAT; |
c6f50d62ecef
8067447: Factor out the shared implementation of the VM flags manipulation code
jbachorik
parents:
diff
changeset
|
86 |
} |
c6f50d62ecef
8067447: Factor out the shared implementation of the VM flags manipulation code
jbachorik
parents:
diff
changeset
|
87 |
|
c6f50d62ecef
8067447: Factor out the shared implementation of the VM flags manipulation code
jbachorik
parents:
diff
changeset
|
88 |
int WriteableFlags::set_intx_flag(const char* name, intx value, Flag::Flags origin, FormatBuffer<80>& err_msg) { |
c6f50d62ecef
8067447: Factor out the shared implementation of the VM flags manipulation code
jbachorik
parents:
diff
changeset
|
89 |
return CommandLineFlags::intxAtPut((char*)name, &value, origin) ? SUCCESS : ERR_OTHER; |
c6f50d62ecef
8067447: Factor out the shared implementation of the VM flags manipulation code
jbachorik
parents:
diff
changeset
|
90 |
} |
c6f50d62ecef
8067447: Factor out the shared implementation of the VM flags manipulation code
jbachorik
parents:
diff
changeset
|
91 |
|
c6f50d62ecef
8067447: Factor out the shared implementation of the VM flags manipulation code
jbachorik
parents:
diff
changeset
|
92 |
// set a uintx global flag |
c6f50d62ecef
8067447: Factor out the shared implementation of the VM flags manipulation code
jbachorik
parents:
diff
changeset
|
93 |
int WriteableFlags::set_uintx_flag(const char* name, const char* arg, Flag::Flags origin, FormatBuffer<80>& err_msg) { |
c6f50d62ecef
8067447: Factor out the shared implementation of the VM flags manipulation code
jbachorik
parents:
diff
changeset
|
94 |
uintx value; |
c6f50d62ecef
8067447: Factor out the shared implementation of the VM flags manipulation code
jbachorik
parents:
diff
changeset
|
95 |
|
c6f50d62ecef
8067447: Factor out the shared implementation of the VM flags manipulation code
jbachorik
parents:
diff
changeset
|
96 |
if (sscanf(arg, UINTX_FORMAT, &value)) { |
c6f50d62ecef
8067447: Factor out the shared implementation of the VM flags manipulation code
jbachorik
parents:
diff
changeset
|
97 |
return set_uintx_flag(name, value, origin, err_msg); |
c6f50d62ecef
8067447: Factor out the shared implementation of the VM flags manipulation code
jbachorik
parents:
diff
changeset
|
98 |
} |
c6f50d62ecef
8067447: Factor out the shared implementation of the VM flags manipulation code
jbachorik
parents:
diff
changeset
|
99 |
err_msg.print("flag value must be an unsigned integer"); |
c6f50d62ecef
8067447: Factor out the shared implementation of the VM flags manipulation code
jbachorik
parents:
diff
changeset
|
100 |
return WRONG_FORMAT; |
c6f50d62ecef
8067447: Factor out the shared implementation of the VM flags manipulation code
jbachorik
parents:
diff
changeset
|
101 |
} |
c6f50d62ecef
8067447: Factor out the shared implementation of the VM flags manipulation code
jbachorik
parents:
diff
changeset
|
102 |
|
c6f50d62ecef
8067447: Factor out the shared implementation of the VM flags manipulation code
jbachorik
parents:
diff
changeset
|
103 |
int WriteableFlags::set_uintx_flag(const char* name, uintx value, Flag::Flags origin, FormatBuffer<80>& err_msg) { |
c6f50d62ecef
8067447: Factor out the shared implementation of the VM flags manipulation code
jbachorik
parents:
diff
changeset
|
104 |
if (strncmp(name, "MaxHeapFreeRatio", 17) == 0) { |
c6f50d62ecef
8067447: Factor out the shared implementation of the VM flags manipulation code
jbachorik
parents:
diff
changeset
|
105 |
if (!Arguments::verify_MaxHeapFreeRatio(err_msg, value)) { |
c6f50d62ecef
8067447: Factor out the shared implementation of the VM flags manipulation code
jbachorik
parents:
diff
changeset
|
106 |
return OUT_OF_BOUNDS; |
c6f50d62ecef
8067447: Factor out the shared implementation of the VM flags manipulation code
jbachorik
parents:
diff
changeset
|
107 |
} |
c6f50d62ecef
8067447: Factor out the shared implementation of the VM flags manipulation code
jbachorik
parents:
diff
changeset
|
108 |
} else if (strncmp(name, "MinHeapFreeRatio", 17) == 0) { |
c6f50d62ecef
8067447: Factor out the shared implementation of the VM flags manipulation code
jbachorik
parents:
diff
changeset
|
109 |
if (!Arguments::verify_MinHeapFreeRatio(err_msg, value)) { |
c6f50d62ecef
8067447: Factor out the shared implementation of the VM flags manipulation code
jbachorik
parents:
diff
changeset
|
110 |
return OUT_OF_BOUNDS; |
c6f50d62ecef
8067447: Factor out the shared implementation of the VM flags manipulation code
jbachorik
parents:
diff
changeset
|
111 |
} |
c6f50d62ecef
8067447: Factor out the shared implementation of the VM flags manipulation code
jbachorik
parents:
diff
changeset
|
112 |
} |
c6f50d62ecef
8067447: Factor out the shared implementation of the VM flags manipulation code
jbachorik
parents:
diff
changeset
|
113 |
return CommandLineFlags::uintxAtPut((char*)name, &value, origin) ? SUCCESS : ERR_OTHER; |
c6f50d62ecef
8067447: Factor out the shared implementation of the VM flags manipulation code
jbachorik
parents:
diff
changeset
|
114 |
} |
c6f50d62ecef
8067447: Factor out the shared implementation of the VM flags manipulation code
jbachorik
parents:
diff
changeset
|
115 |
|
c6f50d62ecef
8067447: Factor out the shared implementation of the VM flags manipulation code
jbachorik
parents:
diff
changeset
|
116 |
// set a uint64_t global flag |
c6f50d62ecef
8067447: Factor out the shared implementation of the VM flags manipulation code
jbachorik
parents:
diff
changeset
|
117 |
int WriteableFlags::set_uint64_t_flag(const char* name, const char* arg, Flag::Flags origin, FormatBuffer<80>& err_msg) { |
c6f50d62ecef
8067447: Factor out the shared implementation of the VM flags manipulation code
jbachorik
parents:
diff
changeset
|
118 |
uint64_t value; |
c6f50d62ecef
8067447: Factor out the shared implementation of the VM flags manipulation code
jbachorik
parents:
diff
changeset
|
119 |
|
c6f50d62ecef
8067447: Factor out the shared implementation of the VM flags manipulation code
jbachorik
parents:
diff
changeset
|
120 |
if (sscanf(arg, UINT64_FORMAT, &value)) { |
c6f50d62ecef
8067447: Factor out the shared implementation of the VM flags manipulation code
jbachorik
parents:
diff
changeset
|
121 |
return set_uint64_t_flag(name, value, origin, err_msg); |
c6f50d62ecef
8067447: Factor out the shared implementation of the VM flags manipulation code
jbachorik
parents:
diff
changeset
|
122 |
} |
c6f50d62ecef
8067447: Factor out the shared implementation of the VM flags manipulation code
jbachorik
parents:
diff
changeset
|
123 |
err_msg.print("flag value must be an unsigned 64-bit integer"); |
c6f50d62ecef
8067447: Factor out the shared implementation of the VM flags manipulation code
jbachorik
parents:
diff
changeset
|
124 |
return WRONG_FORMAT; |
c6f50d62ecef
8067447: Factor out the shared implementation of the VM flags manipulation code
jbachorik
parents:
diff
changeset
|
125 |
} |
c6f50d62ecef
8067447: Factor out the shared implementation of the VM flags manipulation code
jbachorik
parents:
diff
changeset
|
126 |
|
c6f50d62ecef
8067447: Factor out the shared implementation of the VM flags manipulation code
jbachorik
parents:
diff
changeset
|
127 |
int WriteableFlags::set_uint64_t_flag(const char* name, uint64_t value, Flag::Flags origin, FormatBuffer<80>& err_msg) { |
c6f50d62ecef
8067447: Factor out the shared implementation of the VM flags manipulation code
jbachorik
parents:
diff
changeset
|
128 |
return CommandLineFlags::uint64_tAtPut((char*)name, &value, origin) ? SUCCESS : ERR_OTHER; |
c6f50d62ecef
8067447: Factor out the shared implementation of the VM flags manipulation code
jbachorik
parents:
diff
changeset
|
129 |
} |
c6f50d62ecef
8067447: Factor out the shared implementation of the VM flags manipulation code
jbachorik
parents:
diff
changeset
|
130 |
|
c6f50d62ecef
8067447: Factor out the shared implementation of the VM flags manipulation code
jbachorik
parents:
diff
changeset
|
131 |
// set a size_t global flag |
c6f50d62ecef
8067447: Factor out the shared implementation of the VM flags manipulation code
jbachorik
parents:
diff
changeset
|
132 |
int WriteableFlags::set_size_t_flag(const char* name, const char* arg, Flag::Flags origin, FormatBuffer<80>& err_msg) { |
c6f50d62ecef
8067447: Factor out the shared implementation of the VM flags manipulation code
jbachorik
parents:
diff
changeset
|
133 |
size_t value; |
c6f50d62ecef
8067447: Factor out the shared implementation of the VM flags manipulation code
jbachorik
parents:
diff
changeset
|
134 |
|
c6f50d62ecef
8067447: Factor out the shared implementation of the VM flags manipulation code
jbachorik
parents:
diff
changeset
|
135 |
if (sscanf(arg, SIZE_FORMAT, &value)) { |
c6f50d62ecef
8067447: Factor out the shared implementation of the VM flags manipulation code
jbachorik
parents:
diff
changeset
|
136 |
return set_size_t_flag(name, value, origin, err_msg); |
c6f50d62ecef
8067447: Factor out the shared implementation of the VM flags manipulation code
jbachorik
parents:
diff
changeset
|
137 |
} |
c6f50d62ecef
8067447: Factor out the shared implementation of the VM flags manipulation code
jbachorik
parents:
diff
changeset
|
138 |
err_msg.print("flag value must be an unsigned integer"); |
c6f50d62ecef
8067447: Factor out the shared implementation of the VM flags manipulation code
jbachorik
parents:
diff
changeset
|
139 |
return WRONG_FORMAT; |
c6f50d62ecef
8067447: Factor out the shared implementation of the VM flags manipulation code
jbachorik
parents:
diff
changeset
|
140 |
} |
c6f50d62ecef
8067447: Factor out the shared implementation of the VM flags manipulation code
jbachorik
parents:
diff
changeset
|
141 |
|
c6f50d62ecef
8067447: Factor out the shared implementation of the VM flags manipulation code
jbachorik
parents:
diff
changeset
|
142 |
int WriteableFlags::set_size_t_flag(const char* name, size_t value, Flag::Flags origin, FormatBuffer<80>& err_msg) { |
c6f50d62ecef
8067447: Factor out the shared implementation of the VM flags manipulation code
jbachorik
parents:
diff
changeset
|
143 |
return CommandLineFlags::size_tAtPut((char*)name, &value, origin) ? SUCCESS : ERR_OTHER; |
c6f50d62ecef
8067447: Factor out the shared implementation of the VM flags manipulation code
jbachorik
parents:
diff
changeset
|
144 |
} |
c6f50d62ecef
8067447: Factor out the shared implementation of the VM flags manipulation code
jbachorik
parents:
diff
changeset
|
145 |
|
c6f50d62ecef
8067447: Factor out the shared implementation of the VM flags manipulation code
jbachorik
parents:
diff
changeset
|
146 |
// set a string global flag using value from AttachOperation |
c6f50d62ecef
8067447: Factor out the shared implementation of the VM flags manipulation code
jbachorik
parents:
diff
changeset
|
147 |
int WriteableFlags::set_ccstr_flag(const char* name, const char* arg, Flag::Flags origin, FormatBuffer<80>& err_msg) { |
c6f50d62ecef
8067447: Factor out the shared implementation of the VM flags manipulation code
jbachorik
parents:
diff
changeset
|
148 |
bool res = CommandLineFlags::ccstrAtPut((char*)name, &arg, origin); |
c6f50d62ecef
8067447: Factor out the shared implementation of the VM flags manipulation code
jbachorik
parents:
diff
changeset
|
149 |
|
c6f50d62ecef
8067447: Factor out the shared implementation of the VM flags manipulation code
jbachorik
parents:
diff
changeset
|
150 |
return res? SUCCESS : ERR_OTHER; |
c6f50d62ecef
8067447: Factor out the shared implementation of the VM flags manipulation code
jbachorik
parents:
diff
changeset
|
151 |
} |
c6f50d62ecef
8067447: Factor out the shared implementation of the VM flags manipulation code
jbachorik
parents:
diff
changeset
|
152 |
|
c6f50d62ecef
8067447: Factor out the shared implementation of the VM flags manipulation code
jbachorik
parents:
diff
changeset
|
153 |
/* sets a writeable flag to the provided value |
c6f50d62ecef
8067447: Factor out the shared implementation of the VM flags manipulation code
jbachorik
parents:
diff
changeset
|
154 |
* |
c6f50d62ecef
8067447: Factor out the shared implementation of the VM flags manipulation code
jbachorik
parents:
diff
changeset
|
155 |
* - return status is one of the WriteableFlags::err enum values |
c6f50d62ecef
8067447: Factor out the shared implementation of the VM flags manipulation code
jbachorik
parents:
diff
changeset
|
156 |
* - an eventual error message will be generated to the provided err_msg buffer |
c6f50d62ecef
8067447: Factor out the shared implementation of the VM flags manipulation code
jbachorik
parents:
diff
changeset
|
157 |
*/ |
c6f50d62ecef
8067447: Factor out the shared implementation of the VM flags manipulation code
jbachorik
parents:
diff
changeset
|
158 |
int WriteableFlags::set_flag(const char* flag_name, const char* flag_value, Flag::Flags origin, FormatBuffer<80>& err_msg) { |
c6f50d62ecef
8067447: Factor out the shared implementation of the VM flags manipulation code
jbachorik
parents:
diff
changeset
|
159 |
return set_flag(flag_name, &flag_value, set_flag_from_char, origin, err_msg); |
c6f50d62ecef
8067447: Factor out the shared implementation of the VM flags manipulation code
jbachorik
parents:
diff
changeset
|
160 |
} |
c6f50d62ecef
8067447: Factor out the shared implementation of the VM flags manipulation code
jbachorik
parents:
diff
changeset
|
161 |
|
c6f50d62ecef
8067447: Factor out the shared implementation of the VM flags manipulation code
jbachorik
parents:
diff
changeset
|
162 |
/* sets a writeable flag to the provided value |
c6f50d62ecef
8067447: Factor out the shared implementation of the VM flags manipulation code
jbachorik
parents:
diff
changeset
|
163 |
* |
c6f50d62ecef
8067447: Factor out the shared implementation of the VM flags manipulation code
jbachorik
parents:
diff
changeset
|
164 |
* - return status is one of the WriteableFlags::err enum values |
c6f50d62ecef
8067447: Factor out the shared implementation of the VM flags manipulation code
jbachorik
parents:
diff
changeset
|
165 |
* - an eventual error message will be generated to the provided err_msg buffer |
c6f50d62ecef
8067447: Factor out the shared implementation of the VM flags manipulation code
jbachorik
parents:
diff
changeset
|
166 |
*/ |
c6f50d62ecef
8067447: Factor out the shared implementation of the VM flags manipulation code
jbachorik
parents:
diff
changeset
|
167 |
int WriteableFlags::set_flag(const char* flag_name, jvalue flag_value, Flag::Flags origin, FormatBuffer<80>& err_msg) { |
c6f50d62ecef
8067447: Factor out the shared implementation of the VM flags manipulation code
jbachorik
parents:
diff
changeset
|
168 |
return set_flag(flag_name, &flag_value, set_flag_from_jvalue, origin, err_msg); |
c6f50d62ecef
8067447: Factor out the shared implementation of the VM flags manipulation code
jbachorik
parents:
diff
changeset
|
169 |
} |
c6f50d62ecef
8067447: Factor out the shared implementation of the VM flags manipulation code
jbachorik
parents:
diff
changeset
|
170 |
|
c6f50d62ecef
8067447: Factor out the shared implementation of the VM flags manipulation code
jbachorik
parents:
diff
changeset
|
171 |
// a writeable flag setter accepting either 'jvalue' or 'char *' values |
c6f50d62ecef
8067447: Factor out the shared implementation of the VM flags manipulation code
jbachorik
parents:
diff
changeset
|
172 |
int WriteableFlags::set_flag(const char* name, const void* value, int(*setter)(Flag*,const void*,Flag::Flags,FormatBuffer<80>&), Flag::Flags origin, FormatBuffer<80>& err_msg) { |
c6f50d62ecef
8067447: Factor out the shared implementation of the VM flags manipulation code
jbachorik
parents:
diff
changeset
|
173 |
if (name == NULL) { |
c6f50d62ecef
8067447: Factor out the shared implementation of the VM flags manipulation code
jbachorik
parents:
diff
changeset
|
174 |
err_msg.print("flag name is missing"); |
c6f50d62ecef
8067447: Factor out the shared implementation of the VM flags manipulation code
jbachorik
parents:
diff
changeset
|
175 |
return MISSING_NAME; |
c6f50d62ecef
8067447: Factor out the shared implementation of the VM flags manipulation code
jbachorik
parents:
diff
changeset
|
176 |
} |
c6f50d62ecef
8067447: Factor out the shared implementation of the VM flags manipulation code
jbachorik
parents:
diff
changeset
|
177 |
if (value == NULL) { |
c6f50d62ecef
8067447: Factor out the shared implementation of the VM flags manipulation code
jbachorik
parents:
diff
changeset
|
178 |
err_msg.print("flag value is missing"); |
c6f50d62ecef
8067447: Factor out the shared implementation of the VM flags manipulation code
jbachorik
parents:
diff
changeset
|
179 |
return MISSING_VALUE; |
c6f50d62ecef
8067447: Factor out the shared implementation of the VM flags manipulation code
jbachorik
parents:
diff
changeset
|
180 |
} |
c6f50d62ecef
8067447: Factor out the shared implementation of the VM flags manipulation code
jbachorik
parents:
diff
changeset
|
181 |
|
c6f50d62ecef
8067447: Factor out the shared implementation of the VM flags manipulation code
jbachorik
parents:
diff
changeset
|
182 |
Flag* f = Flag::find_flag((char*)name, strlen(name)); |
c6f50d62ecef
8067447: Factor out the shared implementation of the VM flags manipulation code
jbachorik
parents:
diff
changeset
|
183 |
if (f) { |
c6f50d62ecef
8067447: Factor out the shared implementation of the VM flags manipulation code
jbachorik
parents:
diff
changeset
|
184 |
// only writeable flags are allowed to be set |
c6f50d62ecef
8067447: Factor out the shared implementation of the VM flags manipulation code
jbachorik
parents:
diff
changeset
|
185 |
if (f->is_writeable()) { |
c6f50d62ecef
8067447: Factor out the shared implementation of the VM flags manipulation code
jbachorik
parents:
diff
changeset
|
186 |
return setter(f, value, origin, err_msg); |
c6f50d62ecef
8067447: Factor out the shared implementation of the VM flags manipulation code
jbachorik
parents:
diff
changeset
|
187 |
} else { |
c6f50d62ecef
8067447: Factor out the shared implementation of the VM flags manipulation code
jbachorik
parents:
diff
changeset
|
188 |
err_msg.print("only 'writeable' flags can be set"); |
c6f50d62ecef
8067447: Factor out the shared implementation of the VM flags manipulation code
jbachorik
parents:
diff
changeset
|
189 |
return NON_WRITABLE; |
c6f50d62ecef
8067447: Factor out the shared implementation of the VM flags manipulation code
jbachorik
parents:
diff
changeset
|
190 |
} |
c6f50d62ecef
8067447: Factor out the shared implementation of the VM flags manipulation code
jbachorik
parents:
diff
changeset
|
191 |
} |
c6f50d62ecef
8067447: Factor out the shared implementation of the VM flags manipulation code
jbachorik
parents:
diff
changeset
|
192 |
|
c6f50d62ecef
8067447: Factor out the shared implementation of the VM flags manipulation code
jbachorik
parents:
diff
changeset
|
193 |
err_msg.print("flag %s does not exist", name); |
c6f50d62ecef
8067447: Factor out the shared implementation of the VM flags manipulation code
jbachorik
parents:
diff
changeset
|
194 |
return INVALID_FLAG; |
c6f50d62ecef
8067447: Factor out the shared implementation of the VM flags manipulation code
jbachorik
parents:
diff
changeset
|
195 |
} |
c6f50d62ecef
8067447: Factor out the shared implementation of the VM flags manipulation code
jbachorik
parents:
diff
changeset
|
196 |
|
c6f50d62ecef
8067447: Factor out the shared implementation of the VM flags manipulation code
jbachorik
parents:
diff
changeset
|
197 |
// a writeable flag setter accepting 'char *' values |
c6f50d62ecef
8067447: Factor out the shared implementation of the VM flags manipulation code
jbachorik
parents:
diff
changeset
|
198 |
int WriteableFlags::set_flag_from_char(Flag* f, const void* value, Flag::Flags origin, FormatBuffer<80>& err_msg) { |
c6f50d62ecef
8067447: Factor out the shared implementation of the VM flags manipulation code
jbachorik
parents:
diff
changeset
|
199 |
char* flag_value = *(char**)value; |
c6f50d62ecef
8067447: Factor out the shared implementation of the VM flags manipulation code
jbachorik
parents:
diff
changeset
|
200 |
if (flag_value == NULL) { |
c6f50d62ecef
8067447: Factor out the shared implementation of the VM flags manipulation code
jbachorik
parents:
diff
changeset
|
201 |
err_msg.print("flag value is missing"); |
c6f50d62ecef
8067447: Factor out the shared implementation of the VM flags manipulation code
jbachorik
parents:
diff
changeset
|
202 |
return MISSING_VALUE; |
c6f50d62ecef
8067447: Factor out the shared implementation of the VM flags manipulation code
jbachorik
parents:
diff
changeset
|
203 |
} |
c6f50d62ecef
8067447: Factor out the shared implementation of the VM flags manipulation code
jbachorik
parents:
diff
changeset
|
204 |
if (f->is_bool()) { |
c6f50d62ecef
8067447: Factor out the shared implementation of the VM flags manipulation code
jbachorik
parents:
diff
changeset
|
205 |
return set_bool_flag(f->_name, flag_value, origin, err_msg); |
31236 | 206 |
} else if (f->is_int()) { |
207 |
return set_int_flag(f->_name, flag_value, origin, err_msg); |
|
208 |
} else if (f->is_uint()) { |
|
209 |
return set_uint_flag(f->_name, flag_value, origin, err_msg); |
|
28949
c6f50d62ecef
8067447: Factor out the shared implementation of the VM flags manipulation code
jbachorik
parents:
diff
changeset
|
210 |
} else if (f->is_intx()) { |
c6f50d62ecef
8067447: Factor out the shared implementation of the VM flags manipulation code
jbachorik
parents:
diff
changeset
|
211 |
return set_intx_flag(f->_name, flag_value, origin, err_msg); |
c6f50d62ecef
8067447: Factor out the shared implementation of the VM flags manipulation code
jbachorik
parents:
diff
changeset
|
212 |
} else if (f->is_uintx()) { |
c6f50d62ecef
8067447: Factor out the shared implementation of the VM flags manipulation code
jbachorik
parents:
diff
changeset
|
213 |
return set_uintx_flag(f->_name, flag_value, origin, err_msg); |
c6f50d62ecef
8067447: Factor out the shared implementation of the VM flags manipulation code
jbachorik
parents:
diff
changeset
|
214 |
} else if (f->is_uint64_t()) { |
c6f50d62ecef
8067447: Factor out the shared implementation of the VM flags manipulation code
jbachorik
parents:
diff
changeset
|
215 |
return set_uint64_t_flag(f->_name, flag_value, origin, err_msg); |
c6f50d62ecef
8067447: Factor out the shared implementation of the VM flags manipulation code
jbachorik
parents:
diff
changeset
|
216 |
} else if (f->is_size_t()) { |
c6f50d62ecef
8067447: Factor out the shared implementation of the VM flags manipulation code
jbachorik
parents:
diff
changeset
|
217 |
return set_size_t_flag(f->_name, flag_value, origin, err_msg); |
c6f50d62ecef
8067447: Factor out the shared implementation of the VM flags manipulation code
jbachorik
parents:
diff
changeset
|
218 |
} else if (f->is_ccstr()) { |
c6f50d62ecef
8067447: Factor out the shared implementation of the VM flags manipulation code
jbachorik
parents:
diff
changeset
|
219 |
return set_ccstr_flag(f->_name, flag_value, origin, err_msg); |
c6f50d62ecef
8067447: Factor out the shared implementation of the VM flags manipulation code
jbachorik
parents:
diff
changeset
|
220 |
} else { |
c6f50d62ecef
8067447: Factor out the shared implementation of the VM flags manipulation code
jbachorik
parents:
diff
changeset
|
221 |
ShouldNotReachHere(); |
c6f50d62ecef
8067447: Factor out the shared implementation of the VM flags manipulation code
jbachorik
parents:
diff
changeset
|
222 |
} |
c6f50d62ecef
8067447: Factor out the shared implementation of the VM flags manipulation code
jbachorik
parents:
diff
changeset
|
223 |
return ERR_OTHER; |
c6f50d62ecef
8067447: Factor out the shared implementation of the VM flags manipulation code
jbachorik
parents:
diff
changeset
|
224 |
} |
c6f50d62ecef
8067447: Factor out the shared implementation of the VM flags manipulation code
jbachorik
parents:
diff
changeset
|
225 |
|
c6f50d62ecef
8067447: Factor out the shared implementation of the VM flags manipulation code
jbachorik
parents:
diff
changeset
|
226 |
// a writeable flag setter accepting 'jvalue' values |
c6f50d62ecef
8067447: Factor out the shared implementation of the VM flags manipulation code
jbachorik
parents:
diff
changeset
|
227 |
int WriteableFlags::set_flag_from_jvalue(Flag* f, const void* value, Flag::Flags origin, FormatBuffer<80>& err_msg) { |
c6f50d62ecef
8067447: Factor out the shared implementation of the VM flags manipulation code
jbachorik
parents:
diff
changeset
|
228 |
jvalue new_value = *(jvalue*)value; |
c6f50d62ecef
8067447: Factor out the shared implementation of the VM flags manipulation code
jbachorik
parents:
diff
changeset
|
229 |
if (f->is_bool()) { |
c6f50d62ecef
8067447: Factor out the shared implementation of the VM flags manipulation code
jbachorik
parents:
diff
changeset
|
230 |
bool bvalue = (new_value.z == JNI_TRUE ? true : false); |
c6f50d62ecef
8067447: Factor out the shared implementation of the VM flags manipulation code
jbachorik
parents:
diff
changeset
|
231 |
return set_bool_flag(f->_name, bvalue, origin, err_msg); |
31236 | 232 |
} else if (f->is_int()) { |
233 |
int ivalue = (int)new_value.j; |
|
234 |
return set_int_flag(f->_name, ivalue, origin, err_msg); |
|
235 |
} else if (f->is_uint()) { |
|
236 |
uint uvalue = (uint)new_value.j; |
|
237 |
return set_uint_flag(f->_name, uvalue, origin, err_msg); |
|
28949
c6f50d62ecef
8067447: Factor out the shared implementation of the VM flags manipulation code
jbachorik
parents:
diff
changeset
|
238 |
} else if (f->is_intx()) { |
c6f50d62ecef
8067447: Factor out the shared implementation of the VM flags manipulation code
jbachorik
parents:
diff
changeset
|
239 |
intx ivalue = (intx)new_value.j; |
c6f50d62ecef
8067447: Factor out the shared implementation of the VM flags manipulation code
jbachorik
parents:
diff
changeset
|
240 |
return set_intx_flag(f->_name, ivalue, origin, err_msg); |
c6f50d62ecef
8067447: Factor out the shared implementation of the VM flags manipulation code
jbachorik
parents:
diff
changeset
|
241 |
} else if (f->is_uintx()) { |
c6f50d62ecef
8067447: Factor out the shared implementation of the VM flags manipulation code
jbachorik
parents:
diff
changeset
|
242 |
uintx uvalue = (uintx)new_value.j; |
c6f50d62ecef
8067447: Factor out the shared implementation of the VM flags manipulation code
jbachorik
parents:
diff
changeset
|
243 |
return set_uintx_flag(f->_name, uvalue, origin, err_msg); |
c6f50d62ecef
8067447: Factor out the shared implementation of the VM flags manipulation code
jbachorik
parents:
diff
changeset
|
244 |
} else if (f->is_uint64_t()) { |
c6f50d62ecef
8067447: Factor out the shared implementation of the VM flags manipulation code
jbachorik
parents:
diff
changeset
|
245 |
uint64_t uvalue = (uint64_t)new_value.j; |
c6f50d62ecef
8067447: Factor out the shared implementation of the VM flags manipulation code
jbachorik
parents:
diff
changeset
|
246 |
return set_uint64_t_flag(f->_name, uvalue, origin, err_msg); |
c6f50d62ecef
8067447: Factor out the shared implementation of the VM flags manipulation code
jbachorik
parents:
diff
changeset
|
247 |
} else if (f->is_size_t()) { |
c6f50d62ecef
8067447: Factor out the shared implementation of the VM flags manipulation code
jbachorik
parents:
diff
changeset
|
248 |
size_t svalue = (size_t)new_value.j; |
c6f50d62ecef
8067447: Factor out the shared implementation of the VM flags manipulation code
jbachorik
parents:
diff
changeset
|
249 |
return set_size_t_flag(f->_name, svalue, origin, err_msg); |
c6f50d62ecef
8067447: Factor out the shared implementation of the VM flags manipulation code
jbachorik
parents:
diff
changeset
|
250 |
} else if (f->is_ccstr()) { |
c6f50d62ecef
8067447: Factor out the shared implementation of the VM flags manipulation code
jbachorik
parents:
diff
changeset
|
251 |
oop str = JNIHandles::resolve_external_guard(new_value.l); |
c6f50d62ecef
8067447: Factor out the shared implementation of the VM flags manipulation code
jbachorik
parents:
diff
changeset
|
252 |
if (str == NULL) { |
c6f50d62ecef
8067447: Factor out the shared implementation of the VM flags manipulation code
jbachorik
parents:
diff
changeset
|
253 |
err_msg.print("flag value is missing"); |
c6f50d62ecef
8067447: Factor out the shared implementation of the VM flags manipulation code
jbachorik
parents:
diff
changeset
|
254 |
return MISSING_VALUE; |
c6f50d62ecef
8067447: Factor out the shared implementation of the VM flags manipulation code
jbachorik
parents:
diff
changeset
|
255 |
} |
c6f50d62ecef
8067447: Factor out the shared implementation of the VM flags manipulation code
jbachorik
parents:
diff
changeset
|
256 |
ccstr svalue = java_lang_String::as_utf8_string(str); |
c6f50d62ecef
8067447: Factor out the shared implementation of the VM flags manipulation code
jbachorik
parents:
diff
changeset
|
257 |
int ret = WriteableFlags::set_ccstr_flag(f->_name, svalue, origin, err_msg); |
c6f50d62ecef
8067447: Factor out the shared implementation of the VM flags manipulation code
jbachorik
parents:
diff
changeset
|
258 |
if (ret != SUCCESS) { |
c6f50d62ecef
8067447: Factor out the shared implementation of the VM flags manipulation code
jbachorik
parents:
diff
changeset
|
259 |
FREE_C_HEAP_ARRAY(char, svalue); |
c6f50d62ecef
8067447: Factor out the shared implementation of the VM flags manipulation code
jbachorik
parents:
diff
changeset
|
260 |
} |
c6f50d62ecef
8067447: Factor out the shared implementation of the VM flags manipulation code
jbachorik
parents:
diff
changeset
|
261 |
return ret; |
c6f50d62ecef
8067447: Factor out the shared implementation of the VM flags manipulation code
jbachorik
parents:
diff
changeset
|
262 |
} else { |
c6f50d62ecef
8067447: Factor out the shared implementation of the VM flags manipulation code
jbachorik
parents:
diff
changeset
|
263 |
ShouldNotReachHere(); |
c6f50d62ecef
8067447: Factor out the shared implementation of the VM flags manipulation code
jbachorik
parents:
diff
changeset
|
264 |
} |
c6f50d62ecef
8067447: Factor out the shared implementation of the VM flags manipulation code
jbachorik
parents:
diff
changeset
|
265 |
return ERR_OTHER; |
29068
683bef04fb20
8072935: Fix missing newline at end of file after 8067447
dholmes
parents:
28949
diff
changeset
|
266 |
} |
683bef04fb20
8072935: Fix missing newline at end of file after 8067447
dholmes
parents:
28949
diff
changeset
|
267 |