Index: src/factory.cc |
diff --git a/src/factory.cc b/src/factory.cc |
index dea22df99608bdbb3391adebfbe87babeea7b8de..339b9ba1627c3270f72dc63bf67ac79ce4335592 100644 |
--- a/src/factory.cc |
+++ b/src/factory.cc |
@@ -2119,11 +2119,14 @@ Handle<JSMessageObject> Factory::NewJSMessageObject( |
Handle<SharedFunctionInfo> Factory::NewSharedFunctionInfo( |
Handle<String> name, MaybeHandle<Code> maybe_code, bool is_constructor) { |
+ // Function names are assumed to be flat elsewhere. Must flatten before |
+ // allocating SharedFunctionInfo to avoid GC seeing the uninitialized SFI. |
+ name = String::Flatten(name, TENURED); |
+ |
Handle<Map> map = shared_function_info_map(); |
Handle<SharedFunctionInfo> share = New<SharedFunctionInfo>(map, OLD_SPACE); |
// Set pointer fields. |
- name = String::Flatten(name, TENURED); |
share->set_name(*name); |
Handle<Code> code; |
if (!maybe_code.ToHandle(&code)) { |