Changeset 36977 in webkit for trunk/JavaScriptCore
- Timestamp:
- Sep 26, 2008, 7:36:15 PM (17 years ago)
- Location:
- trunk/JavaScriptCore
- Files:
-
- 14 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/JavaScriptCore/ChangeLog
r36976 r36977 1 2008-09-26 Sam Weinig <[email protected]> 2 3 Reviewed by Darin Adler. 4 5 Patch for https://bugs.webkit.org/show_bug.cgi?id=21152 6 Speedup static property get/put 7 8 Convert getting/setting static property values to use static functions 9 instead of storing an integer and switching in getValueProperty/putValueProperty. 10 11 * kjs/JSObject.cpp: 12 (JSC::JSObject::deleteProperty): 13 (JSC::JSObject::getPropertyAttributes): 14 * kjs/MathObject.cpp: 15 (JSC::MathObject::getOwnPropertySlot): 16 * kjs/NumberConstructor.cpp: 17 (JSC::numberConstructorNaNValue): 18 (JSC::numberConstructorNegInfinity): 19 (JSC::numberConstructorPosInfinity): 20 (JSC::numberConstructorMaxValue): 21 (JSC::numberConstructorMinValue): 22 * kjs/PropertySlot.h: 23 (JSC::PropertySlot::): 24 * kjs/RegExpConstructor.cpp: 25 (JSC::regExpConstructorDollar1): 26 (JSC::regExpConstructorDollar2): 27 (JSC::regExpConstructorDollar3): 28 (JSC::regExpConstructorDollar4): 29 (JSC::regExpConstructorDollar5): 30 (JSC::regExpConstructorDollar6): 31 (JSC::regExpConstructorDollar7): 32 (JSC::regExpConstructorDollar8): 33 (JSC::regExpConstructorDollar9): 34 (JSC::regExpConstructorInput): 35 (JSC::regExpConstructorMultiline): 36 (JSC::regExpConstructorLastMatch): 37 (JSC::regExpConstructorLastParen): 38 (JSC::regExpConstructorLeftContext): 39 (JSC::regExpConstructorRightContext): 40 (JSC::setRegExpConstructorInput): 41 (JSC::setRegExpConstructorMultiline): 42 (JSC::RegExpConstructor::setInput): 43 (JSC::RegExpConstructor::setMultiline): 44 (JSC::RegExpConstructor::multiline): 45 * kjs/RegExpConstructor.h: 46 * kjs/RegExpObject.cpp: 47 (JSC::regExpObjectGlobal): 48 (JSC::regExpObjectIgnoreCase): 49 (JSC::regExpObjectMultiline): 50 (JSC::regExpObjectSource): 51 (JSC::regExpObjectLastIndex): 52 (JSC::setRegExpObjectLastIndex): 53 * kjs/RegExpObject.h: 54 (JSC::RegExpObject::setLastIndex): 55 (JSC::RegExpObject::lastIndex): 56 (JSC::RegExpObject::RegExpObjectData::RegExpObjectData): 57 * kjs/StructureID.cpp: 58 (JSC::StructureID::getEnumerablePropertyNames): 59 * kjs/create_hash_table: 60 * kjs/lexer.cpp: 61 (JSC::Lexer::lex): 62 * kjs/lookup.cpp: 63 (JSC::HashTable::createTable): 64 (JSC::HashTable::deleteTable): 65 (JSC::setUpStaticFunctionSlot): 66 * kjs/lookup.h: 67 (JSC::HashEntry::initialize): 68 (JSC::HashEntry::setKey): 69 (JSC::HashEntry::key): 70 (JSC::HashEntry::attributes): 71 (JSC::HashEntry::function): 72 (JSC::HashEntry::functionLength): 73 (JSC::HashEntry::propertyGetter): 74 (JSC::HashEntry::propertyPutter): 75 (JSC::HashEntry::lexerValue): 76 (JSC::HashEntry::): 77 (JSC::HashTable::entry): 78 (JSC::getStaticPropertySlot): 79 (JSC::getStaticValueSlot): 80 (JSC::lookupPut): 81 1 82 2008-09-26 Gavin Barraclough <[email protected]> 2 83 -
trunk/JavaScriptCore/kjs/JSObject.cpp
r36766 r36977 210 210 // Look in the static hashtable of properties 211 211 const HashEntry* entry = findPropertyHashEntry(exec, propertyName); 212 if (entry && entry->attributes & DontDelete)212 if (entry && entry->attributes() & DontDelete) 213 213 return false; // this builtin property can't be deleted 214 214 … … 419 419 const HashEntry* entry = findPropertyHashEntry(exec, propertyName); 420 420 if (entry) { 421 attributes = entry->attributes ;421 attributes = entry->attributes(); 422 422 return true; 423 423 } -
trunk/JavaScriptCore/kjs/MathObject.cpp
r36726 r36977 106 106 return JSObject::getOwnPropertySlot(exec, propertyName, slot); 107 107 108 ASSERT(entry->attributes & Function);108 ASSERT(entry->attributes() & Function); 109 109 setUpStaticFunctionSlot(exec, entry, this, propertyName, slot); 110 110 return true; -
trunk/JavaScriptCore/kjs/NumberConstructor.cpp
r36726 r36977 22 22 #include "config.h" 23 23 #include "NumberConstructor.h" 24 #include "NumberConstructor.lut.h"25 24 26 25 #include "NumberObject.h" … … 31 30 ASSERT_CLASS_FITS_IN_CELL(NumberConstructor); 32 31 32 static JSValue* numberConstructorNaNValue(ExecState*, const Identifier&, const PropertySlot&); 33 static JSValue* numberConstructorNegInfinity(ExecState*, const Identifier&, const PropertySlot&); 34 static JSValue* numberConstructorPosInfinity(ExecState*, const Identifier&, const PropertySlot&); 35 static JSValue* numberConstructorMaxValue(ExecState*, const Identifier&, const PropertySlot&); 36 static JSValue* numberConstructorMinValue(ExecState*, const Identifier&, const PropertySlot&); 37 38 } // namespace JSC 39 40 #include "NumberConstructor.lut.h" 41 42 namespace JSC { 43 33 44 const ClassInfo NumberConstructor::info = { "Function", &InternalFunction::info, 0, ExecState::numberTable }; 34 45 35 /* Source for Number Object.lut.h46 /* Source for NumberConstructor.lut.h 36 47 @begin numberTable 37 NaN NumberConstructor::NaNValue DontEnum|DontDelete|ReadOnly38 NEGATIVE_INFINITY NumberConstructor::NegInfinity DontEnum|DontDelete|ReadOnly39 POSITIVE_INFINITY NumberConstructor::PosInfinity DontEnum|DontDelete|ReadOnly40 MAX_VALUE NumberConstructor::MaxValue DontEnum|DontDelete|ReadOnly41 MIN_VALUE NumberConstructor::MinValue DontEnum|DontDelete|ReadOnly48 NaN numberConstructorNaNValue DontEnum|DontDelete|ReadOnly 49 NEGATIVE_INFINITY numberConstructorNegInfinity DontEnum|DontDelete|ReadOnly 50 POSITIVE_INFINITY numberConstructorPosInfinity DontEnum|DontDelete|ReadOnly 51 MAX_VALUE numberConstructorMaxValue DontEnum|DontDelete|ReadOnly 52 MIN_VALUE numberConstructorMinValue DontEnum|DontDelete|ReadOnly 42 53 @end 43 54 */ 55 44 56 NumberConstructor::NumberConstructor(ExecState* exec, PassRefPtr<StructureID> structure, NumberPrototype* numberPrototype) 45 57 : InternalFunction(exec, structure, Identifier(exec, numberPrototype->info.className)) … … 57 69 } 58 70 59 JSValue* NumberConstructor::getValueProperty(ExecState* exec, int token) const71 JSValue* numberConstructorNaNValue(ExecState* exec, const Identifier&, const PropertySlot&) 60 72 { 61 // ECMA 15.7.3 62 switch (token) { 63 case NaNValue: 64 return jsNaN(exec); 65 case NegInfinity: 66 return jsNumberCell(exec, -Inf); 67 case PosInfinity: 68 return jsNumberCell(exec, Inf); 69 case MaxValue: 70 return jsNumberCell(exec, 1.7976931348623157E+308); 71 case MinValue: 72 return jsNumberCell(exec, 5E-324); 73 } 74 ASSERT_NOT_REACHED(); 75 return jsNull(); 73 return jsNaN(exec); 74 } 75 76 JSValue* numberConstructorNegInfinity(ExecState* exec, const Identifier&, const PropertySlot&) 77 { 78 return jsNumberCell(exec, -Inf); 79 } 80 81 JSValue* numberConstructorPosInfinity(ExecState* exec, const Identifier&, const PropertySlot&) 82 { 83 return jsNumberCell(exec, Inf); 84 } 85 86 JSValue* numberConstructorMaxValue(ExecState* exec, const Identifier&, const PropertySlot&) 87 { 88 return jsNumberCell(exec, 1.7976931348623157E+308); 89 } 90 91 JSValue* numberConstructorMinValue(ExecState* exec, const Identifier&, const PropertySlot&) 92 { 93 return jsNumberCell(exec, 5E-324); 76 94 } 77 95 -
trunk/JavaScriptCore/kjs/PropertySlot.h
r36264 r36977 32 32 class ExecState; 33 33 class JSObject; 34 struct HashEntry;35 34 36 35 #define JSC_VALUE_SLOT_MARKER 0 … … 132 131 } 133 132 134 void setStaticEntry(JSValue* slotBase, const HashEntry* staticEntry, GetValueFunc getValue)135 {136 ASSERT(slotBase);137 ASSERT(staticEntry);138 ASSERT(getValue);139 m_getValue = getValue;140 m_slotBase = slotBase;141 m_data.staticEntry = staticEntry;142 }143 144 133 void setCustom(JSValue* slotBase, GetValueFunc getValue) 145 134 { … … 199 188 } 200 189 201 const HashEntry* staticEntry() const { return m_data.staticEntry; }202 190 unsigned index() const { return m_data.index; } 203 191 … … 212 200 JSValue** valueSlot; 213 201 Register* registerSlot; 214 const HashEntry* staticEntry;215 202 unsigned index; 216 203 } m_data; -
trunk/JavaScriptCore/kjs/RegExpConstructor.cpp
r36784 r36977 21 21 #include "config.h" 22 22 #include "RegExpConstructor.h" 23 #include "RegExpConstructor.lut.h"24 23 25 24 #include "ArrayPrototype.h" … … 35 34 namespace JSC { 36 35 36 static JSValue* regExpConstructorInput(ExecState*, const Identifier&, const PropertySlot&); 37 static JSValue* regExpConstructorMultiline(ExecState*, const Identifier&, const PropertySlot&); 38 static JSValue* regExpConstructorLastMatch(ExecState*, const Identifier&, const PropertySlot&); 39 static JSValue* regExpConstructorLastParen(ExecState*, const Identifier&, const PropertySlot&); 40 static JSValue* regExpConstructorLeftContext(ExecState*, const Identifier&, const PropertySlot&); 41 static JSValue* regExpConstructorRightContext(ExecState*, const Identifier&, const PropertySlot&); 42 static JSValue* regExpConstructorDollar1(ExecState*, const Identifier&, const PropertySlot&); 43 static JSValue* regExpConstructorDollar2(ExecState*, const Identifier&, const PropertySlot&); 44 static JSValue* regExpConstructorDollar3(ExecState*, const Identifier&, const PropertySlot&); 45 static JSValue* regExpConstructorDollar4(ExecState*, const Identifier&, const PropertySlot&); 46 static JSValue* regExpConstructorDollar5(ExecState*, const Identifier&, const PropertySlot&); 47 static JSValue* regExpConstructorDollar6(ExecState*, const Identifier&, const PropertySlot&); 48 static JSValue* regExpConstructorDollar7(ExecState*, const Identifier&, const PropertySlot&); 49 static JSValue* regExpConstructorDollar8(ExecState*, const Identifier&, const PropertySlot&); 50 static JSValue* regExpConstructorDollar9(ExecState*, const Identifier&, const PropertySlot&); 51 52 static void setRegExpConstructorInput(ExecState*, JSObject*, JSValue*); 53 static void setRegExpConstructorMultiline(ExecState*, JSObject*, JSValue*); 54 55 } // namespace JSC 56 57 #include "RegExpConstructor.lut.h" 58 59 namespace JSC { 60 37 61 ASSERT_CLASS_FITS_IN_CELL(RegExpConstructor); 38 62 … … 41 65 /* Source for RegExpConstructor.lut.h 42 66 @begin regExpConstructorTable 43 input RegExpConstructor::Input None44 $_ RegExpConstructor::Input DontEnum45 multiline RegExpConstructor::Multiline None46 $* RegExpConstructor::Multiline DontEnum47 lastMatch RegExpConstructor::LastMatch DontDelete|ReadOnly48 $& RegExpConstructor::LastMatch DontDelete|ReadOnly|DontEnum49 lastParen RegExpConstructor::LastParen DontDelete|ReadOnly50 $+ RegExpConstructor::LastParen DontDelete|ReadOnly|DontEnum51 leftContext RegExpConstructor::LeftContext DontDelete|ReadOnly52 $` RegExpConstructor::LeftContext DontDelete|ReadOnly|DontEnum53 rightContext RegExpConstructor::RightContext DontDelete|ReadOnly54 $' RegExpConstructor::RightContext DontDelete|ReadOnly|DontEnum55 $1 RegExpConstructor::Dollar1 DontDelete|ReadOnly56 $2 RegExpConstructor::Dollar2 DontDelete|ReadOnly57 $3 RegExpConstructor::Dollar3 DontDelete|ReadOnly58 $4 RegExpConstructor::Dollar4 DontDelete|ReadOnly59 $5 RegExpConstructor::Dollar5 DontDelete|ReadOnly60 $6 RegExpConstructor::Dollar6 DontDelete|ReadOnly61 $7 RegExpConstructor::Dollar7 DontDelete|ReadOnly62 $8 RegExpConstructor::Dollar8 DontDelete|ReadOnly63 $9 RegExpConstructor::Dollar9 DontDelete|ReadOnly67 input regExpConstructorInput None 68 $_ regExpConstructorInput DontEnum 69 multiline regExpConstructorMultiline None 70 $* regExpConstructorMultiline DontEnum 71 lastMatch regExpConstructorLastMatch DontDelete|ReadOnly 72 $& regExpConstructorLastMatch DontDelete|ReadOnly|DontEnum 73 lastParen regExpConstructorLastParen DontDelete|ReadOnly 74 $+ regExpConstructorLastParen DontDelete|ReadOnly|DontEnum 75 leftContext regExpConstructorLeftContext DontDelete|ReadOnly 76 $` regExpConstructorLeftContext DontDelete|ReadOnly|DontEnum 77 rightContext regExpConstructorRightContext DontDelete|ReadOnly 78 $' regExpConstructorRightContext DontDelete|ReadOnly|DontEnum 79 $1 regExpConstructorDollar1 DontDelete|ReadOnly 80 $2 regExpConstructorDollar2 DontDelete|ReadOnly 81 $3 regExpConstructorDollar3 DontDelete|ReadOnly 82 $4 regExpConstructorDollar4 DontDelete|ReadOnly 83 $5 regExpConstructorDollar5 DontDelete|ReadOnly 84 $6 regExpConstructorDollar6 DontDelete|ReadOnly 85 $7 regExpConstructorDollar7 DontDelete|ReadOnly 86 $8 regExpConstructorDollar8 DontDelete|ReadOnly 87 $9 regExpConstructorDollar9 DontDelete|ReadOnly 64 88 @end 65 89 */ … … 203 227 } 204 228 205 JSValue* RegExpConstructor::getValueProperty(ExecState* exec, int token) const 206 { 207 switch (token) { 208 case Dollar1: 209 return getBackref(exec, 1); 210 case Dollar2: 211 return getBackref(exec, 2); 212 case Dollar3: 213 return getBackref(exec, 3); 214 case Dollar4: 215 return getBackref(exec, 4); 216 case Dollar5: 217 return getBackref(exec, 5); 218 case Dollar6: 219 return getBackref(exec, 6); 220 case Dollar7: 221 return getBackref(exec, 7); 222 case Dollar8: 223 return getBackref(exec, 8); 224 case Dollar9: 225 return getBackref(exec, 9); 226 case Input: 227 return jsString(exec, d->input); 228 case Multiline: 229 return jsBoolean(d->multiline); 230 case LastMatch: 231 return getBackref(exec, 0); 232 case LastParen: 233 return getLastParen(exec); 234 case LeftContext: 235 return getLeftContext(exec); 236 case RightContext: 237 return getRightContext(exec); 238 default: 239 ASSERT_NOT_REACHED(); 240 } 241 242 return jsEmptyString(exec); 229 JSValue* regExpConstructorDollar1(ExecState* exec, const Identifier&, const PropertySlot& slot) 230 { 231 return static_cast<RegExpConstructor*>(slot.slotBase())->getBackref(exec, 1); 232 } 233 234 JSValue* regExpConstructorDollar2(ExecState* exec, const Identifier&, const PropertySlot& slot) 235 { 236 return static_cast<RegExpConstructor*>(slot.slotBase())->getBackref(exec, 2); 237 } 238 239 JSValue* regExpConstructorDollar3(ExecState* exec, const Identifier&, const PropertySlot& slot) 240 { 241 return static_cast<RegExpConstructor*>(slot.slotBase())->getBackref(exec, 3); 242 } 243 244 JSValue* regExpConstructorDollar4(ExecState* exec, const Identifier&, const PropertySlot& slot) 245 { 246 return static_cast<RegExpConstructor*>(slot.slotBase())->getBackref(exec, 4); 247 } 248 249 JSValue* regExpConstructorDollar5(ExecState* exec, const Identifier&, const PropertySlot& slot) 250 { 251 return static_cast<RegExpConstructor*>(slot.slotBase())->getBackref(exec, 5); 252 } 253 254 JSValue* regExpConstructorDollar6(ExecState* exec, const Identifier&, const PropertySlot& slot) 255 { 256 return static_cast<RegExpConstructor*>(slot.slotBase())->getBackref(exec, 6); 257 } 258 259 JSValue* regExpConstructorDollar7(ExecState* exec, const Identifier&, const PropertySlot& slot) 260 { 261 return static_cast<RegExpConstructor*>(slot.slotBase())->getBackref(exec, 7); 262 } 263 264 JSValue* regExpConstructorDollar8(ExecState* exec, const Identifier&, const PropertySlot& slot) 265 { 266 return static_cast<RegExpConstructor*>(slot.slotBase())->getBackref(exec, 8); 267 } 268 269 JSValue* regExpConstructorDollar9(ExecState* exec, const Identifier&, const PropertySlot& slot) 270 { 271 return static_cast<RegExpConstructor*>(slot.slotBase())->getBackref(exec, 9); 272 } 273 274 JSValue* regExpConstructorInput(ExecState* exec, const Identifier&, const PropertySlot& slot) 275 { 276 return jsString(exec, static_cast<RegExpConstructor*>(slot.slotBase())->input()); 277 } 278 279 JSValue* regExpConstructorMultiline(ExecState*, const Identifier&, const PropertySlot& slot) 280 { 281 return jsBoolean(static_cast<RegExpConstructor*>(slot.slotBase())->multiline()); 282 } 283 284 JSValue* regExpConstructorLastMatch(ExecState* exec, const Identifier&, const PropertySlot& slot) 285 { 286 return static_cast<RegExpConstructor*>(slot.slotBase())->getBackref(exec, 0); 287 } 288 289 JSValue* regExpConstructorLastParen(ExecState* exec, const Identifier&, const PropertySlot& slot) 290 { 291 return static_cast<RegExpConstructor*>(slot.slotBase())->getLastParen(exec); 292 } 293 294 JSValue* regExpConstructorLeftContext(ExecState* exec, const Identifier&, const PropertySlot& slot) 295 { 296 return static_cast<RegExpConstructor*>(slot.slotBase())->getLeftContext(exec); 297 } 298 299 JSValue* regExpConstructorRightContext(ExecState* exec, const Identifier&, const PropertySlot& slot) 300 { 301 return static_cast<RegExpConstructor*>(slot.slotBase())->getRightContext(exec); 243 302 } 244 303 … … 248 307 } 249 308 250 void RegExpConstructor::putValueProperty(ExecState* exec, int token, JSValue* value) 251 { 252 switch (token) { 253 case Input: 254 d->input = value->toString(exec); 255 break; 256 case Multiline: 257 d->multiline = value->toBoolean(exec); 258 break; 259 default: 260 ASSERT_NOT_REACHED(); 261 } 309 void setRegExpConstructorInput(ExecState* exec, JSObject* baseObject, JSValue* value) 310 { 311 static_cast<RegExpConstructor*>(baseObject)->setInput(value->toString(exec)); 312 } 313 314 void setRegExpConstructorMultiline(ExecState* exec, JSObject* baseObject, JSValue* value) 315 { 316 static_cast<RegExpConstructor*>(baseObject)->setMultiline(value->toBoolean(exec)); 262 317 } 263 318 … … 306 361 } 307 362 363 void RegExpConstructor::setInput(const UString& input) 364 { 365 d->input = input; 366 } 367 308 368 const UString& RegExpConstructor::input() const 309 369 { … … 313 373 } 314 374 375 void RegExpConstructor::setMultiline(bool multiline) 376 { 377 d->multiline = multiline; 378 } 379 380 bool RegExpConstructor::multiline() const 381 { 382 return d->multiline; 383 } 384 315 385 } // namespace JSC -
trunk/JavaScriptCore/kjs/RegExpConstructor.h
r36784 r36977 33 33 class RegExpConstructor : public InternalFunction { 34 34 public: 35 enum {36 Dollar1,37 Dollar2,38 Dollar3,39 Dollar4,40 Dollar5,41 Dollar6,42 Dollar7,43 Dollar8,44 Dollar9,45 Input,46 Multiline,47 LastMatch,48 LastParen,49 LeftContext,50 RightContext51 };52 53 35 RegExpConstructor(ExecState*, PassRefPtr<StructureID>, RegExpPrototype*); 54 36 55 37 virtual void put(ExecState*, const Identifier& propertyName, JSValue*, PutPropertySlot&); 56 void putValueProperty(ExecState*, int token, JSValue*);57 38 virtual bool getOwnPropertySlot(ExecState*, const Identifier& propertyName, PropertySlot&); 58 JSValue* getValueProperty(ExecState*, int token) const;59 39 60 40 static const ClassInfo info; … … 62 42 void performMatch(RegExp*, const UString&, int startOffset, int& position, int& length, int** ovector = 0); 63 43 JSObject* arrayOfMatches(ExecState*) const; 44 45 void setInput(const UString&); 64 46 const UString& input() const; 47 48 void setMultiline(bool); 49 bool multiline() const; 50 51 JSValue* getBackref(ExecState*, unsigned) const; 52 JSValue* getLastParen(ExecState*) const; 53 JSValue* getLeftContext(ExecState*) const; 54 JSValue* getRightContext(ExecState*) const; 65 55 66 56 private: … … 69 59 70 60 virtual const ClassInfo* classInfo() const { return &info; } 71 72 JSValue* getBackref(ExecState*, unsigned) const;73 JSValue* getLastParen(ExecState*) const;74 JSValue* getLeftContext(ExecState*) const;75 JSValue* getRightContext(ExecState*) const;76 61 77 62 OwnPtr<RegExpConstructorPrivate> d; -
trunk/JavaScriptCore/kjs/RegExpObject.cpp
r36726 r36977 21 21 #include "config.h" 22 22 #include "RegExpObject.h" 23 #include "RegExpObject.lut.h"24 23 25 24 #include "JSArray.h" … … 31 30 namespace JSC { 32 31 32 static JSValue* regExpObjectGlobal(ExecState*, const Identifier&, const PropertySlot&); 33 static JSValue* regExpObjectIgnoreCase(ExecState*, const Identifier&, const PropertySlot&); 34 static JSValue* regExpObjectMultiline(ExecState*, const Identifier&, const PropertySlot&); 35 static JSValue* regExpObjectSource(ExecState*, const Identifier&, const PropertySlot&); 36 static JSValue* regExpObjectLastIndex(ExecState*, const Identifier&, const PropertySlot&); 37 static void setRegExpObjectLastIndex(ExecState*, JSObject*, JSValue*); 38 39 } // namespace JSC 40 41 #include "RegExpObject.lut.h" 42 43 namespace JSC { 44 33 45 ASSERT_CLASS_FITS_IN_CELL(RegExpObject); 34 46 … … 37 49 /* Source for RegExpObject.lut.h 38 50 @begin regExpTable 39 global RegExpObject::Global DontDelete|ReadOnly|DontEnum40 ignoreCase RegExpObject::IgnoreCase DontDelete|ReadOnly|DontEnum41 multiline RegExpObject::Multiline DontDelete|ReadOnly|DontEnum42 source RegExpObject::Source DontDelete|ReadOnly|DontEnum43 lastIndex RegExpObject::LastIndex DontDelete|DontEnum51 global regExpObjectGlobal DontDelete|ReadOnly|DontEnum 52 ignoreCase regExpObjectIgnoreCase DontDelete|ReadOnly|DontEnum 53 multiline regExpObjectMultiline DontDelete|ReadOnly|DontEnum 54 source regExpObjectSource DontDelete|ReadOnly|DontEnum 55 lastIndex regExpObjectLastIndex DontDelete|DontEnum 44 56 @end 45 57 */ … … 60 72 } 61 73 62 JSValue* RegExpObject::getValueProperty(ExecState* exec, int token) const74 JSValue* regExpObjectGlobal(ExecState*, const Identifier&, const PropertySlot& slot) 63 75 { 64 switch (token) { 65 case Global: 66 return jsBoolean(d->regExp->global()); 67 case IgnoreCase: 68 return jsBoolean(d->regExp->ignoreCase()); 69 case Multiline: 70 return jsBoolean(d->regExp->multiline()); 71 case Source: 72 return jsString(exec, d->regExp->pattern()); 73 case LastIndex: 74 return jsNumber(exec, d->lastIndex); 75 } 76 77 ASSERT_NOT_REACHED(); 78 return 0; 76 return jsBoolean(static_cast<RegExpObject*>(slot.slotBase())->regExp()->global()); 77 } 78 79 JSValue* regExpObjectIgnoreCase(ExecState*, const Identifier&, const PropertySlot& slot) 80 { 81 return jsBoolean(static_cast<RegExpObject*>(slot.slotBase())->regExp()->ignoreCase()); 82 } 83 84 JSValue* regExpObjectMultiline(ExecState*, const Identifier&, const PropertySlot& slot) 85 { 86 return jsBoolean(static_cast<RegExpObject*>(slot.slotBase())->regExp()->multiline()); 87 } 88 89 JSValue* regExpObjectSource(ExecState* exec, const Identifier&, const PropertySlot& slot) 90 { 91 return jsString(exec, static_cast<RegExpObject*>(slot.slotBase())->regExp()->pattern()); 92 } 93 94 JSValue* regExpObjectLastIndex(ExecState* exec, const Identifier&, const PropertySlot& slot) 95 { 96 return jsNumber(exec, static_cast<RegExpObject*>(slot.slotBase())->lastIndex()); 79 97 } 80 98 … … 84 102 } 85 103 86 void RegExpObject::putValueProperty(ExecState* exec, int token, JSValue* value)104 void setRegExpObjectLastIndex(ExecState* exec, JSObject* baseObject, JSValue* value) 87 105 { 88 UNUSED_PARAM(token); 89 ASSERT(token == LastIndex); 90 d->lastIndex = value->toInteger(exec); 106 static_cast<RegExpObject*>(baseObject)->setLastIndex(value->toInteger(exec)); 91 107 } 92 108 -
trunk/JavaScriptCore/kjs/RegExpObject.h
r36726 r36977 29 29 class RegExpObject : public JSObject { 30 30 public: 31 enum { Global, IgnoreCase, Multiline, Source, LastIndex };32 33 31 RegExpObject(PassRefPtr<StructureID>, PassRefPtr<RegExp>); 34 32 virtual ~RegExpObject(); … … 37 35 RegExp* regExp() const { return d->regExp.get(); } 38 36 37 void setLastIndex(double lastIndex) { d->lastIndex = lastIndex; } 38 double lastIndex() const { return d->lastIndex; } 39 39 40 JSValue* test(ExecState*, const ArgList&); 40 41 JSValue* exec(ExecState*, const ArgList&); 41 42 42 bool getOwnPropertySlot(ExecState*, const Identifier& propertyName, PropertySlot&); 43 JSValue* getValueProperty(ExecState*, int token) const; 44 void put(ExecState*, const Identifier& propertyName, JSValue*, PutPropertySlot&); 45 void putValueProperty(ExecState*, int token, JSValue*); 43 virtual bool getOwnPropertySlot(ExecState*, const Identifier& propertyName, PropertySlot&); 44 virtual void put(ExecState*, const Identifier& propertyName, JSValue*, PutPropertySlot&); 46 45 47 46 virtual const ClassInfo* classInfo() const { return &info; } 48 47 static const ClassInfo info; 49 50 void setLastIndex(double lastIndex) { d->lastIndex = lastIndex; }51 48 52 49 private: … … 54 51 55 52 virtual CallType getCallData(CallData&); 56 53 57 54 struct RegExpObjectData { 58 RegExpObjectData(PassRefPtr<RegExp> regExp _, double lastIndex_)59 : regExp(regExp _)60 , lastIndex(lastIndex _)55 RegExpObjectData(PassRefPtr<RegExp> regExp, double lastIndex) 56 : regExp(regExp) 57 , lastIndex(lastIndex) 61 58 { 62 59 } … … 65 62 double lastIndex; 66 63 }; 67 64 68 65 OwnPtr<RegExpObjectData> d; 69 66 }; -
trunk/JavaScriptCore/kjs/StructureID.cpp
r36789 r36977 73 73 const HashEntry* entry = table->table; 74 74 for (int i = 0; i <= hashSizeMask; ++i, ++entry) { 75 if (entry->key && !(entry->attributes& DontEnum))76 propertyNames.add(entry->key );75 if (entry->key() && !(entry->attributes() & DontEnum)) 76 propertyNames.add(entry->key()); 77 77 } 78 78 } -
trunk/JavaScriptCore/kjs/create_hash_table
r36263 r36977 41 41 42 42 my @keys = (); 43 my @attrs = (); 43 44 my @values = (); 44 my @attrs = ();45 my @params = ();46 45 my @hashes = (); 47 46 … … 52 51 sub calcSize(); 53 52 sub output(); 53 sub jsc_ucfirst($); 54 54 sub hashValue($); 55 55 … … 70 70 71 71 @keys = (); 72 @attrs = (); 72 73 @values = (); 73 @attrs = ();74 @params = ();75 74 @hashes = (); 76 75 … … 81 80 my $att = $3; 82 81 my $param = $4; 82 83 83 push(@keys, $key); 84 push(@values, $val); 84 push(@attrs, length($att) > 0 ? $att : "0"); 85 86 if ($att =~ m/Function/) { 87 push(@values, { "type" => "Function", "function" => $val, "params" => (length($param) ? $param : "") }); 88 #printf STDERR "WARNING: Number of arguments missing for $key/$val\n" if (length($param) == 0); 89 } elsif (length($att)) { 90 my $get = $val; 91 my $put = !($att =~ m/ReadOnly/) ? "set" . jsc_ucfirst($val) : "0"; 92 push(@values, { "type" => "Property", "get" => $get, "put" => $put }); 93 } else { 94 push(@values, { "type" => "Lexer", "value" => $val }); 95 } 85 96 push(@hashes, hashValue($key)); 86 printf STDERR "WARNING: Number of arguments missing for $key/$val\n" if ($att =~ m/Function/ && length($param) == 0);87 push(@attrs, length($att) > 0 ? $att : "0");88 push(@params, length($param) > 0 ? $param : "0");89 97 } elsif ($inside) { 90 98 die "invalid data {" . $_ . "}"; … … 93 101 94 102 die "missing closing \@end" if ($inside); 103 104 sub jsc_ucfirst($) 105 { 106 my ($value) = @_; 107 108 if ($value =~ /js/) { 109 $value =~ s/js/JS/; 110 return $value; 111 } 112 113 return ucfirst($value); 114 } 115 95 116 96 117 sub ceilingToPowerOf2 … … 189 210 print "\n#include \"lookup.h\"\n" if ($includelookup); 190 211 if ($useNameSpace) { 191 print "\nnamespace ${useNameSpace} \n{\n";192 print "\nusing namespace JSC; ";212 print "\nnamespace ${useNameSpace} {\n"; 213 print "\nusing namespace JSC;\n"; 193 214 } else { 194 215 print "\nnamespace JSC {\n"; … … 198 219 my $i = 0; 199 220 foreach my $key (@keys) { 200 print " { \"$key\", (intptr_t)$values[$i], $attrs[$i], $params[$i] },\n"; 221 my $firstValue = ""; 222 my $secondValue = ""; 223 224 if ($values[$i]{"type"} eq "Function") { 225 $firstValue = $values[$i]{"function"}; 226 $secondValue = $values[$i]{"params"}; 227 } elsif ($values[$i]{"type"} eq "Property") { 228 $firstValue = $values[$i]{"get"}; 229 $secondValue = $values[$i]{"put"}; 230 } elsif ($values[$i]{"type"} eq "Lexer") { 231 $firstValue = $values[$i]{"value"}; 232 $secondValue = "0"; 233 } 234 print " { \"$key\", $attrs[$i], (intptr_t)$firstValue, (intptr_t)$secondValue },\n"; 201 235 $i++; 202 236 } -
trunk/JavaScriptCore/kjs/lexer.cpp
r36660 r36977 560 560 break; 561 561 } 562 token = entry-> integerValue;562 token = entry->lexerValue(); 563 563 // Hack for "f = function somename() { ... }"; too hard to get into the grammar. 564 564 m_eatNextIdentifier = token == FUNCTION && m_lastToken == '='; -
trunk/JavaScriptCore/kjs/lookup.cpp
r36877 r36977 30 30 HashEntry* entries = new HashEntry[hashSizeMask + 1]; 31 31 for (int i = 0; i <= hashSizeMask; ++i) 32 entries[i]. key = 0;32 entries[i].setKey(0); 33 33 for (int i = 0; values[i].key; ++i) { 34 34 UString::Rep* identifier = Identifier::add(globalData, values[i].key).releaseRef(); 35 35 int hashIndex = identifier->computedHash() & hashSizeMask; 36 ASSERT(!entries[hashIndex].key); 37 entries[hashIndex].key = identifier; 38 entries[hashIndex].integerValue = values[i].value; 39 entries[hashIndex].attributes = values[i].attributes; 40 entries[hashIndex].length = values[i].length; 36 ASSERT(!entries[hashIndex].key()); 37 entries[hashIndex].initialize(identifier, values[i].attributes, values[i].value1, values[i].value2); 41 38 } 42 39 table = entries; … … 47 44 if (table) { 48 45 for (int i = 0; i != hashSizeMask + 1; ++i) { 49 if (UString::Rep* key = table[i].key )46 if (UString::Rep* key = table[i].key()) 50 47 key->deref(); 51 48 } 52 delete [] table;49 delete [] table; 53 50 table = 0; 54 51 } … … 57 54 void setUpStaticFunctionSlot(ExecState* exec, const HashEntry* entry, JSObject* thisObj, const Identifier& propertyName, PropertySlot& slot) 58 55 { 59 ASSERT(entry->attributes & Function);56 ASSERT(entry->attributes() & Function); 60 57 JSValue** location = thisObj->getDirectLocation(propertyName); 61 58 62 59 if (!location) { 63 PrototypeFunction* function = new (exec) PrototypeFunction(exec, entry-> length, propertyName, entry->functionValue);64 thisObj->putDirect(propertyName, function, entry->attributes );60 PrototypeFunction* function = new (exec) PrototypeFunction(exec, entry->functionLength(), propertyName, entry->function()); 61 thisObj->putDirect(propertyName, function, entry->attributes()); 65 62 location = thisObj->getDirectLocation(propertyName); 66 63 } 67 64 68 65 slot.setValueSlot(thisObj, location, thisObj->offsetForLocation(location)); 69 66 } -
trunk/JavaScriptCore/kjs/lookup.h
r36877 r36977 26 26 #include "JSGlobalObject.h" 27 27 #include "JSObject.h" 28 #include "PropertySlot.h" 28 29 #include "identifier.h" 29 30 #include <stdio.h> … … 33 34 34 35 // Hash table generated by the create_hash_table script. 35 36 36 struct HashTableValue { 37 37 const char* key; // property name 38 intptr_t value; // integer or function39 38 unsigned char attributes; // JSObject attributes 40 unsigned char length; // number of arguments for function 39 intptr_t value1; 40 intptr_t value2; 41 41 }; 42 42 43 struct HashEntry { 44 UString::Rep* key; 43 // FIXME: There is no reason this get function can't be simpler. 44 // ie. typedef JSValue* (*GetFunction)(ExecState*, JSObject* baseObject) 45 typedef PropertySlot::GetValueFunc GetFunction; 46 typedef void (*PutFunction)(ExecState*, JSObject* baseObject, JSValue* value); 47 48 class HashEntry { 49 public: 50 void initialize(UString::Rep* key, unsigned char attributes, intptr_t v1, intptr_t v2) 51 { 52 m_key = key; 53 m_attributes = attributes; 54 m_u.store.value1 = v1; 55 m_u.store.value2 = v2; 56 } 57 58 void setKey(UString::Rep* key) { m_key = key; } 59 UString::Rep* key() const { return m_key; } 60 61 unsigned char attributes() const { return m_attributes; } 62 63 NativeFunction function() const { ASSERT(m_attributes & Function); return m_u.function.functionValue; } 64 unsigned char functionLength() const { ASSERT(m_attributes & Function); return static_cast<unsigned char>(m_u.function.length); } 65 66 GetFunction propertyGetter() const { ASSERT(!(m_attributes & Function)); return m_u.property.get; } 67 PutFunction propertyPutter() const { ASSERT(!(m_attributes & Function)); return m_u.property.put; } 68 69 intptr_t lexerValue() const { ASSERT(!m_attributes); return m_u.lexer.value; } 70 71 private: 72 UString::Rep* m_key; 73 unsigned char m_attributes; // JSObject attributes 74 45 75 union { 46 intptr_t integerValue; 47 NativeFunction functionValue; 48 }; 49 unsigned char attributes; // JSObject attributes 50 unsigned char length; // number of arguments for function 76 struct { 77 intptr_t value1; 78 intptr_t value2; 79 } store; 80 struct { 81 NativeFunction functionValue; 82 intptr_t length; // number of arguments for function 83 } function; 84 struct { 85 GetFunction get; 86 PutFunction put; 87 } property; 88 struct { 89 intptr_t value; 90 intptr_t unused; 91 } lexer; 92 } m_u; 51 93 }; 52 94 … … 88 130 ASSERT(table); 89 131 const HashEntry* entry = &table[identifier.ustring().rep()->computedHash() & hashSizeMask]; 90 if (entry->key != identifier.ustring().rep())132 if (entry->key() != identifier.ustring().rep()) 91 133 return 0; 92 134 return entry; … … 100 142 101 143 /** 102 * @internal103 * Helper for getStaticValueSlot and getStaticPropertySlot104 */105 template <class ThisImp>106 JSValue* staticValueGetter(ExecState* exec, const Identifier&, const PropertySlot& slot)107 {108 ThisImp* thisObj = static_cast<ThisImp*>(slot.slotBase());109 const HashEntry* entry = slot.staticEntry();110 return thisObj->getValueProperty(exec, entry->integerValue);111 }112 113 /**114 * Helper method for property lookups115 *116 144 * This method does it all (looking in the hashtable, checking for function 117 145 * overrides, creating the function or retrieving from cache, calling 118 146 * getValueProperty in case of a non-function property, forwarding to parent if 119 147 * unknown property). 120 *121 * Template arguments:122 * @param FuncImp the class which implements this object's functions123 * @param ThisImp the class of "this". It must implement the getValueProperty(exec,token) method,124 * for non-function properties.125 * @param ParentImp the class of the parent, to propagate the lookup.126 *127 * Method arguments:128 * @param exec execution state, as usual129 * @param propertyName the property we're looking for130 * @param table the static hashtable for this class131 * @param thisObj "this"132 148 */ 133 149 template <class ThisImp, class ParentImp> … … 139 155 return thisObj->ParentImp::getOwnPropertySlot(exec, propertyName, slot); 140 156 141 if (entry->attributes & Function)157 if (entry->attributes() & Function) 142 158 setUpStaticFunctionSlot(exec, entry, thisObj, propertyName, slot); 143 159 else 144 slot.set StaticEntry(thisObj, entry, staticValueGetter<ThisImp>);160 slot.setCustom(thisObj, entry->propertyGetter()); 145 161 146 162 return true; … … 178 194 return thisObj->ParentImp::getOwnPropertySlot(exec, propertyName, slot); 179 195 180 ASSERT(!(entry->attributes & Function));181 182 slot.set StaticEntry(thisObj, entry, staticValueGetter<ThisImp>);196 ASSERT(!(entry->attributes() & Function)); 197 198 slot.setCustom(thisObj, entry->propertyGetter()); 183 199 return true; 184 200 } … … 197 213 return false; 198 214 199 if (entry->attributes & Function) // function: put as override property215 if (entry->attributes() & Function) // function: put as override property 200 216 thisObj->putDirect(propertyName, value); 201 else if (!(entry->attributes & ReadOnly))202 thisObj->putValueProperty(exec, entry->integerValue, value);217 else if (!(entry->attributes() & ReadOnly)) 218 entry->propertyPutter()(exec, thisObj, value); 203 219 204 220 return true;
Note:
See TracChangeset
for help on using the changeset viewer.