JavaScriptCore:
2008-09-21 Maciej Stachowiak <mjs@apple.com>
Reviewed by Darin.
- introduce a TypeInfo class, for holding per-type (in the C++ class sense) date in StructureID
https://bugs.webkit.org/show_bug.cgi?id=20981
* JavaScriptCore.exp:
* JavaScriptCore.xcodeproj/project.pbxproj:
* VM/CTI.cpp:
(JSC::CTI::privateCompileMainPass):
(JSC::CTI::privateCompilePutByIdTransition):
* VM/Machine.cpp:
(JSC::jsIsObjectType):
(JSC::Machine::Machine):
* kjs/AllInOneFile.cpp:
* kjs/JSCell.h:
(JSC::JSCell::isObject):
(JSC::JSCell::isString):
* kjs/JSGlobalData.cpp:
(JSC::JSGlobalData::JSGlobalData):
* kjs/JSGlobalObject.cpp:
(JSC::JSGlobalObject::reset):
* kjs/JSGlobalObject.h:
(JSC::StructureID::prototypeForLookup):
* kjs/JSNumberCell.h:
(JSC::JSNumberCell::createStructureID):
* kjs/JSObject.cpp:
(JSC::JSObject::createInheritorID):
* kjs/JSObject.h:
(JSC::JSObject::createStructureID):
* kjs/JSString.h:
(JSC::JSString::createStructureID):
* kjs/NativeErrorConstructor.cpp:
(JSC::NativeErrorConstructor::NativeErrorConstructor):
* kjs/RegExpConstructor.cpp:
* kjs/RegExpMatchesArray.h: Added.
(JSC::RegExpMatchesArray::getOwnPropertySlot):
(JSC::RegExpMatchesArray::put):
(JSC::RegExpMatchesArray::deleteProperty):
(JSC::RegExpMatchesArray::getPropertyNames):
* kjs/StructureID.cpp:
(JSC::StructureID::StructureID):
(JSC::StructureID::addPropertyTransition):
(JSC::StructureID::toDictionaryTransition):
(JSC::StructureID::changePrototypeTransition):
(JSC::StructureID::getterSetterTransition):
* kjs/StructureID.h:
(JSC::StructureID::create):
(JSC::StructureID::typeInfo):
* kjs/TypeInfo.h: Added.
(JSC::TypeInfo::TypeInfo):
(JSC::TypeInfo::type):
WebCore:
2008-09-21 Maciej Stachowiak <mjs@apple.com>
Reviewed by Darin.
- introduce a TypeInfo class, for holding per-type (in the C++ class sense) date in StructureID
https://bugs.webkit.org/show_bug.cgi?id=20981
* bindings/js/JSAudioConstructor.cpp:
(WebCore::JSAudioConstructor::JSAudioConstructor):
* bindings/js/JSCSSStyleDeclarationCustom.cpp:
(WebCore::JSCSSStyleDeclaration::nameGetter):
* bindings/js/JSDOMBinding.cpp:
(WebCore::createDOMStructure):
* bindings/js/JSDOMBinding.h:
(WebCore::getDOMStructure):
* bindings/js/JSDOMWindowShell.cpp:
(WebCore::JSDOMWindowShell::JSDOMWindowShell):
(WebCore::JSDOMWindowShell::setWindow):
* bindings/js/JSEventTargetNode.cpp:
(WebCore::JSEventTargetNode::createPrototype):
* bindings/js/JSHTMLOptionElementConstructor.cpp:
(WebCore::JSHTMLOptionElementConstructor::JSHTMLOptionElementConstructor):
* bindings/js/JSImageConstructor.cpp:
(WebCore::JSImageConstructor::JSImageConstructor):
* bindings/js/JSXMLHttpRequestConstructor.cpp:
(WebCore::JSXMLHttpRequestConstructor::JSXMLHttpRequestConstructor):
* bindings/js/JSXSLTProcessorConstructor.cpp:
(WebCore::JSXSLTProcessorConstructor::JSXSLTProcessorConstructor):
* bindings/scripts/CodeGeneratorJS.pm:
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@36755 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/JavaScriptCore/ChangeLog b/JavaScriptCore/ChangeLog
index 8ce52c0..c45851d 100644
--- a/JavaScriptCore/ChangeLog
+++ b/JavaScriptCore/ChangeLog
@@ -1,3 +1,57 @@
+2008-09-21 Maciej Stachowiak <mjs@apple.com>
+
+ Reviewed by Darin.
+
+ - introduce a TypeInfo class, for holding per-type (in the C++ class sense) date in StructureID
+ https://bugs.webkit.org/show_bug.cgi?id=20981
+
+ * JavaScriptCore.exp:
+ * JavaScriptCore.xcodeproj/project.pbxproj:
+ * VM/CTI.cpp:
+ (JSC::CTI::privateCompileMainPass):
+ (JSC::CTI::privateCompilePutByIdTransition):
+ * VM/Machine.cpp:
+ (JSC::jsIsObjectType):
+ (JSC::Machine::Machine):
+ * kjs/AllInOneFile.cpp:
+ * kjs/JSCell.h:
+ (JSC::JSCell::isObject):
+ (JSC::JSCell::isString):
+ * kjs/JSGlobalData.cpp:
+ (JSC::JSGlobalData::JSGlobalData):
+ * kjs/JSGlobalObject.cpp:
+ (JSC::JSGlobalObject::reset):
+ * kjs/JSGlobalObject.h:
+ (JSC::StructureID::prototypeForLookup):
+ * kjs/JSNumberCell.h:
+ (JSC::JSNumberCell::createStructureID):
+ * kjs/JSObject.cpp:
+ (JSC::JSObject::createInheritorID):
+ * kjs/JSObject.h:
+ (JSC::JSObject::createStructureID):
+ * kjs/JSString.h:
+ (JSC::JSString::createStructureID):
+ * kjs/NativeErrorConstructor.cpp:
+ (JSC::NativeErrorConstructor::NativeErrorConstructor):
+ * kjs/RegExpConstructor.cpp:
+ * kjs/RegExpMatchesArray.h: Added.
+ (JSC::RegExpMatchesArray::getOwnPropertySlot):
+ (JSC::RegExpMatchesArray::put):
+ (JSC::RegExpMatchesArray::deleteProperty):
+ (JSC::RegExpMatchesArray::getPropertyNames):
+ * kjs/StructureID.cpp:
+ (JSC::StructureID::StructureID):
+ (JSC::StructureID::addPropertyTransition):
+ (JSC::StructureID::toDictionaryTransition):
+ (JSC::StructureID::changePrototypeTransition):
+ (JSC::StructureID::getterSetterTransition):
+ * kjs/StructureID.h:
+ (JSC::StructureID::create):
+ (JSC::StructureID::typeInfo):
+ * kjs/TypeInfo.h: Added.
+ (JSC::TypeInfo::TypeInfo):
+ (JSC::TypeInfo::type):
+
2008-09-21 Darin Adler <darin@apple.com>
Reviewed by Cameron Zwarich.
diff --git a/JavaScriptCore/JavaScriptCore.exp b/JavaScriptCore/JavaScriptCore.exp
index 4ca3e2a6..96c03c3d 100644
--- a/JavaScriptCore/JavaScriptCore.exp
+++ b/JavaScriptCore/JavaScriptCore.exp
@@ -112,7 +112,7 @@
__ZN3JSC11StructureID21clearEnumerationCacheEv
__ZN3JSC11StructureID24fromDictionaryTransitionEPS0_
__ZN3JSC11StructureID25changePrototypeTransitionEPS0_PNS_7JSValueE
-__ZN3JSC11StructureIDC1EPNS_7JSValueENS_6JSTypeE
+__ZN3JSC11StructureIDC1EPNS_7JSValueERKNS_8TypeInfoE
__ZN3JSC11StructureIDD1Ev
__ZN3JSC12DateInstance4infoE
__ZN3JSC12JSGlobalData6createEv
diff --git a/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj b/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj
index bdf0b8e..7185fae 100644
--- a/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj
+++ b/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj
@@ -72,6 +72,7 @@
5D5D8AB60E0D0A7200F9C692 /* jsc in Copy Into Framework */ = {isa = PBXBuildFile; fileRef = 932F5BE10822A1C700736975 /* jsc */; };
5D5D8AD10E0D0EBE00F9C692 /* libedit.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = 5D5D8AD00E0D0EBE00F9C692 /* libedit.dylib */; };
5DE6E5B30E1728EC00180407 /* create_hash_table in Headers */ = {isa = PBXBuildFile; fileRef = F692A8540255597D01FF60F7 /* create_hash_table */; settings = {ATTRIBUTES = (Private, ); }; };
+ 6507D29E0E871E5E00D7D896 /* TypeInfo.h in Headers */ = {isa = PBXBuildFile; fileRef = 6507D2970E871E4A00D7D896 /* TypeInfo.h */; settings = {ATTRIBUTES = (Private, ); }; };
659126BD0BDD1728001921FB /* AllInOneFile.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 659126BC0BDD1728001921FB /* AllInOneFile.cpp */; };
65DFC93308EA173A00F7300B /* HashTable.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 65DFC92D08EA173A00F7300B /* HashTable.cpp */; };
65FDE49C0BDD1D4A00E80111 /* Assertions.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 65E217B808E7EECC0023E5F6 /* Assertions.cpp */; settings = {COMPILER_FLAGS = "-Wno-missing-format-attribute"; }; };
@@ -529,6 +530,7 @@
5DA479650CFBCF56009328A0 /* TCPackedCache.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TCPackedCache.h; sourceTree = "<group>"; };
5DBD18AF0C5401A700C15EAE /* MallocZoneSupport.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MallocZoneSupport.h; sourceTree = "<group>"; };
5DE3D0F40DD8DDFB00468714 /* WebKitAvailability.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebKitAvailability.h; sourceTree = "<group>"; };
+ 6507D2970E871E4A00D7D896 /* TypeInfo.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TypeInfo.h; sourceTree = "<group>"; };
651F6412039D5B5F0078395C /* dtoa.cpp */ = {isa = PBXFileReference; fileEncoding = 30; indentWidth = 4; lastKnownFileType = sourcecode.cpp.cpp; path = dtoa.cpp; sourceTree = "<group>"; tabWidth = 8; };
651F6413039D5B5F0078395C /* dtoa.h */ = {isa = PBXFileReference; fileEncoding = 30; indentWidth = 4; lastKnownFileType = sourcecode.c.h; path = dtoa.h; sourceTree = "<group>"; tabWidth = 8; };
652246A40C8D7A0E007BDAF7 /* HashIterators.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = HashIterators.h; sourceTree = "<group>"; };
@@ -1125,6 +1127,7 @@
65417200039E01BA0058BFEB /* kjs */ = {
isa = PBXGroup;
children = (
+ 6507D2970E871E4A00D7D896 /* TypeInfo.h */,
659126BC0BDD1728001921FB /* AllInOneFile.cpp */,
BCF605110E203EF800B9A64D /* ArgList.cpp */,
BCF605120E203EF800B9A64D /* ArgList.h */,
@@ -1528,6 +1531,7 @@
BC18C4690E16F5CD00B34460 /* StringObjectThatMasqueradesAsUndefined.h in Headers */,
BC18C46A0E16F5CD00B34460 /* StringPrototype.h in Headers */,
BC18C46B0E16F5CD00B34460 /* SymbolTable.h in Headers */,
+ 6507D29E0E871E5E00D7D896 /* TypeInfo.h in Headers */,
BC18C46C0E16F5CD00B34460 /* TCPackedCache.h in Headers */,
BC18C46D0E16F5CD00B34460 /* TCPageMap.h in Headers */,
BC18C46E0E16F5CD00B34460 /* TCSpinLock.h in Headers */,
diff --git a/JavaScriptCore/VM/CTI.cpp b/JavaScriptCore/VM/CTI.cpp
index 06bd611..244bafe 100644
--- a/JavaScriptCore/VM/CTI.cpp
+++ b/JavaScriptCore/VM/CTI.cpp
@@ -922,7 +922,7 @@
m_jit.testl_i32r(JSImmediate::TagMask, X86::eax);
X86Assembler::JmpSrc isImmediate = m_jit.emitUnlinkedJne();
m_jit.movl_mr(OBJECT_OFFSET(JSCell, m_structureID), X86::eax, X86::ecx);
- m_jit.cmpl_i32m(ObjectType, OBJECT_OFFSET(StructureID, m_type), X86::ecx);
+ m_jit.cmpl_i32m(ObjectType, OBJECT_OFFSET(StructureID, m_typeInfo) + OBJECT_OFFSET(TypeInfo, m_type), X86::ecx);
X86Assembler::JmpSrc isObject = m_jit.emitUnlinkedJe();
m_jit.link(isImmediate, m_jit.label());
@@ -2408,7 +2408,7 @@
// ecx = baseObject
m_jit.movl_mr(OBJECT_OFFSET(JSCell, m_structureID), X86::eax, X86::ecx);
// proto(ecx) = baseObject->structureID()->prototype()
- m_jit.cmpl_i32m(ObjectType, OBJECT_OFFSET(StructureID, m_type), X86::ecx);
+ m_jit.cmpl_i32m(ObjectType, OBJECT_OFFSET(StructureID, m_typeInfo) + OBJECT_OFFSET(TypeInfo, m_type), X86::ecx);
failureCases.append(m_jit.emitUnlinkedJne());
m_jit.movl_mr(OBJECT_OFFSET(StructureID, m_prototype), X86::ecx, X86::ecx);
@@ -2423,7 +2423,7 @@
failureCases.append(m_jit.emitUnlinkedJne());
m_jit.movl_mr(OBJECT_OFFSET(JSCell, m_structureID), X86::ecx, X86::ecx);
- m_jit.cmpl_i32m(ObjectType, OBJECT_OFFSET(StructureID, m_type), X86::ecx);
+ m_jit.cmpl_i32m(ObjectType, OBJECT_OFFSET(StructureID, m_typeInfo) + OBJECT_OFFSET(TypeInfo, m_type), X86::ecx);
failureCases.append(m_jit.emitUnlinkedJne());
m_jit.movl_mr(OBJECT_OFFSET(StructureID, m_prototype), X86::ecx, X86::ecx);
}
diff --git a/JavaScriptCore/VM/Machine.cpp b/JavaScriptCore/VM/Machine.cpp
index 0f869aa..6ebd5e8 100644
--- a/JavaScriptCore/VM/Machine.cpp
+++ b/JavaScriptCore/VM/Machine.cpp
@@ -260,7 +260,7 @@
if (JSImmediate::isImmediate(v))
return v->isNull();
- JSType type = static_cast<JSCell*>(v)->structureID()->type();
+ JSType type = static_cast<JSCell*>(v)->structureID()->typeInfo().type();
if (type == NumberType || type == StringType)
return false;
if (type == ObjectType) {
@@ -628,7 +628,7 @@
// Bizarrely, calling fastMalloc here is faster than allocating space on the stack.
void* storage = fastMalloc(sizeof(CollectorBlock));
- JSArray* jsArray = new (storage) JSArray(StructureID::create(jsNull()));
+ JSArray* jsArray = new (storage) JSArray(JSArray::createStructureID(jsNull()));
m_jsArrayVptr = jsArray->vptr();
static_cast<JSCell*>(jsArray)->~JSCell();
@@ -636,7 +636,7 @@
m_jsStringVptr = jsString->vptr();
static_cast<JSCell*>(jsString)->~JSCell();
- JSFunction* jsFunction = new (storage) JSFunction(StructureID::create(jsNull()));
+ JSFunction* jsFunction = new (storage) JSFunction(JSFunction::createStructureID(jsNull()));
m_jsFunctionVptr = jsFunction->vptr();
static_cast<JSCell*>(jsFunction)->~JSCell();
diff --git a/JavaScriptCore/kjs/AllInOneFile.cpp b/JavaScriptCore/kjs/AllInOneFile.cpp
index b58cff8..124971a 100644
--- a/JavaScriptCore/kjs/AllInOneFile.cpp
+++ b/JavaScriptCore/kjs/AllInOneFile.cpp
@@ -26,6 +26,11 @@
#define JAVASCRIPTCORE_BUILDING_ALL_IN_ONE_FILE 1
#include "config.h"
+// these headers are included here to avoid confusion between ::JSType and JSC::JSType
+#include "JSCallbackConstructor.h"
+#include "JSCallbackFunction.h"
+#include "JSCallbackObject.h"
+
#include "JSStaticScopeObject.cpp"
#include "JSFunction.cpp"
#include "Arguments.cpp"
diff --git a/JavaScriptCore/kjs/JSCell.h b/JavaScriptCore/kjs/JSCell.h
index 912100a..8853559 100644
--- a/JavaScriptCore/kjs/JSCell.h
+++ b/JavaScriptCore/kjs/JSCell.h
@@ -123,12 +123,12 @@
inline bool JSCell::isObject() const
{
- return m_structureID->type() == ObjectType;
+ return m_structureID->typeInfo().type() == ObjectType;
}
inline bool JSCell::isString() const
{
- return m_structureID->type() == StringType;
+ return m_structureID->typeInfo().type() == StringType;
}
inline StructureID* JSCell::structureID() const
diff --git a/JavaScriptCore/kjs/JSGlobalData.cpp b/JavaScriptCore/kjs/JSGlobalData.cpp
index 1c40c25..e75f394 100644
--- a/JavaScriptCore/kjs/JSGlobalData.cpp
+++ b/JavaScriptCore/kjs/JSGlobalData.cpp
@@ -76,9 +76,9 @@
, regExpConstructorTable(&JSC::regExpConstructorTable)
, stringTable(&JSC::stringTable)
#endif
- , nullProtoStructureID(StructureID::create(jsNull()))
- , stringStructureID(StructureID::create(jsNull(), StringType))
- , numberStructureID(StructureID::create(jsNull(), NumberType))
+ , nullProtoStructureID(JSObject::createStructureID(jsNull()))
+ , stringStructureID(JSString::createStructureID(jsNull()))
+ , numberStructureID(JSNumberCell::createStructureID(jsNull()))
, identifierTable(createIdentifierTable())
, propertyNames(new CommonIdentifiers(this))
, emptyList(new ArgList)
diff --git a/JavaScriptCore/kjs/JSGlobalObject.cpp b/JavaScriptCore/kjs/JSGlobalObject.cpp
index 2674725..7d60128 100644
--- a/JavaScriptCore/kjs/JSGlobalObject.cpp
+++ b/JavaScriptCore/kjs/JSGlobalObject.cpp
@@ -30,6 +30,9 @@
#include "config.h"
#include "JSGlobalObject.h"
+#include "JSCallbackConstructor.h"
+#include "JSCallbackFunction.h"
+#include "JSCallbackObject.h"
#include "ArrayConstructor.h"
#include "ArrayPrototype.h"
#include "BooleanConstructor.h"
@@ -55,6 +58,7 @@
#include "Profiler.h"
#include "PrototypeFunction.h"
#include "RegExpConstructor.h"
+#include "RegExpMatchesArray.h"
#include "RegExpPrototype.h"
#include "ScopeChainMark.h"
#include "StringConstructor.h"
@@ -202,34 +206,33 @@
// Prototypes
d()->functionPrototype = new (exec) FunctionPrototype(exec);
- d()->functionStructure = StructureID::create(d()->functionPrototype);
- d()->callbackFunctionStructure = StructureID::create(d()->functionPrototype);
- d()->prototypeFunctionStructure = StructureID::create(d()->functionPrototype);
- d()->callbackFunctionStructure = StructureID::create(d()->functionPrototype);
+ d()->functionStructure = JSFunction::createStructureID(d()->functionPrototype);
+ d()->callbackFunctionStructure = JSCallbackFunction::createStructureID(d()->functionPrototype);
+ d()->prototypeFunctionStructure = PrototypeFunction::createStructureID(d()->functionPrototype);
d()->functionPrototype->addFunctionProperties(exec, d()->prototypeFunctionStructure.get());
d()->objectPrototype = new (exec) ObjectPrototype(exec, d()->prototypeFunctionStructure.get());
d()->emptyObjectStructure = d()->objectPrototype->inheritorID();
d()->functionPrototype->setPrototype(d()->objectPrototype);
- d()->argumentsStructure = StructureID::create(d()->objectPrototype);
- d()->callbackConstructorStructure = StructureID::create(d()->objectPrototype);
- d()->callbackObjectStructure = StructureID::create(d()->objectPrototype);
- d()->arrayPrototype = new (exec) ArrayPrototype(StructureID::create(d()->objectPrototype));
- d()->arrayStructure = StructureID::create(d()->arrayPrototype);
- d()->regExpMatchesArrayStructure = StructureID::create(d()->arrayPrototype);
- d()->stringPrototype = new (exec) StringPrototype(exec, StructureID::create(d()->objectPrototype));
- d()->stringObjectStructure = StructureID::create(d()->stringPrototype);
- d()->booleanPrototype = new (exec) BooleanPrototype(exec, StructureID::create(d()->objectPrototype), d()->prototypeFunctionStructure.get());
- d()->booleanObjectStructure = StructureID::create(d()->booleanPrototype);
- d()->numberPrototype = new (exec) NumberPrototype(exec, StructureID::create(d()->objectPrototype), d()->prototypeFunctionStructure.get());
- d()->numberObjectStructure = StructureID::create(d()->numberPrototype);
- d()->datePrototype = new (exec) DatePrototype(exec, StructureID::create(d()->objectPrototype));
- d()->dateStructure = StructureID::create(d()->datePrototype);
- d()->regExpPrototype = new (exec) RegExpPrototype(exec, StructureID::create(d()->objectPrototype), d()->prototypeFunctionStructure.get());
- d()->regExpStructure = StructureID::create(d()->regExpPrototype);
- ErrorPrototype* errorPrototype = new (exec) ErrorPrototype(exec, StructureID::create(d()->objectPrototype), d()->prototypeFunctionStructure.get());
- d()->errorStructure = StructureID::create(errorPrototype);
+ d()->argumentsStructure = Arguments::createStructureID(d()->objectPrototype);
+ d()->callbackConstructorStructure = JSCallbackConstructor::createStructureID(d()->objectPrototype);
+ d()->callbackObjectStructure = JSCallbackObject<JSObject>::createStructureID(d()->objectPrototype);
+ d()->arrayPrototype = new (exec) ArrayPrototype(ArrayPrototype::createStructureID(d()->objectPrototype));
+ d()->arrayStructure = JSArray::createStructureID(d()->arrayPrototype);
+ d()->regExpMatchesArrayStructure = RegExpMatchesArray::createStructureID(d()->arrayPrototype);
+ d()->stringPrototype = new (exec) StringPrototype(exec, StringPrototype::createStructureID(d()->objectPrototype));
+ d()->stringObjectStructure = StringObject::createStructureID(d()->stringPrototype);
+ d()->booleanPrototype = new (exec) BooleanPrototype(exec, BooleanPrototype::createStructureID(d()->objectPrototype), d()->prototypeFunctionStructure.get());
+ d()->booleanObjectStructure = BooleanObject::createStructureID(d()->booleanPrototype);
+ d()->numberPrototype = new (exec) NumberPrototype(exec, NumberPrototype::createStructureID(d()->objectPrototype), d()->prototypeFunctionStructure.get());
+ d()->numberObjectStructure = NumberObject::createStructureID(d()->numberPrototype);
+ d()->datePrototype = new (exec) DatePrototype(exec, DatePrototype::createStructureID(d()->objectPrototype));
+ d()->dateStructure = DateInstance::createStructureID(d()->datePrototype);
+ d()->regExpPrototype = new (exec) RegExpPrototype(exec, RegExpPrototype::createStructureID(d()->objectPrototype), d()->prototypeFunctionStructure.get());
+ d()->regExpStructure = RegExpObject::createStructureID(d()->regExpPrototype);
+ ErrorPrototype* errorPrototype = new (exec) ErrorPrototype(exec, ErrorPrototype::createStructureID(d()->objectPrototype), d()->prototypeFunctionStructure.get());
+ d()->errorStructure = ErrorInstance::createStructureID(errorPrototype);
- RefPtr<StructureID> nativeErrorPrototypeStructure = StructureID::create(errorPrototype);
+ RefPtr<StructureID> nativeErrorPrototypeStructure = NativeErrorPrototype::createStructureID(errorPrototype);
NativeErrorPrototype* evalErrorPrototype = new (exec) NativeErrorPrototype(exec, nativeErrorPrototypeStructure, "EvalError", "EvalError");
NativeErrorPrototype* rangeErrorPrototype = new (exec) NativeErrorPrototype(exec, nativeErrorPrototypeStructure, "RangeError", "RangeError");
@@ -240,19 +243,19 @@
// Constructors
- JSValue* objectConstructor = new (exec) ObjectConstructor(exec, StructureID::create(d()->functionPrototype), d()->objectPrototype);
- JSValue* functionConstructor = new (exec) FunctionConstructor(exec, StructureID::create(d()->functionPrototype), d()->functionPrototype);
- JSValue* arrayConstructor = new (exec) ArrayConstructor(exec, StructureID::create(d()->functionPrototype), d()->arrayPrototype);
- JSValue* stringConstructor = new (exec) StringConstructor(exec, StructureID::create(d()->functionPrototype), d()->prototypeFunctionStructure.get(), d()->stringPrototype);
- JSValue* booleanConstructor = new (exec) BooleanConstructor(exec, StructureID::create(d()->functionPrototype), d()->booleanPrototype);
- JSValue* numberConstructor = new (exec) NumberConstructor(exec, StructureID::create(d()->functionPrototype), d()->numberPrototype);
- JSValue* dateConstructor = new (exec) DateConstructor(exec, StructureID::create(d()->functionPrototype), d()->prototypeFunctionStructure.get(), d()->datePrototype);
+ JSValue* objectConstructor = new (exec) ObjectConstructor(exec, ObjectConstructor::createStructureID(d()->functionPrototype), d()->objectPrototype);
+ JSValue* functionConstructor = new (exec) FunctionConstructor(exec, FunctionConstructor::createStructureID(d()->functionPrototype), d()->functionPrototype);
+ JSValue* arrayConstructor = new (exec) ArrayConstructor(exec, ArrayConstructor::createStructureID(d()->functionPrototype), d()->arrayPrototype);
+ JSValue* stringConstructor = new (exec) StringConstructor(exec, StringConstructor::createStructureID(d()->functionPrototype), d()->prototypeFunctionStructure.get(), d()->stringPrototype);
+ JSValue* booleanConstructor = new (exec) BooleanConstructor(exec, BooleanConstructor::createStructureID(d()->functionPrototype), d()->booleanPrototype);
+ JSValue* numberConstructor = new (exec) NumberConstructor(exec, NumberConstructor::createStructureID(d()->functionPrototype), d()->numberPrototype);
+ JSValue* dateConstructor = new (exec) DateConstructor(exec, DateConstructor::createStructureID(d()->functionPrototype), d()->prototypeFunctionStructure.get(), d()->datePrototype);
- d()->regExpConstructor = new (exec) RegExpConstructor(exec, StructureID::create(d()->functionPrototype), d()->regExpPrototype);
+ d()->regExpConstructor = new (exec) RegExpConstructor(exec, RegExpConstructor::createStructureID(d()->functionPrototype), d()->regExpPrototype);
- d()->errorConstructor = new (exec) ErrorConstructor(exec, StructureID::create(d()->functionPrototype), errorPrototype);
+ d()->errorConstructor = new (exec) ErrorConstructor(exec, ErrorConstructor::createStructureID(d()->functionPrototype), errorPrototype);
- RefPtr<StructureID> nativeErrorStructure = StructureID::create(d()->functionPrototype);
+ RefPtr<StructureID> nativeErrorStructure = NativeErrorConstructor::createStructureID(d()->functionPrototype);
d()->evalErrorConstructor = new (exec) NativeErrorConstructor(exec, nativeErrorStructure, evalErrorPrototype);
d()->rangeErrorConstructor = new (exec) NativeErrorConstructor(exec, nativeErrorStructure, rangeErrorPrototype);
@@ -301,7 +304,7 @@
// Set global values.
GlobalPropertyInfo staticGlobals[] = {
- GlobalPropertyInfo(Identifier(exec, "Math"), new (exec) MathObject(exec, StructureID::create(d()->objectPrototype)), DontEnum | DontDelete),
+ GlobalPropertyInfo(Identifier(exec, "Math"), new (exec) MathObject(exec, MathObject::createStructureID(d()->objectPrototype)), DontEnum | DontDelete),
GlobalPropertyInfo(Identifier(exec, "NaN"), jsNaN(exec), DontEnum | DontDelete),
GlobalPropertyInfo(Identifier(exec, "Infinity"), jsNumber(exec, Inf), DontEnum | DontDelete),
GlobalPropertyInfo(Identifier(exec, "undefined"), jsUndefined(), DontEnum | DontDelete)
@@ -311,7 +314,7 @@
// Set global functions.
- d()->evalFunction = new (exec) GlobalEvalFunction(exec, StructureID::create(d()->functionPrototype), 1, exec->propertyNames().eval, globalFuncEval, this);
+ d()->evalFunction = new (exec) GlobalEvalFunction(exec, GlobalEvalFunction::createStructureID(d()->functionPrototype), 1, exec->propertyNames().eval, globalFuncEval, this);
putDirectFunction(exec, d()->evalFunction, DontEnum);
putDirectFunction(exec, new (exec) PrototypeFunction(exec, d()->prototypeFunctionStructure.get(), 2, Identifier(exec, "parseInt"), globalFuncParseInt), DontEnum);
putDirectFunction(exec, new (exec) PrototypeFunction(exec, d()->prototypeFunctionStructure.get(), 1, Identifier(exec, "parseFloat"), globalFuncParseFloat), DontEnum);
diff --git a/JavaScriptCore/kjs/JSGlobalObject.h b/JavaScriptCore/kjs/JSGlobalObject.h
index 2f5ca3f..ef100e5 100644
--- a/JavaScriptCore/kjs/JSGlobalObject.h
+++ b/JavaScriptCore/kjs/JSGlobalObject.h
@@ -312,13 +312,13 @@
inline JSValue* StructureID::prototypeForLookup(ExecState* exec)
{
- if (m_type == ObjectType)
+ if (typeInfo().type() == ObjectType)
return m_prototype;
- if (m_type == StringType)
+ if (typeInfo().type() == StringType)
return exec->lexicalGlobalObject()->stringPrototype();
- ASSERT(m_type == NumberType);
+ ASSERT(typeInfo().type() == NumberType);
return exec->lexicalGlobalObject()->numberPrototype();
}
diff --git a/JavaScriptCore/kjs/JSNumberCell.h b/JavaScriptCore/kjs/JSNumberCell.h
index 07feaa8..2f1c3ca2 100644
--- a/JavaScriptCore/kjs/JSNumberCell.h
+++ b/JavaScriptCore/kjs/JSNumberCell.h
@@ -70,6 +70,8 @@
#endif
}
+ static PassRefPtr<StructureID> createStructureID(JSValue* proto) { return StructureID::create(proto, TypeInfo(NumberType)); }
+
private:
JSNumberCell(ExecState* exec, double value)
: JSCell(exec->globalData().numberStructureID.get())
diff --git a/JavaScriptCore/kjs/JSObject.cpp b/JavaScriptCore/kjs/JSObject.cpp
index 0c94289..93f7bbf 100644
--- a/JavaScriptCore/kjs/JSObject.cpp
+++ b/JavaScriptCore/kjs/JSObject.cpp
@@ -499,7 +499,7 @@
StructureID* JSObject::createInheritorID()
{
- m_inheritorID = StructureID::create(this);
+ m_inheritorID = JSObject::createStructureID(this);
return m_inheritorID.get();
}
diff --git a/JavaScriptCore/kjs/JSObject.h b/JavaScriptCore/kjs/JSObject.h
index 430e09f..c60e16a 100644
--- a/JavaScriptCore/kjs/JSObject.h
+++ b/JavaScriptCore/kjs/JSObject.h
@@ -181,6 +181,8 @@
static const size_t inlineStorageCapacity = 2;
+ static PassRefPtr<StructureID> createStructureID(JSValue* proto) { return StructureID::create(proto, TypeInfo(ObjectType)); }
+
protected:
bool getOwnPropertySlotForWrite(ExecState*, const Identifier&, PropertySlot&, bool& slotIsWriteable);
diff --git a/JavaScriptCore/kjs/JSString.h b/JavaScriptCore/kjs/JSString.h
index 76cfe64..2194a46 100644
--- a/JavaScriptCore/kjs/JSString.h
+++ b/JavaScriptCore/kjs/JSString.h
@@ -82,6 +82,8 @@
bool canGetIndex(unsigned i) { return i < static_cast<unsigned>(m_value.size()); }
JSString* getIndex(ExecState*, unsigned);
+ static PassRefPtr<StructureID> createStructureID(JSValue* proto) { return StructureID::create(proto, TypeInfo(StringType)); }
+
private:
enum VPtrStealingHackType { VPtrStealingHack };
JSString(VPtrStealingHackType)
diff --git a/JavaScriptCore/kjs/NativeErrorConstructor.cpp b/JavaScriptCore/kjs/NativeErrorConstructor.cpp
index cd126e1..234c1f4 100644
--- a/JavaScriptCore/kjs/NativeErrorConstructor.cpp
+++ b/JavaScriptCore/kjs/NativeErrorConstructor.cpp
@@ -33,7 +33,7 @@
NativeErrorConstructor::NativeErrorConstructor(ExecState* exec, PassRefPtr<StructureID> structure, NativeErrorPrototype* nativeErrorPrototype)
: InternalFunction(exec, structure, Identifier(exec, nativeErrorPrototype->getDirect(exec->propertyNames().name)->getString()))
- , m_errorStructure(StructureID::create(nativeErrorPrototype))
+ , m_errorStructure(ErrorInstance::createStructureID(nativeErrorPrototype))
{
putDirect(exec->propertyNames().length, jsNumber(exec, 1), DontDelete | ReadOnly | DontEnum); // ECMA 15.11.7.5
putDirect(exec->propertyNames().prototype, nativeErrorPrototype, DontDelete | ReadOnly | DontEnum);
diff --git a/JavaScriptCore/kjs/RegExpConstructor.cpp b/JavaScriptCore/kjs/RegExpConstructor.cpp
index 6ec62d6..22c5386 100644
--- a/JavaScriptCore/kjs/RegExpConstructor.cpp
+++ b/JavaScriptCore/kjs/RegExpConstructor.cpp
@@ -27,6 +27,7 @@
#include "JSFunction.h"
#include "JSString.h"
#include "ObjectPrototype.h"
+#include "RegExpMatchesArray.h"
#include "RegExpObject.h"
#include "RegExpPrototype.h"
#include "regexp.h"
@@ -114,23 +115,6 @@
}
}
-class RegExpMatchesArray : public JSArray {
-public:
- RegExpMatchesArray(ExecState*, RegExpConstructorPrivate*);
- virtual ~RegExpMatchesArray();
-
-private:
- virtual bool getOwnPropertySlot(ExecState* exec, const Identifier& propertyName, PropertySlot& slot) { if (lazyCreationData()) fillArrayInstance(exec); return JSArray::getOwnPropertySlot(exec, propertyName, slot); }
- virtual bool getOwnPropertySlot(ExecState* exec, unsigned propertyName, PropertySlot& slot) { if (lazyCreationData()) fillArrayInstance(exec); return JSArray::getOwnPropertySlot(exec, propertyName, slot); }
- virtual void put(ExecState* exec, const Identifier& propertyName, JSValue* v, PutPropertySlot& slot) { if (lazyCreationData()) fillArrayInstance(exec); JSArray::put(exec, propertyName, v, slot); }
- virtual void put(ExecState* exec, unsigned propertyName, JSValue* v) { if (lazyCreationData()) fillArrayInstance(exec); JSArray::put(exec, propertyName, v); }
- virtual bool deleteProperty(ExecState* exec, const Identifier& propertyName) { if (lazyCreationData()) fillArrayInstance(exec); return JSArray::deleteProperty(exec, propertyName); }
- virtual bool deleteProperty(ExecState* exec, unsigned propertyName) { if (lazyCreationData()) fillArrayInstance(exec); return JSArray::deleteProperty(exec, propertyName); }
- virtual void getPropertyNames(ExecState* exec, PropertyNameArray& arr) { if (lazyCreationData()) fillArrayInstance(exec); JSArray::getPropertyNames(exec, arr); }
-
- void fillArrayInstance(ExecState*);
-};
-
RegExpMatchesArray::RegExpMatchesArray(ExecState* exec, RegExpConstructorPrivate* data)
: JSArray(exec->lexicalGlobalObject()->regExpMatchesArrayStructure(), data->lastNumSubPatterns + 1)
{
diff --git a/JavaScriptCore/kjs/RegExpMatchesArray.h b/JavaScriptCore/kjs/RegExpMatchesArray.h
new file mode 100644
index 0000000..e341e77
--- /dev/null
+++ b/JavaScriptCore/kjs/RegExpMatchesArray.h
@@ -0,0 +1,46 @@
+/*
+ * 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
+ * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ */
+
+#ifndef RegExpMatchesArray_h
+#define RegExpMatchesArray_h
+
+#include "JSArray.h"
+
+namespace JSC {
+
+class RegExpMatchesArray : public JSArray {
+public:
+ RegExpMatchesArray(ExecState*, RegExpConstructorPrivate*);
+ virtual ~RegExpMatchesArray();
+
+private:
+ virtual bool getOwnPropertySlot(ExecState* exec, const Identifier& propertyName, PropertySlot& slot) { if (lazyCreationData()) fillArrayInstance(exec); return JSArray::getOwnPropertySlot(exec, propertyName, slot); }
+ virtual bool getOwnPropertySlot(ExecState* exec, unsigned propertyName, PropertySlot& slot) { if (lazyCreationData()) fillArrayInstance(exec); return JSArray::getOwnPropertySlot(exec, propertyName, slot); }
+ virtual void put(ExecState* exec, const Identifier& propertyName, JSValue* v, PutPropertySlot& slot) { if (lazyCreationData()) fillArrayInstance(exec); JSArray::put(exec, propertyName, v, slot); }
+ virtual void put(ExecState* exec, unsigned propertyName, JSValue* v) { if (lazyCreationData()) fillArrayInstance(exec); JSArray::put(exec, propertyName, v); }
+ virtual bool deleteProperty(ExecState* exec, const Identifier& propertyName) { if (lazyCreationData()) fillArrayInstance(exec); return JSArray::deleteProperty(exec, propertyName); }
+ virtual bool deleteProperty(ExecState* exec, unsigned propertyName) { if (lazyCreationData()) fillArrayInstance(exec); return JSArray::deleteProperty(exec, propertyName); }
+ virtual void getPropertyNames(ExecState* exec, PropertyNameArray& arr) { if (lazyCreationData()) fillArrayInstance(exec); JSArray::getPropertyNames(exec, arr); }
+
+ void fillArrayInstance(ExecState*);
+};
+
+}
+
+#endif // RegExpMatchesArray_h
diff --git a/JavaScriptCore/kjs/StructureID.cpp b/JavaScriptCore/kjs/StructureID.cpp
index 7abe149..51fea93 100644
--- a/JavaScriptCore/kjs/StructureID.cpp
+++ b/JavaScriptCore/kjs/StructureID.cpp
@@ -36,9 +36,9 @@
namespace JSC {
-StructureID::StructureID(JSValue* prototype, JSType type)
- : m_isDictionary(false)
- , m_type(type)
+StructureID::StructureID(JSValue* prototype, const TypeInfo& typeInfo)
+ : m_typeInfo(typeInfo)
+ , m_isDictionary(false)
, m_prototype(prototype)
, m_cachedPrototypeChain(0)
, m_previous(0)
@@ -141,7 +141,7 @@
return transition.release();
}
- RefPtr<StructureID> transition = create(structureID->m_prototype);
+ RefPtr<StructureID> transition = create(structureID->m_prototype, structureID->typeInfo());
transition->m_cachedPrototypeChain = structureID->m_cachedPrototypeChain;
transition->m_previous = structureID;
transition->m_nameInPrevious = propertyName.ustring().rep();
@@ -159,7 +159,7 @@
{
ASSERT(!structureID->m_isDictionary);
- RefPtr<StructureID> transition = create(structureID->m_prototype);
+ RefPtr<StructureID> transition = create(structureID->m_prototype, structureID->typeInfo());
transition->m_isDictionary = true;
transition->m_propertyMap = structureID->m_propertyMap;
return transition.release();
@@ -178,7 +178,7 @@
PassRefPtr<StructureID> StructureID::changePrototypeTransition(StructureID* structureID, JSValue* prototype)
{
- RefPtr<StructureID> transition = create(prototype);
+ RefPtr<StructureID> transition = create(prototype, structureID->typeInfo());
transition->m_transitionCount = structureID->m_transitionCount + 1;
transition->m_propertyMap = structureID->m_propertyMap;
return transition.release();
@@ -186,7 +186,7 @@
PassRefPtr<StructureID> StructureID::getterSetterTransition(StructureID* structureID)
{
- RefPtr<StructureID> transition = create(structureID->storedPrototype());
+ RefPtr<StructureID> transition = create(structureID->storedPrototype(), structureID->typeInfo());
transition->m_transitionCount = structureID->m_transitionCount + 1;
transition->m_propertyMap = structureID->m_propertyMap;
return transition.release();
diff --git a/JavaScriptCore/kjs/StructureID.h b/JavaScriptCore/kjs/StructureID.h
index c6fcc82..d176ef3 100644
--- a/JavaScriptCore/kjs/StructureID.h
+++ b/JavaScriptCore/kjs/StructureID.h
@@ -1,3 +1,4 @@
+// -*- mode: c++; c-basic-offset: 4 -*-
/*
* Copyright (C) 2008 Apple Inc. All rights reserved.
*
@@ -29,6 +30,7 @@
#include "JSType.h"
#include "JSValue.h"
#include "PropertyMap.h"
+#include "TypeInfo.h"
#include "ustring.h"
#include <wtf/HashFunctions.h>
#include <wtf/HashTraits.h>
@@ -75,9 +77,9 @@
class StructureID : public RefCounted<StructureID> {
public:
friend class CTI;
- static PassRefPtr<StructureID> create(JSValue* prototype, JSType type = ObjectType)
+ static PassRefPtr<StructureID> create(JSValue* prototype, const TypeInfo& typeInfo)
{
- return adoptRef(new StructureID(prototype, type));
+ return adoptRef(new StructureID(prototype, typeInfo));
}
static PassRefPtr<StructureID> changePrototypeTransition(StructureID*, JSValue* prototype);
@@ -96,7 +98,7 @@
bool isDictionary() const { return m_isDictionary; }
- JSType type() const { return m_type; }
+ const TypeInfo& typeInfo() const { return m_typeInfo; }
JSValue* storedPrototype() const { return m_prototype; }
JSValue* prototypeForLookup(ExecState*);
@@ -119,12 +121,13 @@
typedef std::pair<RefPtr<UString::Rep>, unsigned> TransitionTableKey;
typedef HashMap<TransitionTableKey, StructureID*, TransitionTableHash, TransitionTableHashTraits> TransitionTable;
- StructureID(JSValue* prototype, JSType);
+ StructureID(JSValue* prototype, const TypeInfo&);
static const size_t s_maxTransitionLength = 64;
+ TypeInfo m_typeInfo;
+
bool m_isDictionary;
- JSType m_type;
JSValue* m_prototype;
RefPtr<StructureIDChain> m_cachedPrototypeChain;
diff --git a/JavaScriptCore/kjs/TypeInfo.h b/JavaScriptCore/kjs/TypeInfo.h
new file mode 100644
index 0000000..0f2cc14
--- /dev/null
+++ b/JavaScriptCore/kjs/TypeInfo.h
@@ -0,0 +1,47 @@
+// -*- mode: c++; c-basic-offset: 4 -*-
+/*
+ * Copyright (C) 2008 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef TypeInfo_h
+#define TypeInfo_h
+
+#include "JSType.h"
+
+namespace JSC {
+
+ class TypeInfo {
+ friend class CTI;
+ public:
+ TypeInfo(JSType type) : m_type(type) { }
+
+ JSType type() const { return m_type; }
+
+ private:
+ JSType m_type;
+ };
+
+}
+
+#endif // TypeInfo_h