Commit 74e6ed63 authored by darin@apple.com's avatar darin@apple.com
Browse files

JavaScriptCore:

2008-10-22  Darin Adler  <darin@apple.com>

        Reviewed by Sam Weinig.

        - fix https://bugs.webkit.org/show_bug.cgi?id=21294
          Bug 21294: Devirtualize getOwnPropertySlot()

        A bit over 3% faster on V8 tests.

        * JavascriptCore.exp: Export leak-related functions..

        * API/JSCallbackConstructor.h:
        (JSC::JSCallbackConstructor::createStructureID): Set HasStandardGetOwnPropertySlot
        since this class doesn't override getPropertySlot.
        * API/JSCallbackFunction.h:
        (JSC::JSCallbackFunction::createStructureID): Ditto.

        * VM/ExceptionHelpers.cpp:
        (JSC::InterruptedExecutionError::InterruptedExecutionError): Use a structure
        that's created just for this class instead of trying to share a single "null
        prototype" structure.

        * VM/Machine.cpp:
        (JSC::Machine::cti_op_create_arguments_no_params): Rename
        Arguments::ArgumentsNoParameters to Arguments::NoParameters.
        
        * kjs/Arguments.h: Rename the enum from Arguments::ArgumentsParameters to
        Arguments::NoParametersType and the value from Arguments::ArgumentsNoParameters
        to Arguments::NoParameters.
        (JSC::Arguments::createStructureID): Added. Returns a structure without
        HasStandardGetOwnPropertySlot since this class overrides getOwnPropertySlot.
        (JSC::Arguments::Arguments): Added an assertion that there are no parameters.

        * kjs/DatePrototype.h:
        (JSC::DatePrototype::createStructureID): Added. Returns a structure without
        HasStandardGetOwnPropertySlot since this class overrides getOwnPropertySlot.

        * kjs/FunctionPrototype.h:
        (JSC::FunctionPrototype::createStructureID): Set HasStandardGetOwnPropertySlot
        since this class doesn't override getPropertySlot.
        * kjs/InternalFunction.h:
        (JSC::InternalFunction::createStructureID): Ditto.

        * kjs/JSArray.h:
        (JSC::JSArray::createStructureID): Added. Returns a structure without
        HasStandardGetOwnPropertySlot since this class overrides getOwnPropertySlot.

        * kjs/JSCell.h: Added declaration of fastGetOwnPropertySlot; a non-virtual
        version that uses the structure bit to decide whether to call the virtual
        version.

        * kjs/JSFunction.h:
        (JSC::JSFunction::createStructureID): Added. Returns a structure without
        HasStandardGetOwnPropertySlot since this class overrides getOwnPropertySlot.

        * kjs/JSGlobalData.cpp:
        (JSC::JSGlobalData::JSGlobalData): Initialize new structures; removed
        nullProtoStructureID.
        * kjs/JSGlobalData.h: Added new structures. Removed nullProtoStructureID.

        * kjs/JSGlobalObject.h:
        (JSC::JSGlobalObject::createStructureID): Added. Returns a structure without
        HasStandardGetOwnPropertySlot since this class overrides getOwnPropertySlot.

        * kjs/JSNotAnObject.h:
        (JSC::JSNotAnObjectErrorStub::JSNotAnObjectErrorStub): Use a structure
        that's created just for this class instead of trying to share a single "null
        prototype" structure.
        (JSC::JSNotAnObjectErrorStub::isNotAnObjectErrorStub): Marked this function
        virtual for clarity and made it private since no one should call it if they
        already have a pointer to this specific type.
        (JSC::JSNotAnObject::JSNotAnObject): Use a structure that's created just
        for this class instead of trying to share a single "null prototype" structure.
        (JSC::JSNotAnObject::createStructureID): Added. Returns a structure without
        HasStandardGetOwnPropertySlot since this class overrides getOwnPropertySlot.

        * kjs/JSObject.h:
        (JSC::JSObject::createStructureID): Added HasStandardGetOwnPropertySlot.
        (JSC::JSObject::inlineGetOwnPropertySlot): Added. Used so we can share code
        between getOwnPropertySlot and fastGetOwnPropertySlot.
        (JSC::JSObject::getOwnPropertySlot): Moved so that functions are above the
        functions that call them. Moved the guts of this function into
        inlineGetOwnPropertySlot.
        (JSC::JSCell::fastGetOwnPropertySlot): Added. Checks the
        HasStandardGetOwnPropertySlot bit and if it's set, calls
        inlineGetOwnPropertySlot, otherwise calls getOwnPropertySlot.
        (JSC::JSObject::getPropertySlot): Changed to call fastGetOwnPropertySlot.
        (JSC::JSValue::get): Changed to call fastGetOwnPropertySlot.

        * kjs/JSWrapperObject.h: Made constructor protected to emphasize that
        this class is only a base class and never instantiated.

        * kjs/MathObject.h:
        (JSC::MathObject::createStructureID): Added. Returns a structure without
        HasStandardGetOwnPropertySlot since this class overrides getOwnPropertySlot.
        * kjs/NumberConstructor.h:
        (JSC::NumberConstructor::createStructureID): Ditto.
        * kjs/RegExpConstructor.h:
        (JSC::RegExpConstructor::createStructureID): Ditto.
        * kjs/RegExpObject.h:
        (JSC::RegExpObject::createStructureID): Ditto.
        * kjs/StringObject.h:
        (JSC::StringObject::createStructureID): Ditto.

        * kjs/TypeInfo.h: Added HasStandardGetOwnPropertySlot flag and
        hasStandardGetOwnPropertySlot accessor function.

