Commit 243788ce authored by fpizlo@apple.com's avatar fpizlo@apple.com

JSFunction and its descendants should be destructible

https://bugs.webkit.org/show_bug.cgi?id=102062

Reviewed by Mark Hahnenberg.

This will make it easy to place an InlineWatchpointSet inside JSFunction. In the
future, we could make JSFunction non-destructible again by making a version of
WatchpointSet that is entirely GC'd, but this seems like overkill for now.
        
This is performance-neutral.

* runtime/JSBoundFunction.cpp:
(JSC::JSBoundFunction::destroy):
(JSC):
* runtime/JSBoundFunction.h:
(JSBoundFunction):
* runtime/JSFunction.cpp:
(JSC):
(JSC::JSFunction::destroy):
* runtime/JSFunction.h:
(JSFunction):



git-svn-id: http://svn.webkit.org/repository/webkit/trunk@134460 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 8f0f9737
2012-11-13 Filip Pizlo <fpizlo@apple.com>
JSFunction and its descendants should be destructible
https://bugs.webkit.org/show_bug.cgi?id=102062
Reviewed by Mark Hahnenberg.
This will make it easy to place an InlineWatchpointSet inside JSFunction. In the
future, we could make JSFunction non-destructible again by making a version of
WatchpointSet that is entirely GC'd, but this seems like overkill for now.
This is performance-neutral.
* runtime/JSBoundFunction.cpp:
(JSC::JSBoundFunction::destroy):
(JSC):
* runtime/JSBoundFunction.h:
(JSBoundFunction):
* runtime/JSFunction.cpp:
(JSC):
(JSC::JSFunction::destroy):
* runtime/JSFunction.h:
(JSFunction):
2012-11-13 Cosmin Truta <ctruta@rim.com>
Uninitialized fields in class JSLock
......
......@@ -88,6 +88,11 @@ JSBoundFunction* JSBoundFunction::create(ExecState* exec, JSGlobalObject* global
return function;
}
void JSBoundFunction::destroy(JSCell* cell)
{
static_cast<JSBoundFunction*>(cell)->JSBoundFunction::~JSBoundFunction();
}
bool JSBoundFunction::customHasInstance(JSObject* object, ExecState* exec, JSValue value)
{
return jsCast<JSBoundFunction*>(object)->m_targetFunction->hasInstance(exec, value);
......
......@@ -38,6 +38,8 @@ public:
typedef JSFunction Base;
static JSBoundFunction* create(ExecState*, JSGlobalObject*, JSObject* targetFunction, JSValue boundThis, JSValue boundArgs, int, const String&);
static void destroy(JSCell*);
static bool customHasInstance(JSObject*, ExecState*, JSValue);
......
......@@ -48,8 +48,6 @@ EncodedJSValue JSC_HOST_CALL callHostFunctionAsConstructor(ExecState* exec)
return throwVMError(exec, createNotAConstructorError(exec, exec->callee()));
}
ASSERT_HAS_TRIVIAL_DESTRUCTOR(JSFunction);
const ClassInfo JSFunction::s_info = { "Function", &Base::s_info, 0, 0, CREATE_METHOD_TABLE(JSFunction) };
bool JSFunction::isHostFunctionNonInline() const
......@@ -76,6 +74,11 @@ JSFunction* JSFunction::create(ExecState* exec, JSGlobalObject* globalObject, in
return function;
}
void JSFunction::destroy(JSCell* cell)
{
static_cast<JSFunction*>(cell)->JSFunction::~JSFunction();
}
JSFunction::JSFunction(ExecState* exec, JSGlobalObject* globalObject, Structure* structure)
: Base(exec->globalData(), structure)
, m_executable()
......
......@@ -25,6 +25,7 @@
#define JSFunction_h
#include "InternalFunction.h"
#include "JSDestructibleObject.h"
#include "JSScope.h"
namespace JSC {
......@@ -46,14 +47,14 @@ namespace JSC {
JS_EXPORT_PRIVATE String getCalculatedDisplayName(CallFrame*, JSObject*);
class JSFunction : public JSNonFinalObject {
class JSFunction : public JSDestructibleObject {
friend class JIT;
friend class DFG::SpeculativeJIT;
friend class DFG::JITCompiler;
friend class JSGlobalData;
public:
typedef JSNonFinalObject Base;
typedef JSDestructibleObject Base;
JS_EXPORT_PRIVATE static JSFunction* create(ExecState*, JSGlobalObject*, int length, const String& name, NativeFunction, Intrinsic = NoIntrinsic, NativeFunction nativeConstructor = callHostFunctionAsConstructor);
......@@ -66,6 +67,8 @@ namespace JSC {
return function;
}
static void destroy(JSCell*);
JS_EXPORT_PRIVATE String name(ExecState*);
JS_EXPORT_PRIVATE String displayName(ExecState*);
const String calculatedDisplayName(ExecState*);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment