Changeset 62650 in webkit


Ignore:
Timestamp:
Jul 7, 2010 3:27:46 AM (14 years ago)
Author:
steveblock@google.com
Message:

2010-07-07 Steve Block <steveblock@google.com>

Reviewed by Adam Barth.

JavaInstanceV8 needs to push a local reference frame to avoid table overflow.
https://bugs.webkit.org/show_bug.cgi?id=41516

This change is required to help prevent the Java virtual machine from
running out of local references. The Java virtual machine supports only
a limited number of local references. Normally, local references are
cleared when the native method returns.

This change adds calls to PushLocalFrame() and PopLocalFrame() around
each invocation of a method on JavaInstance. These calls instruct the
virtual machine to clear local references when the frame is popped.
This means that in the case where many calls to JavaInstance methods
are made within the same native call, local references are cleared as
soon as they are no longer needed, thus conserving references.

This change mirrors exactly JavaInstanceJSC.

No new tests.

  • bridge/jni/v8/JavaInstanceV8.cpp: (JavaInstance::virtualBegin): (JavaInstance::virtualEnd):
  • bridge/jni/v8/JavaInstanceV8.h:
Location:
trunk/WebCore
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/WebCore/ChangeLog

    r62647 r62650  
     12010-07-07  Steve Block  <steveblock@google.com>
     2
     3        Reviewed by Adam Barth.
     4
     5        JavaInstanceV8 needs to push a local reference frame to avoid table overflow.
     6        https://bugs.webkit.org/show_bug.cgi?id=41516
     7
     8        This change is required to help prevent the Java virtual machine from
     9        running out of local references. The Java virtual machine supports only
     10        a limited number of local references. Normally, local references are
     11        cleared when the native method returns.
     12
     13        This change adds calls to PushLocalFrame() and PopLocalFrame() around
     14        each invocation of a method on JavaInstance. These calls instruct the
     15        virtual machine to clear local references when the frame is popped.
     16        This means that in the case where many calls to JavaInstance methods
     17        are made within the same native call, local references are cleared as
     18        soon as they are no longer needed, thus conserving references.
     19
     20        This change mirrors exactly JavaInstanceJSC.
     21
     22        No new tests.
     23
     24        * bridge/jni/v8/JavaInstanceV8.cpp:
     25        (JavaInstance::virtualBegin):
     26        (JavaInstance::virtualEnd):
     27        * bridge/jni/v8/JavaInstanceV8.h:
     28
    1292010-07-06  Yury Semikhatsky  <yurys@chromium.org>
    230
  • trunk/WebCore/bridge/jni/v8/JavaInstanceV8.cpp

    r54165 r62650  
    3333
    3434#include <assert.h>
    35 #include <utils/Log.h>
    36 
    37 #define LOG_TAG "v8binding"
    3835
    3936using namespace JSC::Bindings;
     
    4946    m_instance = 0;
    5047    delete m_class;
     48}
     49
     50#define NUM_LOCAL_REFS 64
     51
     52void JavaInstance::virtualBegin()
     53{
     54    getJNIEnv()->PushLocalFrame(NUM_LOCAL_REFS);
     55}
     56
     57void JavaInstance::virtualEnd()
     58{
     59    getJNIEnv()->PopLocalFrame(0);
    5160}
    5261
     
    8089        }
    8190    }
    82     if (!method) {
    83         LOGW("unable to find an appropiate method\n");
     91    if (!method)
    8492        return false;
    85     }
    8693
    8794    const JavaMethod* jMethod = static_cast<const JavaMethod*>(method);
     
    157164    m_instance = m_env->NewGlobalRef(instance);
    158165
    159     LOGV("new global ref %p for %p\n", m_instance, instance);
    160 
    161166    if (!m_instance)
    162167        fprintf(stderr, "%s:  could not get GlobalRef for %p\n", __PRETTY_FUNCTION__, instance);
     
    165170JObjectWrapper::~JObjectWrapper()
    166171{
    167     LOGV("deleting global ref %p\n", m_instance);
    168172    m_env->DeleteGlobalRef(m_instance);
    169173}
  • trunk/WebCore/bridge/jni/v8/JavaInstanceV8.h

    r54596 r62650  
    9090    mutable JavaClass* m_class;
    9191
    92     virtual void virtualBegin() {}
    93     virtual void virtualEnd() {}
     92    virtual void virtualBegin();
     93    virtual void virtualEnd();
    9494};
    9595
Note: See TracChangeset for help on using the changeset viewer.