Changeset 167199 in webkit for trunk/Source/JavaScriptCore/runtime/JSFunction.cpp
- Timestamp:
- Apr 13, 2014, 11:01:54 AM (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/JavaScriptCore/runtime/JSFunction.cpp
r167165 r167199 34 34 #include "GetterSetter.h" 35 35 #include "JSArray.h" 36 #include "JSBoundFunction.h"37 36 #include "JSFunctionInlines.h" 38 37 #include "JSGlobalObject.h" … … 252 251 class RetrieveCallerFunctionFunctor { 253 252 public: 254 RetrieveCallerFunctionFunctor(JSFunction* functionObj) 255 : m_targetCallee(jsDynamicCast<JSObject*>(functionObj)) 253 RetrieveCallerFunctionFunctor(ExecState* exec, JSFunction* functionObj) 254 : m_exec(exec) 255 , m_targetCallee(jsDynamicCast<JSObject*>(functionObj)) 256 256 , m_hasFoundFrame(false) 257 257 , m_hasSkippedToCallerFrame(false) … … 266 266 JSObject* callee = visitor->callee(); 267 267 268 if (callee && callee-> inherits(JSBoundFunction::info()))268 if (callee && callee->hasOwnProperty(m_exec, m_exec->propertyNames().boundFunctionNamePrivateName)) 269 269 return StackVisitor::Continue; 270 270 … … 284 284 285 285 private: 286 ExecState* m_exec; 286 287 JSObject* m_targetCallee; 287 288 bool m_hasFoundFrame; … … 292 293 static JSValue retrieveCallerFunction(ExecState* exec, JSFunction* functionObj) 293 294 { 294 RetrieveCallerFunctionFunctor functor( functionObj);295 RetrieveCallerFunctionFunctor functor(exec, functionObj); 295 296 exec->iterate(functor); 296 297 return functor.result(); … … 329 330 { 330 331 JSFunction* thisObject = jsCast<JSFunction*>(object); 331 if (thisObject->isHost OrBuiltinFunction())332 if (thisObject->isHostFunction()) 332 333 return Base::getOwnPropertySlot(thisObject, exec, propertyName, slot); 333 334 if (propertyName == exec->propertyNames().prototype) { 334 if (thisObject->isBuiltinFunction()) { 335 if (propertyName == exec->propertyNames().caller) { 336 if (thisObject->jsExecutable()->isStrictMode()) { 337 bool result = Base::getOwnPropertySlot(thisObject, exec, propertyName, slot); 338 if (!result) { 339 thisObject->putDirectAccessor(exec, propertyName, thisObject->globalObject()->throwTypeErrorGetterSetter(exec->vm()), DontDelete | DontEnum | Accessor); 340 result = Base::getOwnPropertySlot(thisObject, exec, propertyName, slot); 341 ASSERT(result); 342 } 343 return result; 344 } 345 slot.setCacheableCustom(thisObject, ReadOnly | DontEnum | DontDelete, callerGetter); 346 return true; 347 } 348 if (propertyName == exec->propertyNames().prototypeForHasInstancePrivateName) { 349 PropertySlot boundFunctionSlot(thisObject); 350 if (Base::getOwnPropertySlot(thisObject, exec, exec->propertyNames().boundFunctionPrivateName, boundFunctionSlot)) { 351 JSValue boundFunction = boundFunctionSlot.getValue(exec, exec->propertyNames().boundFunctionPrivateName); 352 PropertySlot boundPrototypeSlot(asObject(boundFunction)); 353 if (asObject(boundFunction)->getPropertySlot(exec, propertyName, boundPrototypeSlot)) { 354 slot.setValue(boundPrototypeSlot.slotBase(), boundPrototypeSlot.attributes(), boundPrototypeSlot.getValue(exec, propertyName)); 355 return true; 356 } 357 } 358 } 359 if (propertyName == exec->propertyNames().name) { 360 PropertySlot nameSlot(thisObject); 361 if (Base::getOwnPropertySlot(thisObject, exec, exec->vm().propertyNames->boundFunctionNamePrivateName, nameSlot)) { 362 slot.setValue(thisObject, DontEnum | DontDelete | ReadOnly, nameSlot.getValue(exec, exec->vm().propertyNames->boundFunctionNamePrivateName)); 363 return true; 364 } 365 } 366 if (propertyName == exec->propertyNames().length) { 367 PropertySlot lengthSlot(thisObject); 368 if (Base::getOwnPropertySlot(thisObject, exec, exec->vm().propertyNames->boundFunctionLengthPrivateName, lengthSlot)) { 369 slot.setValue(thisObject, DontEnum | DontDelete | ReadOnly, lengthSlot.getValue(exec, exec->vm().propertyNames->boundFunctionLengthPrivateName)); 370 return true; 371 } 372 } 373 374 return Base::getOwnPropertySlot(thisObject, exec, propertyName, slot); 375 } 376 377 if (propertyName == exec->propertyNames().prototype || propertyName == exec->propertyNames().prototypeForHasInstancePrivateName) { 335 378 VM& vm = exec->vm(); 336 379 unsigned attributes; … … 339 382 JSObject* prototype = constructEmptyObject(exec); 340 383 prototype->putDirect(vm, exec->propertyNames().constructor, thisObject, DontEnum); 341 thisObject->putDirect (vm, exec->propertyNames().prototype, prototype, DontDelete | DontEnum);384 thisObject->putDirectPrototypeProperty(vm, prototype, DontDelete | DontEnum); 342 385 offset = thisObject->getDirectOffset(vm, exec->propertyNames().prototype, attributes); 343 386 ASSERT(isValidOffset(offset)); … … 391 434 { 392 435 JSFunction* thisObject = jsCast<JSFunction*>(object); 393 if (!thisObject->isHostOrBuiltinFunction() && (mode == IncludeDontEnumProperties)) { 394 VM& vm = exec->vm(); 395 // Make sure prototype has been reified. 396 PropertySlot slot(thisObject); 397 thisObject->methodTable(vm)->getOwnPropertySlot(thisObject, exec, vm.propertyNames->prototype, slot); 398 399 propertyNames.add(vm.propertyNames->arguments); 400 propertyNames.add(vm.propertyNames->caller); 401 propertyNames.add(vm.propertyNames->length); 402 propertyNames.add(vm.propertyNames->name); 436 if (mode == IncludeDontEnumProperties) { 437 bool shouldIncludeJSFunctionProperties = !thisObject->isHostOrBuiltinFunction(); 438 if (!shouldIncludeJSFunctionProperties && thisObject->isBuiltinFunction()) { 439 PropertySlot boundFunctionSlot(thisObject); 440 shouldIncludeJSFunctionProperties = Base::getOwnPropertySlot(thisObject, exec, exec->propertyNames().boundFunctionPrivateName, boundFunctionSlot); 441 } 442 if (shouldIncludeJSFunctionProperties) { 443 VM& vm = exec->vm(); 444 // Make sure prototype has been reified. 445 PropertySlot slot(thisObject); 446 thisObject->methodTable(vm)->getOwnPropertySlot(thisObject, exec, vm.propertyNames->prototype, slot); 447 448 propertyNames.add(vm.propertyNames->arguments); 449 propertyNames.add(vm.propertyNames->caller); 450 propertyNames.add(vm.propertyNames->length); 451 propertyNames.add(vm.propertyNames->name); 452 } 403 453 } 404 454 Base::getOwnNonIndexPropertyNames(thisObject, exec, propertyNames, mode); … … 420 470 thisObject->m_allocationProfileWatchpoint.fireAll(); 421 471 // Don't allow this to be cached, since a [[Put]] must clear m_allocationProfile. 422 PutPropertySlot dontCache(thisObject); 423 Base::put(thisObject, exec, propertyName, value, dontCache); 472 PutPropertySlot dontCachePrototype(thisObject); 473 Base::put(thisObject, exec, propertyName, value, dontCachePrototype); 474 PutPropertySlot dontCachePrototypeForHasInstance(thisObject); 475 Base::put(thisObject, exec, exec->propertyNames().prototypeForHasInstancePrivateName, value, dontCachePrototypeForHasInstance); 424 476 return; 425 477 } … … 466 518 thisObject->m_allocationProfile.clear(); 467 519 thisObject->m_allocationProfileWatchpoint.fireAll(); 468 return Base::defineOwnProperty(object, exec, propertyName, descriptor, throwException); 520 if (!Base::defineOwnProperty(object, exec, propertyName, descriptor, throwException)) 521 return false; 522 Base::defineOwnProperty(object, exec, exec->propertyNames().prototypeForHasInstancePrivateName, descriptor, throwException); 523 return true; 469 524 } 470 525
Note:
See TracChangeset
for help on using the changeset viewer.