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

Side by Side Diff: runtime/vm/dart_api_impl_test.cc

Issue 1097723002: Type and constant propagator should guard against mutable class ids. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Fix LoadStaticField Created 5 years, 8 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « runtime/vm/constant_propagator.cc ('k') | runtime/vm/flow_graph_type_propagator.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 #include "bin/builtin.h" 5 #include "bin/builtin.h"
6 #include "include/dart_api.h" 6 #include "include/dart_api.h"
7 #include "include/dart_debugger_api.h" 7 #include "include/dart_debugger_api.h"
8 #include "include/dart_mirrors_api.h" 8 #include "include/dart_mirrors_api.h"
9 #include "include/dart_native_api.h" 9 #include "include/dart_native_api.h"
10 #include "platform/assert.h" 10 #include "platform/assert.h"
(...skipping 8811 matching lines...) Expand 10 before | Expand all | Expand 10 after
8822 NewString("main"), 8822 NewString("main"),
8823 0, 8823 0,
8824 NULL); 8824 NULL);
8825 int64_t value = 0; 8825 int64_t value = 0;
8826 result = Dart_IntegerToInt64(result, &value); 8826 result = Dart_IntegerToInt64(result, &value);
8827 EXPECT_VALID(result); 8827 EXPECT_VALID(result);
8828 EXPECT_EQ(260, value); 8828 EXPECT_EQ(260, value);
8829 } 8829 }
8830 8830
8831 8831
8832 TEST_CASE(ExternalStringPolymorphicDeoptimize) {
8833 const char* kScriptChars =
8834 "const strA = 'AAAA';\n"
8835 "class A {\n"
8836 " static change_str(String s) native 'A_change_str';\n"
8837 "}\n"
8838 "compare(a, b, [i = 0]) {\n"
8839 " return a.codeUnitAt(i) == b.codeUnitAt(i);\n"
8840 "}\n"
8841 "compareA(b, [i = 0]) {\n"
8842 " return compare(strA, b, i);\n"
8843 "}\n"
8844 "main() {\n"
8845 " var externalA = 'AA' + 'AA';\n"
8846 " A.change_str(externalA);\n"
8847 " compare('AA' + 'AA', strA);\n"
8848 " compare(externalA, strA);\n"
8849 " for (var i = 0; i < 10000; i++) compareA(strA);\n"
8850 " A.change_str(strA);\n"
8851 " return compareA('AA' + 'AA');\n"
8852 "}\n";
8853 Dart_Handle lib =
8854 TestCase::LoadTestScript(kScriptChars,
8855 &ExternalStringDeoptimize_native_lookup);
8856 Dart_Handle result = Dart_Invoke(lib,
8857 NewString("main"),
8858 0,
8859 NULL);
8860 bool value = false;
8861 result = Dart_BooleanValue(result, &value);
8862 EXPECT_VALID(result);
8863 EXPECT(value);
8864 }
8865
8866
8867 TEST_CASE(ExternalStringGuardFieldDeoptimize) {
8868 const char* kScriptChars =
8869 "const strA = 'AAAA';\n"
8870 "class A {\n"
8871 " static change_str(String s) native 'A_change_str';\n"
8872 "}\n"
8873 "class G { var f = 'A'; }\n"
8874 "final guard = new G();\n"
8875 "var shouldExternalize = false;\n"
8876 "ext() { if (shouldExternalize) A.change_str(strA); }\n"
8877 "compare(a, b, [i = 0]) {\n"
8878 " guard.f = a;\n"
8879 " ext();"
8880 " return a.codeUnitAt(i) == b.codeUnitAt(i);\n"
8881 "}\n"
8882 "compareA(b, [i = 0]) {\n"
8883 " return compare(strA, b, i);\n"
8884 "}\n"
8885 "main() {\n"
8886 " var externalA = 'AA' + 'AA';\n"
8887 " A.change_str(externalA);\n"
8888 " compare('AA' + 'AA', strA);\n"
8889 " for (var i = 0; i < 10000; i++) compareA(strA);\n"
8890 " shouldExternalize = true;\n"
8891 " return compareA('AA' + 'AA');\n"
8892 "}\n";
8893 Dart_Handle lib =
8894 TestCase::LoadTestScript(kScriptChars,
8895 &ExternalStringDeoptimize_native_lookup);
8896 Dart_Handle result = Dart_Invoke(lib,
8897 NewString("main"),
8898 0,
8899 NULL);
8900 bool value = false;
8901 result = Dart_BooleanValue(result, &value);
8902 EXPECT_VALID(result);
8903 EXPECT(value);
8904 }
8905
8906
8907 TEST_CASE(ExternalStringStaticFieldDeoptimize) {
8908 const char* kScriptChars =
8909 "const strA = 'AAAA';\n"
8910 "class A {\n"
8911 " static change_str(String s) native 'A_change_str';\n"
8912 "}\n"
8913 "class G { static final f = strA; }\n"
8914 "compare(a, b, [i = 0]) {\n"
8915 " return a.codeUnitAt(i) == b.codeUnitAt(i);\n"
8916 "}\n"
8917 "compareA(b, [i = 0]) {\n"
8918 " return compare(G.f, b, i);\n"
8919 "}\n"
8920 "main() {\n"
8921 " var externalA = 'AA' + 'AA';\n"
8922 " A.change_str(externalA);\n"
8923 " compare('AA' + 'AA', strA);\n"
8924 " for (var i = 0; i < 10000; i++) compareA(strA);\n"
8925 " A.change_str(G.f);"
8926 " return compareA('AA' + 'AA');\n"
8927 "}\n";
8928 Dart_Handle lib =
8929 TestCase::LoadTestScript(kScriptChars,
8930 &ExternalStringDeoptimize_native_lookup);
8931 Dart_Handle result = Dart_Invoke(lib,
8932 NewString("main"),
8933 0,
8934 NULL);
8935 bool value = false;
8936 result = Dart_BooleanValue(result, &value);
8937 EXPECT_VALID(result);
8938 EXPECT(value);
8939 }
8940
8941
8832 TEST_CASE(ExternalStringTrimDoubleParse) { 8942 TEST_CASE(ExternalStringTrimDoubleParse) {
8833 const char* kScriptChars = 8943 const char* kScriptChars =
8834 "String str = 'A';\n" 8944 "String str = 'A';\n"
8835 "class A {\n" 8945 "class A {\n"
8836 " static change_str(String s) native 'A_change_str';\n" 8946 " static change_str(String s) native 'A_change_str';\n"
8837 "}\n" 8947 "}\n"
8838 "main() {\n" 8948 "main() {\n"
8839 " var externalOneByteString = ' 0.2\\xA0 ';\n;" 8949 " var externalOneByteString = ' 0.2\\xA0 ';\n;"
8840 " A.change_str(externalOneByteString);\n" 8950 " A.change_str(externalOneByteString);\n"
8841 " var externalTwoByteString = ' \\u{2029}0.6\\u{2029} ';\n" 8951 " var externalTwoByteString = ' \\u{2029}0.6\\u{2029} ';\n"
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after
9005 result = Dart_Invoke(lib, 9115 result = Dart_Invoke(lib,
9006 NewString("testView16"), 9116 NewString("testView16"),
9007 1, 9117 1,
9008 dart_args); 9118 dart_args);
9009 EXPECT_VALID(result); 9119 EXPECT_VALID(result);
9010 EXPECT(Dart_IsString(result)); 9120 EXPECT(Dart_IsString(result));
9011 } 9121 }
9012 } 9122 }
9013 9123
9014 } // namespace dart 9124 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/constant_propagator.cc ('k') | runtime/vm/flow_graph_type_propagator.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698