[V8] Do not create a local handle for a cached v8 string that is returned to V8 immed...
authorharaken@chromium.org <haraken@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 11 Jan 2013 19:27:39 +0000 (19:27 +0000)
committerharaken@chromium.org <haraken@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 11 Jan 2013 19:27:39 +0000 (19:27 +0000)
commit0cb5d924f25e54c5f695683132c5e3295dcaa1ff
treef2e743a65c9fbcf4876cbf500c3b457e36766632
parent56997c3490501acec45b62a945297b800f31f010
[V8] Do not create a local handle for a cached v8 string that is returned to V8 immediately
https://bugs.webkit.org/show_bug.cgi?id=106557

Reviewed by Adam Barth.

Currently we are always creating a local handle for a cached
V8 string returned to V8:

  Handle<Value> v8String(StringImpl* impl, Isolate* isolate) {
    ...;
    return Local<String>::New(isolate, m_cachedString);
  }

However, we don't need to create a local handle in a case
where it is guaranteed that no V8 object allocation is conducted
before a control flow returns back to V8. In particular, in a case
where a cached V8 string is immediately returned to V8, we don't
need to create a local handle:

  Handle<Value> xxxxAttrGetter() {
    ...;
    return v8String(imp->xxxx(), isolate);  // This can return a persistent handle safely.
  }

This patch improves performance of div.id by 9.2%.

No tests. No change in behavior.

* bindings/scripts/CodeGeneratorV8.pm:
(GenerateNormalAttrGetter):
(GenerateCallbackImplementation):
(GenerateFunctionCallString):
(NativeToJSValue):
* bindings/scripts/test/V8/V8TestEventConstructor.cpp:
(WebCore::TestEventConstructorV8Internal::attr1AttrGetter):
(WebCore::TestEventConstructorV8Internal::attr2AttrGetter):
* bindings/scripts/test/V8/V8TestException.cpp:
(WebCore::TestExceptionV8Internal::nameAttrGetter):
* bindings/scripts/test/V8/V8TestInterface.cpp:
(WebCore::TestInterfaceV8Internal::supplementalStaticAttrAttrGetter):
(WebCore::TestInterfaceV8Internal::supplementalStr1AttrGetter):
(WebCore::TestInterfaceV8Internal::supplementalStr2AttrGetter):
* bindings/scripts/test/V8/V8TestObj.cpp:
(WebCore::TestObjV8Internal::readOnlyStringAttrAttrGetter):
(WebCore::TestObjV8Internal::staticStringAttrAttrGetter):
(WebCore::TestObjV8Internal::stringAttrAttrGetter):
(WebCore::TestObjV8Internal::reflectedStringAttrAttrGetter):
(WebCore::TestObjV8Internal::reflectedURLAttrAttrGetter):
(WebCore::TestObjV8Internal::reflectedCustomURLAttrAttrGetter):
(WebCore::TestObjV8Internal::stringAttrWithGetterExceptionAttrGetter):
(WebCore::TestObjV8Internal::stringAttrWithSetterExceptionAttrGetter):
(WebCore::TestObjV8Internal::hashAttrGetter):
(WebCore::TestObjV8Internal::conditionalMethod1Callback):
* bindings/v8/V8Binding.h:
(WebCore::v8String):
(WebCore::v8StringOrNull):
(WebCore::v8StringOrUndefined):
* bindings/v8/V8ValueCache.cpp:
(WebCore::StringCache::v8ExternalStringSlow):
* bindings/v8/V8ValueCache.h:
(WebCore::StringCache::v8ExternalString):
(StringCache):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@139469 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Source/WebCore/ChangeLog
Source/WebCore/bindings/scripts/CodeGeneratorV8.pm
Source/WebCore/bindings/scripts/test/V8/V8TestEventConstructor.cpp
Source/WebCore/bindings/scripts/test/V8/V8TestException.cpp
Source/WebCore/bindings/scripts/test/V8/V8TestInterface.cpp
Source/WebCore/bindings/scripts/test/V8/V8TestObj.cpp
Source/WebCore/bindings/v8/V8Binding.h
Source/WebCore/bindings/v8/V8ValueCache.cpp
Source/WebCore/bindings/v8/V8ValueCache.h