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

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

Issue 2343633002: [interpreter] Add a fast path for dynamic local load (Closed)
Patch Set: Disable clang format for the new 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 c7e96cf8ffe470aee36b3448911283b709e2b9e4..2d0cefefcb4c743a3fa2333806289ad14b6e1936 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();
+ // Factory* factory = isolate->factory();
rmcilroy 2016/09/16 08:56:55 remove
Leszek Swirski 2016/09/16 10:46:55 Done.
+
+ const char* inner_function_prologue = "function inner() {";
+ const char* inner_function_epilogue = "return x; };";
rmcilroy 2016/09/16 08:56:55 I'm not sure the inner_function_epilogue is partic
Leszek Swirski 2016/09/16 10:46:55 Done.
+ const char* outer_function_epilogue = "return inner();";
+
+ std::tuple<const char*, const char*, Handle<Object>> lookup_slot[] = {
rmcilroy 2016/09/16 08:56:55 Could you add these tests to test-run-bytecode-gra
Leszek Swirski 2016/09/16 10:46:54 Done.
+ // Eval in inner context
+ std::make_tuple("var x = 0;", "eval('');",
+ handle(Smi::FromInt(0), isolate)),
+ std::make_tuple("var x = 0;", "eval('var x = 1');",
+ handle(Smi::FromInt(1), isolate)),
+ std::make_tuple("var x = 0;", "'use strict'; eval('var x = 1');",
+ handle(Smi::FromInt(0), isolate)),
+ // Eval in outer context
+ std::make_tuple("var x = 0; eval('');", "",
+ handle(Smi::FromInt(0), isolate)),
+ std::make_tuple("var x = 0; eval('var x = 1');", "",
+ handle(Smi::FromInt(1), isolate)),
+ std::make_tuple("'use strict'; var x = 0; eval('var x = 1');", "",
+ 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;

Powered by Google App Engine
This is Rietveld 408576698