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

Unified Diff: runtime/lib/object.cc

Issue 1222863003: Make frequent type checks (instanceof) faster by adding dedicated instanceof methods; improves dart… (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: flag Created 5 years, 5 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 | « no previous file | runtime/lib/object_patch.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/lib/object.cc
diff --git a/runtime/lib/object.cc b/runtime/lib/object.cc
index fe88b85e354dbd3adc0614b340d7e6d688604cfe..2c43d96e58db30af0e22668af6838a940ae0a122 100644
--- a/runtime/lib/object.cc
+++ b/runtime/lib/object.cc
@@ -207,6 +207,66 @@ DEFINE_NATIVE_ENTRY(Object_instanceOf, 5) {
}
+DEFINE_NATIVE_ENTRY(Object_instanceOfNum, 2) {
+ const Instance& instance =
+ Instance::CheckedHandle(zone, arguments->NativeArgAt(0));
+ const Bool& negate = Bool::CheckedHandle(zone, arguments->NativeArgAt(1));
+ bool is_instance_of = instance.IsNumber();
+ if (negate.value()) {
+ is_instance_of = !is_instance_of;
+ }
+ return Bool::Get(is_instance_of).raw();
+}
+
+
+DEFINE_NATIVE_ENTRY(Object_instanceOfInt, 2) {
+ const Instance& instance =
+ Instance::CheckedHandle(zone, arguments->NativeArgAt(0));
+ const Bool& negate = Bool::CheckedHandle(zone, arguments->NativeArgAt(1));
+ bool is_instance_of = instance.IsInteger();
+ if (negate.value()) {
+ is_instance_of = !is_instance_of;
+ }
+ return Bool::Get(is_instance_of).raw();
+}
+
+
+DEFINE_NATIVE_ENTRY(Object_instanceOfSmi, 2) {
+ const Instance& instance =
+ Instance::CheckedHandle(zone, arguments->NativeArgAt(0));
+ const Bool& negate = Bool::CheckedHandle(zone, arguments->NativeArgAt(1));
+ bool is_instance_of = instance.IsSmi();
+ if (negate.value()) {
+ is_instance_of = !is_instance_of;
+ }
+ return Bool::Get(is_instance_of).raw();
+}
+
+
+DEFINE_NATIVE_ENTRY(Object_instanceOfDouble, 2) {
+ const Instance& instance =
+ Instance::CheckedHandle(zone, arguments->NativeArgAt(0));
+ const Bool& negate = Bool::CheckedHandle(zone, arguments->NativeArgAt(1));
+ bool is_instance_of = instance.IsDouble();
+ if (negate.value()) {
+ is_instance_of = !is_instance_of;
+ }
+ return Bool::Get(is_instance_of).raw();
+}
+
+
+DEFINE_NATIVE_ENTRY(Object_instanceOfString, 2) {
+ const Instance& instance =
+ Instance::CheckedHandle(zone, arguments->NativeArgAt(0));
+ const Bool& negate = Bool::CheckedHandle(zone, arguments->NativeArgAt(1));
+ bool is_instance_of = instance.IsString();
+ if (negate.value()) {
+ is_instance_of = !is_instance_of;
+ }
+ return Bool::Get(is_instance_of).raw();
+}
+
+
DEFINE_NATIVE_ENTRY(Object_as, 4) {
const Instance& instance = Instance::CheckedHandle(arguments->NativeArgAt(0));
// Instantiator at position 1 is not used. It is passed along so that the call
« no previous file with comments | « no previous file | runtime/lib/object_patch.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698