Changeset 218936 in webkit for trunk/Source/JavaScriptCore/jsc.cpp
- Timestamp:
- Jun 29, 2017, 10:34:57 AM (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/JavaScriptCore/jsc.cpp
r218816 r218936 987 987 template<typename Func> 988 988 int runJSC(CommandLine, bool isWorker, const Func&); 989 static void checkException(GlobalObject*, bool isLastFile, bool hasException, JSValue, const String& uncaughtExceptionName, bool alwaysDumpUncaughtException, bool dump, bool& success);989 static void checkException(GlobalObject*, bool isLastFile, bool hasException, JSValue, CommandLine&, bool& success); 990 990 991 991 class Message : public ThreadSafeRefCounted<Message> { … … 1211 1211 String m_profilerOutput; 1212 1212 String m_uncaughtExceptionName; 1213 bool m_treatWatchdogExceptionAsSuccess { false }; 1213 1214 bool m_alwaysDumpUncaughtException { false }; 1214 1215 bool m_dumpSamplingProfilerData { false }; … … 2618 2619 if (evaluationException) 2619 2620 result = evaluationException->value(); 2620 checkException(globalObject, true, evaluationException, result, String(), false, false, success);2621 checkException(globalObject, true, evaluationException, result, commandLine, success); 2621 2622 if (!success) 2622 2623 exit(1); … … 3293 3294 } 3294 3295 3295 static bool checkUncaughtException(VM& vm, GlobalObject* globalObject, JSValue exception, const String& expectedExceptionName, bool alwaysDumpException) 3296 { 3296 static bool checkUncaughtException(VM& vm, GlobalObject* globalObject, JSValue exception, CommandLine& options) 3297 { 3298 const String& expectedExceptionName = options.m_uncaughtExceptionName; 3297 3299 auto scope = DECLARE_CATCH_SCOPE(vm); 3298 3300 scope.clearException(); … … 3315 3317 } 3316 3318 if (isInstanceOfExpectedException) { 3317 if ( alwaysDumpException)3319 if (options.m_alwaysDumpUncaughtException) 3318 3320 dumpException(globalObject, exception); 3319 3321 return true; … … 3325 3327 } 3326 3328 3327 static void checkException(GlobalObject* globalObject, bool isLastFile, bool hasException, JSValue value, const String& uncaughtExceptionName, bool alwaysDumpUncaughtException, bool dump, bool& success)3329 static void checkException(GlobalObject* globalObject, bool isLastFile, bool hasException, JSValue value, CommandLine& options, bool& success) 3328 3330 { 3329 3331 VM& vm = globalObject->vm(); 3330 if (!uncaughtExceptionName || !isLastFile) { 3332 3333 if (options.m_treatWatchdogExceptionAsSuccess && value.inherits(vm, TerminatedExecutionError::info())) { 3334 ASSERT(hasException); 3335 return; 3336 } 3337 3338 if (!options.m_uncaughtExceptionName || !isLastFile) { 3331 3339 success = success && !hasException; 3332 if ( dump && !hasException)3340 if (options.m_dump && !hasException) 3333 3341 printf("End: %s\n", value.toWTFString(globalObject->globalExec()).utf8().data()); 3334 3342 if (hasException) 3335 3343 dumpException(globalObject, value); 3336 3344 } else 3337 success = success && checkUncaughtException(vm, globalObject, (hasException) ? value : JSValue(), uncaughtExceptionName, alwaysDumpUncaughtException); 3338 } 3339 3340 static bool runWithScripts(GlobalObject* globalObject, const Vector<Script>& scripts, const String& uncaughtExceptionName, bool alwaysDumpUncaughtException, bool dump, bool module) 3341 { 3345 success = success && checkUncaughtException(vm, globalObject, (hasException) ? value : JSValue(), options); 3346 } 3347 3348 static bool runWithOptions(GlobalObject* globalObject, CommandLine& options) 3349 { 3350 Vector<Script>& scripts = options.m_scripts; 3342 3351 String fileName; 3343 3352 Vector<char> scriptBuffer; 3344 3353 3345 if ( dump)3354 if (options.m_dump) 3346 3355 JSC::Options::dumpGeneratedBytecodes() = true; 3347 3356 … … 3356 3365 for (size_t i = 0; i < scripts.size(); i++) { 3357 3366 JSInternalPromise* promise = nullptr; 3358 bool isModule = module || scripts[i].scriptType == Script::ScriptType::Module;3367 bool isModule = options.m_module || scripts[i].scriptType == Script::ScriptType::Module; 3359 3368 if (scripts[i].codeSource == Script::CodeSource::File) { 3360 3369 fileName = scripts[i].argument; … … 3383 3392 3384 3393 JSFunction* fulfillHandler = JSNativeStdFunction::create(vm, globalObject, 1, String(), [&, isLastFile](ExecState* exec) { 3385 checkException(globalObject, isLastFile, false, exec->argument(0), uncaughtExceptionName, alwaysDumpUncaughtException, dump, success);3394 checkException(globalObject, isLastFile, false, exec->argument(0), options, success); 3386 3395 return JSValue::encode(jsUndefined()); 3387 3396 }); 3388 3397 3389 3398 JSFunction* rejectHandler = JSNativeStdFunction::create(vm, globalObject, 1, String(), [&, isLastFile](ExecState* exec) { 3390 checkException(globalObject, isLastFile, true, exec->argument(0), uncaughtExceptionName, alwaysDumpUncaughtException, dump, success);3399 checkException(globalObject, isLastFile, true, exec->argument(0), options, success); 3391 3400 return JSValue::encode(jsUndefined()); 3392 3401 }); … … 3401 3410 if (evaluationException) 3402 3411 returnValue = evaluationException->value(); 3403 checkException(globalObject, isLastFile, evaluationException, returnValue, uncaughtExceptionName, alwaysDumpUncaughtException, dump, success);3412 checkException(globalObject, isLastFile, evaluationException, returnValue, options, success); 3404 3413 } 3405 3414 … … 3503 3512 fprintf(stderr, " --module-file=<file> Parse and evaluate the given file as module (this option may be passed more than once)\n"); 3504 3513 fprintf(stderr, " --exception=<name> Check the last script exits with an uncaught exception with the specified name\n"); 3514 fprintf(stderr, " --watchdog-exception-ok Uncaught watchdog exceptions exit with success\n"); 3505 3515 fprintf(stderr, " --dumpException Dump uncaught exception text\n"); 3506 3516 fprintf(stderr, " --options Dumps all JSC VM options and exits\n"); … … 3629 3639 if (!strncmp(arg, "--exception=", exceptionStrLength)) { 3630 3640 m_uncaughtExceptionName = String(arg + exceptionStrLength); 3641 continue; 3642 } 3643 3644 if (!strcmp(arg, "--watchdog-exception-ok")) { 3645 m_treatWatchdogExceptionAsSuccess = true; 3631 3646 continue; 3632 3647 } … … 3779 3794 options, false, 3780 3795 [&] (VM&, GlobalObject* globalObject) { 3781 return runWith Scripts(globalObject, options.m_scripts, options.m_uncaughtExceptionName, options.m_alwaysDumpUncaughtException, options.m_dump, options.m_module);3796 return runWithOptions(globalObject, options); 3782 3797 }); 3783 3798
Note:
See TracChangeset
for help on using the changeset viewer.