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 20 matching lines...) Expand all Loading... |
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_FunctionNameShouldPrintAsAnonymous) { | |
42 SealHandleScope shs(isolate); | |
43 DCHECK(args.length() == 1); | |
44 CONVERT_ARG_CHECKED(JSFunction, f, 0); | |
45 return isolate->heap()->ToBoolean( | |
46 f->shared()->name_should_print_as_anonymous()); | |
47 } | |
48 | |
49 | |
50 RUNTIME_FUNCTION(Runtime_CompleteFunctionConstruction) { | 41 RUNTIME_FUNCTION(Runtime_CompleteFunctionConstruction) { |
51 SealHandleScope shs(isolate); | 42 SealHandleScope shs(isolate); |
52 DCHECK(args.length() == 3); | 43 DCHECK(args.length() == 3); |
53 CONVERT_ARG_HANDLE_CHECKED(JSFunction, func, 0); | 44 CONVERT_ARG_HANDLE_CHECKED(JSFunction, func, 0); |
54 CONVERT_ARG_HANDLE_CHECKED(JSFunction, constructor, 1); | 45 CONVERT_ARG_HANDLE_CHECKED(JSFunction, constructor, 1); |
55 CONVERT_ARG_HANDLE_CHECKED(Object, unchecked_new_target, 2); | 46 CONVERT_ARG_HANDLE_CHECKED(Object, unchecked_new_target, 2); |
56 func->shared()->set_name_should_print_as_anonymous(true); | 47 func->shared()->set_name_should_print_as_anonymous(true); |
57 | 48 |
58 if (unchecked_new_target->IsUndefined()) return *func; | 49 if (unchecked_new_target->IsUndefined()) return *func; |
59 | 50 |
(...skipping 22 matching lines...) Expand all Loading... |
82 | 73 |
83 Handle<Context> context(func->context(), isolate); | 74 Handle<Context> context(func->context(), isolate); |
84 Handle<JSFunction> result = | 75 Handle<JSFunction> result = |
85 isolate->factory()->NewFunctionFromSharedFunctionInfo( | 76 isolate->factory()->NewFunctionFromSharedFunctionInfo( |
86 map, shared_info, context, NOT_TENURED); | 77 map, shared_info, context, NOT_TENURED); |
87 DCHECK_EQ(func->IsConstructor(), result->IsConstructor()); | 78 DCHECK_EQ(func->IsConstructor(), result->IsConstructor()); |
88 return *result; | 79 return *result; |
89 } | 80 } |
90 | 81 |
91 | 82 |
92 RUNTIME_FUNCTION(Runtime_FunctionIsArrow) { | |
93 SealHandleScope shs(isolate); | |
94 DCHECK(args.length() == 1); | |
95 CONVERT_ARG_CHECKED(JSFunction, f, 0); | |
96 return isolate->heap()->ToBoolean(f->shared()->is_arrow()); | |
97 } | |
98 | |
99 | |
100 RUNTIME_FUNCTION(Runtime_FunctionIsConciseMethod) { | |
101 SealHandleScope shs(isolate); | |
102 DCHECK(args.length() == 1); | |
103 CONVERT_ARG_CHECKED(JSFunction, f, 0); | |
104 return isolate->heap()->ToBoolean(f->shared()->is_concise_method()); | |
105 } | |
106 | |
107 | |
108 RUNTIME_FUNCTION(Runtime_FunctionRemovePrototype) { | 83 RUNTIME_FUNCTION(Runtime_FunctionRemovePrototype) { |
109 SealHandleScope shs(isolate); | 84 SealHandleScope shs(isolate); |
110 DCHECK(args.length() == 1); | 85 DCHECK(args.length() == 1); |
111 | 86 |
112 CONVERT_ARG_CHECKED(JSFunction, f, 0); | 87 CONVERT_ARG_CHECKED(JSFunction, f, 0); |
113 RUNTIME_ASSERT(f->RemovePrototype()); | 88 RUNTIME_ASSERT(f->RemovePrototype()); |
114 f->shared()->set_construct_stub( | 89 f->shared()->set_construct_stub( |
115 *isolate->builtins()->ConstructedNonConstructable()); | 90 *isolate->builtins()->ConstructedNonConstructable()); |
116 | 91 |
117 return isolate->heap()->undefined_value(); | 92 return isolate->heap()->undefined_value(); |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
203 | 178 |
204 RUNTIME_FUNCTION(Runtime_FunctionIsAPIFunction) { | 179 RUNTIME_FUNCTION(Runtime_FunctionIsAPIFunction) { |
205 SealHandleScope shs(isolate); | 180 SealHandleScope shs(isolate); |
206 DCHECK(args.length() == 1); | 181 DCHECK(args.length() == 1); |
207 | 182 |
208 CONVERT_ARG_CHECKED(JSFunction, f, 0); | 183 CONVERT_ARG_CHECKED(JSFunction, f, 0); |
209 return isolate->heap()->ToBoolean(f->shared()->IsApiFunction()); | 184 return isolate->heap()->ToBoolean(f->shared()->IsApiFunction()); |
210 } | 185 } |
211 | 186 |
212 | 187 |
213 RUNTIME_FUNCTION(Runtime_FunctionHidesSource) { | |
214 SealHandleScope shs(isolate); | |
215 DCHECK(args.length() == 1); | |
216 CONVERT_ARG_CHECKED(JSFunction, f, 0); | |
217 | |
218 SharedFunctionInfo* shared = f->shared(); | |
219 bool hide_source = !shared->script()->IsScript() || | |
220 Script::cast(shared->script())->hide_source(); | |
221 return isolate->heap()->ToBoolean(hide_source); | |
222 } | |
223 | |
224 | |
225 RUNTIME_FUNCTION(Runtime_SetCode) { | 188 RUNTIME_FUNCTION(Runtime_SetCode) { |
226 HandleScope scope(isolate); | 189 HandleScope scope(isolate); |
227 DCHECK(args.length() == 2); | 190 DCHECK(args.length() == 2); |
228 | 191 |
229 CONVERT_ARG_HANDLE_CHECKED(JSFunction, target, 0); | 192 CONVERT_ARG_HANDLE_CHECKED(JSFunction, target, 0); |
230 CONVERT_ARG_HANDLE_CHECKED(JSFunction, source, 1); | 193 CONVERT_ARG_HANDLE_CHECKED(JSFunction, source, 1); |
231 | 194 |
232 Handle<SharedFunctionInfo> target_shared(target->shared()); | 195 Handle<SharedFunctionInfo> target_shared(target->shared()); |
233 Handle<SharedFunctionInfo> source_shared(source->shared()); | 196 Handle<SharedFunctionInfo> source_shared(source->shared()); |
234 RUNTIME_ASSERT(!source_shared->bound()); | 197 RUNTIME_ASSERT(!source_shared->bound()); |
(...skipping 377 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
612 } | 575 } |
613 | 576 |
614 | 577 |
615 RUNTIME_FUNCTION(Runtime_ThrowStrongModeTooFewArguments) { | 578 RUNTIME_FUNCTION(Runtime_ThrowStrongModeTooFewArguments) { |
616 HandleScope scope(isolate); | 579 HandleScope scope(isolate); |
617 DCHECK(args.length() == 0); | 580 DCHECK(args.length() == 0); |
618 THROW_NEW_ERROR_RETURN_FAILURE(isolate, | 581 THROW_NEW_ERROR_RETURN_FAILURE(isolate, |
619 NewTypeError(MessageTemplate::kStrongArity)); | 582 NewTypeError(MessageTemplate::kStrongArity)); |
620 } | 583 } |
621 | 584 |
| 585 |
| 586 RUNTIME_FUNCTION(Runtime_FunctionToString) { |
| 587 HandleScope scope(isolate); |
| 588 DCHECK_EQ(1, args.length()); |
| 589 CONVERT_ARG_HANDLE_CHECKED(JSFunction, function, 0); |
| 590 return *JSFunction::ToString(function); |
| 591 } |
| 592 |
622 } // namespace internal | 593 } // namespace internal |
623 } // namespace v8 | 594 } // namespace v8 |
OLD | NEW |