Changeset 37799 in webkit for trunk/JavaScriptCore/kjs
- Timestamp:
- Oct 22, 2008, 5:11:11 PM (17 years ago)
- Location:
- trunk/JavaScriptCore/kjs
- Files:
-
- 19 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/JavaScriptCore/kjs/Arguments.h
r37684 r37799 54 54 class Arguments : public JSObject { 55 55 public: 56 enum ArgumentsParameters { 57 ArgumentsNoParameters 58 }; 56 enum NoParametersType { NoParameters }; 59 57 60 58 Arguments(CallFrame*); 61 Arguments(CallFrame*, enum ArgumentsParameters);59 Arguments(CallFrame*, NoParametersType); 62 60 virtual ~Arguments(); 63 61 … … 74 72 d->activation = activation; 75 73 d->registers = &activation->registerAt(0); 74 } 75 76 static PassRefPtr<StructureID> createStructureID(JSValuePtr prototype) 77 { 78 return StructureID::create(prototype, TypeInfo(ObjectType)); 76 79 } 77 80 … … 154 157 } 155 158 156 inline Arguments::Arguments(CallFrame* callFrame, enum ArgumentsParameters)159 inline Arguments::Arguments(CallFrame* callFrame, NoParametersType) 157 160 : JSObject(callFrame->lexicalGlobalObject()->argumentsStructure()) 158 161 , d(new ArgumentsData) 159 162 { 163 ASSERT(!callFrame->callee()->m_body->parameterCount()); 164 160 165 unsigned numArguments = callFrame->argumentCount() - 1; 161 166 -
trunk/JavaScriptCore/kjs/DatePrototype.h
r36726 r37799 36 36 virtual const ClassInfo* classInfo() const { return &info; } 37 37 static const ClassInfo info; 38 39 static PassRefPtr<StructureID> createStructureID(JSValuePtr prototype) 40 { 41 return StructureID::create(prototype, TypeInfo(ObjectType)); 42 } 38 43 }; 39 44 -
trunk/JavaScriptCore/kjs/FunctionPrototype.h
r37747 r37799 33 33 static PassRefPtr<StructureID> createStructureID(JSValuePtr proto) 34 34 { 35 return StructureID::create(proto, TypeInfo(ObjectType ));35 return StructureID::create(proto, TypeInfo(ObjectType, HasStandardGetOwnPropertySlot)); 36 36 } 37 37 -
trunk/JavaScriptCore/kjs/InternalFunction.h
r37747 r37799 41 41 static PassRefPtr<StructureID> createStructureID(JSValuePtr proto) 42 42 { 43 return StructureID::create(proto, TypeInfo(ObjectType, ImplementsHasInstance ));43 return StructureID::create(proto, TypeInfo(ObjectType, ImplementsHasInstance | HasStandardGetOwnPropertySlot)); 44 44 } 45 45 -
trunk/JavaScriptCore/kjs/JSArray.h
r37684 r37799 77 77 void fillArgList(ExecState*, ArgList&); 78 78 79 static PassRefPtr<StructureID> createStructureID(JSValuePtr prototype) 80 { 81 return StructureID::create(prototype, TypeInfo(ObjectType)); 82 } 83 79 84 protected: 80 85 virtual void put(ExecState*, const Identifier& propertyName, JSValuePtr, PutPropertySlot&); -
trunk/JavaScriptCore/kjs/JSCell.h
r37714 r37799 100 100 101 101 private: 102 // Base implementation, but for non-object classes implements getPropertySlot. 102 // Base implementation; for non-object classes implements getPropertySlot. 103 bool fastGetOwnPropertySlot(ExecState*, const Identifier& propertyName, PropertySlot&); 103 104 virtual bool getOwnPropertySlot(ExecState*, const Identifier& propertyName, PropertySlot&); 104 105 virtual bool getOwnPropertySlot(ExecState*, unsigned propertyName, PropertySlot&); -
trunk/JavaScriptCore/kjs/JSFunction.h
r37684 r37799 69 69 RefPtr<FunctionBodyNode> m_body; 70 70 71 static PassRefPtr<StructureID> createStructureID(JSValuePtr prototype) 72 { 73 return StructureID::create(prototype, TypeInfo(ObjectType, ImplementsHasInstance)); 74 } 75 71 76 private: 72 77 virtual const ClassInfo* classInfo() const { return &info; } -
trunk/JavaScriptCore/kjs/JSGlobalData.cpp
r37705 r37799 35 35 #include "JSClassRef.h" 36 36 #include "JSLock.h" 37 #include "JSNotAnObject.h" 37 38 #include "JSStaticScopeObject.h" 38 39 #include "Machine.h" … … 69 70 , regExpConstructorTable(new HashTable(JSC::regExpConstructorTable)) 70 71 , stringTable(new HashTable(JSC::stringTable)) 71 , nullProtoStructureID(JSObject::createStructureID(jsNull()))72 72 , activationStructureID(JSActivation::createStructureID(jsNull())) 73 , interruptedExecutionErrorStructure(JSObject::createStructureID(jsNull())) 73 74 , staticScopeStructureID(JSStaticScopeObject::createStructureID(jsNull())) 74 75 , stringStructureID(JSString::createStructureID(jsNull())) 76 , notAnObjectErrorStubStructure(JSNotAnObjectErrorStub::createStructureID(jsNull())) 77 , notAnObjectStructure(JSNotAnObject::createStructureID(jsNull())) 75 78 , numberStructureID(JSNumberCell::createStructureID(jsNull())) 76 79 , identifierTable(createIdentifierTable()) -
trunk/JavaScriptCore/kjs/JSGlobalData.h
r37684 r37799 79 79 const HashTable* stringTable; 80 80 81 RefPtr<StructureID> nullProtoStructureID;82 81 RefPtr<StructureID> activationStructureID; 82 RefPtr<StructureID> interruptedExecutionErrorStructure; 83 83 RefPtr<StructureID> staticScopeStructureID; 84 84 RefPtr<StructureID> stringStructureID; 85 RefPtr<StructureID> notAnObjectErrorStubStructure; 86 RefPtr<StructureID> notAnObjectStructure; 85 87 RefPtr<StructureID> numberStructureID; 86 88 -
trunk/JavaScriptCore/kjs/JSGlobalObject.h
r37759 r37799 252 252 JSGlobalObjectData* d() const { return static_cast<JSGlobalObjectData*>(JSVariableObject::d); } 253 253 254 static PassRefPtr<StructureID> createStructureID(JSValuePtr prototype) 255 { 256 return StructureID::create(prototype, TypeInfo(ObjectType)); 257 } 258 254 259 protected: 255 260 struct GlobalPropertyInfo { -
trunk/JavaScriptCore/kjs/JSNotAnObject.h
r37684 r37799 37 37 public: 38 38 JSNotAnObjectErrorStub(ExecState* exec, bool isNull) 39 : JSObject(exec->globalData().n ullProtoStructureID)39 : JSObject(exec->globalData().notAnObjectErrorStubStructure) 40 40 , m_isNull(isNull) 41 41 { 42 42 } 43 43 44 bool isNull() const { return m_isNull; } 44 bool isNotAnObjectErrorStub() const { return true; } 45 45 46 private: 47 virtual bool isNotAnObjectErrorStub() const { return true; } 48 46 49 bool m_isNull; 47 50 }; … … 53 56 public: 54 57 JSNotAnObject(ExecState* exec, JSNotAnObjectErrorStub* exception) 55 : JSObject(exec->globalData().n ullProtoStructureID)58 : JSObject(exec->globalData().notAnObjectStructure) 56 59 , m_exception(exception) 57 60 { 61 } 62 63 static PassRefPtr<StructureID> createStructureID(JSValuePtr prototype) 64 { 65 return StructureID::create(prototype, TypeInfo(ObjectType)); 58 66 } 59 67 -
trunk/JavaScriptCore/kjs/JSObject.h
r37747 r37799 56 56 friend class BatchedTransitionOptimizer; 57 57 friend class CTI; 58 friend class JSCell; 58 59 59 60 public: … … 184 185 static const size_t nonInlineBaseStorageCapacity = 16; 185 186 186 static PassRefPtr<StructureID> createStructureID(JSValuePtr proto) { return StructureID::create(proto, TypeInfo(ObjectType)); } 187 static PassRefPtr<StructureID> createStructureID(JSValuePtr prototype) 188 { 189 return StructureID::create(prototype, TypeInfo(ObjectType, HasStandardGetOwnPropertySlot)); 190 } 187 191 188 192 protected: … … 190 194 191 195 private: 196 bool inlineGetOwnPropertySlot(ExecState*, const Identifier& propertyName, PropertySlot&); 197 192 198 const HashEntry* findPropertyHashEntry(ExecState*, const Identifier& propertyName) const; 193 199 StructureID* createInheritorID(); … … 267 273 } 268 274 269 inline JSValuePtr JSObject::get(ExecState* exec, const Identifier& propertyName) const 270 { 271 PropertySlot slot(this); 272 if (const_cast<JSObject*>(this)->getPropertySlot(exec, propertyName, slot)) 273 return slot.getValue(exec, propertyName); 274 275 return jsUndefined(); 276 } 277 278 inline JSValuePtr JSObject::get(ExecState* exec, unsigned propertyName) const 279 { 280 PropertySlot slot(this); 281 if (const_cast<JSObject*>(this)->getPropertySlot(exec, propertyName, slot)) 282 return slot.getValue(exec, propertyName); 283 284 return jsUndefined(); 285 } 286 287 // It may seem crazy to inline a function this large but it makes a big difference 288 // since this is function very hot in variable lookup 289 inline bool JSObject::getPropertySlot(ExecState* exec, const Identifier& propertyName, PropertySlot& slot) 290 { 291 JSObject* object = this; 292 while (true) { 293 if (object->getOwnPropertySlot(exec, propertyName, slot)) 294 return true; 295 296 JSValuePtr prototype = object->prototype(); 297 if (!prototype->isObject()) 298 return false; 299 300 object = asObject(prototype); 301 } 302 } 303 304 inline bool JSObject::getPropertySlot(ExecState* exec, unsigned propertyName, PropertySlot& slot) 305 { 306 JSObject* object = this; 307 308 while (true) { 309 if (object->getOwnPropertySlot(exec, propertyName, slot)) 310 return true; 311 312 JSValuePtr prototype = object->prototype(); 313 if (!prototype->isObject()) 314 break; 315 316 object = asObject(prototype); 275 ALWAYS_INLINE bool JSObject::inlineGetOwnPropertySlot(ExecState* exec, const Identifier& propertyName, PropertySlot& slot) 276 { 277 if (JSValuePtr* location = getDirectLocation(propertyName)) { 278 if (m_structureID->hasGetterSetterProperties() && location[0]->isGetterSetter()) 279 fillGetterPropertySlot(slot, location); 280 else 281 slot.setValueSlot(this, location, offsetForLocation(location)); 282 return true; 283 } 284 285 // non-standard Netscape extension 286 if (propertyName == exec->propertyNames().underscoreProto) { 287 slot.setValue(prototype()); 288 return true; 317 289 } 318 290 … … 320 292 } 321 293 322 // It may seem crazy to inline a function this large, especially a virtual function,323 // but it makes a big difference to property lookup that derived classes can inline their324 // base class call to this.325 294 ALWAYS_INLINE bool JSObject::getOwnPropertySlotForWrite(ExecState* exec, const Identifier& propertyName, PropertySlot& slot, bool& slotIsWriteable) 326 295 { … … 352 321 ALWAYS_INLINE bool JSObject::getOwnPropertySlot(ExecState* exec, const Identifier& propertyName, PropertySlot& slot) 353 322 { 354 if (JSValuePtr* location = getDirectLocation(propertyName)) { 355 if (m_structureID->hasGetterSetterProperties() && location[0]->isGetterSetter()) 356 fillGetterPropertySlot(slot, location); 357 else 358 slot.setValueSlot(this, location, offsetForLocation(location)); 359 return true; 360 } 361 362 // non-standard Netscape extension 363 if (propertyName == exec->propertyNames().underscoreProto) { 364 slot.setValue(prototype()); 365 return true; 366 } 367 368 return false; 323 return inlineGetOwnPropertySlot(exec, propertyName, slot); 324 } 325 326 ALWAYS_INLINE bool JSCell::fastGetOwnPropertySlot(ExecState* exec, const Identifier& propertyName, PropertySlot& slot) 327 { 328 if (structureID()->typeInfo().hasStandardGetOwnPropertySlot()) 329 return asObject(this)->inlineGetOwnPropertySlot(exec, propertyName, slot); 330 return getOwnPropertySlot(exec, propertyName, slot); 331 } 332 333 // It may seem crazy to inline a function this large but it makes a big difference 334 // since this is function very hot in variable lookup 335 inline bool JSObject::getPropertySlot(ExecState* exec, const Identifier& propertyName, PropertySlot& slot) 336 { 337 JSObject* object = this; 338 while (true) { 339 if (object->fastGetOwnPropertySlot(exec, propertyName, slot)) 340 return true; 341 JSValuePtr prototype = object->prototype(); 342 if (!prototype->isObject()) 343 return false; 344 object = asObject(prototype); 345 } 346 } 347 348 inline bool JSObject::getPropertySlot(ExecState* exec, unsigned propertyName, PropertySlot& slot) 349 { 350 JSObject* object = this; 351 while (true) { 352 if (object->getOwnPropertySlot(exec, propertyName, slot)) 353 return true; 354 JSValuePtr prototype = object->prototype(); 355 if (!prototype->isObject()) 356 return false; 357 object = asObject(prototype); 358 } 359 } 360 361 inline JSValuePtr JSObject::get(ExecState* exec, const Identifier& propertyName) const 362 { 363 PropertySlot slot(this); 364 if (const_cast<JSObject*>(this)->getPropertySlot(exec, propertyName, slot)) 365 return slot.getValue(exec, propertyName); 366 367 return jsUndefined(); 368 } 369 370 inline JSValuePtr JSObject::get(ExecState* exec, unsigned propertyName) const 371 { 372 PropertySlot slot(this); 373 if (const_cast<JSObject*>(this)->getPropertySlot(exec, propertyName, slot)) 374 return slot.getValue(exec, propertyName); 375 376 return jsUndefined(); 369 377 } 370 378 … … 462 470 JSCell* cell = asCell(); 463 471 while (true) { 464 if (cell-> getOwnPropertySlot(exec, propertyName, slot))472 if (cell->fastGetOwnPropertySlot(exec, propertyName, slot)) 465 473 return slot.getValue(exec, propertyName); 466 474 ASSERT(cell->isObject()); -
trunk/JavaScriptCore/kjs/JSWrapperObject.h
r37705 r37799 30 30 // Number, Boolean and Date which are wrappers for primitive types. 31 31 class JSWrapperObject : public JSObject { 32 protected: 33 explicit JSWrapperObject(PassRefPtr<StructureID>); 34 32 35 public: 33 explicit JSWrapperObject(PassRefPtr<StructureID>);34 35 36 JSValuePtr internalValue() const { return m_internalValue; } 36 37 void setInternalValue(JSValuePtr); -
trunk/JavaScriptCore/kjs/MathObject.h
r36726 r37799 1 1 /* 2 2 * Copyright (C) 1999-2000 Harri Porten ([email protected]) 3 * Copyright (C) 2008 Apple Inc. All rights reserved. 3 4 * 4 5 * This library is free software; you can redistribute it and/or … … 33 34 virtual const ClassInfo* classInfo() const { return &info; } 34 35 static const ClassInfo info; 36 37 static PassRefPtr<StructureID> createStructureID(JSValuePtr prototype) 38 { 39 return StructureID::create(prototype, TypeInfo(ObjectType)); 40 } 35 41 }; 36 42 -
trunk/JavaScriptCore/kjs/NumberConstructor.h
r37684 r37799 32 32 NumberConstructor(ExecState*, PassRefPtr<StructureID>, NumberPrototype*); 33 33 34 bool getOwnPropertySlot(ExecState*, const Identifier&, PropertySlot&);34 virtual bool getOwnPropertySlot(ExecState*, const Identifier&, PropertySlot&); 35 35 JSValuePtr getValueProperty(ExecState*, int token) const; 36 36 37 37 static const ClassInfo info; 38 39 static PassRefPtr<StructureID> createStructureID(JSValuePtr proto) 40 { 41 return StructureID::create(proto, TypeInfo(ObjectType, ImplementsHasInstance)); 42 } 38 43 39 44 enum { NaNValue, NegInfinity, PosInfinity, MaxValue, MinValue }; -
trunk/JavaScriptCore/kjs/RegExpConstructor.h
r37684 r37799 34 34 public: 35 35 RegExpConstructor(ExecState*, PassRefPtr<StructureID>, RegExpPrototype*); 36 37 static PassRefPtr<StructureID> createStructureID(JSValuePtr prototype) 38 { 39 return StructureID::create(prototype, TypeInfo(ObjectType, ImplementsHasInstance)); 40 } 36 41 37 42 virtual void put(ExecState*, const Identifier& propertyName, JSValuePtr, PutPropertySlot&); -
trunk/JavaScriptCore/kjs/RegExpObject.h
r37684 r37799 47 47 static const ClassInfo info; 48 48 49 static PassRefPtr<StructureID> createStructureID(JSValuePtr prototype) 50 { 51 return StructureID::create(prototype, TypeInfo(ObjectType)); 52 } 53 49 54 private: 50 55 bool match(ExecState*, const ArgList&); -
trunk/JavaScriptCore/kjs/StringObject.h
r37684 r37799 46 46 JSString* internalValue() const { return asString(JSWrapperObject::internalValue());} 47 47 48 static PassRefPtr<StructureID> createStructureID(JSValuePtr prototype) 49 { 50 return StructureID::create(prototype, TypeInfo(ObjectType)); 51 } 52 48 53 protected: 49 54 StringObject(PassRefPtr<StructureID>, JSString*); -
trunk/JavaScriptCore/kjs/TypeInfo.h
r37285 r37799 32 32 namespace JSC { 33 33 34 // WebCore uses thisto make document.all and style.filter undetectable.34 // WebCore uses MasqueradesAsUndefined to make document.all and style.filter undetectable. 35 35 static const unsigned MasqueradesAsUndefined = 1; 36 36 static const unsigned ImplementsHasInstance = 1 << 1; 37 37 static const unsigned OverridesHasInstance = 1 << 2; 38 38 static const unsigned NeedsThisConversion = 1 << 3; 39 static const unsigned HasStandardGetOwnPropertySlot = 1 << 4; 39 40 40 41 class TypeInfo { … … 49 50 bool overridesHasInstance() const { return m_flags & OverridesHasInstance; } 50 51 bool needsThisConversion() const { return m_flags & NeedsThisConversion; } 52 bool hasStandardGetOwnPropertySlot() const { return m_flags & HasStandardGetOwnPropertySlot; } 51 53 52 54 unsigned flags() const { return m_flags; } 55 53 56 private: 54 57 JSType m_type;
Note:
See TracChangeset
for help on using the changeset viewer.