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/conversions.h" | 9 #include "src/conversions.h" |
10 #include "src/isolate-inl.h" | 10 #include "src/isolate-inl.h" |
(...skipping 1868 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1879 void Factory::BecomeJSObject(Handle<JSProxy> proxy) { | 1879 void Factory::BecomeJSObject(Handle<JSProxy> proxy) { |
1880 ReinitializeJSProxy(proxy, JS_OBJECT_TYPE, JSObject::kHeaderSize); | 1880 ReinitializeJSProxy(proxy, JS_OBJECT_TYPE, JSObject::kHeaderSize); |
1881 } | 1881 } |
1882 | 1882 |
1883 | 1883 |
1884 void Factory::BecomeJSFunction(Handle<JSProxy> proxy) { | 1884 void Factory::BecomeJSFunction(Handle<JSProxy> proxy) { |
1885 ReinitializeJSProxy(proxy, JS_FUNCTION_TYPE, JSFunction::kSize); | 1885 ReinitializeJSProxy(proxy, JS_FUNCTION_TYPE, JSFunction::kSize); |
1886 } | 1886 } |
1887 | 1887 |
1888 | 1888 |
1889 Handle<FixedArray> Factory::NewTypeFeedbackVector(int slot_count) { | 1889 Handle<TypeFeedbackVector> Factory::NewTypeFeedbackVector(int slot_count) { |
1890 // Ensure we can skip the write barrier | 1890 // Ensure we can skip the write barrier |
1891 DCHECK_EQ(isolate()->heap()->uninitialized_symbol(), | 1891 DCHECK_EQ(isolate()->heap()->uninitialized_symbol(), |
1892 *TypeFeedbackInfo::UninitializedSentinel(isolate())); | 1892 *TypeFeedbackInfo::UninitializedSentinel(isolate())); |
1893 | 1893 |
1894 CALL_HEAP_FUNCTION( | 1894 if (slot_count == 0) { |
1895 isolate(), | 1895 return Handle<TypeFeedbackVector>::cast(empty_fixed_array()); |
1896 isolate()->heap()->AllocateFixedArrayWithFiller( | 1896 } |
1897 slot_count, | 1897 |
1898 TENURED, | 1898 CALL_HEAP_FUNCTION(isolate(), |
1899 *TypeFeedbackInfo::UninitializedSentinel(isolate())), | 1899 isolate()->heap()->AllocateFixedArrayWithFiller( |
1900 FixedArray); | 1900 slot_count, TENURED, |
| 1901 *TypeFeedbackInfo::UninitializedSentinel(isolate())), |
| 1902 TypeFeedbackVector); |
1901 } | 1903 } |
1902 | 1904 |
1903 | 1905 |
1904 Handle<SharedFunctionInfo> Factory::NewSharedFunctionInfo( | 1906 Handle<SharedFunctionInfo> Factory::NewSharedFunctionInfo( |
1905 Handle<String> name, int number_of_literals, FunctionKind kind, | 1907 Handle<String> name, int number_of_literals, FunctionKind kind, |
1906 Handle<Code> code, Handle<ScopeInfo> scope_info, | 1908 Handle<Code> code, Handle<ScopeInfo> scope_info, |
1907 Handle<FixedArray> feedback_vector) { | 1909 Handle<TypeFeedbackVector> feedback_vector) { |
1908 DCHECK(IsValidFunctionKind(kind)); | 1910 DCHECK(IsValidFunctionKind(kind)); |
1909 Handle<SharedFunctionInfo> shared = NewSharedFunctionInfo(name, code); | 1911 Handle<SharedFunctionInfo> shared = NewSharedFunctionInfo(name, code); |
1910 shared->set_scope_info(*scope_info); | 1912 shared->set_scope_info(*scope_info); |
1911 shared->set_feedback_vector(*feedback_vector); | 1913 shared->set_feedback_vector(*feedback_vector); |
1912 shared->set_kind(kind); | 1914 shared->set_kind(kind); |
1913 int literals_array_size = number_of_literals; | 1915 int literals_array_size = number_of_literals; |
1914 // If the function contains object, regexp or array literals, | 1916 // If the function contains object, regexp or array literals, |
1915 // allocate extra space for a literals array prefix containing the | 1917 // allocate extra space for a literals array prefix containing the |
1916 // context. | 1918 // context. |
1917 if (number_of_literals > 0) { | 1919 if (number_of_literals > 0) { |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1965 share->set_optimized_code_map(Smi::FromInt(0)); | 1967 share->set_optimized_code_map(Smi::FromInt(0)); |
1966 share->set_scope_info(ScopeInfo::Empty(isolate())); | 1968 share->set_scope_info(ScopeInfo::Empty(isolate())); |
1967 Code* construct_stub = | 1969 Code* construct_stub = |
1968 isolate()->builtins()->builtin(Builtins::kJSConstructStubGeneric); | 1970 isolate()->builtins()->builtin(Builtins::kJSConstructStubGeneric); |
1969 share->set_construct_stub(construct_stub); | 1971 share->set_construct_stub(construct_stub); |
1970 share->set_instance_class_name(*Object_string()); | 1972 share->set_instance_class_name(*Object_string()); |
1971 share->set_function_data(*undefined_value(), SKIP_WRITE_BARRIER); | 1973 share->set_function_data(*undefined_value(), SKIP_WRITE_BARRIER); |
1972 share->set_script(*undefined_value(), SKIP_WRITE_BARRIER); | 1974 share->set_script(*undefined_value(), SKIP_WRITE_BARRIER); |
1973 share->set_debug_info(*undefined_value(), SKIP_WRITE_BARRIER); | 1975 share->set_debug_info(*undefined_value(), SKIP_WRITE_BARRIER); |
1974 share->set_inferred_name(*empty_string(), SKIP_WRITE_BARRIER); | 1976 share->set_inferred_name(*empty_string(), SKIP_WRITE_BARRIER); |
1975 share->set_feedback_vector(*empty_fixed_array(), SKIP_WRITE_BARRIER); | 1977 share->set_feedback_vector(*NewTypeFeedbackVector(0), SKIP_WRITE_BARRIER); |
1976 share->set_profiler_ticks(0); | 1978 share->set_profiler_ticks(0); |
1977 share->set_ast_node_count(0); | 1979 share->set_ast_node_count(0); |
1978 share->set_counters(0); | 1980 share->set_counters(0); |
1979 | 1981 |
1980 // Set integer fields (smi or int, depending on the architecture). | 1982 // Set integer fields (smi or int, depending on the architecture). |
1981 share->set_length(0); | 1983 share->set_length(0); |
1982 share->set_formal_parameter_count(0); | 1984 share->set_formal_parameter_count(0); |
1983 share->set_expected_nof_properties(0); | 1985 share->set_expected_nof_properties(0); |
1984 share->set_num_literals(0); | 1986 share->set_num_literals(0); |
1985 share->set_start_position_and_type(0); | 1987 share->set_start_position_and_type(0); |
(...skipping 405 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2391 return Handle<Object>::null(); | 2393 return Handle<Object>::null(); |
2392 } | 2394 } |
2393 | 2395 |
2394 | 2396 |
2395 Handle<Object> Factory::ToBoolean(bool value) { | 2397 Handle<Object> Factory::ToBoolean(bool value) { |
2396 return value ? true_value() : false_value(); | 2398 return value ? true_value() : false_value(); |
2397 } | 2399 } |
2398 | 2400 |
2399 | 2401 |
2400 } } // namespace v8::internal | 2402 } } // namespace v8::internal |
OLD | NEW |