Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(635)

Side by Side Diff: src/factory.cc

Issue 1467473002: Install ConstructNonConstructable as construct stub for non-constructables. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Rebase Created 5 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/factory.h ('k') | src/globals.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/bootstrapper.h" 9 #include "src/bootstrapper.h"
10 #include "src/conversions.h" 10 #include "src/conversions.h"
(...skipping 1184 matching lines...) Expand 10 before | Expand all | Expand 10 after
1195 Handle<JSFunction> result = New<JSFunction>(map, space); 1195 Handle<JSFunction> result = New<JSFunction>(map, space);
1196 InitializeFunction(result, info, context); 1196 InitializeFunction(result, info, context);
1197 return result; 1197 return result;
1198 } 1198 }
1199 1199
1200 1200
1201 Handle<JSFunction> Factory::NewFunction(Handle<Map> map, 1201 Handle<JSFunction> Factory::NewFunction(Handle<Map> map,
1202 Handle<String> name, 1202 Handle<String> name,
1203 MaybeHandle<Code> code) { 1203 MaybeHandle<Code> code) {
1204 Handle<Context> context(isolate()->native_context()); 1204 Handle<Context> context(isolate()->native_context());
1205 Handle<SharedFunctionInfo> info = NewSharedFunctionInfo(name, code); 1205 Handle<SharedFunctionInfo> info =
1206 NewSharedFunctionInfo(name, code, map->is_constructor());
1206 DCHECK(is_sloppy(info->language_mode()) && 1207 DCHECK(is_sloppy(info->language_mode()) &&
1207 (map.is_identical_to(isolate()->sloppy_function_map()) || 1208 (map.is_identical_to(isolate()->sloppy_function_map()) ||
1208 map.is_identical_to( 1209 map.is_identical_to(
1209 isolate()->sloppy_function_without_prototype_map()) || 1210 isolate()->sloppy_function_without_prototype_map()) ||
1210 map.is_identical_to( 1211 map.is_identical_to(
1211 isolate()->sloppy_function_with_readonly_prototype_map()) || 1212 isolate()->sloppy_function_with_readonly_prototype_map()) ||
1212 map.is_identical_to(isolate()->strict_function_map()))); 1213 map.is_identical_to(isolate()->strict_function_map())));
1213 return NewFunction(map, info, context); 1214 return NewFunction(map, info, context);
1214 } 1215 }
1215 1216
(...skipping 799 matching lines...) Expand 10 before | Expand all | Expand 10 after
2015 // Restore the saved hash. 2016 // Restore the saved hash.
2016 object->set_hash(*hash); 2017 object->set_hash(*hash);
2017 } 2018 }
2018 2019
2019 2020
2020 Handle<SharedFunctionInfo> Factory::NewSharedFunctionInfo( 2021 Handle<SharedFunctionInfo> Factory::NewSharedFunctionInfo(
2021 Handle<String> name, int number_of_literals, FunctionKind kind, 2022 Handle<String> name, int number_of_literals, FunctionKind kind,
2022 Handle<Code> code, Handle<ScopeInfo> scope_info, 2023 Handle<Code> code, Handle<ScopeInfo> scope_info,
2023 Handle<TypeFeedbackVector> feedback_vector) { 2024 Handle<TypeFeedbackVector> feedback_vector) {
2024 DCHECK(IsValidFunctionKind(kind)); 2025 DCHECK(IsValidFunctionKind(kind));
2025 Handle<SharedFunctionInfo> shared = NewSharedFunctionInfo(name, code); 2026 Handle<SharedFunctionInfo> shared = NewSharedFunctionInfo(
2027 name, code, IsConstructable(kind, scope_info->language_mode()));
2026 shared->set_scope_info(*scope_info); 2028 shared->set_scope_info(*scope_info);
2027 shared->set_feedback_vector(*feedback_vector); 2029 shared->set_feedback_vector(*feedback_vector);
2028 shared->set_kind(kind); 2030 shared->set_kind(kind);
2029 shared->set_num_literals(number_of_literals); 2031 shared->set_num_literals(number_of_literals);
2030 if (IsGeneratorFunction(kind)) { 2032 if (IsGeneratorFunction(kind)) {
2031 shared->set_instance_class_name(isolate()->heap()->Generator_string()); 2033 shared->set_instance_class_name(isolate()->heap()->Generator_string());
2032 shared->DisableOptimization(kGenerator); 2034 shared->DisableOptimization(kGenerator);
2033 } 2035 }
2034 return shared; 2036 return shared;
2035 } 2037 }
(...skipping 12 matching lines...) Expand all
2048 message_obj->set_argument(*argument); 2050 message_obj->set_argument(*argument);
2049 message_obj->set_start_position(start_position); 2051 message_obj->set_start_position(start_position);
2050 message_obj->set_end_position(end_position); 2052 message_obj->set_end_position(end_position);
2051 message_obj->set_script(*script); 2053 message_obj->set_script(*script);
2052 message_obj->set_stack_frames(*stack_frames); 2054 message_obj->set_stack_frames(*stack_frames);
2053 return message_obj; 2055 return message_obj;
2054 } 2056 }
2055 2057
2056 2058
2057 Handle<SharedFunctionInfo> Factory::NewSharedFunctionInfo( 2059 Handle<SharedFunctionInfo> Factory::NewSharedFunctionInfo(
2058 Handle<String> name, 2060 Handle<String> name, MaybeHandle<Code> maybe_code, bool is_constructor) {
2059 MaybeHandle<Code> maybe_code) {
2060 Handle<Map> map = shared_function_info_map(); 2061 Handle<Map> map = shared_function_info_map();
2061 Handle<SharedFunctionInfo> share = New<SharedFunctionInfo>(map, OLD_SPACE); 2062 Handle<SharedFunctionInfo> share = New<SharedFunctionInfo>(map, OLD_SPACE);
2062 2063
2063 // Set pointer fields. 2064 // Set pointer fields.
2064 share->set_name(*name); 2065 share->set_name(*name);
2065 Handle<Code> code; 2066 Handle<Code> code;
2066 if (!maybe_code.ToHandle(&code)) { 2067 if (!maybe_code.ToHandle(&code)) {
2067 code = handle(isolate()->builtins()->builtin(Builtins::kIllegal)); 2068 code = isolate()->builtins()->Illegal();
2068 } 2069 }
2069 share->set_code(*code); 2070 share->set_code(*code);
2070 share->set_optimized_code_map(*cleared_optimized_code_map()); 2071 share->set_optimized_code_map(*cleared_optimized_code_map());
2071 share->set_scope_info(ScopeInfo::Empty(isolate())); 2072 share->set_scope_info(ScopeInfo::Empty(isolate()));
2072 Code* construct_stub = 2073 Handle<Code> construct_stub =
2073 isolate()->builtins()->builtin(Builtins::kJSConstructStubGeneric); 2074 is_constructor ? isolate()->builtins()->JSConstructStubGeneric()
2074 share->set_construct_stub(construct_stub); 2075 : isolate()->builtins()->ConstructedNonConstructable();
2076 share->set_construct_stub(*construct_stub);
2075 share->set_instance_class_name(*Object_string()); 2077 share->set_instance_class_name(*Object_string());
2076 share->set_function_data(*undefined_value(), SKIP_WRITE_BARRIER); 2078 share->set_function_data(*undefined_value(), SKIP_WRITE_BARRIER);
2077 share->set_script(*undefined_value(), SKIP_WRITE_BARRIER); 2079 share->set_script(*undefined_value(), SKIP_WRITE_BARRIER);
2078 share->set_debug_info(*undefined_value(), SKIP_WRITE_BARRIER); 2080 share->set_debug_info(*undefined_value(), SKIP_WRITE_BARRIER);
2079 share->set_inferred_name(*empty_string(), SKIP_WRITE_BARRIER); 2081 share->set_inferred_name(*empty_string(), SKIP_WRITE_BARRIER);
2080 StaticFeedbackVectorSpec empty_spec; 2082 StaticFeedbackVectorSpec empty_spec;
2081 Handle<TypeFeedbackMetadata> feedback_metadata = 2083 Handle<TypeFeedbackMetadata> feedback_metadata =
2082 TypeFeedbackMetadata::New(isolate(), &empty_spec); 2084 TypeFeedbackMetadata::New(isolate(), &empty_spec);
2083 Handle<TypeFeedbackVector> feedback_vector = 2085 Handle<TypeFeedbackVector> feedback_vector =
2084 TypeFeedbackVector::New(isolate(), feedback_metadata); 2086 TypeFeedbackVector::New(isolate(), feedback_metadata);
(...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after
2330 } 2332 }
2331 2333
2332 2334
2333 Handle<Object> Factory::ToBoolean(bool value) { 2335 Handle<Object> Factory::ToBoolean(bool value) {
2334 return value ? true_value() : false_value(); 2336 return value ? true_value() : false_value();
2335 } 2337 }
2336 2338
2337 2339
2338 } // namespace internal 2340 } // namespace internal
2339 } // namespace v8 2341 } // namespace v8
OLDNEW
« no previous file with comments | « src/factory.h ('k') | src/globals.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698