OLD | NEW |
1 // Copyright 2014 the V8 project authors. All rights reserved. | 1 // Copyright 2014 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "src/factory.h" | 5 #include "src/factory.h" |
6 | 6 |
7 #include "src/allocation-site-scopes.h" | 7 #include "src/allocation-site-scopes.h" |
8 #include "src/base/bits.h" | 8 #include "src/base/bits.h" |
9 #include "src/bootstrapper.h" | 9 #include "src/bootstrapper.h" |
10 #include "src/conversions.h" | 10 #include "src/conversions.h" |
(...skipping 2101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2112 message_obj->set_start_position(start_position); | 2112 message_obj->set_start_position(start_position); |
2113 message_obj->set_end_position(end_position); | 2113 message_obj->set_end_position(end_position); |
2114 message_obj->set_script(*script); | 2114 message_obj->set_script(*script); |
2115 message_obj->set_stack_frames(*stack_frames); | 2115 message_obj->set_stack_frames(*stack_frames); |
2116 return message_obj; | 2116 return message_obj; |
2117 } | 2117 } |
2118 | 2118 |
2119 | 2119 |
2120 Handle<SharedFunctionInfo> Factory::NewSharedFunctionInfo( | 2120 Handle<SharedFunctionInfo> Factory::NewSharedFunctionInfo( |
2121 Handle<String> name, MaybeHandle<Code> maybe_code, bool is_constructor) { | 2121 Handle<String> name, MaybeHandle<Code> maybe_code, bool is_constructor) { |
| 2122 // Function names are assumed to be flat elsewhere. Must flatten before |
| 2123 // allocating SharedFunctionInfo to avoid GC seeing the uninitialized SFI. |
| 2124 name = String::Flatten(name, TENURED); |
| 2125 |
2122 Handle<Map> map = shared_function_info_map(); | 2126 Handle<Map> map = shared_function_info_map(); |
2123 Handle<SharedFunctionInfo> share = New<SharedFunctionInfo>(map, OLD_SPACE); | 2127 Handle<SharedFunctionInfo> share = New<SharedFunctionInfo>(map, OLD_SPACE); |
2124 | 2128 |
2125 // Set pointer fields. | 2129 // Set pointer fields. |
2126 name = String::Flatten(name, TENURED); | |
2127 share->set_name(*name); | 2130 share->set_name(*name); |
2128 Handle<Code> code; | 2131 Handle<Code> code; |
2129 if (!maybe_code.ToHandle(&code)) { | 2132 if (!maybe_code.ToHandle(&code)) { |
2130 code = isolate()->builtins()->Illegal(); | 2133 code = isolate()->builtins()->Illegal(); |
2131 } | 2134 } |
2132 share->set_code(*code); | 2135 share->set_code(*code); |
2133 share->set_optimized_code_map(*cleared_optimized_code_map()); | 2136 share->set_optimized_code_map(*cleared_optimized_code_map()); |
2134 share->set_scope_info(ScopeInfo::Empty(isolate())); | 2137 share->set_scope_info(ScopeInfo::Empty(isolate())); |
2135 Handle<Code> construct_stub = | 2138 Handle<Code> construct_stub = |
2136 is_constructor ? isolate()->builtins()->JSConstructStubGeneric() | 2139 is_constructor ? isolate()->builtins()->JSConstructStubGeneric() |
(...skipping 261 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2398 } | 2401 } |
2399 | 2402 |
2400 | 2403 |
2401 Handle<Object> Factory::ToBoolean(bool value) { | 2404 Handle<Object> Factory::ToBoolean(bool value) { |
2402 return value ? true_value() : false_value(); | 2405 return value ? true_value() : false_value(); |
2403 } | 2406 } |
2404 | 2407 |
2405 | 2408 |
2406 } // namespace internal | 2409 } // namespace internal |
2407 } // namespace v8 | 2410 } // namespace v8 |
OLD | NEW |