Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(125)

Side by Side Diff: runtime/vm/dart_api_impl.cc

Issue 1887203004: Remove timeline events for Dart_GetNativeX. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 2134 matching lines...) Expand 10 before | Expand all | Expand 10 after
2145 return Api::NewHandle(T, Integer::New(str_obj)); 2145 return Api::NewHandle(T, Integer::New(str_obj));
2146 } 2146 }
2147 2147
2148 2148
2149 DART_EXPORT Dart_Handle Dart_IntegerToInt64(Dart_Handle integer, 2149 DART_EXPORT Dart_Handle Dart_IntegerToInt64(Dart_Handle integer,
2150 int64_t* value) { 2150 int64_t* value) {
2151 // Fast path for Smis. 2151 // Fast path for Smis.
2152 Thread* thread = Thread::Current(); 2152 Thread* thread = Thread::Current();
2153 Isolate* isolate = thread->isolate(); 2153 Isolate* isolate = thread->isolate();
2154 CHECK_ISOLATE(isolate); 2154 CHECK_ISOLATE(isolate);
2155 API_TIMELINE_DURATION;
2156 if (Api::IsSmi(integer)) { 2155 if (Api::IsSmi(integer)) {
2157 *value = Api::SmiValue(integer); 2156 *value = Api::SmiValue(integer);
2158 return Api::Success(); 2157 return Api::Success();
2159 } 2158 }
2160 // Slow path for Mints and Bigints. 2159 // Slow path for Mints and Bigints.
2161 DARTSCOPE(thread); 2160 DARTSCOPE(thread);
2162 const Integer& int_obj = Api::UnwrapIntegerHandle(Z, integer); 2161 const Integer& int_obj = Api::UnwrapIntegerHandle(Z, integer);
2163 if (int_obj.IsNull()) { 2162 if (int_obj.IsNull()) {
2164 RETURN_TYPE_ERROR(Z, integer, Integer); 2163 RETURN_TYPE_ERROR(Z, integer, Integer);
2165 } 2164 }
2166 ASSERT(!int_obj.IsSmi()); 2165 ASSERT(!int_obj.IsSmi());
2167 if (int_obj.IsMint()) { 2166 if (int_obj.IsMint()) {
2168 *value = int_obj.AsInt64Value(); 2167 *value = int_obj.AsInt64Value();
2169 return Api::Success(); 2168 return Api::Success();
2170 } else { 2169 } else {
2171 const Bigint& bigint = Bigint::Cast(int_obj); 2170 const Bigint& bigint = Bigint::Cast(int_obj);
2172 if (bigint.FitsIntoInt64()) { 2171 if (bigint.FitsIntoInt64()) {
2173 *value = bigint.AsInt64Value(); 2172 *value = bigint.AsInt64Value();
2174 return Api::Success(); 2173 return Api::Success();
2175 } 2174 }
2176 } 2175 }
2177 return Api::NewError("%s: Integer %s cannot be represented as an int64_t.", 2176 return Api::NewError("%s: Integer %s cannot be represented as an int64_t.",
2178 CURRENT_FUNC, int_obj.ToCString()); 2177 CURRENT_FUNC, int_obj.ToCString());
2179 } 2178 }
2180 2179
2181 2180
2182 DART_EXPORT Dart_Handle Dart_IntegerToUint64(Dart_Handle integer, 2181 DART_EXPORT Dart_Handle Dart_IntegerToUint64(Dart_Handle integer,
2183 uint64_t* value) { 2182 uint64_t* value) {
2184 API_TIMELINE_DURATION;
2185 // Fast path for Smis. 2183 // Fast path for Smis.
2186 Thread* thread = Thread::Current(); 2184 Thread* thread = Thread::Current();
2187 Isolate* isolate = thread->isolate(); 2185 Isolate* isolate = thread->isolate();
2188 CHECK_ISOLATE(isolate); 2186 CHECK_ISOLATE(isolate);
2189 if (Api::IsSmi(integer)) { 2187 if (Api::IsSmi(integer)) {
2190 intptr_t smi_value = Api::SmiValue(integer); 2188 intptr_t smi_value = Api::SmiValue(integer);
2191 if (smi_value >= 0) { 2189 if (smi_value >= 0) {
2192 *value = smi_value; 2190 *value = smi_value;
2193 return Api::Success(); 2191 return Api::Success();
2194 } 2192 }
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
2234 Bigint::NewFromInt64(int_obj.AsInt64Value())); 2232 Bigint::NewFromInt64(int_obj.AsInt64Value()));
2235 *value = bigint.ToHexCString(BigintAllocate); 2233 *value = bigint.ToHexCString(BigintAllocate);
2236 } else { 2234 } else {
2237 *value = Bigint::Cast(int_obj).ToHexCString(BigintAllocate); 2235 *value = Bigint::Cast(int_obj).ToHexCString(BigintAllocate);
2238 } 2236 }
2239 return Api::Success(); 2237 return Api::Success();
2240 } 2238 }
2241 2239
2242 2240
2243 DART_EXPORT Dart_Handle Dart_NewDouble(double value) { 2241 DART_EXPORT Dart_Handle Dart_NewDouble(double value) {
2244 API_TIMELINE_DURATION;
2245 DARTSCOPE(Thread::Current()); 2242 DARTSCOPE(Thread::Current());
2246 CHECK_CALLBACK_STATE(T); 2243 CHECK_CALLBACK_STATE(T);
2247 return Api::NewHandle(T, Double::New(value)); 2244 return Api::NewHandle(T, Double::New(value));
2248 } 2245 }
2249 2246
2250 2247
2251 DART_EXPORT Dart_Handle Dart_DoubleValue(Dart_Handle double_obj, 2248 DART_EXPORT Dart_Handle Dart_DoubleValue(Dart_Handle double_obj,
2252 double* value) { 2249 double* value) {
2253 API_TIMELINE_DURATION;
2254 DARTSCOPE(Thread::Current()); 2250 DARTSCOPE(Thread::Current());
2255 const Double& obj = Api::UnwrapDoubleHandle(Z, double_obj); 2251 const Double& obj = Api::UnwrapDoubleHandle(Z, double_obj);
2256 if (obj.IsNull()) { 2252 if (obj.IsNull()) {
2257 RETURN_TYPE_ERROR(Z, double_obj, Double); 2253 RETURN_TYPE_ERROR(Z, double_obj, Double);
2258 } 2254 }
2259 *value = obj.value(); 2255 *value = obj.value();
2260 return Api::Success(); 2256 return Api::Success();
2261 } 2257 }
2262 2258
2263 2259
(...skipping 2552 matching lines...) Expand 10 before | Expand all | Expand 10 after
4816 return Api::NewError("%s: invalid argument type %d.", 4812 return Api::NewError("%s: invalid argument type %d.",
4817 CURRENT_FUNC, arg_type); 4813 CURRENT_FUNC, arg_type);
4818 } 4814 }
4819 } 4815 }
4820 return Api::Success(); 4816 return Api::Success();
4821 } 4817 }
4822 4818
4823 4819
4824 DART_EXPORT Dart_Handle Dart_GetNativeArgument(Dart_NativeArguments args, 4820 DART_EXPORT Dart_Handle Dart_GetNativeArgument(Dart_NativeArguments args,
4825 int index) { 4821 int index) {
4826 API_TIMELINE_DURATION;
4827 NativeArguments* arguments = reinterpret_cast<NativeArguments*>(args); 4822 NativeArguments* arguments = reinterpret_cast<NativeArguments*>(args);
4828 if ((index < 0) || (index >= arguments->NativeArgCount())) { 4823 if ((index < 0) || (index >= arguments->NativeArgCount())) {
4829 return Api::NewError( 4824 return Api::NewError(
4830 "%s: argument 'index' out of range. Expected 0..%d but saw %d.", 4825 "%s: argument 'index' out of range. Expected 0..%d but saw %d.",
4831 CURRENT_FUNC, arguments->NativeArgCount() - 1, index); 4826 CURRENT_FUNC, arguments->NativeArgCount() - 1, index);
4832 } 4827 }
4833 return Api::NewHandle(arguments->thread(), 4828 return Api::NewHandle(arguments->thread(),
4834 arguments->NativeArgAt(index)); 4829 arguments->NativeArgAt(index));
4835 } 4830 }
4836 4831
4837 4832
4838 DART_EXPORT int Dart_GetNativeArgumentCount(Dart_NativeArguments args) { 4833 DART_EXPORT int Dart_GetNativeArgumentCount(Dart_NativeArguments args) {
4839 API_TIMELINE_DURATION;
4840 NativeArguments* arguments = reinterpret_cast<NativeArguments*>(args); 4834 NativeArguments* arguments = reinterpret_cast<NativeArguments*>(args);
4841 return arguments->NativeArgCount(); 4835 return arguments->NativeArgCount();
4842 } 4836 }
4843 4837
4844 4838
4845 DART_EXPORT Dart_Handle Dart_GetNativeFieldsOfArgument( 4839 DART_EXPORT Dart_Handle Dart_GetNativeFieldsOfArgument(
4846 Dart_NativeArguments args, 4840 Dart_NativeArguments args,
4847 int arg_index, 4841 int arg_index,
4848 int num_fields, 4842 int num_fields,
4849 intptr_t* field_values) { 4843 intptr_t* field_values) {
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
4888 return Api::NewError("%s expects argument at %d to be of" 4882 return Api::NewError("%s expects argument at %d to be of"
4889 " type String.", CURRENT_FUNC, arg_index); 4883 " type String.", CURRENT_FUNC, arg_index);
4890 } 4884 }
4891 return result; 4885 return result;
4892 } 4886 }
4893 4887
4894 4888
4895 DART_EXPORT Dart_Handle Dart_GetNativeIntegerArgument(Dart_NativeArguments args, 4889 DART_EXPORT Dart_Handle Dart_GetNativeIntegerArgument(Dart_NativeArguments args,
4896 int index, 4890 int index,
4897 int64_t* value) { 4891 int64_t* value) {
4898 API_TIMELINE_DURATION;
4899 NativeArguments* arguments = reinterpret_cast<NativeArguments*>(args); 4892 NativeArguments* arguments = reinterpret_cast<NativeArguments*>(args);
4900 if ((index < 0) || (index >= arguments->NativeArgCount())) { 4893 if ((index < 0) || (index >= arguments->NativeArgCount())) {
4901 return Api::NewError( 4894 return Api::NewError(
4902 "%s: argument 'index' out of range. Expected 0..%d but saw %d.", 4895 "%s: argument 'index' out of range. Expected 0..%d but saw %d.",
4903 CURRENT_FUNC, arguments->NativeArgCount() - 1, index); 4896 CURRENT_FUNC, arguments->NativeArgCount() - 1, index);
4904 } 4897 }
4905 if (!GetNativeIntegerArgument(arguments, index, value)) { 4898 if (!GetNativeIntegerArgument(arguments, index, value)) {
4906 return Api::NewError("%s: expects argument at %d to be of" 4899 return Api::NewError("%s: expects argument at %d to be of"
4907 " type Integer.", CURRENT_FUNC, index); 4900 " type Integer.", CURRENT_FUNC, index);
4908 } 4901 }
4909 return Api::Success(); 4902 return Api::Success();
4910 } 4903 }
4911 4904
4912 4905
4913 DART_EXPORT Dart_Handle Dart_GetNativeBooleanArgument(Dart_NativeArguments args, 4906 DART_EXPORT Dart_Handle Dart_GetNativeBooleanArgument(Dart_NativeArguments args,
4914 int index, 4907 int index,
4915 bool* value) { 4908 bool* value) {
4916 API_TIMELINE_DURATION;
4917 NativeArguments* arguments = reinterpret_cast<NativeArguments*>(args); 4909 NativeArguments* arguments = reinterpret_cast<NativeArguments*>(args);
4918 if ((index < 0) || (index >= arguments->NativeArgCount())) { 4910 if ((index < 0) || (index >= arguments->NativeArgCount())) {
4919 return Api::NewError( 4911 return Api::NewError(
4920 "%s: argument 'index' out of range. Expected 0..%d but saw %d.", 4912 "%s: argument 'index' out of range. Expected 0..%d but saw %d.",
4921 CURRENT_FUNC, arguments->NativeArgCount() - 1, index); 4913 CURRENT_FUNC, arguments->NativeArgCount() - 1, index);
4922 } 4914 }
4923 if (!Api::GetNativeBooleanArgument(arguments, index, value)) { 4915 if (!Api::GetNativeBooleanArgument(arguments, index, value)) {
4924 return Api::NewError("%s: expects argument at %d to be of type Boolean.", 4916 return Api::NewError("%s: expects argument at %d to be of type Boolean.",
4925 CURRENT_FUNC, index); 4917 CURRENT_FUNC, index);
4926 } 4918 }
4927 return Api::Success(); 4919 return Api::Success();
4928 } 4920 }
4929 4921
4930 4922
4931 DART_EXPORT Dart_Handle Dart_GetNativeDoubleArgument(Dart_NativeArguments args, 4923 DART_EXPORT Dart_Handle Dart_GetNativeDoubleArgument(Dart_NativeArguments args,
4932 int index, 4924 int index,
4933 double* value) { 4925 double* value) {
4934 API_TIMELINE_DURATION;
4935 NativeArguments* arguments = reinterpret_cast<NativeArguments*>(args); 4926 NativeArguments* arguments = reinterpret_cast<NativeArguments*>(args);
4936 if ((index < 0) || (index >= arguments->NativeArgCount())) { 4927 if ((index < 0) || (index >= arguments->NativeArgCount())) {
4937 return Api::NewError( 4928 return Api::NewError(
4938 "%s: argument 'index' out of range. Expected 0..%d but saw %d.", 4929 "%s: argument 'index' out of range. Expected 0..%d but saw %d.",
4939 CURRENT_FUNC, arguments->NativeArgCount() - 1, index); 4930 CURRENT_FUNC, arguments->NativeArgCount() - 1, index);
4940 } 4931 }
4941 if (!GetNativeDoubleArgument(arguments, index, value)) { 4932 if (!GetNativeDoubleArgument(arguments, index, value)) {
4942 return Api::NewError("%s: expects argument at %d to be of" 4933 return Api::NewError("%s: expects argument at %d to be of"
4943 " type Double.", CURRENT_FUNC, index); 4934 " type Double.", CURRENT_FUNC, index);
4944 } 4935 }
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
5049 Isolate* isolate = Isolate::Current(); 5040 Isolate* isolate = Isolate::Current();
5050 CHECK_ISOLATE(isolate); 5041 CHECK_ISOLATE(isolate);
5051 isolate->set_environment_callback(callback); 5042 isolate->set_environment_callback(callback);
5052 return Api::Success(); 5043 return Api::Success();
5053 } 5044 }
5054 5045
5055 5046
5056 // --- Scripts and Libraries --- 5047 // --- Scripts and Libraries ---
5057 DART_EXPORT void Dart_SetBooleanReturnValue(Dart_NativeArguments args, 5048 DART_EXPORT void Dart_SetBooleanReturnValue(Dart_NativeArguments args,
5058 bool retval) { 5049 bool retval) {
5059 API_TIMELINE_DURATION;
5060 NativeArguments* arguments = reinterpret_cast<NativeArguments*>(args); 5050 NativeArguments* arguments = reinterpret_cast<NativeArguments*>(args);
5061 arguments->SetReturn(Bool::Get(retval)); 5051 arguments->SetReturn(Bool::Get(retval));
5062 } 5052 }
5063 5053
5064 5054
5065 DART_EXPORT void Dart_SetIntegerReturnValue(Dart_NativeArguments args, 5055 DART_EXPORT void Dart_SetIntegerReturnValue(Dart_NativeArguments args,
5066 int64_t retval) { 5056 int64_t retval) {
5067 NativeArguments* arguments = reinterpret_cast<NativeArguments*>(args); 5057 NativeArguments* arguments = reinterpret_cast<NativeArguments*>(args);
5068 ASSERT(arguments->thread()->isolate() == Isolate::Current()); 5058 ASSERT(arguments->thread()->isolate() == Isolate::Current());
5069 if (Smi::IsValid(retval)) { 5059 if (Smi::IsValid(retval)) {
(...skipping 1059 matching lines...) Expand 10 before | Expand all | Expand 10 after
6129 return Api::Success(); 6119 return Api::Success();
6130 } 6120 }
6131 #endif // DART_PRECOMPILER 6121 #endif // DART_PRECOMPILER
6132 6122
6133 6123
6134 DART_EXPORT bool Dart_IsRunningPrecompiledCode() { 6124 DART_EXPORT bool Dart_IsRunningPrecompiledCode() {
6135 return Dart::IsRunningPrecompiledCode(); 6125 return Dart::IsRunningPrecompiledCode();
6136 } 6126 }
6137 6127
6138 } // namespace dart 6128 } // namespace dart
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698