Changeset 153454 in webkit
- Timestamp:
- Jul 29, 2013 6:15:18 PM (11 years ago)
- Location:
- trunk/Source/JavaScriptCore
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/JavaScriptCore/ChangeLog
r153410 r153454 1 2013-07-29 Gavin Barraclough <barraclough@apple.com> 2 3 Some cleanup in PropertySlot 4 https://bugs.webkit.org/show_bug.cgi?id=119189 5 6 Reviewed by Geoff Garen. 7 8 PropertySlot represents a property in one of four states - value, getter, custom, or custom-index. 9 The state is currently tracked redundantly by two mechanisms - the custom getter function (m_getValue) 10 is set to a special value to indicate the type (other than custom), and the type is also tracked by 11 an enum - but only if cacheable. Cacheability can typically be determined by the value of m_offset 12 (this is invalidOffset if not cacheable). 13 14 * Internally, always track the type of the property using an enum value, PropertyType. 15 * Use m_offset to indicate cacheable. 16 * Keep the external interface (CachedPropertyType) unchanged. 17 * Better pack data into the m_data union. 18 19 Performance neutral. 20 21 * dfg/DFGRepatch.cpp: 22 (JSC::DFG::tryCacheGetByID): 23 (JSC::DFG::tryBuildGetByIDList): 24 - cachedPropertyType() -> isCacheable*() 25 * jit/JITPropertyAccess.cpp: 26 (JSC::JIT::privateCompileGetByIdProto): 27 (JSC::JIT::privateCompileGetByIdSelfList): 28 (JSC::JIT::privateCompileGetByIdProtoList): 29 (JSC::JIT::privateCompileGetByIdChainList): 30 (JSC::JIT::privateCompileGetByIdChain): 31 - cachedPropertyType() -> isCacheable*() 32 * jit/JITPropertyAccess32_64.cpp: 33 (JSC::JIT::privateCompileGetByIdProto): 34 (JSC::JIT::privateCompileGetByIdSelfList): 35 (JSC::JIT::privateCompileGetByIdProtoList): 36 (JSC::JIT::privateCompileGetByIdChainList): 37 (JSC::JIT::privateCompileGetByIdChain): 38 - cachedPropertyType() -> isCacheable*() 39 * jit/JITStubs.cpp: 40 (JSC::tryCacheGetByID): 41 - cachedPropertyType() -> isCacheable*() 42 * llint/LLIntSlowPaths.cpp: 43 (JSC::LLInt::LLINT_SLOW_PATH_DECL): 44 - cachedPropertyType() -> isCacheable*() 45 * runtime/PropertySlot.cpp: 46 (JSC::PropertySlot::functionGetter): 47 - refactoring described above. 48 * runtime/PropertySlot.h: 49 (JSC::PropertySlot::PropertySlot): 50 (JSC::PropertySlot::getValue): 51 (JSC::PropertySlot::isCacheable): 52 (JSC::PropertySlot::isCacheableValue): 53 (JSC::PropertySlot::isCacheableGetter): 54 (JSC::PropertySlot::isCacheableCustom): 55 (JSC::PropertySlot::cachedOffset): 56 (JSC::PropertySlot::customGetter): 57 (JSC::PropertySlot::setValue): 58 (JSC::PropertySlot::setCustom): 59 (JSC::PropertySlot::setCacheableCustom): 60 (JSC::PropertySlot::setCustomIndex): 61 (JSC::PropertySlot::setGetterSlot): 62 (JSC::PropertySlot::setCacheableGetterSlot): 63 (JSC::PropertySlot::setUndefined): 64 (JSC::PropertySlot::slotBase): 65 (JSC::PropertySlot::setBase): 66 - refactoring described above. 67 1 68 2013-07-28 Oliver Hunt <oliver@apple.com> 2 69 -
trunk/Source/JavaScriptCore/dfg/DFGRepatch.cpp
r153381 r153454 325 325 // Optimize self access. 326 326 if (slot.slotBase() == baseValue) { 327 if ( (slot.cachedPropertyType() != PropertySlot::Value)327 if (!slot.isCacheableValue() 328 328 || !MacroAssembler::isCompactPtrAlignedAddressOffset(maxOffsetRelativeToPatchedStorage(slot.cachedOffset()))) { 329 329 dfgRepatchCall(codeBlock, stubInfo.callReturnLocation, operationGetByIdBuildList); … … 340 340 341 341 // FIXME: optimize getters and setters 342 if ( slot.cachedPropertyType() != PropertySlot::Value)342 if (!slot.isCacheableValue()) 343 343 return false; 344 344 … … 439 439 // non-Value cached properties require planting calls, which requires registers to have been flushed. Thus, 440 440 // if registers were not flushed, don't do non-Value caching. 441 if ( slot.cachedPropertyType() != PropertySlot::Value)441 if (!slot.isCacheableValue()) 442 442 return false; 443 443 } … … 476 476 MacroAssembler::Jump success; 477 477 478 if (slot.cachedPropertyType() == PropertySlot::Getter 479 || slot.cachedPropertyType() == PropertySlot::Custom) { 480 if (slot.cachedPropertyType() == PropertySlot::Getter) { 478 if (slot.isCacheableGetter() || slot.isCacheableCustom()) { 479 if (slot.isCacheableGetter()) { 481 480 ASSERT(scratchGPR != InvalidGPRReg); 482 481 ASSERT(baseGPR != scratchGPR); … … 568 567 *vm, 569 568 codeBlock->ownerExecutable(), 570 slot.cachedPropertyType() == PropertySlot::Getter 571 || slot.cachedPropertyType() == PropertySlot::Custom); 569 slot.isCacheableGetter() || slot.isCacheableCustom()); 572 570 573 571 polymorphicStructureList->list[listIndex].set(*vm, codeBlock->ownerExecutable(), stubRoutine, structure, isDirect); … … 577 575 } 578 576 579 if (baseValue.asCell()->structure()->typeInfo().prohibitsPropertyCaching() 580 || slot.cachedPropertyType() != PropertySlot::Value) 577 if (baseValue.asCell()->structure()->typeInfo().prohibitsPropertyCaching() || !slot.isCacheableValue()) 581 578 return false; 582 579 -
trunk/Source/JavaScriptCore/jit/JITPropertyAccess.cpp
r153231 r153454 857 857 858 858 // Checks out okay! 859 if (slot. cachedPropertyType() == PropertySlot::Getter) {859 if (slot.isCacheableGetter()) { 860 860 needsStubLink = true; 861 861 compileGetDirectOffset(protoObject, regT1, cachedOffset); … … 865 865 stubCall.addArgument(TrustedImmPtr(stubInfo->callReturnLocation.executableAddress())); 866 866 stubCall.call(); 867 } else if (slot. cachedPropertyType() == PropertySlot::Custom) {867 } else if (slot.isCacheableCustom()) { 868 868 needsStubLink = true; 869 869 JITStubCall stubCall(this, cti_op_get_by_id_custom_stub); … … 918 918 bool needsStubLink = false; 919 919 bool isDirect = false; 920 if (slot. cachedPropertyType() == PropertySlot::Getter) {920 if (slot.isCacheableGetter()) { 921 921 needsStubLink = true; 922 922 compileGetDirectOffset(regT0, regT1, cachedOffset); … … 926 926 stubCall.addArgument(TrustedImmPtr(stubInfo->callReturnLocation.executableAddress())); 927 927 stubCall.call(); 928 } else if (slot. cachedPropertyType() == PropertySlot::Custom) {928 } else if (slot.isCacheableCustom()) { 929 929 needsStubLink = true; 930 930 JITStubCall stubCall(this, cti_op_get_by_id_custom_stub); … … 992 992 bool needsStubLink = false; 993 993 bool isDirect = false; 994 if (slot. cachedPropertyType() == PropertySlot::Getter) {994 if (slot.isCacheableGetter()) { 995 995 needsStubLink = true; 996 996 compileGetDirectOffset(protoObject, regT1, cachedOffset); … … 1000 1000 stubCall.addArgument(TrustedImmPtr(stubInfo->callReturnLocation.executableAddress())); 1001 1001 stubCall.call(); 1002 } else if (slot. cachedPropertyType() == PropertySlot::Custom) {1002 } else if (slot.isCacheableCustom()) { 1003 1003 needsStubLink = true; 1004 1004 JITStubCall stubCall(this, cti_op_get_by_id_custom_stub); … … 1071 1071 bool needsStubLink = false; 1072 1072 bool isDirect = false; 1073 if (slot. cachedPropertyType() == PropertySlot::Getter) {1073 if (slot.isCacheableGetter()) { 1074 1074 needsStubLink = true; 1075 1075 compileGetDirectOffset(protoObject, regT1, cachedOffset); … … 1079 1079 stubCall.addArgument(TrustedImmPtr(stubInfo->callReturnLocation.executableAddress())); 1080 1080 stubCall.call(); 1081 } else if (slot. cachedPropertyType() == PropertySlot::Custom) {1081 } else if (slot.isCacheableCustom()) { 1082 1082 needsStubLink = true; 1083 1083 JITStubCall stubCall(this, cti_op_get_by_id_custom_stub); … … 1149 1149 1150 1150 bool needsStubLink = false; 1151 if (slot. cachedPropertyType() == PropertySlot::Getter) {1151 if (slot.isCacheableGetter()) { 1152 1152 needsStubLink = true; 1153 1153 compileGetDirectOffset(protoObject, regT1, cachedOffset); … … 1157 1157 stubCall.addArgument(TrustedImmPtr(stubInfo->callReturnLocation.executableAddress())); 1158 1158 stubCall.call(); 1159 } else if (slot. cachedPropertyType() == PropertySlot::Custom) {1159 } else if (slot.isCacheableCustom()) { 1160 1160 needsStubLink = true; 1161 1161 JITStubCall stubCall(this, cti_op_get_by_id_custom_stub); -
trunk/Source/JavaScriptCore/jit/JITPropertyAccess32_64.cpp
r153231 r153454 819 819 bool needsStubLink = false; 820 820 // Checks out okay! 821 if (slot. cachedPropertyType() == PropertySlot::Getter) {821 if (slot.isCacheableGetter()) { 822 822 needsStubLink = true; 823 823 compileGetDirectOffset(protoObject, regT2, regT1, cachedOffset); … … 827 827 stubCall.addArgument(TrustedImmPtr(stubInfo->callReturnLocation.executableAddress())); 828 828 stubCall.call(); 829 } else if (slot. cachedPropertyType() == PropertySlot::Custom) {829 } else if (slot.isCacheableCustom()) { 830 830 needsStubLink = true; 831 831 JITStubCall stubCall(this, cti_op_get_by_id_custom_stub); … … 885 885 bool needsStubLink = false; 886 886 bool isDirect = false; 887 if (slot. cachedPropertyType() == PropertySlot::Getter) {887 if (slot.isCacheableGetter()) { 888 888 needsStubLink = true; 889 889 compileGetDirectOffset(regT0, regT2, regT1, cachedOffset); … … 893 893 stubCall.addArgument(TrustedImmPtr(stubInfo->callReturnLocation.executableAddress())); 894 894 stubCall.call(); 895 } else if (slot. cachedPropertyType() == PropertySlot::Custom) {895 } else if (slot.isCacheableCustom()) { 896 896 needsStubLink = true; 897 897 JITStubCall stubCall(this, cti_op_get_by_id_custom_stub); … … 959 959 bool needsStubLink = false; 960 960 bool isDirect = false; 961 if (slot. cachedPropertyType() == PropertySlot::Getter) {961 if (slot.isCacheableGetter()) { 962 962 needsStubLink = true; 963 963 compileGetDirectOffset(protoObject, regT2, regT1, cachedOffset); … … 967 967 stubCall.addArgument(TrustedImmPtr(stubInfo->callReturnLocation.executableAddress())); 968 968 stubCall.call(); 969 } else if (slot. cachedPropertyType() == PropertySlot::Custom) {969 } else if (slot.isCacheableCustom()) { 970 970 needsStubLink = true; 971 971 JITStubCall stubCall(this, cti_op_get_by_id_custom_stub); … … 1038 1038 bool needsStubLink = false; 1039 1039 bool isDirect = false; 1040 if (slot. cachedPropertyType() == PropertySlot::Getter) {1040 if (slot.isCacheableGetter()) { 1041 1041 needsStubLink = true; 1042 1042 compileGetDirectOffset(protoObject, regT2, regT1, cachedOffset); … … 1046 1046 stubCall.addArgument(TrustedImmPtr(stubInfo->callReturnLocation.executableAddress())); 1047 1047 stubCall.call(); 1048 } else if (slot. cachedPropertyType() == PropertySlot::Custom) {1048 } else if (slot.isCacheableCustom()) { 1049 1049 needsStubLink = true; 1050 1050 JITStubCall stubCall(this, cti_op_get_by_id_custom_stub); … … 1116 1116 1117 1117 bool needsStubLink = false; 1118 if (slot. cachedPropertyType() == PropertySlot::Getter) {1118 if (slot.isCacheableGetter()) { 1119 1119 needsStubLink = true; 1120 1120 compileGetDirectOffset(protoObject, regT2, regT1, cachedOffset); … … 1124 1124 stubCall.addArgument(TrustedImmPtr(stubInfo->callReturnLocation.executableAddress())); 1125 1125 stubCall.call(); 1126 } else if (slot. cachedPropertyType() == PropertySlot::Custom) {1126 } else if (slot.isCacheableCustom()) { 1127 1127 needsStubLink = true; 1128 1128 JITStubCall stubCall(this, cti_op_get_by_id_custom_stub); -
trunk/Source/JavaScriptCore/jit/JITStubs.cpp
r153237 r153454 221 221 if (slot.slotBase() == baseValue) { 222 222 RELEASE_ASSERT(stubInfo->accessType == access_unset); 223 if ((slot.cachedPropertyType() != PropertySlot::Value) 224 || !MacroAssembler::isCompactPtrAlignedAddressOffset(maxOffsetRelativeToPatchedStorage(slot.cachedOffset()))) 223 if (!slot.isCacheableValue() || !MacroAssembler::isCompactPtrAlignedAddressOffset(maxOffsetRelativeToPatchedStorage(slot.cachedOffset()))) 225 224 ctiPatchCallByReturnAddress(codeBlock, returnAddress, FunctionPtr(cti_op_get_by_id_self_fail)); 226 225 else { … … 256 255 } 257 256 258 stubInfo->initGetByIdProto(callFrame->vm(), codeBlock->ownerExecutable(), structure, slotBaseObject->structure(), slot. cachedPropertyType() == PropertySlot::Value);257 stubInfo->initGetByIdProto(callFrame->vm(), codeBlock->ownerExecutable(), structure, slotBaseObject->structure(), slot.isCacheableValue()); 259 258 260 259 ASSERT(!structure->isDictionary()); … … 273 272 274 273 StructureChain* prototypeChain = structure->prototypeChain(callFrame); 275 stubInfo->initGetByIdChain(callFrame->vm(), codeBlock->ownerExecutable(), structure, prototypeChain, count, slot. cachedPropertyType() == PropertySlot::Value);274 stubInfo->initGetByIdChain(callFrame->vm(), codeBlock->ownerExecutable(), structure, prototypeChain, count, slot.isCacheableValue()); 276 275 JIT::compileGetByIdChain(callFrame->scope()->vm(), callFrame, codeBlock, stubInfo, structure, prototypeChain, count, propertyName, slot, offset, returnAddress); 277 276 } -
trunk/Source/JavaScriptCore/llint/LLIntSlowPaths.cpp
r153360 r153454 516 516 && slot.isCacheable() 517 517 && slot.slotBase() == baseValue 518 && slot. cachedPropertyType() == PropertySlot::Value) {518 && slot.isCacheableValue()) { 519 519 520 520 JSCell* baseCell = baseValue.asCell(); -
trunk/Source/JavaScriptCore/runtime/PropertySlot.cpp
r153145 r153454 29 29 JSValue PropertySlot::functionGetter(ExecState* exec) const 30 30 { 31 return callGetter(exec, m_thisValue, m_data.getterSetter);31 return callGetter(exec, JSValue::decode(m_data.getter.thisValue), m_data.getter.getterSetter); 32 32 } 33 33 -
trunk/Source/JavaScriptCore/runtime/PropertySlot.h
r153145 r153454 31 31 namespace JSC { 32 32 33 class ExecState; 34 class GetterSetter; 35 36 #define JSC_VALUE_MARKER 0 37 #define INDEX_GETTER_MARKER reinterpret_cast<GetValueFunc>(2) 38 #define GETTER_FUNCTION_MARKER reinterpret_cast<GetValueFunc>(3) 39 40 class PropertySlot { 41 public: 42 enum CachedPropertyType { 43 Uncacheable, 44 Getter, 45 Custom, 46 Value 47 }; 48 49 PropertySlot() 50 : m_cachedPropertyType(Uncacheable) 51 { 52 clearBase(); 53 clearOffset(); 54 clearValue(); 55 } 56 57 explicit PropertySlot(const JSValue base) 58 : m_slotBase(base) 59 , m_cachedPropertyType(Uncacheable) 60 { 61 clearOffset(); 62 clearValue(); 63 } 64 65 typedef JSValue (*GetValueFunc)(ExecState*, JSValue slotBase, PropertyName); 66 typedef JSValue (*GetIndexValueFunc)(ExecState*, JSValue slotBase, unsigned); 67 68 JSValue getValue(ExecState* exec, PropertyName propertyName) const 69 { 70 if (m_getValue == JSC_VALUE_MARKER) 71 return m_value; 72 if (m_getValue == INDEX_GETTER_MARKER) 73 return m_getIndexValue(exec, slotBase(), index()); 74 if (m_getValue == GETTER_FUNCTION_MARKER) 75 return functionGetter(exec); 76 return m_getValue(exec, slotBase(), propertyName); 77 } 78 79 JSValue getValue(ExecState* exec, unsigned propertyName) const 80 { 81 if (m_getValue == JSC_VALUE_MARKER) 82 return m_value; 83 if (m_getValue == INDEX_GETTER_MARKER) 84 return m_getIndexValue(exec, m_slotBase, m_data.index); 85 if (m_getValue == GETTER_FUNCTION_MARKER) 86 return functionGetter(exec); 87 return m_getValue(exec, slotBase(), Identifier::from(exec, propertyName)); 88 } 89 90 CachedPropertyType cachedPropertyType() const { return m_cachedPropertyType; } 91 bool isCacheable() const { return m_cachedPropertyType != Uncacheable; } 92 bool isCacheableValue() const { return m_cachedPropertyType == Value; } 93 PropertyOffset cachedOffset() const 94 { 95 ASSERT(isCacheable()); 96 return m_offset; 97 } 98 99 void setValue(JSValue slotBase, JSValue value) 100 { 101 ASSERT(value); 102 clearOffset(); 103 m_getValue = JSC_VALUE_MARKER; 104 m_slotBase = slotBase; 105 m_value = value; 106 } 107 108 void setValue(JSValue slotBase, JSValue value, PropertyOffset offset) 109 { 110 ASSERT(value); 111 m_getValue = JSC_VALUE_MARKER; 112 m_slotBase = slotBase; 113 m_value = value; 114 m_offset = offset; 115 m_cachedPropertyType = Value; 116 } 117 118 void setValue(JSValue value) 119 { 120 ASSERT(value); 121 clearBase(); 122 clearOffset(); 123 m_getValue = JSC_VALUE_MARKER; 124 m_value = value; 125 } 126 127 void setCustom(JSValue slotBase, GetValueFunc getValue) 128 { 129 ASSERT(slotBase); 130 ASSERT(getValue); 131 m_getValue = getValue; 132 m_getIndexValue = 0; 133 m_slotBase = slotBase; 134 } 135 136 void setCacheableCustom(JSValue slotBase, GetValueFunc getValue) 137 { 138 ASSERT(slotBase); 139 ASSERT(getValue); 140 m_getValue = getValue; 141 m_getIndexValue = 0; 142 m_slotBase = slotBase; 143 m_cachedPropertyType = Custom; 144 } 145 146 void setCustomIndex(JSValue slotBase, unsigned index, GetIndexValueFunc getIndexValue) 147 { 148 ASSERT(slotBase); 149 ASSERT(getIndexValue); 150 m_getValue = INDEX_GETTER_MARKER; 151 m_getIndexValue = getIndexValue; 152 m_slotBase = slotBase; 153 m_data.index = index; 154 } 155 156 void setGetterSlot(GetterSetter* getterSetter) 157 { 158 ASSERT(getterSetter); 159 m_thisValue = m_slotBase; 160 m_getValue = GETTER_FUNCTION_MARKER; 161 m_data.getterSetter = getterSetter; 162 } 163 164 void setCacheableGetterSlot(JSValue slotBase, GetterSetter* getterSetter, PropertyOffset offset) 165 { 166 ASSERT(getterSetter); 167 m_getValue = GETTER_FUNCTION_MARKER; 168 m_thisValue = m_slotBase; 169 m_slotBase = slotBase; 170 m_data.getterSetter = getterSetter; 171 m_offset = offset; 172 m_cachedPropertyType = Getter; 173 } 174 175 void setUndefined() 176 { 177 setValue(jsUndefined()); 178 } 179 180 JSValue slotBase() const 181 { 182 return m_slotBase; 183 } 184 185 void setBase(JSValue base) 186 { 187 ASSERT(m_slotBase); 188 ASSERT(base); 189 m_slotBase = base; 190 } 191 192 void clearBase() 193 { 194 #ifndef NDEBUG 195 m_slotBase = JSValue(); 196 #endif 197 } 198 199 void clearValue() 200 { 201 #ifndef NDEBUG 202 m_value = JSValue(); 203 #endif 204 } 205 206 void clearOffset() 207 { 208 // Clear offset even in release builds, in case this PropertySlot has been used before. 209 // (For other data members, we don't need to clear anything because reuse would meaningfully overwrite them.) 210 m_offset = invalidOffset; 211 m_cachedPropertyType = Uncacheable; 212 } 213 214 unsigned index() const { return m_data.index; } 215 216 GetValueFunc customGetter() const 217 { 218 ASSERT(m_cachedPropertyType == Custom); 219 return m_getValue; 220 } 221 private: 222 JS_EXPORT_PRIVATE JSValue functionGetter(ExecState*) const; 223 224 GetValueFunc m_getValue; 225 GetIndexValueFunc m_getIndexValue; 226 227 JSValue m_slotBase; 228 union { 33 class ExecState; 34 class GetterSetter; 35 36 class PropertySlot { 37 enum PropertyType { 38 TypeUnset, 39 TypeValue, 40 TypeGetter, 41 TypeCustom, 42 TypeCustomIndex 43 }; 44 45 public: 46 PropertySlot() 47 : m_propertyType(TypeUnset) 48 , m_offset(invalidOffset) 49 { 50 } 51 52 explicit PropertySlot(const JSValue base) 53 : m_slotBase(base) 54 , m_propertyType(TypeUnset) 55 , m_offset(invalidOffset) 56 { 57 } 58 59 typedef JSValue (*GetValueFunc)(ExecState*, JSValue slotBase, PropertyName); 60 typedef JSValue (*GetIndexValueFunc)(ExecState*, JSValue slotBase, unsigned); 61 62 JSValue getValue(ExecState* exec, PropertyName propertyName) const 63 { 64 if (m_propertyType == TypeValue) 65 return JSValue::decode(m_data.value); 66 if (m_propertyType == TypeCustomIndex) 67 return m_data.customIndex.getIndexValue(exec, slotBase(), m_data.customIndex.index); 68 if (m_propertyType == TypeGetter) 69 return functionGetter(exec); 70 return m_data.custom.getValue(exec, slotBase(), propertyName); 71 } 72 73 JSValue getValue(ExecState* exec, unsigned propertyName) const 74 { 75 if (m_propertyType == TypeValue) 76 return JSValue::decode(m_data.value); 77 if (m_propertyType == TypeCustomIndex) 78 return m_data.customIndex.getIndexValue(exec, slotBase(), m_data.customIndex.index); 79 if (m_propertyType == TypeGetter) 80 return functionGetter(exec); 81 return m_data.custom.getValue(exec, slotBase(), Identifier::from(exec, propertyName)); 82 } 83 84 bool isCacheable() const { return m_offset != invalidOffset; } 85 bool isCacheableValue() const { return isCacheable() && m_propertyType == TypeValue; } 86 bool isCacheableGetter() const { return isCacheable() && m_propertyType == TypeGetter; } 87 bool isCacheableCustom() const { return isCacheable() && m_propertyType == TypeCustom; } 88 89 PropertyOffset cachedOffset() const 90 { 91 ASSERT(isCacheable()); 92 return m_offset; 93 } 94 95 GetValueFunc customGetter() const 96 { 97 ASSERT(isCacheableCustom()); 98 return m_data.custom.getValue; 99 } 100 101 void setValue(JSValue slotBase, JSValue value) 102 { 103 ASSERT(value); 104 m_data.value = JSValue::encode(value); 105 106 ASSERT(slotBase); 107 m_slotBase = slotBase; 108 m_propertyType = TypeValue; 109 m_offset = invalidOffset; 110 } 111 112 void setValue(JSValue slotBase, JSValue value, PropertyOffset offset) 113 { 114 ASSERT(value); 115 m_data.value = JSValue::encode(value); 116 117 ASSERT(slotBase); 118 m_slotBase = slotBase; 119 m_propertyType = TypeValue; 120 m_offset = offset; 121 } 122 123 void setValue(JSValue value) 124 { 125 ASSERT(value); 126 m_data.value = JSValue::encode(value); 127 128 m_slotBase = JSValue(); 129 m_propertyType = TypeValue; 130 m_offset = invalidOffset; 131 } 132 133 void setCustom(JSValue slotBase, GetValueFunc getValue) 134 { 135 ASSERT(getValue); 136 m_data.custom.getValue = getValue; 137 138 ASSERT(slotBase); 139 m_slotBase = slotBase; 140 m_propertyType = TypeCustom; 141 m_offset = invalidOffset; 142 } 143 144 void setCacheableCustom(JSValue slotBase, GetValueFunc getValue) 145 { 146 ASSERT(getValue); 147 m_data.custom.getValue = getValue; 148 149 ASSERT(slotBase); 150 m_slotBase = slotBase; 151 m_propertyType = TypeCustom; 152 m_offset = !invalidOffset; 153 } 154 155 void setCustomIndex(JSValue slotBase, unsigned index, GetIndexValueFunc getIndexValue) 156 { 157 ASSERT(getIndexValue); 158 m_data.customIndex.getIndexValue = getIndexValue; 159 m_data.customIndex.index = index; 160 161 ASSERT(slotBase); 162 m_slotBase = slotBase; 163 m_propertyType = TypeCustomIndex; 164 m_offset = invalidOffset; 165 } 166 167 void setGetterSlot(GetterSetter* getterSetter) 168 { 169 ASSERT(getterSetter); 170 m_data.getter.thisValue = JSValue::encode(m_slotBase); 171 m_data.getter.getterSetter = getterSetter; 172 173 m_propertyType = TypeGetter; 174 m_offset = invalidOffset; 175 } 176 177 void setCacheableGetterSlot(JSValue slotBase, GetterSetter* getterSetter, PropertyOffset offset) 178 { 179 ASSERT(getterSetter); 180 m_data.getter.thisValue = JSValue::encode(m_slotBase); 181 m_data.getter.getterSetter = getterSetter; 182 183 ASSERT(slotBase); 184 m_slotBase = slotBase; 185 m_propertyType = TypeGetter; 186 m_offset = offset; 187 } 188 189 void setUndefined() 190 { 191 setValue(jsUndefined()); 192 } 193 194 JSValue slotBase() const 195 { 196 return m_slotBase; 197 } 198 199 void setBase(JSValue base) 200 { 201 ASSERT(m_slotBase); 202 ASSERT(base); 203 m_slotBase = base; 204 } 205 206 private: 207 JS_EXPORT_PRIVATE JSValue functionGetter(ExecState*) const; 208 209 union { 210 EncodedJSValue value; 211 struct { 212 EncodedJSValue thisValue; 229 213 GetterSetter* getterSetter; 214 } getter; 215 struct { 216 GetValueFunc getValue; 217 } custom; 218 struct { 219 GetIndexValueFunc getIndexValue; 230 220 unsigned index; 231 } m_data; 232 233 JSValue m_value; 234 JSValue m_thisValue; 235 236 PropertyOffset m_offset; 237 CachedPropertyType m_cachedPropertyType; 238 }; 221 } customIndex; 222 } m_data; 223 224 JSValue m_slotBase; 225 PropertyType m_propertyType; 226 PropertyOffset m_offset; 227 }; 239 228 240 229 } // namespace JSC
Note: See TracChangeset
for help on using the changeset viewer.