JavaScriptGlue:

2008-10-22  Darin Adler  <darin@apple.com>

        Reviewed by Sam Weinig.

        - fix https://bugs.webkit.org/show_bug.cgi?id=21294
          Bug 21294: Devirtualize getOwnPropertySlot()

        * JSRun.cpp:
        (JSGlueGlobalObject::JSGlueGlobalObject): Moved constructor here.
        Set up flags in its new location in global object data, and set up
        a structure for UserObjectImp too.
        (JSRun::JSRun): Added code to give the JSGlueGlobalObject its own unique
        structure, rather than using the default one from JSGlobalObject.

        * JSRun.h: Made JSGlueGlobalObject take a structure ID. Also moved
        the data into a separate data object. And added userObjectStructure,
        a Structure to be used by UserObjectImp.

        * JSUtils.cpp: Removed unused sharedGlobalData global.
        (JSObjectKJSValue): Pass Structure in when creating UserObjectImp.
        (unprotectGlobalObject): Use JSGlueGLobalObject type specifically.
        (initializeGlobalObjectKey): Removed code to set up unused sharedGlobalData.
        (getThreadGlobalObject): Added. Shared by JSObjectKJSValue and
        getThreadGlobalExecState. Also now passes in a structure ID when creating
        the global object.
        (getThreadGlobalExecState): Changed to call getThreadGlobalObject.

        * UserObjectImp.cpp:
        (UserObjectImp::UserObjectImp): Changed to take a structure.
        * UserObjectImp.h:
        (UserObjectImp::createStructureID): Added. Returns a structure without
        HasStandardGetOwnPropertySlot since this class overrides getOwnPropertySlot.

WebCore:

