comparison src/share/vm/runtime/globals.cpp @ 11173:6b0fd0964b87

Merge with http://hg.openjdk.java.net/hsx/hsx25/hotspot/
author Doug Simon <doug.simon@oracle.com>
date Wed, 31 Jul 2013 11:00:54 +0200
parents 5fc51c1ecdeb 6e3634222155
children cefad50507d8
comparison
equal deleted inserted replaced
10912:4ea54634f03e 11173:6b0fd0964b87
74 bool Flag::is_unlocked() const { 74 bool Flag::is_unlocked() const {
75 if (strcmp(kind, "{diagnostic}") == 0 || 75 if (strcmp(kind, "{diagnostic}") == 0 ||
76 strcmp(kind, "{C2 diagnostic}") == 0 || 76 strcmp(kind, "{C2 diagnostic}") == 0 ||
77 strcmp(kind, "{ARCH diagnostic}") == 0 || 77 strcmp(kind, "{ARCH diagnostic}") == 0 ||
78 strcmp(kind, "{Shark diagnostic}") == 0) { 78 strcmp(kind, "{Shark diagnostic}") == 0) {
79 if (strcmp(name, "EnableInvokeDynamic") == 0 && UnlockExperimentalVMOptions && !UnlockDiagnosticVMOptions) {
80 // transitional logic to allow tests to run until they are changed
81 static int warned;
82 if (++warned == 1) warning("Use -XX:+UnlockDiagnosticVMOptions before EnableInvokeDynamic flag");
83 return true;
84 }
85 return UnlockDiagnosticVMOptions; 79 return UnlockDiagnosticVMOptions;
86 } else if (strcmp(kind, "{experimental}") == 0 || 80 } else if (strcmp(kind, "{experimental}") == 0 ||
87 strcmp(kind, "{C2 experimental}") == 0 || 81 strcmp(kind, "{C2 experimental}") == 0 ||
88 strcmp(kind, "{ARCH experimental}") == 0 || 82 strcmp(kind, "{ARCH experimental}") == 0 ||
89 strcmp(kind, "{Shark experimental}") == 0) { 83 strcmp(kind, "{Shark experimental}") == 0) {
298 }; 292 };
299 293
300 Flag* Flag::flags = flagTable; 294 Flag* Flag::flags = flagTable;
301 size_t Flag::numFlags = (sizeof(flagTable) / sizeof(Flag)); 295 size_t Flag::numFlags = (sizeof(flagTable) / sizeof(Flag));
302 296
303 inline bool str_equal(const char* s, char* q, size_t len) { 297 inline bool str_equal(const char* s, const char* q, size_t len) {
304 // s is null terminated, q is not! 298 // s is null terminated, q is not!
305 if (strlen(s) != (unsigned int) len) return false; 299 if (strlen(s) != (unsigned int) len) return false;
306 return strncmp(s, q, len) == 0; 300 return strncmp(s, q, len) == 0;
307 } 301 }
308 302
309 // Search the flag table for a named flag 303 // Search the flag table for a named flag
310 Flag* Flag::find_flag(char* name, size_t length, bool allow_locked) { 304 Flag* Flag::find_flag(const char* name, size_t length, bool allow_locked) {
311 for (Flag* current = &flagTable[0]; current->name != NULL; current++) { 305 for (Flag* current = &flagTable[0]; current->name != NULL; current++) {
312 if (str_equal(current->name, name, length)) { 306 if (str_equal(current->name, name, length)) {
313 // Found a matching entry. Report locked flags only if allowed. 307 // Found a matching entry. Report locked flags only if allowed.
314 if (!(current->is_unlocked() || current->is_unlocker())) { 308 if (!(current->is_unlocked() || current->is_unlocker())) {
315 if (!allow_locked) { 309 if (!allow_locked) {
323 } 317 }
324 // Flag name is not in the flag table 318 // Flag name is not in the flag table
325 return NULL; 319 return NULL;
326 } 320 }
327 321
322 // Compute string similarity based on Dice's coefficient
323 static float str_similar(const char* str1, const char* str2, size_t len2) {
324 int len1 = (int) strlen(str1);
325 int total = len1 + (int) len2;
326
327 int hit = 0;
328
329 for (int i = 0; i < len1 -1; ++i) {
330 for (int j = 0; j < (int) len2 -1; ++j) {
331 if ((str1[i] == str2[j]) && (str1[i+1] == str2[j+1])) {
332 ++hit;
333 break;
334 }
335 }
336 }
337
338 return 2.0f * (float) hit / (float) total;
339 }
340
341 Flag* Flag::fuzzy_match(const char* name, size_t length, bool allow_locked) {
342 float VMOptionsFuzzyMatchSimilarity = 0.7f;
343 Flag* match = NULL;
344 float score;
345 float max_score = -1;
346
347 for (Flag* current = &flagTable[0]; current->name != NULL; current++) {
348 score = str_similar(current->name, name, length);
349 if (score > max_score) {
350 max_score = score;
351 match = current;
352 }
353 }
354
355 if (!(match->is_unlocked() || match->is_unlocker())) {
356 if (!allow_locked) {
357 return NULL;
358 }
359 }
360
361 if (max_score < VMOptionsFuzzyMatchSimilarity) {
362 return NULL;
363 }
364
365 return match;
366 }
367
328 // Returns the address of the index'th element 368 // Returns the address of the index'th element
329 static Flag* address_of_flag(CommandLineFlagWithType flag) { 369 static Flag* address_of_flag(CommandLineFlagWithType flag) {
330 assert((size_t)flag < Flag::numFlags, "bad command line flag index"); 370 assert((size_t)flag < Flag::numFlags, "bad command line flag index");
331 return &Flag::flags[flag]; 371 return &Flag::flags[flag];
332 } 372 }