Changeset 244996 in webkit
- Timestamp:
- May 6, 2019 5:29:09 PM (5 years ago)
- Location:
- trunk
- Files:
-
- 1 added
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/JSTests/ChangeLog
r244981 r244996 1 2019-05-06 Yusuke Suzuki <ysuzuki@apple.com> 2 3 [JSC] We should check OOM for description string of Symbol 4 https://bugs.webkit.org/show_bug.cgi?id=197634 5 6 Reviewed by Keith Miller. 7 8 * stress/check-symbol-description-oom.js: Added. 9 (shouldThrow): 10 1 11 2019-05-06 Yusuke Suzuki <ysuzuki@apple.com> 2 12 -
trunk/Source/JavaScriptCore/API/JSValueRef.cpp
r244088 r244996 332 332 } 333 333 ExecState* exec = toJS(ctx); 334 JSLockHolder locker(exec); 335 auto scope = DECLARE_CATCH_SCOPE(exec->vm()); 336 337 JSString* jsDescription = jsString(exec, description ? description->string() : String()); 338 RETURN_IF_EXCEPTION(scope, nullptr); 339 340 return toRef(exec, Symbol::create(exec, jsDescription)); 334 VM& vm = exec->vm(); 335 JSLockHolder locker(exec); 336 337 if (!description) 338 return toRef(exec, Symbol::create(vm)); 339 return toRef(exec, Symbol::createWithDescription(vm, description->string())); 341 340 } 342 341 -
trunk/Source/JavaScriptCore/API/tests/testapi.cpp
r244694 r244996 131 131 void basicSymbol(); 132 132 void symbolsTypeof(); 133 void symbolsDescription(); 133 134 void symbolsGetPropertyForKey(); 134 135 void symbolsSetPropertyForKey(); … … 269 270 270 271 static const char* isSymbolFunction = "(function isSymbol(symbol) { return typeof(symbol) === 'symbol'; })"; 272 static const char* getSymbolDescription = "(function getSymbolDescription(symbol) { return symbol.description; })"; 271 273 static const char* getFunction = "(function get(object, key) { return object[key]; })"; 272 274 static const char* setFunction = "(function set(object, key, value) { object[key] = value; })"; … … 282 284 void TestAPI::symbolsTypeof() 283 285 { 284 APIString description("dope"); 285 JSValueRef symbol = JSValueMakeSymbol(context, description); 286 check(functionReturnsTrue(isSymbolFunction, symbol), "JSValueMakeSymbol makes a symbol value"); 286 { 287 JSValueRef symbol = JSValueMakeSymbol(context, nullptr); 288 check(functionReturnsTrue(isSymbolFunction, symbol), "JSValueMakeSymbol makes a symbol value"); 289 } 290 { 291 APIString description("dope"); 292 JSValueRef symbol = JSValueMakeSymbol(context, description); 293 check(functionReturnsTrue(isSymbolFunction, symbol), "JSValueMakeSymbol makes a symbol value"); 294 } 295 } 296 297 void TestAPI::symbolsDescription() 298 { 299 { 300 JSValueRef symbol = JSValueMakeSymbol(context, nullptr); 301 auto result = callFunction(getSymbolDescription, symbol); 302 check(JSValueIsStrictEqual(context, result.value(), JSValueMakeUndefined(context)), "JSValueMakeSymbol with nullptr description produces a symbol value without description"); 303 } 304 { 305 APIString description("dope"); 306 JSValueRef symbol = JSValueMakeSymbol(context, description); 307 auto result = callFunction(getSymbolDescription, symbol); 308 check(JSValueIsStrictEqual(context, result.value(), JSValueMakeString(context, description)), "JSValueMakeSymbol with description string produces a symbol value with description"); 309 } 287 310 } 288 311 … … 492 515 RUN(basicSymbol()); 493 516 RUN(symbolsTypeof()); 517 RUN(symbolsDescription()); 494 518 RUN(symbolsGetPropertyForKey()); 495 519 RUN(symbolsSetPropertyForKey()); -
trunk/Source/JavaScriptCore/ChangeLog
r244987 r244996 1 2019-05-06 Yusuke Suzuki <ysuzuki@apple.com> 2 3 [JSC] We should check OOM for description string of Symbol 4 https://bugs.webkit.org/show_bug.cgi?id=197634 5 6 Reviewed by Keith Miller. 7 8 When resoling JSString for description of Symbol, we should check OOM error. 9 We also change JSValueMakeSymbol(..., nullptr) to returning a symbol value 10 without description, (1) to simplify the code and (2) give a way for JSC API 11 to create a symbol value without description. 12 13 * API/JSValueRef.cpp: 14 (JSValueMakeSymbol): 15 * API/tests/testapi.cpp: 16 (TestAPI::symbolsTypeof): 17 (TestAPI::symbolsDescription): 18 (testCAPIViaCpp): 19 * dfg/DFGOperations.cpp: 20 * runtime/Symbol.cpp: 21 (JSC::Symbol::createWithDescription): 22 * runtime/Symbol.h: 23 * runtime/SymbolConstructor.cpp: 24 (JSC::callSymbol): 25 1 26 2019-05-06 Keith Rollin <krollin@apple.com> 2 27 -
trunk/Source/JavaScriptCore/dfg/DFGOperations.cpp
r244764 r244996 2292 2292 VM& vm = exec->vm(); 2293 2293 NativeCallFrameTracer tracer(&vm, exec); 2294 2295 return Symbol::create(exec, description); 2294 auto scope = DECLARE_THROW_SCOPE(vm); 2295 2296 String string = description->value(exec); 2297 RETURN_IF_EXCEPTION(scope, nullptr); 2298 2299 return Symbol::createWithDescription(vm, string); 2296 2300 } 2297 2301 -
trunk/Source/JavaScriptCore/runtime/Symbol.cpp
r242991 r244996 117 117 } 118 118 119 Symbol* Symbol::create (ExecState* exec, JSString*description)119 Symbol* Symbol::createWithDescription(VM& vm, const String& description) 120 120 { 121 VM& vm = exec->vm(); 122 String desc = description->value(exec); 123 Symbol* symbol = new (NotNull, allocateCell<Symbol>(vm.heap)) Symbol(vm, desc); 121 Symbol* symbol = new (NotNull, allocateCell<Symbol>(vm.heap)) Symbol(vm, description); 124 122 symbol->finishCreation(vm); 125 123 return symbol; -
trunk/Source/JavaScriptCore/runtime/Symbol.h
r242991 r244996 47 47 48 48 static Symbol* create(VM&); 49 static Symbol* create (ExecState*, JSString* description);49 static Symbol* createWithDescription(VM&, const String&); 50 50 JS_EXPORT_PRIVATE static Symbol* create(VM&, SymbolImpl& uid); 51 51 -
trunk/Source/JavaScriptCore/runtime/SymbolConstructor.cpp
r242991 r244996 80 80 static EncodedJSValue JSC_HOST_CALL callSymbol(ExecState* exec) 81 81 { 82 VM& vm = exec->vm(); 83 auto scope = DECLARE_THROW_SCOPE(vm); 84 82 85 JSValue description = exec->argument(0); 83 86 if (description.isUndefined()) 84 return JSValue::encode(Symbol::create(exec->vm())); 85 return JSValue::encode(Symbol::create(exec, description.toString(exec))); 87 return JSValue::encode(Symbol::create(vm)); 88 89 String string = description.toWTFString(exec); 90 RETURN_IF_EXCEPTION(scope, { }); 91 return JSValue::encode(Symbol::createWithDescription(vm, string)); 86 92 } 87 93
Note: See TracChangeset
for help on using the changeset viewer.