Changeset 128265 in webkit for trunk/Source/JavaScriptCore/runtime/JSFunction.cpp
- Timestamp:
- Sep 11, 2012, 11:14:56 PM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/JavaScriptCore/runtime/JSFunction.cpp
r127958 r128265 85 85 } 86 86 87 JSFunction::JSFunction(ExecState* exec, FunctionExecutable* executable, JSScope* scope)88 : Base(exec->globalData(), scope->globalObject()->functionStructure())89 , m_executable(exec->globalData(), this, executable)90 , m_scope(exec->globalData(), this, scope)91 {92 }93 94 87 void JSFunction::finishCreation(ExecState* exec, NativeExecutable* executable, int length, const String& name) 95 88 { … … 99 92 putDirect(exec->globalData(), exec->globalData().propertyNames->name, jsString(exec, name), DontDelete | ReadOnly | DontEnum); 100 93 putDirect(exec->globalData(), exec->propertyNames().length, jsNumber(length), DontDelete | ReadOnly | DontEnum); 101 }102 103 void JSFunction::finishCreation(ExecState* exec, FunctionExecutable* executable, JSScope* scope)104 {105 JSGlobalData& globalData = exec->globalData();106 Base::finishCreation(globalData);107 ASSERT(inherits(&s_info));108 109 // Switching the structure here is only safe if we currently have the function structure!110 ASSERT(structure() == scope->globalObject()->functionStructure());111 setStructureAndReallocateStorageIfNecessary(112 globalData,113 scope->globalObject()->namedFunctionStructure());114 putDirectOffset(globalData, scope->globalObject()->functionNameOffset(), executable->nameValue());115 94 } 116 95 … … 125 104 } 126 105 127 const String&JSFunction::name(ExecState* exec)128 { 129 return asString(getDirect(exec->globalData(), exec->globalData().propertyNames->name))->tryGetValue();130 } 131 132 constString JSFunction::displayName(ExecState* exec)106 String JSFunction::name(ExecState* exec) 107 { 108 return get(exec, exec->globalData().propertyNames->name).toWTFString(exec); 109 } 110 111 String JSFunction::displayName(ExecState* exec) 133 112 { 134 113 JSValue displayName = getDirect(exec->globalData(), exec->globalData().propertyNames->displayName); … … 214 193 } 215 194 195 JSValue JSFunction::nameGetter(ExecState*, JSValue slotBase, PropertyName) 196 { 197 JSFunction* thisObj = jsCast<JSFunction*>(slotBase); 198 ASSERT(!thisObj->isHostFunction()); 199 return thisObj->jsExecutable()->nameValue(); 200 } 201 216 202 bool JSFunction::getOwnPropertySlot(JSCell* cell, ExecState* exec, PropertyName propertyName, PropertySlot& slot) 217 203 { … … 252 238 } 253 239 240 if (propertyName == exec->propertyNames().name) { 241 slot.setCacheableCustom(thisObject, nameGetter); 242 return true; 243 } 244 254 245 if (propertyName == exec->propertyNames().caller) { 255 246 if (thisObject->jsExecutable()->isStrictMode()) { … … 300 291 } 301 292 293 if (propertyName == exec->propertyNames().name) { 294 descriptor.setDescriptor(thisObject->jsExecutable()->nameValue(), ReadOnly | DontEnum | DontDelete); 295 return true; 296 } 297 302 298 if (propertyName == exec->propertyNames().caller) { 303 299 if (thisObject->jsExecutable()->isStrictMode()) { … … 328 324 propertyNames.add(exec->propertyNames().caller); 329 325 propertyNames.add(exec->propertyNames().length); 326 propertyNames.add(exec->propertyNames().name); 330 327 } 331 328 Base::getOwnPropertyNames(thisObject, exec, propertyNames, mode); … … 357 354 return; 358 355 } 359 if (propertyName == exec->propertyNames().arguments || propertyName == exec->propertyNames().length || propertyName == exec->propertyNames(). caller) {356 if (propertyName == exec->propertyNames().arguments || propertyName == exec->propertyNames().length || propertyName == exec->propertyNames().name || propertyName == exec->propertyNames().caller) { 360 357 if (slot.isStrictMode()) 361 358 throwTypeError(exec, StrictModeReadonlyPropertyWriteError); … … 372 369 && (propertyName == exec->propertyNames().arguments 373 370 || propertyName == exec->propertyNames().length 371 || propertyName == exec->propertyNames().name 374 372 || propertyName == exec->propertyNames().prototype 375 373 || propertyName == exec->propertyNames().caller)) … … 410 408 } else if (propertyName == exec->propertyNames().length) 411 409 valueCheck = !descriptor.value() || sameValue(exec, descriptor.value(), jsNumber(thisObject->jsExecutable()->parameterCount())); 410 else if (propertyName == exec->propertyNames().name) 411 valueCheck = !descriptor.value() || sameValue(exec, descriptor.value(), thisObject->jsExecutable()->nameValue()); 412 412 else 413 413 return Base::defineOwnProperty(object, exec, propertyName, descriptor, throwException);
Note:
See TracChangeset
for help on using the changeset viewer.