[webkit-changes] cvs commit: JavaScriptCore/kjs object.cpp
Eric
eseidel at opensource.apple.com
Tue Oct 4 02:33:34 PDT 2005
eseidel 05/10/04 02:33:33
Modified: . ChangeLog
kjs object.cpp
Log:
Bug #: none
Submitted by: eseidel
Reviewed by: mjs
Code cleanup, which resulted in a small win on iBench.
* kjs/object.cpp:
(KJS::tryGetAndCallProperty): new static inline
(KJS::ObjectImp::defaultValue): code cleanup
Revision Changes Path
1.853 +10 -0 JavaScriptCore/ChangeLog
Index: ChangeLog
===================================================================
RCS file: /cvs/root/JavaScriptCore/ChangeLog,v
retrieving revision 1.852
retrieving revision 1.853
diff -u -r1.852 -r1.853
--- ChangeLog 4 Oct 2005 05:57:09 -0000 1.852
+++ ChangeLog 4 Oct 2005 09:33:31 -0000 1.853
@@ -1,3 +1,13 @@
+2005-10-04 Eric Seidel <eseidel at apple.com>
+
+ Reviewed by mjs.
+
+ Code cleanup, which resulted in a small win on iBench.
+
+ * kjs/object.cpp:
+ (KJS::tryGetAndCallProperty): new static inline
+ (KJS::ObjectImp::defaultValue): code cleanup
+
2005-10-03 Maciej Stachowiak <mjs at apple.com>
Patch from George Staikos <staikos at kde.org>, reviewed and tweaked a bit by me.
1.53 +28 -36 JavaScriptCore/kjs/object.cpp
Index: object.cpp
===================================================================
RCS file: /cvs/root/JavaScriptCore/kjs/object.cpp,v
retrieving revision 1.52
retrieving revision 1.53
diff -u -r1.52 -r1.53
--- object.cpp 3 Oct 2005 21:11:50 -0000 1.52
+++ object.cpp 4 Oct 2005 09:33:33 -0000 1.53
@@ -277,28 +277,17 @@
return deleteProperty(exec, Identifier::from(propertyName));
}
-// ECMA 8.6.2.6
-ValueImp *ObjectImp::defaultValue(ExecState *exec, Type hint) const
-{
- if (hint != StringType && hint != NumberType) {
- /* Prefer String for Date objects */
- if (_proto == exec->lexicalInterpreter()->builtinDatePrototype())
- hint = StringType;
- else
- hint = NumberType;
- }
-
- ValueImp *v;
- if (hint == StringType)
- v = get(exec,toStringPropertyName);
- else
- v = get(exec,valueOfPropertyName);
-
+static inline
+#ifdef __GNUC__
+__attribute__((always_inline))
+#endif
+ValueImp *tryGetAndCallProperty(ExecState *exec, const ObjectImp *object, const Identifier &propertyName) {
+ ValueImp *v = object->get(exec, propertyName);
if (v->isObject()) {
ObjectImp *o = static_cast<ObjectImp*>(v);
if (o->implementsCall()) { // spec says "not primitive type" but ...
- ObjectImp *thisObj = const_cast<ObjectImp*>(this);
- ValueImp *def = o->call(exec,thisObj,List::empty());
+ ObjectImp *thisObj = const_cast<ObjectImp*>(object);
+ ValueImp *def = o->call(exec, thisObj, List::empty());
Type defType = def->type();
if (defType == UnspecifiedType || defType == UndefinedType ||
defType == NullType || defType == BooleanType ||
@@ -307,26 +296,29 @@
}
}
}
+ return NULL;
+}
- if (hint == StringType)
- v = get(exec,valueOfPropertyName);
- else
- v = get(exec,toStringPropertyName);
-
- if (v->isObject()) {
- ObjectImp *o = static_cast<ObjectImp*>(v);
- if (o->implementsCall()) { // spec says "not primitive type" but ...
- ObjectImp *thisObj = const_cast<ObjectImp*>(this);
- ValueImp *def = o->call(exec,thisObj,List::empty());
- Type defType = def->type();
- if (defType == UnspecifiedType || defType == UndefinedType ||
- defType == NullType || defType == BooleanType ||
- defType == StringType || defType == NumberType) {
- return def;
- }
- }
+// ECMA 8.6.2.6
+ValueImp *ObjectImp::defaultValue(ExecState *exec, Type hint) const
+{
+ Identifier firstPropertyName;
+ Identifier secondPropertyName;
+ /* Prefer String for Date objects */
+ if ((hint == StringType) || (hint != StringType) && (hint != NumberType) && (_proto == exec->lexicalInterpreter()->builtinDatePrototype())) {
+ firstPropertyName = toStringPropertyName;
+ secondPropertyName = valueOfPropertyName;
+ } else {
+ firstPropertyName = valueOfPropertyName;
+ secondPropertyName = toStringPropertyName;
}
+ ValueImp *v;
+ if ((v = tryGetAndCallProperty(exec, this, firstPropertyName)))
+ return v;
+ if ((v = tryGetAndCallProperty(exec, this, secondPropertyName)))
+ return v;
+
if (exec->hadException())
return exec->exception();
More information about the webkit-changes
mailing list