OLD | NEW |
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/simulator.h" |
11 #include "vm/stub_code.h" | 12 #include "vm/stub_code.h" |
12 #include "vm/symbols.h" | 13 #include "vm/symbols.h" |
13 | 14 |
14 namespace dart { | 15 namespace dart { |
15 | 16 |
16 // A cache of VM heap allocated arguments descriptors. | 17 // A cache of VM heap allocated arguments descriptors. |
17 RawArray* ArgumentsDescriptor::cached_args_descriptors_[kCachedDescriptorCount]; | 18 RawArray* ArgumentsDescriptor::cached_args_descriptors_[kCachedDescriptorCount]; |
18 | 19 |
19 | 20 |
20 RawObject* DartEntry::InvokeDynamic(const Function& function, | 21 RawObject* DartEntry::InvokeFunction(const Function& function, |
21 const Array& arguments) { | 22 const Array& arguments) { |
22 const Array& arg_desc = | 23 const Array& arguments_descriptor = |
23 Array::Handle(ArgumentsDescriptor::New(arguments.Length())); | 24 Array::Handle(ArgumentsDescriptor::New(arguments.Length())); |
24 return InvokeDynamic(function, arguments, arg_desc); | 25 return InvokeFunction(function, arguments, arguments_descriptor); |
25 } | 26 } |
26 | 27 |
27 | 28 |
28 RawObject* DartEntry::InvokeDynamic(const Function& function, | 29 RawObject* DartEntry::InvokeFunction(const Function& function, |
29 const Array& arguments, | 30 const Array& arguments, |
30 const Array& arguments_descriptor) { | 31 const Array& arguments_descriptor) { |
| 32 const Context& context = |
| 33 Context::ZoneHandle(Isolate::Current()->object_store()->empty_context()); |
| 34 ASSERT(context.isolate() == Isolate::Current()); |
| 35 return InvokeFunction(function, arguments, arguments_descriptor, context); |
| 36 } |
| 37 |
| 38 |
| 39 RawObject* DartEntry::InvokeFunction(const Function& function, |
| 40 const Array& arguments, |
| 41 const Array& arguments_descriptor, |
| 42 const Context& context) { |
31 // Get the entrypoint corresponding to the function specified, this | 43 // Get the entrypoint corresponding to the function specified, this |
32 // will result in a compilation of the function if it is not already | 44 // will result in a compilation of the function if it is not already |
33 // compiled. | 45 // compiled. |
34 if (!function.HasCode()) { | 46 if (!function.HasCode()) { |
35 const Error& error = Error::Handle(Compiler::CompileFunction(function)); | 47 const Error& error = Error::Handle(Compiler::CompileFunction(function)); |
36 if (!error.IsNull()) { | 48 if (!error.IsNull()) { |
37 return error.raw(); | |
38 } | |
39 } | |
40 | |
41 // Now Call the invoke stub which will invoke the dart function. | |
42 invokestub entrypoint = reinterpret_cast<invokestub>( | |
43 StubCode::InvokeDartCodeEntryPoint()); | |
44 const Context& context = | |
45 Context::ZoneHandle(Isolate::Current()->object_store()->empty_context()); | |
46 ASSERT(context.isolate() == Isolate::Current()); | |
47 const Code& code = Code::Handle(function.CurrentCode()); | |
48 ASSERT(!code.IsNull()); | |
49 ASSERT(Isolate::Current()->no_callback_scope_depth() == 0); | |
50 return entrypoint(code.EntryPoint(), | |
51 arguments_descriptor, | |
52 arguments, | |
53 context); | |
54 } | |
55 | |
56 | |
57 RawObject* DartEntry::InvokeStatic(const Function& function, | |
58 const Array& arguments) { | |
59 const Array& arguments_descriptor = | |
60 Array::Handle(ArgumentsDescriptor::New(arguments.Length())); | |
61 return InvokeStatic(function, arguments, arguments_descriptor); | |
62 } | |
63 | |
64 | |
65 RawObject* DartEntry::InvokeStatic(const Function& function, | |
66 const Array& arguments, | |
67 const Array& arguments_descriptor) { | |
68 // Get the entrypoint corresponding to the function specified, this | |
69 // will result in a compilation of the function if it is not already | |
70 // compiled. | |
71 ASSERT(!function.IsNull()); | |
72 if (!function.HasCode()) { | |
73 const Error& error = Error::Handle(Compiler::CompileFunction(function)); | |
74 if (!error.IsNull()) { | |
75 return error.raw(); | 49 return error.raw(); |
76 } | 50 } |
77 } | 51 } |
78 // Now Call the invoke stub which will invoke the dart function. | 52 // Now Call the invoke stub which will invoke the dart function. |
79 invokestub entrypoint = reinterpret_cast<invokestub>( | 53 invokestub entrypoint = reinterpret_cast<invokestub>( |
80 StubCode::InvokeDartCodeEntryPoint()); | 54 StubCode::InvokeDartCodeEntryPoint()); |
81 const Context& context = | |
82 Context::ZoneHandle(Isolate::Current()->object_store()->empty_context()); | |
83 ASSERT(context.isolate() == Isolate::Current()); | |
84 const Code& code = Code::Handle(function.CurrentCode()); | 55 const Code& code = Code::Handle(function.CurrentCode()); |
85 ASSERT(!code.IsNull()); | 56 ASSERT(!code.IsNull()); |
86 ASSERT(Isolate::Current()->no_callback_scope_depth() == 0); | 57 ASSERT(Isolate::Current()->no_callback_scope_depth() == 0); |
87 return entrypoint(code.EntryPoint(), | 58 #ifdef USING_SIMULATOR |
88 arguments_descriptor, | 59 return bit_copy<RawObject*, int64_t>(Simulator::Current()->Call( |
89 arguments, | 60 reinterpret_cast<int32_t>(entrypoint), |
90 context); | 61 static_cast<int32_t>(code.EntryPoint()), |
| 62 reinterpret_cast<int32_t>(&arguments_descriptor), |
| 63 reinterpret_cast<int32_t>(&arguments), |
| 64 reinterpret_cast<int32_t>(&context), |
| 65 0)); |
| 66 #else |
| 67 return entrypoint(code.EntryPoint(), |
| 68 arguments_descriptor, |
| 69 arguments, |
| 70 context); |
| 71 #endif |
91 } | 72 } |
92 | 73 |
93 | 74 |
94 RawObject* DartEntry::InvokeClosure(const Instance& closure, | 75 RawObject* DartEntry::InvokeClosure(const Array& arguments) { |
95 const Array& arguments) { | |
96 const Array& arguments_descriptor = | 76 const Array& arguments_descriptor = |
97 Array::Handle(ArgumentsDescriptor::New(arguments.Length())); | 77 Array::Handle(ArgumentsDescriptor::New(arguments.Length())); |
98 return InvokeClosure(closure, arguments, arguments_descriptor); | 78 return InvokeClosure(arguments, arguments_descriptor); |
99 } | 79 } |
100 | 80 |
101 | 81 |
102 RawObject* DartEntry::InvokeClosure(const Instance& instance, | 82 RawObject* DartEntry::InvokeClosure(const Array& arguments, |
103 const Array& arguments, | |
104 const Array& arguments_descriptor) { | 83 const Array& arguments_descriptor) { |
105 ASSERT(instance.raw() == arguments.At(0)); | 84 Instance& instance = Instance::Handle(); |
| 85 instance ^= arguments.At(0); |
106 // Get the entrypoint corresponding to the closure function or to the call | 86 // Get the entrypoint corresponding to the closure function or to the call |
107 // method of the instance. This will result in a compilation of the function | 87 // method of the instance. This will result in a compilation of the function |
108 // if it is not already compiled. | 88 // if it is not already compiled. |
109 Function& function = Function::Handle(); | 89 Function& function = Function::Handle(); |
110 Context& context = Context::Handle(); | 90 Context& context = Context::Handle(); |
111 if (instance.IsCallable(&function, &context)) { | 91 if (instance.IsCallable(&function, &context)) { |
112 // Only invoke the function if its arguments are compatible. | 92 // Only invoke the function if its arguments are compatible. |
113 const ArgumentsDescriptor args_desc(arguments_descriptor); | 93 const ArgumentsDescriptor args_desc(arguments_descriptor); |
114 if (function.AreValidArgumentCounts(args_desc.Count(), | 94 if (function.AreValidArgumentCounts(args_desc.Count(), |
115 args_desc.NamedCount(), | 95 args_desc.NamedCount(), |
116 NULL)) { | 96 NULL)) { |
117 if (!function.HasCode()) { | |
118 const Error& error = Error::Handle(Compiler::CompileFunction(function)); | |
119 if (!error.IsNull()) { | |
120 return error.raw(); | |
121 } | |
122 } | |
123 // Now call the invoke stub which will invoke the closure function or | |
124 // 'call' function. | |
125 // The closure or non-closure object (receiver) is passed as implicit | 97 // The closure or non-closure object (receiver) is passed as implicit |
126 // first argument. It is already included in the arguments array. | 98 // first argument. It is already included in the arguments array. |
127 invokestub entrypoint = reinterpret_cast<invokestub>( | 99 return InvokeFunction(function, arguments, arguments_descriptor, context); |
128 StubCode::InvokeDartCodeEntryPoint()); | |
129 ASSERT(context.isolate() == Isolate::Current()); | |
130 const Code& code = Code::Handle(function.CurrentCode()); | |
131 ASSERT(!code.IsNull()); | |
132 ASSERT(Isolate::Current()->no_callback_scope_depth() == 0); | |
133 return entrypoint(code.EntryPoint(), | |
134 arguments_descriptor, | |
135 arguments, | |
136 context); | |
137 } | 100 } |
138 } | 101 } |
139 // There is no compatible 'call' method, so invoke noSuchMethod. | 102 // There is no compatible 'call' method, so invoke noSuchMethod. |
140 return InvokeNoSuchMethod(instance, | 103 return InvokeNoSuchMethod(instance, |
141 Symbols::Call(), | 104 Symbols::Call(), |
142 arguments, | 105 arguments, |
143 arguments_descriptor); | 106 arguments_descriptor); |
144 } | 107 } |
145 | 108 |
146 | 109 |
(...skipping 15 matching lines...) Expand all Loading... |
162 Resolver::ResolveStaticByName(invocation_mirror_class, | 125 Resolver::ResolveStaticByName(invocation_mirror_class, |
163 function_name, | 126 function_name, |
164 Resolver::kIsQualified)); | 127 Resolver::kIsQualified)); |
165 ASSERT(!allocation_function.IsNull()); | 128 ASSERT(!allocation_function.IsNull()); |
166 const int kNumAllocationArgs = 3; | 129 const int kNumAllocationArgs = 3; |
167 const Array& allocation_args = Array::Handle(Array::New(kNumAllocationArgs)); | 130 const Array& allocation_args = Array::Handle(Array::New(kNumAllocationArgs)); |
168 allocation_args.SetAt(0, target_name); | 131 allocation_args.SetAt(0, target_name); |
169 allocation_args.SetAt(1, arguments_descriptor); | 132 allocation_args.SetAt(1, arguments_descriptor); |
170 allocation_args.SetAt(2, arguments); | 133 allocation_args.SetAt(2, arguments); |
171 const Object& invocation_mirror = Object::Handle( | 134 const Object& invocation_mirror = Object::Handle( |
172 InvokeStatic(allocation_function, allocation_args)); | 135 InvokeFunction(allocation_function, allocation_args)); |
173 | 136 |
174 // Now use the invocation mirror object and invoke NoSuchMethod. | 137 // Now use the invocation mirror object and invoke NoSuchMethod. |
175 const int kNumArguments = 2; | 138 const int kNumArguments = 2; |
176 const int kNumNamedArguments = 0; | 139 const int kNumNamedArguments = 0; |
177 const Function& function = Function::Handle( | 140 const Function& function = Function::Handle( |
178 Resolver::ResolveDynamic(receiver, | 141 Resolver::ResolveDynamic(receiver, |
179 Symbols::NoSuchMethod(), | 142 Symbols::NoSuchMethod(), |
180 kNumArguments, | 143 kNumArguments, |
181 kNumNamedArguments)); | 144 kNumNamedArguments)); |
182 ASSERT(!function.IsNull()); | 145 ASSERT(!function.IsNull()); |
183 const Array& args = Array::Handle(Array::New(kNumArguments)); | 146 const Array& args = Array::Handle(Array::New(kNumArguments)); |
184 args.SetAt(0, receiver); | 147 args.SetAt(0, receiver); |
185 args.SetAt(1, invocation_mirror); | 148 args.SetAt(1, invocation_mirror); |
186 return InvokeDynamic(function, args); | 149 return InvokeFunction(function, args); |
187 } | 150 } |
188 | 151 |
189 | 152 |
190 ArgumentsDescriptor::ArgumentsDescriptor(const Array& array) | 153 ArgumentsDescriptor::ArgumentsDescriptor(const Array& array) |
191 : array_(array) { | 154 : array_(array) { |
192 } | 155 } |
193 | 156 |
194 | 157 |
195 intptr_t ArgumentsDescriptor::Count() const { | 158 intptr_t ArgumentsDescriptor::Count() const { |
196 return Smi::CheckedHandle(array_.At(kCountIndex)).Value(); | 159 return Smi::CheckedHandle(array_.At(kCountIndex)).Value(); |
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
343 obj = arguments.At(i); | 306 obj = arguments.At(i); |
344 constructor_arguments.SetAt((i + kNumExtraArgs), obj); | 307 constructor_arguments.SetAt((i + kNumExtraArgs), obj); |
345 } | 308 } |
346 | 309 |
347 const String& function_name = String::Handle( | 310 const String& function_name = String::Handle( |
348 String::Concat(class_name, constructor_name)); | 311 String::Concat(class_name, constructor_name)); |
349 const Function& constructor = | 312 const Function& constructor = |
350 Function::Handle(cls.LookupConstructorAllowPrivate(function_name)); | 313 Function::Handle(cls.LookupConstructorAllowPrivate(function_name)); |
351 ASSERT(!constructor.IsNull()); | 314 ASSERT(!constructor.IsNull()); |
352 const Object& retval = | 315 const Object& retval = |
353 Object::Handle(DartEntry::InvokeStatic(constructor, constructor_arguments)); | 316 Object::Handle(DartEntry::InvokeFunction(constructor, |
| 317 constructor_arguments)); |
354 ASSERT(retval.IsNull() || retval.IsError()); | 318 ASSERT(retval.IsNull() || retval.IsError()); |
355 if (retval.IsError()) { | 319 if (retval.IsError()) { |
356 return retval.raw(); | 320 return retval.raw(); |
357 } | 321 } |
358 return exception_object.raw(); | 322 return exception_object.raw(); |
359 } | 323 } |
360 | 324 |
361 | 325 |
362 RawObject* DartLibraryCalls::ToString(const Instance& receiver) { | 326 RawObject* DartLibraryCalls::ToString(const Instance& receiver) { |
363 const int kNumArguments = 1; // Receiver. | 327 const int kNumArguments = 1; // Receiver. |
364 const int kNumNamedArguments = 0; // None. | 328 const int kNumNamedArguments = 0; // None. |
365 const Function& function = Function::Handle( | 329 const Function& function = Function::Handle( |
366 Resolver::ResolveDynamic(receiver, | 330 Resolver::ResolveDynamic(receiver, |
367 Symbols::toString(), | 331 Symbols::toString(), |
368 kNumArguments, | 332 kNumArguments, |
369 kNumNamedArguments)); | 333 kNumNamedArguments)); |
370 ASSERT(!function.IsNull()); | 334 ASSERT(!function.IsNull()); |
371 const Array& args = Array::Handle(Array::New(kNumArguments)); | 335 const Array& args = Array::Handle(Array::New(kNumArguments)); |
372 args.SetAt(0, receiver); | 336 args.SetAt(0, receiver); |
373 const Object& result = Object::Handle(DartEntry::InvokeDynamic(function, | 337 const Object& result = Object::Handle(DartEntry::InvokeFunction(function, |
374 args)); | 338 args)); |
375 ASSERT(result.IsInstance() || result.IsError()); | 339 ASSERT(result.IsInstance() || result.IsError()); |
376 return result.raw(); | 340 return result.raw(); |
377 } | 341 } |
378 | 342 |
379 | 343 |
380 RawObject* DartLibraryCalls::Equals(const Instance& left, | 344 RawObject* DartLibraryCalls::Equals(const Instance& left, |
381 const Instance& right) { | 345 const Instance& right) { |
382 const int kNumArguments = 2; | 346 const int kNumArguments = 2; |
383 const int kNumNamedArguments = 0; | 347 const int kNumNamedArguments = 0; |
384 const Function& function = Function::Handle( | 348 const Function& function = Function::Handle( |
385 Resolver::ResolveDynamic(left, | 349 Resolver::ResolveDynamic(left, |
386 Symbols::EqualOperator(), | 350 Symbols::EqualOperator(), |
387 kNumArguments, | 351 kNumArguments, |
388 kNumNamedArguments)); | 352 kNumNamedArguments)); |
389 ASSERT(!function.IsNull()); | 353 ASSERT(!function.IsNull()); |
390 | 354 |
391 const Array& args = Array::Handle(Array::New(kNumArguments)); | 355 const Array& args = Array::Handle(Array::New(kNumArguments)); |
392 args.SetAt(0, left); | 356 args.SetAt(0, left); |
393 args.SetAt(1, right); | 357 args.SetAt(1, right); |
394 const Object& result = Object::Handle(DartEntry::InvokeDynamic(function, | 358 const Object& result = Object::Handle(DartEntry::InvokeFunction(function, |
395 args)); | 359 args)); |
396 ASSERT(result.IsInstance() || result.IsError()); | 360 ASSERT(result.IsInstance() || result.IsError()); |
397 return result.raw(); | 361 return result.raw(); |
398 } | 362 } |
399 | 363 |
400 | 364 |
401 RawObject* DartLibraryCalls::LookupReceivePort(Dart_Port port_id) { | 365 RawObject* DartLibraryCalls::LookupReceivePort(Dart_Port port_id) { |
402 Isolate* isolate = Isolate::Current(); | 366 Isolate* isolate = Isolate::Current(); |
403 Function& function = | 367 Function& function = |
404 Function::Handle(isolate, | 368 Function::Handle(isolate, |
405 isolate->object_store()->lookup_receive_port_function()); | 369 isolate->object_store()->lookup_receive_port_function()); |
406 const int kNumArguments = 1; | 370 const int kNumArguments = 1; |
407 if (function.IsNull()) { | 371 if (function.IsNull()) { |
408 Library& isolate_lib = Library::Handle(Library::IsolateLibrary()); | 372 Library& isolate_lib = Library::Handle(Library::IsolateLibrary()); |
409 ASSERT(!isolate_lib.IsNull()); | 373 ASSERT(!isolate_lib.IsNull()); |
410 const String& class_name = | 374 const String& class_name = |
411 String::Handle(isolate_lib.PrivateName(Symbols::_ReceivePortImpl())); | 375 String::Handle(isolate_lib.PrivateName(Symbols::_ReceivePortImpl())); |
412 const String& function_name = | 376 const String& function_name = |
413 String::Handle(isolate_lib.PrivateName(Symbols::_lookupReceivePort())); | 377 String::Handle(isolate_lib.PrivateName(Symbols::_lookupReceivePort())); |
414 function = Resolver::ResolveStatic(isolate_lib, | 378 function = Resolver::ResolveStatic(isolate_lib, |
415 class_name, | 379 class_name, |
416 function_name, | 380 function_name, |
417 kNumArguments, | 381 kNumArguments, |
418 Object::empty_array(), | 382 Object::empty_array(), |
419 Resolver::kIsQualified); | 383 Resolver::kIsQualified); |
420 isolate->object_store()->set_lookup_receive_port_function(function); | 384 isolate->object_store()->set_lookup_receive_port_function(function); |
421 } | 385 } |
422 const Array& args = Array::Handle(Array::New(kNumArguments)); | 386 const Array& args = Array::Handle(Array::New(kNumArguments)); |
423 args.SetAt(0, Integer::Handle(Integer::New(port_id))); | 387 args.SetAt(0, Integer::Handle(Integer::New(port_id))); |
424 const Object& result = | 388 const Object& result = |
425 Object::Handle(DartEntry::InvokeStatic(function, args)); | 389 Object::Handle(DartEntry::InvokeFunction(function, args)); |
426 return result.raw(); | 390 return result.raw(); |
427 } | 391 } |
428 | 392 |
429 | 393 |
430 RawObject* DartLibraryCalls::HandleMessage(const Object& receive_port, | 394 RawObject* DartLibraryCalls::HandleMessage(const Object& receive_port, |
431 Dart_Port reply_port_id, | 395 Dart_Port reply_port_id, |
432 const Instance& message) { | 396 const Instance& message) { |
433 Isolate* isolate = Isolate::Current(); | 397 Isolate* isolate = Isolate::Current(); |
434 Function& function = | 398 Function& function = |
435 Function::Handle(isolate, | 399 Function::Handle(isolate, |
(...skipping 12 matching lines...) Expand all Loading... |
448 kNumArguments, | 412 kNumArguments, |
449 Object::empty_array(), | 413 Object::empty_array(), |
450 Resolver::kIsQualified); | 414 Resolver::kIsQualified); |
451 isolate->object_store()->set_handle_message_function(function); | 415 isolate->object_store()->set_handle_message_function(function); |
452 } | 416 } |
453 const Array& args = Array::Handle(isolate, Array::New(kNumArguments)); | 417 const Array& args = Array::Handle(isolate, Array::New(kNumArguments)); |
454 args.SetAt(0, receive_port); | 418 args.SetAt(0, receive_port); |
455 args.SetAt(1, Integer::Handle(isolate, Integer::New(reply_port_id))); | 419 args.SetAt(1, Integer::Handle(isolate, Integer::New(reply_port_id))); |
456 args.SetAt(2, message); | 420 args.SetAt(2, message); |
457 const Object& result = | 421 const Object& result = |
458 Object::Handle(isolate, DartEntry::InvokeStatic(function, args)); | 422 Object::Handle(isolate, DartEntry::InvokeFunction(function, args)); |
459 ASSERT(result.IsNull() || result.IsError()); | 423 ASSERT(result.IsNull() || result.IsError()); |
460 return result.raw(); | 424 return result.raw(); |
461 } | 425 } |
462 | 426 |
463 | 427 |
464 RawObject* DartLibraryCalls::NewSendPort(intptr_t port_id) { | 428 RawObject* DartLibraryCalls::NewSendPort(intptr_t port_id) { |
465 Library& isolate_lib = Library::Handle(Library::IsolateLibrary()); | 429 Library& isolate_lib = Library::Handle(Library::IsolateLibrary()); |
466 ASSERT(!isolate_lib.IsNull()); | 430 ASSERT(!isolate_lib.IsNull()); |
467 const String& class_name = | 431 const String& class_name = |
468 String::Handle(isolate_lib.PrivateName(Symbols::_SendPortImpl())); | 432 String::Handle(isolate_lib.PrivateName(Symbols::_SendPortImpl())); |
469 const int kNumArguments = 1; | 433 const int kNumArguments = 1; |
470 const String& function_name = | 434 const String& function_name = |
471 String::Handle(isolate_lib.PrivateName(Symbols::_create())); | 435 String::Handle(isolate_lib.PrivateName(Symbols::_create())); |
472 const Function& function = Function::Handle( | 436 const Function& function = Function::Handle( |
473 Resolver::ResolveStatic(isolate_lib, | 437 Resolver::ResolveStatic(isolate_lib, |
474 class_name, | 438 class_name, |
475 function_name, | 439 function_name, |
476 kNumArguments, | 440 kNumArguments, |
477 Object::empty_array(), | 441 Object::empty_array(), |
478 Resolver::kIsQualified)); | 442 Resolver::kIsQualified)); |
479 const Array& args = Array::Handle(Array::New(kNumArguments)); | 443 const Array& args = Array::Handle(Array::New(kNumArguments)); |
480 args.SetAt(0, Integer::Handle(Integer::New(port_id))); | 444 args.SetAt(0, Integer::Handle(Integer::New(port_id))); |
481 return DartEntry::InvokeStatic(function, args); | 445 return DartEntry::InvokeFunction(function, args); |
482 } | 446 } |
483 | 447 |
484 | 448 |
485 RawObject* DartLibraryCalls::MapSetAt(const Instance& map, | 449 RawObject* DartLibraryCalls::MapSetAt(const Instance& map, |
486 const Instance& key, | 450 const Instance& key, |
487 const Instance& value) { | 451 const Instance& value) { |
488 const int kNumArguments = 3; | 452 const int kNumArguments = 3; |
489 const Function& function = Function::Handle( | 453 const Function& function = Function::Handle( |
490 Resolver::ResolveDynamic(map, | 454 Resolver::ResolveDynamic(map, |
491 Symbols::AssignIndexToken(), | 455 Symbols::AssignIndexToken(), |
492 kNumArguments, | 456 kNumArguments, |
493 0)); | 457 0)); |
494 ASSERT(!function.IsNull()); | 458 ASSERT(!function.IsNull()); |
495 const Array& args = Array::Handle(Array::New(kNumArguments)); | 459 const Array& args = Array::Handle(Array::New(kNumArguments)); |
496 args.SetAt(0, map); | 460 args.SetAt(0, map); |
497 args.SetAt(1, key); | 461 args.SetAt(1, key); |
498 args.SetAt(2, value); | 462 args.SetAt(2, value); |
499 const Object& result = Object::Handle(DartEntry::InvokeDynamic(function, | 463 const Object& result = Object::Handle(DartEntry::InvokeFunction(function, |
500 args)); | 464 args)); |
501 return result.raw(); | 465 return result.raw(); |
502 } | 466 } |
503 | 467 |
504 | 468 |
505 RawObject* DartLibraryCalls::PortGetId(const Instance& port) { | 469 RawObject* DartLibraryCalls::PortGetId(const Instance& port) { |
506 const Class& cls = Class::Handle(port.clazz()); | 470 const Class& cls = Class::Handle(port.clazz()); |
507 const Library& isolate_lib = Library::Handle(Library::IsolateLibrary()); | 471 const Library& isolate_lib = Library::Handle(Library::IsolateLibrary()); |
508 const String& func_name = | 472 const String& func_name = |
509 String::Handle(isolate_lib.PrivateName( | 473 String::Handle(isolate_lib.PrivateName( |
510 String::Handle(Field::GetterName(Symbols::_id())))); | 474 String::Handle(Field::GetterName(Symbols::_id())))); |
511 const Function& func = Function::Handle(cls.LookupDynamicFunction(func_name)); | 475 const Function& func = Function::Handle(cls.LookupDynamicFunction(func_name)); |
512 ASSERT(!func.IsNull()); | 476 ASSERT(!func.IsNull()); |
513 const Array& args = Array::Handle(Array::New(1)); | 477 const Array& args = Array::Handle(Array::New(1)); |
514 args.SetAt(0, port); | 478 args.SetAt(0, port); |
515 return DartEntry::InvokeDynamic(func, args); | 479 return DartEntry::InvokeFunction(func, args); |
516 } | 480 } |
517 | 481 |
518 | 482 |
519 } // namespace dart | 483 } // namespace dart |
OLD | NEW |