OLD | NEW |
---|---|
1 | 1 |
2 // Copyright 2006-2008 the V8 project authors. All rights reserved. | 2 // Copyright 2006-2008 the V8 project authors. All rights reserved. |
3 // Redistribution and use in source and binary forms, with or without | 3 // Redistribution and use in source and binary forms, with or without |
4 // modification, are permitted provided that the following conditions are | 4 // modification, are permitted provided that the following conditions are |
5 // met: | 5 // met: |
6 // | 6 // |
7 // * Redistributions of source code must retain the above copyright | 7 // * Redistributions of source code must retain the above copyright |
8 // notice, this list of conditions and the following disclaimer. | 8 // notice, this list of conditions and the following disclaimer. |
9 // * Redistributions in binary form must reproduce the above | 9 // * Redistributions in binary form must reproduce the above |
10 // copyright notice, this list of conditions and the following | 10 // copyright notice, this list of conditions and the following |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
102 script_handle, | 102 script_handle, |
103 stack_trace_handle, | 103 stack_trace_handle, |
104 stack_frames_handle); | 104 stack_frames_handle); |
105 | 105 |
106 return message; | 106 return message; |
107 } | 107 } |
108 | 108 |
109 | 109 |
110 void MessageHandler::ReportMessage(MessageLocation* loc, | 110 void MessageHandler::ReportMessage(MessageLocation* loc, |
111 Handle<Object> message) { | 111 Handle<Object> message) { |
112 // If we are in process of message reporting, just ignore all other requests | |
113 // to report a message as they are due to unhandled exceptions thrown in | |
114 // message callbacks. | |
115 static int in_process = false; | |
Mads Ager (chromium)
2011/03/21 10:33:22
This will not work with isolates. You need this to
antonm
2011/03/21 18:15:48
Done.
| |
116 if (in_process) { | |
117 ReportMessage("uncaught exception thrown while reporting"); | |
118 return; | |
119 } | |
120 in_process = true; | |
121 | |
122 // We are calling into embedder's code which can throw exceptions. | |
123 // Thus we need to save current exception state, reset it to the clean one | |
124 // and ignore scheduled exceptions callbacks can throw. | |
125 Top::ExceptionScope exception_scope; | |
126 Top::clear_pending_exception(); | |
127 Top::set_external_caught_exception(false); | |
128 | |
112 v8::Local<v8::Message> api_message_obj = v8::Utils::MessageToLocal(message); | 129 v8::Local<v8::Message> api_message_obj = v8::Utils::MessageToLocal(message); |
113 | 130 |
114 v8::NeanderArray global_listeners(Factory::message_listeners()); | 131 v8::NeanderArray global_listeners(Factory::message_listeners()); |
115 int global_length = global_listeners.length(); | 132 int global_length = global_listeners.length(); |
116 if (global_length == 0) { | 133 if (global_length == 0) { |
117 DefaultMessageReport(loc, message); | 134 DefaultMessageReport(loc, message); |
135 if (Top::has_scheduled_exception()) { | |
136 Top::clear_scheduled_exception(); | |
137 } | |
118 } else { | 138 } else { |
119 for (int i = 0; i < global_length; i++) { | 139 for (int i = 0; i < global_length; i++) { |
120 HandleScope scope; | 140 HandleScope scope; |
121 if (global_listeners.get(i)->IsUndefined()) continue; | 141 if (global_listeners.get(i)->IsUndefined()) continue; |
122 v8::NeanderObject listener(JSObject::cast(global_listeners.get(i))); | 142 v8::NeanderObject listener(JSObject::cast(global_listeners.get(i))); |
123 Handle<Proxy> callback_obj(Proxy::cast(listener.get(0))); | 143 Handle<Proxy> callback_obj(Proxy::cast(listener.get(0))); |
124 v8::MessageCallback callback = | 144 v8::MessageCallback callback = |
125 FUNCTION_CAST<v8::MessageCallback>(callback_obj->proxy()); | 145 FUNCTION_CAST<v8::MessageCallback>(callback_obj->proxy()); |
126 Handle<Object> callback_data(listener.get(1)); | 146 Handle<Object> callback_data(listener.get(1)); |
127 callback(api_message_obj, v8::Utils::ToLocal(callback_data)); | 147 callback(api_message_obj, v8::Utils::ToLocal(callback_data)); |
148 if (Top::has_scheduled_exception()) { | |
149 Top::clear_scheduled_exception(); | |
150 } | |
128 } | 151 } |
129 } | 152 } |
153 | |
154 in_process = false; | |
130 } | 155 } |
131 | 156 |
132 | 157 |
133 Handle<String> MessageHandler::GetMessage(Handle<Object> data) { | 158 Handle<String> MessageHandler::GetMessage(Handle<Object> data) { |
134 Handle<String> fmt_str = Factory::LookupAsciiSymbol("FormatMessage"); | 159 Handle<String> fmt_str = Factory::LookupAsciiSymbol("FormatMessage"); |
135 Handle<JSFunction> fun = | 160 Handle<JSFunction> fun = |
136 Handle<JSFunction>(JSFunction::cast( | 161 Handle<JSFunction>(JSFunction::cast( |
137 Top::builtins()->GetPropertyNoExceptionThrown(*fmt_str))); | 162 Top::builtins()->GetPropertyNoExceptionThrown(*fmt_str))); |
138 Object** argv[1] = { data.location() }; | 163 Object** argv[1] = { data.location() }; |
139 | 164 |
(...skipping 15 matching lines...) Expand all Loading... | |
155 } | 180 } |
156 | 181 |
157 | 182 |
158 SmartPointer<char> MessageHandler::GetLocalizedMessage(Handle<Object> data) { | 183 SmartPointer<char> MessageHandler::GetLocalizedMessage(Handle<Object> data) { |
159 HandleScope scope; | 184 HandleScope scope; |
160 return GetMessage(data)->ToCString(DISALLOW_NULLS); | 185 return GetMessage(data)->ToCString(DISALLOW_NULLS); |
161 } | 186 } |
162 | 187 |
163 | 188 |
164 } } // namespace v8::internal | 189 } } // namespace v8::internal |
OLD | NEW |