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

Unified 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, 1 month 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/factory.h ('k') | src/globals.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/factory.cc
diff --git a/src/factory.cc b/src/factory.cc
index 045186d2d97d288b5e1db262c0089eef489f66a1..18641c0ceb4e2d774884552428f21e2d97692ada 100644
--- a/src/factory.cc
+++ b/src/factory.cc
@@ -1202,7 +1202,8 @@ Handle<JSFunction> Factory::NewFunction(Handle<Map> map,
Handle<String> name,
MaybeHandle<Code> code) {
Handle<Context> context(isolate()->native_context());
- Handle<SharedFunctionInfo> info = NewSharedFunctionInfo(name, code);
+ Handle<SharedFunctionInfo> info =
+ NewSharedFunctionInfo(name, code, map->is_constructor());
DCHECK(is_sloppy(info->language_mode()) &&
(map.is_identical_to(isolate()->sloppy_function_map()) ||
map.is_identical_to(
@@ -2022,7 +2023,8 @@ Handle<SharedFunctionInfo> Factory::NewSharedFunctionInfo(
Handle<Code> code, Handle<ScopeInfo> scope_info,
Handle<TypeFeedbackVector> feedback_vector) {
DCHECK(IsValidFunctionKind(kind));
- Handle<SharedFunctionInfo> shared = NewSharedFunctionInfo(name, code);
+ Handle<SharedFunctionInfo> shared = NewSharedFunctionInfo(
+ name, code, IsConstructable(kind, scope_info->language_mode()));
shared->set_scope_info(*scope_info);
shared->set_feedback_vector(*feedback_vector);
shared->set_kind(kind);
@@ -2055,8 +2057,7 @@ Handle<JSMessageObject> Factory::NewJSMessageObject(
Handle<SharedFunctionInfo> Factory::NewSharedFunctionInfo(
- Handle<String> name,
- MaybeHandle<Code> maybe_code) {
+ Handle<String> name, MaybeHandle<Code> maybe_code, bool is_constructor) {
Handle<Map> map = shared_function_info_map();
Handle<SharedFunctionInfo> share = New<SharedFunctionInfo>(map, OLD_SPACE);
@@ -2064,14 +2065,15 @@ Handle<SharedFunctionInfo> Factory::NewSharedFunctionInfo(
share->set_name(*name);
Handle<Code> code;
if (!maybe_code.ToHandle(&code)) {
- code = handle(isolate()->builtins()->builtin(Builtins::kIllegal));
+ code = isolate()->builtins()->Illegal();
}
share->set_code(*code);
share->set_optimized_code_map(*cleared_optimized_code_map());
share->set_scope_info(ScopeInfo::Empty(isolate()));
- Code* construct_stub =
- isolate()->builtins()->builtin(Builtins::kJSConstructStubGeneric);
- share->set_construct_stub(construct_stub);
+ Handle<Code> construct_stub =
+ is_constructor ? isolate()->builtins()->JSConstructStubGeneric()
+ : isolate()->builtins()->ConstructedNonConstructable();
+ share->set_construct_stub(*construct_stub);
share->set_instance_class_name(*Object_string());
share->set_function_data(*undefined_value(), SKIP_WRITE_BARRIER);
share->set_script(*undefined_value(), SKIP_WRITE_BARRIER);
« 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