Changeset 206405 in webkit
- Timestamp:
- Sep 26, 2016, 4:56:37 PM (9 years ago)
- Location:
- trunk/Source/JavaScriptCore
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/JavaScriptCore/API/JSObjectRef.cpp
r206267 r206405 310 310 } 311 311 ExecState* exec = toJS(ctx); 312 JSLockHolder locker(exec); 312 VM& vm = exec->vm(); 313 JSLockHolder locker(vm); 314 auto scope = DECLARE_CATCH_SCOPE(vm); 313 315 314 316 JSObject* jsObject = toJS(object); … … 316 318 JSValue jsValue = toJS(exec, value); 317 319 318 if (attributes && !jsObject->hasProperty(exec, name)) { 319 PropertyDescriptor desc(jsValue, attributes); 320 jsObject->methodTable()->defineOwnProperty(jsObject, exec, name, desc, false); 321 } else { 322 PutPropertySlot slot(jsObject); 323 jsObject->methodTable()->put(jsObject, exec, name, jsValue, slot); 324 } 325 320 bool doesNotHaveProperty = attributes && !jsObject->hasProperty(exec, name); 321 if (LIKELY(!scope.exception())) { 322 if (doesNotHaveProperty) { 323 PropertyDescriptor desc(jsValue, attributes); 324 jsObject->methodTable()->defineOwnProperty(jsObject, exec, name, desc, false); 325 } else { 326 PutPropertySlot slot(jsObject); 327 jsObject->methodTable()->put(jsObject, exec, name, jsValue, slot); 328 } 329 } 326 330 handleExceptionIfNeeded(exec, exception); 327 331 } -
trunk/Source/JavaScriptCore/ChangeLog
r206401 r206405 1 2016-09-26 Mark Lam <mark.lam@apple.com> 2 3 Add some needed CatchScopes in code that should not throw. 4 https://bugs.webkit.org/show_bug.cgi?id=162584 5 6 Reviewed by Keith Miller. 7 8 * API/JSObjectRef.cpp: 9 (JSObjectSetProperty): 10 - This function already handles exceptions in its own way. We're honoring this 11 contract and catching exceptions and passing it to the handler. 12 13 * interpreter/Interpreter.cpp: 14 (JSC::notifyDebuggerOfUnwinding): 15 - The debugger should not be throwing any exceptions. 16 17 * jsc.cpp: 18 (runJSC): 19 - the buck stops here. There's no reason an exception should propagate past here. 20 21 * profiler/ProfilerDatabase.cpp: 22 (JSC::Profiler::Database::save): 23 - If an exception was thrown while saving the database, there's nothing we can 24 really do about it anyway. Just fail nicely and return false. This is in line 25 with existing error checking code in Database::save() that returns false if 26 it's not able to open the file to save to. 27 28 * runtime/ExceptionHelpers.cpp: 29 (JSC::createError): 30 - If we're not able to stringify the error value, then we'll just use the 31 provided message as the error string. It doesn't make sense to have the 32 Error factory throw an exception that shadows the intended exception that the 33 client probably wants to throw (assuming that that's why the client is creating 34 this Error object). 35 36 * runtime/JSModuleLoader.cpp: 37 (JSC::JSModuleLoader::finishCreation): 38 - The existing code already RELEASE_ASSERT that no exception was thrown. 39 Hence, it's appropriate to use a CatchScope here. 40 41 * runtime/SamplingProfiler.cpp: 42 (JSC::SamplingProfiler::StackFrame::nameFromCallee): 43 - The sampling profiler is doing a VMInquiry get here. It should never throw an 44 exception. Hence, we'll just use a CatchScope and assert accordingly. 45 1 46 2016-09-26 Mark Lam <mark.lam@apple.com> 2 47 -
trunk/Source/JavaScriptCore/interpreter/Interpreter.cpp
r206401 r206405 584 584 { 585 585 VM& vm = callFrame->vm(); 586 auto throwScope = DECLARE_THROW_SCOPE(vm);586 auto catchScope = DECLARE_CATCH_SCOPE(vm); 587 587 if (Debugger* debugger = callFrame->vmEntryGlobalObject()->debugger()) { 588 588 SuspendExceptionScope scope(&vm); … … 591 591 else 592 592 debugger->didExecuteProgram(callFrame); 593 ASSERT_UNUSED( throwScope, !throwScope.exception());593 ASSERT_UNUSED(catchScope, !catchScope.exception()); 594 594 } 595 595 } -
trunk/Source/JavaScriptCore/jsc.cpp
r206386 r206405 2540 2540 { 2541 2541 JSLockHolder locker(vm); 2542 auto scope = DECLARE_CATCH_SCOPE(*vm); 2542 2543 2543 2544 int result; … … 2546 2547 2547 2548 GlobalObject* globalObject = GlobalObject::create(*vm, GlobalObject::createStructure(*vm, jsNull()), options.m_arguments); 2549 RETURN_IF_EXCEPTION(scope, 3); 2550 2548 2551 bool success = runWithScripts(globalObject, options.m_scripts, options.m_uncaughtExceptionName, options.m_alwaysDumpUncaughtException, options.m_dump, options.m_module); 2549 2552 if (options.m_interactive && success) -
trunk/Source/JavaScriptCore/profiler/ProfilerDatabase.cpp
r206386 r206405 135 135 bool Database::save(const char* filename) const 136 136 { 137 auto scope = DECLARE_CATCH_SCOPE(m_vm); 137 138 auto out = FilePrintStream::open(filename, "w"); 138 139 if (!out) 139 140 return false; 140 141 141 out->print(toJSON()); 142 String data = toJSON(); 143 if (UNLIKELY(scope.exception())) { 144 scope.clearException(); 145 return false; 146 } 147 out->print(data); 142 148 return true; 143 149 } -
trunk/Source/JavaScriptCore/runtime/ExceptionHelpers.cpp
r205198 r206405 237 237 JSObject* createError(ExecState* exec, JSValue value, const String& message, ErrorInstance::SourceAppender appender) 238 238 { 239 VM& vm = exec->vm(); 240 auto scope = DECLARE_CATCH_SCOPE(vm); 241 239 242 String errorMessage = makeString(errorDescriptionForValue(exec, value)->value(exec), ' ', message); 243 if (UNLIKELY(scope.exception())) { 244 scope.clearException(); 245 errorMessage = message; 246 } 240 247 JSObject* exception = createTypeError(exec, errorMessage, appender, runtimeTypeForValue(value)); 241 248 ASSERT(exception->isErrorInstance()); -
trunk/Source/JavaScriptCore/runtime/JSModuleLoader.cpp
r205569 r206405 58 58 void JSModuleLoader::finishCreation(ExecState* exec, VM& vm, JSGlobalObject* globalObject) 59 59 { 60 auto scope = DECLARE_CATCH_SCOPE(vm); 61 60 62 Base::finishCreation(vm); 61 63 ASSERT(inherits(info())); 62 auto scope = DECLARE_THROW_SCOPE(vm);63 64 JSMap* map = JSMap::create(exec, vm, globalObject->mapStructure()); 64 65 RELEASE_ASSERT(!scope.exception()); -
trunk/Source/JavaScriptCore/runtime/SamplingProfiler.cpp
r206267 r206405 592 592 return String(); 593 593 594 auto scope = DECLARE_CATCH_SCOPE(vm); 594 595 ExecState* exec = callee->globalObject()->globalExec(); 595 596 auto getPropertyIfPureOperation = [&] (const Identifier& ident) -> String { 596 597 PropertySlot slot(callee, PropertySlot::InternalMethodType::VMInquiry); 597 598 PropertyName propertyName(ident); 598 if (callee->getPropertySlot(exec, propertyName, slot)) { 599 bool hasProperty = callee->getPropertySlot(exec, propertyName, slot); 600 ASSERT_UNUSED(scope, !scope.exception()); 601 if (hasProperty) { 599 602 if (slot.isValue()) { 600 603 JSValue nameValue = slot.getValue(exec, propertyName);
Note:
See TracChangeset
for help on using the changeset viewer.