| 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 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 150 | 150 |
| 151 Handle<AccessorPair> Factory::NewAccessorPair() { | 151 Handle<AccessorPair> Factory::NewAccessorPair() { |
| 152 Handle<AccessorPair> accessors = | 152 Handle<AccessorPair> accessors = |
| 153 Handle<AccessorPair>::cast(NewStruct(ACCESSOR_PAIR_TYPE)); | 153 Handle<AccessorPair>::cast(NewStruct(ACCESSOR_PAIR_TYPE)); |
| 154 accessors->set_getter(*the_hole_value(), SKIP_WRITE_BARRIER); | 154 accessors->set_getter(*the_hole_value(), SKIP_WRITE_BARRIER); |
| 155 accessors->set_setter(*the_hole_value(), SKIP_WRITE_BARRIER); | 155 accessors->set_setter(*the_hole_value(), SKIP_WRITE_BARRIER); |
| 156 return accessors; | 156 return accessors; |
| 157 } | 157 } |
| 158 | 158 |
| 159 | 159 |
| 160 Handle<TypeFeedbackInfo> Factory::NewTypeFeedbackInfo() { | 160 Handle<TypeFeedbackInfo> Factory::NewTypeFeedbackInfo( |
| 161 Handle<TypeFeedbackVector> vector) { |
| 161 Handle<TypeFeedbackInfo> info = | 162 Handle<TypeFeedbackInfo> info = |
| 162 Handle<TypeFeedbackInfo>::cast(NewStruct(TYPE_FEEDBACK_INFO_TYPE)); | 163 Handle<TypeFeedbackInfo>::cast(NewStruct(TYPE_FEEDBACK_INFO_TYPE)); |
| 164 info->set_feedback_vector(*vector); |
| 163 info->initialize_storage(); | 165 info->initialize_storage(); |
| 164 return info; | 166 return info; |
| 165 } | 167 } |
| 166 | 168 |
| 167 | 169 |
| 168 // Internalized strings are created in the old generation (data space). | 170 // Internalized strings are created in the old generation (data space). |
| 169 Handle<String> Factory::InternalizeUtf8String(Vector<const char> string) { | 171 Handle<String> Factory::InternalizeUtf8String(Vector<const char> string) { |
| 170 Utf8StringKey key(string, isolate()->heap()->HashSeed()); | 172 Utf8StringKey key(string, isolate()->heap()->HashSeed()); |
| 171 return InternalizeStringWithKey(&key); | 173 return InternalizeStringWithKey(&key); |
| 172 } | 174 } |
| (...skipping 1760 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1933 void Factory::BecomeJSObject(Handle<JSProxy> proxy) { | 1935 void Factory::BecomeJSObject(Handle<JSProxy> proxy) { |
| 1934 ReinitializeJSProxy(proxy, JS_OBJECT_TYPE, JSObject::kHeaderSize); | 1936 ReinitializeJSProxy(proxy, JS_OBJECT_TYPE, JSObject::kHeaderSize); |
| 1935 } | 1937 } |
| 1936 | 1938 |
| 1937 | 1939 |
| 1938 void Factory::BecomeJSFunction(Handle<JSProxy> proxy) { | 1940 void Factory::BecomeJSFunction(Handle<JSProxy> proxy) { |
| 1939 ReinitializeJSProxy(proxy, JS_FUNCTION_TYPE, JSFunction::kSize); | 1941 ReinitializeJSProxy(proxy, JS_FUNCTION_TYPE, JSFunction::kSize); |
| 1940 } | 1942 } |
| 1941 | 1943 |
| 1942 | 1944 |
| 1943 Handle<TypeFeedbackVector> Factory::NewTypeFeedbackVector(int slot_count) { | 1945 Handle<TypeFeedbackVector> Factory::NewTypeFeedbackVector(int slot_count, |
| 1944 // Ensure we can skip the write barrier | 1946 int ic_slot_count) { |
| 1945 DCHECK_EQ(isolate()->heap()->uninitialized_symbol(), | 1947 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 } | 1948 } |
| 1958 | 1949 |
| 1959 | 1950 |
| 1960 Handle<SharedFunctionInfo> Factory::NewSharedFunctionInfo( | 1951 Handle<SharedFunctionInfo> Factory::NewSharedFunctionInfo( |
| 1961 Handle<String> name, int number_of_literals, FunctionKind kind, | 1952 Handle<String> name, int number_of_literals, FunctionKind kind, |
| 1962 Handle<Code> code, Handle<ScopeInfo> scope_info, | 1953 Handle<Code> code, Handle<ScopeInfo> scope_info, |
| 1963 Handle<TypeFeedbackVector> feedback_vector) { | 1954 Handle<TypeFeedbackVector> feedback_vector) { |
| 1964 DCHECK(IsValidFunctionKind(kind)); | 1955 DCHECK(IsValidFunctionKind(kind)); |
| 1965 Handle<SharedFunctionInfo> shared = NewSharedFunctionInfo(name, code); | 1956 Handle<SharedFunctionInfo> shared = NewSharedFunctionInfo(name, code); |
| 1966 shared->set_scope_info(*scope_info); | 1957 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)); | 2012 share->set_optimized_code_map(Smi::FromInt(0)); |
| 2022 share->set_scope_info(ScopeInfo::Empty(isolate())); | 2013 share->set_scope_info(ScopeInfo::Empty(isolate())); |
| 2023 Code* construct_stub = | 2014 Code* construct_stub = |
| 2024 isolate()->builtins()->builtin(Builtins::kJSConstructStubGeneric); | 2015 isolate()->builtins()->builtin(Builtins::kJSConstructStubGeneric); |
| 2025 share->set_construct_stub(construct_stub); | 2016 share->set_construct_stub(construct_stub); |
| 2026 share->set_instance_class_name(*Object_string()); | 2017 share->set_instance_class_name(*Object_string()); |
| 2027 share->set_function_data(*undefined_value(), SKIP_WRITE_BARRIER); | 2018 share->set_function_data(*undefined_value(), SKIP_WRITE_BARRIER); |
| 2028 share->set_script(*undefined_value(), SKIP_WRITE_BARRIER); | 2019 share->set_script(*undefined_value(), SKIP_WRITE_BARRIER); |
| 2029 share->set_debug_info(*undefined_value(), SKIP_WRITE_BARRIER); | 2020 share->set_debug_info(*undefined_value(), SKIP_WRITE_BARRIER); |
| 2030 share->set_inferred_name(*empty_string(), SKIP_WRITE_BARRIER); | 2021 share->set_inferred_name(*empty_string(), SKIP_WRITE_BARRIER); |
| 2031 Handle<TypeFeedbackVector> feedback_vector = NewTypeFeedbackVector(0); | 2022 Handle<TypeFeedbackVector> feedback_vector = NewTypeFeedbackVector(0, 0); |
| 2032 share->set_feedback_vector(*feedback_vector, SKIP_WRITE_BARRIER); | 2023 share->set_feedback_vector(*feedback_vector, SKIP_WRITE_BARRIER); |
| 2033 share->set_profiler_ticks(0); | 2024 share->set_profiler_ticks(0); |
| 2034 share->set_ast_node_count(0); | 2025 share->set_ast_node_count(0); |
| 2035 share->set_counters(0); | 2026 share->set_counters(0); |
| 2036 | 2027 |
| 2037 // Set integer fields (smi or int, depending on the architecture). | 2028 // Set integer fields (smi or int, depending on the architecture). |
| 2038 share->set_length(0); | 2029 share->set_length(0); |
| 2039 share->set_formal_parameter_count(0); | 2030 share->set_formal_parameter_count(0); |
| 2040 share->set_expected_nof_properties(0); | 2031 share->set_expected_nof_properties(0); |
| 2041 share->set_num_literals(0); | 2032 share->set_num_literals(0); |
| (...skipping 409 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2451 return Handle<Object>::null(); | 2442 return Handle<Object>::null(); |
| 2452 } | 2443 } |
| 2453 | 2444 |
| 2454 | 2445 |
| 2455 Handle<Object> Factory::ToBoolean(bool value) { | 2446 Handle<Object> Factory::ToBoolean(bool value) { |
| 2456 return value ? true_value() : false_value(); | 2447 return value ? true_value() : false_value(); |
| 2457 } | 2448 } |
| 2458 | 2449 |
| 2459 | 2450 |
| 2460 } } // namespace v8::internal | 2451 } } // namespace v8::internal |
| OLD | NEW |