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 1614 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1807 void Factory::BecomeJSObject(Handle<JSReceiver> object) { | 1806 void Factory::BecomeJSObject(Handle<JSReceiver> object) { |
1808 ReinitializeJSReceiver(object, JS_OBJECT_TYPE, JSObject::kHeaderSize); | 1807 ReinitializeJSReceiver(object, JS_OBJECT_TYPE, JSObject::kHeaderSize); |
1809 } | 1808 } |
1810 | 1809 |
1811 | 1810 |
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 |
| 1816 Handle<FixedArray> Factory::NewTypeFeedbackVector(int slot_count) { |
| 1817 // Ensure we can skip the write barrier |
| 1818 ASSERT_EQ(isolate()->heap()->uninitialized_symbol(), |
| 1819 *TypeFeedbackInfo::UninitializedSentinel(isolate())); |
| 1820 |
| 1821 CALL_HEAP_FUNCTION( |
| 1822 isolate(), |
| 1823 isolate()->heap()->AllocateFixedArrayWithFiller( |
| 1824 slot_count, |
| 1825 TENURED, |
| 1826 *TypeFeedbackInfo::UninitializedSentinel(isolate())), |
| 1827 FixedArray); |
| 1828 } |
| 1829 |
| 1830 |
1817 Handle<SharedFunctionInfo> Factory::NewSharedFunctionInfo( | 1831 Handle<SharedFunctionInfo> Factory::NewSharedFunctionInfo( |
1818 Handle<String> name, | 1832 Handle<String> name, |
1819 int number_of_literals, | 1833 int number_of_literals, |
1820 bool is_generator, | 1834 bool is_generator, |
1821 Handle<Code> code, | 1835 Handle<Code> code, |
1822 Handle<ScopeInfo> scope_info) { | 1836 Handle<ScopeInfo> scope_info, |
| 1837 Handle<FixedArray> feedback_vector) { |
1823 Handle<SharedFunctionInfo> shared = NewSharedFunctionInfo(name); | 1838 Handle<SharedFunctionInfo> shared = NewSharedFunctionInfo(name); |
1824 shared->set_code(*code); | 1839 shared->set_code(*code); |
1825 shared->set_scope_info(*scope_info); | 1840 shared->set_scope_info(*scope_info); |
| 1841 shared->set_feedback_vector(*feedback_vector); |
1826 int literals_array_size = number_of_literals; | 1842 int literals_array_size = number_of_literals; |
1827 // If the function contains object, regexp or array literals, | 1843 // If the function contains object, regexp or array literals, |
1828 // allocate extra space for a literals array prefix containing the | 1844 // allocate extra space for a literals array prefix containing the |
1829 // context. | 1845 // context. |
1830 if (number_of_literals > 0) { | 1846 if (number_of_literals > 0) { |
1831 literals_array_size += JSFunction::kLiteralsPrefixSize; | 1847 literals_array_size += JSFunction::kLiteralsPrefixSize; |
1832 } | 1848 } |
1833 shared->set_num_literals(literals_array_size); | 1849 shared->set_num_literals(literals_array_size); |
1834 if (is_generator) { | 1850 if (is_generator) { |
1835 shared->set_instance_class_name(isolate()->heap()->Generator_string()); | 1851 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)); | 1889 share->set_optimized_code_map(Smi::FromInt(0)); |
1874 share->set_scope_info(ScopeInfo::Empty(isolate())); | 1890 share->set_scope_info(ScopeInfo::Empty(isolate())); |
1875 Code* construct_stub = | 1891 Code* construct_stub = |
1876 isolate()->builtins()->builtin(Builtins::kJSConstructStubGeneric); | 1892 isolate()->builtins()->builtin(Builtins::kJSConstructStubGeneric); |
1877 share->set_construct_stub(construct_stub); | 1893 share->set_construct_stub(construct_stub); |
1878 share->set_instance_class_name(*Object_string()); | 1894 share->set_instance_class_name(*Object_string()); |
1879 share->set_function_data(*undefined_value(), SKIP_WRITE_BARRIER); | 1895 share->set_function_data(*undefined_value(), SKIP_WRITE_BARRIER); |
1880 share->set_script(*undefined_value(), SKIP_WRITE_BARRIER); | 1896 share->set_script(*undefined_value(), SKIP_WRITE_BARRIER); |
1881 share->set_debug_info(*undefined_value(), SKIP_WRITE_BARRIER); | 1897 share->set_debug_info(*undefined_value(), SKIP_WRITE_BARRIER); |
1882 share->set_inferred_name(*empty_string(), SKIP_WRITE_BARRIER); | 1898 share->set_inferred_name(*empty_string(), SKIP_WRITE_BARRIER); |
| 1899 share->set_feedback_vector(*empty_fixed_array(), SKIP_WRITE_BARRIER); |
1883 share->set_initial_map(*undefined_value(), SKIP_WRITE_BARRIER); | 1900 share->set_initial_map(*undefined_value(), SKIP_WRITE_BARRIER); |
1884 share->set_profiler_ticks(0); | 1901 share->set_profiler_ticks(0); |
1885 share->set_ast_node_count(0); | 1902 share->set_ast_node_count(0); |
1886 share->set_counters(0); | 1903 share->set_counters(0); |
1887 | 1904 |
1888 // Set integer fields (smi or int, depending on the architecture). | 1905 // Set integer fields (smi or int, depending on the architecture). |
1889 share->set_length(0); | 1906 share->set_length(0); |
1890 share->set_formal_parameter_count(0); | 1907 share->set_formal_parameter_count(0); |
1891 share->set_expected_nof_properties(0); | 1908 share->set_expected_nof_properties(0); |
1892 share->set_num_literals(0); | 1909 share->set_num_literals(0); |
(...skipping 435 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2328 return Handle<Object>::null(); | 2345 return Handle<Object>::null(); |
2329 } | 2346 } |
2330 | 2347 |
2331 | 2348 |
2332 Handle<Object> Factory::ToBoolean(bool value) { | 2349 Handle<Object> Factory::ToBoolean(bool value) { |
2333 return value ? true_value() : false_value(); | 2350 return value ? true_value() : false_value(); |
2334 } | 2351 } |
2335 | 2352 |
2336 | 2353 |
2337 } } // namespace v8::internal | 2354 } } // namespace v8::internal |
OLD | NEW |