2008-10-22  Darin Adler  <darin@apple.com>

        Reviewed by Sam Weinig.

        - fix https://bugs.webkit.org/show_bug.cgi?id=21294
          Bug 21294: Devirtualize getOwnPropertySlot()

        * bindings/js/JSDOMWindowShell.h:
        (WebCore::JSDOMWindowShell::createStructureID): Added. Returns a structure without
        HasStandardGetOwnPropertySlot since this class overrides getOwnPropertySlot.

        * bindings/js/JSInspectorCallbackWrapper.cpp:
        (WebCore::JSInspectorCallbackWrapper::wrap): Change to use a unique structure
        for this class rather than sharing nullProtoStructureID, which no longer exists.

        * bindings/js/JSNamedNodesCollection.h:
        (WebCore::JSNamedNodesCollection::createStructureID): Added. Returns a structure without
        HasStandardGetOwnPropertySlot since this class overrides getOwnPropertySlot.
        * bindings/js/JSRGBColor.h:
        (WebCore::JSRGBColor::createStructureID): Ditto.

        * bindings/scripts/CodeGeneratorJS.pm: Added createStructureID functions for the wrappers,
        constructors, and prototypes in any case where they override getOwnPropertySlot, without
        HasStandardGetOwnPropertySlot.

        * bridge/objc/objc_runtime.h:
        (JSC::Bindings::ObjcFallbackObjectImp::createStructureID): Added. Returns a structure
        without HasStandardGetOwnPropertySlot since this class overrides getOwnPropertySlot.
        * bridge/qt/qt_runtime.h:
        (JSC::Bindings::QtRuntimeMethod::createStructureID): Ditto.
        * bridge/runtime_array.h:
        (JSC::RuntimeArray::createStructureID): Ditto.
        * bridge/runtime_method.h:
        (JSC::RuntimeMethod::createStructureID): Ditto.
        * bridge/runtime_object.h:
        (JSC::RuntimeObjectImp::createStructureID): Ditto.



