RESOLVED FIXED168320
[JSC] Drop PassRefPtr
https://bugs.webkit.org/show_bug.cgi?id=168320
Summary [JSC] Drop PassRefPtr
Yusuke Suzuki
Reported 2017-02-14 08:01:18 PST
[JSC] Drop PassRefPtr
Attachments
Patch (110.86 KB, patch)
2017-02-14 08:01 PST, Yusuke Suzuki
no flags
Patch (113.71 KB, patch)
2017-02-14 08:44 PST, Yusuke Suzuki
no flags
Patch (115.96 KB, patch)
2017-02-14 10:57 PST, Yusuke Suzuki
saam: review+
Patch for landing (115.96 KB, patch)
2017-02-15 06:31 PST, Yusuke Suzuki
no flags
Patch for landing (115.97 KB, patch)
2017-02-15 06:34 PST, Yusuke Suzuki
no flags
Patch (4.73 KB, patch)
2017-02-16 11:49 PST, Yusuke Suzuki
no flags
Yusuke Suzuki
Comment 1 2017-02-14 08:01:51 PST
WebKit Commit Bot
Comment 2 2017-02-14 08:06:52 PST
Attachment 301502 [details] did not pass style-queue: ERROR: Source/JavaScriptCore/bytecode/ProgramCodeBlock.h:72: Wrong number of spaces before statement. (expected: 12) [whitespace/indent] [4] ERROR: Source/JavaScriptCore/bytecode/CodeBlock.cpp:1915: Wrong number of spaces before statement. (expected: 8) [whitespace/indent] [4] ERROR: Source/JavaScriptCore/bytecode/FunctionCodeBlock.h:72: Wrong number of spaces before statement. (expected: 12) [whitespace/indent] [4] ERROR: Source/JavaScriptCore/bytecode/EvalCodeBlock.h:74: Wrong number of spaces before statement. (expected: 12) [whitespace/indent] [4] ERROR: Source/JavaScriptCore/bytecode/ModuleProgramCodeBlock.h:72: Wrong number of spaces before statement. (expected: 12) [whitespace/indent] [4] ERROR: Source/JavaScriptCore/runtime/NativeExecutable.h:42: The parameter name "function" adds no information, so it should be removed. [readability/parameter_name] [5] ERROR: Source/JavaScriptCore/runtime/Structure.h:594: 'toStructureShape' is incorrectly named. It should be named 'protector' or 'protectedJSValue'. [readability/naming/protected] [4] Total errors found: 7 in 68 files If any of these errors are false positives, please file a bug against check-webkit-style.
Yusuke Suzuki
Comment 3 2017-02-14 08:44:04 PST
WebKit Commit Bot
Comment 4 2017-02-14 09:37:22 PST
Attachment 301506 [details] did not pass style-queue: ERROR: Source/JavaScriptCore/bytecode/ProgramCodeBlock.h:72: Wrong number of spaces before statement. (expected: 12) [whitespace/indent] [4] ERROR: Source/JavaScriptCore/bytecode/CodeBlock.cpp:1915: Wrong number of spaces before statement. (expected: 8) [whitespace/indent] [4] ERROR: Source/JavaScriptCore/bytecode/FunctionCodeBlock.h:72: Wrong number of spaces before statement. (expected: 12) [whitespace/indent] [4] ERROR: Source/JavaScriptCore/bytecode/EvalCodeBlock.h:74: Wrong number of spaces before statement. (expected: 12) [whitespace/indent] [4] ERROR: Source/JavaScriptCore/bytecode/ModuleProgramCodeBlock.h:72: Wrong number of spaces before statement. (expected: 12) [whitespace/indent] [4] ERROR: Source/JavaScriptCore/runtime/NativeExecutable.h:42: The parameter name "function" adds no information, so it should be removed. [readability/parameter_name] [5] ERROR: Source/JavaScriptCore/runtime/Structure.h:594: 'toStructureShape' is incorrectly named. It should be named 'protector' or 'protectedJSValue'. [readability/naming/protected] [4] Total errors found: 7 in 69 files If any of these errors are false positives, please file a bug against check-webkit-style.
Yusuke Suzuki
Comment 5 2017-02-14 10:57:36 PST
Yusuke Suzuki
Comment 6 2017-02-14 10:59:48 PST
Comment on attachment 301522 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=301522&action=review > Source/JavaScriptCore/ChangeLog:7 > + This is the subset of the series of the patches. We do not touch inspector/, bytecode/, and ArrayBuffer related things for now.
WebKit Commit Bot
Comment 7 2017-02-14 11:01:13 PST
Attachment 301522 [details] did not pass style-queue: ERROR: Source/JavaScriptCore/bytecode/ProgramCodeBlock.h:72: Wrong number of spaces before statement. (expected: 12) [whitespace/indent] [4] ERROR: Source/JavaScriptCore/bytecode/CodeBlock.cpp:1915: Wrong number of spaces before statement. (expected: 8) [whitespace/indent] [4] ERROR: Source/JavaScriptCore/bytecode/FunctionCodeBlock.h:72: Wrong number of spaces before statement. (expected: 12) [whitespace/indent] [4] ERROR: Source/JavaScriptCore/bytecode/EvalCodeBlock.h:74: Wrong number of spaces before statement. (expected: 12) [whitespace/indent] [4] ERROR: Source/JavaScriptCore/bytecode/ModuleProgramCodeBlock.h:72: Wrong number of spaces before statement. (expected: 12) [whitespace/indent] [4] ERROR: Source/JavaScriptCore/runtime/NativeExecutable.h:42: The parameter name "function" adds no information, so it should be removed. [readability/parameter_name] [5] ERROR: Source/JavaScriptCore/runtime/Structure.h:594: 'toStructureShape' is incorrectly named. It should be named 'protector' or 'protectedJSValue'. [readability/naming/protected] [4] Total errors found: 7 in 67 files If any of these errors are false positives, please file a bug against check-webkit-style.
Saam Barati
Comment 8 2017-02-14 11:54:08 PST
Comment on attachment 301522 [details] Patch r=me with it building and passing tests
Yusuke Suzuki
Comment 9 2017-02-15 06:31:26 PST
Created attachment 301609 [details] Patch for landing
WebKit Commit Bot
Comment 10 2017-02-15 06:34:52 PST
Attachment 301609 [details] did not pass style-queue: ERROR: Source/JavaScriptCore/bytecode/ProgramCodeBlock.h:72: Wrong number of spaces before statement. (expected: 12) [whitespace/indent] [4] ERROR: Source/JavaScriptCore/bytecode/CodeBlock.cpp:1915: Wrong number of spaces before statement. (expected: 8) [whitespace/indent] [4] ERROR: Source/JavaScriptCore/bytecode/FunctionCodeBlock.h:72: Wrong number of spaces before statement. (expected: 12) [whitespace/indent] [4] ERROR: Source/JavaScriptCore/bytecode/EvalCodeBlock.h:74: Wrong number of spaces before statement. (expected: 12) [whitespace/indent] [4] ERROR: Source/JavaScriptCore/bytecode/ModuleProgramCodeBlock.h:72: Wrong number of spaces before statement. (expected: 12) [whitespace/indent] [4] ERROR: Source/JavaScriptCore/runtime/NativeExecutable.h:42: The parameter name "function" adds no information, so it should be removed. [readability/parameter_name] [5] ERROR: Source/JavaScriptCore/runtime/Structure.h:594: 'toStructureShape' is incorrectly named. It should be named 'protector' or 'protectedJSValue'. [readability/naming/protected] [4] Total errors found: 7 in 67 files If any of these errors are false positives, please file a bug against check-webkit-style.
Yusuke Suzuki
Comment 11 2017-02-15 06:34:57 PST
Created attachment 301610 [details] Patch for landing
WebKit Commit Bot
Comment 12 2017-02-15 06:38:06 PST
Attachment 301610 [details] did not pass style-queue: ERROR: Source/JavaScriptCore/bytecode/ProgramCodeBlock.h:72: Wrong number of spaces before statement. (expected: 12) [whitespace/indent] [4] ERROR: Source/JavaScriptCore/bytecode/CodeBlock.cpp:1915: Wrong number of spaces before statement. (expected: 8) [whitespace/indent] [4] ERROR: Source/JavaScriptCore/bytecode/FunctionCodeBlock.h:72: Wrong number of spaces before statement. (expected: 12) [whitespace/indent] [4] ERROR: Source/JavaScriptCore/bytecode/EvalCodeBlock.h:74: Wrong number of spaces before statement. (expected: 12) [whitespace/indent] [4] ERROR: Source/JavaScriptCore/bytecode/ModuleProgramCodeBlock.h:72: Wrong number of spaces before statement. (expected: 12) [whitespace/indent] [4] ERROR: Source/JavaScriptCore/runtime/NativeExecutable.h:42: The parameter name "function" adds no information, so it should be removed. [readability/parameter_name] [5] ERROR: Source/JavaScriptCore/runtime/Structure.h:594: 'toStructureShape' is incorrectly named. It should be named 'protector' or 'protectedJSValue'. [readability/naming/protected] [4] Total errors found: 7 in 67 files If any of these errors are false positives, please file a bug against check-webkit-style.
Yusuke Suzuki
Comment 13 2017-02-15 09:11:07 PST
Filip Pizlo
Comment 14 2017-02-16 10:57:08 PST
Comment on attachment 301522 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=301522&action=review > Source/JavaScriptCore/API/tests/JSONParseTest.cpp:42 > - RefPtr<VM> vm = VM::create(); > + { > + Ref<VM> vm = VM::create(); This change is wrong. It's not correct to use Ref<> for VM. I think that Ref<> in general is very dangerous for JSC code, because in JSC we rely on pointers being allowed to be null and we rely on the assignability of pointers. > Source/JavaScriptCore/API/tests/JSONParseTest.cpp:-61 > - vm = nullptr; This is incorrect. We were deliberately nulling the VM, so that our reference to it would be gone before JSLockHolder destructs. This manifests as RELEASE_ASSERTs because the VM gets destructed without the lock held.
Yusuke Suzuki
Comment 15 2017-02-16 11:30:10 PST
Comment on attachment 301522 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=301522&action=review Thanks! >> Source/JavaScriptCore/API/tests/JSONParseTest.cpp:42 >> + Ref<VM> vm = VM::create(); > > This change is wrong. It's not correct to use Ref<> for VM. > > I think that Ref<> in general is very dangerous for JSC code, because in JSC we rely on pointers being allowed to be null and we rely on the assignability of pointers. OK, for VM, we should use RefPtr<>. I think that we already made factory functions `::create()` return `Ref<>`. So using Ref<> after that creation just propagates this non-null ability. This patch just propagates the Ref<> from the factory function to the caller side. And if the given factory function can fail, we should make this function return `RefPtr<>`. And in that case, we named these functions `tryCreate` (e.g. ArrayBuffer::tryCreate()). This returns RefPtr<>. And of course, receiving it as Ref<> causes compile error! And I think that using Ref<> if we can makes it explicit whether the given code relies on the assignability of pointers. So actually, in this change, we still keep RefPtr<> if it requires assignability. And if we use Ref<> for the code that uses assignability, it just becomes compile error. >> Source/JavaScriptCore/API/tests/JSONParseTest.cpp:-61 >> - vm = nullptr; > > This is incorrect. We were deliberately nulling the VM, so that our reference to it would be gone before JSLockHolder destructs. > > This manifests as RELEASE_ASSERTs because the VM gets destructed without the lock held. I see. I'll apply the patch to revert this VM part.
Yusuke Suzuki
Comment 16 2017-02-16 11:49:35 PST
Reopening to attach new patch.
Yusuke Suzuki
Comment 17 2017-02-16 11:49:39 PST
Created attachment 301792 [details] Patch Patch for landing
Yusuke Suzuki
Comment 18 2017-02-16 11:52:22 PST
Note You need to log in before you can comment on or make changes to this bug.