Reviewed (and tweaked a little) by Maciej.
- shrank the size of JSObject by 8 bytes and made the corresponding reduction to the cell size, resulting
in a 1.2% speed improvement on JS iBench (and probably overall memory savings).
This was done by removing _scope and _internalValue data members
from JSObject and moving them only to the subclasses that actually
make use of them.
* kjs/object.cpp:
(KJS::JSObject::mark): No need to mark scope or internal value here.
* kjs/object.h:
(KJS::JSObject::JSObject): Don't initialize them.
* kjs/JSWrapperObject.cpp: Added. New base class for object types that
wrap primitive values (Number, String, Boolean, Date).
(KJS::JSWrapperObject::mark):
* kjs/JSWrapperObject.h: Added.
(KJS::JSWrapperObject::JSWrapperObject):
(KJS::JSWrapperObject::internalValue):
(KJS::JSWrapperObject::setInternalValue):
* kjs/array_object.cpp:
(ArrayPrototype::ArrayPrototype): Don't set useless internal value.
* kjs/bool_object.cpp:
(BooleanInstance::BooleanInstance): Inherit from JSWrapperObject.
(BooleanProtoFunc::callAsFunction): Fixed to account for fact that not all
JSObjects have an internal value.
(BooleanObjectImp::construct): ditto.
* kjs/bool_object.h:
* kjs/collector.cpp: Lowered cell size to 48.
(KJS::Collector::allocate): meaningless whitespace change
* kjs/date_object.cpp:
(KJS::DateInstance::DateInstance): Inherit from JSWrapperObject.
(KJS::DateProtoFunc::callAsFunction): adjusted for move of internalValue
(KJS::DateObjectImp::construct): ditto
* kjs/date_object.h:
* kjs/error_object.cpp:
(ErrorPrototype::ErrorPrototype): don't set internal value
* kjs/function.cpp: move _scope and related handling here
(KJS::FunctionImp::mark): mark scope
* kjs/function.h:
(KJS::FunctionImp::scope): moved here from JSObject
(KJS::FunctionImp::setScope): ditto
* kjs/number_object.cpp:
(NumberInstance::NumberInstance): inherit from JSWrapperObject
(NumberProtoFunc::callAsFunction): adjusted
(NumberObjectImp::construct): adjusted
* kjs/number_object.h: shring RegExp-related objects a little
* kjs/regexp_object.cpp:
(RegExpPrototype::RegExpPrototype): Adjust for size tweaks
(RegExpObjectImp::RegExpObjectImp): ditto
* kjs/regexp_object.h:
* kjs/string_object.cpp:
(StringInstance::StringInstance): inherit from JSWrapperObject
(StringProtoFunc::callAsFunction): adjusted
* kjs/string_object.h:
* JavaScriptCore.exp: Exported new methods as needed.
* JavaScriptCore.xcodeproj/project.pbxproj: Added new files to build.
WebCore:
Reviewed (and tweaked a little) by Maciej.
- shrank the size of JSObject by 8 bytes and made the corresponding reduction to the cell size, resulting
in a 1.2% speed improvement on JS iBench (and probably overall memory savings).
The WebCore part of this is to expect only FunctionImp to have a scope, not all JSObjects.
* bindings/js/kjs_events.cpp:
(KJS::JSLazyEventListener::parseCode):
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@15846
268f45cc-cd09-0410-ab3c-
d52691b4dbfc
+2006-08-13 Maks Orlovich <maksim@kde.org>
+
+ Reviewed (and tweaked a little) by Maciej.
+
+ - shrank the size of JSObject by 8 bytes and made the corresponding reduction to the cell size, resulting
+ in a 1.2% speed improvement on JS iBench (and probably overall memory savings).
+
+ This was done by removing _scope and _internalValue data members
+ from JSObject and moving them only to the subclasses that actually
+ make use of them.
+
+ * kjs/object.cpp:
+ (KJS::JSObject::mark): No need to mark scope or internal value here.
+ * kjs/object.h:
+ (KJS::JSObject::JSObject): Don't initialize them.
+ * kjs/JSWrapperObject.cpp: Added. New base class for object types that
+ wrap primitive values (Number, String, Boolean, Date).
+ (KJS::JSWrapperObject::mark):
+ * kjs/JSWrapperObject.h: Added.
+ (KJS::JSWrapperObject::JSWrapperObject):
+ (KJS::JSWrapperObject::internalValue):
+ (KJS::JSWrapperObject::setInternalValue):
+ * kjs/array_object.cpp:
+ (ArrayPrototype::ArrayPrototype): Don't set useless internal value.
+ * kjs/bool_object.cpp:
+ (BooleanInstance::BooleanInstance): Inherit from JSWrapperObject.
+ (BooleanProtoFunc::callAsFunction): Fixed to account for fact that not all
+ JSObjects have an internal value.
+ (BooleanObjectImp::construct): ditto.
+ * kjs/bool_object.h:
+ * kjs/collector.cpp: Lowered cell size to 48.
+ (KJS::Collector::allocate): meaningless whitespace change
+ * kjs/date_object.cpp:
+ (KJS::DateInstance::DateInstance): Inherit from JSWrapperObject.
+ (KJS::DateProtoFunc::callAsFunction): adjusted for move of internalValue
+ (KJS::DateObjectImp::construct): ditto
+ * kjs/date_object.h:
+ * kjs/error_object.cpp:
+ (ErrorPrototype::ErrorPrototype): don't set internal value
+ * kjs/function.cpp: move _scope and related handling here
+ (KJS::FunctionImp::mark): mark scope
+ * kjs/function.h:
+ (KJS::FunctionImp::scope): moved here from JSObject
+ (KJS::FunctionImp::setScope): ditto
+ * kjs/number_object.cpp:
+ (NumberInstance::NumberInstance): inherit from JSWrapperObject
+ (NumberProtoFunc::callAsFunction): adjusted
+ (NumberObjectImp::construct): adjusted
+ * kjs/number_object.h: shring RegExp-related objects a little
+ * kjs/regexp_object.cpp:
+ (RegExpPrototype::RegExpPrototype): Adjust for size tweaks
+ (RegExpObjectImp::RegExpObjectImp): ditto
+ * kjs/regexp_object.h:
+ * kjs/string_object.cpp:
+ (StringInstance::StringInstance): inherit from JSWrapperObject
+ (StringProtoFunc::callAsFunction): adjusted
+ * kjs/string_object.h:
+ * JavaScriptCore.exp: Exported new methods as needed.
+ * JavaScriptCore.xcodeproj/project.pbxproj: Added new files to build.
+
2006-08-04 Brady Eidson <beidson@apple.com>
Reviewed by Geoff's rubber stamp
-
_JSCheckScriptSyntax
_JSClassCreate
_JSClassRelease
__ZN3KJS14StringInstance4infoE
__ZN3KJS14StringInstanceC1EPNS_8JSObjectERKNS_7UStringE
__ZN3KJS14StringInstanceC2EPNS_8JSObjectERKNS_7UStringE
+__ZN3KJS15JSWrapperObject4markEv
__ZN3KJS15SavedPropertiesC1Ev
__ZN3KJS15SavedPropertiesD1Ev
__ZN3KJS16RuntimeObjectImp4infoE
__ZNK3KJS8JSObject9toBooleanEPNS_9ExecStateE
__ZNK3KJS9ExecState18lexicalInterpreterEv
__ZTVN3KJS14StringInstanceE
+__ZTVN3KJS15JSWrapperObjectE
__ZTVN3KJS19InternalFunctionImpE
__ZTVN3KJS8JSObjectE
_kJSClassDefinitionEmpty
65B174F609D100FA00820339 /* number_object.lut.h in Headers */ = {isa = PBXBuildFile; fileRef = 65B174F209D100FA00820339 /* number_object.lut.h */; };
65B174F809D100FA00820339 /* string_object.lut.h in Headers */ = {isa = PBXBuildFile; fileRef = 65B174F409D100FA00820339 /* string_object.lut.h */; };
65C647B4093EF8D60022C380 /* RefPtr.h in Headers */ = {isa = PBXBuildFile; fileRef = 65C647B3093EF8D60022C380 /* RefPtr.h */; settings = {ATTRIBUTES = (Private, ); }; };
+ 65C7A1730A8EAACB00FA37EA /* JSWrapperObject.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 65C7A1710A8EAACB00FA37EA /* JSWrapperObject.cpp */; };
+ 65C7A1740A8EAACB00FA37EA /* JSWrapperObject.h in Headers */ = {isa = PBXBuildFile; fileRef = 65C7A1720A8EAACB00FA37EA /* JSWrapperObject.h */; settings = {ATTRIBUTES = (Private, ); }; };
65D6D87F09B5A32E0002E4D7 /* Platform.h in Headers */ = {isa = PBXBuildFile; fileRef = 65D6D87E09B5A32E0002E4D7 /* Platform.h */; settings = {ATTRIBUTES = (Private, ); }; };
65D7D19C08F10B5B0015ABD8 /* FastMallocInternal.h in Headers */ = {isa = PBXBuildFile; fileRef = 65D7D19B08F10B5B0015ABD8 /* FastMallocInternal.h */; };
65DFC93008EA173A00F7300B /* HashFunctions.h in Headers */ = {isa = PBXBuildFile; fileRef = 65DFC92A08EA173A00F7300B /* HashFunctions.h */; settings = {ATTRIBUTES = (Private, ); }; };
65B174F409D100FA00820339 /* string_object.lut.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = string_object.lut.h; sourceTree = "<group>"; };
65C02FBB0637462A003E7EE6 /* protect.h */ = {isa = PBXFileReference; fileEncoding = 30; indentWidth = 4; lastKnownFileType = sourcecode.c.h; path = protect.h; sourceTree = "<group>"; tabWidth = 8; };
65C647B3093EF8D60022C380 /* RefPtr.h */ = {isa = PBXFileReference; fileEncoding = 30; indentWidth = 4; lastKnownFileType = sourcecode.c.h; path = RefPtr.h; sourceTree = "<group>"; tabWidth = 8; };
+ 65C7A1710A8EAACB00FA37EA /* JSWrapperObject.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = JSWrapperObject.cpp; sourceTree = "<group>"; };
+ 65C7A1720A8EAACB00FA37EA /* JSWrapperObject.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = JSWrapperObject.h; sourceTree = "<group>"; };
65D6D87E09B5A32E0002E4D7 /* Platform.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = Platform.h; sourceTree = "<group>"; };
65D7D19B08F10B5B0015ABD8 /* FastMallocInternal.h */ = {isa = PBXFileReference; fileEncoding = 30; indentWidth = 4; lastKnownFileType = sourcecode.c.h; path = FastMallocInternal.h; sourceTree = "<group>"; tabWidth = 8; };
65DFC92A08EA173A00F7300B /* HashFunctions.h */ = {isa = PBXFileReference; fileEncoding = 30; indentWidth = 4; lastKnownFileType = sourcecode.c.h; path = HashFunctions.h; sourceTree = "<group>"; tabWidth = 8; };
65417200039E01BA0058BFEB /* kjs */ = {
isa = PBXGroup;
children = (
+ 65C7A1710A8EAACB00FA37EA /* JSWrapperObject.cpp */,
+ 65C7A1720A8EAACB00FA37EA /* JSWrapperObject.h */,
65400C0F0A69BAF200509887 /* PropertyNameArray.cpp */,
65400C100A69BAF200509887 /* PropertyNameArray.h */,
938772E5038BFE19008635CE /* array_instance.h */,
1440FCE30A51E46B0005F061 /* JSClassRef.h in Headers */,
65400C120A69BAF200509887 /* PropertyNameArray.h in Headers */,
1CAF34890A6C421700ABE06E /* WebScriptObject.h in Headers */,
+ 65C7A1740A8EAACB00FA37EA /* JSWrapperObject.h in Headers */,
);
runOnlyForDeploymentPostprocessing = 0;
};
1440FCE40A51E46B0005F061 /* JSClassRef.cpp in Sources */,
1421359B0A677F4F00A8195E /* JSBase.cpp in Sources */,
65400C110A69BAF200509887 /* PropertyNameArray.cpp in Sources */,
+ 65C7A1730A8EAACB00FA37EA /* JSWrapperObject.cpp in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
--- /dev/null
+// -*- c-basic-offset: 2 -*-
+/*
+ * Copyright (C) 2006 Maks Orlovich
+ * Copyright (C) 2006 Apple Computer, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ *
+ */
+
+#include "JSWrapperObject.h"
+
+namespace KJS {
+
+void JSWrapperObject::mark()
+{
+ JSObject::mark();
+ if (m_internalValue && !m_internalValue->marked())
+ m_internalValue->mark();
+}
+
+} // namespace KJS
--- /dev/null
+// -*- mode: c++; c-basic-offset: 4 -*-
+/*
+ * Copyright (C) 2006 Maks Orlovich
+ * Copyright (C) 2006 Apple Computer, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ *
+ */
+
+#ifndef KJS_JSWrapperObject_h
+#define KJS_JSWrapperObject_h
+
+#include "object.h"
+
+namespace KJS {
+
+ /**
+ This class is used as a base for classes such as String,
+ Number, Boolean and Date which which are wrappers for primitive
+ types. These classes stores the internal value, which is the
+ actual value represented by the wrapper objects.
+ */
+ class JSWrapperObject : public JSObject {
+ public:
+ JSWrapperObject(JSValue* proto);
+
+ /**
+ * Returns the internal value of the object. This is used for objects such
+ * as String and Boolean which are wrappers for native types. The interal
+ * value is the actual value represented by the wrapper objects.
+ *
+ * @see ECMA 8.6.2
+ * @return The internal value of the object
+ */
+ JSValue* internalValue() const;
+
+ /**
+ * Sets the internal value of the object
+ *
+ * @see internalValue()
+ *
+ * @param v The new internal value
+ */
+ void setInternalValue(JSValue* v);
+
+ virtual void mark();
+
+ private:
+ JSValue* m_internalValue;
+ };
+
+ inline JSWrapperObject::JSWrapperObject(JSValue* proto)
+ : JSObject(proto)
+ , m_internalValue(0)
+ {
+ }
+
+ inline JSValue* JSWrapperObject::internalValue() const
+ {
+ return m_internalValue;
+ }
+
+ inline void JSWrapperObject::setInternalValue(JSValue* v)
+ {
+ ASSERT(v);
+ m_internalValue = v;
+ }
+
+} // namespace KJS
+
+#endif // KJS_JSWrapperObject_h
ArrayPrototype::ArrayPrototype(ExecState*, ObjectPrototype* objProto)
: ArrayInstance(objProto, 0)
{
- setInternalValue(jsNull());
}
bool ArrayPrototype::getOwnPropertySlot(ExecState* exec, const Identifier& propertyName, PropertySlot& slot)
const ClassInfo BooleanInstance::info = {"Boolean", 0, 0, 0};
BooleanInstance::BooleanInstance(JSObject *proto)
- : JSObject(proto)
+ : JSWrapperObject(proto)
{
}
// execute "toString()" or "valueOf()", respectively
- JSValue *v = thisObj->internalValue();
+ JSValue *v = static_cast<BooleanInstance*>(thisObj)->internalValue();
assert(v);
if (id == ToString)
// ECMA 15.6.2
JSObject *BooleanObjectImp::construct(ExecState *exec, const List &args)
{
- JSObject *obj(new BooleanInstance(exec->lexicalInterpreter()->builtinBooleanPrototype()));
+ BooleanInstance *obj(new BooleanInstance(exec->lexicalInterpreter()->builtinBooleanPrototype()));
bool b;
if (args.size() > 0)
#define BOOL_OBJECT_H_
#include "function_object.h"
+#include "JSWrapperObject.h"
namespace KJS {
- class BooleanInstance : public JSObject {
+ class BooleanInstance : public JSWrapperObject {
public:
BooleanInstance(JSObject *proto);
namespace KJS {
// tunable parameters
-const size_t MINIMUM_CELL_SIZE = 56;
+const size_t MINIMUM_CELL_SIZE = 48;
const size_t BLOCK_SIZE = (8 * 4096);
const size_t SPARE_EMPTY_BLOCKS = 2;
const size_t MIN_ARRAY_SIZE = 14;
if (s > CELL_SIZE) {
// oversize allocator
-
size_t usedOversizeCells = heap.usedOversizeCells;
size_t numOversizeCells = heap.numOversizeCells;
const ClassInfo DateInstance::info = {"Date", 0, 0, 0};
DateInstance::DateInstance(JSObject *proto)
- : JSObject(proto)
+ : JSWrapperObject(proto)
{
}
if (!thisObj->inherits(&DateInstance::info))
return throwError(exec, TypeError);
+ DateInstance* thisDateObj = static_cast<DateInstance*>(thisObj);
+
JSValue *result = 0;
UString s;
#if !PLATFORM(DARWIN)
oldlocale = setlocale(LC_ALL, 0);
// FIXME: Where's the code to set the locale back to oldlocale?
#endif
- JSValue *v = thisObj->internalValue();
+ JSValue *v = thisDateObj->internalValue();
double milli = v->toNumber(exec);
if (isNaN(milli)) {
switch (id) {
case SetTime:
milli = roundValue(exec, args[0]);
result = jsNumber(milli);
- thisObj->setInternalValue(result);
+ thisDateObj->setInternalValue(result);
break;
case SetMilliSeconds:
fillStructuresUsingTimeArgs(exec, args, 1, &ms, &t);
id == SetMinutes || id == SetHours || id == SetDate ||
id == SetMonth || id == SetFullYear ) {
result = jsNumber(makeTime(&t, ms, utc));
- thisObj->setInternalValue(result);
+ thisDateObj->setInternalValue(result);
}
return result;
value = utc;
} else if (numArgs == 1) {
if (args[0]->isObject(&DateInstance::info))
- value = static_cast<JSObject*>(args[0])->internalValue()->toNumber(exec);
+ value = static_cast<DateInstance*>(args[0])->internalValue()->toNumber(exec);
else {
JSValue* primitive = args[0]->toPrimitive(exec);
if (primitive->isString())
#define DATE_OBJECT_H
#include "internal.h"
+#include "JSWrapperObject.h"
namespace KJS {
class FunctionPrototype;
class ObjectPrototype;
- class DateInstance : public JSObject {
+ class DateInstance : public JSWrapperObject {
public:
DateInstance(JSObject *proto);
FunctionPrototype *funcProto)
: JSObject(objectProto)
{
- setInternalValue(jsUndefined());
// The constructor will be added later in ErrorObjectImp's constructor
put(exec, namePropertyName, jsString("Error"), DontEnum);
{
}
+void FunctionImp::mark()
+{
+ InternalFunctionImp::mark();
+ _scope.mark();
+}
+
FunctionImp::~FunctionImp()
{
}
RefPtr<FunctionBodyNode> body;
+ /**
+ * Returns the scope of this object. This is used when execution declared
+ * functions - the execution context for the function is initialized with
+ * extra object in it's scope. An example of this is functions declared
+ * inside other functions:
+ *
+ * \code
+ * function f() {
+ *
+ * function b() {
+ * return prototype;
+ * }
+ *
+ * var x = 4;
+ * // do some stuff
+ * }
+ * f.prototype = new String();
+ * \endcode
+ *
+ * When the function f.b is executed, its scope will include properties of
+ * f. So in the example above the return value of f.b() would be the new
+ * String object that was assigned to f.prototype.
+ *
+ * @param exec The current execution state
+ * @return The function's scope
+ */
+ const ScopeChain &scope() const { return _scope; }
+ void setScope(const ScopeChain &s) { _scope = s; }
+
+ virtual void mark();
protected:
OwnPtr<Parameter> param;
private:
+ ScopeChain _scope;
+
static JSValue *argumentsGetter(ExecState *, JSObject *, const Identifier &, const PropertySlot&);
static JSValue *lengthGetter(ExecState *, JSObject *, const Identifier &, const PropertySlot&);
const ClassInfo NumberInstance::info = {"Number", 0, 0, 0};
NumberInstance::NumberInstance(JSObject *proto)
- : JSObject(proto)
+ : JSWrapperObject(proto)
{
}
// ------------------------------ NumberPrototype ---------------------------
if (!thisObj->inherits(&NumberInstance::info))
return throwError(exec, TypeError);
- JSValue *v = thisObj->internalValue();
+ JSValue *v = static_cast<NumberInstance*>(thisObj)->internalValue();
switch (id) {
case ToString: {
double dradix = 10;
JSObject *NumberObjectImp::construct(ExecState *exec, const List &args)
{
JSObject *proto = exec->lexicalInterpreter()->builtinNumberPrototype();
- JSObject *obj(new NumberInstance(proto));
+ NumberInstance *obj(new NumberInstance(proto));
double n;
if (args.isEmpty())
#define NUMBER_OBJECT_H_
#include "function_object.h"
+#include "JSWrapperObject.h"
namespace KJS {
- class NumberInstance : public JSObject {
+ class NumberInstance : public JSWrapperObject {
public:
NumberInstance(JSObject *proto);
proto->mark();
_prop.mark();
-
- if (_internalValue && !_internalValue->marked())
- _internalValue->mark();
-
- _scope.mark();
}
JSType JSObject::type() const
*/
virtual bool hasInstance(ExecState *exec, JSValue *value);
- /**
- * Returns the scope of this object. This is used when execution declared
- * functions - the execution context for the function is initialized with
- * extra object in it's scope. An example of this is functions declared
- * inside other functions:
- *
- * \code
- * function f() {
- *
- * function b() {
- * return prototype;
- * }
- *
- * var x = 4;
- * // do some stuff
- * }
- * f.prototype = new String();
- * \endcode
- *
- * When the function f.b is executed, its scope will include properties of
- * f. So in the example above the return value of f.b() would be the new
- * String object that was assigned to f.prototype.
- *
- * @param exec The current execution state
- * @return The function's scope
- */
- const ScopeChain &scope() const { return _scope; }
- void setScope(const ScopeChain &s) { _scope = s; }
-
virtual void getPropertyNames(ExecState*, PropertyNameArray&);
- /**
- * Returns the internal value of the object. This is used for objects such
- * as String and Boolean which are wrappers for native types. The interal
- * value is the actual value represented by the wrapper objects.
- *
- * @see ECMA 8.6.2
- * @return The internal value of the object
- */
- JSValue *internalValue() const;
-
- /**
- * Sets the internal value of the object
- *
- * @see internalValue()
- *
- * @param v The new internal value
- */
- void setInternalValue(JSValue *v);
-
virtual JSValue *toPrimitive(ExecState *exec, JSType preferredType = UnspecifiedType) const;
virtual bool toBoolean(ExecState *exec) const;
virtual double toNumber(ExecState *exec) const;
private:
const HashEntry* findPropertyHashEntry( const Identifier& propertyName ) const;
JSValue *_proto;
- JSValue *_internalValue;
- ScopeChain _scope;
};
/**
inline JSObject::JSObject(JSValue* proto, bool destructorIsThreadSafe)
: JSCell(destructorIsThreadSafe)
, _proto(proto)
- , _internalValue(0)
{
assert(proto);
}
inline JSObject::JSObject(bool destructorIsThreadSafe)
: JSCell(destructorIsThreadSafe)
, _proto(jsNull())
- , _internalValue(0)
{
}
-inline JSValue *JSObject::internalValue() const
-{
- return _internalValue;
-}
-
-inline void JSObject::setInternalValue(JSValue *v)
-{
- _internalValue = v;
-}
-
inline JSValue *JSObject::prototype() const
{
return _proto;
return false;
}
+
// FIXME: Put this function in a separate file named something like scope_chain_mark.h -- can't put it in scope_chain.h since it depends on JSObject.
inline void ScopeChain::mark()
// ------------------------------ RegExpPrototype ---------------------------
-// ECMA 15.9.4
+// ECMA 15.10.5
const ClassInfo RegExpPrototype::info = {"RegExpPrototype", 0, 0, 0};
FunctionPrototype *funcProto)
: JSObject(objProto)
{
- setInternalValue(jsString(""));
-
// The constructor will be added later in RegExpObject's constructor (?)
static const Identifier execPropertyName("exec");
RegExpObjectImp::RegExpObjectImp(ExecState*, FunctionPrototype* funcProto, RegExpPrototype* regProto)
- : InternalFunctionImp(funcProto), multiline(false), lastInput(""), lastNumSubPatterns(0)
+ : InternalFunctionImp(funcProto), lastInput(""), lastNumSubPatterns(0), multiline(false)
{
// ECMA 15.10.5.1 RegExp.prototype
putDirect(prototypePropertyName, regProto, DontEnum|DontDelete|ReadOnly);
JSValue *getRightContext() const;
// Global search cache / settings
- bool multiline;
UString lastInput;
OwnArrayPtr<int> lastOvector;
- unsigned lastNumSubPatterns;
+ unsigned lastNumSubPatterns : 31;
+ bool multiline : 1;
static const ClassInfo info;
};
#include "string_object.h"
#include "string_object.lut.h"
+#include "JSWrapperObject.h"
#include "error_object.h"
#include "operations.h"
#include "PropertyNameArray.h"
const ClassInfo StringInstance::info = {"String", 0, 0, 0};
StringInstance::StringInstance(JSObject *proto)
- : JSObject(proto)
+ : JSWrapperObject(proto)
{
setInternalValue(jsString(""));
}
StringInstance::StringInstance(JSObject *proto, const UString &string)
- : JSObject(proto)
+ : JSWrapperObject(proto)
{
setInternalValue(jsString(string));
}
if (!thisObj || !thisObj->inherits(&StringInstance::info))
return throwError(exec, TypeError);
- return jsString(thisObj->internalValue()->toString(exec));
+ return jsString(static_cast<StringInstance*>(thisObj)->internalValue()->toString(exec));
}
UString u, u2, u3;
#define STRING_OBJECT_H_
#include "function_object.h"
+#include "JSWrapperObject.h"
namespace KJS {
- class StringInstance : public JSObject {
+ class StringInstance : public JSWrapperObject {
public:
StringInstance(JSObject *proto);
StringInstance(JSObject *proto, const UString &string);
+2006-08-13 Maks Orlovich <maksim@kde.org>
+
+ Reviewed (and tweaked a little) by Maciej.
+
+ - shrank the size of JSObject by 8 bytes and made the corresponding reduction to the cell size, resulting
+ in a 1.2% speed improvement on JS iBench (and probably overall memory savings).
+
+ The WebCore part of this is to expect only FunctionImp to have a scope, not all JSObjects.
+
+ * bindings/js/kjs_events.cpp:
+ (KJS::JSLazyEventListener::parseCode):
+
2006-08-12 Eric Seidel <eric@eseidel.com>
Reviewed by hyatt and mjs.
args.append(jsString(code));
listener = constr->construct(exec, args, m_functionName, sourceURL, lineNumber); // ### is globalExec ok ?
+ FunctionImp* listenerAsFunction = static_cast<FunctionImp*>(listener.get());
+
if (exec->hadException()) {
exec->clearException();
} else if (originalNode) {
// Add the event's home element to the scope
// (and the document, and the form - see JSHTMLElement::eventHandlerScope)
- ScopeChain scope = listener->scope();
+ ScopeChain scope = listenerAsFunction->scope();
JSValue* thisObj = toJS(exec, originalNode);
if (thisObj->isObject()) {
static_cast<DOMEventTargetNode*>(thisObj)->pushEventHandlerScope(exec, scope);
- listener->setScope(scope);
+ listenerAsFunction->setScope(scope);
}
}
}
--- /dev/null
+/*
+ Copyright (C) 2004 Apple Computer, Inc. All rights reserved.
+*/
+#ifndef _WEB_SCRIPT_OBJECT_PRIVATE_H_
+#define _WEB_SCRIPT_OBJECT_PRIVATE_H_
+
+#import "WebScriptObject.h"
+
+#include <JavaScriptCore/internal.h>
+#include <JavaScriptCore/runtime_root.h>
+
+@interface WebScriptObject (Private)
++ (id)_convertValueToObjcValue:(KJS::JSValue *)value originExecutionContext:(const KJS::Bindings::RootObject *)originExecutionContext executionContext:(const KJS::Bindings::RootObject *)executionContext;
+- _init;
+- _initWithJSObject:(KJS::JSObject *)imp originExecutionContext:(const KJS::Bindings::RootObject *)originExecutionContext executionContext:(const KJS::Bindings::RootObject *)executionContext ;
+- (void)_initializeWithObjectImp:(KJS::JSObject *)imp originExecutionContext:(const KJS::Bindings::RootObject *)originExecutionContext executionContext:(const KJS::Bindings::RootObject *)executionContext ;
+- (void)_initializeScriptDOMNodeImp;
+- (KJS::JSObject *)_imp;
+- (void)_setExecutionContext:(const KJS::Bindings::RootObject *)context;
+- (const KJS::Bindings::RootObject *)_executionContext;
+- (void)_setOriginExecutionContext:(const KJS::Bindings::RootObject *)originExecutionContext;
+- (const KJS::Bindings::RootObject *)_originExecutionContext;
+@end
+
+@interface WebScriptObjectPrivate : NSObject
+{
+@public
+ KJS::JSObject *imp;
+ const KJS::Bindings::RootObject *executionContext;
+ const KJS::Bindings::RootObject *originExecutionContext;
+ BOOL isCreatedByDOMWrapper;
+}
+@end
+
+
+#endif