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/allocation-site-scopes.h" | 7 #include "src/allocation-site-scopes.h" |
8 #include "src/base/bits.h" | 8 #include "src/base/bits.h" |
9 #include "src/conversions.h" | 9 #include "src/conversions.h" |
10 #include "src/isolate-inl.h" | 10 #include "src/isolate-inl.h" |
(...skipping 1177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1188 | 1188 |
1189 // Invoke the JavaScript factory method. If an exception is thrown while | 1189 // Invoke the JavaScript factory method. If an exception is thrown while |
1190 // running the factory method, use the exception as the result. | 1190 // running the factory method, use the exception as the result. |
1191 Handle<Object> result; | 1191 Handle<Object> result; |
1192 MaybeHandle<Object> exception; | 1192 MaybeHandle<Object> exception; |
1193 if (!Execution::TryCall(fun, | 1193 if (!Execution::TryCall(fun, |
1194 isolate()->js_builtins_object(), | 1194 isolate()->js_builtins_object(), |
1195 arraysize(argv), | 1195 arraysize(argv), |
1196 argv, | 1196 argv, |
1197 &exception).ToHandle(&result)) { | 1197 &exception).ToHandle(&result)) { |
1198 return exception; | 1198 Handle<Object> exception_obj; |
| 1199 if (exception.ToHandle(&exception_obj)) return exception_obj; |
| 1200 return undefined_value(); |
1199 } | 1201 } |
1200 return result; | 1202 return result; |
1201 } | 1203 } |
1202 | 1204 |
1203 | 1205 |
1204 MaybeHandle<Object> Factory::NewError(Handle<String> message) { | 1206 MaybeHandle<Object> Factory::NewError(Handle<String> message) { |
1205 return NewError("$Error", message); | 1207 return NewError("$Error", message); |
1206 } | 1208 } |
1207 | 1209 |
1208 | 1210 |
1209 MaybeHandle<Object> Factory::NewError(const char* constructor, | 1211 MaybeHandle<Object> Factory::NewError(const char* constructor, |
1210 Handle<String> message) { | 1212 Handle<String> message) { |
1211 Handle<String> constr = InternalizeUtf8String(constructor); | 1213 Handle<String> constr = InternalizeUtf8String(constructor); |
1212 Handle<JSFunction> fun = Handle<JSFunction>::cast(Object::GetProperty( | 1214 Handle<JSFunction> fun = Handle<JSFunction>::cast(Object::GetProperty( |
1213 isolate()->js_builtins_object(), constr).ToHandleChecked()); | 1215 isolate()->js_builtins_object(), constr).ToHandleChecked()); |
1214 Handle<Object> argv[] = { message }; | 1216 Handle<Object> argv[] = { message }; |
1215 | 1217 |
1216 // Invoke the JavaScript factory method. If an exception is thrown while | 1218 // Invoke the JavaScript factory method. If an exception is thrown while |
1217 // running the factory method, use the exception as the result. | 1219 // running the factory method, use the exception as the result. |
1218 Handle<Object> result; | 1220 Handle<Object> result; |
1219 MaybeHandle<Object> exception; | 1221 MaybeHandle<Object> exception; |
1220 if (!Execution::TryCall(fun, | 1222 if (!Execution::TryCall(fun, |
1221 isolate()->js_builtins_object(), | 1223 isolate()->js_builtins_object(), |
1222 arraysize(argv), | 1224 arraysize(argv), |
1223 argv, | 1225 argv, |
1224 &exception).ToHandle(&result)) { | 1226 &exception).ToHandle(&result)) { |
1225 return exception; | 1227 Handle<Object> exception_obj; |
| 1228 if (exception.ToHandle(&exception_obj)) return exception_obj; |
| 1229 return undefined_value(); |
1226 } | 1230 } |
1227 return result; | 1231 return result; |
1228 } | 1232 } |
1229 | 1233 |
1230 | 1234 |
1231 void Factory::InitializeFunction(Handle<JSFunction> function, | 1235 void Factory::InitializeFunction(Handle<JSFunction> function, |
1232 Handle<SharedFunctionInfo> info, | 1236 Handle<SharedFunctionInfo> info, |
1233 Handle<Context> context) { | 1237 Handle<Context> context) { |
1234 function->initialize_properties(); | 1238 function->initialize_properties(); |
1235 function->initialize_elements(); | 1239 function->initialize_elements(); |
(...skipping 1094 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2330 return Handle<Object>::null(); | 2334 return Handle<Object>::null(); |
2331 } | 2335 } |
2332 | 2336 |
2333 | 2337 |
2334 Handle<Object> Factory::ToBoolean(bool value) { | 2338 Handle<Object> Factory::ToBoolean(bool value) { |
2335 return value ? true_value() : false_value(); | 2339 return value ? true_value() : false_value(); |
2336 } | 2340 } |
2337 | 2341 |
2338 | 2342 |
2339 } } // namespace v8::internal | 2343 } } // namespace v8::internal |
OLD | NEW |