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

Side by Side Diff: src/runtime/runtime-function.cc

Issue 1548623002: [runtime] Also migrate the Function and GeneratorFunction constructors to C++. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Fix message tests. Created 4 years, 12 months 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/runtime/runtime-compiler.cc ('k') | test/message/paren_in_arg_string.out » ('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/runtime/runtime-utils.h" 5 #include "src/runtime/runtime-utils.h"
6 6
7 #include "src/accessors.h" 7 #include "src/accessors.h"
8 #include "src/arguments.h" 8 #include "src/arguments.h"
9 #include "src/compiler.h" 9 #include "src/compiler.h"
10 #include "src/deoptimizer.h" 10 #include "src/deoptimizer.h"
(...skipping 20 matching lines...) Expand all
31 31
32 CONVERT_ARG_HANDLE_CHECKED(JSFunction, f, 0); 32 CONVERT_ARG_HANDLE_CHECKED(JSFunction, f, 0);
33 CONVERT_ARG_HANDLE_CHECKED(String, name, 1); 33 CONVERT_ARG_HANDLE_CHECKED(String, name, 1);
34 34
35 name = String::Flatten(name); 35 name = String::Flatten(name);
36 f->shared()->set_name(*name); 36 f->shared()->set_name(*name);
37 return isolate->heap()->undefined_value(); 37 return isolate->heap()->undefined_value();
38 } 38 }
39 39
40 40
41 RUNTIME_FUNCTION(Runtime_CompleteFunctionConstruction) {
42 SealHandleScope shs(isolate);
43 DCHECK(args.length() == 3);
44 CONVERT_ARG_HANDLE_CHECKED(JSFunction, func, 0);
45 CONVERT_ARG_HANDLE_CHECKED(JSFunction, constructor, 1);
46 CONVERT_ARG_HANDLE_CHECKED(Object, unchecked_new_target, 2);
47 func->shared()->set_name_should_print_as_anonymous(true);
48
49 if (unchecked_new_target->IsUndefined()) return *func;
50
51 Handle<JSReceiver> new_target =
52 Handle<JSReceiver>::cast(unchecked_new_target);
53 // If new.target is equal to |constructor| then the function |func| created
54 // is already correctly setup and nothing else should be done here.
55 // But if new.target is not equal to |constructor| then we are have a
56 // Function builtin subclassing case and therefore the function |func|
57 // has wrong initial map. To fix that we create a new function object with
58 // correct initial map.
59 if (*constructor == *new_target) return *func;
60
61 // Create a new JSFunction object with correct initial map.
62 HandleScope handle_scope(isolate);
63
64 DCHECK(constructor->has_initial_map());
65 Handle<Map> initial_map;
66 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
67 isolate, initial_map,
68 JSFunction::GetDerivedMap(isolate, constructor, new_target));
69
70 Handle<SharedFunctionInfo> shared_info(func->shared(), isolate);
71 Handle<Map> map = Map::AsLanguageMode(
72 initial_map, shared_info->language_mode(), shared_info->kind());
73
74 Handle<Context> context(func->context(), isolate);
75 Handle<JSFunction> result =
76 isolate->factory()->NewFunctionFromSharedFunctionInfo(
77 map, shared_info, context, NOT_TENURED);
78 DCHECK_EQ(func->IsConstructor(), result->IsConstructor());
79 return *result;
80 }
81
82
83 RUNTIME_FUNCTION(Runtime_FunctionRemovePrototype) { 41 RUNTIME_FUNCTION(Runtime_FunctionRemovePrototype) {
84 SealHandleScope shs(isolate); 42 SealHandleScope shs(isolate);
85 DCHECK(args.length() == 1); 43 DCHECK(args.length() == 1);
86 44
87 CONVERT_ARG_CHECKED(JSFunction, f, 0); 45 CONVERT_ARG_CHECKED(JSFunction, f, 0);
88 RUNTIME_ASSERT(f->RemovePrototype()); 46 RUNTIME_ASSERT(f->RemovePrototype());
89 f->shared()->set_construct_stub( 47 f->shared()->set_construct_stub(
90 *isolate->builtins()->ConstructedNonConstructable()); 48 *isolate->builtins()->ConstructedNonConstructable());
91 49
92 return isolate->heap()->undefined_value(); 50 return isolate->heap()->undefined_value();
(...skipping 492 matching lines...) Expand 10 before | Expand all | Expand 10 after
585 543
586 RUNTIME_FUNCTION(Runtime_FunctionToString) { 544 RUNTIME_FUNCTION(Runtime_FunctionToString) {
587 HandleScope scope(isolate); 545 HandleScope scope(isolate);
588 DCHECK_EQ(1, args.length()); 546 DCHECK_EQ(1, args.length());
589 CONVERT_ARG_HANDLE_CHECKED(JSFunction, function, 0); 547 CONVERT_ARG_HANDLE_CHECKED(JSFunction, function, 0);
590 return *JSFunction::ToString(function); 548 return *JSFunction::ToString(function);
591 } 549 }
592 550
593 } // namespace internal 551 } // namespace internal
594 } // namespace v8 552 } // namespace v8
OLDNEW
« no previous file with comments | « src/runtime/runtime-compiler.cc ('k') | test/message/paren_in_arg_string.out » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698