git-svn-id: http://svn.webkit.org/repository/webkit/trunk@37799 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 21fec10d
......@@ -41,7 +41,7 @@ public:
static PassRefPtr<StructureID> createStructureID(JSValuePtr proto)
{
return StructureID::create(proto, TypeInfo(ObjectType, ImplementsHasInstance));
return StructureID::create(proto, TypeInfo(ObjectType, ImplementsHasInstance | HasStandardGetOwnPropertySlot));
}
private:
......
......@@ -41,7 +41,7 @@ public:
// refactor the code so this override isn't necessary
static PassRefPtr<StructureID> createStructureID(JSValuePtr proto)
{
return StructureID::create(proto, TypeInfo(ObjectType));
return StructureID::create(proto, TypeInfo(ObjectType, HasStandardGetOwnPropertySlot));
}
private:
......
2008-10-22 Darin Adler <darin@apple.com>
Reviewed by Sam Weinig.
- fix https://bugs.webkit.org/show_bug.cgi?id=21294
Bug 21294: Devirtualize getOwnPropertySlot()
A bit over 3% faster on V8 tests.
* JavascriptCore.exp: Export leak-related functions..
* API/JSCallbackConstructor.h:
(JSC::JSCallbackConstructor::createStructureID): Set HasStandardGetOwnPropertySlot
since this class doesn't override getPropertySlot.
* API/JSCallbackFunction.h:
(JSC::JSCallbackFunction::createStructureID): Ditto.
* VM/ExceptionHelpers.cpp:
(JSC::InterruptedExecutionError::InterruptedExecutionError): Use a structure
that's created just for this class instead of trying to share a single "null
prototype" structure.
* VM/Machine.cpp:
(JSC::Machine::cti_op_create_arguments_no_params): Rename
Arguments::ArgumentsNoParameters to Arguments::NoParameters.
* kjs/Arguments.h: Rename the enum from Arguments::ArgumentsParameters to
Arguments::NoParametersType and the value from Arguments::ArgumentsNoParameters
to Arguments::NoParameters.
(JSC::Arguments::createStructureID): Added. Returns a structure without
HasStandardGetOwnPropertySlot since this class overrides getOwnPropertySlot.
(JSC::Arguments::Arguments): Added an assertion that there are no parameters.
* kjs/DatePrototype.h:
(JSC::DatePrototype::createStructureID): Added. Returns a structure without
HasStandardGetOwnPropertySlot since this class overrides getOwnPropertySlot.
* kjs/FunctionPrototype.h:
(JSC::FunctionPrototype::createStructureID): Set HasStandardGetOwnPropertySlot
since this class doesn't override getPropertySlot.
* kjs/InternalFunction.h:
(JSC::InternalFunction::createStructureID): Ditto.
* kjs/JSArray.h:
(JSC::JSArray::createStructureID): Added. Returns a structure without
HasStandardGetOwnPropertySlot since this class overrides getOwnPropertySlot.
* kjs/JSCell.h: Added declaration of fastGetOwnPropertySlot; a non-virtual
version that uses the structure bit to decide whether to call the virtual
version.
* kjs/JSFunction.h:
(JSC::JSFunction::createStructureID): Added. Returns a structure without
HasStandardGetOwnPropertySlot since this class overrides getOwnPropertySlot.
* kjs/JSGlobalData.cpp:
(JSC::JSGlobalData::JSGlobalData): Initialize new structures; removed
nullProtoStructureID.
* kjs/JSGlobalData.h: Added new structures. Removed nullProtoStructureID.
* kjs/JSGlobalObject.h:
(JSC::JSGlobalObject::createStructureID): Added. Returns a structure without
HasStandardGetOwnPropertySlot since this class overrides getOwnPropertySlot.
* kjs/JSNotAnObject.h:
(JSC::JSNotAnObjectErrorStub::JSNotAnObjectErrorStub): Use a structure
that's created just for this class instead of trying to share a single "null
prototype" structure.
(JSC::JSNotAnObjectErrorStub::isNotAnObjectErrorStub): Marked this function
virtual for clarity and made it private since no one should call it if they
already have a pointer to this specific type.
(JSC::JSNotAnObject::JSNotAnObject): Use a structure that's created just
for this class instead of trying to share a single "null prototype" structure.
(JSC::JSNotAnObject::createStructureID): Added. Returns a structure without
HasStandardGetOwnPropertySlot since this class overrides getOwnPropertySlot.
* kjs/JSObject.h:
(JSC::JSObject::createStructureID): Added HasStandardGetOwnPropertySlot.
(JSC::JSObject::inlineGetOwnPropertySlot): Added. Used so we can share code
between getOwnPropertySlot and fastGetOwnPropertySlot.
(JSC::JSObject::getOwnPropertySlot): Moved so that functions are above the
functions that call them. Moved the guts of this function into
inlineGetOwnPropertySlot.
(JSC::JSCell::fastGetOwnPropertySlot): Added. Checks the
HasStandardGetOwnPropertySlot bit and if it's set, calls
inlineGetOwnPropertySlot, otherwise calls getOwnPropertySlot.
(JSC::JSObject::getPropertySlot): Changed to call fastGetOwnPropertySlot.
(JSC::JSValue::get): Changed to call fastGetOwnPropertySlot.
* kjs/JSWrapperObject.h: Made constructor protected to emphasize that
this class is only a base class and never instantiated.
* kjs/MathObject.h:
(JSC::MathObject::createStructureID): Added. Returns a structure without
HasStandardGetOwnPropertySlot since this class overrides getOwnPropertySlot.
* kjs/NumberConstructor.h:
(JSC::NumberConstructor::createStructureID): Ditto.
* kjs/RegExpConstructor.h:
(JSC::RegExpConstructor::createStructureID): Ditto.
* kjs/RegExpObject.h:
(JSC::RegExpObject::createStructureID): Ditto.
* kjs/StringObject.h:
(JSC::StringObject::createStructureID): Ditto.
* kjs/TypeInfo.h: Added HasStandardGetOwnPropertySlot flag and
hasStandardGetOwnPropertySlot accessor function.
2008-10-22 Cameron Zwarich <zwarich@apple.com>
Reviewed by Geoff Garen.
......
......@@ -112,6 +112,8 @@ __ZN3JSC11ProgramNode6createEPNS_12JSGlobalDataEPNS_14SourceElementsEPN3WTF6Vect
__ZN3JSC11PropertyMap3getERKNS_10IdentifierERj
__ZN3JSC11PropertyMap3putERKNS_10IdentifierEj
__ZN3JSC11PropertyMapD1Ev
__ZN3JSC11StructureID17stopIgnoringLeaksEv
__ZN3JSC11StructureID18startIgnoringLeaksEv
__ZN3JSC11StructureID21addPropertyTransitionEPS0_RKNS_10IdentifierEjRm
__ZN3JSC11StructureID21clearEnumerationCacheEv
__ZN3JSC11StructureID24fromDictionaryTransitionEPS0_
......
......@@ -51,7 +51,7 @@ static void substitute(UString& string, const UString& substring)
class InterruptedExecutionError : public JSObject {
public:
InterruptedExecutionError(JSGlobalData* globalData)
: JSObject(globalData->nullProtoStructureID)
: JSObject(globalData->interruptedExecutionErrorStructure)
{
}
......
......@@ -4825,7 +4825,7 @@ void Machine::cti_op_create_arguments_no_params(CTI_ARGS)
{
CTI_STACK_HACK();
Arguments* arguments = new (ARG_globalData) Arguments(ARG_callFrame, Arguments::ArgumentsNoParameters);
Arguments* arguments = new (ARG_globalData) Arguments(ARG_callFrame, Arguments::NoParameters);
ARG_callFrame->setCalleeArguments(arguments);
ARG_callFrame[RegisterFile::ArgumentsRegister] = arguments;
}
......
......@@ -53,12 +53,10 @@ namespace JSC {
class Arguments : public JSObject {
public:
enum ArgumentsParameters {
ArgumentsNoParameters
};
enum NoParametersType { NoParameters };
Arguments(CallFrame*);
Arguments(CallFrame*, enum ArgumentsParameters);
Arguments(CallFrame*, NoParametersType);
virtual ~Arguments();
static const ClassInfo info;
......@@ -75,6 +73,11 @@ namespace JSC {
d->registers = &activation->registerAt(0);
}
static PassRefPtr<StructureID> createStructureID(JSValuePtr prototype)
{
return StructureID::create(prototype, TypeInfo(ObjectType));
}
private:
void getArgumentsData(CallFrame*, JSFunction*&, ptrdiff_t& firstParameterIndex, Register*& argv, int& argc);
virtual bool getOwnPropertySlot(ExecState*, const Identifier& propertyName, PropertySlot&);
......@@ -153,10 +156,12 @@ namespace JSC {
d->overrodeCallee = false;
}
inline Arguments::Arguments(CallFrame* callFrame, enum ArgumentsParameters)
inline Arguments::Arguments(CallFrame* callFrame, NoParametersType)
: JSObject(callFrame->lexicalGlobalObject()->argumentsStructure())
, d(new ArgumentsData)
{
ASSERT(!callFrame->callee()->m_body->parameterCount());
unsigned numArguments = callFrame->argumentCount() - 1;
d->numParameters = 0;
......
......@@ -35,6 +35,11 @@ namespace JSC {
virtual const ClassInfo* classInfo() const { return &info; }
static const ClassInfo info;
static PassRefPtr<StructureID> createStructureID(JSValuePtr prototype)
{
return StructureID::create(prototype, TypeInfo(ObjectType));
}
};
} // namespace JSC
......
......@@ -32,7 +32,7 @@ namespace JSC {
static PassRefPtr<StructureID> createStructureID(JSValuePtr proto)
{
return StructureID::create(proto, TypeInfo(ObjectType));
return StructureID::create(proto, TypeInfo(ObjectType, HasStandardGetOwnPropertySlot));
}
private:
......
......@@ -40,7 +40,7 @@ namespace JSC {
static PassRefPtr<StructureID> createStructureID(JSValuePtr proto)
{
return StructureID::create(proto, TypeInfo(ObjectType, ImplementsHasInstance));
return StructureID::create(proto, TypeInfo(ObjectType, ImplementsHasInstance | HasStandardGetOwnPropertySlot));
}
protected:
......
......@@ -76,6 +76,11 @@ namespace JSC {
void fillArgList(ExecState*, ArgList&);
static PassRefPtr<StructureID> createStructureID(JSValuePtr prototype)
{
return StructureID::create(prototype, TypeInfo(ObjectType));
}
protected:
virtual void put(ExecState*, const Identifier& propertyName, JSValuePtr, PutPropertySlot&);
virtual bool deleteProperty(ExecState*, const Identifier& propertyName);
......
......@@ -99,7 +99,8 @@ namespace JSC {
void* vptr() { return *reinterpret_cast<void**>(this); }
private:
// Base implementation, but for non-object classes implements getPropertySlot.
// Base implementation; for non-object classes implements getPropertySlot.
bool fastGetOwnPropertySlot(ExecState*, const Identifier& propertyName, PropertySlot&);
virtual bool getOwnPropertySlot(ExecState*, const Identifier& propertyName, PropertySlot&);
virtual bool getOwnPropertySlot(ExecState*, unsigned propertyName, PropertySlot&);
......
......@@ -68,6 +68,11 @@ namespace JSC {
// FIXME: This should be private
RefPtr<FunctionBodyNode> m_body;
static PassRefPtr<StructureID> createStructureID(JSValuePtr prototype)
{
return StructureID::create(prototype, TypeInfo(ObjectType, ImplementsHasInstance));
}
private:
virtual const ClassInfo* classInfo() const { return &info; }
......
......@@ -34,6 +34,7 @@
#include "JSActivation.h"
#include "JSClassRef.h"
#include "JSLock.h"
#include "JSNotAnObject.h"
#include "JSStaticScopeObject.h"
#include "Machine.h"
#include "Parser.h"
......@@ -68,10 +69,12 @@ JSGlobalData::JSGlobalData(bool isShared)
, regExpTable(new HashTable(JSC::regExpTable))
, regExpConstructorTable(new HashTable(JSC::regExpConstructorTable))
, stringTable(new HashTable(JSC::stringTable))
, nullProtoStructureID(JSObject::createStructureID(jsNull()))
, activationStructureID(JSActivation::createStructureID(jsNull()))
, interruptedExecutionErrorStructure(JSObject::createStructureID(jsNull()))
, staticScopeStructureID(JSStaticScopeObject::createStructureID(jsNull()))
, stringStructureID(JSString::createStructureID(jsNull()))
, notAnObjectErrorStubStructure(JSNotAnObjectErrorStub::createStructureID(jsNull()))
, notAnObjectStructure(JSNotAnObject::createStructureID(jsNull()))
, numberStructureID(JSNumberCell::createStructureID(jsNull()))
, identifierTable(createIdentifierTable())
, propertyNames(new CommonIdentifiers(this))
......
......@@ -78,10 +78,12 @@ namespace JSC {
const HashTable* regExpConstructorTable;
const HashTable* stringTable;
RefPtr<StructureID> nullProtoStructureID;
RefPtr<StructureID> activationStructureID;
RefPtr<StructureID> interruptedExecutionErrorStructure;
RefPtr<StructureID> staticScopeStructureID;
RefPtr<StructureID> stringStructureID;
RefPtr<StructureID> notAnObjectErrorStubStructure;
RefPtr<StructureID> notAnObjectStructure;
RefPtr<StructureID> numberStructureID;
IdentifierTable* identifierTable;
......
......@@ -251,6 +251,11 @@ namespace JSC {
JSGlobalData* globalData() { return d()->globalData.get(); }
JSGlobalObjectData* d() const { return static_cast<JSGlobalObjectData*>(JSVariableObject::d); }
static PassRefPtr<StructureID> createStructureID(JSValuePtr prototype)
{
return StructureID::create(prototype, TypeInfo(ObjectType));
}
protected:
struct GlobalPropertyInfo {
GlobalPropertyInfo(const Identifier& i, JSValuePtr v, unsigned a)
......
......@@ -36,13 +36,16 @@ namespace JSC {
class JSNotAnObjectErrorStub : public JSObject {
public:
JSNotAnObjectErrorStub(ExecState* exec, bool isNull)
: JSObject(exec->globalData().nullProtoStructureID)
: JSObject(exec->globalData().notAnObjectErrorStubStructure)
, m_isNull(isNull)
{
}
bool isNull() const { return m_isNull; }
bool isNotAnObjectErrorStub() const { return true; }
private:
virtual bool isNotAnObjectErrorStub() const { return true; }
bool m_isNull;
};
......@@ -52,11 +55,16 @@ namespace JSC {
class JSNotAnObject : public JSObject {
public:
JSNotAnObject(ExecState* exec, JSNotAnObjectErrorStub* exception)
: JSObject(exec->globalData().nullProtoStructureID)
: JSObject(exec->globalData().notAnObjectStructure)
, m_exception(exception)
{
}
static PassRefPtr<StructureID> createStructureID(JSValuePtr prototype)
{
return StructureID::create(prototype, TypeInfo(ObjectType));
}
private:
// JSValue methods
virtual JSValuePtr toPrimitive(ExecState*, PreferredPrimitiveType) const;
......
......@@ -55,6 +55,7 @@ namespace JSC {
class JSObject : public JSCell {
friend class BatchedTransitionOptimizer;
friend class CTI;
friend class JSCell;
public:
explicit JSObject(PassRefPtr<StructureID>);
......@@ -183,12 +184,17 @@ namespace JSC {
static const size_t inlineStorageCapacity = 2;
static const size_t nonInlineBaseStorageCapacity = 16;
static PassRefPtr<StructureID> createStructureID(JSValuePtr proto) { return StructureID::create(proto, TypeInfo(ObjectType)); }
static PassRefPtr<StructureID> createStructureID(JSValuePtr prototype)
{
return StructureID::create(prototype, TypeInfo(ObjectType, HasStandardGetOwnPropertySlot));
}
protected:
bool getOwnPropertySlotForWrite(ExecState*, const Identifier&, PropertySlot&, bool& slotIsWriteable);
private:
bool inlineGetOwnPropertySlot(ExecState*, const Identifier& propertyName, PropertySlot&);
const HashEntry* findPropertyHashEntry(ExecState*, const Identifier& propertyName) const;
StructureID* createInheritorID();
......@@ -266,62 +272,25 @@ inline bool JSValue::isObject(const ClassInfo* classInfo) const
return !JSImmediate::isImmediate(asValue()) && asCell()->isObject(classInfo);
}
inline JSValuePtr JSObject::get(ExecState* exec, const Identifier& propertyName) const
ALWAYS_INLINE bool JSObject::inlineGetOwnPropertySlot(ExecState* exec, const Identifier& propertyName, PropertySlot& slot)
{
PropertySlot slot(this);
if (const_cast<JSObject*>(this)->getPropertySlot(exec, propertyName, slot))
return slot.getValue(exec, propertyName);
return jsUndefined();
}
inline JSValuePtr JSObject::get(ExecState* exec, unsigned propertyName) const
{
PropertySlot slot(this);
if (const_cast<JSObject*>(this)->getPropertySlot(exec, propertyName, slot))
return slot.getValue(exec, propertyName);
return jsUndefined();
}
// It may seem crazy to inline a function this large but it makes a big difference
// since this is function very hot in variable lookup
inline bool JSObject::getPropertySlot(ExecState* exec, const Identifier& propertyName, PropertySlot& slot)
{
JSObject* object = this;
while (true) {
if (object->getOwnPropertySlot(exec, propertyName, slot))
return true;
JSValuePtr prototype = object->prototype();
if (!prototype->isObject())
return false;
object = asObject(prototype);
if (JSValuePtr* location = getDirectLocation(propertyName)) {
if (m_structureID->hasGetterSetterProperties() && location[0]->isGetterSetter())
fillGetterPropertySlot(slot, location);
else
slot.setValueSlot(this, location, offsetForLocation(location));
return true;
}
}
inline bool JSObject::getPropertySlot(ExecState* exec, unsigned propertyName, PropertySlot& slot)
{
JSObject* object = this;
while (true) {
if (object->getOwnPropertySlot(exec, propertyName, slot))
return true;
JSValuePtr prototype = object->prototype();
if (!prototype->isObject())
break;
object = asObject(prototype);
// non-standard Netscape extension
if (propertyName == exec->propertyNames().underscoreProto) {
slot.setValue(prototype());
return true;
}
return false;
}
// It may seem crazy to inline a function this large, especially a virtual function,
// but it makes a big difference to property lookup that derived classes can inline their
// base class call to this.
ALWAYS_INLINE bool JSObject::getOwnPropertySlotForWrite(ExecState* exec, const Identifier& propertyName, PropertySlot& slot, bool& slotIsWriteable)
{
unsigned attributes;
......@@ -351,21 +320,60 @@ ALWAYS_INLINE bool JSObject::getOwnPropertySlotForWrite(ExecState* exec, const I
// base class call to this.
ALWAYS_INLINE bool JSObject::getOwnPropertySlot(ExecState* exec, const Identifier& propertyName, PropertySlot& slot)
{
if (JSValuePtr* location = getDirectLocation(propertyName)) {
if (m_structureID->hasGetterSetterProperties() && location[0]->isGetterSetter())
fillGetterPropertySlot(slot, location);
else
slot.setValueSlot(this, location, offsetForLocation(location));
return true;
return inlineGetOwnPropertySlot(exec, propertyName, slot);
}
ALWAYS_INLINE bool JSCell::fastGetOwnPropertySlot(ExecState* exec, const Identifier& propertyName, PropertySlot& slot)
{
if (structureID()->typeInfo().hasStandardGetOwnPropertySlot())
return asObject(this)->inlineGetOwnPropertySlot(exec, propertyName, slot);
return getOwnPropertySlot(exec, propertyName, slot);
}
// It may seem crazy to inline a function this large but it makes a big difference
// since this is function very hot in variable lookup
inline bool JSObject::getPropertySlot(ExecState* exec, const Identifier& propertyName, PropertySlot& slot)
{
JSObject* object = this;
while (true) {
if (object->fastGetOwnPropertySlot(exec, propertyName, slot))
return true;
JSValuePtr prototype = object->prototype();
if (!prototype->isObject())
return false;
object = asObject(prototype);
}
}
// non-standard Netscape extension
if (propertyName == exec->propertyNames().underscoreProto) {
slot.setValue(prototype());
return true;
inline bool JSObject::getPropertySlot(ExecState* exec, unsigned propertyName, PropertySlot& slot)
{
JSObject* object = this;
while (true) {
if (object->getOwnPropertySlot(exec, propertyName, slot))
return true;
JSValuePtr prototype = object->prototype();
if (!prototype->isObject())
return false;
object = asObject(prototype);
}
}
return false;
inline JSValuePtr JSObject::get(ExecState* exec, const Identifier& propertyName) const
{
PropertySlot slot(this);
if (const_cast<JSObject*>(this)->getPropertySlot(exec, propertyName, slot))
return slot.getValue(exec, propertyName);
return jsUndefined();
}
inline JSValuePtr JSObject::get(ExecState* exec, unsigned propertyName) const
{
PropertySlot slot(this);
if (const_cast<JSObject*>(this)->getPropertySlot(exec, propertyName, slot))
return slot.getValue(exec, propertyName);
return jsUndefined();
}
inline void JSObject::putDirect(const Identifier& propertyName, JSValuePtr value, unsigned attr)
......@@ -461,7 +469,7 @@ inline JSValuePtr JSValue::get(ExecState* exec, const Identifier& propertyName,
}
JSCell* cell = asCell();
while (true) {
if (cell->getOwnPropertySlot(exec, propertyName, slot))
if (cell->fastGetOwnPropertySlot(exec, propertyName, slot))
return slot.getValue(exec, propertyName);
ASSERT(cell->isObject());
JSValuePtr prototype = static_cast<JSObject*>(cell)->prototype();
......
......@@ -29,9 +29,10 @@ namespace JSC {
// This class is used as a base for classes such as String,
// Number, Boolean and Date which are wrappers for primitive types.
class JSWrapperObject : public JSObject {
public:
protected:
explicit JSWrapperObject(PassRefPtr<StructureID>);
public:
JSValuePtr internalValue() const { return m_internalValue; }
void setInternalValue(JSValuePtr);
......
/*
* Copyright (C) 1999-2000 Harri Porten (porten@kde.org)
* Copyright (C) 2008 Apple Inc. All rights reserved.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
......@@ -32,6 +33,11 @@ namespace JSC {
virtual const ClassInfo* classInfo() const { return &info; }
static const ClassInfo info;
static PassRefPtr<StructureID> createStructureID(JSValuePtr prototype)
{
return StructureID::create(prototype, TypeInfo(ObjectType));
}
};
} // namespace JSC
......
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