Index: test/cctest/compiler/test-run-bytecode-graph-builder.cc |
diff --git a/test/cctest/compiler/test-run-bytecode-graph-builder.cc b/test/cctest/compiler/test-run-bytecode-graph-builder.cc |
index be3cd24fa264422aa85ee174165af4809c410cf5..be1fefeee52e9a338489251acd607680c3e76473 100644 |
--- a/test/cctest/compiler/test-run-bytecode-graph-builder.cc |
+++ b/test/cctest/compiler/test-run-bytecode-graph-builder.cc |
@@ -1016,6 +1016,46 @@ TEST(BytecodeGraphBuilderDeleteLookupSlot) { |
} |
+TEST(BytecodeGraphBuilderLookupSlot) { |
+ HandleAndZoneScope scope; |
+ Isolate* isolate = scope.main_isolate(); |
+ Zone* zone = scope.main_zone(); |
+ Factory* factory = isolate->factory(); |
+ |
+ const char* function_prologue = "var f;" |
+ "var x = 12;" |
+ "y = 10;" |
+ "var obj = {val:3.1414};" |
+ "var z = 30;" |
+ "function f1() {" |
+ " var z = 20;" |
+ " eval(\"function t() {"; |
+ const char* function_epilogue = " }; f = t; t();\");" |
+ "}" |
+ "f1();"; |
+ |
+ ExpectedSnippet<0> snippets[] = { |
+ {"return x;", {factory->NewNumber(12)}}, |
+ {"return obj.val;", {factory->NewNumber(3.1414)}}, |
+ {"return typeof x;", {factory->NewStringFromStaticChars("number")}}, |
+ {"x = 23; return x;", {factory->NewNumber(23)}}, |
+ {"'use strict'; obj.val = 23.456; return obj.val;", |
+ {factory->NewNumber(23.456)}}}; |
+ |
+ size_t num_snippets = sizeof(snippets) / sizeof(snippets[0]); |
+ for (size_t i = 0; i < num_snippets; i++) { |
+ ScopedVector<char> script(1024); |
+ SNPrintF(script, "%s %s %s", function_prologue, snippets[i].code_snippet, |
+ function_epilogue); |
+ |
+ BytecodeGraphTester tester(isolate, zone, script.start(), "t"); |
+ auto callable = tester.GetCallable<>(); |
+ Handle<Object> return_value = callable().ToHandleChecked(); |
+ CHECK(return_value->SameValue(*snippets[i].return_value())); |
+ } |
+} |
+ |
+ |
bool get_compare_result(Token::Value opcode, Handle<Object> lhs_value, |
Handle<Object> rhs_value) { |
switch (opcode) { |