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

Side by Side Diff: vm/dart_entry.cc

Issue 10783035: Create frequently used symbols in the vm isolate (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/runtime/
Patch Set: Created 8 years, 5 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 | « vm/dart_api_impl.cc ('k') | vm/dart_entry_test.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 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 #include "vm/dart_entry.h" 5 #include "vm/dart_entry.h"
6 6
7 #include "vm/code_generator.h" 7 #include "vm/code_generator.h"
8 #include "vm/compiler.h" 8 #include "vm/compiler.h"
9 #include "vm/object_store.h" 9 #include "vm/object_store.h"
10 #include "vm/resolver.h" 10 #include "vm/resolver.h"
11 #include "vm/stub_code.h" 11 #include "vm/stub_code.h"
12 #include "vm/symbols.h"
12 13
13 namespace dart { 14 namespace dart {
14 15
15 RawObject* DartEntry::InvokeDynamic( 16 RawObject* DartEntry::InvokeDynamic(
16 const Instance& receiver, 17 const Instance& receiver,
17 const Function& function, 18 const Function& function,
18 const GrowableArray<const Object*>& arguments, 19 const GrowableArray<const Object*>& arguments,
19 const Array& optional_arguments_names) { 20 const Array& optional_arguments_names) {
20 // Get the entrypoint corresponding to the function specified, this 21 // Get the entrypoint corresponding to the function specified, this
21 // will result in a compilation of the function if it is not already 22 // will result in a compilation of the function if it is not already
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after
168 const GrowableArray<const Object*>& arguments) { 169 const GrowableArray<const Object*>& arguments) {
169 const Class& cls = Class::Handle(lib.LookupClass(class_name)); 170 const Class& cls = Class::Handle(lib.LookupClass(class_name));
170 ASSERT(!cls.IsNull()); 171 ASSERT(!cls.IsNull());
171 // For now, we only support a non-parameterized or raw type. 172 // For now, we only support a non-parameterized or raw type.
172 const Instance& exception_object = Instance::Handle(Instance::New(cls)); 173 const Instance& exception_object = Instance::Handle(Instance::New(cls));
173 GrowableArray<const Object*> constructor_arguments(arguments.length() + 2); 174 GrowableArray<const Object*> constructor_arguments(arguments.length() + 2);
174 constructor_arguments.Add(&exception_object); 175 constructor_arguments.Add(&exception_object);
175 constructor_arguments.Add(&Smi::Handle(Smi::New(Function::kCtorPhaseAll))); 176 constructor_arguments.Add(&Smi::Handle(Smi::New(Function::kCtorPhaseAll)));
176 constructor_arguments.AddArray(arguments); 177 constructor_arguments.AddArray(arguments);
177 178
178 const String& period = String::Handle(String::New(".")); 179 const String& period = String::Handle(Symbols::Dot());
179 String& constructor_name = String::Handle(String::Concat(class_name, period)); 180 String& constructor_name = String::Handle(String::Concat(class_name, period));
180 Function& constructor = 181 Function& constructor =
181 Function::Handle(cls.LookupConstructor(constructor_name)); 182 Function::Handle(cls.LookupConstructor(constructor_name));
182 ASSERT(!constructor.IsNull()); 183 ASSERT(!constructor.IsNull());
183 const Array& kNoArgumentNames = Array::Handle(); 184 const Array& kNoArgumentNames = Array::Handle();
184 const Object& retval = Object::Handle( 185 const Object& retval = Object::Handle(
185 DartEntry::InvokeStatic(constructor, constructor_arguments, 186 DartEntry::InvokeStatic(constructor, constructor_arguments,
186 kNoArgumentNames)); 187 kNoArgumentNames));
187 ASSERT(retval.IsNull() || retval.IsError()); 188 ASSERT(retval.IsNull() || retval.IsError());
188 if (retval.IsError()) { 189 if (retval.IsError()) {
189 return retval.raw(); 190 return retval.raw();
190 } 191 }
191 return exception_object.raw(); 192 return exception_object.raw();
192 } 193 }
193 194
194 195
195 RawObject* DartLibraryCalls::ToString(const Instance& receiver) { 196 RawObject* DartLibraryCalls::ToString(const Instance& receiver) {
196 const String& function_name = 197 const String& function_name =
197 String::Handle(String::NewSymbol("toString")); 198 String::Handle(Symbols::New("toString"));
198 GrowableArray<const Object*> arguments; 199 GrowableArray<const Object*> arguments;
199 const int kNumArguments = 1; // Receiver. 200 const int kNumArguments = 1; // Receiver.
200 const int kNumNamedArguments = 0; // None. 201 const int kNumNamedArguments = 0; // None.
201 const Array& kNoArgumentNames = Array::Handle(); 202 const Array& kNoArgumentNames = Array::Handle();
202 const Function& function = Function::Handle( 203 const Function& function = Function::Handle(
203 Resolver::ResolveDynamic(receiver, 204 Resolver::ResolveDynamic(receiver,
204 function_name, 205 function_name,
205 kNumArguments, 206 kNumArguments,
206 kNumNamedArguments)); 207 kNumNamedArguments));
207 ASSERT(!function.IsNull()); 208 ASSERT(!function.IsNull());
208 const Object& result = Object::Handle( 209 const Object& result = Object::Handle(
209 DartEntry::InvokeDynamic(receiver, 210 DartEntry::InvokeDynamic(receiver,
210 function, 211 function,
211 arguments, 212 arguments,
212 kNoArgumentNames)); 213 kNoArgumentNames));
213 ASSERT(result.IsInstance() || result.IsError()); 214 ASSERT(result.IsInstance() || result.IsError());
214 return result.raw(); 215 return result.raw();
215 } 216 }
216 217
217 218
218 RawObject* DartLibraryCalls::Equals(const Instance& left, 219 RawObject* DartLibraryCalls::Equals(const Instance& left,
219 const Instance& right) { 220 const Instance& right) {
220 const String& function_name = 221 const String& function_name =
221 String::Handle(String::NewSymbol("==")); 222 String::Handle(Symbols::New("=="));
222 GrowableArray<const Object*> arguments; 223 GrowableArray<const Object*> arguments;
223 arguments.Add(&right); 224 arguments.Add(&right);
224 const int kNumArguments = 2; 225 const int kNumArguments = 2;
225 const int kNumNamedArguments = 0; 226 const int kNumNamedArguments = 0;
226 const Array& kNoArgumentNames = Array::Handle(); 227 const Array& kNoArgumentNames = Array::Handle();
227 const Function& function = Function::Handle( 228 const Function& function = Function::Handle(
228 Resolver::ResolveDynamic(left, 229 Resolver::ResolveDynamic(left,
229 function_name, 230 function_name,
230 kNumArguments, 231 kNumArguments,
231 kNumNamedArguments)); 232 kNumNamedArguments));
232 ASSERT(!function.IsNull()); 233 ASSERT(!function.IsNull());
233 const Object& result = Object::Handle( 234 const Object& result = Object::Handle(
234 DartEntry::InvokeDynamic(left, function, arguments, kNoArgumentNames)); 235 DartEntry::InvokeDynamic(left, function, arguments, kNoArgumentNames));
235 ASSERT(result.IsInstance() || result.IsError()); 236 ASSERT(result.IsInstance() || result.IsError());
236 return result.raw(); 237 return result.raw();
237 } 238 }
238 239
239 240
240 RawObject* DartLibraryCalls::HandleMessage(Dart_Port dest_port_id, 241 RawObject* DartLibraryCalls::HandleMessage(Dart_Port dest_port_id,
241 Dart_Port reply_port_id, 242 Dart_Port reply_port_id,
242 const Instance& message) { 243 const Instance& message) {
243 Library& isolate_lib = Library::Handle(Library::IsolateLibrary()); 244 Library& isolate_lib = Library::Handle(Library::IsolateLibrary());
244 ASSERT(!isolate_lib.IsNull()); 245 ASSERT(!isolate_lib.IsNull());
245 const String& public_class_name = 246 const String& public_class_name =
246 String::Handle(String::NewSymbol("_ReceivePortImpl")); 247 String::Handle(Symbols::New("_ReceivePortImpl"));
247 const String& class_name = 248 const String& class_name =
248 String::Handle(isolate_lib.PrivateName(public_class_name)); 249 String::Handle(isolate_lib.PrivateName(public_class_name));
249 const String& function_name = 250 const String& function_name =
250 String::Handle(String::NewSymbol("_handleMessage")); 251 String::Handle(Symbols::New("_handleMessage"));
251 const int kNumArguments = 3; 252 const int kNumArguments = 3;
252 const Array& kNoArgumentNames = Array::Handle(); 253 const Array& kNoArgumentNames = Array::Handle();
253 const Function& function = Function::Handle( 254 const Function& function = Function::Handle(
254 Resolver::ResolveStatic(isolate_lib, 255 Resolver::ResolveStatic(isolate_lib,
255 class_name, 256 class_name,
256 function_name, 257 function_name,
257 kNumArguments, 258 kNumArguments,
258 kNoArgumentNames, 259 kNoArgumentNames,
259 Resolver::kIsQualified)); 260 Resolver::kIsQualified));
260 GrowableArray<const Object*> arguments(kNumArguments); 261 GrowableArray<const Object*> arguments(kNumArguments);
261 arguments.Add(&Integer::Handle(Integer::New(dest_port_id))); 262 arguments.Add(&Integer::Handle(Integer::New(dest_port_id)));
262 arguments.Add(&Integer::Handle(Integer::New(reply_port_id))); 263 arguments.Add(&Integer::Handle(Integer::New(reply_port_id)));
263 arguments.Add(&message); 264 arguments.Add(&message);
264 const Object& result = Object::Handle( 265 const Object& result = Object::Handle(
265 DartEntry::InvokeStatic(function, arguments, kNoArgumentNames)); 266 DartEntry::InvokeStatic(function, arguments, kNoArgumentNames));
266 ASSERT(result.IsNull() || result.IsError()); 267 ASSERT(result.IsNull() || result.IsError());
267 return result.raw(); 268 return result.raw();
268 } 269 }
269 270
270 271
271 RawObject* DartLibraryCalls::NewSendPort(intptr_t port_id) { 272 RawObject* DartLibraryCalls::NewSendPort(intptr_t port_id) {
272 Library& isolate_lib = Library::Handle(Library::IsolateLibrary()); 273 Library& isolate_lib = Library::Handle(Library::IsolateLibrary());
273 ASSERT(!isolate_lib.IsNull()); 274 ASSERT(!isolate_lib.IsNull());
274 const String& public_class_name = 275 const String& public_class_name =
275 String::Handle(String::New("_SendPortImpl")); 276 String::Handle(String::New("_SendPortImpl"));
276 const String& class_name = 277 const String& class_name =
277 String::Handle(isolate_lib.PrivateName(public_class_name)); 278 String::Handle(isolate_lib.PrivateName(public_class_name));
278 const String& function_name = String::Handle(String::NewSymbol("_create")); 279 const String& function_name = String::Handle(Symbols::New("_create"));
279 const int kNumArguments = 1; 280 const int kNumArguments = 1;
280 const Array& kNoArgumentNames = Array::Handle(); 281 const Array& kNoArgumentNames = Array::Handle();
281 const Function& function = Function::Handle( 282 const Function& function = Function::Handle(
282 Resolver::ResolveStatic(isolate_lib, 283 Resolver::ResolveStatic(isolate_lib,
283 class_name, 284 class_name,
284 function_name, 285 function_name,
285 kNumArguments, 286 kNumArguments,
286 kNoArgumentNames, 287 kNoArgumentNames,
287 Resolver::kIsQualified)); 288 Resolver::kIsQualified));
288 GrowableArray<const Object*> arguments(kNumArguments); 289 GrowableArray<const Object*> arguments(kNumArguments);
(...skipping 13 matching lines...) Expand all
302 args.Add(&key); 303 args.Add(&key);
303 args.Add(&value); 304 args.Add(&value);
304 const Array& kNoArgumentNames = Array::Handle(); 305 const Array& kNoArgumentNames = Array::Handle();
305 const Object& result = Object::Handle( 306 const Object& result = Object::Handle(
306 DartEntry::InvokeDynamic(map, function, args, kNoArgumentNames)); 307 DartEntry::InvokeDynamic(map, function, args, kNoArgumentNames));
307 return result.raw(); 308 return result.raw();
308 } 309 }
309 310
310 311
311 RawObject* DartLibraryCalls::PortGetId(const Instance& port) { 312 RawObject* DartLibraryCalls::PortGetId(const Instance& port) {
312 const String& field_name = String::Handle(String::NewSymbol("_id")); 313 const String& field_name = String::Handle(Symbols::New("_id"));
313 const Class& cls = Class::Handle(port.clazz()); 314 const Class& cls = Class::Handle(port.clazz());
314 const String& func_name = String::Handle(Field::GetterName(field_name)); 315 const String& func_name = String::Handle(Field::GetterName(field_name));
315 const Function& func = Function::Handle(cls.LookupDynamicFunction(func_name)); 316 const Function& func = Function::Handle(cls.LookupDynamicFunction(func_name));
316 ASSERT(!func.IsNull()); 317 ASSERT(!func.IsNull());
317 GrowableArray<const Object*> arguments; 318 GrowableArray<const Object*> arguments;
318 const Array& kNoArgumentNames = Array::Handle(); 319 const Array& kNoArgumentNames = Array::Handle();
319 return DartEntry::InvokeDynamic(port, func, arguments, kNoArgumentNames); 320 return DartEntry::InvokeDynamic(port, func, arguments, kNoArgumentNames);
320 } 321 }
321 322
322 323
323 } // namespace dart 324 } // namespace dart
OLDNEW
« no previous file with comments | « vm/dart_api_impl.cc ('k') | vm/dart_entry_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698