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 "factory.h" | 5 #include "factory.h" |
6 | 6 |
7 #include "conversions.h" | 7 #include "conversions.h" |
8 #include "isolate-inl.h" | 8 #include "isolate-inl.h" |
9 #include "macro-assembler.h" | 9 #include "macro-assembler.h" |
10 | 10 |
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
172 accessors->set_setter(*the_hole_value(), SKIP_WRITE_BARRIER); | 172 accessors->set_setter(*the_hole_value(), SKIP_WRITE_BARRIER); |
173 accessors->set_access_flags(Smi::FromInt(0), SKIP_WRITE_BARRIER); | 173 accessors->set_access_flags(Smi::FromInt(0), SKIP_WRITE_BARRIER); |
174 return accessors; | 174 return accessors; |
175 } | 175 } |
176 | 176 |
177 | 177 |
178 Handle<TypeFeedbackInfo> Factory::NewTypeFeedbackInfo() { | 178 Handle<TypeFeedbackInfo> Factory::NewTypeFeedbackInfo() { |
179 Handle<TypeFeedbackInfo> info = | 179 Handle<TypeFeedbackInfo> info = |
180 Handle<TypeFeedbackInfo>::cast(NewStruct(TYPE_FEEDBACK_INFO_TYPE)); | 180 Handle<TypeFeedbackInfo>::cast(NewStruct(TYPE_FEEDBACK_INFO_TYPE)); |
181 info->initialize_storage(); | 181 info->initialize_storage(); |
182 info->set_feedback_vector(*empty_fixed_array(), SKIP_WRITE_BARRIER); | |
183 return info; | 182 return info; |
184 } | 183 } |
185 | 184 |
186 | 185 |
187 // Internalized strings are created in the old generation (data space). | 186 // Internalized strings are created in the old generation (data space). |
188 Handle<String> Factory::InternalizeUtf8String(Vector<const char> string) { | 187 Handle<String> Factory::InternalizeUtf8String(Vector<const char> string) { |
189 Utf8StringKey key(string, isolate()->heap()->HashSeed()); | 188 Utf8StringKey key(string, isolate()->heap()->HashSeed()); |
190 return InternalizeStringWithKey(&key); | 189 return InternalizeStringWithKey(&key); |
191 } | 190 } |
192 | 191 |
(...skipping 1619 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1812 void Factory::BecomeJSFunction(Handle<JSReceiver> object) { | 1811 void Factory::BecomeJSFunction(Handle<JSReceiver> object) { |
1813 ReinitializeJSReceiver(object, JS_FUNCTION_TYPE, JSFunction::kSize); | 1812 ReinitializeJSReceiver(object, JS_FUNCTION_TYPE, JSFunction::kSize); |
1814 } | 1813 } |
1815 | 1814 |
1816 | 1815 |
1817 Handle<SharedFunctionInfo> Factory::NewSharedFunctionInfo( | 1816 Handle<SharedFunctionInfo> Factory::NewSharedFunctionInfo( |
1818 Handle<String> name, | 1817 Handle<String> name, |
1819 int number_of_literals, | 1818 int number_of_literals, |
1820 bool is_generator, | 1819 bool is_generator, |
1821 Handle<Code> code, | 1820 Handle<Code> code, |
1822 Handle<ScopeInfo> scope_info) { | 1821 Handle<ScopeInfo> scope_info, |
| 1822 Handle<FixedArray> feedback_vector) { |
1823 Handle<SharedFunctionInfo> shared = NewSharedFunctionInfo(name); | 1823 Handle<SharedFunctionInfo> shared = NewSharedFunctionInfo(name); |
1824 shared->set_code(*code); | 1824 shared->set_code(*code); |
1825 shared->set_scope_info(*scope_info); | 1825 shared->set_scope_info(*scope_info); |
| 1826 shared->set_feedback_vector(*feedback_vector); |
1826 int literals_array_size = number_of_literals; | 1827 int literals_array_size = number_of_literals; |
1827 // If the function contains object, regexp or array literals, | 1828 // If the function contains object, regexp or array literals, |
1828 // allocate extra space for a literals array prefix containing the | 1829 // allocate extra space for a literals array prefix containing the |
1829 // context. | 1830 // context. |
1830 if (number_of_literals > 0) { | 1831 if (number_of_literals > 0) { |
1831 literals_array_size += JSFunction::kLiteralsPrefixSize; | 1832 literals_array_size += JSFunction::kLiteralsPrefixSize; |
1832 } | 1833 } |
1833 shared->set_num_literals(literals_array_size); | 1834 shared->set_num_literals(literals_array_size); |
1834 if (is_generator) { | 1835 if (is_generator) { |
1835 shared->set_instance_class_name(isolate()->heap()->Generator_string()); | 1836 shared->set_instance_class_name(isolate()->heap()->Generator_string()); |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1873 share->set_optimized_code_map(Smi::FromInt(0)); | 1874 share->set_optimized_code_map(Smi::FromInt(0)); |
1874 share->set_scope_info(ScopeInfo::Empty(isolate())); | 1875 share->set_scope_info(ScopeInfo::Empty(isolate())); |
1875 Code* construct_stub = | 1876 Code* construct_stub = |
1876 isolate()->builtins()->builtin(Builtins::kJSConstructStubGeneric); | 1877 isolate()->builtins()->builtin(Builtins::kJSConstructStubGeneric); |
1877 share->set_construct_stub(construct_stub); | 1878 share->set_construct_stub(construct_stub); |
1878 share->set_instance_class_name(*Object_string()); | 1879 share->set_instance_class_name(*Object_string()); |
1879 share->set_function_data(*undefined_value(), SKIP_WRITE_BARRIER); | 1880 share->set_function_data(*undefined_value(), SKIP_WRITE_BARRIER); |
1880 share->set_script(*undefined_value(), SKIP_WRITE_BARRIER); | 1881 share->set_script(*undefined_value(), SKIP_WRITE_BARRIER); |
1881 share->set_debug_info(*undefined_value(), SKIP_WRITE_BARRIER); | 1882 share->set_debug_info(*undefined_value(), SKIP_WRITE_BARRIER); |
1882 share->set_inferred_name(*empty_string(), SKIP_WRITE_BARRIER); | 1883 share->set_inferred_name(*empty_string(), SKIP_WRITE_BARRIER); |
| 1884 share->set_feedback_vector(*empty_fixed_array(), SKIP_WRITE_BARRIER); |
1883 share->set_initial_map(*undefined_value(), SKIP_WRITE_BARRIER); | 1885 share->set_initial_map(*undefined_value(), SKIP_WRITE_BARRIER); |
1884 share->set_profiler_ticks(0); | 1886 share->set_profiler_ticks(0); |
1885 share->set_ast_node_count(0); | 1887 share->set_ast_node_count(0); |
1886 share->set_counters(0); | 1888 share->set_counters(0); |
1887 | 1889 |
1888 // Set integer fields (smi or int, depending on the architecture). | 1890 // Set integer fields (smi or int, depending on the architecture). |
1889 share->set_length(0); | 1891 share->set_length(0); |
1890 share->set_formal_parameter_count(0); | 1892 share->set_formal_parameter_count(0); |
1891 share->set_expected_nof_properties(0); | 1893 share->set_expected_nof_properties(0); |
1892 share->set_num_literals(0); | 1894 share->set_num_literals(0); |
(...skipping 435 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2328 return Handle<Object>::null(); | 2330 return Handle<Object>::null(); |
2329 } | 2331 } |
2330 | 2332 |
2331 | 2333 |
2332 Handle<Object> Factory::ToBoolean(bool value) { | 2334 Handle<Object> Factory::ToBoolean(bool value) { |
2333 return value ? true_value() : false_value(); | 2335 return value ? true_value() : false_value(); |
2334 } | 2336 } |
2335 | 2337 |
2336 | 2338 |
2337 } } // namespace v8::internal | 2339 } } // namespace v8::internal |
OLD | NEW |