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/factory.h" | 5 #include "src/factory.h" |
6 | 6 |
7 #include "src/accessors.h" | 7 #include "src/accessors.h" |
8 #include "src/allocation-site-scopes.h" | 8 #include "src/allocation-site-scopes.h" |
9 #include "src/base/bits.h" | 9 #include "src/base/bits.h" |
10 #include "src/bootstrapper.h" | 10 #include "src/bootstrapper.h" |
(...skipping 1157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1168 result = handle(isolate()->pending_exception(), isolate()); | 1168 result = handle(isolate()->pending_exception(), isolate()); |
1169 isolate()->clear_pending_exception(); | 1169 isolate()->clear_pending_exception(); |
1170 } | 1170 } |
1171 | 1171 |
1172 return scope.CloseAndEscape(result); | 1172 return scope.CloseAndEscape(result); |
1173 } | 1173 } |
1174 | 1174 |
1175 | 1175 |
1176 Handle<Object> Factory::NewError(Handle<JSFunction> constructor, | 1176 Handle<Object> Factory::NewError(Handle<JSFunction> constructor, |
1177 Handle<String> message) { | 1177 Handle<String> message) { |
1178 Handle<Object> argv[] = { message }; | 1178 // Construct a new error object. If an exception is thrown, use the exception |
| 1179 // as the result. |
1179 | 1180 |
1180 // Invoke the JavaScript factory method. If an exception is thrown while | 1181 Handle<Object> no_caller; |
1181 // running the factory method, use the exception as the result. | 1182 MaybeHandle<Object> maybe_error = |
1182 Handle<Object> result; | 1183 ErrorUtils::Construct(isolate(), constructor, constructor, message, |
1183 MaybeHandle<Object> exception; | 1184 SKIP_NONE, no_caller, false); |
1184 if (!Execution::TryCall(isolate(), constructor, undefined_value(), | 1185 if (maybe_error.is_null()) { |
1185 arraysize(argv), argv, &exception) | 1186 DCHECK(isolate()->has_pending_exception()); |
1186 .ToHandle(&result)) { | 1187 maybe_error = handle(isolate()->pending_exception(), isolate()); |
1187 Handle<Object> exception_obj; | 1188 isolate()->clear_pending_exception(); |
1188 if (exception.ToHandle(&exception_obj)) return exception_obj; | |
1189 return undefined_value(); | |
1190 } | 1189 } |
1191 return result; | 1190 |
| 1191 return maybe_error.ToHandleChecked(); |
1192 } | 1192 } |
1193 | 1193 |
1194 | 1194 |
1195 #define DEFINE_ERROR(NAME, name) \ | 1195 #define DEFINE_ERROR(NAME, name) \ |
1196 Handle<Object> Factory::New##NAME(MessageTemplate::Template template_index, \ | 1196 Handle<Object> Factory::New##NAME(MessageTemplate::Template template_index, \ |
1197 Handle<Object> arg0, Handle<Object> arg1, \ | 1197 Handle<Object> arg0, Handle<Object> arg1, \ |
1198 Handle<Object> arg2) { \ | 1198 Handle<Object> arg2) { \ |
1199 return NewError(isolate()->name##_function(), template_index, arg0, arg1, \ | 1199 return NewError(isolate()->name##_function(), template_index, arg0, arg1, \ |
1200 arg2); \ | 1200 arg2); \ |
1201 } | 1201 } |
(...skipping 1294 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2496 Handle<AccessorInfo> prototype = | 2496 Handle<AccessorInfo> prototype = |
2497 Accessors::FunctionPrototypeInfo(isolate(), attribs); | 2497 Accessors::FunctionPrototypeInfo(isolate(), attribs); |
2498 AccessorConstantDescriptor d(Handle<Name>(Name::cast(prototype->name())), | 2498 AccessorConstantDescriptor d(Handle<Name>(Name::cast(prototype->name())), |
2499 prototype, attribs); | 2499 prototype, attribs); |
2500 map->AppendDescriptor(&d); | 2500 map->AppendDescriptor(&d); |
2501 } | 2501 } |
2502 } | 2502 } |
2503 | 2503 |
2504 } // namespace internal | 2504 } // namespace internal |
2505 } // namespace v8 | 2505 } // namespace v8 |
OLD | NEW |