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

Side by Side Diff: src/messages.cc

Issue 174056: Add support for forceful termination of JavaScript execution. (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: '' Created 11 years, 4 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/ia32/codegen-ia32.cc ('k') | src/objects-debug.cc » ('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 129 matching lines...) Expand 10 before | Expand all | Expand 10 after
140 callback(api_message_obj, v8::Utils::ToLocal(callback_data)); 140 callback(api_message_obj, v8::Utils::ToLocal(callback_data));
141 } 141 }
142 } 142 }
143 } 143 }
144 144
145 145
146 Handle<String> MessageHandler::GetMessage(Handle<Object> data) { 146 Handle<String> MessageHandler::GetMessage(Handle<Object> data) {
147 Handle<String> fmt_str = Factory::LookupAsciiSymbol("FormatMessage"); 147 Handle<String> fmt_str = Factory::LookupAsciiSymbol("FormatMessage");
148 Handle<JSFunction> fun = 148 Handle<JSFunction> fun =
149 Handle<JSFunction>( 149 Handle<JSFunction>(
150 JSFunction::cast( 150 JSFunction::cast(Top::builtins()->GetProperty(*fmt_str)));
151 Top::builtins()->GetProperty(*fmt_str)));
152 Object** argv[1] = { data.location() }; 151 Object** argv[1] = { data.location() };
153 152
154 bool caught_exception; 153 bool caught_exception;
155 Handle<Object> result = 154 Handle<Object> result =
156 Execution::TryCall(fun, Top::builtins(), 1, argv, 155 Execution::TryCall(fun, Top::builtins(), 1, argv, &caught_exception);
157 &caught_exception);
158 156
159 if (caught_exception || !result->IsString()) { 157 if (caught_exception || !result->IsString()) {
160 return Factory::LookupAsciiSymbol("<error>"); 158 return Factory::LookupAsciiSymbol("<error>");
161 } 159 }
162 Handle<String> result_string = Handle<String>::cast(result); 160 Handle<String> result_string = Handle<String>::cast(result);
163 // A string that has been obtained from JS code in this way is 161 // A string that has been obtained from JS code in this way is
164 // likely to be a complicated ConsString of some sort. We flatten it 162 // likely to be a complicated ConsString of some sort. We flatten it
165 // here to improve the efficiency of converting it to a C string and 163 // here to improve the efficiency of converting it to a C string and
166 // other operations that are likely to take place (see GetLocalizedMessage 164 // other operations that are likely to take place (see GetLocalizedMessage
167 // for example). 165 // for example).
168 FlattenString(result_string); 166 FlattenString(result_string);
169 return result_string; 167 return result_string;
170 } 168 }
171 169
172 170
173 SmartPointer<char> MessageHandler::GetLocalizedMessage(Handle<Object> data) { 171 SmartPointer<char> MessageHandler::GetLocalizedMessage(Handle<Object> data) {
174 HandleScope scope; 172 HandleScope scope;
175 return GetMessage(data)->ToCString(DISALLOW_NULLS); 173 return GetMessage(data)->ToCString(DISALLOW_NULLS);
176 } 174 }
177 175
178 176
179 } } // namespace v8::internal 177 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/ia32/codegen-ia32.cc ('k') | src/objects-debug.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698