Changeset 209080 in webkit
- Timestamp:
- Nov 29, 2016, 11:08:59 AM (8 years ago)
- Location:
- trunk/Source/JavaScriptCore
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
TabularUnified trunk/Source/JavaScriptCore/ChangeLog ¶
r209062 r209080 1 2016-11-29 Mark Lam <mark.lam@apple.com> 2 3 Fix exception scope verification failures in ProxyConstructor.cpp and ProxyObject.cpp. 4 https://bugs.webkit.org/show_bug.cgi?id=165053 5 6 Reviewed by Saam Barati. 7 8 Also replaced returning JSValue() with returning { }. 9 10 * runtime/ProxyConstructor.cpp: 11 (JSC::constructProxyObject): 12 * runtime/ProxyObject.cpp: 13 (JSC::ProxyObject::structureForTarget): 14 (JSC::performProxyGet): 15 (JSC::ProxyObject::performInternalMethodGetOwnProperty): 16 (JSC::ProxyObject::performHasProperty): 17 (JSC::ProxyObject::getOwnPropertySlotCommon): 18 (JSC::ProxyObject::performPut): 19 (JSC::ProxyObject::putByIndexCommon): 20 (JSC::performProxyCall): 21 (JSC::performProxyConstruct): 22 (JSC::ProxyObject::performDelete): 23 (JSC::ProxyObject::performPreventExtensions): 24 (JSC::ProxyObject::performIsExtensible): 25 (JSC::ProxyObject::performDefineOwnProperty): 26 (JSC::ProxyObject::performGetOwnPropertyNames): 27 (JSC::ProxyObject::performSetPrototype): 28 (JSC::ProxyObject::performGetPrototype): 29 1 30 2016-11-28 Matt Baker <mattbaker@apple.com> 2 31 -
TabularUnified trunk/Source/JavaScriptCore/runtime/ProxyConstructor.cpp ¶
r206386 r209080 100 100 JSValue target = args.at(0); 101 101 JSValue handler = args.at(1); 102 scope.release(); 102 103 return JSValue::encode(ProxyObject::create(exec, exec->lexicalGlobalObject(), target, handler)); 103 104 } -
TabularUnified trunk/Source/JavaScriptCore/runtime/ProxyObject.cpp ¶
r206386 r209080 75 75 JSObject* targetAsObject = jsCast<JSObject*>(target); 76 76 CallData ignoredCallData; 77 bool isCallable = targetAsObject->methodTable()->getCallData(targetAsObject, ignoredCallData) != CallType::None; 77 VM& vm = globalObject->vm(); 78 bool isCallable = targetAsObject->methodTable(vm)->getCallData(targetAsObject, ignoredCallData) != CallType::None; 78 79 return isCallable ? globalObject->callableProxyObjectStructure() : globalObject->proxyObjectStructure(); 79 80 } … … 122 123 if (UNLIKELY(!vm.isSafeToRecurseSoft())) { 123 124 throwStackOverflowError(exec, scope); 124 return JSValue();125 return { }; 125 126 } 126 127 … … 131 132 }; 132 133 133 if (vm.propertyNames->isPrivateName(Identifier::fromUid(&vm, propertyName.uid()))) 134 if (vm.propertyNames->isPrivateName(Identifier::fromUid(&vm, propertyName.uid()))) { 135 scope.release(); 134 136 return performDefaultGet(); 137 } 135 138 136 139 JSValue handlerValue = proxyObject->handler(); … … 142 145 CallType callType; 143 146 JSValue getHandler = handler->getMethod(exec, callData, callType, vm.propertyNames->get, ASCIILiteral("'get' property of a Proxy's handler object should be callable")); 144 RETURN_IF_EXCEPTION(scope, JSValue()); 145 146 if (getHandler.isUndefined()) 147 RETURN_IF_EXCEPTION(scope, { }); 148 149 if (getHandler.isUndefined()) { 150 scope.release(); 147 151 return performDefaultGet(); 152 } 148 153 149 154 MarkedArgumentBuffer arguments; … … 152 157 arguments.append(receiver); 153 158 JSValue trapResult = call(exec, getHandler, callType, callData, handler, arguments); 154 RETURN_IF_EXCEPTION(scope, JSValue());159 RETURN_IF_EXCEPTION(scope, { }); 155 160 156 161 PropertyDescriptor descriptor; … … 165 170 } 166 171 167 RETURN_IF_EXCEPTION(scope, JSValue());172 RETURN_IF_EXCEPTION(scope, { }); 168 173 169 174 return trapResult; … … 195 200 }; 196 201 197 if (vm.propertyNames->isPrivateName(Identifier::fromUid(&vm, propertyName.uid()))) 202 if (vm.propertyNames->isPrivateName(Identifier::fromUid(&vm, propertyName.uid()))) { 203 scope.release(); 198 204 return performDefaultGetOwnProperty(); 205 } 199 206 200 207 JSValue handlerValue = this->handler(); … … 209 216 JSValue getOwnPropertyDescriptorMethod = handler->getMethod(exec, callData, callType, makeIdentifier(vm, "getOwnPropertyDescriptor"), ASCIILiteral("'getOwnPropertyDescriptor' property of a Proxy's handler should be callable")); 210 217 RETURN_IF_EXCEPTION(scope, false); 211 if (getOwnPropertyDescriptorMethod.isUndefined()) 218 if (getOwnPropertyDescriptorMethod.isUndefined()) { 219 scope.release(); 212 220 return performDefaultGetOwnProperty(); 221 } 213 222 214 223 MarkedArgumentBuffer arguments; … … 257 266 bool valid = validateAndApplyPropertyDescriptor(exec, nullptr, propertyName, isExtensible, 258 267 trapResultAsDescriptor, isTargetPropertyDescriptorDefined, targetPropertyDescriptor, throwException); 268 RETURN_IF_EXCEPTION(scope, false); 259 269 if (!valid) { 260 270 throwVMTypeError(exec, scope, ASCIILiteral("Result from 'getOwnPropertyDescriptor' fails the IsCompatiblePropertyDescriptor test")); … … 296 306 }; 297 307 298 if (vm.propertyNames->isPrivateName(Identifier::fromUid(&vm, propertyName.uid()))) 308 if (vm.propertyNames->isPrivateName(Identifier::fromUid(&vm, propertyName.uid()))) { 309 scope.release(); 299 310 return performDefaultHasProperty(); 311 } 300 312 301 313 JSValue handlerValue = this->handler(); … … 310 322 JSValue hasMethod = handler->getMethod(exec, callData, callType, vm.propertyNames->has, ASCIILiteral("'has' property of a Proxy's handler should be callable")); 311 323 RETURN_IF_EXCEPTION(scope, false); 312 if (hasMethod.isUndefined()) 324 if (hasMethod.isUndefined()) { 325 scope.release(); 313 326 return performDefaultHasProperty(); 327 } 314 328 315 329 MarkedArgumentBuffer arguments; … … 355 369 switch (slot.internalMethodType()) { 356 370 case PropertySlot::InternalMethodType::Get: 371 scope.release(); 357 372 return performGet(exec, propertyName, slot); 358 373 case PropertySlot::InternalMethodType::GetOwnProperty: 374 scope.release(); 359 375 return performInternalMethodGetOwnProperty(exec, propertyName, slot); 360 376 case PropertySlot::InternalMethodType::HasProperty: 377 scope.release(); 361 378 return performHasProperty(exec, propertyName, slot); 362 379 default: … … 391 408 } 392 409 393 if (vm.propertyNames->isPrivateName(Identifier::fromUid(&vm, propertyName.uid()))) 410 if (vm.propertyNames->isPrivateName(Identifier::fromUid(&vm, propertyName.uid()))) { 411 scope.release(); 394 412 return performDefaultPut(); 413 } 395 414 396 415 JSValue handlerValue = this->handler(); … … 406 425 RETURN_IF_EXCEPTION(scope, false); 407 426 JSObject* target = this->target(); 408 if (setMethod.isUndefined()) 427 if (setMethod.isUndefined()) { 428 scope.release(); 409 429 return performDefaultPut(); 430 } 410 431 411 432 MarkedArgumentBuffer arguments; … … 461 482 return target->methodTable(vm)->put(target, exec, ident.impl(), putValue, slot); 462 483 }; 484 scope.release(); 463 485 return performPut(exec, putValue, thisValue, ident.impl(), performDefaultPut); 464 486 } … … 476 498 if (UNLIKELY(!vm.isSafeToRecurseSoft())) { 477 499 throwStackOverflowError(exec, scope); 478 return JSValue::encode(JSValue());500 return encodedJSValue(); 479 501 } 480 502 ProxyObject* proxy = jsCast<ProxyObject*>(exec->callee()); … … 493 515 CallType callType = target->methodTable(vm)->getCallData(target, callData); 494 516 RELEASE_ASSERT(callType != CallType::None); 517 scope.release(); 495 518 return JSValue::encode(call(exec, target, callType, callData, exec->thisValue(), ArgList(exec))); 496 519 } … … 502 525 arguments.append(exec->thisValue()); 503 526 arguments.append(argArray); 527 scope.release(); 504 528 return JSValue::encode(call(exec, applyMethod, callType, callData, handler, arguments)); 505 529 } … … 524 548 if (UNLIKELY(!vm.isSafeToRecurseSoft())) { 525 549 throwStackOverflowError(exec, scope); 526 return JSValue::encode(JSValue());550 return encodedJSValue(); 527 551 } 528 552 ProxyObject* proxy = jsCast<ProxyObject*>(exec->callee()); … … 541 565 ConstructType constructType = target->methodTable(vm)->getConstructData(target, constructData); 542 566 RELEASE_ASSERT(constructType != ConstructType::None); 567 scope.release(); 543 568 return JSValue::encode(construct(exec, target, constructType, constructData, ArgList(exec), exec->newTarget())); 544 569 } … … 580 605 } 581 606 582 if (vm.propertyNames->isPrivateName(Identifier::fromUid(&vm, propertyName.uid()))) 607 if (vm.propertyNames->isPrivateName(Identifier::fromUid(&vm, propertyName.uid()))) { 608 scope.release(); 583 609 return performDefaultDelete(); 610 } 584 611 585 612 JSValue handlerValue = this->handler(); … … 595 622 RETURN_IF_EXCEPTION(scope, false); 596 623 JSObject* target = this->target(); 597 if (deletePropertyMethod.isUndefined()) 624 if (deletePropertyMethod.isUndefined()) { 625 scope.release(); 598 626 return performDefaultDelete(); 627 } 599 628 600 629 MarkedArgumentBuffer arguments; … … 665 694 RETURN_IF_EXCEPTION(scope, false); 666 695 JSObject* target = this->target(); 667 if (preventExtensionsMethod.isUndefined()) 696 if (preventExtensionsMethod.isUndefined()) { 697 scope.release(); 668 698 return target->methodTable(vm)->preventExtensions(target, exec); 699 } 669 700 670 701 MarkedArgumentBuffer arguments; … … 715 746 716 747 JSObject* target = this->target(); 717 if (isExtensibleMethod.isUndefined()) 748 if (isExtensibleMethod.isUndefined()) { 749 scope.release(); 718 750 return target->isExtensible(exec); 751 } 719 752 720 753 MarkedArgumentBuffer arguments; … … 759 792 JSObject* target = this->target(); 760 793 auto performDefaultDefineOwnProperty = [&] { 794 scope.release(); 761 795 return target->methodTable(vm)->defineOwnProperty(target, exec, propertyName, descriptor, shouldThrow); 762 796 }; … … 822 856 bool throwException = false; 823 857 bool isCompatibleDescriptor = validateAndApplyPropertyDescriptor(exec, nullptr, propertyName, targetIsExtensible, descriptor, isCurrentDefined, current, throwException); 858 RETURN_IF_EXCEPTION(scope, false); 824 859 if (!isCompatibleDescriptor) { 825 860 throwVMTypeError(exec, scope, ASCIILiteral("Proxy's 'defineProperty' trap did not define a property on its target that is compatible with the trap's input descriptor")); … … 861 896 JSObject* target = this->target(); 862 897 if (ownKeysMethod.isUndefined()) { 863 target->methodTable(exec->vm())->getOwnPropertyNames(target, exec, trapResult, enumerationMode); 898 scope.release(); 899 target->methodTable(vm)->getOwnPropertyNames(target, exec, trapResult, enumerationMode); 864 900 return; 865 901 } … … 906 942 907 943 bool targetIsExensible = target->isExtensible(exec); 944 RETURN_IF_EXCEPTION(scope, void()); 908 945 909 946 PropertyNameArray targetKeys(&vm, propertyNameMode); … … 1006 1043 1007 1044 JSObject* target = this->target(); 1008 if (setPrototypeOfMethod.isUndefined()) 1045 if (setPrototypeOfMethod.isUndefined()) { 1046 scope.release(); 1009 1047 return target->setPrototype(vm, exec, prototype, shouldThrowIfCantSet); 1048 } 1010 1049 1011 1050 MarkedArgumentBuffer arguments; … … 1050 1089 if (UNLIKELY(!vm.isSafeToRecurseSoft())) { 1051 1090 throwStackOverflowError(exec, scope); 1052 return JSValue();1091 return { }; 1053 1092 } 1054 1093 … … 1056 1095 if (handlerValue.isNull()) { 1057 1096 throwVMTypeError(exec, scope, ASCIILiteral(s_proxyAlreadyRevokedErrorMessage)); 1058 return JSValue();1097 return { }; 1059 1098 } 1060 1099 … … 1063 1102 CallType callType; 1064 1103 JSValue getPrototypeOfMethod = handler->getMethod(exec, callData, callType, makeIdentifier(vm, "getPrototypeOf"), ASCIILiteral("'getPrototypeOf' property of a Proxy's handler should be callable")); 1065 RETURN_IF_EXCEPTION(scope, JSValue());1104 RETURN_IF_EXCEPTION(scope, { }); 1066 1105 1067 1106 JSObject* target = this->target(); 1068 if (getPrototypeOfMethod.isUndefined()) 1107 if (getPrototypeOfMethod.isUndefined()) { 1108 scope.release(); 1069 1109 return target->getPrototype(vm, exec); 1110 } 1070 1111 1071 1112 MarkedArgumentBuffer arguments; 1072 1113 arguments.append(target); 1073 1114 JSValue trapResult = call(exec, getPrototypeOfMethod, callType, callData, handler, arguments); 1074 RETURN_IF_EXCEPTION(scope, JSValue());1115 RETURN_IF_EXCEPTION(scope, { }); 1075 1116 1076 1117 if (!trapResult.isObject() && !trapResult.isNull()) { 1077 1118 throwVMTypeError(exec, scope, ASCIILiteral("Proxy handler's 'getPrototypeOf' trap should either return an object or null")); 1078 return JSValue();1119 return { }; 1079 1120 } 1080 1121 1081 1122 bool targetIsExtensible = target->isExtensible(exec); 1082 RETURN_IF_EXCEPTION(scope, JSValue());1123 RETURN_IF_EXCEPTION(scope, { }); 1083 1124 if (targetIsExtensible) 1084 1125 return trapResult; 1085 1126 1086 1127 JSValue targetPrototype = target->getPrototype(vm, exec); 1087 RETURN_IF_EXCEPTION(scope, JSValue());1128 RETURN_IF_EXCEPTION(scope, { }); 1088 1129 if (!sameValue(exec, targetPrototype, trapResult)) { 1089 1130 throwVMTypeError(exec, scope, ASCIILiteral("Proxy's 'getPrototypeOf' trap for a non-extensible target should return the same value as the target's prototype")); 1090 return JSValue();1131 return { }; 1091 1132 } 1092 1133
Note:
See TracChangeset
for help on using the changeset viewer.