[SCM] WebKit Debian packaging branch, debian/unstable, updated. debian/1.1.15-1-40151-g37bb677
darin
darin at 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Sat Sep 26 07:04:55 UTC 2009
The following commit has been merged in the debian/unstable branch:
commit c758b2869b3e6c1647d750828c67c4ff39a47408
Author: darin <darin at 268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date: Wed Nov 20 21:12:14 2002 +0000
- decrease ref/deref -- 5% speedup in iBench
* JavaScriptCore.pbproj/project.pbxproj: Added array_instance.h
* kjs/array_instance.h: Added so it can be shared by function.h.
* kjs/array_object.cpp:
* kjs/array_object.h:
* kjs/bool_object.cpp:
* kjs/bool_object.h:
* kjs/collector.cpp:
* kjs/date_object.cpp:
* kjs/date_object.h:
* kjs/error_object.cpp:
* kjs/function.cpp:
* kjs/function.h:
* kjs/function_object.cpp:
* kjs/internal.cpp:
* kjs/internal.h:
* kjs/math_object.cpp:
* kjs/nodes.cpp:
* kjs/number_object.cpp:
* kjs/object.cpp:
* kjs/object.h:
* kjs/object_object.cpp:
* kjs/property_map.cpp:
* kjs/reference.cpp:
* kjs/reference.h:
* kjs/regexp_object.cpp:
* kjs/string_object.cpp:
* kjs/string_object.h:
* kjs/value.cpp:
* kjs/value.h:
Switched lots of interfaces so they don't require ref/deref.
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@2783 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/JavaScriptCore/ChangeLog b/JavaScriptCore/ChangeLog
index 1895f7f..351a31b 100644
--- a/JavaScriptCore/ChangeLog
+++ b/JavaScriptCore/ChangeLog
@@ -1,3 +1,39 @@
+2002-11-20 Darin Adler <darin at apple.com>
+
+ - decrease ref/deref -- 5% speedup in iBench
+
+ * JavaScriptCore.pbproj/project.pbxproj: Added array_instance.h
+ * kjs/array_instance.h: Added so it can be shared by function.h.
+
+ * kjs/array_object.cpp:
+ * kjs/array_object.h:
+ * kjs/bool_object.cpp:
+ * kjs/bool_object.h:
+ * kjs/collector.cpp:
+ * kjs/date_object.cpp:
+ * kjs/date_object.h:
+ * kjs/error_object.cpp:
+ * kjs/function.cpp:
+ * kjs/function.h:
+ * kjs/function_object.cpp:
+ * kjs/internal.cpp:
+ * kjs/internal.h:
+ * kjs/math_object.cpp:
+ * kjs/nodes.cpp:
+ * kjs/number_object.cpp:
+ * kjs/object.cpp:
+ * kjs/object.h:
+ * kjs/object_object.cpp:
+ * kjs/property_map.cpp:
+ * kjs/reference.cpp:
+ * kjs/reference.h:
+ * kjs/regexp_object.cpp:
+ * kjs/string_object.cpp:
+ * kjs/string_object.h:
+ * kjs/value.cpp:
+ * kjs/value.h:
+ Switched lots of interfaces so they don't require ref/deref.
+
2002-11-20 Maciej Stachowiak <mjs at apple.com>
Fixed the two most obvious problems with the new GC for another 6%
diff --git a/JavaScriptCore/ChangeLog-2002-12-03 b/JavaScriptCore/ChangeLog-2002-12-03
index 1895f7f..351a31b 100644
--- a/JavaScriptCore/ChangeLog-2002-12-03
+++ b/JavaScriptCore/ChangeLog-2002-12-03
@@ -1,3 +1,39 @@
+2002-11-20 Darin Adler <darin at apple.com>
+
+ - decrease ref/deref -- 5% speedup in iBench
+
+ * JavaScriptCore.pbproj/project.pbxproj: Added array_instance.h
+ * kjs/array_instance.h: Added so it can be shared by function.h.
+
+ * kjs/array_object.cpp:
+ * kjs/array_object.h:
+ * kjs/bool_object.cpp:
+ * kjs/bool_object.h:
+ * kjs/collector.cpp:
+ * kjs/date_object.cpp:
+ * kjs/date_object.h:
+ * kjs/error_object.cpp:
+ * kjs/function.cpp:
+ * kjs/function.h:
+ * kjs/function_object.cpp:
+ * kjs/internal.cpp:
+ * kjs/internal.h:
+ * kjs/math_object.cpp:
+ * kjs/nodes.cpp:
+ * kjs/number_object.cpp:
+ * kjs/object.cpp:
+ * kjs/object.h:
+ * kjs/object_object.cpp:
+ * kjs/property_map.cpp:
+ * kjs/reference.cpp:
+ * kjs/reference.h:
+ * kjs/regexp_object.cpp:
+ * kjs/string_object.cpp:
+ * kjs/string_object.h:
+ * kjs/value.cpp:
+ * kjs/value.h:
+ Switched lots of interfaces so they don't require ref/deref.
+
2002-11-20 Maciej Stachowiak <mjs at apple.com>
Fixed the two most obvious problems with the new GC for another 6%
diff --git a/JavaScriptCore/ChangeLog-2003-10-25 b/JavaScriptCore/ChangeLog-2003-10-25
index 1895f7f..351a31b 100644
--- a/JavaScriptCore/ChangeLog-2003-10-25
+++ b/JavaScriptCore/ChangeLog-2003-10-25
@@ -1,3 +1,39 @@
+2002-11-20 Darin Adler <darin at apple.com>
+
+ - decrease ref/deref -- 5% speedup in iBench
+
+ * JavaScriptCore.pbproj/project.pbxproj: Added array_instance.h
+ * kjs/array_instance.h: Added so it can be shared by function.h.
+
+ * kjs/array_object.cpp:
+ * kjs/array_object.h:
+ * kjs/bool_object.cpp:
+ * kjs/bool_object.h:
+ * kjs/collector.cpp:
+ * kjs/date_object.cpp:
+ * kjs/date_object.h:
+ * kjs/error_object.cpp:
+ * kjs/function.cpp:
+ * kjs/function.h:
+ * kjs/function_object.cpp:
+ * kjs/internal.cpp:
+ * kjs/internal.h:
+ * kjs/math_object.cpp:
+ * kjs/nodes.cpp:
+ * kjs/number_object.cpp:
+ * kjs/object.cpp:
+ * kjs/object.h:
+ * kjs/object_object.cpp:
+ * kjs/property_map.cpp:
+ * kjs/reference.cpp:
+ * kjs/reference.h:
+ * kjs/regexp_object.cpp:
+ * kjs/string_object.cpp:
+ * kjs/string_object.h:
+ * kjs/value.cpp:
+ * kjs/value.h:
+ Switched lots of interfaces so they don't require ref/deref.
+
2002-11-20 Maciej Stachowiak <mjs at apple.com>
Fixed the two most obvious problems with the new GC for another 6%
diff --git a/JavaScriptCore/JavaScriptCore.pbproj/project.pbxproj b/JavaScriptCore/JavaScriptCore.pbproj/project.pbxproj
index fe7ff81..6762d2e 100644
--- a/JavaScriptCore/JavaScriptCore.pbproj/project.pbxproj
+++ b/JavaScriptCore/JavaScriptCore.pbproj/project.pbxproj
@@ -223,6 +223,7 @@
F5341393030CEEB1018BE7F3,
F5BB2BC7030F772101FCFE1D,
933A349C038AE7C6008635CE,
+ 938772E6038BFE19008635CE,
);
isa = PBXHeadersBuildPhase;
runOnlyForDeploymentPostprocessing = 0;
@@ -318,6 +319,7 @@
};
08FB77AEFE84172EC02AAC07 = {
children = (
+ 938772E5038BFE19008635CE,
F692A84D0255597D01FF60F7,
F692A84E0255597D01FF60F7,
F692A84F0255597D01FF60F7,
@@ -471,6 +473,18 @@
settings = {
};
};
+ 938772E5038BFE19008635CE = {
+ fileEncoding = 4;
+ isa = PBXFileReference;
+ path = array_instance.h;
+ refType = 4;
+ };
+ 938772E6038BFE19008635CE = {
+ fileRef = 938772E5038BFE19008635CE;
+ isa = PBXBuildFile;
+ settings = {
+ };
+ };
//930
//931
//932
diff --git a/JavaScriptCore/kjs/array_instance.h b/JavaScriptCore/kjs/array_instance.h
new file mode 100644
index 0000000..fbce820
--- /dev/null
+++ b/JavaScriptCore/kjs/array_instance.h
@@ -0,0 +1,66 @@
+// -*- c-basic-offset: 2 -*-
+/*
+ * This file is part of the KDE libraries
+ * Copyright (C) 1999-2000 Harri Porten (porten at kde.org)
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ */
+
+#ifndef ARRAY_INSTANCE_H
+#define ARRAY_INSTANCE_H
+
+#include "object.h"
+
+namespace KJS {
+
+ class ArrayInstanceImp : public ObjectImp {
+ public:
+ ArrayInstanceImp(ObjectImp *proto, unsigned initialLength);
+ ArrayInstanceImp(ObjectImp *proto, const List &initialValues);
+ ~ArrayInstanceImp();
+
+ virtual Value get(ExecState *exec, const Identifier &propertyName) const;
+ virtual Value get(ExecState *exec, unsigned propertyName) const;
+ virtual void put(ExecState *exec, const Identifier &propertyName, const Value &value, int attr = None);
+ virtual void put(ExecState *exec, unsigned propertyName, const Value &value, int attr = None);
+ virtual bool hasProperty(ExecState *exec, const Identifier &propertyName) const;
+ virtual bool hasProperty(ExecState *exec, unsigned propertyName) const;
+ virtual bool deleteProperty(ExecState *exec, const Identifier &propertyName);
+ virtual bool deleteProperty(ExecState *exec, unsigned propertyName);
+
+ virtual void mark();
+
+ virtual const ClassInfo *classInfo() const { return &info; }
+ static const ClassInfo info;
+
+ unsigned getLength() const { return length; }
+
+ void sort(ExecState *exec);
+ void sort(ExecState *exec, Object &compareFunction);
+
+ private:
+ void setLength(unsigned newLength);
+
+ unsigned pushUndefinedObjectsToEnd();
+
+ unsigned length;
+ unsigned capacity;
+ ValueImp **storage;
+ };
+
+}; // namespace KJS
+
+#endif
diff --git a/JavaScriptCore/kjs/array_object.cpp b/JavaScriptCore/kjs/array_object.cpp
index 9246179..9761ea2 100644
--- a/JavaScriptCore/kjs/array_object.cpp
+++ b/JavaScriptCore/kjs/array_object.cpp
@@ -39,7 +39,7 @@ using namespace KJS;
const ClassInfo ArrayInstanceImp::info = {"Array", 0, 0, 0};
-ArrayInstanceImp::ArrayInstanceImp(const Object &proto, unsigned initialLength)
+ArrayInstanceImp::ArrayInstanceImp(ObjectImp *proto, unsigned initialLength)
: ObjectImp(proto)
, length(initialLength)
, capacity(length)
@@ -47,7 +47,7 @@ ArrayInstanceImp::ArrayInstanceImp(const Object &proto, unsigned initialLength)
{
}
-ArrayInstanceImp::ArrayInstanceImp(const Object &proto, const List &list)
+ArrayInstanceImp::ArrayInstanceImp(ObjectImp *proto, const List &list)
: ObjectImp(proto)
, length(list.size())
, capacity(length)
@@ -289,7 +289,7 @@ const ClassInfo ArrayPrototypeImp::info = {"Array", &ArrayInstanceImp::info, &ar
// ECMA 15.4.4
ArrayPrototypeImp::ArrayPrototypeImp(ExecState *exec,
ObjectPrototypeImp *objProto)
- : ArrayInstanceImp(Object(objProto), 0)
+ : ArrayInstanceImp(objProto, 0)
{
Value protect(this);
setInternalValue(Null());
@@ -664,10 +664,10 @@ Object ArrayObjectImp::construct(ExecState *exec, const List &args)
{
// a single numeric argument denotes the array size (!)
if (args.size() == 1 && args[0].type() == NumberType)
- return Object(new ArrayInstanceImp(exec->interpreter()->builtinArrayPrototype(), args[0].toUInt32(exec)));
+ return Object(new ArrayInstanceImp(exec->interpreter()->builtinArrayPrototype().imp(), args[0].toUInt32(exec)));
// otherwise the array is constructed with the arguments in it
- return Object(new ArrayInstanceImp(exec->interpreter()->builtinArrayPrototype(), args));
+ return Object(new ArrayInstanceImp(exec->interpreter()->builtinArrayPrototype().imp(), args));
}
bool ArrayObjectImp::implementsCall() const
@@ -681,4 +681,3 @@ Value ArrayObjectImp::call(ExecState *exec, Object &/*thisObj*/, const List &arg
// equivalent to 'new Array(....)'
return construct(exec,args);
}
-
diff --git a/JavaScriptCore/kjs/array_object.h b/JavaScriptCore/kjs/array_object.h
index da8c215..04aa870 100644
--- a/JavaScriptCore/kjs/array_object.h
+++ b/JavaScriptCore/kjs/array_object.h
@@ -27,41 +27,6 @@
namespace KJS {
- class ArrayInstanceImp : public ObjectImp {
- public:
- ArrayInstanceImp(const Object &proto, unsigned initialLength);
- ArrayInstanceImp(const Object &proto, const List &initialValues);
- ~ArrayInstanceImp();
-
- virtual Value get(ExecState *exec, const Identifier &propertyName) const;
- virtual Value get(ExecState *exec, unsigned propertyName) const;
- virtual void put(ExecState *exec, const Identifier &propertyName, const Value &value, int attr = None);
- virtual void put(ExecState *exec, unsigned propertyName, const Value &value, int attr = None);
- virtual bool hasProperty(ExecState *exec, const Identifier &propertyName) const;
- virtual bool hasProperty(ExecState *exec, unsigned propertyName) const;
- virtual bool deleteProperty(ExecState *exec, const Identifier &propertyName);
- virtual bool deleteProperty(ExecState *exec, unsigned propertyName);
-
- virtual void mark();
-
- virtual const ClassInfo *classInfo() const { return &info; }
- static const ClassInfo info;
-
- unsigned getLength() const { return length; }
-
- void sort(ExecState *exec);
- void sort(ExecState *exec, Object &compareFunction);
-
- private:
- void setLength(unsigned newLength);
-
- unsigned pushUndefinedObjectsToEnd();
-
- unsigned length;
- unsigned capacity;
- ValueImp **storage;
- };
-
class ArrayPrototypeImp : public ArrayInstanceImp {
public:
ArrayPrototypeImp(ExecState *exec,
diff --git a/JavaScriptCore/kjs/bool_object.cpp b/JavaScriptCore/kjs/bool_object.cpp
index 20c8c7b..acb47eb 100644
--- a/JavaScriptCore/kjs/bool_object.cpp
+++ b/JavaScriptCore/kjs/bool_object.cpp
@@ -35,7 +35,7 @@ using namespace KJS;
const ClassInfo BooleanInstanceImp::info = {"Boolean", 0, 0, 0};
-BooleanInstanceImp::BooleanInstanceImp(const Object &proto)
+BooleanInstanceImp::BooleanInstanceImp(ObjectImp *proto)
: ObjectImp(proto)
{
}
@@ -47,13 +47,13 @@ BooleanInstanceImp::BooleanInstanceImp(const Object &proto)
BooleanPrototypeImp::BooleanPrototypeImp(ExecState *exec,
ObjectPrototypeImp *objectProto,
FunctionPrototypeImp *funcProto)
- : BooleanInstanceImp(Object(objectProto))
+ : BooleanInstanceImp(objectProto)
{
Value protect(this);
// The constructor will be added later by InterpreterImp::InterpreterImp()
- put(exec,toStringPropertyName, Object(new BooleanProtoFuncImp(exec,funcProto,BooleanProtoFuncImp::ToString,0)), DontEnum);
- put(exec,valueOfPropertyName, Object(new BooleanProtoFuncImp(exec,funcProto,BooleanProtoFuncImp::ValueOf,0)), DontEnum);
+ putDirect(toStringPropertyName, new BooleanProtoFuncImp(exec,funcProto,BooleanProtoFuncImp::ToString,0), DontEnum);
+ putDirect(valueOfPropertyName, new BooleanProtoFuncImp(exec,funcProto,BooleanProtoFuncImp::ValueOf,0), DontEnum);
setInternalValue(Boolean(false));
}
@@ -65,7 +65,7 @@ BooleanProtoFuncImp::BooleanProtoFuncImp(ExecState *exec,
: InternalFunctionImp(funcProto), id(i)
{
Value protect(this);
- put(exec,lengthPropertyName,Number(len),DontDelete|ReadOnly|DontEnum);
+ putDirect(lengthPropertyName, len, DontDelete|ReadOnly|DontEnum);
}
@@ -104,10 +104,10 @@ BooleanObjectImp::BooleanObjectImp(ExecState *exec, FunctionPrototypeImp *funcPr
: InternalFunctionImp(funcProto)
{
Value protect(this);
- put(exec,prototypePropertyName, Object(booleanProto),DontEnum|DontDelete|ReadOnly);
+ putDirect(prototypePropertyName, booleanProto, DontEnum|DontDelete|ReadOnly);
// no. of arguments for constructor
- put(exec,lengthPropertyName, Number(1), ReadOnly|DontDelete|DontEnum);
+ putDirect(lengthPropertyName, NumberImp::one(), ReadOnly|DontDelete|DontEnum);
}
@@ -119,8 +119,7 @@ bool BooleanObjectImp::implementsConstruct() const
// ECMA 15.6.2
Object BooleanObjectImp::construct(ExecState *exec, const List &args)
{
- Object proto = exec->interpreter()->builtinBooleanPrototype();
- Object obj(new BooleanInstanceImp(proto));
+ Object obj(new BooleanInstanceImp(exec->interpreter()->builtinBooleanPrototype().imp()));
Boolean b;
if (args.size() > 0)
diff --git a/JavaScriptCore/kjs/bool_object.h b/JavaScriptCore/kjs/bool_object.h
index e5880f9..934f510 100644
--- a/JavaScriptCore/kjs/bool_object.h
+++ b/JavaScriptCore/kjs/bool_object.h
@@ -29,7 +29,7 @@ namespace KJS {
class BooleanInstanceImp : public ObjectImp {
public:
- BooleanInstanceImp(const Object &proto);
+ BooleanInstanceImp(ObjectImp *proto);
virtual const ClassInfo *classInfo() const { return &info; }
static const ClassInfo info;
diff --git a/JavaScriptCore/kjs/collector.cpp b/JavaScriptCore/kjs/collector.cpp
index c350fb4..964be0b 100644
--- a/JavaScriptCore/kjs/collector.cpp
+++ b/JavaScriptCore/kjs/collector.cpp
@@ -99,6 +99,7 @@ void* Collector::allocate(size_t s)
void *newCell = malloc(s);
heap.oversizeCells[heap.usedOversizeCells] = (CollectorCell *)newCell;
heap.usedOversizeCells++;
+ heap.numLiveObjects++;
return (void *)newCell;
}
@@ -140,6 +141,7 @@ void* Collector::allocate(size_t s)
if (cellPos < CELLS_PER_BLOCK) {
targetBlock->bitmap[wordInBitmap] |= (1 << bitInWord);
targetBlock->usedCells++;
+ heap.numLiveObjects++;
return (void *)(targetBlock->cells + cellPos);
}
}
@@ -292,6 +294,7 @@ void Collector::finalCheck()
#endif
#if APPLE_CHANGES
+
int Collector::numInterpreters()
{
int count = 0;
@@ -342,7 +345,7 @@ int Collector::numReferencedObjects()
ValueImp *imp = (ValueImp *)(heap.blocks[block]->cells + BITS_PER_WORD * wordInBitmap + bitInWord);
if ((word & (1 << bitInWord)) &&
- imp->refcount == 0) {
+ imp->refcount != 0) {
++count;
}
}
@@ -351,7 +354,7 @@ int Collector::numReferencedObjects()
for (int cell = 0; cell < heap.usedOversizeCells; cell++) {
ValueImp *imp = (ValueImp *)heap.oversizeCells[cell];
- if (imp->refcount == 0) {
+ if (imp->refcount != 0) {
++count;
}
}
@@ -359,6 +362,7 @@ int Collector::numReferencedObjects()
return count;
}
+// FIXME: Rename. Root object classes are more useful than live object classes.
CFSetRef Collector::liveObjectClasses()
{
CFMutableSetRef classes = CFSetCreateMutable(NULL, 0, &kCFTypeSetCallBacks);
@@ -369,7 +373,8 @@ CFSetRef Collector::liveObjectClasses()
for (int bitInWord = 0; bitInWord < BITS_PER_WORD; bitInWord++) {
ValueImp *imp = (ValueImp *)(heap.blocks[block]->cells + BITS_PER_WORD * wordInBitmap + bitInWord);
- if (word & (1 << bitInWord)) {
+ if (word & (1 << bitInWord)
+ && ((imp->_flags & ValueImp::VI_GCALLOWED) == 0 || imp->refcount != 0)) {
const char *mangled_name = typeid(*imp).name();
int status;
char *demangled_name = __cxxabiv1::__cxa_demangle (mangled_name, NULL, NULL, &status);
@@ -385,18 +390,20 @@ CFSetRef Collector::liveObjectClasses()
for (int cell = 0; cell < heap.usedOversizeCells; cell++) {
ValueImp *imp = (ValueImp *)heap.oversizeCells[cell];
-
- const char *mangled_name = typeid(*imp).name();
- int status;
- char *demangled_name = __cxxabiv1::__cxa_demangle (mangled_name, NULL, NULL, &status);
- CFStringRef className = CFStringCreateWithCString(NULL, demangled_name, kCFStringEncodingASCII);
- free(demangled_name);
- CFSetAddValue(classes, className);
- CFRelease(className);
+ if ((imp->_flags & ValueImp::VI_GCALLOWED) == 0 || imp->refcount != 0) {
+ const char *mangled_name = typeid(*imp).name();
+ int status;
+ char *demangled_name = __cxxabiv1::__cxa_demangle (mangled_name, NULL, NULL, &status);
+
+ CFStringRef className = CFStringCreateWithCString(NULL, demangled_name, kCFStringEncodingASCII);
+ free(demangled_name);
+ CFSetAddValue(classes, className);
+ CFRelease(className);
+ }
}
return classes;
}
-#endif
+#endif // APPLE_CHANGES
diff --git a/JavaScriptCore/kjs/date_object.cpp b/JavaScriptCore/kjs/date_object.cpp
index 2496e3f..49eecce 100644
--- a/JavaScriptCore/kjs/date_object.cpp
+++ b/JavaScriptCore/kjs/date_object.cpp
@@ -209,7 +209,7 @@ using namespace KJS;
const ClassInfo DateInstanceImp::info = {"Date", 0, 0, 0};
-DateInstanceImp::DateInstanceImp(const Object &proto)
+DateInstanceImp::DateInstanceImp(ObjectImp *proto)
: ObjectImp(proto)
{
}
@@ -271,10 +271,10 @@ const ClassInfo DatePrototypeImp::info = {"Date", 0, &dateTable, 0};
DatePrototypeImp::DatePrototypeImp(ExecState *,
ObjectPrototypeImp *objectProto)
- : DateInstanceImp(Object(objectProto))
+ : DateInstanceImp(objectProto)
{
Value protect(this);
- setInternalValue(Number(NaN));
+ setInternalValue(NumberImp::create(NaN));
// The constructor will be added later, after DateObjectImp has been built
}
@@ -292,7 +292,7 @@ DateProtoFuncImp::DateProtoFuncImp(ExecState *exec, int i, int len)
// We use a negative ID to denote the "UTC" variant.
{
Value protect(this);
- put(exec,lengthPropertyName,Number(len),DontDelete|ReadOnly|DontEnum);
+ putDirect(lengthPropertyName, len, DontDelete|ReadOnly|DontEnum);
}
bool DateProtoFuncImp::implementsCall() const
@@ -523,14 +523,17 @@ DateObjectImp::DateObjectImp(ExecState *exec,
: InternalFunctionImp(funcProto)
{
Value protect(this);
+
// ECMA 15.9.4.1 Date.prototype
- put(exec,prototypePropertyName, Object(dateProto), DontEnum|DontDelete|ReadOnly);
+ putDirect(prototypePropertyName, dateProto, DontEnum|DontDelete|ReadOnly);
- put(exec,"parse", Object(new DateObjectFuncImp(exec,funcProto,DateObjectFuncImp::Parse, 1)), DontEnum);
- put(exec,"UTC", Object(new DateObjectFuncImp(exec,funcProto,DateObjectFuncImp::UTC, 7)), DontEnum);
+ static const Identifier parsePropertyName("parse");
+ putDirect(parsePropertyName, new DateObjectFuncImp(exec,funcProto,DateObjectFuncImp::Parse, 1), DontEnum);
+ static const Identifier UTCPropertyName("UTC");
+ putDirect("UTC", new DateObjectFuncImp(exec,funcProto,DateObjectFuncImp::UTC, 7), DontEnum);
// no. of arguments for constructor
- put(exec,lengthPropertyName, Number(7), ReadOnly|DontDelete|DontEnum);
+ putDirect(lengthPropertyName, 7, ReadOnly|DontDelete|DontEnum);
}
bool DateObjectImp::implementsConstruct() const
@@ -601,7 +604,7 @@ Object DateObjectImp::construct(ExecState *exec, const List &args)
}
Object proto = exec->interpreter()->builtinDatePrototype();
- Object ret(new DateInstanceImp(proto));
+ Object ret(new DateInstanceImp(proto.imp()));
ret.setInternalValue(timeClip(value));
return ret;
}
@@ -636,7 +639,7 @@ DateObjectFuncImp::DateObjectFuncImp(ExecState *exec, FunctionPrototypeImp *func
: InternalFunctionImp(funcProto), id(i)
{
Value protect(this);
- put(exec,lengthPropertyName,Number(len),DontDelete|ReadOnly|DontEnum);
+ putDirect(lengthPropertyName, len, DontDelete|ReadOnly|DontEnum);
}
bool DateObjectFuncImp::implementsCall() const
diff --git a/JavaScriptCore/kjs/date_object.h b/JavaScriptCore/kjs/date_object.h
index 14bdc32..51b59aa 100644
--- a/JavaScriptCore/kjs/date_object.h
+++ b/JavaScriptCore/kjs/date_object.h
@@ -31,7 +31,7 @@ namespace KJS {
class DateInstanceImp : public ObjectImp {
public:
- DateInstanceImp(const Object &proto);
+ DateInstanceImp(ObjectImp *proto);
virtual const ClassInfo *classInfo() const { return &info; }
static const ClassInfo info;
diff --git a/JavaScriptCore/kjs/error_object.cpp b/JavaScriptCore/kjs/error_object.cpp
index 00f8a53..86932a4 100644
--- a/JavaScriptCore/kjs/error_object.cpp
+++ b/JavaScriptCore/kjs/error_object.cpp
@@ -35,7 +35,7 @@ using namespace KJS;
ErrorPrototypeImp::ErrorPrototypeImp(ExecState *exec,
ObjectPrototypeImp *objectProto,
FunctionPrototypeImp *funcProto)
- : ObjectImp(Object(objectProto))
+ : ObjectImp(objectProto)
{
Value protect(this);
setInternalValue(Undefined());
@@ -43,7 +43,7 @@ ErrorPrototypeImp::ErrorPrototypeImp(ExecState *exec,
put(exec, namePropertyName, String("Error"), DontEnum);
put(exec, messagePropertyName, String("Unknown error"), DontEnum);
- put(exec, toStringPropertyName, Object(new ErrorProtoFuncImp(exec,funcProto)), DontEnum);
+ putDirect(toStringPropertyName, new ErrorProtoFuncImp(exec,funcProto), DontEnum);
}
// ------------------------------ ErrorProtoFuncImp ----------------------------
@@ -52,7 +52,7 @@ ErrorProtoFuncImp::ErrorProtoFuncImp(ExecState *exec, FunctionPrototypeImp *func
: InternalFunctionImp(funcProto)
{
Value protect(this);
- put(exec,lengthPropertyName,Number(0),DontDelete|ReadOnly|DontEnum);
+ putDirect(lengthPropertyName, NumberImp::zero(), DontDelete|ReadOnly|DontEnum);
}
bool ErrorProtoFuncImp::implementsCall() const
@@ -86,8 +86,8 @@ ErrorObjectImp::ErrorObjectImp(ExecState *exec, FunctionPrototypeImp *funcProto,
{
Value protect(this);
// ECMA 15.11.3.1 Error.prototype
- put(exec, prototypePropertyName, Object(errorProto), DontEnum|DontDelete|ReadOnly);
- //put(exec, namePropertyName, String(n));
+ putDirect(prototypePropertyName, errorProto, DontEnum|DontDelete|ReadOnly);
+ //putDirect(namePropertyName, String(n));
}
bool ErrorObjectImp::implementsConstruct() const
@@ -99,10 +99,11 @@ bool ErrorObjectImp::implementsConstruct() const
Object ErrorObjectImp::construct(ExecState *exec, const List &args)
{
Object proto = Object::dynamicCast(exec->interpreter()->builtinErrorPrototype());
- Object obj(new ObjectImp(proto));
+ ObjectImp *imp = new ObjectImp(proto);
+ Object obj(imp);
if (!args.isEmpty() && args[0].type() != UndefinedType) {
- obj.put(exec, messagePropertyName, String(args[0].toString(exec)));
+ imp->putDirect(messagePropertyName, new StringImp(args[0].toString(exec)));
}
return obj;
@@ -124,12 +125,12 @@ Value ErrorObjectImp::call(ExecState *exec, Object &/*thisObj*/, const List &arg
NativeErrorPrototypeImp::NativeErrorPrototypeImp(ExecState *exec, ErrorPrototypeImp *errorProto,
ErrorType et, UString name, UString message)
- : ObjectImp(Object(errorProto))
+ : ObjectImp(errorProto)
{
Value protect(this);
errType = et;
- put(exec, namePropertyName, String(name));
- put(exec, messagePropertyName, String(message));
+ putDirect(namePropertyName, new StringImp(name), 0);
+ putDirect(messagePropertyName, new StringImp(message), 0);
}
// ------------------------------ NativeErrorImp -------------------------------
@@ -143,8 +144,8 @@ NativeErrorImp::NativeErrorImp(ExecState *exec, FunctionPrototypeImp *funcProto,
Value protect(this);
proto = static_cast<ObjectImp*>(prot.imp());
- put(exec,lengthPropertyName,Number(1),DontDelete|ReadOnly|DontEnum); // ECMA 15.11.7.5
- put(exec,prototypePropertyName,prot);
+ putDirect(lengthPropertyName, NumberImp::one(), DontDelete|ReadOnly|DontEnum); // ECMA 15.11.7.5
+ putDirect(prototypePropertyName, proto, 0);
}
bool NativeErrorImp::implementsConstruct() const
@@ -154,9 +155,10 @@ bool NativeErrorImp::implementsConstruct() const
Object NativeErrorImp::construct(ExecState *exec, const List &args)
{
- Object obj(new ObjectImp(Object(proto)));
+ ObjectImp *imp = new ObjectImp(proto);
+ Object obj(imp);
if (args[0].type() != UndefinedType)
- obj.put(exec, messagePropertyName, String(args[0].toString(exec)));
+ imp->putDirect(messagePropertyName, new StringImp(args[0].toString(exec)));
return obj;
}
@@ -176,4 +178,3 @@ void NativeErrorImp::mark()
if (proto && !proto->marked())
proto->mark();
}
-
diff --git a/JavaScriptCore/kjs/function.cpp b/JavaScriptCore/kjs/function.cpp
index 46a62cb..fe6e5e1 100644
--- a/JavaScriptCore/kjs/function.cpp
+++ b/JavaScriptCore/kjs/function.cpp
@@ -318,17 +318,10 @@ const ClassInfo ArgumentsImp::info = {"Arguments", 0, 0, 0};
// ECMA 10.1.8
ArgumentsImp::ArgumentsImp(ExecState *exec, FunctionImp *func, const List &args)
- : ObjectImp(exec->interpreter()->builtinObjectPrototype())
+ : ArrayInstanceImp(exec->interpreter()->builtinObjectPrototype().imp(), args)
{
Value protect(this);
- put(exec,calleePropertyName, Object(func), DontEnum);
- put(exec,lengthPropertyName, Number(args.size()), DontEnum);
- if (!args.isEmpty()) {
- ListIterator arg = args.begin();
- for (int i = 0; arg != args.end(); arg++, i++) {
- put(exec,i, *arg, DontEnum);
- }
- }
+ putDirect(calleePropertyName, func, DontEnum);
}
// ------------------------------ ActivationImp --------------------------------
@@ -337,12 +330,11 @@ const ClassInfo ActivationImp::info = {"Activation", 0, 0, 0};
// ECMA 10.1.6
ActivationImp::ActivationImp(ExecState *exec, FunctionImp *f, const List &args)
- : _function(f)
+ : _function(f), _arguments(args)
{
Value protect(this);
- arguments = new ArgumentsImp(exec,f, args);
- arguments->setGcAllowed();
- put(exec, argumentsPropertyName, Object(arguments), Internal|DontDelete);
+ _argumentsObject = new ArgumentsImp(exec, f, args);
+ putDirect(argumentsPropertyName, _argumentsObject, Internal|DontDelete);
}
// ------------------------------ GlobalFunc -----------------------------------
@@ -352,7 +344,7 @@ GlobalFuncImp::GlobalFuncImp(ExecState *exec, FunctionPrototypeImp *funcProto, i
: InternalFunctionImp(funcProto), id(i)
{
Value protect(this);
- put(exec,lengthPropertyName,Number(len),DontDelete|ReadOnly|DontEnum);
+ putDirect(lengthPropertyName, len, DontDelete|ReadOnly|DontEnum);
}
CodeType GlobalFuncImp::codeType() const
diff --git a/JavaScriptCore/kjs/function.h b/JavaScriptCore/kjs/function.h
index 4103d09..ea05211 100644
--- a/JavaScriptCore/kjs/function.h
+++ b/JavaScriptCore/kjs/function.h
@@ -24,6 +24,7 @@
#define _KJS_FUNCTION_H_
#include "internal.h"
+#include "array_instance.h"
namespace KJS {
@@ -90,7 +91,7 @@ namespace KJS {
- class ArgumentsImp : public ObjectImp {
+ class ArgumentsImp : public ArrayInstanceImp {
public:
ArgumentsImp(ExecState *exec, FunctionImp *func, const List &args);
@@ -102,8 +103,6 @@ namespace KJS {
public:
ActivationImp(ExecState *exec, FunctionImp *f, const List &args);
- Object argumentsObject() { return Object(arguments); }
-
virtual const ClassInfo *classInfo() const { return &info; }
static const ClassInfo info;
@@ -111,7 +110,8 @@ namespace KJS {
private:
FunctionImp *_function;
- ObjectImp* arguments;
+ List _arguments;
+ ObjectImp *_argumentsObject;
};
class GlobalFuncImp : public InternalFunctionImp {
diff --git a/JavaScriptCore/kjs/function_object.cpp b/JavaScriptCore/kjs/function_object.cpp
index 24880fb..b29b2a1 100644
--- a/JavaScriptCore/kjs/function_object.cpp
+++ b/JavaScriptCore/kjs/function_object.cpp
@@ -40,9 +40,11 @@ FunctionPrototypeImp::FunctionPrototypeImp(ExecState *exec)
: InternalFunctionImp(0)
{
Value protect(this);
- put(exec, toStringPropertyName, Object(new FunctionProtoFuncImp(exec, this, FunctionProtoFuncImp::ToString, 0)), DontEnum);
- put(exec, "apply", Object(new FunctionProtoFuncImp(exec, this, FunctionProtoFuncImp::Apply, 2)), DontEnum);
- put(exec, "call", Object(new FunctionProtoFuncImp(exec, this, FunctionProtoFuncImp::Call, 1)), DontEnum);
+ putDirect(toStringPropertyName, new FunctionProtoFuncImp(exec, this, FunctionProtoFuncImp::ToString, 0), DontEnum);
+ static const Identifier applyPropertyName("apply");
+ putDirect(applyPropertyName, new FunctionProtoFuncImp(exec, this, FunctionProtoFuncImp::Apply, 2), DontEnum);
+ static const Identifier callPropertyName("call");
+ putDirect(callPropertyName, new FunctionProtoFuncImp(exec, this, FunctionProtoFuncImp::Call, 1), DontEnum);
}
FunctionPrototypeImp::~FunctionPrototypeImp()
@@ -67,7 +69,7 @@ FunctionProtoFuncImp::FunctionProtoFuncImp(ExecState *exec,
: InternalFunctionImp(funcProto), id(i)
{
Value protect(this);
- put(exec,lengthPropertyName,Number(len),DontDelete|ReadOnly|DontEnum);
+ putDirect(lengthPropertyName, len, DontDelete|ReadOnly|DontEnum);
}
@@ -174,10 +176,10 @@ FunctionObjectImp::FunctionObjectImp(ExecState *exec, FunctionPrototypeImp *func
: InternalFunctionImp(funcProto)
{
Value protect(this);
- put(exec,prototypePropertyName, Object(funcProto), DontEnum|DontDelete|ReadOnly);
+ putDirect(prototypePropertyName, funcProto, DontEnum|DontDelete|ReadOnly);
// no. of arguments for constructor
- put(exec,lengthPropertyName, Number(1), ReadOnly|DontDelete|DontEnum);
+ putDirect(lengthPropertyName, NumberImp::one(), ReadOnly|DontDelete|DontEnum);
}
FunctionObjectImp::~FunctionObjectImp()
@@ -275,14 +277,12 @@ Object FunctionObjectImp::construct(ExecState *exec, const List &args)
return err;
}
- fimp->put(exec,lengthPropertyName, Number(params),ReadOnly|DontDelete|DontEnum);
List consArgs;
Object objCons = exec->interpreter()->builtinObject();
Object prototype = objCons.construct(exec,List::empty());
- prototype.put(exec, constructorPropertyName,
- Object(fimp), DontEnum|DontDelete|ReadOnly);
- fimp->put(exec,prototypePropertyName,prototype,DontEnum|DontDelete|ReadOnly);
+ prototype.put(exec, constructorPropertyName, Value(fimp), DontEnum|DontDelete|ReadOnly);
+ fimp->put(exec, prototypePropertyName, prototype, DontEnum|DontDelete|ReadOnly);
return ret;
}
diff --git a/JavaScriptCore/kjs/internal.cpp b/JavaScriptCore/kjs/internal.cpp
index 7daa191..e7c6eab 100644
--- a/JavaScriptCore/kjs/internal.cpp
+++ b/JavaScriptCore/kjs/internal.cpp
@@ -221,6 +221,28 @@ Object StringImp::toObject(ExecState *exec) const
// ------------------------------ NumberImp ------------------------------------
+NumberImp *NumberImp::staticNaN;
+
+ValueImp *NumberImp::create(int i)
+{
+ if (SimpleNumber::fits(i))
+ return SimpleNumber::make(i);
+ NumberImp *imp = new NumberImp(static_cast<double>(i));
+ imp->setGcAllowedFast();
+ return imp;
+}
+
+ValueImp *NumberImp::create(double d)
+{
+ if (SimpleNumber::fits(d))
+ return SimpleNumber::make((int)d);
+ if (isNaN(d))
+ return staticNaN;
+ NumberImp *imp = new NumberImp(d);
+ imp->setGcAllowedFast();
+ return imp;
+}
+
Value NumberImp::toPrimitive(ExecState *, Type) const
{
return Number((NumberImp*)this);
@@ -452,6 +474,8 @@ void InterpreterImp::globalInit()
BooleanImp::staticTrue->ref();
BooleanImp::staticFalse = new BooleanImp(false);
BooleanImp::staticFalse->ref();
+ NumberImp::staticNaN = new NumberImp(NaN);
+ NumberImp::staticNaN->ref();
}
void InterpreterImp::globalClear()
@@ -469,6 +493,9 @@ void InterpreterImp::globalClear()
BooleanImp::staticFalse->deref();
BooleanImp::staticFalse->setGcAllowed();
BooleanImp::staticFalse = 0L;
+ NumberImp::staticNaN->deref();
+ NumberImp::staticNaN->setGcAllowed();
+ NumberImp::staticNaN = 0;
}
InterpreterImp::InterpreterImp(Interpreter *interp, const Object &glob)
@@ -786,7 +813,7 @@ void InterpreterImp::setDebugger(Debugger *d)
const ClassInfo InternalFunctionImp::info = {"Function", 0, 0, 0};
InternalFunctionImp::InternalFunctionImp(FunctionPrototypeImp *funcProto)
- : ObjectImp(Object(funcProto))
+ : ObjectImp(funcProto)
{
}
diff --git a/JavaScriptCore/kjs/internal.h b/JavaScriptCore/kjs/internal.h
index 1779ba1..7ffa488 100644
--- a/JavaScriptCore/kjs/internal.h
+++ b/JavaScriptCore/kjs/internal.h
@@ -118,8 +118,15 @@ namespace KJS {
inline String::String(StringImp *imp) : Value(imp) { }
class NumberImp : public ValueImp {
+ friend class Number;
+ friend class InterpreterImp;
public:
- NumberImp(double v) : val(v) { }
+ static ValueImp *create(int);
+ static ValueImp *create(double);
+ static ValueImp *zero() { return SimpleNumber::make(0); }
+ static ValueImp *one() { return SimpleNumber::make(1); }
+ static ValueImp *two() { return SimpleNumber::make(2); }
+
double value() const { return val; }
Type type() const { return NumberType; }
@@ -130,7 +137,11 @@ namespace KJS {
UString toString(ExecState *exec) const;
Object toObject(ExecState *exec) const;
+ static NumberImp *staticNaN;
+
private:
+ NumberImp(double v) : val(v) { }
+
virtual bool toUInt32(unsigned&) const;
double val;
diff --git a/JavaScriptCore/kjs/math_object.cpp b/JavaScriptCore/kjs/math_object.cpp
index fd2defc..9713bc0 100644
--- a/JavaScriptCore/kjs/math_object.cpp
+++ b/JavaScriptCore/kjs/math_object.cpp
@@ -76,7 +76,7 @@ const ClassInfo MathObjectImp::info = { "Math", 0, &mathTable, 0 };
MathObjectImp::MathObjectImp(ExecState * /*exec*/,
ObjectPrototypeImp *objProto)
- : ObjectImp(Object(objProto))
+ : ObjectImp(objProto)
{
}
@@ -130,7 +130,7 @@ MathFuncImp::MathFuncImp(ExecState *exec, int i, int l)
), id(i)
{
Value protect(this);
- put(exec,lengthPropertyName,Number(l),DontDelete|ReadOnly|DontEnum);
+ putDirect(lengthPropertyName, l, DontDelete|ReadOnly|DontEnum);
}
bool MathFuncImp::implementsCall() const
diff --git a/JavaScriptCore/kjs/nodes.cpp b/JavaScriptCore/kjs/nodes.cpp
index 0992759..7b1b9c3 100644
--- a/JavaScriptCore/kjs/nodes.cpp
+++ b/JavaScriptCore/kjs/nodes.cpp
@@ -228,7 +228,7 @@ Reference ResolveNode::evaluateReference(ExecState *exec)
if (o->hasProperty(exec,ident)) {
//cout << "Resolve: FOUND '" << ident.ascii() << "'"
// << " in " << (void*)o << " " << o->classInfo()->className << endl;
- return Reference(Object(o), ident);
+ return Reference(o, ident);
}
scope++;
}
diff --git a/JavaScriptCore/kjs/number_object.cpp b/JavaScriptCore/kjs/number_object.cpp
index 5b60e68..1e974bb 100644
--- a/JavaScriptCore/kjs/number_object.cpp
+++ b/JavaScriptCore/kjs/number_object.cpp
@@ -50,13 +50,13 @@ NumberPrototypeImp::NumberPrototypeImp(ExecState *exec,
: NumberInstanceImp(Object(objProto))
{
Value protect(this);
- setInternalValue(Number(0));
+ setInternalValue(NumberImp::zero());
// The constructor will be added later, after NumberObjectImp has been constructed
- put(exec,toStringPropertyName, Object(new NumberProtoFuncImp(exec,funcProto,NumberProtoFuncImp::ToString, 1)), DontEnum);
- put(exec,toLocaleStringPropertyName, Object(new NumberProtoFuncImp(exec,funcProto,NumberProtoFuncImp::ToLocaleString, 0)), DontEnum);
- put(exec,valueOfPropertyName, Object(new NumberProtoFuncImp(exec,funcProto,NumberProtoFuncImp::ValueOf, 0)), DontEnum);
+ putDirect(toStringPropertyName, new NumberProtoFuncImp(exec,funcProto,NumberProtoFuncImp::ToString, 1), DontEnum);
+ putDirect(toLocaleStringPropertyName, new NumberProtoFuncImp(exec,funcProto,NumberProtoFuncImp::ToLocaleString, 0), DontEnum);
+ putDirect(valueOfPropertyName, new NumberProtoFuncImp(exec,funcProto,NumberProtoFuncImp::ValueOf, 0), DontEnum);
}
@@ -67,7 +67,7 @@ NumberProtoFuncImp::NumberProtoFuncImp(ExecState *exec,
: InternalFunctionImp(funcProto), id(i)
{
Value protect(this);
- put(exec,lengthPropertyName,Number(len),DontDelete|ReadOnly|DontEnum);
+ putDirect(lengthPropertyName, len, DontDelete|ReadOnly|DontEnum);
}
@@ -124,10 +124,10 @@ NumberObjectImp::NumberObjectImp(ExecState *exec,
{
Value protect(this);
// Number.Prototype
- put(exec,prototypePropertyName, Value(numberProto),DontEnum|DontDelete|ReadOnly);
+ putDirect(prototypePropertyName, numberProto,DontEnum|DontDelete|ReadOnly);
// no. of arguments for constructor
- put(exec,lengthPropertyName, Number(1), ReadOnly|DontDelete|DontEnum);
+ putDirect(lengthPropertyName, NumberImp::one(), ReadOnly|DontDelete|DontEnum);
}
Value NumberObjectImp::get(ExecState *exec, const Identifier &propertyName) const
diff --git a/JavaScriptCore/kjs/object.cpp b/JavaScriptCore/kjs/object.cpp
index 7107f58..50114e6 100644
--- a/JavaScriptCore/kjs/object.cpp
+++ b/JavaScriptCore/kjs/object.cpp
@@ -58,6 +58,12 @@ ObjectImp::ObjectImp(const Object &proto)
//fprintf(stderr,"ObjectImp::ObjectImp %p\n",(void*)this);
}
+ObjectImp::ObjectImp(ObjectImp *proto)
+ : _proto(proto), _internalValue(0L), _scope(true)
+{
+ //fprintf(stderr,"ObjectImp::ObjectImp %p\n",(void*)this);
+}
+
ObjectImp::ObjectImp() :
_scope(true)
{
@@ -152,15 +158,6 @@ Value ObjectImp::get(ExecState *exec, unsigned propertyName) const
return get(exec, Identifier::from(propertyName));
}
-// This get method only looks at the property map.
-// A bit like hasProperty(recursive=false), this doesn't go to the prototype.
-// This is used e.g. by lookupOrCreateFunction (to cache a function, we don't want
-// to look up in the prototype, it might already exist there)
-ValueImp* ObjectImp::getDirect(const Identifier& propertyName) const
-{
- return _prop.get(propertyName);
-}
-
// ECMA 8.6.2.2
void ObjectImp::put(ExecState *exec, const Identifier &propertyName,
const Value &value, int attr)
@@ -168,6 +165,12 @@ void ObjectImp::put(ExecState *exec, const Identifier &propertyName,
assert(!value.isNull());
assert(value.type() != ListType);
+ // non-standard netscape extension
+ if (propertyName == specialPrototypePropertyName) {
+ setPrototype(value);
+ return;
+ }
+
/* TODO: check for write permissions directly w/o this call */
/* Doesn't look very easy with the PropertyMap API - David */
// putValue() is used for JS assignemnts. It passes no attribute.
@@ -180,12 +183,6 @@ void ObjectImp::put(ExecState *exec, const Identifier &propertyName,
return;
}
- // non-standard netscape extension
- if (propertyName == specialPrototypePropertyName) {
- setPrototype(value);
- return;
- }
-
_prop.put(propertyName,value.imp(),attr);
}
@@ -394,7 +391,7 @@ ReferenceList ObjectImp::propList(ExecState *exec, bool recursive)
const HashEntry *e = info->propHashTable->entries;
for (int i = 0; i < size; ++i, ++e) {
if ( e->s && !(e->attr & DontEnum) )
- list.append(Reference(Object(this), e->s)); /// ######### check for duplicates with the propertymap
+ list.append(Reference(this, e->s)); /// ######### check for duplicates with the propertymap
}
}
info = info->parentClass;
@@ -413,6 +410,12 @@ void ObjectImp::setInternalValue(const Value &v)
_internalValue = v.imp();
}
+void ObjectImp::setInternalValue(ValueImp *v)
+{
+ v->setGcAllowed();
+ _internalValue = v;
+}
+
Value ObjectImp::toPrimitive(ExecState *exec, Type preferredType) const
{
return defaultValue(exec,preferredType);
@@ -444,6 +447,16 @@ Object ObjectImp::toObject(ExecState */*exec*/) const
return Object(const_cast<ObjectImp*>(this));
}
+void ObjectImp::putDirect(const Identifier &propertyName, ValueImp *value, int attr)
+{
+ value->setGcAllowed();
+ _prop.put(propertyName, value, attr);
+}
+
+void ObjectImp::putDirect(const Identifier &propertyName, int value, int attr)
+{
+ _prop.put(propertyName, NumberImp::create(value), attr);
+}
// ------------------------------ Error ----------------------------------------
diff --git a/JavaScriptCore/kjs/object.h b/JavaScriptCore/kjs/object.h
index 34a31cc..058fe6c 100644
--- a/JavaScriptCore/kjs/object.h
+++ b/JavaScriptCore/kjs/object.h
@@ -369,6 +369,7 @@ namespace KJS {
* @param proto The prototype
*/
ObjectImp(const Object &proto);
+ ObjectImp(ObjectImp *proto);
/**
* Creates a new ObjectImp with a prototype of Null()
@@ -524,7 +525,7 @@ namespace KJS {
* This doesn't take DontDelete into account, and isn't in the ECMA spec.
* It's simply a quick way to remove everything before destroying.
*/
- void deleteAllProperties( ExecState * );
+ void deleteAllProperties(ExecState *);
/**
* Implementation of the [[DefaultValue]] internal property (implemented by
@@ -571,6 +572,7 @@ namespace KJS {
Value internalValue() const;
void setInternalValue(const Value &v);
+ void setInternalValue(ValueImp *v);
Value toPrimitive(ExecState *exec,
Type preferredType = UnspecifiedType) const;
@@ -579,7 +581,15 @@ namespace KJS {
UString toString(ExecState *exec) const;
Object toObject(ExecState *exec) const;
- ValueImp* getDirect(const Identifier& propertyName) const;
+ // This get method only looks at the property map.
+ // A bit like hasProperty(recursive=false), this doesn't go to the prototype.
+ // This is used e.g. by lookupOrCreateFunction (to cache a function, we don't want
+ // to look up in the prototype, it might already exist there)
+ ValueImp *getDirect(const Identifier& propertyName) const
+ { return _prop.get(propertyName); }
+ void putDirect(const Identifier &propertyName, ValueImp *value, int attr = 0);
+ void putDirect(const Identifier &propertyName, int value, int attr = 0);
+
private:
const HashEntry* findPropertyHashEntry( const Identifier& propertyName ) const;
PropertyMap _prop;
diff --git a/JavaScriptCore/kjs/object_object.cpp b/JavaScriptCore/kjs/object_object.cpp
index 74ba0c6..9e57824 100644
--- a/JavaScriptCore/kjs/object_object.cpp
+++ b/JavaScriptCore/kjs/object_object.cpp
@@ -38,8 +38,8 @@ ObjectPrototypeImp::ObjectPrototypeImp(ExecState *exec,
: ObjectImp() // [[Prototype]] is Null()
{
Value protect(this);
- put(exec,toStringPropertyName, Object(new ObjectProtoFuncImp(exec,funcProto,ObjectProtoFuncImp::ToString, 0)), DontEnum);
- put(exec,valueOfPropertyName, Object(new ObjectProtoFuncImp(exec,funcProto,ObjectProtoFuncImp::ValueOf, 0)), DontEnum);
+ putDirect(toStringPropertyName, new ObjectProtoFuncImp(exec,funcProto,ObjectProtoFuncImp::ToString, 0), DontEnum);
+ putDirect(valueOfPropertyName, new ObjectProtoFuncImp(exec,funcProto,ObjectProtoFuncImp::ValueOf, 0), DontEnum);
}
@@ -51,7 +51,7 @@ ObjectProtoFuncImp::ObjectProtoFuncImp(ExecState *exec,
: InternalFunctionImp(funcProto), id(i)
{
Value protect(this);
- put(exec,lengthPropertyName,Number(len),DontDelete|ReadOnly|DontEnum);
+ putDirect(lengthPropertyName, len, DontDelete|ReadOnly|DontEnum);
}
@@ -79,10 +79,10 @@ ObjectObjectImp::ObjectObjectImp(ExecState *exec,
{
Value protect(this);
// ECMA 15.2.3.1
- put(exec,prototypePropertyName, Object(objProto), DontEnum|DontDelete|ReadOnly);
+ putDirect(prototypePropertyName, objProto, DontEnum|DontDelete|ReadOnly);
// no. of arguments for constructor
- put(exec,lengthPropertyName, Number(1), ReadOnly|DontDelete|DontEnum);
+ putDirect(lengthPropertyName, NumberImp::one(), ReadOnly|DontDelete|DontEnum);
}
diff --git a/JavaScriptCore/kjs/property_map.cpp b/JavaScriptCore/kjs/property_map.cpp
index 4cca568..77c7d5b 100644
--- a/JavaScriptCore/kjs/property_map.cpp
+++ b/JavaScriptCore/kjs/property_map.cpp
@@ -126,7 +126,7 @@ ValueImp *PropertyMap::get(const Identifier &name) const
void PropertyMap::put(const Identifier &name, ValueImp *value, int attributes)
{
UString::Rep *rep = name._ustring.rep;
-
+
#if USE_SINGLE_ENTRY
if (!_table) {
UString::Rep *key = _singleEntry.key;
diff --git a/JavaScriptCore/kjs/reference.cpp b/JavaScriptCore/kjs/reference.cpp
index 4f598b3..9c9967b 100644
--- a/JavaScriptCore/kjs/reference.cpp
+++ b/JavaScriptCore/kjs/reference.cpp
@@ -43,6 +43,22 @@ Reference::Reference(const Object& b, unsigned p)
{
}
+Reference::Reference(ObjectImp *b, const Identifier& p)
+ : base(b),
+ baseIsValue(false),
+ propertyNameIsNumber(false),
+ prop(p)
+{
+}
+
+Reference::Reference(ObjectImp *b, unsigned p)
+ : base(b),
+ propertyNameAsNumber(p),
+ baseIsValue(false),
+ propertyNameIsNumber(true)
+{
+}
+
Reference::Reference(const Null& b, const Identifier& p)
: base(b),
baseIsValue(false),
diff --git a/JavaScriptCore/kjs/reference.h b/JavaScriptCore/kjs/reference.h
index 44b4cd6..d70dc24 100644
--- a/JavaScriptCore/kjs/reference.h
+++ b/JavaScriptCore/kjs/reference.h
@@ -34,6 +34,8 @@ namespace KJS {
public:
Reference(const Object& b, const Identifier& p);
Reference(const Object& b, unsigned p);
+ Reference(ObjectImp *b, const Identifier& p);
+ Reference(ObjectImp *b, unsigned p);
Reference(const Null& b, const Identifier& p);
Reference(const Null& b, unsigned p);
static Reference makeValueReference(const Value& v);
diff --git a/JavaScriptCore/kjs/regexp_object.cpp b/JavaScriptCore/kjs/regexp_object.cpp
index 52e2d98..c912cf5 100644
--- a/JavaScriptCore/kjs/regexp_object.cpp
+++ b/JavaScriptCore/kjs/regexp_object.cpp
@@ -40,16 +40,18 @@ using namespace KJS;
RegExpPrototypeImp::RegExpPrototypeImp(ExecState *exec,
ObjectPrototypeImp *objProto,
FunctionPrototypeImp *funcProto)
- : ObjectImp(Object(objProto))
+ : ObjectImp(objProto)
{
Value protect(this);
setInternalValue(String(""));
// The constructor will be added later in RegExpObject's constructor (?)
- put(exec, "exec", Object(new RegExpProtoFuncImp(exec,funcProto,RegExpProtoFuncImp::Exec, 0)), DontEnum);
- put(exec, "test", Object(new RegExpProtoFuncImp(exec,funcProto,RegExpProtoFuncImp::Test, 0)), DontEnum);
- put(exec, toStringPropertyName, Object(new RegExpProtoFuncImp(exec,funcProto,RegExpProtoFuncImp::ToString, 0)), DontEnum);
+ static const Identifier execPropertyName("exec");
+ putDirect(execPropertyName, new RegExpProtoFuncImp(exec,funcProto,RegExpProtoFuncImp::Exec, 0), DontEnum);
+ static const Identifier testPropertyName("test");
+ putDirect(testPropertyName, new RegExpProtoFuncImp(exec,funcProto,RegExpProtoFuncImp::Test, 0), DontEnum);
+ putDirect(toStringPropertyName, new RegExpProtoFuncImp(exec,funcProto,RegExpProtoFuncImp::ToString, 0), DontEnum);
}
// ------------------------------ RegExpProtoFuncImp ---------------------------
@@ -59,7 +61,7 @@ RegExpProtoFuncImp::RegExpProtoFuncImp(ExecState *exec,
: InternalFunctionImp(funcProto), id(i)
{
Value protect(this);
- put(exec,lengthPropertyName,Number(len),DontDelete|ReadOnly|DontEnum);
+ putDirect(lengthPropertyName, len, DontDelete|ReadOnly|DontEnum);
}
bool RegExpProtoFuncImp::implementsCall() const
@@ -137,7 +139,7 @@ Value RegExpProtoFuncImp::call(ExecState *exec, Object &thisObj, const List &arg
const ClassInfo RegExpImp::info = {"RegExp", 0, 0, 0};
RegExpImp::RegExpImp(RegExpPrototypeImp *regexpProto)
- : ObjectImp(Object(regexpProto)), reg(0L)
+ : ObjectImp(regexpProto), reg(0L)
{
}
@@ -156,10 +158,10 @@ RegExpObjectImp::RegExpObjectImp(ExecState *exec,
{
Value protect(this);
// ECMA 15.10.5.1 RegExp.prototype
- put(exec,prototypePropertyName, Object(regProto), DontEnum|DontDelete|ReadOnly);
+ putDirect(prototypePropertyName, regProto, DontEnum|DontDelete|ReadOnly);
// no. of arguments for constructor
- put(exec,lengthPropertyName, Number(2), ReadOnly|DontDelete|DontEnum);
+ putDirect(lengthPropertyName, NumberImp::two(), ReadOnly|DontDelete|DontEnum);
}
RegExpObjectImp::~RegExpObjectImp()
@@ -221,7 +223,7 @@ bool RegExpObjectImp::implementsConstruct() const
// ECMA 15.10.4
Object RegExpObjectImp::construct(ExecState *exec, const List &args)
{
- String p = args.isEmpty() ? UString("") : args[0].toString(exec);
+ UString p = args.isEmpty() ? UString("") : args[0].toString(exec);
UString flags = args[1].toString(exec);
RegExpPrototypeImp *proto = static_cast<RegExpPrototypeImp*>(exec->interpreter()->builtinRegExpPrototype().imp());
@@ -233,12 +235,12 @@ Object RegExpObjectImp::construct(ExecState *exec, const List &args)
bool multiline = (flags.find("m") >= 0);
// TODO: throw a syntax error on invalid flags
- dat->put(exec, "global", Boolean(global));
- dat->put(exec, "ignoreCase", Boolean(ignoreCase));
- dat->put(exec, "multiline", Boolean(multiline));
+ dat->putDirect("global", global ? BooleanImp::staticTrue : BooleanImp::staticFalse);
+ dat->putDirect("ignoreCase", ignoreCase ? BooleanImp::staticTrue : BooleanImp::staticFalse);
+ dat->putDirect("multiline", multiline ? BooleanImp::staticTrue : BooleanImp::staticFalse);
- dat->put(exec, "source", p);
- dat->put(exec, "lastIndex", Number(0), DontDelete | DontEnum);
+ dat->putDirect("source", new StringImp(p));
+ dat->putDirect("lastIndex", NumberImp::zero(), DontDelete | DontEnum);
int reflags = RegExp::None;
if (global)
@@ -247,7 +249,7 @@ Object RegExpObjectImp::construct(ExecState *exec, const List &args)
reflags |= RegExp::IgnoreCase;
if (multiline)
reflags |= RegExp::Multiline;
- dat->setRegExp(new RegExp(p.value(), reflags));
+ dat->setRegExp(new RegExp(p, reflags));
return obj;
}
diff --git a/JavaScriptCore/kjs/string_object.cpp b/JavaScriptCore/kjs/string_object.cpp
index 7e1818b..0ed3a26 100644
--- a/JavaScriptCore/kjs/string_object.cpp
+++ b/JavaScriptCore/kjs/string_object.cpp
@@ -37,13 +37,13 @@ using namespace KJS;
const ClassInfo StringInstanceImp::info = {"String", 0, 0, 0};
-StringInstanceImp::StringInstanceImp(const Object &proto)
+StringInstanceImp::StringInstanceImp(ObjectImp *proto)
: ObjectImp(proto)
{
setInternalValue(String(""));
}
-StringInstanceImp::StringInstanceImp(const Object &proto, const UString &string)
+StringInstanceImp::StringInstanceImp(ObjectImp *proto, const UString &string)
: ObjectImp(proto)
{
setInternalValue(String(string));
@@ -119,11 +119,11 @@ const ClassInfo StringPrototypeImp::info = {"String", &StringInstanceImp::info,
// ECMA 15.5.4
StringPrototypeImp::StringPrototypeImp(ExecState *exec,
ObjectPrototypeImp *objProto)
- : StringInstanceImp(Object(objProto))
+ : StringInstanceImp(objProto)
{
Value protect(this);
// The constructor will be added later, after StringObjectImp has been built
- put(exec,lengthPropertyName,Number(0),DontDelete|ReadOnly|DontEnum);
+ putDirect(lengthPropertyName, NumberImp::zero(), DontDelete|ReadOnly|DontEnum);
}
@@ -140,7 +140,7 @@ StringProtoFuncImp::StringProtoFuncImp(ExecState *exec, int i, int len)
), id(i)
{
Value protect(this);
- put(exec,lengthPropertyName,Number(len),DontDelete|ReadOnly|DontEnum);
+ putDirect(lengthPropertyName, len, DontDelete|ReadOnly|DontEnum);
}
bool StringProtoFuncImp::implementsCall() const
@@ -531,13 +531,13 @@ StringObjectImp::StringObjectImp(ExecState *exec,
{
Value protect(this);
// ECMA 15.5.3.1 String.prototype
- put(exec,prototypePropertyName, Object(stringProto), DontEnum|DontDelete|ReadOnly);
+ putDirect(prototypePropertyName, stringProto, DontEnum|DontDelete|ReadOnly);
static Identifier fromCharCode("fromCharCode");
- put(exec,fromCharCode, Object(new StringObjectFuncImp(exec,funcProto)), DontEnum);
+ putDirect(fromCharCode, new StringObjectFuncImp(exec,funcProto), DontEnum);
// no. of arguments for constructor
- put(exec,lengthPropertyName, Number(1), ReadOnly|DontDelete|DontEnum);
+ putDirect(lengthPropertyName, NumberImp::one(), ReadOnly|DontDelete|DontEnum);
}
@@ -549,7 +549,7 @@ bool StringObjectImp::implementsConstruct() const
// ECMA 15.5.2
Object StringObjectImp::construct(ExecState *exec, const List &args)
{
- Object proto = exec->interpreter()->builtinStringPrototype();
+ ObjectImp *proto = exec->interpreter()->builtinStringPrototype().imp();
if (args.size() == 0)
return Object(new StringInstanceImp(proto));
return Object(new StringInstanceImp(proto, args.begin()->dispatchToString(exec)));
@@ -578,7 +578,7 @@ StringObjectFuncImp::StringObjectFuncImp(ExecState *exec, FunctionPrototypeImp *
: InternalFunctionImp(funcProto)
{
Value protect(this);
- put(exec,lengthPropertyName,Number(1),DontDelete|ReadOnly|DontEnum);
+ putDirect(lengthPropertyName, NumberImp::one(), DontDelete|ReadOnly|DontEnum);
}
bool StringObjectFuncImp::implementsCall() const
diff --git a/JavaScriptCore/kjs/string_object.h b/JavaScriptCore/kjs/string_object.h
index 5eb6aa9..66f80fd 100644
--- a/JavaScriptCore/kjs/string_object.h
+++ b/JavaScriptCore/kjs/string_object.h
@@ -29,8 +29,8 @@ namespace KJS {
class StringInstanceImp : public ObjectImp {
public:
- StringInstanceImp(const Object &proto);
- StringInstanceImp(const Object &proto, const UString &string);
+ StringInstanceImp(ObjectImp *proto);
+ StringInstanceImp(ObjectImp *proto, const UString &string);
virtual Value get(ExecState *exec, const Identifier &propertyName) const;
virtual void put(ExecState *exec, const Identifier &propertyName, const Value &value, int attr = None);
diff --git a/JavaScriptCore/kjs/value.cpp b/JavaScriptCore/kjs/value.cpp
index 96e58d0..6637ddb 100644
--- a/JavaScriptCore/kjs/value.cpp
+++ b/JavaScriptCore/kjs/value.cpp
@@ -202,9 +202,9 @@ bool ValueImp::dispatchToUInt32(unsigned& result) const
Value::Value(ValueImp *v)
{
rep = v;
- if (rep)
+ if (v)
{
- rep->ref();
+ v->ref();
//fprintf(stderr, "Value::Value(%p) imp=%p ref=%d\n", this, rep, rep->refcount);
v->setGcAllowed();
}
@@ -295,7 +295,7 @@ Boolean Boolean::dynamicCast(const Value &v)
// ------------------------------ String ---------------------------------------
-String::String(const UString &s) : Value(new StringImp(UString(s)))
+String::String(const UString &s) : Value(new StringImp(s))
{
}
@@ -322,7 +322,7 @@ Number::Number(unsigned int u)
: Value(SimpleNumber::fits(u) ? SimpleNumber::make(u) : new NumberImp(static_cast<double>(u))) { }
Number::Number(double d)
- : Value(SimpleNumber::fits(d) ? SimpleNumber::make((long)d) : new NumberImp(d)) { }
+ : Value(SimpleNumber::fits(d) ? SimpleNumber::make((long)d) : (KJS::isNaN(d) ? NumberImp::staticNaN : new NumberImp(d))) { }
Number::Number(long int l)
: Value(SimpleNumber::fits(l) ? SimpleNumber::make(l) : new NumberImp(static_cast<double>(l))) { }
@@ -348,15 +348,19 @@ double Number::value() const
int Number::intValue() const
{
- return int(value());
+ if (SimpleNumber::is(rep))
+ return SimpleNumber::value(rep);
+ return (int)((NumberImp*)rep)->value();
}
bool Number::isNaN() const
{
- return KJS::isNaN(value());
+ return rep == NumberImp::staticNaN;
}
bool Number::isInf() const
{
- return KJS::isInf(value());
+ if (SimpleNumber::is(rep))
+ return false;
+ return KJS::isInf(((NumberImp*)rep)->value());
}
diff --git a/JavaScriptCore/kjs/value.h b/JavaScriptCore/kjs/value.h
index 9167bc7..8474077 100644
--- a/JavaScriptCore/kjs/value.h
+++ b/JavaScriptCore/kjs/value.h
@@ -108,6 +108,9 @@ namespace KJS {
* set by Object() so that the collector is allowed to delete us
*/
void setGcAllowed();
+
+ // Will crash if called on a simple number.
+ void setGcAllowedFast() { _flags |= VI_GCALLOWED; }
int toInteger(ExecState *exec) const;
int toInt32(ExecState *exec) const;
--
WebKit Debian packaging
More information about the Pkg-webkit-commits
mailing list