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

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

Issue 1524803003: [Interpreter] Add support for Load / Store to Lookup slots. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@init_eval_impl
Patch Set: Fixed nits. Created 5 years 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 ead1fa1672bfb5c5b83295667419be7d003195d2..d30846a5ca78549362ca578d9893adee3a041c87 100644
--- a/test/cctest/interpreter/test-bytecode-generator.cc
+++ b/test/cctest/interpreter/test-bytecode-generator.cc
@@ -55,6 +55,15 @@ class BytecodeGeneratorHelper {
return handle(js_function->shared()->bytecode_array(), CcTest::i_isolate());
}
+ Handle<BytecodeArray> MakeBytecode(const char* script, const char* filter,
+ const char* function_name) {
+ const char* old_ignition_filter = i::FLAG_ignition_filter;
+ i::FLAG_ignition_filter = filter;
+ Handle<BytecodeArray> return_val = MakeBytecode(script, function_name);
+ i::FLAG_ignition_filter = old_ignition_filter;
+ return return_val;
+ }
+
Handle<BytecodeArray> MakeBytecodeForFunctionBody(const char* body) {
ScopedVector<char> program(3072);
SNPrintF(program, "function %s() { %s }\n%s();", kFunctionName, body,
@@ -69,14 +78,9 @@ class BytecodeGeneratorHelper {
}
Handle<BytecodeArray> MakeBytecodeForFunctionNoFilter(const char* function) {
- const char* old_ignition_filter = i::FLAG_ignition_filter;
- i::FLAG_ignition_filter = "*";
ScopedVector<char> program(3072);
SNPrintF(program, "%s\n%s();", function, kFunctionName);
- Handle<BytecodeArray> return_val =
- MakeBytecode(program.start(), kFunctionName);
- i::FLAG_ignition_filter = old_ignition_filter;
- return return_val;
+ return MakeBytecode(program.start(), "*", kFunctionName);
}
};
@@ -5518,6 +5522,79 @@ TEST(AssignmentsInBinaryExpression) {
}
}
+
+TEST(LookupSlotInEval) {
+ InitializedHandleScope handle_scope;
+ BytecodeGeneratorHelper helper;
+
+ const char* function_prologue = "var f;"
+ "var x = 1;"
+ "function f1() {"
+ " eval(\"function t() {";
+ const char* function_epilogue = " }; f = t; f();\");"
+ "}"
+ "f1();";
+
+ ExpectedSnippet<const char*> snippets[] = {
+ {"return x;",
+ 0 * kPointerSize,
+ 1,
+ 3,
+ {
+ B(LdaLookupSlot), U8(0), //
+ B(Return) //
+ },
+ 1,
+ {"x"}},
+ {"x = 10;",
+ 0 * kPointerSize,
+ 1,
+ 6,
+ {
+ B(LdaSmi8), U8(10), //
+ B(StaLookupSlotSloppy), U8(0), //
+ B(LdaUndefined), //
+ B(Return), //
+ },
+ 1,
+ {"x"}},
+ {"'use strict'; x = 10;",
+ 0 * kPointerSize,
+ 1,
+ 6,
+ {
+ B(LdaSmi8), U8(10), //
+ B(StaLookupSlotStrict), U8(0), //
+ B(LdaUndefined), //
+ B(Return), //
+ },
+ 1,
+ {"x"}},
+ {"return typeof x;",
+ 0 * kPointerSize,
+ 1,
+ 4,
+ {
+ B(LdaLookupSlotInsideTypeof), U8(0), //
+ B(TypeOf), //
+ B(Return), //
+ },
+ 1,
+ {"x"}},
+ };
+
+ for (size_t i = 0; i < arraysize(snippets); i++) {
+ std::string script = std::string(function_prologue) +
+ std::string(snippets[i].code_snippet) +
+ std::string(function_epilogue);
+ // TODO(mythria): use * as filter when function declarations are supported
+ // inside eval.
+ Handle<BytecodeArray> bytecode_array =
+ helper.MakeBytecode(script.c_str(), "t", "f");
+ CheckBytecodeArrayEqual(snippets[i], bytecode_array);
+ }
+}
+
} // namespace interpreter
} // namespace internal
} // namespace v8
« 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