| 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/class_finalizer.h" | 7 #include "vm/class_finalizer.h" |
| 8 #include "vm/code_generator.h" | 8 #include "vm/code_generator.h" |
| 9 #include "vm/compiler.h" | 9 #include "vm/compiler.h" |
| 10 #include "vm/debugger.h" | 10 #include "vm/debugger.h" |
| 11 #include "vm/object_store.h" | 11 #include "vm/object_store.h" |
| 12 #include "vm/resolver.h" | 12 #include "vm/resolver.h" |
| 13 #include "vm/simulator.h" | 13 #include "vm/simulator.h" |
| 14 #include "vm/stub_code.h" | 14 #include "vm/stub_code.h" |
| 15 #include "vm/symbols.h" | 15 #include "vm/symbols.h" |
| 16 #include "vm/timer_scope.h" |
| 16 | 17 |
| 17 namespace dart { | 18 namespace dart { |
| 18 | 19 |
| 19 // A cache of VM heap allocated arguments descriptors. | 20 // A cache of VM heap allocated arguments descriptors. |
| 20 RawArray* ArgumentsDescriptor::cached_args_descriptors_[kCachedDescriptorCount]; | 21 RawArray* ArgumentsDescriptor::cached_args_descriptors_[kCachedDescriptorCount]; |
| 21 | 22 |
| 22 | 23 |
| 23 RawObject* DartEntry::InvokeFunction(const Function& function, | 24 RawObject* DartEntry::InvokeFunction(const Function& function, |
| 24 const Array& arguments) { | 25 const Array& arguments) { |
| 25 const Array& arguments_descriptor = | 26 const Array& arguments_descriptor = |
| (...skipping 19 matching lines...) Expand all Loading... |
| 45 // Get the entrypoint corresponding to the function specified, this | 46 // Get the entrypoint corresponding to the function specified, this |
| 46 // will result in a compilation of the function if it is not already | 47 // will result in a compilation of the function if it is not already |
| 47 // compiled. | 48 // compiled. |
| 48 if (!function.HasCode()) { | 49 if (!function.HasCode()) { |
| 49 const Error& error = Error::Handle(Compiler::CompileFunction(function)); | 50 const Error& error = Error::Handle(Compiler::CompileFunction(function)); |
| 50 if (!error.IsNull()) { | 51 if (!error.IsNull()) { |
| 51 return error.raw(); | 52 return error.raw(); |
| 52 } | 53 } |
| 53 } | 54 } |
| 54 // Now Call the invoke stub which will invoke the dart function. | 55 // Now Call the invoke stub which will invoke the dart function. |
| 56 Isolate* isolate = Isolate::Current(); |
| 57 TIMERSCOPE(isolate, time_dart_execution); |
| 55 invokestub entrypoint = reinterpret_cast<invokestub>( | 58 invokestub entrypoint = reinterpret_cast<invokestub>( |
| 56 StubCode::InvokeDartCodeEntryPoint()); | 59 StubCode::InvokeDartCodeEntryPoint()); |
| 57 const Code& code = Code::Handle(function.CurrentCode()); | 60 const Code& code = Code::Handle(isolate, function.CurrentCode()); |
| 58 ASSERT(!code.IsNull()); | 61 ASSERT(!code.IsNull()); |
| 59 ASSERT(Isolate::Current()->no_callback_scope_depth() == 0); | 62 ASSERT(isolate->no_callback_scope_depth() == 0); |
| 60 #if defined(USING_SIMULATOR) | 63 #if defined(USING_SIMULATOR) |
| 61 return bit_copy<RawObject*, int64_t>(Simulator::Current()->Call( | 64 return bit_copy<RawObject*, int64_t>(Simulator::Current()->Call( |
| 62 reinterpret_cast<int32_t>(entrypoint), | 65 reinterpret_cast<int32_t>(entrypoint), |
| 63 static_cast<int32_t>(code.EntryPoint()), | 66 static_cast<int32_t>(code.EntryPoint()), |
| 64 reinterpret_cast<int32_t>(&arguments_descriptor), | 67 reinterpret_cast<int32_t>(&arguments_descriptor), |
| 65 reinterpret_cast<int32_t>(&arguments), | 68 reinterpret_cast<int32_t>(&arguments), |
| 66 reinterpret_cast<int32_t>(&context))); | 69 reinterpret_cast<int32_t>(&context))); |
| 67 #else | 70 #else |
| 68 return entrypoint(code.EntryPoint(), | 71 return entrypoint(code.EntryPoint(), |
| 69 arguments_descriptor, | 72 arguments_descriptor, |
| 70 arguments, | 73 arguments, |
| 71 context); | 74 context); |
| 72 #endif | 75 #endif |
| 73 } | 76 } |
| 74 | 77 |
| 75 | 78 |
| 76 RawObject* DartEntry::InvokeClosure(const Array& arguments) { | 79 RawObject* DartEntry::InvokeClosure(const Array& arguments) { |
| 77 const Array& arguments_descriptor = | 80 const Array& arguments_descriptor = |
| 78 Array::Handle(ArgumentsDescriptor::New(arguments.Length())); | 81 Array::Handle(ArgumentsDescriptor::New(arguments.Length())); |
| 79 return InvokeClosure(arguments, arguments_descriptor); | 82 return InvokeClosure(arguments, arguments_descriptor); |
| 80 } | 83 } |
| 81 | 84 |
| (...skipping 417 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 499 // Get send port class from isolate library. | 502 // Get send port class from isolate library. |
| 500 const Library& isolate_lib = Library::Handle(Library::IsolateLibrary()); | 503 const Library& isolate_lib = Library::Handle(Library::IsolateLibrary()); |
| 501 const Class& send_port_cls = Class::Handle( | 504 const Class& send_port_cls = Class::Handle( |
| 502 isolate_lib.LookupClassAllowPrivate(Symbols::_SendPortImpl())); | 505 isolate_lib.LookupClassAllowPrivate(Symbols::_SendPortImpl())); |
| 503 // Check for the same class id. | 506 // Check for the same class id. |
| 504 ASSERT(!send_port_cls.IsNull()); | 507 ASSERT(!send_port_cls.IsNull()); |
| 505 return cls.id() == send_port_cls.id(); | 508 return cls.id() == send_port_cls.id(); |
| 506 } | 509 } |
| 507 | 510 |
| 508 } // namespace dart | 511 } // namespace dart |
| OLD | NEW |