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

Side by Side Diff: test/cctest/interpreter/test-bytecode-generator.cc

Issue 2793923002: [Interpreter] Optimize code of the form 'if (x === undefined)'. (Closed)
Patch Set: Rebase Created 3 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
OLDNEW
1 // Copyright 2015 the V8 project authors. All rights reserved. 1 // Copyright 2015 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include <fstream> 5 #include <fstream>
6 6
7 #include "src/v8.h" 7 #include "src/v8.h"
8 8
9 #include "src/interpreter/bytecode-array-iterator.h" 9 #include "src/interpreter/bytecode-array-iterator.h"
10 #include "src/interpreter/bytecode-generator.h" 10 #include "src/interpreter/bytecode-generator.h"
(...skipping 1009 matching lines...) Expand 10 before | Expand all | Expand 10 after
1020 1020
1021 "return 'string' === typeof(undefined);\n", 1021 "return 'string' === typeof(undefined);\n",
1022 1022
1023 "return 'unknown' === typeof(undefined);\n", 1023 "return 'unknown' === typeof(undefined);\n",
1024 }; 1024 };
1025 1025
1026 CHECK(CompareTexts(BuildActual(printer, snippets), 1026 CHECK(CompareTexts(BuildActual(printer, snippets),
1027 LoadGolden("CompareTypeOf.golden"))); 1027 LoadGolden("CompareTypeOf.golden")));
1028 } 1028 }
1029 1029
1030 TEST(CompareNil) {
1031 InitializedIgnitionHandleScope scope;
1032 BytecodeExpectationsPrinter printer(CcTest::isolate());
1033
1034 const char* snippets[] = {
1035 "var a = 1;\n"
1036 "return a === null;\n",
1037
1038 "var a = undefined;\n"
1039 "return undefined === a;\n",
1040
1041 "var a = undefined;\n"
1042 "return undefined !== a;\n",
1043
1044 "var a = 2;\n"
1045 "return a != null;\n",
1046
1047 "var a = undefined;\n"
1048 "return undefined == a;\n",
1049
1050 "var a = undefined;\n"
1051 "return undefined === a ? 1 : 2;\n",
1052
1053 "var a = 0;\n"
1054 "return null == a ? 1 : 2;\n",
1055
1056 "var a = 0;\n"
1057 "return undefined !== a ? 1 : 2;\n",
1058
1059 "var a = 0;\n"
1060 "return a === null ? 1 : 2;\n",
1061
1062 "var a = 0;\n"
1063 "if (a === null) {\n"
1064 " return 1;\n"
1065 "} else {\n"
1066 " return 2;\n"
1067 "}\n",
1068
1069 "var a = 0;\n"
1070 "if (a != undefined) {\n"
1071 " return 1;\n"
1072 "}\n",
1073
1074 "var a = undefined;\n"
1075 "var b = 0;\n"
1076 "while (a !== undefined) {\n"
1077 " b++;\n"
1078 "}\n",
1079 };
1080
1081 CHECK(CompareTexts(BuildActual(printer, snippets),
1082 LoadGolden("CompareNil.golden")));
1083 }
1084
1030 TEST(Delete) { 1085 TEST(Delete) {
1031 InitializedIgnitionHandleScope scope; 1086 InitializedIgnitionHandleScope scope;
1032 BytecodeExpectationsPrinter printer(CcTest::isolate()); 1087 BytecodeExpectationsPrinter printer(CcTest::isolate());
1033 1088
1034 const char* snippets[] = { 1089 const char* snippets[] = {
1035 "var a = {x:13, y:14}; return delete a.x;\n", 1090 "var a = {x:13, y:14}; return delete a.x;\n",
1036 1091
1037 "'use strict'; var a = {x:13, y:14}; return delete a.x;\n", 1092 "'use strict'; var a = {x:13, y:14}; return delete a.x;\n",
1038 1093
1039 "var a = {1:13, 2:14}; return delete a[2];\n", 1094 "var a = {1:13, 2:14}; return delete a[2];\n",
(...skipping 1386 matching lines...) Expand 10 before | Expand all | Expand 10 after
2426 2481
2427 CHECK(CompareTexts(BuildActual(printer, snippets), 2482 CHECK(CompareTexts(BuildActual(printer, snippets),
2428 LoadGolden("ForAwaitOf.golden"))); 2483 LoadGolden("ForAwaitOf.golden")));
2429 2484
2430 i::FLAG_harmony_async_iteration = old_flag; 2485 i::FLAG_harmony_async_iteration = old_flag;
2431 } 2486 }
2432 2487
2433 } // namespace interpreter 2488 } // namespace interpreter
2434 } // namespace internal 2489 } // namespace internal
2435 } // namespace v8 2490 } // namespace v8
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698