OLD | NEW |
1 // Copyright 2016 the V8 project authors. All rights reserved. | 1 // Copyright 2016 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/builtins/builtins.h" | 5 #include "src/builtins/builtins.h" |
6 #include "src/builtins/builtins-utils.h" | 6 #include "src/builtins/builtins-utils.h" |
7 | 7 |
| 8 #include "src/compiler.h" |
8 #include "src/string-builder.h" | 9 #include "src/string-builder.h" |
9 | 10 |
10 namespace v8 { | 11 namespace v8 { |
11 namespace internal { | 12 namespace internal { |
12 | 13 |
13 namespace { | 14 namespace { |
14 | 15 |
15 bool AllowDynamicFunction(Isolate* isolate, Handle<JSFunction> target, | 16 bool AllowDynamicFunction(Isolate* isolate, Handle<JSFunction> target, |
16 Handle<JSObject> target_global_proxy) { | 17 Handle<JSObject> target_global_proxy) { |
17 if (FLAG_allow_unsafe_function_constructor) return true; | 18 if (FLAG_allow_unsafe_function_constructor) return true; |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
95 THROW_NEW_ERROR(isolate, | 96 THROW_NEW_ERROR(isolate, |
96 NewSyntaxError(MessageTemplate::kParenthesisInArgString), | 97 NewSyntaxError(MessageTemplate::kParenthesisInArgString), |
97 Object); | 98 Object); |
98 } | 99 } |
99 } | 100 } |
100 | 101 |
101 // Compile the string in the constructor and not a helper so that errors to | 102 // Compile the string in the constructor and not a helper so that errors to |
102 // come from here. | 103 // come from here. |
103 Handle<JSFunction> function; | 104 Handle<JSFunction> function; |
104 { | 105 { |
105 ASSIGN_RETURN_ON_EXCEPTION( | 106 ASSIGN_RETURN_ON_EXCEPTION(isolate, function, |
106 isolate, function, | 107 Compiler::GetFunctionFromString( |
107 Builtins::CompileString(handle(target->native_context(), isolate), | 108 handle(target->native_context(), isolate), |
108 source, ONLY_SINGLE_FUNCTION_LITERAL), | 109 source, ONLY_SINGLE_FUNCTION_LITERAL), |
109 Object); | 110 Object); |
110 Handle<Object> result; | 111 Handle<Object> result; |
111 ASSIGN_RETURN_ON_EXCEPTION( | 112 ASSIGN_RETURN_ON_EXCEPTION( |
112 isolate, result, | 113 isolate, result, |
113 Execution::Call(isolate, function, target_global_proxy, 0, nullptr), | 114 Execution::Call(isolate, function, target_global_proxy, 0, nullptr), |
114 Object); | 115 Object); |
115 function = Handle<JSFunction>::cast(result); | 116 function = Handle<JSFunction>::cast(result); |
116 function->shared()->set_name_should_print_as_anonymous(true); | 117 function->shared()->set_name_should_print_as_anonymous(true); |
117 } | 118 } |
118 | 119 |
119 // If new.target is equal to target then the function created | 120 // If new.target is equal to target then the function created |
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
291 return *JSFunction::ToString(Handle<JSFunction>::cast(receiver)); | 292 return *JSFunction::ToString(Handle<JSFunction>::cast(receiver)); |
292 } | 293 } |
293 THROW_NEW_ERROR_RETURN_FAILURE( | 294 THROW_NEW_ERROR_RETURN_FAILURE( |
294 isolate, NewTypeError(MessageTemplate::kNotGeneric, | 295 isolate, NewTypeError(MessageTemplate::kNotGeneric, |
295 isolate->factory()->NewStringFromAsciiChecked( | 296 isolate->factory()->NewStringFromAsciiChecked( |
296 "Function.prototype.toString"))); | 297 "Function.prototype.toString"))); |
297 } | 298 } |
298 | 299 |
299 } // namespace internal | 300 } // namespace internal |
300 } // namespace v8 | 301 } // namespace v8 |
OLD | NEW |