Lines Matching refs:isolate

16 #include "src/execution/isolate-inl.h"
59 void MessageHandler::DefaultMessageReport(Isolate* isolate,
62 std::unique_ptr<char[]> str = GetLocalizedMessage(isolate, message_obj);
66 HandleScope scope(isolate);
67 Handle<Object> data(loc->script()->name(), isolate);
77 Isolate* isolate, MessageTemplate message, const MessageLocation* location,
79 Factory* factory = isolate->factory();
84 Handle<Script> script_handle = isolate->factory()->empty_script();
105 void MessageHandler::ReportMessage(Isolate* isolate, const MessageLocation* loc,
110 ReportMessageNoExceptions(isolate, loc, message, v8::Local<v8::Value>());
119 Object exception_object = ReadOnlyRoots(isolate).undefined_value();
120 if (isolate->has_pending_exception()) {
121 exception_object = isolate->pending_exception();
123 Handle<Object> exception(exception_object, isolate);
125 Isolate::ExceptionScope exception_scope(isolate);
126 isolate->clear_pending_exception();
127 isolate->set_external_caught_exception(false);
131 HandleScope scope(isolate);
132 Handle<Object> argument(message->argument(), isolate);
138 maybe_stringified = Object::NoSideEffectsToString(isolate, argument);
140 v8::TryCatch catcher(reinterpret_cast<v8::Isolate*>(isolate));
144 maybe_stringified = Object::ToString(isolate, argument);
148 DCHECK(isolate->has_pending_exception());
149 isolate->clear_pending_exception();
150 isolate->set_external_caught_exception(false);
151 stringified = isolate->factory()->exception_string();
157 ReportMessageNoExceptions(isolate, loc, message, api_exception_obj);
161 Isolate* isolate, const MessageLocation* loc, Handle<Object> message,
167 isolate->factory()->message_listeners();
170 DefaultMessageReport(isolate, loc, message);
171 if (isolate->has_scheduled_exception()) {
172 isolate->clear_scheduled_exception();
176 HandleScope scope(isolate);
177 if (global_listeners->get(i).IsUndefined(isolate)) continue;
187 Handle<Object> callback_data(listener.get(1), isolate);
189 RCS_SCOPE(isolate, RuntimeCallCounterId::kMessageListenerCallback);
191 v8::TryCatch try_catch(reinterpret_cast<v8::Isolate*>(isolate));
192 callback(api_message_obj, callback_data->IsUndefined(isolate)
196 if (isolate->has_scheduled_exception()) {
197 isolate->clear_scheduled_exception();
203 Handle<String> MessageHandler::GetMessage(Isolate* isolate,
206 Handle<Object> arg = Handle<Object>(message->argument(), isolate);
207 return MessageFormatter::Format(isolate, message->type(), arg);
211 Isolate* isolate, Handle<Object> data) {
212 HandleScope scope(isolate);
213 return GetMessage(isolate, data)->ToCString(DISALLOW_NULLS);
220 MaybeHandle<JSArray> GetStackFrames(Isolate* isolate,
223 Handle<JSFunction> constructor = isolate->callsite_function();
224 Handle<FixedArray> sites = isolate->factory()->NewFixedArray(frame_count);
226 Handle<CallSiteInfo> frame(CallSiteInfo::cast(frames->get(i)), isolate);
229 isolate, site,
232 RETURN_ON_EXCEPTION(isolate,
234 site, isolate->factory()->call_site_info_symbol(),
240 return isolate->factory()->NewJSArrayWithElements(sites);
243 MaybeHandle<Object> AppendErrorString(Isolate* isolate, Handle<Object> error,
246 ErrorUtils::ToString(isolate, Handle<Object>::cast(error));
251 DCHECK(isolate->has_pending_exception());
253 handle(isolate->pending_exception(), isolate);
254 isolate->clear_pending_exception();
255 isolate->set_external_caught_exception(false);
257 err_str = ErrorUtils::ToString(isolate, pending_exception);
260 DCHECK(isolate->has_pending_exception());
261 isolate->clear_pending_exception();
262 isolate->set_external_caught_exception(false);
279 explicit PrepareStackTraceScope(Isolate* isolate) : isolate_(isolate) {
296 MaybeHandle<Object> ErrorUtils::FormatStackTrace(Isolate* isolate,
300 return isolate->factory()->empty_string();
305 const bool in_recursion = isolate->formatting_stack_trace();
306 const bool has_overflowed = i::StackLimitCheck{isolate}.HasOverflowed();
312 if (isolate->HasPrepareStackTraceCallback()) {
313 PrepareStackTraceScope scope(isolate);
316 ASSIGN_RETURN_ON_EXCEPTION(isolate, sites, GetStackFrames(isolate, elems),
321 isolate, result,
322 isolate->RunPrepareStackTraceCallback(error_context, error, sites),
327 handle(error_context->error_function(), isolate);
334 isolate, prepare_stack_trace,
335 JSFunction::GetProperty(isolate, global_error, "prepareStackTrace"),
339 PrepareStackTraceScope scope(isolate);
341 isolate->CountUsage(v8::Isolate::kErrorPrepareStackTrace);
344 ASSIGN_RETURN_ON_EXCEPTION(isolate, sites,
345 GetStackFrames(isolate, elems), Object);
355 isolate, result,
356 Execution::Call(isolate, prepare_stack_trace, global_error, argc,
366 IncrementalStringBuilder builder(isolate);
368 RETURN_ON_EXCEPTION(isolate, AppendErrorString(isolate, error, &builder),
374 Handle<CallSiteInfo> frame(CallSiteInfo::cast(elems->get(i)), isolate);
375 SerializeCallSiteInfo(isolate, frame, &builder);
377 if (isolate->has_pending_exception()) {
383 handle(isolate->pending_exception(), isolate);
384 isolate->clear_pending_exception();
385 isolate->set_external_caught_exception(false);
388 ErrorUtils::ToString(isolate, pending_exception);
405 Handle<String> MessageFormatter::Format(Isolate* isolate, MessageTemplate index,
409 Factory* factory = isolate->factory();
412 arg0_string = Object::NoSideEffectsToString(isolate, arg0);
416 arg1_string = Object::NoSideEffectsToString(isolate, arg1);
420 arg2_string = Object::NoSideEffectsToString(isolate, arg2);
423 isolate, index, arg0_string, arg1_string, arg2_string);
426 DCHECK(isolate->has_pending_exception());
427 isolate->clear_pending_exception();
435 return String::Flatten(isolate, result_string);
451 MaybeHandle<String> MessageFormatter::Format(Isolate* isolate,
458 isolate->ThrowIllegalOperation();
462 IncrementalStringBuilder builder(isolate);
485 MaybeHandle<JSObject> ErrorUtils::Construct(Isolate* isolate,
501 return ErrorUtils::Construct(isolate, target, new_target, message, options,
507 Isolate* isolate, Handle<JSFunction> target, Handle<Object> new_target,
513 if (target.is_identical_to(isolate->range_error_function())) {
518 message = isolate->factory()->InternalizeUtf8String(
532 isolate, err,
542 if (!message->IsUndefined(isolate)) {
544 ASSIGN_RETURN_ON_EXCEPTION(isolate, msg_string,
545 Object::ToString(isolate, message), JSObject);
547 isolate,
549 err, isolate->factory()->message_string(), msg_string, DONT_ENUM),
553 if (FLAG_harmony_error_cause && !options->IsUndefined(isolate)) {
557 Handle<Name> cause_string = isolate->factory()->cause_string();
561 JSObject::HasProperty(isolate, js_options, cause_string);
563 DCHECK((isolate)->has_pending_exception());
569 isolate, cause,
570 JSObject::GetProperty(isolate, js_options, cause_string), JSObject);
571 RETURN_ON_EXCEPTION(isolate,
581 RETURN_ON_EXCEPTION(isolate,
582 isolate->CaptureAndSetErrorStack(err, mode, caller),
593 MaybeHandle<String> GetStringPropertyOrDefault(Isolate* isolate,
598 ASSIGN_RETURN_ON_EXCEPTION(isolate, obj,
599 JSObject::GetProperty(isolate, recv, key), String);
602 if (obj->IsUndefined(isolate)) {
605 ASSIGN_RETURN_ON_EXCEPTION(isolate, str, Object::ToString(isolate, obj),
615 MaybeHandle<String> ErrorUtils::ToString(Isolate* isolate,
620 return isolate->Throw<String>(isolate->factory()->NewTypeError(
622 isolate->factory()->NewStringFromAsciiChecked(
631 Handle<String> name_key = isolate->factory()->name_string();
632 Handle<String> name_default = isolate->factory()->Error_string();
635 isolate, name,
636 GetStringPropertyOrDefault(isolate, recv, name_key, name_default),
642 Handle<String> msg_key = isolate->factory()->message_string();
643 Handle<String> msg_default = isolate->factory()->empty_string();
646 isolate, msg,
647 GetStringPropertyOrDefault(isolate, recv, msg_key, msg_default), String);
656 IncrementalStringBuilder builder(isolate);
662 ASSIGN_RETURN_ON_EXCEPTION(isolate, result, builder.Finish(), String);
668 Handle<String> DoFormatMessage(Isolate* isolate, MessageTemplate index,
671 Handle<String> arg0_str = Object::NoSideEffectsToString(isolate, arg0);
672 Handle<String> arg1_str = Object::NoSideEffectsToString(isolate, arg1);
673 Handle<String> arg2_str = Object::NoSideEffectsToString(isolate, arg2);
675 isolate->native_context()->IncrementErrorsThrown();
678 if (!MessageFormatter::Format(isolate, index, arg0_str, arg1_str, arg2_str)
680 DCHECK(isolate->has_pending_exception());
681 isolate->clear_pending_exception();
682 isolate->set_external_caught_exception(false);
683 return isolate->factory()->NewStringFromAsciiChecked("<error>");
693 Isolate* isolate, Handle<JSFunction> constructor, MessageTemplate index,
700 isolate->clear_pending_exception();
702 Handle<String> msg = DoFormatMessage(isolate, index, arg0, arg1, arg2);
703 Handle<Object> options = isolate->factory()->undefined_value();
710 return ErrorUtils::Construct(isolate, constructor, constructor, msg, options,
717 bool ComputeLocation(Isolate* isolate, MessageLocation* target) {
718 JavaScriptFrameIterator it(isolate);
726 Handle<SharedFunctionInfo> shared(summary.function()->shared(), isolate);
727 Handle<Object> script(shared->script(), isolate);
728 SharedFunctionInfo::EnsureSourcePositionsAvailable(isolate, shared);
731 !(Handle<Script>::cast(script)->source().IsUndefined(isolate))) {
740 Handle<String> BuildDefaultCallSite(Isolate* isolate, Handle<Object> object) {
741 IncrementalStringBuilder builder(isolate);
743 builder.AppendString(Object::TypeOf(isolate, object));
753 string = isolate->factory()->NewProperSubString(string, 0,
759 } else if (object->IsNull(isolate)) {
761 } else if (object->IsTrue(isolate)) {
763 } else if (object->IsFalse(isolate)) {
767 builder.AppendString(isolate->factory()->NumberToString(object));
773 Handle<String> RenderCallSite(Isolate* isolate, Handle<Object> object,
776 if (ComputeLocation(isolate, location)) {
778 isolate, *location->shared());
780 ReusableUnoptimizedCompileState reusable_state(isolate);
781 ParseInfo info(isolate, flags, &compile_state, &reusable_state);
782 if (parsing::ParseAny(&info, location->shared(), isolate,
784 info.ast_value_factory()->Internalize(isolate);
785 CallPrinter printer(isolate, location->shared()->IsUserJavaScript());
791 return BuildDefaultCallSite(isolate, object);
816 Handle<JSObject> ErrorUtils::NewIteratorError(Isolate* isolate,
820 Handle<String> callsite = RenderCallSite(isolate, source, &location, &hint);
824 Handle<Symbol> iterator_symbol = isolate->factory()->iterator_symbol();
825 return isolate->factory()->NewTypeError(id, callsite, iterator_symbol);
829 return isolate->factory()->NewTypeError(id, callsite);
832 Object ErrorUtils::ThrowSpreadArgError(Isolate* isolate, MessageTemplate id,
836 if (ComputeLocation(isolate, &location)) {
838 isolate, *location.shared());
840 ReusableUnoptimizedCompileState reusable_state(isolate);
841 ParseInfo info(isolate, flags, &compile_state, &reusable_state);
842 if (parsing::ParseAny(&info, location.shared(), isolate,
844 info.ast_value_factory()->Internalize(isolate);
845 CallPrinter printer(isolate, location.shared()->IsUserJavaScript(),
849 str->length() > 0 ? str : BuildDefaultCallSite(isolate, object);
858 callsite = BuildDefaultCallSite(isolate, object);
862 isolate->ThrowAt(isolate->factory()->NewTypeError(id, callsite, object),
864 return ReadOnlyRoots(isolate).exception();
867 Handle<JSObject> ErrorUtils::NewCalledNonCallableError(Isolate* isolate,
871 Handle<String> callsite = RenderCallSite(isolate, source, &location, &hint);
874 return isolate->factory()->NewTypeError(id, callsite);
878 Isolate* isolate, Handle<Object> source) {
881 Handle<String> callsite = RenderCallSite(isolate, source, &location, &hint);
883 return isolate->factory()->NewTypeError(id, callsite);
886 Object ErrorUtils::ThrowLoadFromNullOrUndefined(Isolate* isolate,
900 Object::NoSideEffectsToMaybeString(isolate, key_handle);
911 if (ComputeLocation(isolate, &location)) {
915 isolate, *location.shared());
917 ReusableUnoptimizedCompileState reusable_state(isolate);
918 ParseInfo info(isolate, flags, &compile_state, &reusable_state);
919 if (parsing::ParseAny(&info, location.shared(), isolate,
921 info.ast_value_factory()->Internalize(isolate);
922 CallPrinter printer(isolate, location.shared()->IsUserJavaScript());
959 callsite = BuildDefaultCallSite(isolate, object);
966 error = isolate->factory()->NewTypeError(
970 error = isolate->factory()->NewTypeError(MessageTemplate::kNonCoercible,
976 error = isolate->factory()->NewTypeError(
978 } else if (*key_handle == ReadOnlyRoots(isolate).iterator_symbol()) {
979 error = NewIteratorError(isolate, object);
981 error = isolate->factory()->NewTypeError(
988 isolate->ThrowAt(error, &location);
990 isolate->Throw(*error);
992 return ReadOnlyRoots(isolate).exception();
997 Isolate* isolate, Handle<JSObject> error_object) {
1001 isolate, error_object, isolate->factory()->error_stack_symbol());
1006 return handle(error_stack_data->formatted_stack(), isolate);
1008 ErrorStackData::EnsureStackFrameInfos(isolate, error_stack_data);
1011 isolate, formatted_stack,
1012 FormatStackTrace(isolate, error_object,
1013 handle(error_stack_data->call_site_infos(), isolate)),
1022 isolate, formatted_stack,
1023 FormatStackTrace(isolate, error_object,
1027 isolate,
1028 JSObject::SetProperty(isolate, error_object,
1029 isolate->factory()->error_stack_symbol(),
1040 void ErrorUtils::SetFormattedStack(Isolate* isolate,
1044 isolate, error_object, isolate->factory()->error_stack_symbol());
1048 ErrorStackData::EnsureStackFrameInfos(isolate, error_stack_data);
1051 JSObject::SetProperty(isolate, error_object,
1052 isolate->factory()->error_stack_symbol(),