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

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

Issue 2005813002: Fix optimizer bug with external strings. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 years, 7 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
« no previous file with comments | « no previous file | runtime/vm/redundancy_elimination.cc » ('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 "vm/compiler.h" 6 #include "vm/compiler.h"
7 #include "include/dart_api.h" 7 #include "include/dart_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 "include/dart_tools_api.h" 10 #include "include/dart_tools_api.h"
(...skipping 8939 matching lines...) Expand 10 before | Expand all | Expand 10 after
8950 EXPECT_VALID(result); 8950 EXPECT_VALID(result);
8951 bool value = false; 8951 bool value = false;
8952 result = Dart_BooleanValue(result, &value); 8952 result = Dart_BooleanValue(result, &value);
8953 EXPECT_VALID(result); 8953 EXPECT_VALID(result);
8954 EXPECT(value); 8954 EXPECT(value);
8955 8955
8956 FLAG_support_externalizable_strings = saved_flag; 8956 FLAG_support_externalizable_strings = saved_flag;
8957 } 8957 }
8958 8958
8959 8959
8960 TEST_CASE(ExternalStringLoadElimination) {
8961 const bool saved_flag = FLAG_support_externalizable_strings;
8962 FLAG_support_externalizable_strings = true;
8963
8964 const char* kScriptChars =
8965 "class A {\n"
8966 " static change_str(String s) native 'A_change_str';\n"
8967 "}\n"
8968 "double_char0(str) {\n"
8969 " return str.codeUnitAt(0) + str.codeUnitAt(0);\n"
8970 "}\n"
8971 "main() {\n"
8972 " var externalA = 'AA' + 'AA';\n"
8973 " A.change_str(externalA);\n"
8974 " for (var i = 0; i < 10000; i++) double_char0(externalA);\n"
8975 " var result = double_char0(externalA);\n"
8976 " return result == 130;\n"
8977 "}\n";
8978 Dart_Handle lib =
8979 TestCase::LoadTestScript(kScriptChars,
8980 &ExternalStringDeoptimize_native_lookup);
8981 Dart_Handle result = Dart_Invoke(lib,
8982 NewString("main"),
8983 0,
8984 NULL);
8985 EXPECT_VALID(result);
8986 bool value = false;
8987 result = Dart_BooleanValue(result, &value);
8988 EXPECT_VALID(result);
8989 EXPECT(value);
8990
8991 FLAG_support_externalizable_strings = saved_flag;
8992 }
8993
8994
8960 TEST_CASE(ExternalStringGuardFieldDeoptimize) { 8995 TEST_CASE(ExternalStringGuardFieldDeoptimize) {
8961 const bool saved_flag = FLAG_support_externalizable_strings; 8996 const bool saved_flag = FLAG_support_externalizable_strings;
8962 FLAG_support_externalizable_strings = true; 8997 FLAG_support_externalizable_strings = true;
8963 8998
8964 const char* kScriptChars = 8999 const char* kScriptChars =
8965 "const strA = 'AAAA';\n" 9000 "const strA = 'AAAA';\n"
8966 "class A {\n" 9001 "class A {\n"
8967 " static change_str(String s) native 'A_change_str';\n" 9002 " static change_str(String s) native 'A_change_str';\n"
8968 "}\n" 9003 "}\n"
8969 "class G { var f = 'A'; }\n" 9004 "class G { var f = 'A'; }\n"
(...skipping 1076 matching lines...) Expand 10 before | Expand all | Expand 10 after
10046 result = Dart_Invoke(lib, 10081 result = Dart_Invoke(lib,
10047 NewString("foozoo"), 10082 NewString("foozoo"),
10048 0, 10083 0,
10049 NULL); 10084 NULL);
10050 EXPECT(Dart_IsError(result)); 10085 EXPECT(Dart_IsError(result));
10051 } 10086 }
10052 10087
10053 #endif // !PRODUCT 10088 #endif // !PRODUCT
10054 10089
10055 } // namespace dart 10090 } // namespace dart
OLDNEW
« no previous file with comments | « no previous file | runtime/vm/redundancy_elimination.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698