Changeset 167313 in webkit for trunk/Source/JavaScriptCore/runtime/JSFunction.cpp
- Timestamp:
- Apr 15, 2014, 10:46:42 AM (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/JavaScriptCore/runtime/JSFunction.cpp
r167199 r167313 34 34 #include "GetterSetter.h" 35 35 #include "JSArray.h" 36 #include "JSBoundFunction.h" 36 37 #include "JSFunctionInlines.h" 37 38 #include "JSGlobalObject.h" … … 251 252 class RetrieveCallerFunctionFunctor { 252 253 public: 253 RetrieveCallerFunctionFunctor(ExecState* exec, JSFunction* functionObj) 254 : m_exec(exec) 255 , m_targetCallee(jsDynamicCast<JSObject*>(functionObj)) 254 RetrieveCallerFunctionFunctor(JSFunction* functionObj) 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-> hasOwnProperty(m_exec, m_exec->propertyNames().boundFunctionNamePrivateName))268 if (callee && callee->inherits(JSBoundFunction::info())) 269 269 return StackVisitor::Continue; 270 270 … … 284 284 285 285 private: 286 ExecState* m_exec;287 286 JSObject* m_targetCallee; 288 287 bool m_hasFoundFrame; … … 293 292 static JSValue retrieveCallerFunction(ExecState* exec, JSFunction* functionObj) 294 293 { 295 RetrieveCallerFunctionFunctor functor( exec,functionObj);294 RetrieveCallerFunctionFunctor functor(functionObj); 296 295 exec->iterate(functor); 297 296 return functor.result(); … … 330 329 { 331 330 JSFunction* thisObject = jsCast<JSFunction*>(object); 332 if (thisObject->isHost Function())331 if (thisObject->isHostOrBuiltinFunction()) 333 332 return Base::getOwnPropertySlot(thisObject, exec, propertyName, slot); 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) { 333 334 if (propertyName == exec->propertyNames().prototype) { 378 335 VM& vm = exec->vm(); 379 336 unsigned attributes; … … 382 339 JSObject* prototype = constructEmptyObject(exec); 383 340 prototype->putDirect(vm, exec->propertyNames().constructor, thisObject, DontEnum); 384 thisObject->putDirect PrototypeProperty(vm, prototype, DontDelete | DontEnum);341 thisObject->putDirect(vm, exec->propertyNames().prototype, prototype, DontDelete | DontEnum); 385 342 offset = thisObject->getDirectOffset(vm, exec->propertyNames().prototype, attributes); 386 343 ASSERT(isValidOffset(offset)); … … 434 391 { 435 392 JSFunction* thisObject = jsCast<JSFunction*>(object); 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 } 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); 453 403 } 454 404 Base::getOwnNonIndexPropertyNames(thisObject, exec, propertyNames, mode); … … 470 420 thisObject->m_allocationProfileWatchpoint.fireAll(); 471 421 // Don't allow this to be cached, since a [[Put]] must clear m_allocationProfile. 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); 422 PutPropertySlot dontCache(thisObject); 423 Base::put(thisObject, exec, propertyName, value, dontCache); 476 424 return; 477 425 } … … 518 466 thisObject->m_allocationProfile.clear(); 519 467 thisObject->m_allocationProfileWatchpoint.fireAll(); 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; 468 return Base::defineOwnProperty(object, exec, propertyName, descriptor, throwException); 524 469 } 525 470
Note:
See TracChangeset
for help on using the changeset viewer.