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

Unified Diff: test/cctest/interpreter/test-bytecode-generator.cc

Issue 1422443006: [Intepreter] Don't throw reference errors for globals in typeof. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Rebased Created 5 years, 1 month 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 | « src/interpreter/interpreter.cc ('k') | test/cctest/interpreter/test-interpreter.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/cctest/interpreter/test-bytecode-generator.cc
diff --git a/test/cctest/interpreter/test-bytecode-generator.cc b/test/cctest/interpreter/test-bytecode-generator.cc
index bf43587b4cf58a5d103dae929e8aca69018565fc..0f36ae84147ac05ed8aa099716b3284fcd8be194 100644
--- a/test/cctest/interpreter/test-bytecode-generator.cc
+++ b/test/cctest/interpreter/test-bytecode-generator.cc
@@ -2456,19 +2456,6 @@ TEST(UnaryOperators) {
1,
{1234}},
{"var x = 13;"
- "return typeof(x);",
- kPointerSize,
- 1,
- 8,
- {
- B(LdaSmi8), U8(13), //
- B(Star), R(0), // TODO(oth): Ldar R(X) following Star R(X)
- B(Ldar), R(0), // could be culled in bytecode array builder.
- B(TypeOf), //
- B(Return), //
- },
- 0},
- {"var x = 13;"
"return ~x;",
1 * kPointerSize,
1,
@@ -2516,6 +2503,73 @@ TEST(UnaryOperators) {
}
+TEST(Typeof) {
+ InitializedHandleScope handle_scope;
+ BytecodeGeneratorHelper helper;
+ Zone zone;
+
+ FeedbackVectorSpec feedback_spec(&zone);
+ FeedbackVectorSlot slot = feedback_spec.AddLoadICSlot();
+
+ Handle<i::TypeFeedbackVector> vector =
+ i::NewTypeFeedbackVector(helper.isolate(), &feedback_spec);
+
+ ExpectedSnippet<const char*> snippets[] = {
+ {"function f() {\n"
+ " var x = 13;\n"
+ " return typeof(x);\n"
+ "}; f();",
+ kPointerSize,
+ 1,
+ 8,
+ {
+ B(LdaSmi8), U8(13), //
+ B(Star), R(0), // TODO(oth): Ldar R(X) following Star R(X)
+ B(Ldar), R(0), // could be culled in bytecode array builder.
+ B(TypeOf), //
+ B(Return), //
+ }},
+ {"var x = 13;\n"
+ "function f() {\n"
+ " return typeof(x);\n"
+ "}; f();",
+ 0,
+ 1,
+ 5,
+ {
+ B(LdaGlobalInsideTypeofSloppy), U8(0), //
+ U8(vector->GetIndex(slot)), //
+ B(TypeOf), //
+ B(Return), //
+ },
+ 1,
+ {"x"}},
+ {"var x = 13;\n"
+ "function f() {\n"
+ " 'use strict';\n"
+ " return typeof(x);\n"
+ "}; f();",
+ 0,
+ 1,
+ 5,
+ {
+ B(LdaGlobalInsideTypeofStrict), U8(0), //
+ U8(vector->GetIndex(slot)), //
+ B(TypeOf), //
+ B(Return), //
+ },
+ 1,
+ {"x"}},
+ };
+
+ for (size_t i = 0; i < arraysize(snippets); i++) {
+ Handle<BytecodeArray> bytecode_array =
+ helper.MakeBytecodeForFunction(snippets[i].code_snippet);
+ CheckBytecodeArrayEqual(snippets[i], bytecode_array);
+ }
+}
+
+
TEST(Delete) {
InitializedHandleScope handle_scope;
BytecodeGeneratorHelper helper;
« no previous file with comments | « src/interpreter/interpreter.cc ('k') | test/cctest/interpreter/test-interpreter.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698