Changeset 245332 in webkit
- Timestamp:
- May 15, 2019, 11:20:49 AM (7 years ago)
- Location:
- branches/safari-607.2.1.2-branch
- Files:
-
- 1 added
- 8 edited
-
JSTests/ChangeLog (modified) (1 diff)
-
JSTests/stress/check-symbol-description-oom.js (added)
-
Source/JavaScriptCore/API/JSValueRef.cpp (modified) (1 diff)
-
Source/JavaScriptCore/API/tests/testapi.cpp (modified) (4 diffs)
-
Source/JavaScriptCore/ChangeLog (modified) (1 diff)
-
Source/JavaScriptCore/dfg/DFGOperations.cpp (modified) (1 diff)
-
Source/JavaScriptCore/runtime/Symbol.cpp (modified) (1 diff)
-
Source/JavaScriptCore/runtime/Symbol.h (modified) (1 diff)
-
Source/JavaScriptCore/runtime/SymbolConstructor.cpp (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
branches/safari-607.2.1.2-branch/JSTests/ChangeLog
r245331 r245332 1 2019-05-15 Alan Coon <alancoon@apple.com> 2 3 Cherry-pick r244996. rdar://problem/50754980 4 5 [JSC] We should check OOM for description string of Symbol 6 https://bugs.webkit.org/show_bug.cgi?id=197634 7 8 Reviewed by Keith Miller. 9 10 JSTests: 11 12 * stress/check-symbol-description-oom.js: Added. 13 (shouldThrow): 14 15 Source/JavaScriptCore: 16 17 When resoling JSString for description of Symbol, we should check OOM error. 18 We also change JSValueMakeSymbol(..., nullptr) to returning a symbol value 19 without description, (1) to simplify the code and (2) give a way for JSC API 20 to create a symbol value without description. 21 22 * API/JSValueRef.cpp: 23 (JSValueMakeSymbol): 24 * API/tests/testapi.cpp: 25 (TestAPI::symbolsTypeof): 26 (TestAPI::symbolsDescription): 27 (testCAPIViaCpp): 28 * dfg/DFGOperations.cpp: 29 * runtime/Symbol.cpp: 30 (JSC::Symbol::createWithDescription): 31 * runtime/Symbol.h: 32 * runtime/SymbolConstructor.cpp: 33 (JSC::callSymbol): 34 35 git-svn-id: https://svn.webkit.org/repository/webkit/trunk@244996 268f45cc-cd09-0410-ab3c-d52691b4dbfc 36 37 2019-05-06 Yusuke Suzuki <ysuzuki@apple.com> 38 39 [JSC] We should check OOM for description string of Symbol 40 https://bugs.webkit.org/show_bug.cgi?id=197634 41 42 Reviewed by Keith Miller. 43 44 * stress/check-symbol-description-oom.js: Added. 45 (shouldThrow): 46 1 47 2019-05-15 Alan Coon <alancoon@apple.com> 2 48 -
branches/safari-607.2.1.2-branch/Source/JavaScriptCore/API/JSValueRef.cpp
r237009 r245332 331 331 } 332 332 ExecState* exec = toJS(ctx); 333 JSLockHolder locker(exec); 334 auto scope = DECLARE_CATCH_SCOPE(exec->vm()); 335 336 JSString* jsDescription = jsString(exec, description ? description->string() : String()); 337 RETURN_IF_EXCEPTION(scope, nullptr); 338 339 return toRef(exec, Symbol::create(exec, jsDescription)); 333 VM& vm = exec->vm(); 334 JSLockHolder locker(exec); 335 336 if (!description) 337 return toRef(exec, Symbol::create(vm)); 338 return toRef(exec, Symbol::createWithDescription(vm, description->string())); 340 339 } 341 340 -
branches/safari-607.2.1.2-branch/Source/JavaScriptCore/API/tests/testapi.cpp
r236805 r245332 130 130 void basicSymbol(); 131 131 void symbolsTypeof(); 132 void symbolsDescription(); 132 133 void symbolsGetPropertyForKey(); 133 134 void symbolsSetPropertyForKey(); … … 268 269 269 270 static const char* isSymbolFunction = "(function isSymbol(symbol) { return typeof(symbol) === 'symbol'; })"; 271 static const char* getSymbolDescription = "(function getSymbolDescription(symbol) { return symbol.description; })"; 270 272 static const char* getFunction = "(function get(object, key) { return object[key]; })"; 271 273 static const char* setFunction = "(function set(object, key, value) { object[key] = value; })"; … … 281 283 void TestAPI::symbolsTypeof() 282 284 { 283 APIString description("dope"); 284 JSValueRef symbol = JSValueMakeSymbol(context, description); 285 check(functionReturnsTrue(isSymbolFunction, symbol), "JSValueMakeSymbol makes a symbol value"); 285 { 286 JSValueRef symbol = JSValueMakeSymbol(context, nullptr); 287 check(functionReturnsTrue(isSymbolFunction, symbol), "JSValueMakeSymbol makes a symbol value"); 288 } 289 { 290 APIString description("dope"); 291 JSValueRef symbol = JSValueMakeSymbol(context, description); 292 check(functionReturnsTrue(isSymbolFunction, symbol), "JSValueMakeSymbol makes a symbol value"); 293 } 294 } 295 296 void TestAPI::symbolsDescription() 297 { 298 { 299 JSValueRef symbol = JSValueMakeSymbol(context, nullptr); 300 auto result = callFunction(getSymbolDescription, symbol); 301 check(JSValueIsStrictEqual(context, result.value(), JSValueMakeUndefined(context)), "JSValueMakeSymbol with nullptr description produces a symbol value without description"); 302 } 303 { 304 APIString description("dope"); 305 JSValueRef symbol = JSValueMakeSymbol(context, description); 306 auto result = callFunction(getSymbolDescription, symbol); 307 check(JSValueIsStrictEqual(context, result.value(), JSValueMakeString(context, description)), "JSValueMakeSymbol with description string produces a symbol value with description"); 308 } 286 309 } 287 310 … … 495 518 RUN(basicSymbol()); 496 519 RUN(symbolsTypeof()); 520 RUN(symbolsDescription()); 497 521 RUN(symbolsGetPropertyForKey()); 498 522 RUN(symbolsSetPropertyForKey()); -
branches/safari-607.2.1.2-branch/Source/JavaScriptCore/ChangeLog
r245331 r245332 1 2019-05-15 Alan Coon <alancoon@apple.com> 2 3 Cherry-pick r244996. rdar://problem/50754980 4 5 [JSC] We should check OOM for description string of Symbol 6 https://bugs.webkit.org/show_bug.cgi?id=197634 7 8 Reviewed by Keith Miller. 9 10 JSTests: 11 12 * stress/check-symbol-description-oom.js: Added. 13 (shouldThrow): 14 15 Source/JavaScriptCore: 16 17 When resoling JSString for description of Symbol, we should check OOM error. 18 We also change JSValueMakeSymbol(..., nullptr) to returning a symbol value 19 without description, (1) to simplify the code and (2) give a way for JSC API 20 to create a symbol value without description. 21 22 * API/JSValueRef.cpp: 23 (JSValueMakeSymbol): 24 * API/tests/testapi.cpp: 25 (TestAPI::symbolsTypeof): 26 (TestAPI::symbolsDescription): 27 (testCAPIViaCpp): 28 * dfg/DFGOperations.cpp: 29 * runtime/Symbol.cpp: 30 (JSC::Symbol::createWithDescription): 31 * runtime/Symbol.h: 32 * runtime/SymbolConstructor.cpp: 33 (JSC::callSymbol): 34 35 git-svn-id: https://svn.webkit.org/repository/webkit/trunk@244996 268f45cc-cd09-0410-ab3c-d52691b4dbfc 36 37 2019-05-06 Yusuke Suzuki <ysuzuki@apple.com> 38 39 [JSC] We should check OOM for description string of Symbol 40 https://bugs.webkit.org/show_bug.cgi?id=197634 41 42 Reviewed by Keith Miller. 43 44 When resoling JSString for description of Symbol, we should check OOM error. 45 We also change JSValueMakeSymbol(..., nullptr) to returning a symbol value 46 without description, (1) to simplify the code and (2) give a way for JSC API 47 to create a symbol value without description. 48 49 * API/JSValueRef.cpp: 50 (JSValueMakeSymbol): 51 * API/tests/testapi.cpp: 52 (TestAPI::symbolsTypeof): 53 (TestAPI::symbolsDescription): 54 (testCAPIViaCpp): 55 * dfg/DFGOperations.cpp: 56 * runtime/Symbol.cpp: 57 (JSC::Symbol::createWithDescription): 58 * runtime/Symbol.h: 59 * runtime/SymbolConstructor.cpp: 60 (JSC::callSymbol): 61 1 62 2019-05-15 Alan Coon <alancoon@apple.com> 2 63 -
branches/safari-607.2.1.2-branch/Source/JavaScriptCore/dfg/DFGOperations.cpp
r240426 r245332 2273 2273 VM& vm = exec->vm(); 2274 2274 NativeCallFrameTracer tracer(&vm, exec); 2275 2276 return Symbol::create(exec, description); 2275 auto scope = DECLARE_THROW_SCOPE(vm); 2276 2277 String string = description->value(exec); 2278 RETURN_IF_EXCEPTION(scope, nullptr); 2279 2280 return Symbol::createWithDescription(vm, string); 2277 2281 } 2278 2282 -
branches/safari-607.2.1.2-branch/Source/JavaScriptCore/runtime/Symbol.cpp
r235712 r245332 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; -
branches/safari-607.2.1.2-branch/Source/JavaScriptCore/runtime/Symbol.h
r232404 r245332 53 53 54 54 static Symbol* create(VM&); 55 static Symbol* create (ExecState*, JSString* description);55 static Symbol* createWithDescription(VM&, const String&); 56 56 JS_EXPORT_PRIVATE static Symbol* create(VM&, SymbolImpl& uid); 57 57 -
branches/safari-607.2.1.2-branch/Source/JavaScriptCore/runtime/SymbolConstructor.cpp
r233122 r245332 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.