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

Unified Diff: runtime/lib/object.cc

Issue 2147123002: Made simple instance-of checks fast for unoptimized code. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Removed compile_time_constants_ from object_store. Created 4 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 723bf69eced37e87d2b9851d8aad625324c9ac28..e1b7a71c8eb53bfc7acd3a25760dcfbd6a5940a6 100644
--- a/runtime/lib/object.cc
+++ b/runtime/lib/object.cc
@@ -166,6 +166,37 @@ DEFINE_NATIVE_ENTRY(Object_instanceOf, 4) {
return Bool::Get(negate.value() ? !is_instance_of : is_instance_of).raw();
}
+DEFINE_NATIVE_ENTRY(Object_simpleInstanceOf, 2) {
+ // This native is only called when the right hand side passes
+ // simpleInstanceOfType and it is a non-negative test.
+ const Instance& instance =
+ Instance::CheckedHandle(zone, arguments->NativeArgAt(0));
+ const AbstractType& type =
+ AbstractType::CheckedHandle(zone, arguments->NativeArgAt(1));
+ const TypeArguments& instantiator_type_arguments =
+ TypeArguments::Handle(TypeArguments::null());
+ ASSERT(type.IsFinalized());
+ ASSERT(!type.IsMalformed());
+ ASSERT(!type.IsMalbounded());
+ Error& bound_error = Error::Handle(zone, Error::null());
+ const bool is_instance_of = instance.IsInstanceOf(type,
+ instantiator_type_arguments,
+ &bound_error);
+ if (!is_instance_of && !bound_error.IsNull()) {
+ // Throw a dynamic type error only if the instanceof test fails.
+ DartFrameIterator iterator;
+ StackFrame* caller_frame = iterator.NextFrame();
+ ASSERT(caller_frame != NULL);
+ const TokenPosition location = caller_frame->GetTokenPos();
+ String& bound_error_message = String::Handle(
+ zone, String::New(bound_error.ToErrorCString()));
+ Exceptions::CreateAndThrowTypeError(
+ location, AbstractType::Handle(zone), AbstractType::Handle(zone),
+ Symbols::Empty(), bound_error_message);
+ UNREACHABLE();
+ }
+ return Bool::Get(is_instance_of).raw();
+}
DEFINE_NATIVE_ENTRY(Object_instanceOfNum, 2) {
const Instance& instance =
« 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