SourceCode should be copied when generating bytecode for functions
authortzagallo@apple.com <tzagallo@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 13 Feb 2019 12:21:00 +0000 (12:21 +0000)
committertzagallo@apple.com <tzagallo@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 13 Feb 2019 12:21:00 +0000 (12:21 +0000)
https://bugs.webkit.org/show_bug.cgi?id=194536

Reviewed by Saam Barati.

The FunctionExecutable might be collected while generating the bytecode
for nested functions, in which case the SourceCode reference would no
longer be valid.

* runtime/CodeCache.cpp:
(JSC::generateUnlinkedCodeBlockForFunctions):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@241431 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/JavaScriptCore/ChangeLog
Source/JavaScriptCore/runtime/CodeCache.cpp

index e96efd2..f6cecf2 100644 (file)
@@ -1,3 +1,17 @@
+2019-02-13  Tadeu Zagallo  <tzagallo@apple.com>
+
+        SourceCode should be copied when generating bytecode for functions
+        https://bugs.webkit.org/show_bug.cgi?id=194536
+
+        Reviewed by Saam Barati.
+
+        The FunctionExecutable might be collected while generating the bytecode
+        for nested functions, in which case the SourceCode reference would no
+        longer be valid.
+
+        * runtime/CodeCache.cpp:
+        (JSC::generateUnlinkedCodeBlockForFunctions):
+
 2019-02-12  Saam barati  <sbarati@apple.com>
 
         JSScript needs to retain its cache path NSURL*
index b41e526..9b6070b 100644 (file)
@@ -170,7 +170,9 @@ void generateUnlinkedCodeBlockForFunctions(VM& vm, UnlinkedCodeBlock* unlinkedCo
             return;
 
         FunctionExecutable* executable = unlinkedExecutable->link(vm, parentSource);
-        const SourceCode& source = executable->source();
+        // FIXME: We shouldn't need to create a FunctionExecutable just to get its source code
+        // https://bugs.webkit.org/show_bug.cgi?id=194576
+        SourceCode source = executable->source();
         UnlinkedFunctionCodeBlock* unlinkedFunctionCodeBlock = unlinkedExecutable->unlinkedCodeBlockFor(vm, source, constructorKind, debuggerMode, error, unlinkedExecutable->parseMode());
         if (unlinkedFunctionCodeBlock)
             generateUnlinkedCodeBlockForFunctions(vm, unlinkedFunctionCodeBlock, source, debuggerMode, error);