Changeset 188887 in webkit
- Timestamp:
- Aug 24, 2015, 2:51:26 PM (9 years ago)
- Location:
- trunk/Source/JavaScriptCore
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/JavaScriptCore/ChangeLog
r188886 r188887 1 2015-08-24 Mark Lam <mark.lam@apple.com> 2 3 Add support for setting JSC options from a file. 4 https://bugs.webkit.org/show_bug.cgi?id=148394 5 6 Reviewed by Saam Barati. 7 8 This is needed for environments where the JSC executable does not have access to 9 environmental variables. This is only needed for debugging, and is currently 10 guarded under a #define USE_OPTIONS_FILE in Options.cpp, and is disabled by 11 default. 12 13 Also fixed Options::setOptions() to be allow for whitespace that is not a single 14 ' '. This makes setOptions() much more flexible and friendlier to use for loading 15 options in general. 16 17 For example, this current use case of loading options from a file may have '\n's 18 in the character stream, and this feature is easier to implement if setOptions() 19 just support more than 1 whitespace char between options, and recognize whitespace 20 characters other than ' '. 21 22 * runtime/Options.cpp: 23 (JSC::parse): 24 (JSC::Options::initialize): 25 (JSC::Options::setOptions): 26 1 27 2015-08-24 Filip Pizlo <fpizlo@apple.com> 2 28 -
trunk/Source/JavaScriptCore/runtime/Options.cpp
r188648 r188887 34 34 #include <stdlib.h> 35 35 #include <string.h> 36 #include <wtf/ASCIICType.h> 36 37 #include <wtf/DataLog.h> 37 38 #include <wtf/NumberOfCores.h> … … 48 49 #include "MacroAssemblerX86.h" 49 50 #endif 51 52 #define USE_OPTIONS_FILE 0 53 #define OPTIONS_FILENAME "/tmp/jsc.options" 50 54 51 55 namespace JSC { … … 362 366 363 367 recomputeDependentOptions(); 368 369 #if USE(OPTIONS_FILE) 370 { 371 const char* filename = OPTIONS_FILENAME; 372 FILE* optionsFile = fopen(filename, "r"); 373 if (!optionsFile) { 374 dataLogF("Failed to open file %s. Did you add the file-read-data entitlement to WebProcess.sb?\n", filename); 375 return; 376 } 377 378 StringBuilder builder; 379 char* line; 380 char buffer[BUFSIZ]; 381 while ((line = fgets(buffer, sizeof(buffer), optionsFile))) 382 builder.append(buffer); 383 384 const char* optionsStr = builder.toString().utf8().data(); 385 dataLogF("Setting options: %s\n", optionsStr); 386 setOptions(optionsStr); 387 388 int result = fclose(optionsFile); 389 if (result) 390 dataLogF("Failed to close file %s: %s\n", filename, strerror(errno)); 391 } 392 #endif 364 393 365 394 // Do range checks where needed and make corrections to the options: … … 411 440 412 441 while (p < end) { 442 // Skip white space. 443 while (p < end && isASCIISpace(*p)) 444 p++; 445 if (p == end) 446 break; 447 413 448 char* optionStart = p; 414 449 p = strstr(p, "="); … … 431 466 } 432 467 433 p = strstr(p, " "); 468 // Find next white space. 469 while (p < end && !isASCIISpace(*p)) 470 p++; 434 471 if (!p) 435 472 p = end; // No more " " separator. Hence, this is the last arg.
Note:
See TracChangeset
for help on using the changeset viewer.