OLD | NEW |
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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 "include/dart_api.h" | 5 #include "include/dart_api.h" |
6 | 6 |
7 #include "vm/bigint_operations.h" | 7 #include "vm/bigint_operations.h" |
8 #include "vm/class_finalizer.h" | 8 #include "vm/class_finalizer.h" |
9 #include "vm/compiler.h" | 9 #include "vm/compiler.h" |
10 #include "vm/dart.h" | 10 #include "vm/dart.h" |
(...skipping 4411 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4422 DARTSCOPE(isolate); | 4422 DARTSCOPE(isolate); |
4423 const Library& lib = Api::UnwrapLibraryHandle(isolate, library); | 4423 const Library& lib = Api::UnwrapLibraryHandle(isolate, library); |
4424 if (lib.IsNull()) { | 4424 if (lib.IsNull()) { |
4425 RETURN_TYPE_ERROR(isolate, library, Library); | 4425 RETURN_TYPE_ERROR(isolate, library, Library); |
4426 } | 4426 } |
4427 lib.set_native_entry_resolver(resolver); | 4427 lib.set_native_entry_resolver(resolver); |
4428 return Api::Success(isolate); | 4428 return Api::Success(isolate); |
4429 } | 4429 } |
4430 | 4430 |
4431 | 4431 |
4432 // --- Profiling support ---- | |
4433 | |
4434 | |
4435 DART_EXPORT void Dart_InitPprofSupport() { | |
4436 DebugInfo* pprof_symbol_generator = DebugInfo::NewGenerator(); | |
4437 ASSERT(pprof_symbol_generator != NULL); | |
4438 Dart::set_pprof_symbol_generator(pprof_symbol_generator); | |
4439 } | |
4440 | |
4441 | |
4442 DART_EXPORT void Dart_GetPprofSymbolInfo(void** buffer, int* buffer_size) { | |
4443 Isolate* isolate = Isolate::Current(); | |
4444 DebugInfo* pprof_symbol_generator = Dart::pprof_symbol_generator(); | |
4445 if (pprof_symbol_generator != NULL) { | |
4446 DebugInfo::ByteBuffer* debug_region = new DebugInfo::ByteBuffer(); | |
4447 ASSERT(debug_region != NULL); | |
4448 pprof_symbol_generator->WriteToMemory(debug_region); | |
4449 *buffer_size = debug_region->size(); | |
4450 if (*buffer_size != 0) { | |
4451 Zone* zone = Api::TopScope(isolate)->zone(); | |
4452 *buffer = reinterpret_cast<void*>(zone->AllocUnsafe(*buffer_size)); | |
4453 memmove(*buffer, debug_region->data(), *buffer_size); | |
4454 } else { | |
4455 *buffer = NULL; | |
4456 } | |
4457 delete debug_region; | |
4458 } else { | |
4459 *buffer = NULL; | |
4460 *buffer_size = 0; | |
4461 } | |
4462 } | |
4463 | |
4464 // --- Peer support --- | 4432 // --- Peer support --- |
4465 | 4433 |
4466 | 4434 |
4467 DART_EXPORT Dart_Handle Dart_GetPeer(Dart_Handle object, void** peer) { | 4435 DART_EXPORT Dart_Handle Dart_GetPeer(Dart_Handle object, void** peer) { |
4468 if (peer == NULL) { | 4436 if (peer == NULL) { |
4469 RETURN_NULL_ERROR(peer); | 4437 RETURN_NULL_ERROR(peer); |
4470 } | 4438 } |
4471 Isolate* isolate = Isolate::Current(); | 4439 Isolate* isolate = Isolate::Current(); |
4472 DARTSCOPE(isolate); | 4440 DARTSCOPE(isolate); |
4473 const Object& obj = Object::Handle(isolate, Api::UnwrapHandle(object)); | 4441 const Object& obj = Object::Handle(isolate, Api::UnwrapHandle(object)); |
(...skipping 22 matching lines...) Expand all Loading... |
4496 } | 4464 } |
4497 { | 4465 { |
4498 NoGCScope no_gc; | 4466 NoGCScope no_gc; |
4499 RawObject* raw_obj = obj.raw(); | 4467 RawObject* raw_obj = obj.raw(); |
4500 isolate->heap()->SetPeer(raw_obj, peer); | 4468 isolate->heap()->SetPeer(raw_obj, peer); |
4501 } | 4469 } |
4502 return Api::Success(isolate); | 4470 return Api::Success(isolate); |
4503 } | 4471 } |
4504 | 4472 |
4505 } // namespace dart | 4473 } // namespace dart |
OLD | NEW |