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

Side by Side Diff: test/cctest/interpreter/test-bytecode-generator.cc

Issue 1555063002: [Interpreter] Adds support for wide variant of load/store lookup slots. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: 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 unified diff | Download patch
OLDNEW
1 // Copyright 2015 the V8 project authors. All rights reserved. 1 // Copyright 2015 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "src/v8.h" 5 #include "src/v8.h"
6 6
7 #include "src/compiler.h" 7 #include "src/compiler.h"
8 #include "src/interpreter/bytecode-array-iterator.h" 8 #include "src/interpreter/bytecode-array-iterator.h"
9 #include "src/interpreter/bytecode-generator.h" 9 #include "src/interpreter/bytecode-generator.h"
10 #include "src/interpreter/interpreter.h" 10 #include "src/interpreter/interpreter.h"
(...skipping 5820 matching lines...) Expand 10 before | Expand all | Expand 10 after
5831 std::string(function_epilogue); 5831 std::string(function_epilogue);
5832 // TODO(mythria): use * as filter when function declarations are supported 5832 // TODO(mythria): use * as filter when function declarations are supported
5833 // inside eval. 5833 // inside eval.
5834 Handle<BytecodeArray> bytecode_array = 5834 Handle<BytecodeArray> bytecode_array =
5835 helper.MakeBytecode(script.c_str(), "t", "f"); 5835 helper.MakeBytecode(script.c_str(), "t", "f");
5836 CheckBytecodeArrayEqual(snippets[i], bytecode_array); 5836 CheckBytecodeArrayEqual(snippets[i], bytecode_array);
5837 } 5837 }
5838 } 5838 }
5839 5839
5840 5840
5841 TEST(LookupSlotWideInEval) {
5842 InitializedHandleScope handle_scope;
5843 BytecodeGeneratorHelper helper;
5844
5845 const char* function_prologue =
5846 "var f;"
5847 "var x = 1;"
5848 "function f1() {"
5849 " eval(\"function t() {";
5850 const char* function_epilogue =
5851 " }; f = t; f();\");"
5852 "}"
5853 "f1();";
5854 std::ostringstream str;
5855 str << "var y = 2.3;";
5856 for (int i = 1; i < 256; i++) {
5857 str << "y = " << 2.3 + i << ";";
5858 }
5859 std::string init_function_body = str.str();
5860
5861 std::string function_body[] = {
5862 init_function_body + "return x;", init_function_body + "return typeof x;",
5863 init_function_body + "x = 10;",
5864 "'use strict';" + init_function_body + "x = 10;"};
5865 int const_count[] = {0, 0, 0, 0};
5866
5867 ExpectedSnippet<InstanceType, 257> snippets[] = {
5868 {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.
5869 1 * kPointerSize,
5870 1,
5871 1028,
5872 {
5873 REPEAT_256(SPACE, //
5874 B(LdaConstant), U8(const_count[0]++), //
5875 B(Star), R(0), ) //
5876 B(LdaLookupSlotWide), U16(256), //
5877 B(Return) //
5878 },
5879 257,
5880 {REPEAT_256(COMMA, InstanceType::HEAP_NUMBER_TYPE),
5881 InstanceType::ONE_BYTE_INTERNALIZED_STRING_TYPE}},
5882 {function_body[1].c_str(),
5883 1 * kPointerSize,
5884 1,
5885 1029,
5886 {
5887 REPEAT_256(SPACE, //
5888 B(LdaConstant), U8(const_count[1]++), //
5889 B(Star), R(0), ) //
5890 B(LdaLookupSlotInsideTypeofWide), U16(256), //
5891 B(TypeOf), //
5892 B(Return) //
5893 },
5894 257,
5895 {REPEAT_256(COMMA, InstanceType::HEAP_NUMBER_TYPE),
5896 InstanceType::ONE_BYTE_INTERNALIZED_STRING_TYPE}},
5897 {function_body[2].c_str(),
5898 1 * kPointerSize,
5899 1,
5900 1031,
5901 {
5902 REPEAT_256(SPACE, //
5903 B(LdaConstant), U8(const_count[2]++), //
5904 B(Star), R(0), ) //
5905 B(LdaSmi8), U8(10), //
5906 B(StaLookupSlotSloppyWide), U16(256), //
5907 B(LdaUndefined), //
5908 B(Return) //
5909 },
5910 257,
5911 {REPEAT_256(COMMA, InstanceType::HEAP_NUMBER_TYPE),
5912 InstanceType::ONE_BYTE_INTERNALIZED_STRING_TYPE}},
5913 {function_body[3].c_str(),
5914 1 * kPointerSize,
5915 1,
5916 1031,
5917 {
5918 REPEAT_256(SPACE,
5919 B(LdaConstant), U8(const_count[3]++), //
5920 B(Star), R(0), ) //
5921 B(LdaSmi8), U8(10), //
5922 B(StaLookupSlotStrictWide), U16(256), //
5923 B(LdaUndefined), //
5924 B(Return) //
5925 },
5926 257,
5927 {REPEAT_256(COMMA, InstanceType::HEAP_NUMBER_TYPE),
5928 InstanceType::ONE_BYTE_INTERNALIZED_STRING_TYPE}},
5929 };
5930
5931 for (size_t i = 0; i < arraysize(snippets); i++) {
5932 std::string script = std::string(function_prologue) +
5933 std::string(snippets[i].code_snippet) +
5934 std::string(function_epilogue);
5935 // TODO(mythria): use * as filter when function declarations are supported
5936 // inside eval.
5937 Handle<BytecodeArray> bytecode_array =
5938 helper.MakeBytecode(script.c_str(), "t", "f");
5939 CheckBytecodeArrayEqual(snippets[i], bytecode_array);
5940 }
5941 }
5942
5943
5841 TEST(DeleteLookupSlot) { 5944 TEST(DeleteLookupSlot) {
5842 InitializedHandleScope handle_scope; 5945 InitializedHandleScope handle_scope;
5843 BytecodeGeneratorHelper helper; 5946 BytecodeGeneratorHelper helper;
5844 5947
5845 const char* function_prologue = "var f;" 5948 const char* function_prologue = "var f;"
5846 "var x = 1;" 5949 "var x = 1;"
5847 "z = 10;" 5950 "z = 10;"
5848 "function f1() {" 5951 "function f1() {"
5849 " var y;" 5952 " var y;"
5850 " eval(\"function t() {"; 5953 " eval(\"function t() {";
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
5893 std::string(function_epilogue); 5996 std::string(function_epilogue);
5894 Handle<BytecodeArray> bytecode_array = 5997 Handle<BytecodeArray> bytecode_array =
5895 helper.MakeBytecode(script.c_str(), "t", "f"); 5998 helper.MakeBytecode(script.c_str(), "t", "f");
5896 CheckBytecodeArrayEqual(snippets[i], bytecode_array); 5999 CheckBytecodeArrayEqual(snippets[i], bytecode_array);
5897 } 6000 }
5898 } 6001 }
5899 6002
5900 } // namespace interpreter 6003 } // namespace interpreter
5901 } // namespace internal 6004 } // namespace internal
5902 } // namespace v8 6005 } // namespace v8
OLDNEW
« no previous file with comments | « test/cctest/compiler/test-run-bytecode-graph-builder.cc ('k') | test/cctest/interpreter/test-interpreter.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698