source: webkit/trunk/JavaScriptCore/kjs/PropertySlot.h@ 37337

Last change on this file since 37337 was 36977, checked in by [email protected], 17 years ago

JavaScriptCore:

2008-09-26 Sam Weinig <[email protected]>

Reviewed by Darin Adler.

Patch for https://bugs.webkit.org/show_bug.cgi?id=21152
Speedup static property get/put

Convert getting/setting static property values to use static functions
instead of storing an integer and switching in getValueProperty/putValueProperty.

  • kjs/JSObject.cpp: (JSC::JSObject::deleteProperty): (JSC::JSObject::getPropertyAttributes):
  • kjs/MathObject.cpp: (JSC::MathObject::getOwnPropertySlot):
  • kjs/NumberConstructor.cpp: (JSC::numberConstructorNaNValue): (JSC::numberConstructorNegInfinity): (JSC::numberConstructorPosInfinity): (JSC::numberConstructorMaxValue): (JSC::numberConstructorMinValue):
  • kjs/PropertySlot.h: (JSC::PropertySlot::):
  • kjs/RegExpConstructor.cpp: (JSC::regExpConstructorDollar1): (JSC::regExpConstructorDollar2): (JSC::regExpConstructorDollar3): (JSC::regExpConstructorDollar4): (JSC::regExpConstructorDollar5): (JSC::regExpConstructorDollar6): (JSC::regExpConstructorDollar7): (JSC::regExpConstructorDollar8): (JSC::regExpConstructorDollar9): (JSC::regExpConstructorInput): (JSC::regExpConstructorMultiline): (JSC::regExpConstructorLastMatch): (JSC::regExpConstructorLastParen): (JSC::regExpConstructorLeftContext): (JSC::regExpConstructorRightContext): (JSC::setRegExpConstructorInput): (JSC::setRegExpConstructorMultiline): (JSC::RegExpConstructor::setInput): (JSC::RegExpConstructor::setMultiline): (JSC::RegExpConstructor::multiline):
  • kjs/RegExpConstructor.h:
  • kjs/RegExpObject.cpp: (JSC::regExpObjectGlobal): (JSC::regExpObjectIgnoreCase): (JSC::regExpObjectMultiline): (JSC::regExpObjectSource): (JSC::regExpObjectLastIndex): (JSC::setRegExpObjectLastIndex):
  • kjs/RegExpObject.h: (JSC::RegExpObject::setLastIndex): (JSC::RegExpObject::lastIndex): (JSC::RegExpObject::RegExpObjectData::RegExpObjectData):
  • kjs/StructureID.cpp: (JSC::StructureID::getEnumerablePropertyNames):
  • kjs/create_hash_table:
  • kjs/lexer.cpp: (JSC::Lexer::lex):
  • kjs/lookup.cpp: (JSC::HashTable::createTable): (JSC::HashTable::deleteTable): (JSC::setUpStaticFunctionSlot):
  • kjs/lookup.h: (JSC::HashEntry::initialize): (JSC::HashEntry::setKey): (JSC::HashEntry::key): (JSC::HashEntry::attributes): (JSC::HashEntry::function): (JSC::HashEntry::functionLength): (JSC::HashEntry::propertyGetter): (JSC::HashEntry::propertyPutter): (JSC::HashEntry::lexerValue): (JSC::HashEntry::): (JSC::HashTable::entry): (JSC::getStaticPropertySlot): (JSC::getStaticValueSlot): (JSC::lookupPut):

WebCore:

2008-09-26 Sam Weinig <[email protected]>

Reviewed by Darin Adler.

