Diff
Modified: trunk/Source/_javascript_Core/ChangeLog (153453 => 153454)
--- trunk/Source/_javascript_Core/ChangeLog 2013-07-30 01:10:16 UTC (rev 153453)
+++ trunk/Source/_javascript_Core/ChangeLog 2013-07-30 01:15:18 UTC (rev 153454)
@@ -1,3 +1,70 @@
+2013-07-29 Gavin Barraclough <[email protected]>
+
+ Some cleanup in PropertySlot
+ https://bugs.webkit.org/show_bug.cgi?id=119189
+
+ Reviewed by Geoff Garen.
+
+ PropertySlot represents a property in one of four states - value, getter, custom, or custom-index.
+ The state is currently tracked redundantly by two mechanisms - the custom getter function (m_getValue)
+ is set to a special value to indicate the type (other than custom), and the type is also tracked by
+ an enum - but only if cacheable. Cacheability can typically be determined by the value of m_offset
+ (this is invalidOffset if not cacheable).
+
+ * Internally, always track the type of the property using an enum value, PropertyType.
+ * Use m_offset to indicate cacheable.
+ * Keep the external interface (CachedPropertyType) unchanged.
+ * Better pack data into the m_data union.
+
+ Performance neutral.
+
+ * dfg/DFGRepatch.cpp:
+ (JSC::DFG::tryCacheGetByID):
+ (JSC::DFG::tryBuildGetByIDList):
+ - cachedPropertyType() -> isCacheable*()
+ * jit/JITPropertyAccess.cpp:
+ (JSC::JIT::privateCompileGetByIdProto):
+ (JSC::JIT::privateCompileGetByIdSelfList):
+ (JSC::JIT::privateCompileGetByIdProtoList):
+ (JSC::JIT::privateCompileGetByIdChainList):
+ (JSC::JIT::privateCompileGetByIdChain):
+ - cachedPropertyType() -> isCacheable*()
+ * jit/JITPropertyAccess32_64.cpp:
+ (JSC::JIT::privateCompileGetByIdProto):
+ (JSC::JIT::privateCompileGetByIdSelfList):
+ (JSC::JIT::privateCompileGetByIdProtoList):
+ (JSC::JIT::privateCompileGetByIdChainList):
+ (JSC::JIT::privateCompileGetByIdChain):
+ - cachedPropertyType() -> isCacheable*()
+ * jit/JITStubs.cpp:
+ (JSC::tryCacheGetByID):
+ - cachedPropertyType() -> isCacheable*()
+ * llint/LLIntSlowPaths.cpp:
+ (JSC::LLInt::LLINT_SLOW_PATH_DECL):
+ - cachedPropertyType() -> isCacheable*()
+ * runtime/PropertySlot.cpp:
+ (JSC::PropertySlot::functionGetter):
+ - refactoring described above.
+ * runtime/PropertySlot.h:
+ (JSC::PropertySlot::PropertySlot):
+ (JSC::PropertySlot::getValue):
+ (JSC::PropertySlot::isCacheable):
+ (JSC::PropertySlot::isCacheableValue):
+ (JSC::PropertySlot::isCacheableGetter):
+ (JSC::PropertySlot::isCacheableCustom):
+ (JSC::PropertySlot::cachedOffset):
+ (JSC::PropertySlot::customGetter):
+ (JSC::PropertySlot::setValue):
+ (JSC::PropertySlot::setCustom):
+ (JSC::PropertySlot::setCacheableCustom):
+ (JSC::PropertySlot::setCustomIndex):
+ (JSC::PropertySlot::setGetterSlot):
+ (JSC::PropertySlot::setCacheableGetterSlot):
+ (JSC::PropertySlot::setUndefined):
+ (JSC::PropertySlot::slotBase):
+ (JSC::PropertySlot::setBase):
+ - refactoring described above.
+
2013-07-28 Oliver Hunt <[email protected]>
REGRESSION: Crash when opening Facebook.com
Modified: trunk/Source/_javascript_Core/dfg/DFGRepatch.cpp (153453 => 153454)
--- trunk/Source/_javascript_Core/dfg/DFGRepatch.cpp 2013-07-30 01:10:16 UTC (rev 153453)
+++ trunk/Source/_javascript_Core/dfg/DFGRepatch.cpp 2013-07-30 01:15:18 UTC (rev 153454)
@@ -324,7 +324,7 @@
// Optimize self access.
if (slot.slotBase() == baseValue) {
- if ((slot.cachedPropertyType() != PropertySlot::Value)
+ if (!slot.isCacheableValue()
|| !MacroAssembler::isCompactPtrAlignedAddressOffset(maxOffsetRelativeToPatchedStorage(slot.cachedOffset()))) {
dfgRepatchCall(codeBlock, stubInfo.callReturnLocation, operationGetByIdBuildList);
return true;
@@ -339,7 +339,7 @@
return false;
// FIXME: optimize getters and setters
- if (slot.cachedPropertyType() != PropertySlot::Value)
+ if (!slot.isCacheableValue())
return false;
PropertyOffset offset = slot.cachedOffset();
@@ -438,7 +438,7 @@
// We cannot do as much inline caching if the registers were not flushed prior to this GetById. In particular,
// non-Value cached properties require planting calls, which requires registers to have been flushed. Thus,
// if registers were not flushed, don't do non-Value caching.
- if (slot.cachedPropertyType() != PropertySlot::Value)
+ if (!slot.isCacheableValue())
return false;
}
@@ -475,9 +475,8 @@
FunctionPtr operationFunction;
MacroAssembler::Jump success;
- if (slot.cachedPropertyType() == PropertySlot::Getter
- || slot.cachedPropertyType() == PropertySlot::Custom) {
- if (slot.cachedPropertyType() == PropertySlot::Getter) {
+ if (slot.isCacheableGetter() || slot.isCacheableCustom()) {
+ if (slot.isCacheableGetter()) {
ASSERT(scratchGPR != InvalidGPRReg);
ASSERT(baseGPR != scratchGPR);
if (isInlineOffset(slot.cachedOffset())) {
@@ -567,8 +566,7 @@
stubInfo.patch.dfg.deltaCallToDone).executableAddress())),
*vm,
codeBlock->ownerExecutable(),
- slot.cachedPropertyType() == PropertySlot::Getter
- || slot.cachedPropertyType() == PropertySlot::Custom);
+ slot.isCacheableGetter() || slot.isCacheableCustom());
polymorphicStructureList->list[listIndex].set(*vm, codeBlock->ownerExecutable(), stubRoutine, structure, isDirect);
@@ -576,8 +574,7 @@
return listIndex < (POLYMORPHIC_LIST_CACHE_SIZE - 1);
}
- if (baseValue.asCell()->structure()->typeInfo().prohibitsPropertyCaching()
- || slot.cachedPropertyType() != PropertySlot::Value)
+ if (baseValue.asCell()->structure()->typeInfo().prohibitsPropertyCaching() || !slot.isCacheableValue())
return false;
ASSERT(slot.slotBase().isObject());
Modified: trunk/Source/_javascript_Core/jit/JITPropertyAccess.cpp (153453 => 153454)
--- trunk/Source/_javascript_Core/jit/JITPropertyAccess.cpp 2013-07-30 01:10:16 UTC (rev 153453)
+++ trunk/Source/_javascript_Core/jit/JITPropertyAccess.cpp 2013-07-30 01:15:18 UTC (rev 153454)
@@ -856,7 +856,7 @@
bool needsStubLink = false;
// Checks out okay!
- if (slot.cachedPropertyType() == PropertySlot::Getter) {
+ if (slot.isCacheableGetter()) {
needsStubLink = true;
compileGetDirectOffset(protoObject, regT1, cachedOffset);
JITStubCall stubCall(this, cti_op_get_by_id_getter_stub);
@@ -864,7 +864,7 @@
stubCall.addArgument(regT0);
stubCall.addArgument(TrustedImmPtr(stubInfo->callReturnLocation.executableAddress()));
stubCall.call();
- } else if (slot.cachedPropertyType() == PropertySlot::Custom) {
+ } else if (slot.isCacheableCustom()) {
needsStubLink = true;
JITStubCall stubCall(this, cti_op_get_by_id_custom_stub);
stubCall.addArgument(TrustedImmPtr(protoObject));
@@ -917,7 +917,7 @@
Jump failureCase = checkStructure(regT0, structure);
bool needsStubLink = false;
bool isDirect = false;
- if (slot.cachedPropertyType() == PropertySlot::Getter) {
+ if (slot.isCacheableGetter()) {
needsStubLink = true;
compileGetDirectOffset(regT0, regT1, cachedOffset);
JITStubCall stubCall(this, cti_op_get_by_id_getter_stub);
@@ -925,7 +925,7 @@
stubCall.addArgument(regT0);
stubCall.addArgument(TrustedImmPtr(stubInfo->callReturnLocation.executableAddress()));
stubCall.call();
- } else if (slot.cachedPropertyType() == PropertySlot::Custom) {
+ } else if (slot.isCacheableCustom()) {
needsStubLink = true;
JITStubCall stubCall(this, cti_op_get_by_id_custom_stub);
stubCall.addArgument(regT0);
@@ -991,7 +991,7 @@
// Checks out okay!
bool needsStubLink = false;
bool isDirect = false;
- if (slot.cachedPropertyType() == PropertySlot::Getter) {
+ if (slot.isCacheableGetter()) {
needsStubLink = true;
compileGetDirectOffset(protoObject, regT1, cachedOffset);
JITStubCall stubCall(this, cti_op_get_by_id_getter_stub);
@@ -999,7 +999,7 @@
stubCall.addArgument(regT0);
stubCall.addArgument(TrustedImmPtr(stubInfo->callReturnLocation.executableAddress()));
stubCall.call();
- } else if (slot.cachedPropertyType() == PropertySlot::Custom) {
+ } else if (slot.isCacheableCustom()) {
needsStubLink = true;
JITStubCall stubCall(this, cti_op_get_by_id_custom_stub);
stubCall.addArgument(TrustedImmPtr(protoObject));
@@ -1070,7 +1070,7 @@
bool needsStubLink = false;
bool isDirect = false;
- if (slot.cachedPropertyType() == PropertySlot::Getter) {
+ if (slot.isCacheableGetter()) {
needsStubLink = true;
compileGetDirectOffset(protoObject, regT1, cachedOffset);
JITStubCall stubCall(this, cti_op_get_by_id_getter_stub);
@@ -1078,7 +1078,7 @@
stubCall.addArgument(regT0);
stubCall.addArgument(TrustedImmPtr(stubInfo->callReturnLocation.executableAddress()));
stubCall.call();
- } else if (slot.cachedPropertyType() == PropertySlot::Custom) {
+ } else if (slot.isCacheableCustom()) {
needsStubLink = true;
JITStubCall stubCall(this, cti_op_get_by_id_custom_stub);
stubCall.addArgument(TrustedImmPtr(protoObject));
@@ -1148,7 +1148,7 @@
ASSERT(protoObject);
bool needsStubLink = false;
- if (slot.cachedPropertyType() == PropertySlot::Getter) {
+ if (slot.isCacheableGetter()) {
needsStubLink = true;
compileGetDirectOffset(protoObject, regT1, cachedOffset);
JITStubCall stubCall(this, cti_op_get_by_id_getter_stub);
@@ -1156,7 +1156,7 @@
stubCall.addArgument(regT0);
stubCall.addArgument(TrustedImmPtr(stubInfo->callReturnLocation.executableAddress()));
stubCall.call();
- } else if (slot.cachedPropertyType() == PropertySlot::Custom) {
+ } else if (slot.isCacheableCustom()) {
needsStubLink = true;
JITStubCall stubCall(this, cti_op_get_by_id_custom_stub);
stubCall.addArgument(TrustedImmPtr(protoObject));
Modified: trunk/Source/_javascript_Core/jit/JITPropertyAccess32_64.cpp (153453 => 153454)
--- trunk/Source/_javascript_Core/jit/JITPropertyAccess32_64.cpp 2013-07-30 01:10:16 UTC (rev 153453)
+++ trunk/Source/_javascript_Core/jit/JITPropertyAccess32_64.cpp 2013-07-30 01:15:18 UTC (rev 153454)
@@ -818,7 +818,7 @@
bool needsStubLink = false;
// Checks out okay!
- if (slot.cachedPropertyType() == PropertySlot::Getter) {
+ if (slot.isCacheableGetter()) {
needsStubLink = true;
compileGetDirectOffset(protoObject, regT2, regT1, cachedOffset);
JITStubCall stubCall(this, cti_op_get_by_id_getter_stub);
@@ -826,7 +826,7 @@
stubCall.addArgument(regT0);
stubCall.addArgument(TrustedImmPtr(stubInfo->callReturnLocation.executableAddress()));
stubCall.call();
- } else if (slot.cachedPropertyType() == PropertySlot::Custom) {
+ } else if (slot.isCacheableCustom()) {
needsStubLink = true;
JITStubCall stubCall(this, cti_op_get_by_id_custom_stub);
stubCall.addArgument(TrustedImmPtr(protoObject));
@@ -884,7 +884,7 @@
Jump failureCase = checkStructure(regT0, structure);
bool needsStubLink = false;
bool isDirect = false;
- if (slot.cachedPropertyType() == PropertySlot::Getter) {
+ if (slot.isCacheableGetter()) {
needsStubLink = true;
compileGetDirectOffset(regT0, regT2, regT1, cachedOffset);
JITStubCall stubCall(this, cti_op_get_by_id_getter_stub);
@@ -892,7 +892,7 @@
stubCall.addArgument(regT0);
stubCall.addArgument(TrustedImmPtr(stubInfo->callReturnLocation.executableAddress()));
stubCall.call();
- } else if (slot.cachedPropertyType() == PropertySlot::Custom) {
+ } else if (slot.isCacheableCustom()) {
needsStubLink = true;
JITStubCall stubCall(this, cti_op_get_by_id_custom_stub);
stubCall.addArgument(regT0);
@@ -958,7 +958,7 @@
bool needsStubLink = false;
bool isDirect = false;
- if (slot.cachedPropertyType() == PropertySlot::Getter) {
+ if (slot.isCacheableGetter()) {
needsStubLink = true;
compileGetDirectOffset(protoObject, regT2, regT1, cachedOffset);
JITStubCall stubCall(this, cti_op_get_by_id_getter_stub);
@@ -966,7 +966,7 @@
stubCall.addArgument(regT0);
stubCall.addArgument(TrustedImmPtr(stubInfo->callReturnLocation.executableAddress()));
stubCall.call();
- } else if (slot.cachedPropertyType() == PropertySlot::Custom) {
+ } else if (slot.isCacheableCustom()) {
needsStubLink = true;
JITStubCall stubCall(this, cti_op_get_by_id_custom_stub);
stubCall.addArgument(TrustedImmPtr(protoObject));
@@ -1037,7 +1037,7 @@
bool needsStubLink = false;
bool isDirect = false;
- if (slot.cachedPropertyType() == PropertySlot::Getter) {
+ if (slot.isCacheableGetter()) {
needsStubLink = true;
compileGetDirectOffset(protoObject, regT2, regT1, cachedOffset);
JITStubCall stubCall(this, cti_op_get_by_id_getter_stub);
@@ -1045,7 +1045,7 @@
stubCall.addArgument(regT0);
stubCall.addArgument(TrustedImmPtr(stubInfo->callReturnLocation.executableAddress()));
stubCall.call();
- } else if (slot.cachedPropertyType() == PropertySlot::Custom) {
+ } else if (slot.isCacheableCustom()) {
needsStubLink = true;
JITStubCall stubCall(this, cti_op_get_by_id_custom_stub);
stubCall.addArgument(TrustedImmPtr(protoObject));
@@ -1115,7 +1115,7 @@
ASSERT(protoObject);
bool needsStubLink = false;
- if (slot.cachedPropertyType() == PropertySlot::Getter) {
+ if (slot.isCacheableGetter()) {
needsStubLink = true;
compileGetDirectOffset(protoObject, regT2, regT1, cachedOffset);
JITStubCall stubCall(this, cti_op_get_by_id_getter_stub);
@@ -1123,7 +1123,7 @@
stubCall.addArgument(regT0);
stubCall.addArgument(TrustedImmPtr(stubInfo->callReturnLocation.executableAddress()));
stubCall.call();
- } else if (slot.cachedPropertyType() == PropertySlot::Custom) {
+ } else if (slot.isCacheableCustom()) {
needsStubLink = true;
JITStubCall stubCall(this, cti_op_get_by_id_custom_stub);
stubCall.addArgument(TrustedImmPtr(protoObject));
Modified: trunk/Source/_javascript_Core/jit/JITStubs.cpp (153453 => 153454)
--- trunk/Source/_javascript_Core/jit/JITStubs.cpp 2013-07-30 01:10:16 UTC (rev 153453)
+++ trunk/Source/_javascript_Core/jit/JITStubs.cpp 2013-07-30 01:15:18 UTC (rev 153454)
@@ -220,8 +220,7 @@
if (slot.slotBase() == baseValue) {
RELEASE_ASSERT(stubInfo->accessType == access_unset);
- if ((slot.cachedPropertyType() != PropertySlot::Value)
- || !MacroAssembler::isCompactPtrAlignedAddressOffset(maxOffsetRelativeToPatchedStorage(slot.cachedOffset())))
+ if (!slot.isCacheableValue() || !MacroAssembler::isCompactPtrAlignedAddressOffset(maxOffsetRelativeToPatchedStorage(slot.cachedOffset())))
ctiPatchCallByReturnAddress(codeBlock, returnAddress, FunctionPtr(cti_op_get_by_id_self_fail));
else {
JIT::patchGetByIdSelf(codeBlock, stubInfo, structure, slot.cachedOffset(), returnAddress);
@@ -255,7 +254,7 @@
offset = slotBaseObject->structure()->get(callFrame->vm(), propertyName);
}
- stubInfo->initGetByIdProto(callFrame->vm(), codeBlock->ownerExecutable(), structure, slotBaseObject->structure(), slot.cachedPropertyType() == PropertySlot::Value);
+ stubInfo->initGetByIdProto(callFrame->vm(), codeBlock->ownerExecutable(), structure, slotBaseObject->structure(), slot.isCacheableValue());
ASSERT(!structure->isDictionary());
ASSERT(!slotBaseObject->structure()->isDictionary());
@@ -272,7 +271,7 @@
}
StructureChain* prototypeChain = structure->prototypeChain(callFrame);
- stubInfo->initGetByIdChain(callFrame->vm(), codeBlock->ownerExecutable(), structure, prototypeChain, count, slot.cachedPropertyType() == PropertySlot::Value);
+ stubInfo->initGetByIdChain(callFrame->vm(), codeBlock->ownerExecutable(), structure, prototypeChain, count, slot.isCacheableValue());
JIT::compileGetByIdChain(callFrame->scope()->vm(), callFrame, codeBlock, stubInfo, structure, prototypeChain, count, propertyName, slot, offset, returnAddress);
}
Modified: trunk/Source/_javascript_Core/llint/LLIntSlowPaths.cpp (153453 => 153454)
--- trunk/Source/_javascript_Core/llint/LLIntSlowPaths.cpp 2013-07-30 01:10:16 UTC (rev 153453)
+++ trunk/Source/_javascript_Core/llint/LLIntSlowPaths.cpp 2013-07-30 01:15:18 UTC (rev 153454)
@@ -515,7 +515,7 @@
&& baseValue.isCell()
&& slot.isCacheable()
&& slot.slotBase() == baseValue
- && slot.cachedPropertyType() == PropertySlot::Value) {
+ && slot.isCacheableValue()) {
JSCell* baseCell = baseValue.asCell();
Structure* structure = baseCell->structure();
Modified: trunk/Source/_javascript_Core/runtime/PropertySlot.cpp (153453 => 153454)
--- trunk/Source/_javascript_Core/runtime/PropertySlot.cpp 2013-07-30 01:10:16 UTC (rev 153453)
+++ trunk/Source/_javascript_Core/runtime/PropertySlot.cpp 2013-07-30 01:15:18 UTC (rev 153454)
@@ -28,7 +28,7 @@
JSValue PropertySlot::functionGetter(ExecState* exec) const
{
- return callGetter(exec, m_thisValue, m_data.getterSetter);
+ return callGetter(exec, JSValue::decode(m_data.getter.thisValue), m_data.getter.getterSetter);
}
} // namespace JSC
Modified: trunk/Source/_javascript_Core/runtime/PropertySlot.h (153453 => 153454)
--- trunk/Source/_javascript_Core/runtime/PropertySlot.h 2013-07-30 01:10:16 UTC (rev 153453)
+++ trunk/Source/_javascript_Core/runtime/PropertySlot.h 2013-07-30 01:15:18 UTC (rev 153454)
@@ -30,213 +30,202 @@
namespace JSC {
- class ExecState;
- class GetterSetter;
+class ExecState;
+class GetterSetter;
-#define JSC_VALUE_MARKER 0
-#define INDEX_GETTER_MARKER reinterpret_cast<GetValueFunc>(2)
-#define GETTER_FUNCTION_MARKER reinterpret_cast<GetValueFunc>(3)
+class PropertySlot {
+ enum PropertyType {
+ TypeUnset,
+ TypeValue,
+ TypeGetter,
+ TypeCustom,
+ TypeCustomIndex
+ };
- class PropertySlot {
- public:
- enum CachedPropertyType {
- Uncacheable,
- Getter,
- Custom,
- Value
- };
+public:
+ PropertySlot()
+ : m_propertyType(TypeUnset)
+ , m_offset(invalidOffset)
+ {
+ }
- PropertySlot()
- : m_cachedPropertyType(Uncacheable)
- {
- clearBase();
- clearOffset();
- clearValue();
- }
+ explicit PropertySlot(const JSValue base)
+ : m_slotBase(base)
+ , m_propertyType(TypeUnset)
+ , m_offset(invalidOffset)
+ {
+ }
- explicit PropertySlot(const JSValue base)
- : m_slotBase(base)
- , m_cachedPropertyType(Uncacheable)
- {
- clearOffset();
- clearValue();
- }
+ typedef JSValue (*GetValueFunc)(ExecState*, JSValue slotBase, PropertyName);
+ typedef JSValue (*GetIndexValueFunc)(ExecState*, JSValue slotBase, unsigned);
- typedef JSValue (*GetValueFunc)(ExecState*, JSValue slotBase, PropertyName);
- typedef JSValue (*GetIndexValueFunc)(ExecState*, JSValue slotBase, unsigned);
+ JSValue getValue(ExecState* exec, PropertyName propertyName) const
+ {
+ if (m_propertyType == TypeValue)
+ return JSValue::decode(m_data.value);
+ if (m_propertyType == TypeCustomIndex)
+ return m_data.customIndex.getIndexValue(exec, slotBase(), m_data.customIndex.index);
+ if (m_propertyType == TypeGetter)
+ return functionGetter(exec);
+ return m_data.custom.getValue(exec, slotBase(), propertyName);
+ }
- JSValue getValue(ExecState* exec, PropertyName propertyName) const
- {
- if (m_getValue == JSC_VALUE_MARKER)
- return m_value;
- if (m_getValue == INDEX_GETTER_MARKER)
- return m_getIndexValue(exec, slotBase(), index());
- if (m_getValue == GETTER_FUNCTION_MARKER)
- return functionGetter(exec);
- return m_getValue(exec, slotBase(), propertyName);
- }
+ JSValue getValue(ExecState* exec, unsigned propertyName) const
+ {
+ if (m_propertyType == TypeValue)
+ return JSValue::decode(m_data.value);
+ if (m_propertyType == TypeCustomIndex)
+ return m_data.customIndex.getIndexValue(exec, slotBase(), m_data.customIndex.index);
+ if (m_propertyType == TypeGetter)
+ return functionGetter(exec);
+ return m_data.custom.getValue(exec, slotBase(), Identifier::from(exec, propertyName));
+ }
- JSValue getValue(ExecState* exec, unsigned propertyName) const
- {
- if (m_getValue == JSC_VALUE_MARKER)
- return m_value;
- if (m_getValue == INDEX_GETTER_MARKER)
- return m_getIndexValue(exec, m_slotBase, m_data.index);
- if (m_getValue == GETTER_FUNCTION_MARKER)
- return functionGetter(exec);
- return m_getValue(exec, slotBase(), Identifier::from(exec, propertyName));
- }
+ bool isCacheable() const { return m_offset != invalidOffset; }
+ bool isCacheableValue() const { return isCacheable() && m_propertyType == TypeValue; }
+ bool isCacheableGetter() const { return isCacheable() && m_propertyType == TypeGetter; }
+ bool isCacheableCustom() const { return isCacheable() && m_propertyType == TypeCustom; }
- CachedPropertyType cachedPropertyType() const { return m_cachedPropertyType; }
- bool isCacheable() const { return m_cachedPropertyType != Uncacheable; }
- bool isCacheableValue() const { return m_cachedPropertyType == Value; }
- PropertyOffset cachedOffset() const
- {
- ASSERT(isCacheable());
- return m_offset;
- }
+ PropertyOffset cachedOffset() const
+ {
+ ASSERT(isCacheable());
+ return m_offset;
+ }
- void setValue(JSValue slotBase, JSValue value)
- {
- ASSERT(value);
- clearOffset();
- m_getValue = JSC_VALUE_MARKER;
- m_slotBase = slotBase;
- m_value = value;
- }
-
- void setValue(JSValue slotBase, JSValue value, PropertyOffset offset)
- {
- ASSERT(value);
- m_getValue = JSC_VALUE_MARKER;
- m_slotBase = slotBase;
- m_value = value;
- m_offset = offset;
- m_cachedPropertyType = Value;
- }
+ GetValueFunc customGetter() const
+ {
+ ASSERT(isCacheableCustom());
+ return m_data.custom.getValue;
+ }
- void setValue(JSValue value)
- {
- ASSERT(value);
- clearBase();
- clearOffset();
- m_getValue = JSC_VALUE_MARKER;
- m_value = value;
- }
+ void setValue(JSValue slotBase, JSValue value)
+ {
+ ASSERT(value);
+ m_data.value = JSValue::encode(value);
- void setCustom(JSValue slotBase, GetValueFunc getValue)
- {
- ASSERT(slotBase);
- ASSERT(getValue);
- m_getValue = getValue;
- m_getIndexValue = 0;
- m_slotBase = slotBase;
- }
-
- void setCacheableCustom(JSValue slotBase, GetValueFunc getValue)
- {
- ASSERT(slotBase);
- ASSERT(getValue);
- m_getValue = getValue;
- m_getIndexValue = 0;
- m_slotBase = slotBase;
- m_cachedPropertyType = Custom;
- }
+ ASSERT(slotBase);
+ m_slotBase = slotBase;
+ m_propertyType = TypeValue;
+ m_offset = invalidOffset;
+ }
+
+ void setValue(JSValue slotBase, JSValue value, PropertyOffset offset)
+ {
+ ASSERT(value);
+ m_data.value = JSValue::encode(value);
- void setCustomIndex(JSValue slotBase, unsigned index, GetIndexValueFunc getIndexValue)
- {
- ASSERT(slotBase);
- ASSERT(getIndexValue);
- m_getValue = INDEX_GETTER_MARKER;
- m_getIndexValue = getIndexValue;
- m_slotBase = slotBase;
- m_data.index = index;
- }
+ ASSERT(slotBase);
+ m_slotBase = slotBase;
+ m_propertyType = TypeValue;
+ m_offset = offset;
+ }
- void setGetterSlot(GetterSetter* getterSetter)
- {
- ASSERT(getterSetter);
- m_thisValue = m_slotBase;
- m_getValue = GETTER_FUNCTION_MARKER;
- m_data.getterSetter = getterSetter;
- }
+ void setValue(JSValue value)
+ {
+ ASSERT(value);
+ m_data.value = JSValue::encode(value);
- void setCacheableGetterSlot(JSValue slotBase, GetterSetter* getterSetter, PropertyOffset offset)
- {
- ASSERT(getterSetter);
- m_getValue = GETTER_FUNCTION_MARKER;
- m_thisValue = m_slotBase;
- m_slotBase = slotBase;
- m_data.getterSetter = getterSetter;
- m_offset = offset;
- m_cachedPropertyType = Getter;
- }
+ m_slotBase = JSValue();
+ m_propertyType = TypeValue;
+ m_offset = invalidOffset;
+ }
- void setUndefined()
- {
- setValue(jsUndefined());
- }
+ void setCustom(JSValue slotBase, GetValueFunc getValue)
+ {
+ ASSERT(getValue);
+ m_data.custom.getValue = getValue;
- JSValue slotBase() const
- {
- return m_slotBase;
- }
+ ASSERT(slotBase);
+ m_slotBase = slotBase;
+ m_propertyType = TypeCustom;
+ m_offset = invalidOffset;
+ }
+
+ void setCacheableCustom(JSValue slotBase, GetValueFunc getValue)
+ {
+ ASSERT(getValue);
+ m_data.custom.getValue = getValue;
- void setBase(JSValue base)
- {
- ASSERT(m_slotBase);
- ASSERT(base);
- m_slotBase = base;
- }
+ ASSERT(slotBase);
+ m_slotBase = slotBase;
+ m_propertyType = TypeCustom;
+ m_offset = !invalidOffset;
+ }
- void clearBase()
- {
-#ifndef NDEBUG
- m_slotBase = JSValue();
-#endif
- }
+ void setCustomIndex(JSValue slotBase, unsigned index, GetIndexValueFunc getIndexValue)
+ {
+ ASSERT(getIndexValue);
+ m_data.customIndex.getIndexValue = getIndexValue;
+ m_data.customIndex.index = index;
- void clearValue()
- {
-#ifndef NDEBUG
- m_value = JSValue();
-#endif
- }
+ ASSERT(slotBase);
+ m_slotBase = slotBase;
+ m_propertyType = TypeCustomIndex;
+ m_offset = invalidOffset;
+ }
- void clearOffset()
- {
- // Clear offset even in release builds, in case this PropertySlot has been used before.
- // (For other data members, we don't need to clear anything because reuse would meaningfully overwrite them.)
- m_offset = invalidOffset;
- m_cachedPropertyType = Uncacheable;
- }
+ void setGetterSlot(GetterSetter* getterSetter)
+ {
+ ASSERT(getterSetter);
+ m_data.getter.thisValue = JSValue::encode(m_slotBase);
+ m_data.getter.getterSetter = getterSetter;
- unsigned index() const { return m_data.index; }
+ m_propertyType = TypeGetter;
+ m_offset = invalidOffset;
+ }
- GetValueFunc customGetter() const
- {
- ASSERT(m_cachedPropertyType == Custom);
- return m_getValue;
- }
- private:
- JS_EXPORT_PRIVATE JSValue functionGetter(ExecState*) const;
+ void setCacheableGetterSlot(JSValue slotBase, GetterSetter* getterSetter, PropertyOffset offset)
+ {
+ ASSERT(getterSetter);
+ m_data.getter.thisValue = JSValue::encode(m_slotBase);
+ m_data.getter.getterSetter = getterSetter;
- GetValueFunc m_getValue;
- GetIndexValueFunc m_getIndexValue;
-
- JSValue m_slotBase;
- union {
+ ASSERT(slotBase);
+ m_slotBase = slotBase;
+ m_propertyType = TypeGetter;
+ m_offset = offset;
+ }
+
+ void setUndefined()
+ {
+ setValue(jsUndefined());
+ }
+
+ JSValue slotBase() const
+ {
+ return m_slotBase;
+ }
+
+ void setBase(JSValue base)
+ {
+ ASSERT(m_slotBase);
+ ASSERT(base);
+ m_slotBase = base;
+ }
+
+private:
+ JS_EXPORT_PRIVATE JSValue functionGetter(ExecState*) const;
+
+ union {
+ EncodedJSValue value;
+ struct {
+ EncodedJSValue thisValue;
GetterSetter* getterSetter;
+ } getter;
+ struct {
+ GetValueFunc getValue;
+ } custom;
+ struct {
+ GetIndexValueFunc getIndexValue;
unsigned index;
- } m_data;
+ } customIndex;
+ } m_data;
- JSValue m_value;
- JSValue m_thisValue;
+ JSValue m_slotBase;
+ PropertyType m_propertyType;
+ PropertyOffset m_offset;
+};
- PropertyOffset m_offset;
- CachedPropertyType m_cachedPropertyType;
- };
-
} // namespace JSC
#endif // PropertySlot_h