Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(676)

Side by Side Diff: src/messages.cc

Issue 6709028: Revert r7258 and r7260. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 9 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/handles.cc ('k') | src/top.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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 // We are calling into embedder's code which can throw exceptions.
113 // Thus we need to save current exception state, reset it to the clean one
114 // and ignore scheduled exceptions callbacks can throw.
115 Top::ExceptionScope exception_scope;
116 Top::clear_pending_exception();
117 Top::set_external_caught_exception(false);
118
119 v8::Local<v8::Message> api_message_obj = v8::Utils::MessageToLocal(message); 112 v8::Local<v8::Message> api_message_obj = v8::Utils::MessageToLocal(message);
120 113
121 v8::NeanderArray global_listeners(Factory::message_listeners()); 114 v8::NeanderArray global_listeners(Factory::message_listeners());
122 int global_length = global_listeners.length(); 115 int global_length = global_listeners.length();
123 if (global_length == 0) { 116 if (global_length == 0) {
124 DefaultMessageReport(loc, message); 117 DefaultMessageReport(loc, message);
125 if (Top::has_scheduled_exception()) {
126 // Consider logging it somehow.
127 Top::clear_scheduled_exception();
128 }
129 } else { 118 } else {
130 for (int i = 0; i < global_length; i++) { 119 for (int i = 0; i < global_length; i++) {
131 HandleScope scope; 120 HandleScope scope;
132 if (global_listeners.get(i)->IsUndefined()) continue; 121 if (global_listeners.get(i)->IsUndefined()) continue;
133 v8::NeanderObject listener(JSObject::cast(global_listeners.get(i))); 122 v8::NeanderObject listener(JSObject::cast(global_listeners.get(i)));
134 Handle<Proxy> callback_obj(Proxy::cast(listener.get(0))); 123 Handle<Proxy> callback_obj(Proxy::cast(listener.get(0)));
135 v8::MessageCallback callback = 124 v8::MessageCallback callback =
136 FUNCTION_CAST<v8::MessageCallback>(callback_obj->proxy()); 125 FUNCTION_CAST<v8::MessageCallback>(callback_obj->proxy());
137 Handle<Object> callback_data(listener.get(1)); 126 Handle<Object> callback_data(listener.get(1));
138 callback(api_message_obj, v8::Utils::ToLocal(callback_data)); 127 callback(api_message_obj, v8::Utils::ToLocal(callback_data));
139 if (Top::has_scheduled_exception()) {
140 // Consider logging it somehow.
141 Top::clear_scheduled_exception();
142 }
143 } 128 }
144 } 129 }
145 } 130 }
146 131
147 132
148 Handle<String> MessageHandler::GetMessage(Handle<Object> data) { 133 Handle<String> MessageHandler::GetMessage(Handle<Object> data) {
149 Handle<String> fmt_str = Factory::LookupAsciiSymbol("FormatMessage"); 134 Handle<String> fmt_str = Factory::LookupAsciiSymbol("FormatMessage");
150 Handle<JSFunction> fun = 135 Handle<JSFunction> fun =
151 Handle<JSFunction>(JSFunction::cast( 136 Handle<JSFunction>(JSFunction::cast(
152 Top::builtins()->GetPropertyNoExceptionThrown(*fmt_str))); 137 Top::builtins()->GetPropertyNoExceptionThrown(*fmt_str)));
(...skipping 17 matching lines...) Expand all
170 } 155 }
171 156
172 157
173 SmartPointer<char> MessageHandler::GetLocalizedMessage(Handle<Object> data) { 158 SmartPointer<char> MessageHandler::GetLocalizedMessage(Handle<Object> data) {
174 HandleScope scope; 159 HandleScope scope;
175 return GetMessage(data)->ToCString(DISALLOW_NULLS); 160 return GetMessage(data)->ToCString(DISALLOW_NULLS);
176 } 161 }
177 162
178 163
179 } } // namespace v8::internal 164 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/handles.cc ('k') | src/top.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698