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 1922 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1933 void Factory::BecomeJSObject(Handle<JSProxy> proxy) { | 1933 void Factory::BecomeJSObject(Handle<JSProxy> proxy) { |
1934 ReinitializeJSProxy(proxy, JS_OBJECT_TYPE, JSObject::kHeaderSize); | 1934 ReinitializeJSProxy(proxy, JS_OBJECT_TYPE, JSObject::kHeaderSize); |
1935 } | 1935 } |
1936 | 1936 |
1937 | 1937 |
1938 void Factory::BecomeJSFunction(Handle<JSProxy> proxy) { | 1938 void Factory::BecomeJSFunction(Handle<JSProxy> proxy) { |
1939 ReinitializeJSProxy(proxy, JS_FUNCTION_TYPE, JSFunction::kSize); | 1939 ReinitializeJSProxy(proxy, JS_FUNCTION_TYPE, JSFunction::kSize); |
1940 } | 1940 } |
1941 | 1941 |
1942 | 1942 |
1943 Handle<TypeFeedbackVector> Factory::NewTypeFeedbackVector(int slot_count) { | 1943 Handle<TypeFeedbackVector> Factory::NewTypeFeedbackVector(int slot_count, |
1944 // Ensure we can skip the write barrier | 1944 int ic_slot_count) { |
1945 DCHECK_EQ(isolate()->heap()->uninitialized_symbol(), | 1945 return TypeFeedbackVector::Allocate(isolate(), slot_count, ic_slot_count); |
1946 *TypeFeedbackVector::UninitializedSentinel(isolate())); | |
1947 | |
1948 if (slot_count == 0) { | |
1949 return Handle<TypeFeedbackVector>::cast(empty_fixed_array()); | |
1950 } | |
1951 | |
1952 CALL_HEAP_FUNCTION(isolate(), | |
1953 isolate()->heap()->AllocateFixedArrayWithFiller( | |
1954 slot_count, TENURED, | |
1955 *TypeFeedbackVector::UninitializedSentinel(isolate())), | |
1956 TypeFeedbackVector); | |
1957 } | 1946 } |
1958 | 1947 |
1959 | 1948 |
1960 Handle<SharedFunctionInfo> Factory::NewSharedFunctionInfo( | 1949 Handle<SharedFunctionInfo> Factory::NewSharedFunctionInfo( |
1961 Handle<String> name, int number_of_literals, FunctionKind kind, | 1950 Handle<String> name, int number_of_literals, FunctionKind kind, |
1962 Handle<Code> code, Handle<ScopeInfo> scope_info, | 1951 Handle<Code> code, Handle<ScopeInfo> scope_info, |
1963 Handle<TypeFeedbackVector> feedback_vector) { | 1952 Handle<TypeFeedbackVector> feedback_vector) { |
1964 DCHECK(IsValidFunctionKind(kind)); | 1953 DCHECK(IsValidFunctionKind(kind)); |
1965 Handle<SharedFunctionInfo> shared = NewSharedFunctionInfo(name, code); | 1954 Handle<SharedFunctionInfo> shared = NewSharedFunctionInfo(name, code); |
1966 shared->set_scope_info(*scope_info); | 1955 shared->set_scope_info(*scope_info); |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2021 share->set_optimized_code_map(Smi::FromInt(0)); | 2010 share->set_optimized_code_map(Smi::FromInt(0)); |
2022 share->set_scope_info(ScopeInfo::Empty(isolate())); | 2011 share->set_scope_info(ScopeInfo::Empty(isolate())); |
2023 Code* construct_stub = | 2012 Code* construct_stub = |
2024 isolate()->builtins()->builtin(Builtins::kJSConstructStubGeneric); | 2013 isolate()->builtins()->builtin(Builtins::kJSConstructStubGeneric); |
2025 share->set_construct_stub(construct_stub); | 2014 share->set_construct_stub(construct_stub); |
2026 share->set_instance_class_name(*Object_string()); | 2015 share->set_instance_class_name(*Object_string()); |
2027 share->set_function_data(*undefined_value(), SKIP_WRITE_BARRIER); | 2016 share->set_function_data(*undefined_value(), SKIP_WRITE_BARRIER); |
2028 share->set_script(*undefined_value(), SKIP_WRITE_BARRIER); | 2017 share->set_script(*undefined_value(), SKIP_WRITE_BARRIER); |
2029 share->set_debug_info(*undefined_value(), SKIP_WRITE_BARRIER); | 2018 share->set_debug_info(*undefined_value(), SKIP_WRITE_BARRIER); |
2030 share->set_inferred_name(*empty_string(), SKIP_WRITE_BARRIER); | 2019 share->set_inferred_name(*empty_string(), SKIP_WRITE_BARRIER); |
2031 Handle<TypeFeedbackVector> feedback_vector = NewTypeFeedbackVector(0); | 2020 Handle<TypeFeedbackVector> feedback_vector = NewTypeFeedbackVector(0, 0); |
2032 share->set_feedback_vector(*feedback_vector, SKIP_WRITE_BARRIER); | 2021 share->set_feedback_vector(*feedback_vector, SKIP_WRITE_BARRIER); |
2033 share->set_profiler_ticks(0); | 2022 share->set_profiler_ticks(0); |
2034 share->set_ast_node_count(0); | 2023 share->set_ast_node_count(0); |
2035 share->set_counters(0); | 2024 share->set_counters(0); |
2036 | 2025 |
2037 // Set integer fields (smi or int, depending on the architecture). | 2026 // Set integer fields (smi or int, depending on the architecture). |
2038 share->set_length(0); | 2027 share->set_length(0); |
2039 share->set_formal_parameter_count(0); | 2028 share->set_formal_parameter_count(0); |
2040 share->set_expected_nof_properties(0); | 2029 share->set_expected_nof_properties(0); |
2041 share->set_num_literals(0); | 2030 share->set_num_literals(0); |
(...skipping 409 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2451 return Handle<Object>::null(); | 2440 return Handle<Object>::null(); |
2452 } | 2441 } |
2453 | 2442 |
2454 | 2443 |
2455 Handle<Object> Factory::ToBoolean(bool value) { | 2444 Handle<Object> Factory::ToBoolean(bool value) { |
2456 return value ? true_value() : false_value(); | 2445 return value ? true_value() : false_value(); |
2457 } | 2446 } |
2458 | 2447 |
2459 | 2448 |
2460 } } // namespace v8::internal | 2449 } } // namespace v8::internal |
OLD | NEW |