Changeset 127955 in webkit


Ignore:
Timestamp:
Sep 7, 2012 6:39:13 PM (12 years ago)
Author:
abarth@webkit.org
Message:

[V8] DOM wrapper creation involves a bunch of sketchy code related to finding the Frame
https://bugs.webkit.org/show_bug.cgi?id=96147

Patch by Adam Barth <abarth@chromium.org> on 2012-09-07
Reviewed by Eric Seidel.

Source/WebCore:

Previously, we used the Frame when instantiating DOM wrappers. That's
sketchy because not all DOM wrappers know how to find their Frame, and
the Frame might be displaying a different document now anyway. This
patch now gets all the information directly from the creation context.

In addition, this patch gets the proper creation context in a few more
cases, including Location.

  • bindings/scripts/CodeGeneratorV8.pm:

(GetInternalFields):
(GenerateNormalAttrGetter):
(GenerateToV8Converters):
(GenerateFunctionCallString):
(NativeToJSValue):

  • bindings/scripts/test/V8/V8Float64Array.cpp:

(WebCore::Float64ArrayV8Internal::fooCallback):
(WebCore::V8Float64Array::wrapSlow):

  • bindings/scripts/test/V8/V8TestActiveDOMObject.cpp:

(WebCore::V8TestActiveDOMObject::wrapSlow):

  • bindings/scripts/test/V8/V8TestCallback.cpp:

(WebCore::V8TestCallback::callbackWithClass1Param):
(WebCore::V8TestCallback::callbackWithClass2Param):
(WebCore::V8TestCallback::callbackWithStringList):
(WebCore::V8TestCallback::callbackRequiresThisToPass):

  • bindings/scripts/test/V8/V8TestCustomNamedGetter.cpp:

(WebCore::V8TestCustomNamedGetter::wrapSlow):

  • bindings/scripts/test/V8/V8TestEventConstructor.cpp:

(WebCore::V8TestEventConstructor::wrapSlow):

  • bindings/scripts/test/V8/V8TestEventTarget.cpp:

(WebCore::TestEventTargetV8Internal::itemCallback):
(WebCore::V8TestEventTarget::wrapSlow):

  • bindings/scripts/test/V8/V8TestException.cpp:

(WebCore::V8TestException::wrapSlow):

  • bindings/scripts/test/V8/V8TestInterface.cpp:

(WebCore::TestInterfaceV8Internal::supplementalNodeAttrGetter):
(WebCore::TestInterfaceV8Internal::supplementalMethod2Callback):
(WebCore::V8TestInterface::wrapSlow):

  • bindings/scripts/test/V8/V8TestMediaQueryListListener.cpp:

(WebCore::V8TestMediaQueryListListener::wrapSlow):

  • bindings/scripts/test/V8/V8TestNamedConstructor.cpp:

(WebCore::V8TestNamedConstructor::wrapSlow):

  • bindings/scripts/test/V8/V8TestNode.cpp:

(WebCore::V8TestNode::wrapSlow):

  • bindings/scripts/test/V8/V8TestObj.cpp:

(WebCore::TestObjV8Internal::testObjAttrAttrGetter):
(WebCore::TestObjV8Internal::XMLObjAttrAttrGetter):
(WebCore::TestObjV8Internal::typedArrayAttrAttrGetter):
(WebCore::TestObjV8Internal::withScriptExecutionContextAttributeAttrGetter):
(WebCore::TestObjV8Internal::withScriptStateAttributeRaisesAttrGetter):
(WebCore::TestObjV8Internal::withScriptExecutionContextAttributeRaisesAttrGetter):
(WebCore::TestObjV8Internal::withScriptExecutionContextAndScriptStateAttributeAttrGetter):
(WebCore::TestObjV8Internal::withScriptExecutionContextAndScriptStateAttributeRaisesAttrGetter):
(WebCore::TestObjV8Internal::withScriptExecutionContextAndScriptStateWithSpacesAttributeAttrGetter):
(WebCore::TestObjV8Internal::withScriptArgumentsAndCallStackAttributeAttrGetter):
(WebCore::TestObjV8Internal::contentDocumentAttrGetter):
(WebCore::TestObjV8Internal::objMethodCallback):
(WebCore::TestObjV8Internal::objMethodWithArgsCallback):
(WebCore::TestObjV8Internal::methodThatRequiresAllArgsAndThrowsCallback):
(WebCore::TestObjV8Internal::withScriptStateObjCallback):
(WebCore::TestObjV8Internal::withScriptStateObjExceptionCallback):
(WebCore::TestObjV8Internal::withScriptExecutionContextAndScriptStateObjExceptionCallback):
(WebCore::TestObjV8Internal::withScriptExecutionContextAndScriptStateWithSpacesCallback):
(WebCore::TestObjV8Internal::getSVGDocumentCallback):
(WebCore::TestObjV8Internal::strictFunctionCallback):
(WebCore::V8TestObj::wrapSlow):

  • bindings/scripts/test/V8/V8TestSerializedScriptValueInterface.cpp:

(WebCore::V8TestSerializedScriptValueInterface::wrapSlow):

  • bindings/v8/V8DOMWindowShell.cpp:

(WebCore::V8DOMWindowShell::disposeContext):

  • bindings/v8/V8DOMWrapper.cpp:

(WebCore::V8DOMWrapper::instantiateV8Object):

  • bindings/v8/V8DOMWrapper.h:

(V8DOMWrapper):

  • bindings/v8/V8PerContextData.cpp:

(WebCore):
(WebCore::V8PerContextData::current):
(WebCore::V8PerContextData::dispose):
(WebCore::V8PerContextData::init):

  • bindings/v8/V8PerContextData.h:

