[Webkit-unassigned] [Bug 184008] New: JSManagedValue doesn't work with primitive values
bugzilla-daemon at webkit.org
bugzilla-daemon at webkit.org
Mon Mar 26 08:56:03 PDT 2018
https://bugs.webkit.org/show_bug.cgi?id=184008
Bug ID: 184008
Summary: JSManagedValue doesn't work with primitive values
Product: WebKit
Version: WebKit Nightly Build
Hardware: Unspecified
OS: Unspecified
Status: NEW
Severity: Normal
Priority: P2
Component: JavaScriptCore
Assignee: webkit-unassigned at lists.webkit.org
Reporter: cgarcia at igalia.com
CC: fpizlo at apple.com, mark.lam at apple.com,
mhahnenb at gmail.com, oliver at apple.com,
utatane.tea at gmail.com
The implementation allows to store primitive values since r157119, but JSManagedValue doesn't return nil for its value after garbage collection in case of primitives. The test case added in r157119 works because the context is destroyed. Is this the expected behavior? See this test case:
@autoreleasepool {
JSContext* context = [[JSContext alloc] init];
JSManagedValue *weakFoo, *weakBar;
@autoreleasepool {
context[@"foo"] = @42;
context[@"bar"] = @"Hello";
JSValue* foo = context[@"foo"];
weakFoo = [JSManagedValue managedValueWithValue:foo];
JSValue* bar = context[@"bar"];
weakBar = [JSManagedValue managedValueWithValue:bar];
}
JSSynchronousGarbageCollectForDebugging([context JSGlobalContextRef]);
@autoreleasepool {
JSValue* value = weakFoo.value;
checkResult(@"foo is 42", value.isNumber && [value toInt32] == 42);
value = weakBar.value;
checkResult(@"bar is Hello", value.isString && [@"Hello" isEqualToString:[value toString]]);
}
[context evaluateScript:@"foo = undefined; bar = undefined;"];
JSSynchronousGarbageCollectForDebugging([context JSGlobalContextRef]);
JSValue* value = weakFoo.value;
checkResult(@"foo is nil", !value);
value = weakBar.value;
checkResult(@"bar is nil", !value);
}
2018-03-26 17:52:12.894 testapi[54452:51379955] TEST: "foo is 42": PASSED
2018-03-26 17:52:12.894 testapi[54452:51379955] TEST: "bar is Hello": PASSED
2018-03-26 17:52:12.894 testapi[54452:51379955] TEST: "foo is nil": FAILED
2018-03-26 17:52:12.894 testapi[54452:51379955] TEST: "bar is nil": PASSED
Is it even possible to support primitive values? I don't think it's possible to use Weak with them, right? Should it be documented that for primitive values it will only work when the context is destroyed?
--
You are receiving this mail because:
You are the assignee for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.webkit.org/pipermail/webkit-unassigned/attachments/20180326/33a04c54/attachment.html>
More information about the webkit-unassigned
mailing list