diff options
author | Simon Hausmann <simon.hausmann@nokia.com> | 2012-08-24 08:29:43 +0200 |
---|---|---|
committer | Simon Hausmann <simon.hausmann@nokia.com> | 2012-08-24 08:29:43 +0200 |
commit | 2e2ba8ff45915f40ed3e014101269c175f2a89a0 (patch) | |
tree | 3b94a9a9fa83efa384b8dac611cf8c6495532a62 /Source/JavaScriptCore/runtime | |
parent | f53e6f8e798362ed712d4a51633b0d0b03dbc213 (diff) | |
download | qtwebkit-2e2ba8ff45915f40ed3e014101269c175f2a89a0.tar.gz |
Imported WebKit commit bf0b0213bbf3886c96610020602012ca7d11b084 (http://svn.webkit.org/repository/webkit/trunk@126545)
New snapshot with clang and python build fixes
Diffstat (limited to 'Source/JavaScriptCore/runtime')
-rw-r--r-- | Source/JavaScriptCore/runtime/ArrayPrototype.cpp | 12 | ||||
-rw-r--r-- | Source/JavaScriptCore/runtime/BooleanConstructor.cpp | 4 | ||||
-rw-r--r-- | Source/JavaScriptCore/runtime/BooleanObject.h | 6 | ||||
-rw-r--r-- | Source/JavaScriptCore/runtime/JSCell.h | 2 | ||||
-rw-r--r-- | Source/JavaScriptCore/runtime/JSGlobalObject.cpp | 1 | ||||
-rw-r--r-- | Source/JavaScriptCore/runtime/JSGlobalObject.h | 5 | ||||
-rw-r--r-- | Source/JavaScriptCore/runtime/JSString.h | 8 | ||||
-rw-r--r-- | Source/JavaScriptCore/runtime/JSValue.h | 2 | ||||
-rw-r--r-- | Source/JavaScriptCore/runtime/NumberObject.h | 4 | ||||
-rw-r--r-- | Source/JavaScriptCore/runtime/ObjectConstructor.cpp | 6 | ||||
-rw-r--r-- | Source/JavaScriptCore/runtime/Operations.cpp | 6 | ||||
-rw-r--r-- | Source/JavaScriptCore/runtime/Operations.h | 6 | ||||
-rw-r--r-- | Source/JavaScriptCore/runtime/RegExpConstructor.cpp | 4 | ||||
-rw-r--r-- | Source/JavaScriptCore/runtime/RegExpPrototype.cpp | 6 | ||||
-rw-r--r-- | Source/JavaScriptCore/runtime/StringObject.cpp | 8 | ||||
-rw-r--r-- | Source/JavaScriptCore/runtime/StringObject.h | 2 | ||||
-rw-r--r-- | Source/JavaScriptCore/runtime/Structure.h | 12 |
17 files changed, 61 insertions, 33 deletions
diff --git a/Source/JavaScriptCore/runtime/ArrayPrototype.cpp b/Source/JavaScriptCore/runtime/ArrayPrototype.cpp index b0adb7f0f..a97cf82de 100644 --- a/Source/JavaScriptCore/runtime/ArrayPrototype.cpp +++ b/Source/JavaScriptCore/runtime/ArrayPrototype.cpp @@ -797,7 +797,7 @@ EncodedJSValue JSC_HOST_CALL arrayProtoFuncFilter(ExecState* exec) cachedCall.setArgument(2, thisObj); JSValue result = cachedCall.call(); - if (result.toBoolean()) + if (result.toBoolean(exec)) resultArray->putDirectIndex(exec, filterIndex++, v); } if (k == length) @@ -818,7 +818,7 @@ EncodedJSValue JSC_HOST_CALL arrayProtoFuncFilter(ExecState* exec) eachArguments.append(thisObj); JSValue result = call(exec, function, callType, callData, applyThis, eachArguments); - if (result.toBoolean()) + if (result.toBoolean(exec)) resultArray->putDirectIndex(exec, filterIndex++, v); } return JSValue::encode(resultArray); @@ -917,7 +917,7 @@ EncodedJSValue JSC_HOST_CALL arrayProtoFuncEvery(ExecState* exec) cachedCall.setArgument(1, jsNumber(k)); cachedCall.setArgument(2, thisObj); JSValue result = cachedCall.call(); - if (!result.toBoolean()) + if (!result.toBoolean(exec)) return JSValue::encode(jsBoolean(false)); } } @@ -934,7 +934,7 @@ EncodedJSValue JSC_HOST_CALL arrayProtoFuncEvery(ExecState* exec) if (exec->hadException()) return JSValue::encode(jsUndefined()); - bool predicateResult = call(exec, function, callType, callData, applyThis, eachArguments).toBoolean(); + bool predicateResult = call(exec, function, callType, callData, applyThis, eachArguments).toBoolean(exec); if (!predicateResult) { result = jsBoolean(false); break; @@ -1025,7 +1025,7 @@ EncodedJSValue JSC_HOST_CALL arrayProtoFuncSome(ExecState* exec) cachedCall.setArgument(1, jsNumber(k)); cachedCall.setArgument(2, thisObj); JSValue result = cachedCall.call(); - if (result.toBoolean()) + if (result.toBoolean(exec)) return JSValue::encode(jsBoolean(true)); } } @@ -1042,7 +1042,7 @@ EncodedJSValue JSC_HOST_CALL arrayProtoFuncSome(ExecState* exec) if (exec->hadException()) return JSValue::encode(jsUndefined()); - bool predicateResult = call(exec, function, callType, callData, applyThis, eachArguments).toBoolean(); + bool predicateResult = call(exec, function, callType, callData, applyThis, eachArguments).toBoolean(exec); if (predicateResult) { result = jsBoolean(true); break; diff --git a/Source/JavaScriptCore/runtime/BooleanConstructor.cpp b/Source/JavaScriptCore/runtime/BooleanConstructor.cpp index 090be0aaa..9b666292c 100644 --- a/Source/JavaScriptCore/runtime/BooleanConstructor.cpp +++ b/Source/JavaScriptCore/runtime/BooleanConstructor.cpp @@ -49,7 +49,7 @@ void BooleanConstructor::finishCreation(ExecState* exec, BooleanPrototype* boole JSObject* constructBoolean(ExecState* exec, const ArgList& args) { BooleanObject* obj = BooleanObject::create(exec->globalData(), asInternalFunction(exec->callee())->globalObject()->booleanObjectStructure()); - obj->setInternalValue(exec->globalData(), jsBoolean(args.at(0).toBoolean())); + obj->setInternalValue(exec->globalData(), jsBoolean(args.at(0).toBoolean(exec))); return obj; } @@ -68,7 +68,7 @@ ConstructType BooleanConstructor::getConstructData(JSCell*, ConstructData& const // ECMA 15.6.1 static EncodedJSValue JSC_HOST_CALL callBooleanConstructor(ExecState* exec) { - return JSValue::encode(jsBoolean(exec->argument(0).toBoolean())); + return JSValue::encode(jsBoolean(exec->argument(0).toBoolean(exec))); } CallType BooleanConstructor::getCallData(JSCell*, CallData& callData) diff --git a/Source/JavaScriptCore/runtime/BooleanObject.h b/Source/JavaScriptCore/runtime/BooleanObject.h index 2704ff3cd..bd0f66944 100644 --- a/Source/JavaScriptCore/runtime/BooleanObject.h +++ b/Source/JavaScriptCore/runtime/BooleanObject.h @@ -27,8 +27,8 @@ namespace JSC { class BooleanObject : public JSWrapperObject { protected: - BooleanObject(JSGlobalData&, Structure*); - void finishCreation(JSGlobalData&); + JS_EXPORT_PRIVATE BooleanObject(JSGlobalData&, Structure*); + JS_EXPORT_PRIVATE void finishCreation(JSGlobalData&); public: typedef JSWrapperObject Base; @@ -40,7 +40,7 @@ namespace JSC { return boolean; } - static const ClassInfo s_info; + static JS_EXPORTDATA const ClassInfo s_info; static Structure* createStructure(JSGlobalData& globalData, JSGlobalObject* globalObject, JSValue prototype) { diff --git a/Source/JavaScriptCore/runtime/JSCell.h b/Source/JavaScriptCore/runtime/JSCell.h index 90e531cec..39f98356f 100644 --- a/Source/JavaScriptCore/runtime/JSCell.h +++ b/Source/JavaScriptCore/runtime/JSCell.h @@ -98,7 +98,7 @@ namespace JSC { // Basic conversions. JS_EXPORT_PRIVATE JSValue toPrimitive(ExecState*, PreferredPrimitiveType) const; bool getPrimitiveNumber(ExecState*, double& number, JSValue&) const; - bool toBoolean() const; + bool toBoolean(ExecState*) const; JS_EXPORT_PRIVATE double toNumber(ExecState*) const; JS_EXPORT_PRIVATE JSObject* toObject(ExecState*, JSGlobalObject*) const; diff --git a/Source/JavaScriptCore/runtime/JSGlobalObject.cpp b/Source/JavaScriptCore/runtime/JSGlobalObject.cpp index 0edc0a8a9..ff7b1486f 100644 --- a/Source/JavaScriptCore/runtime/JSGlobalObject.cpp +++ b/Source/JavaScriptCore/runtime/JSGlobalObject.cpp @@ -115,6 +115,7 @@ template <typename T> static inline void visitIfNeeded(SlotVisitor& visitor, Wri JSGlobalObject::JSGlobalObject(JSGlobalData& globalData, Structure* structure, const GlobalObjectMethodTable* globalObjectMethodTable) : JSSegmentedVariableObject(globalData, structure, &m_symbolTable) , m_globalScopeChain() + , m_masqueradesAsUndefinedWatchpoint(adoptRef(new WatchpointSet(InitializedWatching))) , m_weakRandom(Options::forceWeakRandomSeed() ? Options::forcedWeakRandomSeed() : static_cast<unsigned>(randomNumber() * (std::numeric_limits<unsigned>::max() + 1.0))) , m_evalEnabled(true) , m_globalObjectMethodTable(globalObjectMethodTable ? globalObjectMethodTable : &s_globalObjectMethodTable) diff --git a/Source/JavaScriptCore/runtime/JSGlobalObject.h b/Source/JavaScriptCore/runtime/JSGlobalObject.h index af03f32e6..248004bd5 100644 --- a/Source/JavaScriptCore/runtime/JSGlobalObject.h +++ b/Source/JavaScriptCore/runtime/JSGlobalObject.h @@ -30,6 +30,7 @@ #include "NumberPrototype.h" #include "StringPrototype.h" #include "StructureChain.h" +#include "Watchpoint.h" #include <wtf/HashSet.h> #include <wtf/OwnPtr.h> #include <wtf/RandomNumber.h> @@ -142,6 +143,8 @@ namespace JSC { Debugger* m_debugger; + RefPtr<WatchpointSet> m_masqueradesAsUndefinedWatchpoint; + OwnPtr<JSGlobalObjectRareData> m_rareData; WeakRandom m_weakRandom; @@ -270,6 +273,8 @@ namespace JSC { Structure* regExpStructure() const { return m_regExpStructure.get(); } Structure* stringObjectStructure() const { return m_stringObjectStructure.get(); } + WatchpointSet* masqueradesAsUndefinedWatchpoint() { return m_masqueradesAsUndefinedWatchpoint.get(); } + void setProfileGroup(unsigned value) { createRareDataIfNeeded(); m_rareData->profileGroup = value; } unsigned profileGroup() const { diff --git a/Source/JavaScriptCore/runtime/JSString.h b/Source/JavaScriptCore/runtime/JSString.h index d6fc4c2a1..e91553aeb 100644 --- a/Source/JavaScriptCore/runtime/JSString.h +++ b/Source/JavaScriptCore/runtime/JSString.h @@ -500,23 +500,23 @@ namespace JSC { inline bool isJSString(JSValue v) { return v.isCell() && v.asCell()->classInfo() == &JSString::s_info; } - inline bool JSCell::toBoolean() const + inline bool JSCell::toBoolean(ExecState* exec) const { if (isString()) return static_cast<const JSString*>(this)->toBoolean(); - return !structure()->typeInfo().masqueradesAsUndefined(); + return !structure()->masqueradesAsUndefined(exec->lexicalGlobalObject()); } // --- JSValue inlines ---------------------------- - inline bool JSValue::toBoolean() const + inline bool JSValue::toBoolean(ExecState* exec) const { if (isInt32()) return asInt32(); if (isDouble()) return asDouble() > 0.0 || asDouble() < 0.0; // false for NaN if (isCell()) - return asCell()->toBoolean(); + return asCell()->toBoolean(exec); return isTrue(); // false, null, and undefined all convert to false. } diff --git a/Source/JavaScriptCore/runtime/JSValue.h b/Source/JavaScriptCore/runtime/JSValue.h index 19a8c4759..7aa5453e4 100644 --- a/Source/JavaScriptCore/runtime/JSValue.h +++ b/Source/JavaScriptCore/runtime/JSValue.h @@ -209,7 +209,7 @@ namespace JSC { JSValue toPrimitive(ExecState*, PreferredPrimitiveType = NoPreference) const; bool getPrimitiveNumber(ExecState*, double& number, JSValue&); - bool toBoolean() const; + bool toBoolean(ExecState*) const; // toNumber conversion is expected to be side effect free if an exception has // been set in the ExecState already. diff --git a/Source/JavaScriptCore/runtime/NumberObject.h b/Source/JavaScriptCore/runtime/NumberObject.h index 07334722b..ed84207d9 100644 --- a/Source/JavaScriptCore/runtime/NumberObject.h +++ b/Source/JavaScriptCore/runtime/NumberObject.h @@ -40,7 +40,7 @@ namespace JSC { return number; } - static const ClassInfo s_info; + static JS_EXPORTDATA const ClassInfo s_info; static Structure* createStructure(JSGlobalData& globalData, JSGlobalObject* globalObject, JSValue prototype) { @@ -48,7 +48,7 @@ namespace JSC { } }; - NumberObject* constructNumber(ExecState*, JSGlobalObject*, JSValue); + JS_EXPORT_PRIVATE NumberObject* constructNumber(ExecState*, JSGlobalObject*, JSValue); } // namespace JSC diff --git a/Source/JavaScriptCore/runtime/ObjectConstructor.cpp b/Source/JavaScriptCore/runtime/ObjectConstructor.cpp index 7b6a5f669..5a6fcddf0 100644 --- a/Source/JavaScriptCore/runtime/ObjectConstructor.cpp +++ b/Source/JavaScriptCore/runtime/ObjectConstructor.cpp @@ -214,14 +214,14 @@ static bool toPropertyDescriptor(ExecState* exec, JSValue in, PropertyDescriptor PropertySlot enumerableSlot(description); if (description->getPropertySlot(exec, exec->propertyNames().enumerable, enumerableSlot)) { - desc.setEnumerable(enumerableSlot.getValue(exec, exec->propertyNames().enumerable).toBoolean()); + desc.setEnumerable(enumerableSlot.getValue(exec, exec->propertyNames().enumerable).toBoolean(exec)); if (exec->hadException()) return false; } PropertySlot configurableSlot(description); if (description->getPropertySlot(exec, exec->propertyNames().configurable, configurableSlot)) { - desc.setConfigurable(configurableSlot.getValue(exec, exec->propertyNames().configurable).toBoolean()); + desc.setConfigurable(configurableSlot.getValue(exec, exec->propertyNames().configurable).toBoolean(exec)); if (exec->hadException()) return false; } @@ -236,7 +236,7 @@ static bool toPropertyDescriptor(ExecState* exec, JSValue in, PropertyDescriptor PropertySlot writableSlot(description); if (description->getPropertySlot(exec, exec->propertyNames().writable, writableSlot)) { - desc.setWritable(writableSlot.getValue(exec, exec->propertyNames().writable).toBoolean()); + desc.setWritable(writableSlot.getValue(exec, exec->propertyNames().writable).toBoolean(exec)); if (exec->hadException()) return false; } diff --git a/Source/JavaScriptCore/runtime/Operations.cpp b/Source/JavaScriptCore/runtime/Operations.cpp index 4cb9de505..d96bae575 100644 --- a/Source/JavaScriptCore/runtime/Operations.cpp +++ b/Source/JavaScriptCore/runtime/Operations.cpp @@ -70,7 +70,7 @@ JSValue jsTypeStringForValue(CallFrame* callFrame, JSValue v) if (v.isObject()) { // Return "undefined" for objects that should be treated // as null when doing comparisons. - if (asObject(v)->structure()->typeInfo().masqueradesAsUndefined()) + if (asObject(v)->structure()->masqueradesAsUndefined(callFrame->lexicalGlobalObject())) return globalData.smallStrings.undefinedString(&globalData); CallData callData; JSObject* object = asObject(v); @@ -80,7 +80,7 @@ JSValue jsTypeStringForValue(CallFrame* callFrame, JSValue v) return globalData.smallStrings.objectString(&globalData); } -bool jsIsObjectType(JSValue v) +bool jsIsObjectType(CallFrame* callFrame, JSValue v) { if (!v.isCell()) return v.isNull(); @@ -89,7 +89,7 @@ bool jsIsObjectType(JSValue v) if (type == NumberType || type == StringType) return false; if (type >= ObjectType) { - if (asObject(v)->structure()->typeInfo().masqueradesAsUndefined()) + if (asObject(v)->structure()->masqueradesAsUndefined(callFrame->lexicalGlobalObject())) return false; CallData callData; JSObject* object = asObject(v); diff --git a/Source/JavaScriptCore/runtime/Operations.h b/Source/JavaScriptCore/runtime/Operations.h index 497b19d82..88fffdac4 100644 --- a/Source/JavaScriptCore/runtime/Operations.h +++ b/Source/JavaScriptCore/runtime/Operations.h @@ -31,7 +31,7 @@ namespace JSC { NEVER_INLINE JSValue jsAddSlowCase(CallFrame*, JSValue, JSValue); JSValue jsTypeStringForValue(CallFrame*, JSValue); - bool jsIsObjectType(JSValue); + bool jsIsObjectType(CallFrame*, JSValue); bool jsIsFunctionType(JSValue); ALWAYS_INLINE JSValue jsString(ExecState* exec, JSString* s1, JSString* s2) @@ -134,13 +134,13 @@ namespace JSC { return true; if (!v2.isCell()) return false; - return v2.asCell()->structure()->typeInfo().masqueradesAsUndefined(); + return v2.asCell()->structure()->masqueradesAsUndefined(exec->lexicalGlobalObject()); } if (v2.isUndefinedOrNull()) { if (!v1.isCell()) return false; - return v1.asCell()->structure()->typeInfo().masqueradesAsUndefined(); + return v1.asCell()->structure()->masqueradesAsUndefined(exec->lexicalGlobalObject()); } if (v1.isObject()) { diff --git a/Source/JavaScriptCore/runtime/RegExpConstructor.cpp b/Source/JavaScriptCore/runtime/RegExpConstructor.cpp index 0f2091c27..0b463474f 100644 --- a/Source/JavaScriptCore/runtime/RegExpConstructor.cpp +++ b/Source/JavaScriptCore/runtime/RegExpConstructor.cpp @@ -249,9 +249,9 @@ void setRegExpConstructorInput(ExecState* exec, JSObject* baseObject, JSValue va asRegExpConstructor(baseObject)->setInput(exec, value.toString(exec)); } -void setRegExpConstructorMultiline(ExecState*, JSObject* baseObject, JSValue value) +void setRegExpConstructorMultiline(ExecState* exec, JSObject* baseObject, JSValue value) { - asRegExpConstructor(baseObject)->setMultiline(value.toBoolean()); + asRegExpConstructor(baseObject)->setMultiline(value.toBoolean(exec)); } // ECMA 15.10.4 diff --git a/Source/JavaScriptCore/runtime/RegExpPrototype.cpp b/Source/JavaScriptCore/runtime/RegExpPrototype.cpp index 6080a1c99..24c7c8027 100644 --- a/Source/JavaScriptCore/runtime/RegExpPrototype.cpp +++ b/Source/JavaScriptCore/runtime/RegExpPrototype.cpp @@ -147,11 +147,11 @@ EncodedJSValue JSC_HOST_CALL regExpProtoFuncToString(ExecState* exec) char postfix[5] = { '/', 0, 0, 0, 0 }; int index = 1; - if (thisObject->get(exec, exec->propertyNames().global).toBoolean()) + if (thisObject->get(exec, exec->propertyNames().global).toBoolean(exec)) postfix[index++] = 'g'; - if (thisObject->get(exec, exec->propertyNames().ignoreCase).toBoolean()) + if (thisObject->get(exec, exec->propertyNames().ignoreCase).toBoolean(exec)) postfix[index++] = 'i'; - if (thisObject->get(exec, exec->propertyNames().multiline).toBoolean()) + if (thisObject->get(exec, exec->propertyNames().multiline).toBoolean(exec)) postfix[index] = 'm'; UString source = thisObject->get(exec, exec->propertyNames().source).toString(exec)->value(exec); // If source is empty, use "/(?:)/" to avoid colliding with comment syntax diff --git a/Source/JavaScriptCore/runtime/StringObject.cpp b/Source/JavaScriptCore/runtime/StringObject.cpp index 1dac06b46..3c037bcd1 100644 --- a/Source/JavaScriptCore/runtime/StringObject.cpp +++ b/Source/JavaScriptCore/runtime/StringObject.cpp @@ -22,6 +22,7 @@ #include "StringObject.h" #include "Error.h" +#include "JSGlobalObject.h" #include "PropertyNameArray.h" namespace JSC { @@ -143,4 +144,11 @@ void StringObject::getOwnPropertyNames(JSObject* object, ExecState* exec, Proper return JSObject::getOwnPropertyNames(thisObject, exec, propertyNames, mode); } +StringObject* constructString(ExecState* exec, JSGlobalObject* globalObject, JSValue string) +{ + StringObject* object = StringObject::create(exec, globalObject->stringObjectStructure()); + object->setInternalValue(exec->globalData(), string); + return object; +} + } // namespace JSC diff --git a/Source/JavaScriptCore/runtime/StringObject.h b/Source/JavaScriptCore/runtime/StringObject.h index 7089e8983..f0c445e91 100644 --- a/Source/JavaScriptCore/runtime/StringObject.h +++ b/Source/JavaScriptCore/runtime/StringObject.h @@ -78,6 +78,8 @@ namespace JSC { return static_cast<StringObject*>(asObject(value)); } + JS_EXPORT_PRIVATE StringObject* constructString(ExecState*, JSGlobalObject*, JSValue); + } // namespace JSC #endif // StringObject_h diff --git a/Source/JavaScriptCore/runtime/Structure.h b/Source/JavaScriptCore/runtime/Structure.h index 0b9c92210..2bb0107b7 100644 --- a/Source/JavaScriptCore/runtime/Structure.h +++ b/Source/JavaScriptCore/runtime/Structure.h @@ -256,6 +256,8 @@ namespace JSC { && offset <= lastValidOffset(); } + bool masqueradesAsUndefined(JSGlobalObject* lexicalGlobalObject); + PropertyOffset get(JSGlobalData&, PropertyName); PropertyOffset get(JSGlobalData&, const UString& name); JS_EXPORT_PRIVATE PropertyOffset get(JSGlobalData&, PropertyName, unsigned& attributes, JSCell*& specificValue); @@ -313,6 +315,11 @@ namespace JSC { return OBJECT_OFFSETOF(Structure, m_prototype); } + static ptrdiff_t globalObjectOffset() + { + return OBJECT_OFFSETOF(Structure, m_globalObject); + } + static ptrdiff_t typeInfoFlagsOffset() { return OBJECT_OFFSETOF(Structure, m_typeInfo) + TypeInfo::flagsOffset(); @@ -505,6 +512,11 @@ namespace JSC { return entry ? entry->offset : invalidOffset; } + inline bool Structure::masqueradesAsUndefined(JSGlobalObject* lexicalGlobalObject) + { + return typeInfo().masqueradesAsUndefined() && globalObject() == lexicalGlobalObject; + } + inline JSValue JSValue::structureOrUndefined() const { if (isCell()) |