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

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

Issue 1508293003: [Interpreter] Add support for calling eval. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Fix comments Created 4 years, 11 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/interpreter/bytecode-generator.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 865b1f66ba6d317eac9084aa2a2035d53196cb1d..f2763558afa054f2fd384d24e6a8a4a8c1e1b8c9 100644
--- a/test/cctest/interpreter/test-bytecode-generator.cc
+++ b/test/cctest/interpreter/test-bytecode-generator.cc
@@ -25,6 +25,7 @@ class BytecodeGeneratorHelper {
BytecodeGeneratorHelper() {
i::FLAG_ignition = true;
i::FLAG_ignition_fake_try_catch = true;
+ i::FLAG_ignition_fallback_on_eval_and_catch = false;
i::FLAG_ignition_filter = StrDup(kFunctionName);
i::FLAG_always_opt = false;
i::FLAG_allow_natives_syntax = true;
@@ -1241,7 +1242,6 @@ TEST(PropertyCall) {
FeedbackVectorSpec feedback_spec(&zone);
FeedbackVectorSlot slot1 = feedback_spec.AddCallICSlot();
FeedbackVectorSlot slot2 = feedback_spec.AddLoadICSlot();
- USE(slot1);
Handle<i::TypeFeedbackVector> vector =
i::NewTypeFeedbackVector(helper.isolate(), &feedback_spec);
@@ -1556,7 +1556,6 @@ TEST(CallGlobal) {
FeedbackVectorSpec feedback_spec(&zone);
FeedbackVectorSlot slot1 = feedback_spec.AddCallICSlot();
FeedbackVectorSlot slot2 = feedback_spec.AddLoadICSlot();
- USE(slot1);
Handle<i::TypeFeedbackVector> vector =
i::NewTypeFeedbackVector(helper.isolate(), &feedback_spec);
@@ -5843,6 +5842,205 @@ TEST(AssignmentsInBinaryExpression) {
}
+TEST(Eval) {
+ InitializedHandleScope handle_scope;
+ BytecodeGeneratorHelper helper;
+ Zone zone;
+
+ int closure = Register::function_closure().index();
+ int context = Register::function_context().index();
+ int new_target = Register::new_target().index();
+
+ int first_context_slot = Context::MIN_CONTEXT_SLOTS;
+
+ ExpectedSnippet<const char*> snippets[] = {
+ {"return eval('1;');",
+ 9 * kPointerSize,
+ 1,
+ 73,
+ {
+ B(CallRuntime), U16(Runtime::kNewFunctionContext), R(closure), //
+ U8(1), //
+ B(PushContext), R(0), //
+ B(Ldar), THIS(1), //
+ B(StaContextSlot), R(0), U8(first_context_slot), //
+ B(CreateMappedArguments), //
+ B(StaContextSlot), R(0), U8(first_context_slot + 1), //
+ B(Ldar), R(new_target), //
+ B(StaContextSlot), R(0), U8(first_context_slot + 2), //
+ B(Mov), R(context), R(3), //
+ B(LdaConstant), U8(0), //
+ B(Star), R(4), //
+ B(CallRuntimeForPair), U16(Runtime::kLoadLookupSlot), //
+ R(3), U8(2), R(3), //
+ B(Mov), R(3), R(1), //
+ B(Mov), R(4), R(2), //
+ B(LdaConstant), U8(1), //
+ B(Star), R(3), //
+ B(Mov), R(1), R(4), //
+ B(Mov), R(3), R(5), //
+ B(Mov), R(closure), R(6), //
+ B(LdaZero), //
+ B(Star), R(7), //
+ B(LdaSmi8), U8(10), //
+ B(Star), R(8), //
+ B(CallRuntime), U16(Runtime::kResolvePossiblyDirectEval), R(4), //
+ U8(5), //
+ B(Star), R(1), //
+ B(Call), R(1), R(2), U8(1), U8(0), //
+ B(Return), //
+ },
+ 2,
+ {"eval", "1;"}},
+ };
+
+ for (size_t i = 0; i < arraysize(snippets); i++) {
+ Handle<BytecodeArray> bytecode_array =
+ helper.MakeBytecodeForFunctionBody(snippets[i].code_snippet);
+ CheckBytecodeArrayEqual(snippets[i], bytecode_array);
+ }
+}
+
+
+TEST(LookupSlot) {
+ InitializedHandleScope handle_scope;
+ BytecodeGeneratorHelper helper;
+
+ int closure = Register::function_closure().index();
+ int first_context_slot = Context::MIN_CONTEXT_SLOTS;
+ int context = Register::function_context().index();
+ int new_target = Register::new_target().index();
+
+ ExpectedSnippet<const char*> snippets[] = {
+ {"eval('var x = 10;'); return x;",
+ 9 * kPointerSize,
+ 1,
+ 75,
+ {
+ B(CallRuntime), U16(Runtime::kNewFunctionContext), R(closure), //
+ U8(1), //
+ B(PushContext), R(0), //
+ B(Ldar), THIS(1), //
+ B(StaContextSlot), R(0), U8(first_context_slot), //
+ B(CreateMappedArguments), //
+ B(StaContextSlot), R(0), U8(first_context_slot + 1), //
+ B(Ldar), R(new_target), //
+ B(StaContextSlot), R(0), U8(first_context_slot + 2), //
+ B(Mov), R(context), R(3), //
+ B(LdaConstant), U8(0), //
+ B(Star), R(4), //
+ B(CallRuntimeForPair), U16(Runtime::kLoadLookupSlot), //
+ R(3), U8(2), R(3), //
+ B(Mov), R(3), R(1), //
+ B(Mov), R(4), R(2), //
+ B(LdaConstant), U8(1), //
+ B(Star), R(3), //
+ B(Mov), R(1), R(4), //
+ B(Mov), R(3), R(5), //
+ B(Mov), R(closure), R(6), //
+ B(LdaZero), //
+ B(Star), R(7), //
+ B(LdaSmi8), U8(10), //
+ B(Star), R(8), //
+ B(CallRuntime), U16(Runtime::kResolvePossiblyDirectEval), R(4), //
+ U8(5), //
+ B(Star), R(1), //
+ B(Call), R(1), R(2), U8(1), U8(0), //
+ B(LdaLookupSlot), U8(2), //
+ B(Return), //
+ },
+ 3,
+ {"eval", "var x = 10;", "x"}},
+ {"eval('var x = 10;'); return typeof x;",
+ 9 * kPointerSize,
+ 1,
+ 76,
+ {
+ B(CallRuntime), U16(Runtime::kNewFunctionContext), R(closure), //
+ U8(1), //
+ B(PushContext), R(0), //
+ B(Ldar), THIS(1), //
+ B(StaContextSlot), R(0), U8(first_context_slot), //
+ B(CreateMappedArguments), //
+ B(StaContextSlot), R(0), U8(first_context_slot + 1), //
+ B(Ldar), R(new_target), //
+ B(StaContextSlot), R(0), U8(first_context_slot + 2), //
+ B(Mov), R(context), R(3), //
+ B(LdaConstant), U8(0), //
+ B(Star), R(4), //
+ B(CallRuntimeForPair), U16(Runtime::kLoadLookupSlot), //
+ R(3), U8(2), R(3), //
+ B(Mov), R(3), R(1), //
+ B(Mov), R(4), R(2), //
+ B(LdaConstant), U8(1), //
+ B(Star), R(3), //
+ B(Mov), R(1), R(4), //
+ B(Mov), R(3), R(5), //
+ B(Mov), R(closure), R(6), //
+ B(LdaZero), //
+ B(Star), R(7), //
+ B(LdaSmi8), U8(10), //
+ B(Star), R(8), //
+ B(CallRuntime), U16(Runtime::kResolvePossiblyDirectEval), R(4), //
+ U8(5), //
+ B(Star), R(1), //
+ B(Call), R(1), R(2), U8(1), U8(0), //
+ B(LdaLookupSlotInsideTypeof), U8(2), //
+ B(TypeOf), //
+ B(Return), //
+ },
+ 3,
+ {"eval", "var x = 10;", "x"}},
+ {"x = 20; return eval('');",
+ 9 * kPointerSize,
+ 1,
+ 77,
+ {
+ B(CallRuntime), U16(Runtime::kNewFunctionContext), R(closure), //
+ U8(1), //
+ B(PushContext), R(0), //
+ B(Ldar), THIS(1), //
+ B(StaContextSlot), R(0), U8(first_context_slot), //
+ B(CreateMappedArguments), //
+ B(StaContextSlot), R(0), U8(first_context_slot + 1), //
+ B(Ldar), R(new_target), //
+ B(StaContextSlot), R(0), U8(first_context_slot + 2), //
+ B(LdaSmi8), U8(20), //
+ B(StaLookupSlotSloppy), U8(0), //
+ B(Mov), R(context), R(3), //
+ B(LdaConstant), U8(1), //
+ B(Star), R(4), //
+ B(CallRuntimeForPair), U16(Runtime::kLoadLookupSlot), //
+ R(3), U8(2), R(3), //
+ B(Mov), R(3), R(1), //
+ B(Mov), R(4), R(2), //
+ B(LdaConstant), U8(2), //
+ B(Star), R(3), //
+ B(Mov), R(1), R(4), //
+ B(Mov), R(3), R(5), //
+ B(Mov), R(closure), R(6), //
+ B(LdaZero), //
+ B(Star), R(7), //
+ B(LdaSmi8), U8(10), //
+ B(Star), R(8), //
+ B(CallRuntime), U16(Runtime::kResolvePossiblyDirectEval), R(4), //
+ U8(5), //
+ B(Star), R(1), //
+ B(Call), R(1), R(2), U8(1), U8(0), //
+ B(Return), //
+ },
+ 3,
+ {"x", "eval", ""}},
+ };
+
+ for (size_t i = 0; i < arraysize(snippets); i++) {
+ Handle<BytecodeArray> bytecode_array =
+ helper.MakeBytecodeForFunctionBody(snippets[i].code_snippet);
+ CheckBytecodeArrayEqual(snippets[i], bytecode_array);
+ }
+}
+
+
TEST(LookupSlotInEval) {
InitializedHandleScope handle_scope;
BytecodeGeneratorHelper helper;
@@ -6013,7 +6211,7 @@ TEST(LookupSlotWideInEval) {
}
-TEST(DeleteLookupSlot) {
+TEST(DeleteLookupSlotInEval) {
InitializedHandleScope handle_scope;
BytecodeGeneratorHelper helper;
« no previous file with comments | « src/interpreter/bytecode-generator.cc ('k') | test/cctest/interpreter/test-interpreter.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698