OLD | NEW |
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, 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 #include "include/dart_mirrors_api.h" | 6 #include "include/dart_mirrors_api.h" |
7 #include "include/dart_native_api.h" | 7 #include "include/dart_native_api.h" |
8 | 8 |
9 #include "platform/assert.h" | 9 #include "platform/assert.h" |
10 #include "lib/stacktrace.h" | 10 #include "lib/stacktrace.h" |
(...skipping 3858 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3869 redirect_type ^= redirect_type.Canonicalize(); | 3869 redirect_type ^= redirect_type.Canonicalize(); |
3870 } | 3870 } |
3871 | 3871 |
3872 type_obj = redirect_type.raw(); | 3872 type_obj = redirect_type.raw(); |
3873 type_arguments = redirect_type.arguments(); | 3873 type_arguments = redirect_type.arguments(); |
3874 | 3874 |
3875 cls = type_obj.type_class(); | 3875 cls = type_obj.type_class(); |
3876 } | 3876 } |
3877 if (constructor.IsGenerativeConstructor()) { | 3877 if (constructor.IsGenerativeConstructor()) { |
3878 #if defined(DEBUG) | 3878 #if defined(DEBUG) |
3879 if (!cls.is_allocated() && (Dart::snapshot_kind() == Snapshot::kAppNoJIT)) { | 3879 if (!cls.is_allocated() && (Dart::snapshot_kind() == Snapshot::kAppAOT)) { |
3880 return Api::NewError("Precompilation dropped '%s'", cls.ToCString()); | 3880 return Api::NewError("Precompilation dropped '%s'", cls.ToCString()); |
3881 } | 3881 } |
3882 #endif | 3882 #endif |
3883 // Create the new object. | 3883 // Create the new object. |
3884 new_object = Instance::New(cls); | 3884 new_object = Instance::New(cls); |
3885 } | 3885 } |
3886 | 3886 |
3887 // Create the argument list. | 3887 // Create the argument list. |
3888 intptr_t arg_index = 0; | 3888 intptr_t arg_index = 0; |
3889 int extra_args = 1; | 3889 int extra_args = 1; |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3964 DARTSCOPE(Thread::Current()); | 3964 DARTSCOPE(Thread::Current()); |
3965 CHECK_CALLBACK_STATE(T); | 3965 CHECK_CALLBACK_STATE(T); |
3966 | 3966 |
3967 const Type& type_obj = Api::UnwrapTypeHandle(Z, type); | 3967 const Type& type_obj = Api::UnwrapTypeHandle(Z, type); |
3968 // Get the class to instantiate. | 3968 // Get the class to instantiate. |
3969 if (type_obj.IsNull()) { | 3969 if (type_obj.IsNull()) { |
3970 RETURN_TYPE_ERROR(Z, type, Type); | 3970 RETURN_TYPE_ERROR(Z, type, Type); |
3971 } | 3971 } |
3972 const Class& cls = Class::Handle(Z, type_obj.type_class()); | 3972 const Class& cls = Class::Handle(Z, type_obj.type_class()); |
3973 #if defined(DEBUG) | 3973 #if defined(DEBUG) |
3974 if (!cls.is_allocated() && (Dart::snapshot_kind() == Snapshot::kAppNoJIT)) { | 3974 if (!cls.is_allocated() && (Dart::snapshot_kind() == Snapshot::kAppAOT)) { |
3975 return Api::NewError("Precompilation dropped '%s'", cls.ToCString()); | 3975 return Api::NewError("Precompilation dropped '%s'", cls.ToCString()); |
3976 } | 3976 } |
3977 #endif | 3977 #endif |
3978 const Error& error = Error::Handle(Z, cls.EnsureIsFinalized(T)); | 3978 const Error& error = Error::Handle(Z, cls.EnsureIsFinalized(T)); |
3979 if (!error.IsNull()) { | 3979 if (!error.IsNull()) { |
3980 // An error occurred, return error object. | 3980 // An error occurred, return error object. |
3981 return Api::NewHandle(T, error.raw()); | 3981 return Api::NewHandle(T, error.raw()); |
3982 } | 3982 } |
3983 return Api::NewHandle(T, AllocateObject(T, cls)); | 3983 return Api::NewHandle(T, AllocateObject(T, cls)); |
3984 } | 3984 } |
3985 | 3985 |
3986 | 3986 |
3987 DART_EXPORT Dart_Handle | 3987 DART_EXPORT Dart_Handle |
3988 Dart_AllocateWithNativeFields(Dart_Handle type, | 3988 Dart_AllocateWithNativeFields(Dart_Handle type, |
3989 intptr_t num_native_fields, | 3989 intptr_t num_native_fields, |
3990 const intptr_t* native_fields) { | 3990 const intptr_t* native_fields) { |
3991 DARTSCOPE(Thread::Current()); | 3991 DARTSCOPE(Thread::Current()); |
3992 CHECK_CALLBACK_STATE(T); | 3992 CHECK_CALLBACK_STATE(T); |
3993 | 3993 |
3994 const Type& type_obj = Api::UnwrapTypeHandle(Z, type); | 3994 const Type& type_obj = Api::UnwrapTypeHandle(Z, type); |
3995 // Get the class to instantiate. | 3995 // Get the class to instantiate. |
3996 if (type_obj.IsNull()) { | 3996 if (type_obj.IsNull()) { |
3997 RETURN_TYPE_ERROR(Z, type, Type); | 3997 RETURN_TYPE_ERROR(Z, type, Type); |
3998 } | 3998 } |
3999 if (native_fields == NULL) { | 3999 if (native_fields == NULL) { |
4000 RETURN_NULL_ERROR(native_fields); | 4000 RETURN_NULL_ERROR(native_fields); |
4001 } | 4001 } |
4002 const Class& cls = Class::Handle(Z, type_obj.type_class()); | 4002 const Class& cls = Class::Handle(Z, type_obj.type_class()); |
4003 #if defined(DEBUG) | 4003 #if defined(DEBUG) |
4004 if (!cls.is_allocated() && (Dart::snapshot_kind() == Snapshot::kAppNoJIT)) { | 4004 if (!cls.is_allocated() && (Dart::snapshot_kind() == Snapshot::kAppAOT)) { |
4005 return Api::NewError("Precompilation dropped '%s'", cls.ToCString()); | 4005 return Api::NewError("Precompilation dropped '%s'", cls.ToCString()); |
4006 } | 4006 } |
4007 #endif | 4007 #endif |
4008 const Error& error = Error::Handle(Z, cls.EnsureIsFinalized(T)); | 4008 const Error& error = Error::Handle(Z, cls.EnsureIsFinalized(T)); |
4009 if (!error.IsNull()) { | 4009 if (!error.IsNull()) { |
4010 // An error occurred, return error object. | 4010 // An error occurred, return error object. |
4011 return Api::NewHandle(T, error.raw()); | 4011 return Api::NewHandle(T, error.raw()); |
4012 } | 4012 } |
4013 if (num_native_fields != cls.num_native_fields()) { | 4013 if (num_native_fields != cls.num_native_fields()) { |
4014 return Api::NewError( | 4014 return Api::NewError( |
(...skipping 2496 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6511 if (assembly_size == NULL) { | 6511 if (assembly_size == NULL) { |
6512 RETURN_NULL_ERROR(assembly_size); | 6512 RETURN_NULL_ERROR(assembly_size); |
6513 } | 6513 } |
6514 | 6514 |
6515 NOT_IN_PRODUCT(TimelineDurationScope tds2(T, Timeline::GetIsolateStream(), | 6515 NOT_IN_PRODUCT(TimelineDurationScope tds2(T, Timeline::GetIsolateStream(), |
6516 "WriteAppAOTSnapshot")); | 6516 "WriteAppAOTSnapshot")); |
6517 AssemblyInstructionsWriter instructions_writer(assembly_buffer, ApiReallocate, | 6517 AssemblyInstructionsWriter instructions_writer(assembly_buffer, ApiReallocate, |
6518 2 * MB /* initial_size */); | 6518 2 * MB /* initial_size */); |
6519 uint8_t* vm_isolate_snapshot_buffer = NULL; | 6519 uint8_t* vm_isolate_snapshot_buffer = NULL; |
6520 uint8_t* isolate_snapshot_buffer = NULL; | 6520 uint8_t* isolate_snapshot_buffer = NULL; |
6521 FullSnapshotWriter writer(Snapshot::kAppNoJIT, &vm_isolate_snapshot_buffer, | 6521 FullSnapshotWriter writer(Snapshot::kAppAOT, &vm_isolate_snapshot_buffer, |
6522 &isolate_snapshot_buffer, ApiReallocate, | 6522 &isolate_snapshot_buffer, ApiReallocate, |
6523 &instructions_writer); | 6523 &instructions_writer); |
6524 | 6524 |
6525 writer.WriteFullSnapshot(); | 6525 writer.WriteFullSnapshot(); |
6526 *assembly_size = instructions_writer.AssemblySize(); | 6526 *assembly_size = instructions_writer.AssemblySize(); |
6527 | 6527 |
6528 return Api::Success(); | 6528 return Api::Success(); |
6529 #endif | 6529 #endif |
6530 } | 6530 } |
6531 | 6531 |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6576 } | 6576 } |
6577 if (rodata_blob_size == NULL) { | 6577 if (rodata_blob_size == NULL) { |
6578 RETURN_NULL_ERROR(instructions_blob_size); | 6578 RETURN_NULL_ERROR(instructions_blob_size); |
6579 } | 6579 } |
6580 | 6580 |
6581 NOT_IN_PRODUCT(TimelineDurationScope tds2(T, Timeline::GetIsolateStream(), | 6581 NOT_IN_PRODUCT(TimelineDurationScope tds2(T, Timeline::GetIsolateStream(), |
6582 "WriteAppAOTSnapshot")); | 6582 "WriteAppAOTSnapshot")); |
6583 BlobInstructionsWriter instructions_writer(instructions_blob_buffer, | 6583 BlobInstructionsWriter instructions_writer(instructions_blob_buffer, |
6584 rodata_blob_buffer, ApiReallocate, | 6584 rodata_blob_buffer, ApiReallocate, |
6585 2 * MB /* initial_size */); | 6585 2 * MB /* initial_size */); |
6586 FullSnapshotWriter writer(Snapshot::kAppNoJIT, vm_isolate_snapshot_buffer, | 6586 FullSnapshotWriter writer(Snapshot::kAppAOT, vm_isolate_snapshot_buffer, |
6587 isolate_snapshot_buffer, ApiReallocate, | 6587 isolate_snapshot_buffer, ApiReallocate, |
6588 &instructions_writer); | 6588 &instructions_writer); |
6589 | 6589 |
6590 writer.WriteFullSnapshot(); | 6590 writer.WriteFullSnapshot(); |
6591 *vm_isolate_snapshot_size = writer.VmIsolateSnapshotSize(); | 6591 *vm_isolate_snapshot_size = writer.VmIsolateSnapshotSize(); |
6592 *isolate_snapshot_size = writer.IsolateSnapshotSize(); | 6592 *isolate_snapshot_size = writer.IsolateSnapshotSize(); |
6593 *instructions_blob_size = instructions_writer.InstructionsBlobSize(); | 6593 *instructions_blob_size = instructions_writer.InstructionsBlobSize(); |
6594 *rodata_blob_size = instructions_writer.RodataBlobSize(); | 6594 *rodata_blob_size = instructions_writer.RodataBlobSize(); |
6595 | 6595 |
6596 return Api::Success(); | 6596 return Api::Success(); |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6681 if (::Dart_IsError(state)) { | 6681 if (::Dart_IsError(state)) { |
6682 return state; | 6682 return state; |
6683 } | 6683 } |
6684 I->StopBackgroundCompiler(); | 6684 I->StopBackgroundCompiler(); |
6685 | 6685 |
6686 NOT_IN_PRODUCT(TimelineDurationScope tds2(T, Timeline::GetIsolateStream(), | 6686 NOT_IN_PRODUCT(TimelineDurationScope tds2(T, Timeline::GetIsolateStream(), |
6687 "WriteAppJITSnapshot")); | 6687 "WriteAppJITSnapshot")); |
6688 BlobInstructionsWriter instructions_writer(instructions_blob_buffer, | 6688 BlobInstructionsWriter instructions_writer(instructions_blob_buffer, |
6689 rodata_blob_buffer, ApiReallocate, | 6689 rodata_blob_buffer, ApiReallocate, |
6690 2 * MB /* initial_size */); | 6690 2 * MB /* initial_size */); |
6691 FullSnapshotWriter writer(Snapshot::kAppWithJIT, vm_isolate_snapshot_buffer, | 6691 FullSnapshotWriter writer(Snapshot::kAppJIT, vm_isolate_snapshot_buffer, |
6692 isolate_snapshot_buffer, ApiReallocate, | 6692 isolate_snapshot_buffer, ApiReallocate, |
6693 &instructions_writer); | 6693 &instructions_writer); |
6694 writer.WriteFullSnapshot(); | 6694 writer.WriteFullSnapshot(); |
6695 *vm_isolate_snapshot_size = writer.VmIsolateSnapshotSize(); | 6695 *vm_isolate_snapshot_size = writer.VmIsolateSnapshotSize(); |
6696 *isolate_snapshot_size = writer.IsolateSnapshotSize(); | 6696 *isolate_snapshot_size = writer.IsolateSnapshotSize(); |
6697 *instructions_blob_size = instructions_writer.InstructionsBlobSize(); | 6697 *instructions_blob_size = instructions_writer.InstructionsBlobSize(); |
6698 *rodata_blob_size = instructions_writer.RodataBlobSize(); | 6698 *rodata_blob_size = instructions_writer.RodataBlobSize(); |
6699 | 6699 |
6700 return Api::Success(); | 6700 return Api::Success(); |
6701 #endif | 6701 #endif |
6702 } | 6702 } |
6703 | 6703 |
6704 | 6704 |
6705 DART_EXPORT bool Dart_IsPrecompiledRuntime() { | 6705 DART_EXPORT bool Dart_IsPrecompiledRuntime() { |
6706 #if defined(DART_PRECOMPILED_RUNTIME) | 6706 #if defined(DART_PRECOMPILED_RUNTIME) |
6707 return true; | 6707 return true; |
6708 #else | 6708 #else |
6709 return false; | 6709 return false; |
6710 #endif | 6710 #endif |
6711 } | 6711 } |
6712 | 6712 |
6713 | 6713 |
6714 DART_EXPORT void Dart_DumpNativeStackTrace(void* context) { | 6714 DART_EXPORT void Dart_DumpNativeStackTrace(void* context) { |
6715 #ifndef PRODUCT | 6715 #ifndef PRODUCT |
6716 Profiler::DumpStackTrace(context); | 6716 Profiler::DumpStackTrace(context); |
6717 #endif | 6717 #endif |
6718 } | 6718 } |
6719 | 6719 |
6720 } // namespace dart | 6720 } // namespace dart |
OLD | NEW |