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

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

Issue 1406183002: [Interpreter] Add support for strict mode global stores. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 2 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 "src/v8.h" 5 #include "src/v8.h"
6 6
7 #include "src/compiler.h" 7 #include "src/compiler.h"
8 #include "src/interpreter/bytecode-array-iterator.h" 8 #include "src/interpreter/bytecode-array-iterator.h"
9 #include "src/interpreter/bytecode-generator.h" 9 #include "src/interpreter/bytecode-generator.h"
10 #include "src/interpreter/interpreter.h" 10 #include "src/interpreter/interpreter.h"
(...skipping 1055 matching lines...) Expand 10 before | Expand all | Expand 10 after
1066 helper.MakeBytecode(snippets[i].code_snippet, "f"); 1066 helper.MakeBytecode(snippets[i].code_snippet, "f");
1067 CheckBytecodeArrayEqual(snippets[i], bytecode_array, true); 1067 CheckBytecodeArrayEqual(snippets[i], bytecode_array, true);
1068 } 1068 }
1069 } 1069 }
1070 1070
1071 1071
1072 TEST(StoreGlobal) { 1072 TEST(StoreGlobal) {
1073 InitializedHandleScope handle_scope; 1073 InitializedHandleScope handle_scope;
1074 BytecodeGeneratorHelper helper; 1074 BytecodeGeneratorHelper helper;
1075 1075
1076 ExpectedSnippet<int> snippets[] = { 1076 ExpectedSnippet<InstanceType> snippets[] = {
1077 { 1077 {
1078 "var a = 1;\nfunction f() { a = 2; }\nf()", 1078 "var a = 1;\nfunction f() { a = 2; }\nf()",
1079 0, 1079 0,
1080 1, 1080 1,
1081 6, 1081 6,
1082 { 1082 {
1083 B(LdaSmi8), U8(2), // 1083 B(LdaSmi8), U8(2), //
1084 B(StaGlobal), _, // 1084 B(StaGlobalSloppy), _, //
1085 B(LdaUndefined), // 1085 B(LdaUndefined), //
1086 B(Return) // 1086 B(Return) //
1087 }, 1087 },
1088 }, 1088 },
1089 { 1089 {
1090 "var a = \"test\"; function f(b) { a = b; }\nf(\"global\")", 1090 "var a = \"test\"; function f(b) { a = b; }\nf(\"global\")",
1091 0, 1091 0,
1092 2, 1092 2,
1093 6, 1093 6,
1094 { 1094 {
1095 B(Ldar), R(helper.kLastParamIndex), // 1095 B(Ldar), R(helper.kLastParamIndex), //
1096 B(StaGlobal), _, // 1096 B(StaGlobalSloppy), _, //
1097 B(LdaUndefined), // 1097 B(LdaUndefined), //
1098 B(Return) // 1098 B(Return) //
1099 }, 1099 },
1100 }, 1100 },
1101 {
1102 "'use strict'; var a = 1;\nfunction f() { a = 2; }\nf()",
1103 0,
1104 1,
1105 6,
1106 {
1107 B(LdaSmi8), U8(2), //
1108 B(StaGlobalStrict), _, //
1109 B(LdaUndefined), //
1110 B(Return) //
1111 },
1112 },
1101 }; 1113 };
1102 1114
1103 for (size_t i = 0; i < arraysize(snippets); i++) { 1115 for (size_t i = 0; i < arraysize(snippets); i++) {
1104 Handle<BytecodeArray> bytecode_array = 1116 Handle<BytecodeArray> bytecode_array =
1105 helper.MakeBytecode(snippets[i].code_snippet, "f"); 1117 helper.MakeBytecode(snippets[i].code_snippet, "f");
1106 CheckBytecodeArrayEqual(snippets[i], bytecode_array, true); 1118 CheckBytecodeArrayEqual(snippets[i], bytecode_array, true);
1107 } 1119 }
1108 } 1120 }
1109 1121
1110 1122
(...skipping 448 matching lines...) Expand 10 before | Expand all | Expand 10 after
1559 B(CallRuntime), U16(Runtime::kDeclareGlobals), R(2), U8(2), // 1571 B(CallRuntime), U16(Runtime::kDeclareGlobals), R(2), U8(2), //
1560 B(LdaConstant), U8(2), // 1572 B(LdaConstant), U8(2), //
1561 B(Star), R(2), // 1573 B(Star), R(2), //
1562 B(LdaZero), // 1574 B(LdaZero), //
1563 B(Star), R(3), // 1575 B(Star), R(3), //
1564 B(LdaSmi8), U8(1), // 1576 B(LdaSmi8), U8(1), //
1565 B(Star), R(4), // 1577 B(Star), R(4), //
1566 B(CallRuntime), U16(Runtime::kInitializeVarGlobal), R(2), // 1578 B(CallRuntime), U16(Runtime::kInitializeVarGlobal), R(2), //
1567 U8(3), // 1579 U8(3), //
1568 B(LdaSmi8), U8(2), // 1580 B(LdaSmi8), U8(2), //
1569 B(StaGlobal), _, // 1581 B(StaGlobalSloppy), _, //
1570 B(Star), R(0), // 1582 B(Star), R(0), //
1571 B(Ldar), R(0), // 1583 B(Ldar), R(0), //
1572 B(Return) // 1584 B(Return) //
1573 }, 1585 },
1574 -1}, 1586 -1},
1575 {"function f() {}\nf();", 1587 {"function f() {}\nf();",
1576 4 * kPointerSize, 1588 4 * kPointerSize,
1577 1, 1589 1,
1578 43, 1590 43,
1579 { 1591 {
(...skipping 1086 matching lines...) Expand 10 before | Expand all | Expand 10 after
2666 for (size_t i = 0; i < arraysize(snippets); i++) { 2678 for (size_t i = 0; i < arraysize(snippets); i++) {
2667 Handle<BytecodeArray> bytecode_array = 2679 Handle<BytecodeArray> bytecode_array =
2668 helper.MakeBytecodeForFunctionBody(snippets[i].code_snippet); 2680 helper.MakeBytecodeForFunctionBody(snippets[i].code_snippet);
2669 CheckBytecodeArrayEqual(snippets[i], bytecode_array); 2681 CheckBytecodeArrayEqual(snippets[i], bytecode_array);
2670 } 2682 }
2671 } 2683 }
2672 2684
2673 } // namespace interpreter 2685 } // namespace interpreter
2674 } // namespace internal 2686 } // namespace internal
2675 } // namespace v8 2687 } // namespace v8
OLDNEW
« no previous file with comments | « src/interpreter/interpreter.cc ('k') | test/unittests/interpreter/bytecode-array-builder-unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698