Patch for https://bugs.webkit.org/show_bug.cgi?id=21152
Speedup static property get/put

  • DerivedSources.make:
  • GNUmakefile.am:
  • WebCore.pro:
  • WebCore.vcproj/WebCore.vcproj:
  • WebCore.xcodeproj/project.pbxproj:
  • bindings/js/JSDOMBinding.cpp:
  • bindings/js/JSDOMBinding.h:
  • bindings/js/JSDOMWindowBase.cpp: (WebCore::getDOMConstructor): (WebCore::jsDOMWindowBaseCrypto): (WebCore::jsDOMWindowBaseEvent): (WebCore::jsDOMWindowBaseImage): (WebCore::jsDOMWindowBaseMessageChannel): (WebCore::jsDOMWindowBaseOption): (WebCore::jsDOMWindowBaseXMLHttpRequest): (WebCore::jsDOMWindowBaseAudio): (WebCore::jsDOMWindowBaseXSLTProcessor): (WebCore::jsDOMWindowBaseOnabort): (WebCore::jsDOMWindowBaseOnblur): (WebCore::jsDOMWindowBaseOnchange): (WebCore::jsDOMWindowBaseOnclick): (WebCore::jsDOMWindowBaseOndblclick): (WebCore::jsDOMWindowBaseOnerror): (WebCore::jsDOMWindowBaseOnfocus): (WebCore::jsDOMWindowBaseOnkeydown): (WebCore::jsDOMWindowBaseOnkeypress): (WebCore::jsDOMWindowBaseOnkeyup): (WebCore::jsDOMWindowBaseOnload): (WebCore::jsDOMWindowBaseOnmousedown): (WebCore::jsDOMWindowBaseOnmousemove): (WebCore::jsDOMWindowBaseOnmouseout): (WebCore::jsDOMWindowBaseOnmouseover): (WebCore::jsDOMWindowBaseOnmouseup): (WebCore::jsDOMWindowBaseOnMouseWheel): (WebCore::jsDOMWindowBaseOnreset): (WebCore::jsDOMWindowBaseOnresize): (WebCore::jsDOMWindowBaseOnscroll): (WebCore::jsDOMWindowBaseOnsearch): (WebCore::jsDOMWindowBaseOnselect): (WebCore::jsDOMWindowBaseOnsubmit): (WebCore::jsDOMWindowBaseOnbeforeunload): (WebCore::jsDOMWindowBaseOnunload): (WebCore::jsDOMWindowBaseOnWebKitAnimationStart): (WebCore::jsDOMWindowBaseOnWebKitAnimationIteration): (WebCore::jsDOMWindowBaseOnWebKitAnimationEnd): (WebCore::jsDOMWindowBaseOnWebKitTransitionEnd): (WebCore::JSDOMWindowBase::getOwnPropertySlot): (WebCore::JSDOMWindowBase::put): (WebCore::setJSDOMWindowBaseOnabort): (WebCore::setJSDOMWindowBaseOnblur): (WebCore::setJSDOMWindowBaseOnchange): (WebCore::setJSDOMWindowBaseOnclick): (WebCore::setJSDOMWindowBaseOndblclick): (WebCore::setJSDOMWindowBaseOnerror): (WebCore::setJSDOMWindowBaseOnfocus): (WebCore::setJSDOMWindowBaseOnkeydown): (WebCore::setJSDOMWindowBaseOnkeypress): (WebCore::setJSDOMWindowBaseOnkeyup): (WebCore::setJSDOMWindowBaseOnload): (WebCore::setJSDOMWindowBaseOnmousedown): (WebCore::setJSDOMWindowBaseOnmousemove): (WebCore::setJSDOMWindowBaseOnmouseout): (WebCore::setJSDOMWindowBaseOnmouseover): (WebCore::setJSDOMWindowBaseOnmouseup): (WebCore::setJSDOMWindowBaseOnMouseWheel): (WebCore::setJSDOMWindowBaseOnreset): (WebCore::setJSDOMWindowBaseOnresize): (WebCore::setJSDOMWindowBaseOnscroll): (WebCore::setJSDOMWindowBaseOnsearch): (WebCore::setJSDOMWindowBaseOnselect): (WebCore::setJSDOMWindowBaseOnsubmit): (WebCore::setJSDOMWindowBaseOnbeforeunload): (WebCore::setJSDOMWindowBaseOnunload): (WebCore::setJSDOMWindowBaseOnWebKitAnimationStart): (WebCore::setJSDOMWindowBaseOnWebKitAnimationIteration): (WebCore::setJSDOMWindowBaseOnWebKitAnimationEnd): (WebCore::setJSDOMWindowBaseOnWebKitTransitionEnd): (WebCore::setJSDOMWindowBaseEvent): (WebCore::setJSDOMWindowBaseAudio): (WebCore::setJSDOMWindowBaseImage): (WebCore::setJSDOMWindowBaseMessageChannel): (WebCore::setJSDOMWindowBaseOption): (WebCore::setJSDOMWindowBaseXMLHttpRequest): (WebCore::setJSDOMWindowBaseXSLTProcessor):
  • bindings/js/JSDOMWindowBase.h:
  • bindings/js/JSDOMWindowCustom.cpp: (WebCore::nonCachingStaticCloseFunctionGetter): (WebCore::nonCachingStaticBlurFunctionGetter): (WebCore::nonCachingStaticFocusFunctionGetter): (WebCore::nonCachingStaticPostMessageFunctionGetter):
  • bindings/js/JSDOMWindowCustom.h: (WebCore::JSDOMWindow::customGetOwnPropertySlot):
  • bindings/js/JSEventTargetBase.cpp:
  • bindings/js/JSEventTargetBase.h: (WebCore::JSEventTargetBasePrototype::getOwnPropertySlot): (WebCore::JSEventTargetBasePrototype::classInfo):
  • bindings/js/JSEventTargetNode.cpp: (WebCore::): (WebCore::JSEventTargetNode::getOwnPropertySlot): (WebCore::JSEventTargetNode::put):
  • bindings/js/JSEventTargetNode.h: (WebCore::JSEventTargetNode::classInfo): (WebCore::JSEventTargetNode::prototypeClassName):
  • bindings/js/JSEventTargetSVGElementInstance.cpp: (WebCore::): (WebCore::JSEventTargetSVGElementInstance::getOwnPropertySlot): (WebCore::JSEventTargetSVGElementInstance::put):
  • bindings/js/JSEventTargetSVGElementInstance.h: (WebCore::JSEventTargetSVGElementInstance::classInfo): (WebCore::JSEventTargetSVGElementInstance::prototypeClassName):
  • bindings/js/JSHTMLInputElementCustom.cpp: (WebCore::JSHTMLInputElement::customGetOwnPropertySlot):
  • bindings/js/JSHistoryCustom.cpp: (WebCore::nonCachingStaticBackFunctionGetter): (WebCore::nonCachingStaticForwardFunctionGetter): (WebCore::nonCachingStaticGoFunctionGetter): (WebCore::JSHistory::customGetOwnPropertySlot):
  • bindings/js/JSLocationCustom.cpp: (WebCore::nonCachingStaticReplaceFunctionGetter): (WebCore::nonCachingStaticReloadFunctionGetter): (WebCore::nonCachingStaticAssignFunctionGetter): (WebCore::JSLocation::customGetOwnPropertySlot): (WebCore::JSLocation::customPut):
  • bindings/scripts/CodeGeneratorJS.pm:
  • Property svn:eol-style set to native
