Changeset 128265 in webkit for trunk/Source/JavaScriptCore/runtime
- Timestamp:
- Sep 11, 2012, 11:14:56 PM (13 years ago)
- Location:
- trunk/Source/JavaScriptCore/runtime
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/JavaScriptCore/runtime/Executable.h
r127958 r128265 32 32 #include "JSFunction.h" 33 33 #include "Interpreter.h" 34 #include "JSGlobalObject.h" 34 35 #include "LLIntCLoop.h" 35 36 #include "Nodes.h" … … 754 755 WriteBarrier<SharedSymbolTable> m_symbolTable; 755 756 }; 757 758 inline JSFunction::JSFunction(JSGlobalData& globalData, FunctionExecutable* executable, JSScope* scope) 759 : Base(globalData, scope->globalObject()->functionStructure()) 760 , m_executable(globalData, this, executable) 761 , m_scope(globalData, this, scope) 762 { 763 } 756 764 757 765 inline FunctionExecutable* JSFunction::jsExecutable() const -
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); -
trunk/Source/JavaScriptCore/runtime/JSFunction.h
r127202 r128265 60 60 static JSFunction* create(ExecState* exec, FunctionExecutable* executable, JSScope* scope) 61 61 { 62 JSFunction* function = new (NotNull, allocateCell<JSFunction>(*exec->heap())) JSFunction(exec, executable, scope); 62 JSGlobalData& globalData = exec->globalData(); 63 JSFunction* function = new (NotNull, allocateCell<JSFunction>(globalData.heap)) JSFunction(globalData, executable, scope); 63 64 ASSERT(function->structure()->globalObject()); 64 function->finishCreation( exec, executable, scope);65 function->finishCreation(globalData); 65 66 return function; 66 67 } 67 68 68 JS_EXPORT_PRIVATE const String&name(ExecState*);69 JS_EXPORT_PRIVATE constString displayName(ExecState*);69 JS_EXPORT_PRIVATE String name(ExecState*); 70 JS_EXPORT_PRIVATE String displayName(ExecState*); 70 71 const String calculatedDisplayName(ExecState*); 71 72 … … 138 139 139 140 JS_EXPORT_PRIVATE JSFunction(ExecState*, JSGlobalObject*, Structure*); 140 JSFunction( ExecState*, FunctionExecutable*, JSScope*);141 JSFunction(JSGlobalData&, FunctionExecutable*, JSScope*); 141 142 142 143 void finishCreation(ExecState*, NativeExecutable*, int length, const String& name); 143 void finishCreation(ExecState*, FunctionExecutable*, JSScope*);144 using Base::finishCreation; 144 145 145 146 Structure* cacheInheritorID(ExecState*); … … 164 165 static JSValue callerGetter(ExecState*, JSValue, PropertyName); 165 166 static JSValue lengthGetter(ExecState*, JSValue, PropertyName); 167 static JSValue nameGetter(ExecState*, JSValue, PropertyName); 166 168 167 169 WriteBarrier<ExecutableBase> m_executable;
Note:
See TracChangeset
for help on using the changeset viewer.