Ignore:
Timestamp:
Sep 27, 2016, 1:32:13 PM (9 years ago)
Author:
[email protected]
Message:

Add some needed CatchScopes in code that should not throw.
https://bugs.webkit.org/show_bug.cgi?id=162584

Reviewed by Keith Miller.

Re-landing minus the jsc.cpp and ExceptionHelpers.cpp changes. I'll address
those in a subsequent patch if the need manifests again in my testing.

  • API/JSObjectRef.cpp:

(JSObjectSetProperty):

  • This function already handles exceptions in its own way. We're honoring this contract and catching exceptions and passing it to the handler.
  • interpreter/Interpreter.cpp:

(JSC::notifyDebuggerOfUnwinding):

  • The debugger should not be throwing any exceptions.
  • profiler/ProfilerDatabase.cpp:

(JSC::Profiler::Database::save):

  • If an exception was thrown while saving the database, there's nothing we can really do about it anyway. Just fail nicely and return false. This is in line with existing error checking code in Database::save() that returns false if it's not able to open the file to save to.
  • runtime/JSModuleLoader.cpp:

(JSC::JSModuleLoader::finishCreation):

  • The existing code already RELEASE_ASSERT that no exception was thrown. Hence, it's appropriate to use a CatchScope here.
  • runtime/SamplingProfiler.cpp:

(JSC::SamplingProfiler::StackFrame::nameFromCallee):

  • The sampling profiler is doing a VMInquiry get here. It should never throw an exception. Hence, we'll just use a CatchScope and assert accordingly.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/API/JSObjectRef.cpp

    r206408 r206459  
    310310    }
    311311    ExecState* exec = toJS(ctx);
    312     JSLockHolder locker(exec);
     312    VM& vm = exec->vm();
     313    JSLockHolder locker(vm);
     314    auto scope = DECLARE_CATCH_SCOPE(vm);
    313315
    314316    JSObject* jsObject = toJS(object);
     
    316318    JSValue jsValue = toJS(exec, value);
    317319
    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    }
    326330    handleExceptionIfNeeded(exec, exception);
    327331}
Note: See TracChangeset for help on using the changeset viewer.