diff --git a/LayoutTests/ChangeLog b/LayoutTests/ChangeLog index 99d89768a69283e79c84f7d6b91a86f30498457e..3f8498ce18f7d8d0eee2431e8f57cf2efad03986 100644 --- a/LayoutTests/ChangeLog +++ b/LayoutTests/ChangeLog @@ -1,3 +1,20 @@ +2013-03-15 Mark Hahnenberg + + Roll out r145838 + https://bugs.webkit.org/show_bug.cgi?id=112458 + + Unreviewed. Requested by Filip Pizlo. + + * fast/js/regress/script-tests/string-lookup-hit-identifier.js: Removed. + * fast/js/regress/script-tests/string-lookup-hit.js: Removed. + * fast/js/regress/script-tests/string-lookup-miss.js: Removed. + * fast/js/regress/string-lookup-hit-expected.txt: Removed. + * fast/js/regress/string-lookup-hit-identifier-expected.txt: Removed. + * fast/js/regress/string-lookup-hit-identifier.html: Removed. + * fast/js/regress/string-lookup-hit.html: Removed. + * fast/js/regress/string-lookup-miss-expected.txt: Removed. + * fast/js/regress/string-lookup-miss.html: Removed. + 2013-03-15 Rouslan Solomakhin Move setAsynchronousSpellCheckingEnabled to internals.settings diff --git a/LayoutTests/fast/js/regress/script-tests/string-lookup-hit-identifier.js b/LayoutTests/fast/js/regress/script-tests/string-lookup-hit-identifier.js deleted file mode 100644 index 6bee1ea5e323414fdf434551db185794d3885cf7..0000000000000000000000000000000000000000 --- a/LayoutTests/fast/js/regress/script-tests/string-lookup-hit-identifier.js +++ /dev/null @@ -1,17 +0,0 @@ -var result = (function(){ - var o = {}; - for (var i = 0; i < 100; ++i) - o["a" + i] = 42; - var result = []; - var strings = []; - for (var i = 0; i < 100; ++i) - strings.push("a" + i); - for (var j = 0; j < 1000; ++j) { - for (var i = 0; i < 100; ++i) - result.push(o[strings[i]]); - } - return result.length; -})(); - -if (result != 100000) - throw "Error: bad result: " + result; diff --git a/LayoutTests/fast/js/regress/script-tests/string-lookup-hit.js b/LayoutTests/fast/js/regress/script-tests/string-lookup-hit.js deleted file mode 100644 index 37d9e7f9e7492a69f2fb1a93d94b65902e393e92..0000000000000000000000000000000000000000 --- a/LayoutTests/fast/js/regress/script-tests/string-lookup-hit.js +++ /dev/null @@ -1,14 +0,0 @@ -var result = (function(){ - var o = {}; - for (var i = 0; i < 100; ++i) - o["a" + i] = 42; - var result = []; - for (var j = 0; j < 1000; ++j) { - for (var i = 0; i < 100; ++i) - result.push(o["a" + i]); - } - return result.length; -})(); - -if (result != 100000) - throw "Error: bad result: " + result; diff --git a/LayoutTests/fast/js/regress/script-tests/string-lookup-miss.js b/LayoutTests/fast/js/regress/script-tests/string-lookup-miss.js deleted file mode 100644 index 19114dfb1c4fdf14613fb4c9a7ac00c9d39e6ea7..0000000000000000000000000000000000000000 --- a/LayoutTests/fast/js/regress/script-tests/string-lookup-miss.js +++ /dev/null @@ -1,12 +0,0 @@ -var result = (function(){ - var o = {}; - for (var i = 0; i < 100; ++i) - o["a" + i] = 42; - var result = []; - for (var i = 0; i < 100000; ++i) - result.push(o["a" + i]); - return result.length; -})(); - -if (result != 100000) - throw "Error: bad result: " + result; diff --git a/LayoutTests/fast/js/regress/string-lookup-hit-expected.txt b/LayoutTests/fast/js/regress/string-lookup-hit-expected.txt deleted file mode 100644 index d92d2cde53a34cfeebade706236e59a1f1e129bd..0000000000000000000000000000000000000000 --- a/LayoutTests/fast/js/regress/string-lookup-hit-expected.txt +++ /dev/null @@ -1,10 +0,0 @@ -JSRegress/string-lookup-hit - -On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE". - - -PASS no exception thrown -PASS successfullyParsed is true - -TEST COMPLETE - diff --git a/LayoutTests/fast/js/regress/string-lookup-hit-identifier-expected.txt b/LayoutTests/fast/js/regress/string-lookup-hit-identifier-expected.txt deleted file mode 100644 index d5f1d7f580a60acd0a4438f8c058329214c465c1..0000000000000000000000000000000000000000 --- a/LayoutTests/fast/js/regress/string-lookup-hit-identifier-expected.txt +++ /dev/null @@ -1,10 +0,0 @@ -JSRegress/string-lookup-hit-identifier - -On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE". - - -PASS no exception thrown -PASS successfullyParsed is true - -TEST COMPLETE - diff --git a/LayoutTests/fast/js/regress/string-lookup-hit-identifier.html b/LayoutTests/fast/js/regress/string-lookup-hit-identifier.html deleted file mode 100644 index 9ea00d5da2e93a53b22410821117b2923861a394..0000000000000000000000000000000000000000 --- a/LayoutTests/fast/js/regress/string-lookup-hit-identifier.html +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - - - - - - - diff --git a/LayoutTests/fast/js/regress/string-lookup-hit.html b/LayoutTests/fast/js/regress/string-lookup-hit.html deleted file mode 100644 index 914d12524e060573cd31bcd908a4b4bab8018ea1..0000000000000000000000000000000000000000 --- a/LayoutTests/fast/js/regress/string-lookup-hit.html +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - - - - - - - diff --git a/LayoutTests/fast/js/regress/string-lookup-miss-expected.txt b/LayoutTests/fast/js/regress/string-lookup-miss-expected.txt deleted file mode 100644 index 12fffc5f07286aca3b2d9c5cb789438bb0ac8693..0000000000000000000000000000000000000000 --- a/LayoutTests/fast/js/regress/string-lookup-miss-expected.txt +++ /dev/null @@ -1,10 +0,0 @@ -JSRegress/string-lookup-miss - -On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE". - - -PASS no exception thrown -PASS successfullyParsed is true - -TEST COMPLETE - diff --git a/LayoutTests/fast/js/regress/string-lookup-miss.html b/LayoutTests/fast/js/regress/string-lookup-miss.html deleted file mode 100644 index b96ba515cb82d930f22969e25084bea25ff6d0c3..0000000000000000000000000000000000000000 --- a/LayoutTests/fast/js/regress/string-lookup-miss.html +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - - - - - - - diff --git a/Source/JavaScriptCore/CMakeLists.txt b/Source/JavaScriptCore/CMakeLists.txt index 8b3b66f63f2db774abf15b7a7c908d90f766d925..9119120a6f411b27a681454ba820e37edc1222e8 100644 --- a/Source/JavaScriptCore/CMakeLists.txt +++ b/Source/JavaScriptCore/CMakeLists.txt @@ -329,6 +329,7 @@ set(JavaScriptCore_LUT_FILES runtime/NumberConstructor.cpp runtime/NumberPrototype.cpp runtime/ObjectConstructor.cpp + runtime/ObjectPrototype.cpp runtime/RegExpConstructor.cpp runtime/RegExpObject.cpp runtime/RegExpPrototype.cpp diff --git a/Source/JavaScriptCore/ChangeLog b/Source/JavaScriptCore/ChangeLog index b2832f5788683a3827663f7af1de393dee1a7552..e194cf45f6c6b971f5736bee5d7befa8bfb9f822 100644 --- a/Source/JavaScriptCore/ChangeLog +++ b/Source/JavaScriptCore/ChangeLog @@ -1,3 +1,57 @@ +2013-03-15 Mark Hahnenberg + + Roll out r145838 + https://bugs.webkit.org/show_bug.cgi?id=112458 + + Unreviewed. Requested by Filip Pizlo. + + * CMakeLists.txt: + * DerivedSources.make: + * DerivedSources.pri: + * GNUmakefile.list.am: + * dfg/DFGOperations.cpp: + * interpreter/CallFrame.h: + (JSC::ExecState::objectPrototypeTable): + * jit/JITStubs.cpp: + (JSC::getByVal): + * llint/LLIntSlowPaths.cpp: + (JSC::LLInt::getByVal): + * runtime/CommonIdentifiers.h: + * runtime/JSCell.cpp: + (JSC): + * runtime/JSCell.h: + (JSCell): + * runtime/JSCellInlines.h: + (JSC): + (JSC::JSCell::fastGetOwnProperty): + * runtime/JSGlobalData.cpp: + (JSC): + (JSC::JSGlobalData::JSGlobalData): + (JSC::JSGlobalData::~JSGlobalData): + * runtime/JSGlobalData.h: + (JSGlobalData): + * runtime/JSObject.cpp: + (JSC): + * runtime/JSObject.h: + (JSObject): + (JSC): + * runtime/Lookup.cpp: + (JSC::setUpStaticFunctionSlot): + * runtime/ObjectPrototype.cpp: + (JSC): + (JSC::ObjectPrototype::finishCreation): + (JSC::ObjectPrototype::getOwnPropertySlot): + (JSC::ObjectPrototype::getOwnPropertyDescriptor): + * runtime/ObjectPrototype.h: + (JSC::ObjectPrototype::create): + (ObjectPrototype): + * runtime/PropertyMapHashTable.h: + (JSC::PropertyTable::findWithString): + * runtime/Structure.h: + (Structure): + * runtime/StructureInlines.h: + (JSC::Structure::get): + 2013-03-15 Michael Saboff Cleanup of DFG and Baseline JIT debugging code diff --git a/Source/JavaScriptCore/DerivedSources.make b/Source/JavaScriptCore/DerivedSources.make index 55a76e297f4d7d49dfbefffc03e499e584d6e374..4c3b81e268dfc48dc32ddcb7eb4b36c164f87ab9 100644 --- a/Source/JavaScriptCore/DerivedSources.make +++ b/Source/JavaScriptCore/DerivedSources.make @@ -50,6 +50,7 @@ all : \ NumberConstructor.lut.h \ NumberPrototype.lut.h \ ObjectConstructor.lut.h \ + ObjectPrototype.lut.h \ RegExpConstructor.lut.h \ RegExpPrototype.lut.h \ RegExpJitTables.h \ diff --git a/Source/JavaScriptCore/DerivedSources.pri b/Source/JavaScriptCore/DerivedSources.pri index d637569a2b1e5f5433ea9db6fb4ac0c42907ad6f..8bbc29d2a6e80b77bd482f33271614885944c94f 100644 --- a/Source/JavaScriptCore/DerivedSources.pri +++ b/Source/JavaScriptCore/DerivedSources.pri @@ -20,6 +20,7 @@ LUT_FILES += \ runtime/NumberConstructor.cpp \ runtime/NumberPrototype.cpp \ runtime/ObjectConstructor.cpp \ + runtime/ObjectPrototype.cpp \ runtime/RegExpConstructor.cpp \ runtime/RegExpObject.cpp \ runtime/RegExpPrototype.cpp \ diff --git a/Source/JavaScriptCore/GNUmakefile.list.am b/Source/JavaScriptCore/GNUmakefile.list.am index f4183876c9e98c90e1759edc288f40e80c027403..e63c78a4306da0a26882f108f9c44cc6d4e0056f 100644 --- a/Source/JavaScriptCore/GNUmakefile.list.am +++ b/Source/JavaScriptCore/GNUmakefile.list.am @@ -24,6 +24,7 @@ javascriptcore_built_nosources += \ DerivedSources/JavaScriptCore/NumberConstructor.lut.h \ DerivedSources/JavaScriptCore/NumberPrototype.lut.h \ DerivedSources/JavaScriptCore/ObjectConstructor.lut.h \ + DerivedSources/JavaScriptCore/ObjectPrototype.lut.h \ DerivedSources/JavaScriptCore/RegExpConstructor.lut.h \ DerivedSources/JavaScriptCore/RegExpObject.lut.h \ DerivedSources/JavaScriptCore/RegExpPrototype.lut.h \ diff --git a/Source/JavaScriptCore/dfg/DFGOperations.cpp b/Source/JavaScriptCore/dfg/DFGOperations.cpp index 454a519dfff8fc7fb9559dc6cbf61fe04b77ee0b..4ccb911e3c9501c0cc12ea35286d3f09d2d545b4 100644 --- a/Source/JavaScriptCore/dfg/DFGOperations.cpp +++ b/Source/JavaScriptCore/dfg/DFGOperations.cpp @@ -424,17 +424,19 @@ EncodedJSValue DFG_OPERATION operationGetByVal(ExecState* exec, EncodedJSValue e if (LIKELY(baseValue.isCell())) { JSCell* base = baseValue.asCell(); - if (property.isUInt32()) + if (property.isUInt32()) { return getByVal(exec, base, property.asUInt32()); - if (property.isDouble()) { + } else if (property.isDouble()) { double propertyAsDouble = property.asDouble(); uint32_t propertyAsUInt32 = static_cast(propertyAsDouble); if (propertyAsUInt32 == propertyAsDouble) return getByVal(exec, base, propertyAsUInt32); - } else if (property.isString()) - return JSValue::encode(base->getByString(exec, asString(property)->value(exec))); + } else if (property.isString()) { + if (JSValue result = base->fastGetOwnProperty(exec, asString(property)->value(exec))) + return JSValue::encode(result); + } } - + if (isName(property)) return JSValue::encode(baseValue.get(exec, jsCast(property.asCell())->privateName())); @@ -451,13 +453,15 @@ EncodedJSValue DFG_OPERATION operationGetByValCell(ExecState* exec, JSCell* base if (property.isUInt32()) return getByVal(exec, base, property.asUInt32()); - else if (property.isDouble()) { + if (property.isDouble()) { double propertyAsDouble = property.asDouble(); uint32_t propertyAsUInt32 = static_cast(propertyAsDouble); if (propertyAsUInt32 == propertyAsDouble) return getByVal(exec, base, propertyAsUInt32); - } else if (property.isString()) - return JSValue::encode(base->getByString(exec, asString(property)->value(exec))); + } else if (property.isString()) { + if (JSValue result = base->fastGetOwnProperty(exec, asString(property)->value(exec))) + return JSValue::encode(result); + } if (isName(property)) return JSValue::encode(JSValue(base).get(exec, jsCast(property.asCell())->privateName())); diff --git a/Source/JavaScriptCore/interpreter/CallFrame.h b/Source/JavaScriptCore/interpreter/CallFrame.h index 9852b31c2ac17296c01d08861535166285d368cf..743f18db56151f90904397e3c6e1bcceba02d03a 100644 --- a/Source/JavaScriptCore/interpreter/CallFrame.h +++ b/Source/JavaScriptCore/interpreter/CallFrame.h @@ -90,6 +90,7 @@ namespace JSC { static const HashTable* numberConstructorTable(CallFrame* callFrame) { return callFrame->globalData().numberConstructorTable; } static const HashTable* numberPrototypeTable(CallFrame* callFrame) { return callFrame->globalData().numberPrototypeTable; } static const HashTable* objectConstructorTable(CallFrame* callFrame) { return callFrame->globalData().objectConstructorTable; } + static const HashTable* objectPrototypeTable(CallFrame* callFrame) { return callFrame->globalData().objectPrototypeTable; } static const HashTable* privateNamePrototypeTable(CallFrame* callFrame) { return callFrame->globalData().privateNamePrototypeTable; } static const HashTable* regExpTable(CallFrame* callFrame) { return callFrame->globalData().regExpTable; } static const HashTable* regExpConstructorTable(CallFrame* callFrame) { return callFrame->globalData().regExpConstructorTable; } diff --git a/Source/JavaScriptCore/jit/JITStubs.cpp b/Source/JavaScriptCore/jit/JITStubs.cpp index 793551c612f835245390d21d5a3e7c050e6f0018..d3da846cd9374d707ff226107c1a444b6cafdd8e 100644 --- a/Source/JavaScriptCore/jit/JITStubs.cpp +++ b/Source/JavaScriptCore/jit/JITStubs.cpp @@ -2417,8 +2417,10 @@ DEFINE_STUB_FUNCTION(EncodedJSValue, op_construct_NotJSConstruct) static JSValue getByVal( CallFrame* callFrame, JSValue baseValue, JSValue subscript, ReturnAddressPtr returnAddress) { - if (LIKELY(baseValue.isCell() && subscript.isString())) - return baseValue.asCell()->getByString(callFrame, asString(subscript)->value(callFrame)); + if (LIKELY(baseValue.isCell() && subscript.isString())) { + if (JSValue result = baseValue.asCell()->fastGetOwnProperty(callFrame, asString(subscript)->value(callFrame))) + return result; + } if (subscript.isUInt32()) { uint32_t i = subscript.asUInt32(); diff --git a/Source/JavaScriptCore/llint/LLIntSlowPaths.cpp b/Source/JavaScriptCore/llint/LLIntSlowPaths.cpp index 504b80d4ce0b2280317275868e11232c74578241..c630cbc98952f45313766dd46a4506040ffab5df 100644 --- a/Source/JavaScriptCore/llint/LLIntSlowPaths.cpp +++ b/Source/JavaScriptCore/llint/LLIntSlowPaths.cpp @@ -1060,8 +1060,10 @@ LLINT_SLOW_PATH_DECL(slow_path_del_by_id) inline JSValue getByVal(ExecState* exec, JSValue baseValue, JSValue subscript) { - if (LIKELY(baseValue.isCell() && subscript.isString())) - return baseValue.asCell()->getByString(exec, asString(subscript)->value(exec)); + if (LIKELY(baseValue.isCell() && subscript.isString())) { + if (JSValue result = baseValue.asCell()->fastGetOwnProperty(exec, asString(subscript)->value(exec))) + return result; + } if (subscript.isUInt32()) { uint32_t i = subscript.asUInt32(); diff --git a/Source/JavaScriptCore/runtime/CommonIdentifiers.h b/Source/JavaScriptCore/runtime/CommonIdentifiers.h index fa9eeb0af5bde7b6bb1f58e5da82d84f805bdce3..93f7914d304d176d9b6ccdae43d71100f1f8d274 100644 --- a/Source/JavaScriptCore/runtime/CommonIdentifiers.h +++ b/Source/JavaScriptCore/runtime/CommonIdentifiers.h @@ -99,11 +99,7 @@ macro(valueOf) \ macro(writable) \ macro(displayName) \ - macro(join) \ - macro(__defineGetter__) \ - macro(__defineSetter__) \ - macro(__lookupGetter__) \ - macro(__lookupSetter__) + macro(join) #define JSC_COMMON_IDENTIFIERS_EACH_KEYWORD(macro) \ macro(null) \ diff --git a/Source/JavaScriptCore/runtime/JSCell.cpp b/Source/JavaScriptCore/runtime/JSCell.cpp index 215b4d51b0fe722fbace9ff94c8310c97494b87b..da142e4f6ac2e542632e8bc5129199ada95e3056 100644 --- a/Source/JavaScriptCore/runtime/JSCell.cpp +++ b/Source/JavaScriptCore/runtime/JSCell.cpp @@ -227,10 +227,4 @@ bool JSCell::getOwnPropertyDescriptor(JSObject*, ExecState*, PropertyName, Prope return false; } -JSValue JSCell::getByStringSlow(ExecState* exec, const String& name) -{ - Identifier ident(&exec->globalData(), name); - return JSValue(this).get(exec, ident); -} - } // namespace JSC diff --git a/Source/JavaScriptCore/runtime/JSCell.h b/Source/JavaScriptCore/runtime/JSCell.h index 3a764c52b90f789be91b6c0aa756753a2991f726..534228893bf8ebccb85c3f97ad3e55385e4974ec 100644 --- a/Source/JavaScriptCore/runtime/JSCell.h +++ b/Source/JavaScriptCore/runtime/JSCell.h @@ -122,8 +122,7 @@ public: // call this function, not its slower virtual counterpart. (For integer // property names, we want a similar interface with appropriate optimizations.) bool fastGetOwnPropertySlot(ExecState*, PropertyName, PropertySlot&); - - JSValue getByString(ExecState*, const String&); + JSValue fastGetOwnProperty(ExecState*, const String&); static ptrdiff_t structureOffset() { @@ -162,10 +161,6 @@ protected: private: friend class LLIntOffsetsExtractor; - - template - JSValue getByStringAndKey(ExecState*, const String&, const KeyType&); - JSValue getByStringSlow(ExecState*, const String&); WriteBarrier m_structure; }; diff --git a/Source/JavaScriptCore/runtime/JSCellInlines.h b/Source/JavaScriptCore/runtime/JSCellInlines.h index 6b04e3aae146fa55e36b0ab9b97b21081dc40cc3..c87a02e128b93027b5697907515fe4124f794bed 100644 --- a/Source/JavaScriptCore/runtime/JSCellInlines.h +++ b/Source/JavaScriptCore/runtime/JSCellInlines.h @@ -169,46 +169,20 @@ ALWAYS_INLINE bool JSCell::fastGetOwnPropertySlot(ExecState* exec, PropertyName return methodTable()->getOwnPropertySlot(this, exec, propertyName, slot); } -template -ALWAYS_INLINE JSValue JSCell::getByStringAndKey(ExecState* exec, const String& name, const KeyType& key) -{ - JSCell* cell = this; - - while (true) { - if (UNLIKELY(cell->structure()->typeInfo().overridesGetOwnPropertySlot())) - return getByStringSlow(exec, name); - - unsigned attributes; - PropertyOffset offset = cell->structure()->get(exec->globalData(), key, attributes); - if (offset != invalidOffset) { - if (attributes & Accessor) - return cell->getByStringSlow(exec, name); - return asObject(cell)->getDirect(offset); - } - - JSValue prototype = cell->structure()->storedPrototype(); - if (!prototype.isObject()) - break; - cell = asObject(prototype); - } - - // Make sure we aren't going after indexed storage, and if we are, then just use that. - unsigned index = toUInt32FromStringImpl(name.impl()); - if (index == PropertyName::NotAnIndex) - return jsUndefined(); - - return JSValue(this).get(exec, index); -} - // Fast call to get a property where we may not yet have converted the string to an // identifier. The first time we perform a property access with a given string, try // performing the property map lookup without forming an identifier. We detect this // case by checking whether the hash has yet been set for this string. -ALWAYS_INLINE JSValue JSCell::getByString(ExecState* exec, const String& name) -{ - if (name.impl()->hasHash()) - return getByStringAndKey(exec, name, Identifier(exec, name)); - return getByStringAndKey(exec, name, name); +ALWAYS_INLINE JSValue JSCell::fastGetOwnProperty(ExecState* exec, const String& name) +{ + if (!structure()->typeInfo().overridesGetOwnPropertySlot() && !structure()->hasGetterSetterProperties()) { + PropertyOffset offset = name.impl()->hasHash() + ? structure()->get(exec->globalData(), Identifier(exec, name)) + : structure()->get(exec->globalData(), name); + if (offset != invalidOffset) + return asObject(this)->locationForOffset(offset)->get(); + } + return JSValue(); } inline bool JSCell::toBoolean(ExecState* exec) const diff --git a/Source/JavaScriptCore/runtime/JSGlobalData.cpp b/Source/JavaScriptCore/runtime/JSGlobalData.cpp index 36f2ffd5a856b7664daa73f349344db632e8f3d6..508a876a89c609e6ffc910f7582970b0beab03d2 100644 --- a/Source/JavaScriptCore/runtime/JSGlobalData.cpp +++ b/Source/JavaScriptCore/runtime/JSGlobalData.cpp @@ -93,6 +93,7 @@ extern const HashTable mathTable; extern const HashTable numberConstructorTable; extern const HashTable numberPrototypeTable; JS_EXPORTDATA extern const HashTable objectConstructorTable; +extern const HashTable objectPrototypeTable; extern const HashTable privateNamePrototypeTable; extern const HashTable regExpTable; extern const HashTable regExpConstructorTable; @@ -154,6 +155,7 @@ JSGlobalData::JSGlobalData(GlobalDataType globalDataType, HeapType heapType) , numberConstructorTable(fastNew(JSC::numberConstructorTable)) , numberPrototypeTable(fastNew(JSC::numberPrototypeTable)) , objectConstructorTable(fastNew(JSC::objectConstructorTable)) + , objectPrototypeTable(fastNew(JSC::objectPrototypeTable)) , privateNamePrototypeTable(fastNew(JSC::privateNamePrototypeTable)) , regExpTable(fastNew(JSC::regExpTable)) , regExpConstructorTable(fastNew(JSC::regExpConstructorTable)) @@ -284,6 +286,7 @@ JSGlobalData::~JSGlobalData() numberConstructorTable->deleteTable(); numberPrototypeTable->deleteTable(); objectConstructorTable->deleteTable(); + objectPrototypeTable->deleteTable(); privateNamePrototypeTable->deleteTable(); regExpTable->deleteTable(); regExpConstructorTable->deleteTable(); @@ -303,6 +306,7 @@ JSGlobalData::~JSGlobalData() fastDelete(const_cast(numberConstructorTable)); fastDelete(const_cast(numberPrototypeTable)); fastDelete(const_cast(objectConstructorTable)); + fastDelete(const_cast(objectPrototypeTable)); fastDelete(const_cast(privateNamePrototypeTable)); fastDelete(const_cast(regExpTable)); fastDelete(const_cast(regExpConstructorTable)); diff --git a/Source/JavaScriptCore/runtime/JSGlobalData.h b/Source/JavaScriptCore/runtime/JSGlobalData.h index 570d85d8084ded043c37dd0ead101ca635de8ba0..fad9ce65191c715f1cf5c0ec9e15cce8813c24c8 100644 --- a/Source/JavaScriptCore/runtime/JSGlobalData.h +++ b/Source/JavaScriptCore/runtime/JSGlobalData.h @@ -226,6 +226,7 @@ namespace JSC { const HashTable* numberConstructorTable; const HashTable* numberPrototypeTable; const HashTable* objectConstructorTable; + const HashTable* objectPrototypeTable; const HashTable* privateNamePrototypeTable; const HashTable* regExpTable; const HashTable* regExpConstructorTable; diff --git a/Source/JavaScriptCore/runtime/JSObject.cpp b/Source/JavaScriptCore/runtime/JSObject.cpp index bd88b4df7205bcad6a4be975bdd1fe5a9aa3d050..78ba279bf86211a89996bafaf62c88806442b34c 100644 --- a/Source/JavaScriptCore/runtime/JSObject.cpp +++ b/Source/JavaScriptCore/runtime/JSObject.cpp @@ -2202,16 +2202,6 @@ bool JSObject::putDirectIndexBeyondVectorLength(ExecState* exec, unsigned i, JSV } } -void JSObject::putDirectNativeFunction(ExecState* exec, JSGlobalObject* globalObject, const PropertyName& propertyName, unsigned functionLength, NativeFunction nativeFunction, Intrinsic intrinsic, unsigned attributes) -{ - StringImpl* name = propertyName.publicName(); - ASSERT(name); - - JSFunction* function = - JSFunction::create(exec, globalObject, functionLength, name, nativeFunction, intrinsic); - putDirect(exec->globalData(), propertyName, function, attributes); -} - ALWAYS_INLINE unsigned JSObject::getNewVectorLength(unsigned currentVectorLength, unsigned currentLength, unsigned desiredLength) { ASSERT(desiredLength <= MAX_STORAGE_VECTOR_LENGTH); diff --git a/Source/JavaScriptCore/runtime/JSObject.h b/Source/JavaScriptCore/runtime/JSObject.h index ebd55924bf3c05141be90d3e389ab5070adb1f51..b7a7330f85361466273f83aeead0f203103ed38b 100644 --- a/Source/JavaScriptCore/runtime/JSObject.h +++ b/Source/JavaScriptCore/runtime/JSObject.h @@ -565,8 +565,6 @@ public: void putDirect(JSGlobalData& globalData, PropertyOffset offset, JSValue value) { locationForOffset(offset)->set(globalData, this, value); } void putDirectUndefined(PropertyOffset offset) { locationForOffset(offset)->setUndefined(); } - void putDirectNativeFunction(ExecState*, JSGlobalObject*, const PropertyName&, unsigned functionLength, NativeFunction, Intrinsic, unsigned attributes); - JS_EXPORT_PRIVATE static bool defineOwnProperty(JSObject*, ExecState*, PropertyName, PropertyDescriptor&, bool shouldThrow); bool isGlobalObject() const; @@ -702,7 +700,7 @@ protected: ASSERT(structure()->isObject()); ASSERT(classInfo()); } - + static Structure* createStructure(JSGlobalData& globalData, JSGlobalObject* globalObject, JSValue prototype) { return Structure::create(globalData, globalObject, prototype, TypeInfo(ObjectType, StructureFlags), &s_info); @@ -911,7 +909,6 @@ private: // Nobody should ever ask any of these questions on something already known to be a JSObject. using JSCell::isAPIValueWrapper; using JSCell::isGetterSetter; - void getObject(); void getString(ExecState* exec); void isObject(); @@ -1452,14 +1449,6 @@ inline int offsetRelativeToBase(PropertyOffset offset) COMPILE_ASSERT(!(sizeof(JSObject) % sizeof(WriteBarrierBase)), JSObject_inline_storage_has_correct_alignment); -// Helper for defining native functions, if you're not using a static hash table. -// Use this macro from within finishCreation() methods in prototypes. This assumes -// you've defined variables called exec, globalObject, and globalData, and they -// have the expected meanings. This also assumes that the function you're defining -// doesn't have an intrinsic. -#define JSC_NATIVE_FUNCTION(jsName, cppName, attributes, length) \ - putDirectNativeFunction(exec, globalObject, globalData.propertyNames->jsName, (length), cppName, NoIntrinsic, (attributes)) - } // namespace JSC #endif // JSObject_h diff --git a/Source/JavaScriptCore/runtime/Lookup.cpp b/Source/JavaScriptCore/runtime/Lookup.cpp index 546668b70d713d4e95a85411139226d98be4193f..067c5c0b71427ad1d969614377537f81e01d1aa4 100644 --- a/Source/JavaScriptCore/runtime/Lookup.cpp +++ b/Source/JavaScriptCore/runtime/Lookup.cpp @@ -77,9 +77,11 @@ bool setUpStaticFunctionSlot(ExecState* exec, const HashEntry* entry, JSObject* if (thisObj->staticFunctionsReified()) return false; - thisObj->putDirectNativeFunction( - exec, thisObj->globalObject(), propertyName, entry->functionLength(), - entry->function(), entry->intrinsic(), entry->attributes()); + StringImpl* name = propertyName.publicName(); + ASSERT(name); + + JSFunction* function = JSFunction::create(exec, thisObj->globalObject(), entry->functionLength(), name, entry->function(), entry->intrinsic()); + thisObj->putDirect(exec->globalData(), propertyName, function, entry->attributes()); offset = thisObj->getDirectOffset(exec->globalData(), propertyName); ASSERT(isValidOffset(offset)); } diff --git a/Source/JavaScriptCore/runtime/ObjectPrototype.cpp b/Source/JavaScriptCore/runtime/ObjectPrototype.cpp index 1625e43f88242077f35b4006aed0ceb971793984..3342e71ce0a9088edb23a605f63c90e1d07a9da6 100644 --- a/Source/JavaScriptCore/runtime/ObjectPrototype.cpp +++ b/Source/JavaScriptCore/runtime/ObjectPrototype.cpp @@ -40,40 +40,51 @@ static EncodedJSValue JSC_HOST_CALL objectProtoFuncLookupSetter(ExecState*); static EncodedJSValue JSC_HOST_CALL objectProtoFuncPropertyIsEnumerable(ExecState*); static EncodedJSValue JSC_HOST_CALL objectProtoFuncToLocaleString(ExecState*); +} + +#include "ObjectPrototype.lut.h" + +namespace JSC { + ASSERT_HAS_TRIVIAL_DESTRUCTOR(ObjectPrototype); -const ClassInfo ObjectPrototype::s_info = { "Object", &JSNonFinalObject::s_info, 0, 0, CREATE_METHOD_TABLE(ObjectPrototype) }; +const ClassInfo ObjectPrototype::s_info = { "Object", &JSNonFinalObject::s_info, 0, ExecState::objectPrototypeTable, CREATE_METHOD_TABLE(ObjectPrototype) }; + +/* Source for ObjectPrototype.lut.h +@begin objectPrototypeTable + toString objectProtoFuncToString DontEnum|Function 0 + toLocaleString objectProtoFuncToLocaleString DontEnum|Function 0 + valueOf objectProtoFuncValueOf DontEnum|Function 0 + hasOwnProperty objectProtoFuncHasOwnProperty DontEnum|Function 1 + propertyIsEnumerable objectProtoFuncPropertyIsEnumerable DontEnum|Function 1 + isPrototypeOf objectProtoFuncIsPrototypeOf DontEnum|Function 1 + __defineGetter__ objectProtoFuncDefineGetter DontEnum|Function 2 + __defineSetter__ objectProtoFuncDefineSetter DontEnum|Function 2 + __lookupGetter__ objectProtoFuncLookupGetter DontEnum|Function 1 + __lookupSetter__ objectProtoFuncLookupSetter DontEnum|Function 1 +@end +*/ ObjectPrototype::ObjectPrototype(ExecState* exec, Structure* stucture) : JSNonFinalObject(exec->globalData(), stucture) { } -void ObjectPrototype::finishCreation(ExecState* exec, JSGlobalObject* globalObject) +void ObjectPrototype::finishCreation(JSGlobalData& globalData, JSGlobalObject*) { - JSGlobalData& globalData = exec->globalData(); - Base::finishCreation(globalData); ASSERT(inherits(&s_info)); globalData.prototypeMap.addPrototype(this); - - JSC_NATIVE_FUNCTION(toString, objectProtoFuncToString, DontEnum, 0); - JSC_NATIVE_FUNCTION(toLocaleString, objectProtoFuncToLocaleString, DontEnum, 0); - JSC_NATIVE_FUNCTION(valueOf, objectProtoFuncValueOf, DontEnum, 0); - JSC_NATIVE_FUNCTION(hasOwnProperty, objectProtoFuncHasOwnProperty, DontEnum, 1); - JSC_NATIVE_FUNCTION(propertyIsEnumerable, objectProtoFuncPropertyIsEnumerable, DontEnum, 1); - JSC_NATIVE_FUNCTION(isPrototypeOf, objectProtoFuncIsPrototypeOf, DontEnum, 1); - JSC_NATIVE_FUNCTION(__defineGetter__, objectProtoFuncDefineGetter, DontEnum, 2); - JSC_NATIVE_FUNCTION(__defineSetter__, objectProtoFuncDefineSetter, DontEnum, 2); - JSC_NATIVE_FUNCTION(__lookupGetter__, objectProtoFuncLookupGetter, DontEnum, 1); - JSC_NATIVE_FUNCTION(__lookupSetter__, objectProtoFuncLookupSetter, DontEnum, 1); } -ObjectPrototype* ObjectPrototype::create(ExecState* exec, JSGlobalObject* globalObject, Structure* structure) +bool ObjectPrototype::getOwnPropertySlot(JSCell* cell, ExecState* exec, PropertyName propertyName, PropertySlot &slot) +{ + return getStaticFunctionSlot(exec, ExecState::objectPrototypeTable(exec), jsCast(cell), propertyName, slot); +} + +bool ObjectPrototype::getOwnPropertyDescriptor(JSObject* object, ExecState* exec, PropertyName propertyName, PropertyDescriptor& descriptor) { - ObjectPrototype* prototype = new (NotNull, allocateCell(*exec->heap())) ObjectPrototype(exec, structure); - prototype->finishCreation(exec, globalObject); - return prototype; + return getStaticFunctionDescriptor(exec, ExecState::objectPrototypeTable(exec), jsCast(object), propertyName, descriptor); } // ------------------------------ Functions -------------------------------- diff --git a/Source/JavaScriptCore/runtime/ObjectPrototype.h b/Source/JavaScriptCore/runtime/ObjectPrototype.h index dc287ea4cf597fde9f68bb0b455be89cce889130..e3551d6fd75e4956ae158aaefbf2d2f4f8feaab4 100644 --- a/Source/JavaScriptCore/runtime/ObjectPrototype.h +++ b/Source/JavaScriptCore/runtime/ObjectPrototype.h @@ -29,7 +29,12 @@ namespace JSC { public: typedef JSNonFinalObject Base; - static ObjectPrototype* create(ExecState*, JSGlobalObject*, Structure*); + static ObjectPrototype* create(ExecState* exec, JSGlobalObject* globalObject, Structure* structure) + { + ObjectPrototype* prototype = new (NotNull, allocateCell(*exec->heap())) ObjectPrototype(exec, structure); + prototype->finishCreation(exec->globalData(), globalObject); + return prototype; + } static const ClassInfo s_info; @@ -39,10 +44,14 @@ namespace JSC { } protected: - void finishCreation(ExecState*, JSGlobalObject*); + static const unsigned StructureFlags = OverridesGetOwnPropertySlot | JSNonFinalObject::StructureFlags; + + void finishCreation(JSGlobalData&, JSGlobalObject*); private: ObjectPrototype(ExecState*, Structure*); + static bool getOwnPropertySlot(JSCell*, ExecState*, PropertyName, PropertySlot&); + static bool getOwnPropertyDescriptor(JSObject*, ExecState*, PropertyName, PropertyDescriptor&); }; JS_EXPORT_PRIVATE EncodedJSValue JSC_HOST_CALL objectProtoFuncToString(ExecState*); diff --git a/Source/JavaScriptCore/runtime/PropertyMapHashTable.h b/Source/JavaScriptCore/runtime/PropertyMapHashTable.h index 9fa91bbc617f33022d433b2e4423aeb4d60b3b7c..54e2973b14c9d067eae15cbf375b69d803ba775d 100644 --- a/Source/JavaScriptCore/runtime/PropertyMapHashTable.h +++ b/Source/JavaScriptCore/runtime/PropertyMapHashTable.h @@ -311,7 +311,7 @@ inline PropertyTable::find_iterator PropertyTable::find(const KeyType& key) inline PropertyTable::find_iterator PropertyTable::findWithString(const KeyType& key) { ASSERT(key); - ASSERT(!key->isIdentifier()); + ASSERT(!key->isIdentifier() && !key->hasHash()); unsigned hash = key->hash(); unsigned step = 0; diff --git a/Source/JavaScriptCore/runtime/Structure.h b/Source/JavaScriptCore/runtime/Structure.h index c669e08f20a35dc593b6536aa5f32b0fd39ee82b..f56877dbbdda7f0cdfbbee3ec7ef0f6b94459e7f 100644 --- a/Source/JavaScriptCore/runtime/Structure.h +++ b/Source/JavaScriptCore/runtime/Structure.h @@ -233,8 +233,7 @@ public: bool masqueradesAsUndefined(JSGlobalObject* lexicalGlobalObject); PropertyOffset get(JSGlobalData&, PropertyName); - PropertyOffset get(JSGlobalData&, PropertyName, unsigned& attributes); - PropertyOffset get(JSGlobalData&, const WTF::String& name, unsigned& attributes); + PropertyOffset get(JSGlobalData&, const WTF::String& name); JS_EXPORT_PRIVATE PropertyOffset get(JSGlobalData&, PropertyName, unsigned& attributes, JSCell*& specificValue); bool hasGetterSetterProperties() const { return m_hasGetterSetterProperties; } diff --git a/Source/JavaScriptCore/runtime/StructureInlines.h b/Source/JavaScriptCore/runtime/StructureInlines.h index 5da1dde5f9524607c616a21d3f0da4b2010f2ecc..522e8279953e2ae5632f5601b8d8580107e6f73c 100644 --- a/Source/JavaScriptCore/runtime/StructureInlines.h +++ b/Source/JavaScriptCore/runtime/StructureInlines.h @@ -69,22 +69,7 @@ inline PropertyOffset Structure::get(JSGlobalData& globalData, PropertyName prop return entry ? entry->offset : invalidOffset; } -inline PropertyOffset Structure::get(JSGlobalData& globalData, PropertyName propertyName, unsigned& attributes) -{ - ASSERT(structure()->classInfo() == &s_info); - materializePropertyMapIfNecessary(globalData); - if (!propertyTable()) - return invalidOffset; - - PropertyMapEntry* entry = propertyTable()->find(propertyName.uid()).first; - if (!entry) - return invalidOffset; - - attributes = entry->attributes; - return entry->offset; -} - -inline PropertyOffset Structure::get(JSGlobalData& globalData, const WTF::String& name, unsigned& attributes) +inline PropertyOffset Structure::get(JSGlobalData& globalData, const WTF::String& name) { ASSERT(structure()->classInfo() == &s_info); materializePropertyMapIfNecessary(globalData); @@ -92,11 +77,7 @@ inline PropertyOffset Structure::get(JSGlobalData& globalData, const WTF::String return invalidOffset; PropertyMapEntry* entry = propertyTable()->findWithString(name.impl()).first; - if (!entry) - return invalidOffset; - - attributes = entry->attributes; - return entry->offset; + return entry ? entry->offset : invalidOffset; } inline bool Structure::masqueradesAsUndefined(JSGlobalObject* lexicalGlobalObject)