Changeset 128802 in webkit for trunk/Source/JavaScriptCore/runtime/SparseArrayValueMap.cpp
- Timestamp:
- Sep 17, 2012, 1:56:39 PM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/JavaScriptCore/runtime/SparseArrayValueMap.cpp
r128680 r128802 100 100 return; 101 101 } 102 103 if (!(entry.attributes & Accessor)) { 104 if (entry.attributes & ReadOnly) { 102 103 entry.put(exec, array, this, value, shouldThrow); 104 } 105 106 bool SparseArrayValueMap::putDirect(ExecState* exec, JSObject* array, unsigned i, JSValue value, unsigned attributes, PutDirectIndexMode mode) 107 { 108 AddResult result = add(array, i); 109 SparseArrayEntry& entry = result.iterator->second; 110 111 // To save a separate find & add, we first always add to the sparse map. 112 // In the uncommon case that this is a new property, and the array is not 113 // extensible, this is not the right thing to have done - so remove again. 114 if (mode != PutDirectIndexLikePutDirect && result.isNewEntry && !array->isExtensible()) { 115 remove(result.iterator); 116 return reject(exec, mode == PutDirectIndexShouldThrow, "Attempting to define property on object that is not extensible."); 117 } 118 119 entry.attributes = attributes; 120 entry.set(exec->globalData(), this, value); 121 return true; 122 } 123 124 void SparseArrayEntry::get(PropertySlot& slot) const 125 { 126 JSValue value = Base::get(); 127 ASSERT(value); 128 129 if (LIKELY(!value.isGetterSetter())) { 130 slot.setValue(value); 131 return; 132 } 133 134 JSObject* getter = asGetterSetter(value)->getter(); 135 if (!getter) { 136 slot.setUndefined(); 137 return; 138 } 139 140 slot.setGetterSlot(getter); 141 } 142 143 void SparseArrayEntry::get(PropertyDescriptor& descriptor) const 144 { 145 descriptor.setDescriptor(Base::get(), attributes); 146 } 147 148 JSValue SparseArrayEntry::get(ExecState* exec, JSObject* array) const 149 { 150 JSValue result = Base::get(); 151 ASSERT(result); 152 153 if (LIKELY(!result.isGetterSetter())) 154 return result; 155 156 JSObject* getter = asGetterSetter(result)->getter(); 157 if (!getter) 158 return jsUndefined(); 159 160 CallData callData; 161 CallType callType = getter->methodTable()->getCallData(getter, callData); 162 return call(exec, getter, callType, callData, array, exec->emptyList()); 163 } 164 165 void SparseArrayEntry::put(ExecState* exec, JSValue thisValue, SparseArrayValueMap* map, JSValue value, bool shouldThrow) 166 { 167 if (!(attributes & Accessor)) { 168 if (attributes & ReadOnly) { 105 169 if (shouldThrow) 106 170 throwTypeError(exec, StrictModeReadonlyPropertyWriteError); … … 108 172 } 109 173 110 entry.set(exec->globalData(), this, value);111 return; 112 } 113 114 JSValue accessor = entry.SparseArrayEntry::Base::get();174 set(exec->globalData(), map, value); 175 return; 176 } 177 178 JSValue accessor = Base::get(); 115 179 ASSERT(accessor.isGetterSetter()); 116 180 JSObject* setter = asGetterSetter(accessor)->setter(); … … 126 190 MarkedArgumentBuffer args; 127 191 args.append(value); 128 call(exec, setter, callType, callData, array, args); 129 } 130 131 bool SparseArrayValueMap::putDirect(ExecState* exec, JSObject* array, unsigned i, JSValue value, unsigned attributes, PutDirectIndexMode mode) 132 { 133 AddResult result = add(array, i); 134 SparseArrayEntry& entry = result.iterator->second; 135 136 // To save a separate find & add, we first always add to the sparse map. 137 // In the uncommon case that this is a new property, and the array is not 138 // extensible, this is not the right thing to have done - so remove again. 139 if (mode != PutDirectIndexLikePutDirect && result.isNewEntry && !array->isExtensible()) { 140 remove(result.iterator); 141 return reject(exec, mode == PutDirectIndexShouldThrow, "Attempting to define property on object that is not extensible."); 142 } 143 144 entry.attributes = attributes; 145 entry.set(exec->globalData(), this, value); 146 return true; 147 } 148 149 void SparseArrayEntry::get(PropertySlot& slot) const 150 { 151 JSValue value = Base::get(); 152 ASSERT(value); 153 154 if (LIKELY(!value.isGetterSetter())) { 155 slot.setValue(value); 156 return; 157 } 158 159 JSObject* getter = asGetterSetter(value)->getter(); 160 if (!getter) { 161 slot.setUndefined(); 162 return; 163 } 164 165 slot.setGetterSlot(getter); 166 } 167 168 void SparseArrayEntry::get(PropertyDescriptor& descriptor) const 169 { 170 descriptor.setDescriptor(Base::get(), attributes); 171 } 172 173 JSValue SparseArrayEntry::get(ExecState* exec, JSObject* array) const 174 { 175 JSValue result = Base::get(); 176 ASSERT(result); 177 178 if (LIKELY(!result.isGetterSetter())) 179 return result; 180 181 JSObject* getter = asGetterSetter(result)->getter(); 182 if (!getter) 183 return jsUndefined(); 184 185 CallData callData; 186 CallType callType = getter->methodTable()->getCallData(getter, callData); 187 return call(exec, getter, callType, callData, array, exec->emptyList()); 192 call(exec, setter, callType, callData, thisValue, args); 188 193 } 189 194
Note:
See TracChangeset
for help on using the changeset viewer.