File size: 5.7 KB
Line 
1/*
2 * Copyright (C) 2005, 2007, 2008 Apple Inc. All rights reserved.
3 *
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Library General Public
6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version.
8 *
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Library General Public License for more details.
13 *
14 * You should have received a copy of the GNU Library General Public License
15 * along with this library; see the file COPYING.LIB. If not, write to
16 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17 * Boston, MA 02110-1301, USA.
18 *
19 */
20
21#ifndef PropertySlot_h
22#define PropertySlot_h
23
24#include "Register.h"
25#include "JSValue.h"
26#include "identifier.h"
27#include <wtf/Assertions.h>
28#include <wtf/NotFound.h>
29
30namespace JSC {
31
32 class ExecState;
33 class JSObject;
34
35#define JSC_VALUE_SLOT_MARKER 0
36#define JSC_REGISTER_SLOT_MARKER reinterpret_cast<GetValueFunc>(1)
37
38 class PropertySlot {
39 public:
40 PropertySlot()
41 : m_offset(WTF::notFound)
42 {
43 clearBase();
44 clearValue();
45 }
46
47 explicit PropertySlot(JSValue* base)
48 : m_slotBase(base)
49 , m_offset(WTF::notFound)
50 {
51 clearValue();
52 }
53
54 typedef JSValue* (*GetValueFunc)(ExecState*, const Identifier&, const PropertySlot&);
55
56 JSValue* getValue(ExecState* exec, const Identifier& propertyName) const
57 {
58 if (m_getValue == JSC_VALUE_SLOT_MARKER)
59 return *m_data.valueSlot;
60 if (m_getValue == JSC_REGISTER_SLOT_MARKER)
61 return (*m_data.registerSlot).jsValue(exec);
62 return m_getValue(exec, propertyName, *this);
63 }
64
65 JSValue* getValue(ExecState* exec, unsigned propertyName) const
66 {
67 if (m_getValue == JSC_VALUE_SLOT_MARKER)
68 return *m_data.valueSlot;
69 if (m_getValue == JSC_REGISTER_SLOT_MARKER)
70 return (*m_data.registerSlot).jsValue(exec);
71 return m_getValue(exec, Identifier::from(exec, propertyName), *this);
72 }
73
74 bool isCacheable() const { return m_offset != WTF::notFound; }
75 size_t cachedOffset() const
76 {
77 ASSERT(isCacheable());
78 return m_offset;
79 }
80
81 void putValue(JSValue* value)
82 {
83 if (m_getValue == JSC_VALUE_SLOT_MARKER) {
84 *m_data.valueSlot = value;
85 return;
86 }
87 ASSERT(m_getValue == JSC_REGISTER_SLOT_MARKER);
88 *m_data.registerSlot = value;
89 }
90
91 void setValueSlot(JSValue** valueSlot)
92 {
93 ASSERT(valueSlot);
94 m_getValue = JSC_VALUE_SLOT_MARKER;
95 clearBase();
96 m_data.valueSlot = valueSlot;
97 }
98
99 void setValueSlot(JSValue* slotBase, JSValue** valueSlot)
100 {
101 ASSERT(valueSlot);
102 m_getValue = JSC_VALUE_SLOT_MARKER;
103 m_slotBase = slotBase;
104 m_data.valueSlot = valueSlot;
105 }
106
107 void setValueSlot(JSValue* slotBase, JSValue** valueSlot, size_t offset)
108 {
109 ASSERT(valueSlot);
110 m_getValue = JSC_VALUE_SLOT_MARKER;
111 m_slotBase = slotBase;
112 m_data.valueSlot = valueSlot;
113 m_offset = offset;
114 }
115
116 void setValue(JSValue* value)
117 {
118 ASSERT(value);
119 m_getValue = JSC_VALUE_SLOT_MARKER;
120 clearBase();
121 m_value = value;
122 m_data.valueSlot = &m_value;
123 }
124
125 void setRegisterSlot(Register* registerSlot)
126 {
127 ASSERT(registerSlot);
128 m_getValue = JSC_REGISTER_SLOT_MARKER;
129 clearBase();
130 m_data.registerSlot = registerSlot;
131 }
132
133 void setCustom(JSValue* slotBase, GetValueFunc getValue)
134 {
135 ASSERT(slotBase);
136 ASSERT(getValue);
137 m_getValue = getValue;
138 m_slotBase = slotBase;
139 }
140
141 void setCustomIndex(JSValue* slotBase, unsigned index, GetValueFunc getValue)
142 {
143 ASSERT(slotBase);
144 ASSERT(getValue);
145 m_getValue = getValue;
146 m_slotBase = slotBase;
147 m_data.index = index;
148 }
149
150 void setGetterSlot(JSObject* getterFunc)
151 {
152 ASSERT(getterFunc);
153 m_getValue = functionGetter;
154 m_data.getterFunc = getterFunc;
155 }
156
157 void setUndefined()
158 {
159 clearBase();
160 setValue(jsUndefined());
161 }
162
163 JSValue* slotBase() const
164 {
165 ASSERT(m_slotBase);
166 return m_slotBase;
167 }
168
169 void setBase(JSValue* base)
170 {
171 ASSERT(m_slotBase);
172 ASSERT(base);
173 m_slotBase = base;
174 }
175
176 void clearBase()
177 {
178#ifndef NDEBUG
179 m_slotBase = 0;
180#endif
181 }
182
183 void clearValue()
184 {
185#ifndef NDEBUG
186 m_value = 0;
187#endif
188 }
189
190 unsigned index() const { return m_data.index; }
191
192 private:
193 static JSValue* functionGetter(ExecState*, const Identifier&, const PropertySlot&);
194
195 GetValueFunc m_getValue;
196
197 JSValue* m_slotBase;
198 union {
199 JSObject* getterFunc;
200 JSValue** valueSlot;
201 Register* registerSlot;
202 unsigned index;
203 } m_data;
204
205 JSValue* m_value;
206
207 size_t m_offset;
208 };
209
210} // namespace JSC
211
212#endif // PropertySlot_h
Note: See TracBrowser for help on using the repository browser.