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/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 29 matching lines...) Expand all Loading... |
40 | 40 |
41 RUNTIME_FUNCTION(Runtime_FunctionNameShouldPrintAsAnonymous) { | 41 RUNTIME_FUNCTION(Runtime_FunctionNameShouldPrintAsAnonymous) { |
42 SealHandleScope shs(isolate); | 42 SealHandleScope shs(isolate); |
43 DCHECK(args.length() == 1); | 43 DCHECK(args.length() == 1); |
44 CONVERT_ARG_CHECKED(JSFunction, f, 0); | 44 CONVERT_ARG_CHECKED(JSFunction, f, 0); |
45 return isolate->heap()->ToBoolean( | 45 return isolate->heap()->ToBoolean( |
46 f->shared()->name_should_print_as_anonymous()); | 46 f->shared()->name_should_print_as_anonymous()); |
47 } | 47 } |
48 | 48 |
49 | 49 |
50 RUNTIME_FUNCTION(Runtime_CompleteFunctionConstruction) { | 50 RUNTIME_FUNCTION(Runtime_FunctionMarkNameShouldPrintAsAnonymous) { |
51 SealHandleScope shs(isolate); | 51 SealHandleScope shs(isolate); |
52 DCHECK(args.length() == 3); | 52 DCHECK(args.length() == 1); |
53 CONVERT_ARG_HANDLE_CHECKED(JSFunction, func, 0); | 53 CONVERT_ARG_CHECKED(JSFunction, f, 0); |
54 CONVERT_ARG_HANDLE_CHECKED(JSFunction, constructor, 1); | 54 f->shared()->set_name_should_print_as_anonymous(true); |
55 CONVERT_ARG_HANDLE_CHECKED(Object, new_target, 2); | 55 return isolate->heap()->undefined_value(); |
56 func->shared()->set_name_should_print_as_anonymous(true); | |
57 | |
58 // If new.target is equal to |constructor| then the function |func| created | |
59 // is already correctly setup and nothing else should be done here. | |
60 // But if new.target is not equal to |constructor| then we are have a | |
61 // Function builtin subclassing case and therefore the function |func| | |
62 // has wrong initial map. To fix that we create a new function object with | |
63 // correct initial map. | |
64 if (new_target->IsUndefined() || *constructor == *new_target) { | |
65 return *func; | |
66 } | |
67 | |
68 // Create a new JSFunction object with correct initial map. | |
69 HandleScope handle_scope(isolate); | |
70 Handle<JSFunction> original_constructor = | |
71 Handle<JSFunction>::cast(new_target); | |
72 | |
73 DCHECK(constructor->has_initial_map()); | |
74 Handle<Map> initial_map = | |
75 JSFunction::EnsureDerivedHasInitialMap(original_constructor, constructor); | |
76 | |
77 Handle<SharedFunctionInfo> shared_info(func->shared(), isolate); | |
78 Handle<Context> context(func->context(), isolate); | |
79 Handle<JSFunction> result = | |
80 isolate->factory()->NewFunctionFromSharedFunctionInfo( | |
81 initial_map, shared_info, context, NOT_TENURED); | |
82 DCHECK_EQ(func->IsConstructor(), result->IsConstructor()); | |
83 return *result; | |
84 } | 56 } |
85 | 57 |
86 | 58 |
87 RUNTIME_FUNCTION(Runtime_FunctionIsArrow) { | 59 RUNTIME_FUNCTION(Runtime_FunctionIsArrow) { |
88 SealHandleScope shs(isolate); | 60 SealHandleScope shs(isolate); |
89 DCHECK(args.length() == 1); | 61 DCHECK(args.length() == 1); |
90 CONVERT_ARG_CHECKED(JSFunction, f, 0); | 62 CONVERT_ARG_CHECKED(JSFunction, f, 0); |
91 return isolate->heap()->ToBoolean(f->shared()->is_arrow()); | 63 return isolate->heap()->ToBoolean(f->shared()->is_arrow()); |
92 } | 64 } |
93 | 65 |
(...skipping 532 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
626 | 598 |
627 | 599 |
628 RUNTIME_FUNCTION(Runtime_ThrowStrongModeTooFewArguments) { | 600 RUNTIME_FUNCTION(Runtime_ThrowStrongModeTooFewArguments) { |
629 HandleScope scope(isolate); | 601 HandleScope scope(isolate); |
630 DCHECK(args.length() == 0); | 602 DCHECK(args.length() == 0); |
631 THROW_NEW_ERROR_RETURN_FAILURE(isolate, | 603 THROW_NEW_ERROR_RETURN_FAILURE(isolate, |
632 NewTypeError(MessageTemplate::kStrongArity)); | 604 NewTypeError(MessageTemplate::kStrongArity)); |
633 } | 605 } |
634 } // namespace internal | 606 } // namespace internal |
635 } // namespace v8 | 607 } // namespace v8 |
OLD | NEW |