Changeset 164077 in webkit


Ignore:
Timestamp:
Feb 13, 2014 5:06:53 PM (10 years ago)
Author:
mark.lam@apple.com
Message:

The JSContainerConvertor and ObjcContainerConvertor need to protect JSValueRefs.
<https://webkit.org/b/128764>

Reviewed by Mark Hahnenberg.

Added a vector of Strong<Unknown> references in the 2 containers, and append
the newly created JSValues to those vectors. This will keep all those JS objects
alive for the duration of the conversion.

  • API/JSValue.mm:

(JSContainerConvertor::add):
(ObjcContainerConvertor::add):

Location:
trunk/Source/JavaScriptCore
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/API/JSValue.mm

    r163844 r164077  
    3838#import "JSCInlines.h"
    3939#import "JSCJSValue.h"
     40#import "Strong.h"
    4041#import <wtf/HashMap.h>
    4142#import <wtf/HashSet.h>
     
    596597    HashMap<JSValueRef, id> m_objectMap;
    597598    Vector<Task> m_worklist;
     599    Vector<JSC::Strong<JSC::Unknown>> m_jsValues;
    598600};
    599601
     
    612614void JSContainerConvertor::add(Task task)
    613615{
     616    JSC::ExecState* exec = toJS(m_context);
     617    m_jsValues.append(JSC::Strong<JSC::Unknown>(exec->vm(), toJS(exec, task.js)));
    614618    m_objectMap.add(task.js, task.objc);
    615619    if (task.type != ContainerNone)
     
    818822    HashMap<id, JSValueRef> m_objectMap;
    819823    Vector<Task> m_worklist;
     824    Vector<JSC::Strong<JSC::Unknown>> m_jsValues;
    820825};
    821826
     
    835840void ObjcContainerConvertor::add(ObjcContainerConvertor::Task task)
    836841{
     842    JSC::ExecState* exec = toJS(m_context.JSGlobalContextRef);
     843    m_jsValues.append(JSC::Strong<JSC::Unknown>(exec->vm(), toJS(exec, task.js)));
    837844    m_objectMap.add(task.objc, task.js);
    838845    if (task.type != ContainerNone)
  • trunk/Source/JavaScriptCore/ChangeLog

    r164074 r164077  
     12014-02-13  Mark Lam  <mark.lam@apple.com>
     2
     3        The JSContainerConvertor and ObjcContainerConvertor need to protect JSValueRefs.
     4        <https://webkit.org/b/128764>
     5
     6        Reviewed by Mark Hahnenberg.
     7
     8        Added a vector of Strong<Unknown> references in the 2 containers, and append
     9        the newly created JSValues to those vectors. This will keep all those JS objects
     10        alive for the duration of the conversion.
     11
     12        * API/JSValue.mm:
     13        (JSContainerConvertor::add):
     14        (ObjcContainerConvertor::add):
     15
    1162014-02-13  Matthew Mirman  <mmirman@apple.com>
    217
Note: See TracChangeset for help on using the changeset viewer.