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

Unified Diff: runtime/vm/native_entry.h

Issue 1705163003: Move native entry argument exception throwing code out of line (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 years, 10 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « runtime/vm/native_arguments.h ('k') | runtime/vm/native_entry.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/native_entry.h
diff --git a/runtime/vm/native_entry.h b/runtime/vm/native_entry.h
index c5578f92635e9cd21368785136c8eb8c4a178ffb..2e90ffce1eb93760b384d25bc7c9ee2a6647ee6d 100644
--- a/runtime/vm/native_entry.h
+++ b/runtime/vm/native_entry.h
@@ -71,15 +71,16 @@ typedef void (*NativeFunction)(NativeArguments* arguments);
NativeArguments* arguments)
+// Helper that throws an argument exception.
+void DartNativeThrowArgumentException(const Instance& instance);
+
// Natives should throw an exception if an illegal argument or null is passed.
// type name = value.
#define GET_NON_NULL_NATIVE_ARGUMENT(type, name, value) \
const Instance& __##name##_instance__ = \
Instance::CheckedHandle(zone, value); \
if (!__##name##_instance__.Is##type()) { \
- const Array& __args__ = Array::Handle(Array::New(1)); \
- __args__.SetAt(0, __##name##_instance__); \
- Exceptions::ThrowByType(Exceptions::kArgument, __args__); \
+ DartNativeThrowArgumentException(__##name##_instance__); \
} \
const type& name = type::Cast(__##name##_instance__);
@@ -92,9 +93,7 @@ typedef void (*NativeFunction)(NativeArguments* arguments);
type& name = type::Handle(zone); \
if (!__##name##_instance__.IsNull()) { \
if (!__##name##_instance__.Is##type()) { \
- const Array& __args__ = Array::Handle(Array::New(1)); \
- __args__.SetAt(0, __##name##_instance__); \
- Exceptions::ThrowByType(Exceptions::kArgument, __args__); \
+ DartNativeThrowArgumentException(__##name##_instance__); \
} \
} \
name ^= value;
siva 2016/02/18 16:55:22 Not sure why we did it this way and not as: const
Cutch 2016/02/18 17:04:41 That doesn't compile without first doing a RawCast
siva 2016/05/27 23:47:24 Got it.
« no previous file with comments | « runtime/vm/native_arguments.h ('k') | runtime/vm/native_entry.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698