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

Unified Diff: runtime/vm/simulator_dbc.cc

Issue 2109743002: DBC: Implement InstanceOf. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: . Created 4 years, 6 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
Index: runtime/vm/simulator_dbc.cc
diff --git a/runtime/vm/simulator_dbc.cc b/runtime/vm/simulator_dbc.cc
index 1938950cebf21817fa52746ec83d614fc136e32f..6096095fcbccfcf2be6272b67d2fc069452ff96e 100644
--- a/runtime/vm/simulator_dbc.cc
+++ b/runtime/vm/simulator_dbc.cc
@@ -1854,6 +1854,38 @@ RawObject* Simulator::Call(const Code& code,
}
{
+ BYTECODE(InstanceOf, 0); // Stack: instance, type args, type, cache
+ RawInstance* instance = static_cast<RawInstance*>(SP[-3]);
zra 2016/06/28 19:30:35 If you use the RAW_CAST macro, we'll also get some
rmacnak 2016/06/28 21:21:50 RAW_CAST is too strict here. type_args may be null
+ RawTypeArguments* type_args = static_cast<RawTypeArguments*>(SP[-2]);
+ RawAbstractType* raw_type = static_cast<RawAbstractType*>(SP[-1]);
+ RawSubtypeTestCache* cache = static_cast<RawSubtypeTestCache*>(SP[0]);
+
+ const AbstractType& type = AbstractType::Handle(raw_type);
+ if (type.IsInstantiated()) {
+ if (instance == null_value) {
+ SP[-3] = type.IsNullType() ? true_value : false_value;
+ goto InstanceOfOk;
+ }
+ }
+
+ // TODO(rmacnak): Use the cache.
+
+ {
+ SP[1] = instance;
+ SP[2] = raw_type;
+ SP[3] = type_args;
+ SP[4] = cache;
+ Exit(thread, FP, SP + 5, pc);
+ NativeArguments native_args(thread, 4, SP + 1, SP - 3);
+ INVOKE_RUNTIME(DRT_Instanceof, native_args);
+ }
+
+ InstanceOfOk:
+ SP -= 3;
+ DISPATCH();
+ }
+
+ {
BYTECODE(AssertAssignable, A_D); // Stack: instance, type args, type, name
RawObject** args = SP - 3;
if (args[0] != null_value) {
@@ -1978,6 +2010,12 @@ RawObject* Simulator::Call(const Code& code,
}
{
+ BYTECODE(LogicalNot, 0);
+ SP[0] = (SP[0] == true_value) ? false_value : true_value;
+ DISPATCH();
+ }
+
+ {
BYTECODE(IfEqStrictTOS, 0);
SP -= 2;
if (SP[1] != SP[2]) {
« runtime/vm/intermediate_language_dbc.cc ('K') | « runtime/vm/intermediate_language_dbc.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698