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

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

Issue 2343633002: [interpreter] Add a fast path for dynamic local load (Closed)
Patch Set: Fix extension slot word size in equality test Created 4 years, 3 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
Index: test/cctest/interpreter/test-interpreter.cc
diff --git a/test/cctest/interpreter/test-interpreter.cc b/test/cctest/interpreter/test-interpreter.cc
index 26c11890f52d7b1b2cfbf027f6249b506c36e94f..99b99734ae280bc770f3ae0922fd6cbc8eb07ffc 100644
--- a/test/cctest/interpreter/test-interpreter.cc
+++ b/test/cctest/interpreter/test-interpreter.cc
@@ -2,6 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
+#include <tuple>
+
#include "src/v8.h"
#include "src/execution.h"
@@ -3862,6 +3864,47 @@ TEST(InterpreterLookupSlot) {
}
}
+TEST(InterpreterLookupContextSlot) {
+ HandleAndZoneScope handles;
+ Isolate* isolate = handles.main_isolate();
+
+ const char* inner_function_prologue = "function inner() {";
+ const char* inner_function_epilogue = "};";
+ const char* outer_function_epilogue = "return inner();";
+
+ std::tuple<const char*, const char*, Handle<Object>> lookup_slot[] = {
+ // Eval in inner context.
+ std::make_tuple("var x = 0;", "eval(''); return x;",
+ handle(Smi::FromInt(0), isolate)),
+ std::make_tuple("var x = 0;", "eval('var x = 1'); return x;",
+ handle(Smi::FromInt(1), isolate)),
+ std::make_tuple("var x = 0;",
+ "'use strict'; eval('var x = 1'); return x;",
+ handle(Smi::FromInt(0), isolate)),
+ // Eval in outer context.
+ std::make_tuple("var x = 0; eval('');", "return x;",
+ handle(Smi::FromInt(0), isolate)),
+ std::make_tuple("var x = 0; eval('var x = 1');", "return x;",
+ handle(Smi::FromInt(1), isolate)),
+ std::make_tuple("'use strict'; var x = 0; eval('var x = 1');",
+ "return x;", handle(Smi::FromInt(0), isolate)),
+ };
+
+ for (size_t i = 0; i < arraysize(lookup_slot); i++) {
+ std::string body = std::string(std::get<0>(lookup_slot[i])) +
+ std::string(inner_function_prologue) +
+ std::string(std::get<1>(lookup_slot[i])) +
+ std::string(inner_function_epilogue) +
+ std::string(outer_function_epilogue);
+ std::string script = InterpreterTester::SourceForBody(body.c_str());
+
+ InterpreterTester tester(isolate, script.c_str());
+ auto callable = tester.GetCallable<>();
+
+ Handle<i::Object> return_value = callable().ToHandleChecked();
+ CHECK(return_value->SameValue(*std::get<2>(lookup_slot[i])));
+ }
+}
TEST(InterpreterCallLookupSlot) {
HandleAndZoneScope handles;
« no previous file with comments | « test/cctest/interpreter/test-bytecode-generator.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