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 cbd689c1c77042374efd10ffe12f6c5992ffbac7..30979a2987b163f8a7a84db74c611ff1ee555664 100644 |
--- a/test/cctest/interpreter/test-bytecode-generator.cc |
+++ b/test/cctest/interpreter/test-bytecode-generator.cc |
@@ -5838,6 +5838,109 @@ TEST(LookupSlotInEval) { |
} |
+TEST(LookupSlotWideInEval) { |
+ 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();"; |
+ std::ostringstream str; |
+ str << "var y = 2.3;"; |
+ for (int i = 1; i < 256; i++) { |
+ str << "y = " << 2.3 + i << ";"; |
+ } |
+ std::string init_function_body = str.str(); |
+ |
+ std::string function_body[] = { |
+ init_function_body + "return x;", init_function_body + "return typeof x;", |
+ init_function_body + "x = 10;", |
+ "'use strict';" + init_function_body + "x = 10;"}; |
+ int const_count[] = {0, 0, 0, 0}; |
+ |
+ ExpectedSnippet<InstanceType, 257> snippets[] = { |
+ {function_body[0].c_str(), |
rmcilroy
2016/01/04 15:22:32
I would prefer you just put the actual function co
mythria
2016/01/05 10:07:26
Thanks,
Done.
|
+ 1 * kPointerSize, |
+ 1, |
+ 1028, |
+ { |
+ REPEAT_256(SPACE, // |
+ B(LdaConstant), U8(const_count[0]++), // |
+ B(Star), R(0), ) // |
+ B(LdaLookupSlotWide), U16(256), // |
+ B(Return) // |
+ }, |
+ 257, |
+ {REPEAT_256(COMMA, InstanceType::HEAP_NUMBER_TYPE), |
+ InstanceType::ONE_BYTE_INTERNALIZED_STRING_TYPE}}, |
+ {function_body[1].c_str(), |
+ 1 * kPointerSize, |
+ 1, |
+ 1029, |
+ { |
+ REPEAT_256(SPACE, // |
+ B(LdaConstant), U8(const_count[1]++), // |
+ B(Star), R(0), ) // |
+ B(LdaLookupSlotInsideTypeofWide), U16(256), // |
+ B(TypeOf), // |
+ B(Return) // |
+ }, |
+ 257, |
+ {REPEAT_256(COMMA, InstanceType::HEAP_NUMBER_TYPE), |
+ InstanceType::ONE_BYTE_INTERNALIZED_STRING_TYPE}}, |
+ {function_body[2].c_str(), |
+ 1 * kPointerSize, |
+ 1, |
+ 1031, |
+ { |
+ REPEAT_256(SPACE, // |
+ B(LdaConstant), U8(const_count[2]++), // |
+ B(Star), R(0), ) // |
+ B(LdaSmi8), U8(10), // |
+ B(StaLookupSlotSloppyWide), U16(256), // |
+ B(LdaUndefined), // |
+ B(Return) // |
+ }, |
+ 257, |
+ {REPEAT_256(COMMA, InstanceType::HEAP_NUMBER_TYPE), |
+ InstanceType::ONE_BYTE_INTERNALIZED_STRING_TYPE}}, |
+ {function_body[3].c_str(), |
+ 1 * kPointerSize, |
+ 1, |
+ 1031, |
+ { |
+ REPEAT_256(SPACE, |
+ B(LdaConstant), U8(const_count[3]++), // |
+ B(Star), R(0), ) // |
+ B(LdaSmi8), U8(10), // |
+ B(StaLookupSlotStrictWide), U16(256), // |
+ B(LdaUndefined), // |
+ B(Return) // |
+ }, |
+ 257, |
+ {REPEAT_256(COMMA, InstanceType::HEAP_NUMBER_TYPE), |
+ InstanceType::ONE_BYTE_INTERNALIZED_STRING_TYPE}}, |
+ }; |
+ |
+ 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); |
+ } |
+} |
+ |
+ |
TEST(DeleteLookupSlot) { |
InitializedHandleScope handle_scope; |
BytecodeGeneratorHelper helper; |