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

Side by Side Diff: src/messages.cc

Issue 8133020: Simplify calling generated code from the runtime. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 9 years, 2 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
« src/ic.cc ('K') | « src/jsregexp.cc ('k') | src/objects.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 // Copyright 2011 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 2 // Redistribution and use in source and binary forms, with or without
4 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
5 // met: 4 // met:
6 // 5 //
7 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
8 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
9 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
10 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
11 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
12 // with the distribution. 11 // with the distribution.
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after
142 } 141 }
143 142
144 143
145 Handle<String> MessageHandler::GetMessage(Handle<Object> data) { 144 Handle<String> MessageHandler::GetMessage(Handle<Object> data) {
146 Handle<String> fmt_str = FACTORY->LookupAsciiSymbol("FormatMessage"); 145 Handle<String> fmt_str = FACTORY->LookupAsciiSymbol("FormatMessage");
147 Handle<JSFunction> fun = 146 Handle<JSFunction> fun =
148 Handle<JSFunction>( 147 Handle<JSFunction>(
149 JSFunction::cast( 148 JSFunction::cast(
150 Isolate::Current()->js_builtins_object()-> 149 Isolate::Current()->js_builtins_object()->
151 GetPropertyNoExceptionThrown(*fmt_str))); 150 GetPropertyNoExceptionThrown(*fmt_str)));
152 Object** argv[1] = { data.location() }; 151 Handle<Object> argv[] = { data };
153 152
154 bool caught_exception; 153 bool caught_exception;
155 Handle<Object> result = 154 Handle<Object> result =
156 Execution::TryCall(fun, 155 Execution::TryCall(fun,
157 Isolate::Current()->js_builtins_object(), 1, argv, &caught_exception); 156 Isolate::Current()->js_builtins_object(),
157 ARRAY_SIZE(argv),
158 argv,
159 &caught_exception);
158 160
159 if (caught_exception || !result->IsString()) { 161 if (caught_exception || !result->IsString()) {
160 return FACTORY->LookupAsciiSymbol("<error>"); 162 return FACTORY->LookupAsciiSymbol("<error>");
161 } 163 }
162 Handle<String> result_string = Handle<String>::cast(result); 164 Handle<String> result_string = Handle<String>::cast(result);
163 // A string that has been obtained from JS code in this way is 165 // 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 166 // 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 167 // here to improve the efficiency of converting it to a C string and
166 // other operations that are likely to take place (see GetLocalizedMessage 168 // other operations that are likely to take place (see GetLocalizedMessage
167 // for example). 169 // for example).
168 FlattenString(result_string); 170 FlattenString(result_string);
169 return result_string; 171 return result_string;
170 } 172 }
171 173
172 174
173 SmartArrayPointer<char> MessageHandler::GetLocalizedMessage( 175 SmartArrayPointer<char> MessageHandler::GetLocalizedMessage(
174 Handle<Object> data) { 176 Handle<Object> data) {
175 HandleScope scope; 177 HandleScope scope;
176 return GetMessage(data)->ToCString(DISALLOW_NULLS); 178 return GetMessage(data)->ToCString(DISALLOW_NULLS);
177 } 179 }
178 180
179 181
180 } } // namespace v8::internal 182 } } // namespace v8::internal
OLDNEW
« src/ic.cc ('K') | « src/jsregexp.cc ('k') | src/objects.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698