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 ---- | 4432 // --- Profiling support --- |
4433 | 4433 |
| 4434 // TODO(7565): Dartium should use the new VM flag "generate_pprof_symbols" for |
| 4435 // pprof profiling. Then these symbols should be removed. |
4434 | 4436 |
4435 DART_EXPORT void Dart_InitPprofSupport() { | 4437 DART_EXPORT void Dart_InitPprofSupport() { } |
4436 DebugInfo* pprof_symbol_generator = DebugInfo::NewGenerator(); | 4438 |
4437 ASSERT(pprof_symbol_generator != NULL); | 4439 DART_EXPORT void Dart_GetPprofSymbolInfo(void** buffer, int* buffer_size) { |
4438 Dart::set_pprof_symbol_generator(pprof_symbol_generator); | 4440 *buffer = NULL; |
| 4441 *buffer_size = 0; |
4439 } | 4442 } |
4440 | 4443 |
4441 | 4444 |
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 --- | 4445 // --- Peer support --- |
4465 | 4446 |
4466 | 4447 |
4467 DART_EXPORT Dart_Handle Dart_GetPeer(Dart_Handle object, void** peer) { | 4448 DART_EXPORT Dart_Handle Dart_GetPeer(Dart_Handle object, void** peer) { |
4468 if (peer == NULL) { | 4449 if (peer == NULL) { |
4469 RETURN_NULL_ERROR(peer); | 4450 RETURN_NULL_ERROR(peer); |
4470 } | 4451 } |
4471 Isolate* isolate = Isolate::Current(); | 4452 Isolate* isolate = Isolate::Current(); |
4472 DARTSCOPE(isolate); | 4453 DARTSCOPE(isolate); |
4473 const Object& obj = Object::Handle(isolate, Api::UnwrapHandle(object)); | 4454 const Object& obj = Object::Handle(isolate, Api::UnwrapHandle(object)); |
(...skipping 22 matching lines...) Expand all Loading... |
4496 } | 4477 } |
4497 { | 4478 { |
4498 NoGCScope no_gc; | 4479 NoGCScope no_gc; |
4499 RawObject* raw_obj = obj.raw(); | 4480 RawObject* raw_obj = obj.raw(); |
4500 isolate->heap()->SetPeer(raw_obj, peer); | 4481 isolate->heap()->SetPeer(raw_obj, peer); |
4501 } | 4482 } |
4502 return Api::Success(isolate); | 4483 return Api::Success(isolate); |
4503 } | 4484 } |
4504 | 4485 |
4505 } // namespace dart | 4486 } // namespace dart |
OLD | NEW |