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

Unified Diff: runtime/vm/dart_api_impl_test.cc

Issue 22314017: Do not use guarded cid on externalizable cid-s (one and two byte strings). (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 4 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/vm/flow_graph_type_propagator.cc » ('j') | runtime/vm/object.h » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/dart_api_impl_test.cc
===================================================================
--- runtime/vm/dart_api_impl_test.cc (revision 25890)
+++ runtime/vm/dart_api_impl_test.cc (working copy)
@@ -7116,6 +7116,47 @@
}
+// Do not use guarding mechanism on externalizable classes, since their class
+// can change on the fly,
+TEST_CASE(GuardExternalizedString) {
+ const char* kScriptChars =
+ "main() {\n"
+ " var a = new A('hello');\n"
+ " var res = runOne(a);\n"
+ " if (res != 10640000) return -1;\n"
+ " change_str(a.f);\n"
+ " res = runOne(a);\n"
+ " return res;\n"
+ "}\n"
+ "runOne(a) {\n"
+ " var sum = 0;\n"
+ " for (int i = 0; i < 20000; i++) {\n"
+ " for (int j = 0; j < a.f.length; j++) {\n"
+ " sum += a.f.codeUnitAt(j);\n"
+ " }\n"
+ " }\n"
+ " return sum;\n"
+ "}\n"
+ "class A {\n"
+ " var f;\n"
+ " A(this.f);\n"
+ "}\n"
+ "change_str(String s) native 'A_change_str';\n"
+ "";
+ Dart_Handle lib =
+ TestCase::LoadTestScript(kScriptChars,
+ &ExternalStringDeoptimize_native_lookup);
+ Dart_Handle result = Dart_Invoke(lib,
+ NewString("main"),
+ 0,
+ NULL);
+ int64_t value = 0;
+ result = Dart_IntegerToInt64(result, &value);
+ EXPECT_VALID(result);
+ EXPECT_EQ(10640000, value);
+}
+
+
TEST_CASE(ExternalStringDeoptimize) {
const char* kScriptChars =
"String str = 'A';\n"
« no previous file with comments | « no previous file | runtime/vm/flow_graph_type_propagator.cc » ('j') | runtime/vm/object.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698