(V8PerContextData):

LayoutTests:

The V8 results for this test now match the JSC results. We can remove
the chromium-specific baseline.

  • platform/chromium/fast/workers/storage/test-authorizer-sync-expected.txt: Removed.
Location:
trunk
Files:
1 deleted
21 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r127954 r127955  
     12012-09-07  Adam Barth  <abarth@chromium.org>
     2
     3        [V8] DOM wrapper creation involves a bunch of sketchy code related to finding the Frame
     4        https://bugs.webkit.org/show_bug.cgi?id=96147
     5
     6        Reviewed by Eric Seidel.
     7
     8        The V8 results for this test now match the JSC results. We can remove
     9        the chromium-specific baseline.
     10
     11        * platform/chromium/fast/workers/storage/test-authorizer-sync-expected.txt: Removed.
     12
    1132012-09-07  James Robinson  <jamesr@chromium.org>
    214
  • trunk/Source/WebCore/ChangeLog

    r127952 r127955  
     12012-09-07  Adam Barth  <abarth@chromium.org>
     2
     3        [V8] DOM wrapper creation involves a bunch of sketchy code related to finding the Frame
     4        https://bugs.webkit.org/show_bug.cgi?id=96147
     5
     6        Reviewed by Eric Seidel.
     7
     8        Previously, we used the Frame when instantiating DOM wrappers. That's
     9        sketchy because not all DOM wrappers know how to find their Frame, and
     10        the Frame might be displaying a different document now anyway. This
     11        patch now gets all the information directly from the creation context.
     12
     13        In addition, this patch gets the proper creation context in a few more
     14        cases, including Location.
     15
     16        * bindings/scripts/CodeGeneratorV8.pm:
     17        (GetInternalFields):
     18        (GenerateNormalAttrGetter):
     19        (GenerateToV8Converters):
     20        (GenerateFunctionCallString):
     21        (NativeToJSValue):
     22        * bindings/scripts/test/V8/V8Float64Array.cpp:
     23        (WebCore::Float64ArrayV8Internal::fooCallback):
     24        (WebCore::V8Float64Array::wrapSlow):
     25        * bindings/scripts/test/V8/V8TestActiveDOMObject.cpp:
     26        (WebCore::V8TestActiveDOMObject::wrapSlow):
     27        * bindings/scripts/test/V8/V8TestCallback.cpp:
     28        (WebCore::V8TestCallback::callbackWithClass1Param):
     29        (WebCore::V8TestCallback::callbackWithClass2Param):
     30        (WebCore::V8TestCallback::callbackWithStringList):
     31        (WebCore::V8TestCallback::callbackRequiresThisToPass):
     32        * bindings/scripts/test/V8/V8TestCustomNamedGetter.cpp:
     33        (WebCore::V8TestCustomNamedGetter::wrapSlow):
     34        * bindings/scripts/test/V8/V8TestEventConstructor.cpp:
     35        (WebCore::V8TestEventConstructor::wrapSlow):
     36        * bindings/scripts/test/V8/V8TestEventTarget.cpp:
     37        (WebCore::TestEventTargetV8Internal::itemCallback):
     38        (WebCore::V8TestEventTarget::wrapSlow):
     39        * bindings/scripts/test/V8/V8TestException.cpp:
     40        (WebCore::V8TestException::wrapSlow):
     41        * bindings/scripts/test/V8/V8TestInterface.cpp:
     42        (WebCore::TestInterfaceV8Internal::supplementalNodeAttrGetter):
     43        (WebCore::TestInterfaceV8Internal::supplementalMethod2Callback):
     44        (WebCore::V8TestInterface::wrapSlow):
     45        * bindings/scripts/test/V8/V8TestMediaQueryListListener.cpp:
     46        (WebCore::V8TestMediaQueryListListener::wrapSlow):
     47        * bindings/scripts/test/V8/V8TestNamedConstructor.cpp:
     48        (WebCore::V8TestNamedConstructor::wrapSlow):
     49        * bindings/scripts/test/V8/V8TestNode.cpp:
     50        (WebCore::V8TestNode::wrapSlow):
     51        * bindings/scripts/test/V8/V8TestObj.cpp:
     52        (WebCore::TestObjV8Internal::testObjAttrAttrGetter):
     53        (WebCore::TestObjV8Internal::XMLObjAttrAttrGetter):
     54        (WebCore::TestObjV8Internal::typedArrayAttrAttrGetter):
     55        (WebCore::TestObjV8Internal::withScriptExecutionContextAttributeAttrGetter):
     56        (WebCore::TestObjV8Internal::withScriptStateAttributeRaisesAttrGetter):
     57        (WebCore::TestObjV8Internal::withScriptExecutionContextAttributeRaisesAttrGetter):
     58        (WebCore::TestObjV8Internal::withScriptExecutionContextAndScriptStateAttributeAttrGetter):
     59        (WebCore::TestObjV8Internal::withScriptExecutionContextAndScriptStateAttributeRaisesAttrGetter):
     60        (WebCore::TestObjV8Internal::withScriptExecutionContextAndScriptStateWithSpacesAttributeAttrGetter):
     61        (WebCore::TestObjV8Internal::withScriptArgumentsAndCallStackAttributeAttrGetter):
     62        (WebCore::TestObjV8Internal::contentDocumentAttrGetter):
     63        (WebCore::TestObjV8Internal::objMethodCallback):
     64        (WebCore::TestObjV8Internal::objMethodWithArgsCallback):
     65        (WebCore::TestObjV8Internal::methodThatRequiresAllArgsAndThrowsCallback):
     66        (WebCore::TestObjV8Internal::withScriptStateObjCallback):
     67        (WebCore::TestObjV8Internal::withScriptStateObjExceptionCallback):
     68        (WebCore::TestObjV8Internal::withScriptExecutionContextAndScriptStateObjExceptionCallback):
     69        (WebCore::TestObjV8Internal::withScriptExecutionContextAndScriptStateWithSpacesCallback):
     70        (WebCore::TestObjV8Internal::getSVGDocumentCallback):
     71        (WebCore::TestObjV8Internal::strictFunctionCallback):
     72        (WebCore::V8TestObj::wrapSlow):
     73        * bindings/scripts/test/V8/V8TestSerializedScriptValueInterface.cpp:
     74        (WebCore::V8TestSerializedScriptValueInterface::wrapSlow):
     75        * bindings/v8/V8DOMWindowShell.cpp:
     76        (WebCore::V8DOMWindowShell::disposeContext):
     77        * bindings/v8/V8DOMWrapper.cpp:
     78        (WebCore::V8DOMWrapper::instantiateV8Object):
     79        * bindings/v8/V8DOMWrapper.h:
     80        (V8DOMWrapper):
     81        * bindings/v8/V8PerContextData.cpp:
     82        (WebCore):
     83        (WebCore::V8PerContextData::current):
     84        (WebCore::V8PerContextData::dispose):
     85        (WebCore::V8PerContextData::init):
     86        * bindings/v8/V8PerContextData.h:
     87        (V8PerContextData):
     88
    1892012-09-07  James Robinson  <jamesr@chromium.org>
    290
  • trunk/Source/WebCore/bindings/scripts/CodeGeneratorV8.pm

    r127946 r127955  
    561561
    562562    my @customInternalFields = ();
     563
     564    if ($name eq "DOMWindow" || $dataNode->extendedAttributes->{"IsWorkerContext"}) {
     565        push(@customInternalFields, "perContextDataIndex");
     566    }
     567
    563568    # We can't ask whether a parent type has a given extendedAttribute,
    564569    # so special-case AbstractWorker and WorkerContext to include all sub-types.
     
    10881093END
    10891094        } else {
    1090             push(@implContentDecls, "    " . ReturnNativeToJSValue($attribute->signature, $result, "info.GetIsolate()").";\n");
     1095            push(@implContentDecls, "    " . ReturnNativeToJSValue($attribute->signature, $result, "info.Holder()", "info.GetIsolate()").";\n");
    10911096        }
    10921097    }
     
    33603365
    33613366    AddToImplIncludes("Frame.h");
    3362     my $frame = "0";
    3363     if (IsNodeSubType($dataNode)) {
    3364         # DocumentType nodes are the only nodes that may have a NULL document.
    3365         if ($interfaceName eq "DocumentType") {
    3366             $frame = "impl->document() ? impl->document()->frame() : 0";
    3367         } else {
    3368             $frame = "impl->document()->frame()";
    3369         }
    3370     }
    3371     push(@implContent, <<END);
    3372     Frame* frame = $frame;
    3373 END
    33743367
    33753368    if (IsSubType($dataNode, "Document")) {
    33763369        push(@implContent, <<END);
    3377     if (frame && frame->script()->windowShell()->context().IsEmpty() && frame->script()->windowShell()->initializeIfNeeded()) {
    3378         // initializeIfNeeded may have created a wrapper for the object, retry from the start.
    3379         return ${className}::wrap(impl.get(), creationContext, isolate);
    3380     }
    3381 END
    3382     }
    3383 
    3384     # FIXME: We need a better way of recovering the correct prototype chain
    3385     # for every sort of object. For now, we special-case cross-origin visible
    3386     # objects (i.e., those with CheckSecurity).
    3387     if (IsVisibleAcrossOrigins($dataNode)) {
    3388         AddToImplIncludes("Frame.h");
    3389         push(@implContent, <<END);
    3390     if (impl->frame()) {
    3391         frame = impl->frame();
    3392         frame->script()->windowShell()->initializeIfNeeded();
     3370    if (Frame* frame = impl->frame()) {
     3371        if (frame->script()->windowShell()->context().IsEmpty() && frame->script()->windowShell()->initializeIfNeeded()) {
     3372            // initializeIfNeeded may have created a wrapper for the object, retry from the start.
     3373            return ${className}::wrap(impl.get(), creationContext, isolate);
     3374        }
    33933375    }
    33943376END
     
    34053387        context->Enter();
    34063388    }
    3407 END
    3408 
    3409     push(@implContent, <<END);
    3410     wrapper = V8DOMWrapper::instantiateV8Object(frame, &info, impl.get());
    3411 END
    3412 
    3413     push(@implContent, <<END);
     3389
     3390    wrapper = V8DOMWrapper::instantiateV8Object(&info, impl.get());
     3391
    34143392    if (!context.IsEmpty())
    34153393        context->Exit();
    3416 END
    3417 
    3418     push(@implContent, <<END);
     3394
    34193395    if (UNLIKELY(wrapper.IsEmpty()))
    34203396        return wrapper;
     
    35923568
    35933569    $return .= ".release()" if ($returnIsRef);
    3594     $result .= $indent . ReturnNativeToJSValue($function->signature, $return, "args.GetIsolate()") . ";\n";
     3570    $result .= $indent . ReturnNativeToJSValue($function->signature, $return, "args.Holder()", "args.GetIsolate()") . ";\n";
    35953571
    35963572    return $result;
     
    40233999    my $signature = shift;
    40244000    my $value = shift;
     4001    my $getCreationContext = shift;
     4002    my $getCreationContextArg = $getCreationContext ? ", $getCreationContext" : "";
    40254003    my $getIsolate = shift;
    40264004    my $getIsolateArg = $getIsolate ? ", $getIsolate" : "";
     
    40794057            AddToImplIncludes("$sequenceType.h");
    40804058        }
    4081         return "v8Array($value, $getIsolate)";
     4059        return "v8Array($value$getIsolateArg)";
    40824060    }
    40834061
     
    40864064    # special case for non-DOM node interfaces
    40874065    if (IsDOMNodeType($type)) {
    4088         return "toV8(${value}, v8::Handle<v8::Object>()" . ($signature->extendedAttributes->{"ReturnNewObject"} ? "$getIsolateArg, true)" : "$getIsolateArg)");
     4066        return "toV8(${value}$getCreationContextArg$getIsolateArg" . ($signature->extendedAttributes->{"ReturnNewObject"} ? ", true)" : ")");
    40894067    }
    40904068
    40914069    if ($type eq "EventTarget") {
    4092         return "V8DOMWrapper::convertEventTargetToV8Object($value, v8::Handle<v8::Object>()$getIsolateArg)";
     4070        return "V8DOMWrapper::convertEventTargetToV8Object($value$getCreationContextArg$getIsolateArg)";
    40934071    }
    40944072
     
    41074085    AddToImplIncludes("wtf/GetPtr.h");
    41084086
    4109     return "toV8($value, v8::Handle<v8::Object>()$getIsolateArg)";
     4087    return "toV8($value$getCreationContextArg$getIsolateArg)";
    41104088}
    41114089
  • trunk/Source/WebCore/bindings/scripts/test/V8/V8Float64Array.cpp

    r127946 r127955  
    5757    Float64Array* imp = V8Float64Array::toNative(args.Holder());
    5858    EXCEPTION_BLOCK(Float32Array*, array, V8Float32Array::HasInstance(MAYBE_MISSING_PARAMETER(args, 0, DefaultIsUndefined)) ? V8Float32Array::toNative(v8::Handle<v8::Object>::Cast(MAYBE_MISSING_PARAMETER(args, 0, DefaultIsUndefined))) : 0);
    59     return toV8(imp->foo(array), v8::Handle<v8::Object>(), args.GetIsolate());
     59    return toV8(imp->foo(array), args.Holder(), args.GetIsolate());
    6060}
    6161
     
    152152    v8::Handle<v8::Object> wrapper;
    153153    ASSERT(static_cast<void*>(static_cast<ArrayBufferView*>(impl.get())) == static_cast<void*>(impl.get()));
    154     Frame* frame = 0;
    155154
    156155    v8::Handle<v8::Context> context;
     
    162161        context->Enter();
    163162    }
    164     wrapper = V8DOMWrapper::instantiateV8Object(frame, &info, impl.get());
     163
     164    wrapper = V8DOMWrapper::instantiateV8Object(&info, impl.get());
     165
    165166    if (!context.IsEmpty())
    166167        context->Exit();
     168
    167169    if (UNLIKELY(wrapper.IsEmpty()))
    168170        return wrapper;
  • trunk/Source/WebCore/bindings/scripts/test/V8/V8TestActiveDOMObject.cpp

    r127946 r127955  
    180180{
    181181    v8::Handle<v8::Object> wrapper;
    182     Frame* frame = 0;
    183     if (impl->frame()) {
    184         frame = impl->frame();
    185         frame->script()->windowShell()->initializeIfNeeded();
    186     }
    187182
    188183    v8::Handle<v8::Context> context;
     
    194189        context->Enter();
    195190    }
    196     wrapper = V8DOMWrapper::instantiateV8Object(frame, &info, impl.get());
     191
     192    wrapper = V8DOMWrapper::instantiateV8Object(&info, impl.get());
     193
    197194    if (!context.IsEmpty())
    198195        context->Exit();
     196
    199197    if (UNLIKELY(wrapper.IsEmpty()))
    200198        return wrapper;
  • trunk/Source/WebCore/bindings/scripts/test/V8/V8TestCallback.cpp

    r127946 r127955  
    8787    v8::Context::Scope scope(v8Context);
    8888
    89     v8::Handle<v8::Value> class1ParamHandle = toV8(class1Param, v8::Handle<v8::Object>());
     89    v8::Handle<v8::Value> class1ParamHandle = toV8(class1Param);
    9090    if (class1ParamHandle.IsEmpty()) {
    9191        if (!isScriptControllerTerminating())
     
    115115    v8::Context::Scope scope(v8Context);
    116116
    117     v8::Handle<v8::Value> class2ParamHandle = toV8(class2Param, v8::Handle<v8::Object>());
     117    v8::Handle<v8::Value> class2ParamHandle = toV8(class2Param);
    118118    if (class2ParamHandle.IsEmpty()) {
    119119        if (!isScriptControllerTerminating())
     
    150150    v8::Context::Scope scope(v8Context);
    151151
    152     v8::Handle<v8::Value> listParamHandle = toV8(listParam, v8::Handle<v8::Object>());
     152    v8::Handle<v8::Value> listParamHandle = toV8(listParam);
    153153    if (listParamHandle.IsEmpty()) {
    154154        if (!isScriptControllerTerminating())
     
    208208    v8::Context::Scope scope(v8Context);
    209209
    210     v8::Handle<v8::Value> class8ParamHandle = toV8(class8Param, v8::Handle<v8::Object>());
     210    v8::Handle<v8::Value> class8ParamHandle = toV8(class8Param);
    211211    if (class8ParamHandle.IsEmpty()) {
    212212        if (!isScriptControllerTerminating())
     
    214214        return true;
    215215    }
    216     v8::Handle<v8::Value> thisClassParamHandle = toV8(thisClassParam, v8::Handle<v8::Object>());
     216    v8::Handle<v8::Value> thisClassParamHandle = toV8(thisClassParam);
    217217    if (thisClassParamHandle.IsEmpty()) {
    218218        if (!isScriptControllerTerminating())
  • trunk/Source/WebCore/bindings/scripts/test/V8/V8TestCustomNamedGetter.cpp

    r127946 r127955  
    114114{
    115115    v8::Handle<v8::Object> wrapper;
    116     Frame* frame = 0;
    117116
    118117    v8::Handle<v8::Context> context;
     
    124123        context->Enter();
    125124    }
    126     wrapper = V8DOMWrapper::instantiateV8Object(frame, &info, impl.get());
     125
     126    wrapper = V8DOMWrapper::instantiateV8Object(&info, impl.get());
     127
    127128    if (!context.IsEmpty())
    128129        context->Exit();
     130
    129131    if (UNLIKELY(wrapper.IsEmpty()))
    130132        return wrapper;
  • trunk/Source/WebCore/bindings/scripts/test/V8/V8TestEventConstructor.cpp

    r127946 r127955  
    151151{
    152152    v8::Handle<v8::Object> wrapper;
    153     Frame* frame = 0;
    154153
    155154    v8::Handle<v8::Context> context;
     
    161160        context->Enter();
    162161    }
    163     wrapper = V8DOMWrapper::instantiateV8Object(frame, &info, impl.get());
     162
     163    wrapper = V8DOMWrapper::instantiateV8Object(&info, impl.get());
     164
    164165    if (!context.IsEmpty())
    165166        context->Exit();
     167
    166168    if (UNLIKELY(wrapper.IsEmpty()))
    167169        return wrapper;
  • trunk/Source/WebCore/bindings/scripts/test/V8/V8TestEventTarget.cpp

    r127946 r127955  
    5656        goto fail;
    5757    }
    58     return toV8(imp->item(index), v8::Handle<v8::Object>(), args.GetIsolate());
     58    return toV8(imp->item(index), args.Holder(), args.GetIsolate());
    5959    }
    6060    fail:
     
    175175{
    176176    v8::Handle<v8::Object> wrapper;
    177     Frame* frame = 0;
    178177
    179178    v8::Handle<v8::Context> context;
     
    185184        context->Enter();
    186185    }
    187     wrapper = V8DOMWrapper::instantiateV8Object(frame, &info, impl.get());
     186
     187    wrapper = V8DOMWrapper::instantiateV8Object(&info, impl.get());
     188
    188189    if (!context.IsEmpty())
    189190        context->Exit();
     191
    190192    if (UNLIKELY(wrapper.IsEmpty()))
    191193        return wrapper;
  • trunk/Source/WebCore/bindings/scripts/test/V8/V8TestException.cpp

    r127946 r127955  
    105105{
    106106    v8::Handle<v8::Object> wrapper;
    107     Frame* frame = 0;
    108107
    109108    v8::Handle<v8::Context> context;
     
    115114        context->Enter();
    116115    }
    117     wrapper = V8DOMWrapper::instantiateV8Object(frame, &info, impl.get());
     116
     117    wrapper = V8DOMWrapper::instantiateV8Object(&info, impl.get());
     118
    118119    if (!context.IsEmpty())
    119120        context->Exit();
     121
    120122    if (UNLIKELY(wrapper.IsEmpty()))
    121123        return wrapper;
  • trunk/Source/WebCore/bindings/scripts/test/V8/V8TestInterface.cpp

    r127946 r127955  
    121121    INC_STATS("DOM.TestInterface.supplementalNode._get");
    122122    TestInterface* imp = V8TestInterface::toNative(info.Holder());
    123     return toV8(TestSupplemental::supplementalNode(imp), v8::Handle<v8::Object>(), info.GetIsolate());
     123    return toV8(TestSupplemental::supplementalNode(imp), info.Holder(), info.GetIsolate());
    124124}
    125125
     
    169169    if (UNLIKELY(ec))
    170170        goto fail;
    171     return toV8(result.release(), v8::Handle<v8::Object>(), args.GetIsolate());
     171    return toV8(result.release(), args.Holder(), args.GetIsolate());
    172172    }
    173173    fail:
     
    348348{
    349349    v8::Handle<v8::Object> wrapper;
    350     Frame* frame = 0;
    351350
    352351    v8::Handle<v8::Context> context;
     
    358357        context->Enter();
    359358    }
    360     wrapper = V8DOMWrapper::instantiateV8Object(frame, &info, impl.get());
     359
     360    wrapper = V8DOMWrapper::instantiateV8Object(&info, impl.get());
     361
    361362    if (!context.IsEmpty())
    362363        context->Exit();
     364
    363365    if (UNLIKELY(wrapper.IsEmpty()))
    364366        return wrapper;
  • trunk/Source/WebCore/bindings/scripts/test/V8/V8TestMediaQueryListListener.cpp

    r127946 r127955  
    114114{
    115115    v8::Handle<v8::Object> wrapper;
    116     Frame* frame = 0;
    117116
    118117    v8::Handle<v8::Context> context;
     
    124123        context->Enter();
    125124    }
    126     wrapper = V8DOMWrapper::instantiateV8Object(frame, &info, impl.get());
     125
     126    wrapper = V8DOMWrapper::instantiateV8Object(&info, impl.get());
     127
    127128    if (!context.IsEmpty())
    128129        context->Exit();
     130
    129131    if (UNLIKELY(wrapper.IsEmpty()))
    130132        return wrapper;
  • trunk/Source/WebCore/bindings/scripts/test/V8/V8TestNamedConstructor.cpp

    r127946 r127955  
    158158{
    159159    v8::Handle<v8::Object> wrapper;
    160     Frame* frame = 0;
    161160
    162161    v8::Handle<v8::Context> context;
     
    168167        context->Enter();
    169168    }
    170     wrapper = V8DOMWrapper::instantiateV8Object(frame, &info, impl.get());
     169
     170    wrapper = V8DOMWrapper::instantiateV8Object(&info, impl.get());
     171
    171172    if (!context.IsEmpty())
    172173        context->Exit();
     174
    173175    if (UNLIKELY(wrapper.IsEmpty()))
    174176        return wrapper;
  • trunk/Source/WebCore/bindings/scripts/test/V8/V8TestNode.cpp

    r127946 r127955  
    114114    v8::Handle<v8::Object> wrapper;
    115115    ASSERT(static_cast<void*>(static_cast<Node*>(impl.get())) == static_cast<void*>(impl.get()));
    116     Frame* frame = impl->document()->frame();
    117116
    118117    v8::Handle<v8::Context> context;
     
    124123        context->Enter();
    125124    }
    126     wrapper = V8DOMWrapper::instantiateV8Object(frame, &info, impl.get());
     125
     126    wrapper = V8DOMWrapper::instantiateV8Object(&info, impl.get());
     127
    127128    if (!context.IsEmpty())
    128129        context->Exit();
     130
    129131    if (UNLIKELY(wrapper.IsEmpty()))
    130132        return wrapper;
  • trunk/Source/WebCore/bindings/scripts/test/V8/V8TestObj.cpp

    r127946 r127955  
    230230    INC_STATS("DOM.TestObj.testObjAttr._get");
    231231    TestObj* imp = V8TestObj::toNative(info.Holder());
    232     return toV8(imp->testObjAttr(), v8::Handle<v8::Object>(), info.GetIsolate());
     232    return toV8(imp->testObjAttr(), info.Holder(), info.GetIsolate());
    233233}
    234234
     
    246246    INC_STATS("DOM.TestObj.XMLObjAttr._get");
    247247    TestObj* imp = V8TestObj::toNative(info.Holder());
    248     return toV8(imp->xmlObjAttr(), v8::Handle<v8::Object>(), info.GetIsolate());
     248    return toV8(imp->xmlObjAttr(), info.Holder(), info.GetIsolate());
    249249}
    250250
     
    422422    INC_STATS("DOM.TestObj.typedArrayAttr._get");
    423423    TestObj* imp = V8TestObj::toNative(info.Holder());
    424     return toV8(imp->typedArrayAttr(), v8::Handle<v8::Object>(), info.GetIsolate());
     424    return toV8(imp->typedArrayAttr(), info.Holder(), info.GetIsolate());
    425425}
    426426
     
    549549    if (!scriptContext)
    550550        return v8Undefined();
    551     return toV8(imp->withScriptExecutionContextAttribute(scriptContext), v8::Handle<v8::Object>(), info.GetIsolate());
     551    return toV8(imp->withScriptExecutionContextAttribute(scriptContext), info.Holder(), info.GetIsolate());
    552552}
    553553
     
    577577    if (state.hadException())
    578578        return throwError(state.exception(), info.GetIsolate());
    579     return toV8(v.release(), v8::Handle<v8::Object>(), info.GetIsolate());
     579    return toV8(v.release(), info.Holder(), info.GetIsolate());
    580580}
    581581
     
    608608    if (UNLIKELY(ec))
    609609        return setDOMException(ec, info.GetIsolate());
    610     return toV8(v.release(), v8::Handle<v8::Object>(), info.GetIsolate());
     610    return toV8(v.release(), info.Holder(), info.GetIsolate());
    611611}
    612612
     
    636636    if (!scriptContext)
    637637        return v8Undefined();
    638     return toV8(imp->withScriptExecutionContextAndScriptStateAttribute(state, scriptContext), v8::Handle<v8::Object>(), info.GetIsolate());
     638    return toV8(imp->withScriptExecutionContextAndScriptStateAttribute(state, scriptContext), info.Holder(), info.GetIsolate());
    639639}
    640640
     
    672672    if (state.hadException())
    673673        return throwError(state.exception(), info.GetIsolate());
    674     return toV8(v.release(), v8::Handle<v8::Object>(), info.GetIsolate());
     674    return toV8(v.release(), info.Holder(), info.GetIsolate());
    675675}
    676676
     
    705705    if (!scriptContext)
    706706        return v8Undefined();
    707     return toV8(imp->withScriptExecutionContextAndScriptStateWithSpacesAttribute(state, scriptContext), v8::Handle<v8::Object>(), info.GetIsolate());
     707    return toV8(imp->withScriptExecutionContextAndScriptStateWithSpacesAttribute(state, scriptContext), info.Holder(), info.GetIsolate());
    708708}
    709709
     
    732732    if (!callStack)
    733733        return v8Undefined();
    734     return toV8(imp->withScriptArgumentsAndCallStackAttribute(callStack), v8::Handle<v8::Object>(), info.GetIsolate());
     734    return toV8(imp->withScriptArgumentsAndCallStackAttribute(callStack), info.Holder(), info.GetIsolate());
    735735}
    736736
     
    950950        return v8::Handle<v8::Value>(v8::Null(info.GetIsolate()));
    951951
    952     return toV8(imp->contentDocument(), v8::Handle<v8::Object>(), info.GetIsolate());
     952    return toV8(imp->contentDocument(), info.Holder(), info.GetIsolate());
    953953}
    954954
     
    11121112    INC_STATS("DOM.TestObj.objMethod");
    11131113    TestObj* imp = V8TestObj::toNative(args.Holder());
    1114     return toV8(imp->objMethod(), v8::Handle<v8::Object>(), args.GetIsolate());
     1114    return toV8(imp->objMethod(), args.Holder(), args.GetIsolate());
    11151115}
    11161116
     
    11241124    STRING_TO_V8PARAMETER_EXCEPTION_BLOCK(V8Parameter<>, strArg, MAYBE_MISSING_PARAMETER(args, 1, DefaultIsUndefined));
    11251125    EXCEPTION_BLOCK(TestObj*, objArg, V8TestObj::HasInstance(MAYBE_MISSING_PARAMETER(args, 2, DefaultIsUndefined)) ? V8TestObj::toNative(v8::Handle<v8::Object>::Cast(MAYBE_MISSING_PARAMETER(args, 2, DefaultIsUndefined))) : 0);
    1126     return toV8(imp->objMethodWithArgs(Arg, strArg, objArg), v8::Handle<v8::Object>(), args.GetIsolate());
     1126    return toV8(imp->objMethodWithArgs(Arg, strArg, objArg), args.Holder(), args.GetIsolate());
    11271127}
    11281128
     
    11611161    if (UNLIKELY(ec))
    11621162        goto fail;
    1163     return toV8(result.release(), v8::Handle<v8::Object>(), args.GetIsolate());
     1163    return toV8(result.release(), args.Holder(), args.GetIsolate());
    11641164    }
    11651165    fail:
     
    12681268    if (state.hadException())
    12691269        return throwError(state.exception(), args.GetIsolate());
    1270     return toV8(result.release(), v8::Handle<v8::Object>(), args.GetIsolate());
     1270    return toV8(result.release(), args.Holder(), args.GetIsolate());
    12711271}
    12721272
     
    13011301    if (state.hadException())
    13021302        return throwError(state.exception(), args.GetIsolate());
    1303     return toV8(result.release(), v8::Handle<v8::Object>(), args.GetIsolate());
     1303    return toV8(result.release(), args.Holder(), args.GetIsolate());
    13041304    }
    13051305    fail:
     
    13471347    if (state.hadException())
    13481348        return throwError(state.exception(), args.GetIsolate());
    1349     return toV8(result.release(), v8::Handle<v8::Object>(), args.GetIsolate());
     1349    return toV8(result.release(), args.Holder(), args.GetIsolate());
    13501350    }
    13511351    fail:
     
    13641364    if (state.hadException())
    13651365        return throwError(state.exception(), args.GetIsolate());
    1366     return toV8(result.release(), v8::Handle<v8::Object>(), args.GetIsolate());
     1366    return toV8(result.release(), args.Holder(), args.GetIsolate());
    13671367}
    13681368
     
    18341834    if (UNLIKELY(ec))
    18351835        goto fail;
    1836     return toV8(result.release(), v8::Handle<v8::Object>(), args.GetIsolate());
     1836    return toV8(result.release(), args.Holder(), args.GetIsolate());
    18371837    }
    18381838    fail:
     
    19201920    if (UNLIKELY(ec))
    19211921        goto fail;
    1922     return toV8(result.release(), v8::Handle<v8::Object>(), args.GetIsolate());
     1922    return toV8(result.release(), args.Holder(), args.GetIsolate());
    19231923    }
    19241924    fail:
     
    23252325{
    23262326    v8::Handle<v8::Object> wrapper;
    2327     Frame* frame = 0;
    23282327
    23292328    v8::Handle<v8::Context> context;
     
    23352334        context->Enter();
    23362335    }
    2337     wrapper = V8DOMWrapper::instantiateV8Object(frame, &info, impl.get());
     2336
     2337    wrapper = V8DOMWrapper::instantiateV8Object(&info, impl.get());
     2338
    23382339    if (!context.IsEmpty())
    23392340        context->Exit();
     2341
    23402342    if (UNLIKELY(wrapper.IsEmpty()))
    23412343        return wrapper;
  • trunk/Source/WebCore/bindings/scripts/test/V8/V8TestSerializedScriptValueInterface.cpp

    r127946 r127955  
    297297{
    298298    v8::Handle<v8::Object> wrapper;
    299     Frame* frame = 0;
    300299
    301300    v8::Handle<v8::Context> context;
     
    307306        context->Enter();
    308307    }
    309     wrapper = V8DOMWrapper::instantiateV8Object(frame, &info, impl.get());
     308
     309    wrapper = V8DOMWrapper::instantiateV8Object(&info, impl.get());
     310
    310311    if (!context.IsEmpty())
    311312        context->Exit();
     313
    312314    if (UNLIKELY(wrapper.IsEmpty()))
    313315        return wrapper;
  • trunk/Source/WebCore/bindings/v8/V8DOMWindowShell.cpp

    r127946 r127955  
    194194void V8DOMWindowShell::disposeContext()
    195195{
     196    m_perContextData.clear();
     197
    196198    if (!m_context.isEmpty()) {
    197199        m_frame->loader()->client()->willReleaseScriptContext(m_context.get(), 0);
     
    204206        V8GCForContextDispose::instance().notifyContextDisposed(isMainFrame);
    205207    }
    206 
    207     m_perContextData.clear();
    208208}
    209209
  • trunk/Source/WebCore/bindings/v8/V8DOMWrapper.cpp

    r127946 r127955  
    158158}
    159159
    160 v8::Local<v8::Object> V8DOMWrapper::instantiateV8Object(Frame* frame, WrapperTypeInfo* type, void* impl)
    161 {
    162 #if ENABLE(WORKERS)
    163     WorkerContext* workerContext = 0;
    164 #endif
    165     if (!frame) {
    166         v8::Handle<v8::Context> context = v8::Context::GetCurrent();
    167         if (!context.IsEmpty()) {
    168             v8::Handle<v8::Object> globalPrototype = v8::Handle<v8::Object>::Cast(context->Global()->GetPrototype());
    169             if (isWrapperOfType(globalPrototype, &V8DOMWindow::info)) {
    170                 Frame* globalFrame = V8DOMWindow::toNative(globalPrototype)->frame();
    171                 if (globalFrame && globalFrame->script()->canExecuteScripts(NotAboutToExecuteScript))
    172                     frame = globalFrame;
    173             }
    174 #if ENABLE(WORKERS)
    175             else if (isWrapperOfType(globalPrototype, &V8WorkerContext::info))
    176                 workerContext = V8WorkerContext::toNative(lookupDOMWrapper(V8WorkerContext::GetTemplate(), context->Global()));
    177 #endif
    178         }
    179     }
    180 
    181     V8PerContextData* contextData = 0;
    182     if (frame)
    183         contextData = perContextDataForCurrentWorld(frame);
    184 #if ENABLE(WORKERS)
    185     else if (workerContext)
    186         contextData = perContextData(workerContext);
    187 #endif
    188 
    189     v8::Local<v8::Object> instance;
    190     if (contextData)
    191         instance = contextData->createWrapperFromCache(type);
    192     else {
    193         v8::Local<v8::Function> function = type->getTemplate()->GetFunction();
    194         instance = V8ObjectConstructor::newInstance(function);
    195     }
    196     if (!instance.IsEmpty()) {
    197         // Avoid setting the DOM wrapper for failed allocations.
    198         setDOMWrapper(instance, type, impl);
    199         if (type == &V8HTMLDocument::info)
    200             instance = V8HTMLDocument::wrapInShadowObject(instance, static_cast<Node*>(impl));
    201     }
     160v8::Local<v8::Object> V8DOMWrapper::instantiateV8Object(WrapperTypeInfo* type, void* impl)
     161{
     162    V8PerContextData* perContextData = V8PerContextData::current();
     163
     164    v8::Local<v8::Object> instance = perContextData ? perContextData->createWrapperFromCache(type) : V8ObjectConstructor::newInstance(type->getTemplate()->GetFunction());
     165
     166    // Avoid setting the DOM wrapper for failed allocations.
     167    if (instance.IsEmpty())
     168        return instance;
     169
     170    setDOMWrapper(instance, type, impl);
     171    if (type == &V8HTMLDocument::info)
     172        instance = V8HTMLDocument::wrapInShadowObject(instance, static_cast<Node*>(impl));
     173
    202174    return instance;
    203175}
  • trunk/Source/WebCore/bindings/v8/V8DOMWrapper.h

    r127946 r127955  
    120120        static void setNamedHiddenWindowReference(Frame*, const char*, v8::Handle<v8::Value>);
    121121
    122         static v8::Local<v8::Object> instantiateV8Object(Frame*, WrapperTypeInfo*, void*);
     122        static v8::Local<v8::Object> instantiateV8Object(WrapperTypeInfo*, void*);
    123123
    124124        static v8::Handle<v8::Object> getCachedWrapper(Node* node)
  • trunk/Source/WebCore/bindings/v8/V8PerContextData.cpp

    r126926 r127955  
    3232#include "V8PerContextData.h"
    3333
     34#include "V8DOMWindow.h"
    3435#include "V8ObjectConstructor.h"
     36#include "V8WorkerContext.h"
    3537
    3638namespace WebCore {
    3739
     40static const int perContextDataIndex = V8DOMWindow::perContextDataIndex;
     41COMPILE_ASSERT(V8DOMWindow::perContextDataIndex == V8WorkerContext::perContextDataIndex, DOMWindowAndWorkerContextMustHaveTheSamePerContextDataIndex);
     42
     43V8PerContextData* V8PerContextData::current()
     44{
     45    return static_cast<V8PerContextData*>(v8::Handle<v8::Object>::Cast(v8::Context::GetCurrent()->Global()->GetPrototype())->GetPointerFromInternalField(perContextDataIndex));
     46}
     47
    3848void V8PerContextData::dispose()
    3949{
     50    v8::HandleScope handleScope;
     51    v8::Handle<v8::Object>::Cast(m_context->Global()->GetPrototype())->SetPointerInInternalField(perContextDataIndex, 0);
     52
    4053    {
    4154        WrapperBoilerplateMap::iterator it = m_wrapperBoilerplates.begin();
     
    7487bool V8PerContextData::init()
    7588{
     89    v8::Handle<v8::Object>::Cast(m_context->Global()->GetPrototype())->SetPointerInInternalField(perContextDataIndex, this);
     90
    7691    v8::Handle<v8::String> prototypeString = v8::String::NewSymbol("prototype");
    7792    if (prototypeString.IsEmpty())
  • trunk/Source/WebCore/bindings/v8/V8PerContextData.h

    r126484 r127955  
    5454    bool init();
    5555
     56    static V8PerContextData* current();
     57
    5658    // To create JS Wrapper objects, we create a cache of a 'boiler plate'
    5759    // object, and then simply Clone that object each time we need a new one.
Note: See TracChangeset for help on using the changeset viewer.