diff options
Diffstat (limited to 'deps/v8/test/cctest/interpreter/test-bytecode-generator.cc')
-rw-r--r-- | deps/v8/test/cctest/interpreter/test-bytecode-generator.cc | 282 |
1 files changed, 132 insertions, 150 deletions
diff --git a/deps/v8/test/cctest/interpreter/test-bytecode-generator.cc b/deps/v8/test/cctest/interpreter/test-bytecode-generator.cc index d82bad228b..fbcd297dd6 100644 --- a/deps/v8/test/cctest/interpreter/test-bytecode-generator.cc +++ b/deps/v8/test/cctest/interpreter/test-bytecode-generator.cc @@ -6,7 +6,6 @@ #include "src/v8.h" -#include "src/compiler.h" #include "src/interpreter/bytecode-array-iterator.h" #include "src/interpreter/bytecode-generator.h" #include "src/interpreter/interpreter.h" @@ -57,12 +56,13 @@ namespace interpreter { #define REPEAT_64_UNIQUE_VARS() REPEAT_32_UNIQUE_VARS() REPEAT_32_UNIQUE_VARS() #define REPEAT_128_UNIQUE_VARS() REPEAT_64_UNIQUE_VARS() REPEAT_64_UNIQUE_VARS() -#define REPEAT_249_UNIQUE_VARS() \ +#define REPEAT_250_UNIQUE_VARS() \ REPEAT_128_UNIQUE_VARS() \ REPEAT_64_UNIQUE_VARS() \ REPEAT_32_UNIQUE_VARS() \ REPEAT_16_UNIQUE_VARS() \ REPEAT_8_UNIQUE_VARS() \ + UNIQUE_VAR() \ UNIQUE_VAR() static const char* kGoldenFileDirectory = @@ -72,7 +72,6 @@ class InitializedIgnitionHandleScope : public InitializedHandleScope { public: InitializedIgnitionHandleScope() { i::FLAG_ignition = true; - i::FLAG_ignition_osr = false; // TODO(4764): Disabled for now. i::FLAG_always_opt = false; i::FLAG_allow_natives_syntax = true; CcTest::i_isolate()->interpreter()->Initialize(); @@ -152,12 +151,9 @@ bool CompareTexts(const std::string& generated, const std::string& expected) { } while (true); } -using ConstantPoolType = BytecodeExpectationsPrinter::ConstantPoolType; - TEST(PrimitiveReturnStatements) { InitializedIgnitionHandleScope scope; - BytecodeExpectationsPrinter printer(CcTest::isolate(), - ConstantPoolType::kNumber); + BytecodeExpectationsPrinter printer(CcTest::isolate()); const char* snippets[] = { "", @@ -188,8 +184,7 @@ TEST(PrimitiveReturnStatements) { TEST(PrimitiveExpressions) { InitializedIgnitionHandleScope scope; - BytecodeExpectationsPrinter printer(CcTest::isolate(), - ConstantPoolType::kNumber); + BytecodeExpectationsPrinter printer(CcTest::isolate()); const char* snippets[] = { "var x = 0; return x;\n", @@ -224,8 +219,7 @@ TEST(PrimitiveExpressions) { TEST(LogicalExpressions) { InitializedIgnitionHandleScope scope; - BytecodeExpectationsPrinter printer(CcTest::isolate(), - ConstantPoolType::kNumber); + BytecodeExpectationsPrinter printer(CcTest::isolate()); const char* snippets[] = { "var x = 0; return x || 3;\n", @@ -268,8 +262,7 @@ TEST(LogicalExpressions) { TEST(Parameters) { InitializedIgnitionHandleScope scope; - BytecodeExpectationsPrinter printer(CcTest::isolate(), - ConstantPoolType::kNumber); + BytecodeExpectationsPrinter printer(CcTest::isolate()); printer.set_wrap(false); printer.set_test_function_name("f"); @@ -295,8 +288,7 @@ TEST(Parameters) { TEST(IntegerConstants) { InitializedIgnitionHandleScope scope; - BytecodeExpectationsPrinter printer(CcTest::isolate(), - ConstantPoolType::kNumber); + BytecodeExpectationsPrinter printer(CcTest::isolate()); const char* snippets[] = { "return 12345678;\n", @@ -311,8 +303,7 @@ TEST(IntegerConstants) { TEST(HeapNumberConstants) { InitializedIgnitionHandleScope scope; - BytecodeExpectationsPrinter printer(CcTest::isolate(), - ConstantPoolType::kNumber); + BytecodeExpectationsPrinter printer(CcTest::isolate()); const char* snippets[] = { "return 1.2;\n", @@ -331,8 +322,7 @@ TEST(HeapNumberConstants) { TEST(StringConstants) { InitializedIgnitionHandleScope scope; - BytecodeExpectationsPrinter printer(CcTest::isolate(), - ConstantPoolType::kString); + BytecodeExpectationsPrinter printer(CcTest::isolate()); const char* snippets[] = { "return \"This is a string\";\n", @@ -347,8 +337,7 @@ TEST(StringConstants) { TEST(PropertyLoads) { InitializedIgnitionHandleScope scope; - BytecodeExpectationsPrinter printer(CcTest::isolate(), - ConstantPoolType::kString); + BytecodeExpectationsPrinter printer(CcTest::isolate()); printer.set_wrap(false); printer.set_test_function_name("f"); @@ -391,8 +380,7 @@ TEST(PropertyLoads) { TEST(PropertyStores) { InitializedIgnitionHandleScope scope; - BytecodeExpectationsPrinter printer(CcTest::isolate(), - ConstantPoolType::kString); + BytecodeExpectationsPrinter printer(CcTest::isolate()); printer.set_wrap(false); printer.set_test_function_name("f"); @@ -457,8 +445,7 @@ TEST(PropertyStores) { TEST(PropertyCall) { InitializedIgnitionHandleScope scope; - BytecodeExpectationsPrinter printer(CcTest::isolate(), - ConstantPoolType::kString); + BytecodeExpectationsPrinter printer(CcTest::isolate()); printer.set_wrap(false); printer.set_test_function_name("f"); @@ -485,8 +472,7 @@ TEST(PropertyCall) { TEST(LoadGlobal) { InitializedIgnitionHandleScope scope; - BytecodeExpectationsPrinter printer(CcTest::isolate(), - ConstantPoolType::kString); + BytecodeExpectationsPrinter printer(CcTest::isolate()); printer.set_wrap(false); printer.set_test_function_name("f"); @@ -518,8 +504,7 @@ TEST(LoadGlobal) { TEST(StoreGlobal) { InitializedIgnitionHandleScope scope; - BytecodeExpectationsPrinter printer(CcTest::isolate(), - ConstantPoolType::kString); + BytecodeExpectationsPrinter printer(CcTest::isolate()); printer.set_wrap(false); printer.set_test_function_name("f"); @@ -563,8 +548,7 @@ TEST(StoreGlobal) { TEST(CallGlobal) { InitializedIgnitionHandleScope scope; - BytecodeExpectationsPrinter printer(CcTest::isolate(), - ConstantPoolType::kString); + BytecodeExpectationsPrinter printer(CcTest::isolate()); printer.set_wrap(false); printer.set_test_function_name("f"); @@ -584,8 +568,7 @@ TEST(CallGlobal) { TEST(CallRuntime) { InitializedIgnitionHandleScope scope; - BytecodeExpectationsPrinter printer(CcTest::isolate(), - ConstantPoolType::kMixed); + BytecodeExpectationsPrinter printer(CcTest::isolate()); printer.set_wrap(false); printer.set_test_function_name("f"); @@ -609,8 +592,7 @@ TEST(CallRuntime) { TEST(IfConditions) { InitializedIgnitionHandleScope scope; - BytecodeExpectationsPrinter printer(CcTest::isolate(), - ConstantPoolType::kMixed); + BytecodeExpectationsPrinter printer(CcTest::isolate()); printer.set_wrap(false); printer.set_test_function_name("f"); @@ -724,11 +706,9 @@ TEST(IfConditions) { TEST(DeclareGlobals) { InitializedIgnitionHandleScope scope; - BytecodeExpectationsPrinter printer(CcTest::isolate(), - ConstantPoolType::kMixed); + BytecodeExpectationsPrinter printer(CcTest::isolate()); printer.set_wrap(false); printer.set_test_function_name("f"); - printer.set_execute(false); printer.set_top_level(true); const char* snippets[] = { @@ -749,8 +729,7 @@ TEST(DeclareGlobals) { TEST(BreakableBlocks) { InitializedIgnitionHandleScope scope; - BytecodeExpectationsPrinter printer(CcTest::isolate(), - ConstantPoolType::kMixed); + BytecodeExpectationsPrinter printer(CcTest::isolate()); const char* snippets[] = { "var x = 0;\n" @@ -796,8 +775,7 @@ TEST(BreakableBlocks) { TEST(BasicLoops) { InitializedIgnitionHandleScope scope; - BytecodeExpectationsPrinter printer(CcTest::isolate(), - ConstantPoolType::kMixed); + BytecodeExpectationsPrinter printer(CcTest::isolate()); const char* snippets[] = { "var x = 0;\n" "while (false) { x = 99; break; continue; }\n" @@ -950,8 +928,7 @@ TEST(BasicLoops) { TEST(JumpsRequiringConstantWideOperands) { InitializedIgnitionHandleScope scope; - BytecodeExpectationsPrinter printer(CcTest::isolate(), - ConstantPoolType::kNumber); + BytecodeExpectationsPrinter printer(CcTest::isolate()); const char* snippets[] = { REPEAT_256("var x = 0.1;\n") REPEAT_32("var x = 0.2;\n") @@ -970,8 +947,7 @@ TEST(JumpsRequiringConstantWideOperands) { TEST(UnaryOperators) { InitializedIgnitionHandleScope scope; - BytecodeExpectationsPrinter printer(CcTest::isolate(), - ConstantPoolType::kNumber); + BytecodeExpectationsPrinter printer(CcTest::isolate()); const char* snippets[] = { "var x = 0;\n" "while (x != 10) {\n" @@ -1008,8 +984,7 @@ TEST(UnaryOperators) { TEST(Typeof) { InitializedIgnitionHandleScope scope; - BytecodeExpectationsPrinter printer(CcTest::isolate(), - ConstantPoolType::kString); + BytecodeExpectationsPrinter printer(CcTest::isolate()); printer.set_wrap(false); printer.set_test_function_name("f"); @@ -1031,8 +1006,7 @@ TEST(Typeof) { TEST(Delete) { InitializedIgnitionHandleScope scope; - BytecodeExpectationsPrinter printer(CcTest::isolate(), - ConstantPoolType::kMixed); + BytecodeExpectationsPrinter printer(CcTest::isolate()); const char* snippets[] = { "var a = {x:13, y:14}; return delete a.x;\n", @@ -1057,8 +1031,7 @@ TEST(Delete) { TEST(GlobalDelete) { InitializedIgnitionHandleScope scope; - BytecodeExpectationsPrinter printer(CcTest::isolate(), - ConstantPoolType::kMixed); + BytecodeExpectationsPrinter printer(CcTest::isolate()); printer.set_wrap(false); printer.set_test_function_name("f"); @@ -1095,8 +1068,7 @@ TEST(GlobalDelete) { TEST(FunctionLiterals) { InitializedIgnitionHandleScope scope; - BytecodeExpectationsPrinter printer(CcTest::isolate(), - ConstantPoolType::kMixed); + BytecodeExpectationsPrinter printer(CcTest::isolate()); const char* snippets[] = { "return function(){ }\n", @@ -1112,8 +1084,7 @@ TEST(FunctionLiterals) { TEST(RegExpLiterals) { InitializedIgnitionHandleScope scope; - BytecodeExpectationsPrinter printer(CcTest::isolate(), - ConstantPoolType::kString); + BytecodeExpectationsPrinter printer(CcTest::isolate()); const char* snippets[] = { "return /ab+d/;\n", @@ -1129,8 +1100,7 @@ TEST(RegExpLiterals) { TEST(RegExpLiteralsWide) { InitializedIgnitionHandleScope scope; - BytecodeExpectationsPrinter printer(CcTest::isolate(), - ConstantPoolType::kMixed); + BytecodeExpectationsPrinter printer(CcTest::isolate()); const char* snippets[] = { "var a;" // @@ -1144,8 +1114,7 @@ TEST(RegExpLiteralsWide) { TEST(ArrayLiterals) { InitializedIgnitionHandleScope scope; - BytecodeExpectationsPrinter printer(CcTest::isolate(), - ConstantPoolType::kMixed); + BytecodeExpectationsPrinter printer(CcTest::isolate()); const char* snippets[] = { "return [ 1, 2 ];\n", @@ -1163,8 +1132,7 @@ TEST(ArrayLiterals) { TEST(ArrayLiteralsWide) { InitializedIgnitionHandleScope scope; - BytecodeExpectationsPrinter printer(CcTest::isolate(), - ConstantPoolType::kMixed); + BytecodeExpectationsPrinter printer(CcTest::isolate()); const char* snippets[] = { "var a;" // @@ -1178,8 +1146,7 @@ TEST(ArrayLiteralsWide) { TEST(ObjectLiterals) { InitializedIgnitionHandleScope scope; - BytecodeExpectationsPrinter printer(CcTest::isolate(), - ConstantPoolType::kMixed); + BytecodeExpectationsPrinter printer(CcTest::isolate()); const char* snippets[] = { "return { };\n", @@ -1219,8 +1186,7 @@ TEST(ObjectLiterals) { TEST(ObjectLiteralsWide) { InitializedIgnitionHandleScope scope; - BytecodeExpectationsPrinter printer(CcTest::isolate(), - ConstantPoolType::kMixed); + BytecodeExpectationsPrinter printer(CcTest::isolate()); const char* snippets[] = { "var a;" // REPEAT_256("\na = 1.23;") // @@ -1233,11 +1199,9 @@ TEST(ObjectLiteralsWide) { TEST(TopLevelObjectLiterals) { InitializedIgnitionHandleScope scope; - BytecodeExpectationsPrinter printer(CcTest::isolate(), - ConstantPoolType::kMixed); + BytecodeExpectationsPrinter printer(CcTest::isolate()); printer.set_wrap(false); printer.set_test_function_name("f"); - printer.set_execute(false); printer.set_top_level(true); const char* snippets[] = { @@ -1250,8 +1214,7 @@ TEST(TopLevelObjectLiterals) { TEST(TryCatch) { InitializedIgnitionHandleScope scope; - BytecodeExpectationsPrinter printer(CcTest::isolate(), - ConstantPoolType::kString); + BytecodeExpectationsPrinter printer(CcTest::isolate()); const char* snippets[] = { "try { return 1; } catch(e) { return 2; }\n", @@ -1267,8 +1230,7 @@ TEST(TryCatch) { TEST(TryFinally) { InitializedIgnitionHandleScope scope; - BytecodeExpectationsPrinter printer(CcTest::isolate(), - ConstantPoolType::kString); + BytecodeExpectationsPrinter printer(CcTest::isolate()); const char* snippets[] = { "var a = 1;\n" "try { a = 2; } finally { a = 3; }\n", @@ -1287,8 +1249,7 @@ TEST(TryFinally) { TEST(Throw) { InitializedIgnitionHandleScope scope; - BytecodeExpectationsPrinter printer(CcTest::isolate(), - ConstantPoolType::kString); + BytecodeExpectationsPrinter printer(CcTest::isolate()); const char* snippets[] = { "throw 1;\n", @@ -1303,8 +1264,7 @@ TEST(Throw) { TEST(CallNew) { InitializedIgnitionHandleScope scope; - BytecodeExpectationsPrinter printer(CcTest::isolate(), - ConstantPoolType::kMixed); + BytecodeExpectationsPrinter printer(CcTest::isolate()); printer.set_wrap(false); printer.set_test_function_name("f"); @@ -1338,8 +1298,7 @@ TEST(ContextVariables) { STATIC_ASSERT(Context::MIN_CONTEXT_SLOTS + 3 + 249 == 256); InitializedIgnitionHandleScope scope; - BytecodeExpectationsPrinter printer(CcTest::isolate(), - ConstantPoolType::kMixed); + BytecodeExpectationsPrinter printer(CcTest::isolate()); const char* snippets[] = { "var a; return function() { a = 1; };\n", @@ -1354,7 +1313,7 @@ TEST(ContextVariables) { "{ let b = 2; return function() { a + b; }; }\n", "'use strict';\n" - REPEAT_249_UNIQUE_VARS() + REPEAT_250_UNIQUE_VARS() "eval();\n" "var b = 100;\n" "return b\n", @@ -1366,8 +1325,7 @@ TEST(ContextVariables) { TEST(ContextParameters) { InitializedIgnitionHandleScope scope; - BytecodeExpectationsPrinter printer(CcTest::isolate(), - ConstantPoolType::kMixed); + BytecodeExpectationsPrinter printer(CcTest::isolate()); printer.set_wrap(false); printer.set_test_function_name("f"); @@ -1387,8 +1345,7 @@ TEST(ContextParameters) { TEST(OuterContextVariables) { InitializedIgnitionHandleScope scope; - BytecodeExpectationsPrinter printer(CcTest::isolate(), - ConstantPoolType::kMixed); + BytecodeExpectationsPrinter printer(CcTest::isolate()); printer.set_wrap(false); printer.set_test_function_name("f"); @@ -1418,8 +1375,7 @@ TEST(OuterContextVariables) { TEST(CountOperators) { InitializedIgnitionHandleScope scope; - BytecodeExpectationsPrinter printer(CcTest::isolate(), - ConstantPoolType::kMixed); + BytecodeExpectationsPrinter printer(CcTest::isolate()); const char* snippets[] = { "var a = 1; return ++a;\n", @@ -1450,8 +1406,7 @@ TEST(CountOperators) { TEST(GlobalCountOperators) { InitializedIgnitionHandleScope scope; - BytecodeExpectationsPrinter printer(CcTest::isolate(), - ConstantPoolType::kString); + BytecodeExpectationsPrinter printer(CcTest::isolate()); printer.set_wrap(false); printer.set_test_function_name("f"); @@ -1479,8 +1434,7 @@ TEST(GlobalCountOperators) { TEST(CompoundExpressions) { InitializedIgnitionHandleScope scope; - BytecodeExpectationsPrinter printer(CcTest::isolate(), - ConstantPoolType::kMixed); + BytecodeExpectationsPrinter printer(CcTest::isolate()); const char* snippets[] = { "var a = 1; a += 2;\n", @@ -1499,8 +1453,7 @@ TEST(CompoundExpressions) { TEST(GlobalCompoundExpressions) { InitializedIgnitionHandleScope scope; - BytecodeExpectationsPrinter printer(CcTest::isolate(), - ConstantPoolType::kString); + BytecodeExpectationsPrinter printer(CcTest::isolate()); printer.set_wrap(false); printer.set_test_function_name("f"); @@ -1520,8 +1473,7 @@ TEST(GlobalCompoundExpressions) { TEST(CreateArguments) { InitializedIgnitionHandleScope scope; - BytecodeExpectationsPrinter printer(CcTest::isolate(), - ConstantPoolType::kString); + BytecodeExpectationsPrinter printer(CcTest::isolate()); printer.set_wrap(false); printer.set_test_function_name("f"); @@ -1545,8 +1497,7 @@ TEST(CreateArguments) { TEST(CreateRestParameter) { InitializedIgnitionHandleScope scope; - BytecodeExpectationsPrinter printer(CcTest::isolate(), - ConstantPoolType::kNumber); + BytecodeExpectationsPrinter printer(CcTest::isolate()); printer.set_wrap(false); printer.set_test_function_name("f"); @@ -1566,8 +1517,7 @@ TEST(CreateRestParameter) { TEST(ForIn) { InitializedIgnitionHandleScope scope; - BytecodeExpectationsPrinter printer(CcTest::isolate(), - ConstantPoolType::kMixed); + BytecodeExpectationsPrinter printer(CcTest::isolate()); const char* snippets[] = { "for (var p in null) {}\n", @@ -1597,8 +1547,7 @@ TEST(ForIn) { TEST(ForOf) { InitializedIgnitionHandleScope scope; - BytecodeExpectationsPrinter printer(CcTest::isolate(), - ConstantPoolType::kMixed); + BytecodeExpectationsPrinter printer(CcTest::isolate()); const char* snippets[] = { "for (var p of [0, 1, 2]) {}\n", @@ -1620,8 +1569,7 @@ TEST(ForOf) { TEST(Conditional) { InitializedIgnitionHandleScope scope; - BytecodeExpectationsPrinter printer(CcTest::isolate(), - ConstantPoolType::kNumber); + BytecodeExpectationsPrinter printer(CcTest::isolate()); const char* snippets[] = { "return 1 ? 2 : 3;\n", @@ -1639,8 +1587,7 @@ TEST(Conditional) { TEST(Switch) { InitializedIgnitionHandleScope scope; - BytecodeExpectationsPrinter printer(CcTest::isolate(), - ConstantPoolType::kNumber); + BytecodeExpectationsPrinter printer(CcTest::isolate()); const char* snippets[] = { "var a = 1;\n" "switch(a) {\n" @@ -1707,8 +1654,7 @@ TEST(Switch) { TEST(BasicBlockToBoolean) { InitializedIgnitionHandleScope scope; - BytecodeExpectationsPrinter printer(CcTest::isolate(), - ConstantPoolType::kNumber); + BytecodeExpectationsPrinter printer(CcTest::isolate()); const char* snippets[] = { "var a = 1; if (a || a < 0) { return 1; }\n", @@ -1723,8 +1669,7 @@ TEST(BasicBlockToBoolean) { TEST(DeadCodeRemoval) { InitializedIgnitionHandleScope scope; - BytecodeExpectationsPrinter printer(CcTest::isolate(), - ConstantPoolType::kNumber); + BytecodeExpectationsPrinter printer(CcTest::isolate()); const char* snippets[] = { "return; var a = 1; a();\n", @@ -1741,8 +1686,7 @@ TEST(DeadCodeRemoval) { TEST(ThisFunction) { InitializedIgnitionHandleScope scope; - BytecodeExpectationsPrinter printer(CcTest::isolate(), - ConstantPoolType::kNumber); + BytecodeExpectationsPrinter printer(CcTest::isolate()); printer.set_wrap(false); printer.set_test_function_name("f"); @@ -1760,8 +1704,7 @@ TEST(ThisFunction) { TEST(NewTarget) { InitializedIgnitionHandleScope scope; - BytecodeExpectationsPrinter printer(CcTest::isolate(), - ConstantPoolType::kMixed); + BytecodeExpectationsPrinter printer(CcTest::isolate()); const char* snippets[] = { "return new.target;\n", @@ -1775,8 +1718,7 @@ TEST(NewTarget) { TEST(RemoveRedundantLdar) { InitializedIgnitionHandleScope scope; - BytecodeExpectationsPrinter printer(CcTest::isolate(), - ConstantPoolType::kNumber); + BytecodeExpectationsPrinter printer(CcTest::isolate()); const char* snippets[] = { "var ld_a = 1;\n" // This test is to check Ldar does not "while(true) {\n" // get removed if the preceding Star is @@ -1803,8 +1745,7 @@ TEST(RemoveRedundantLdar) { TEST(AssignmentsInBinaryExpression) { InitializedIgnitionHandleScope scope; - BytecodeExpectationsPrinter printer(CcTest::isolate(), - ConstantPoolType::kString); + BytecodeExpectationsPrinter printer(CcTest::isolate()); const char* snippets[] = { "var x = 0, y = 1;\n" "return (x = 2, y = 3, x = 4, y = 5);\n", @@ -1844,8 +1785,7 @@ TEST(AssignmentsInBinaryExpression) { TEST(Eval) { InitializedIgnitionHandleScope scope; - BytecodeExpectationsPrinter printer(CcTest::isolate(), - ConstantPoolType::kString); + BytecodeExpectationsPrinter printer(CcTest::isolate()); const char* snippets[] = { "return eval('1;');\n", }; @@ -1856,16 +1796,32 @@ TEST(Eval) { TEST(LookupSlot) { InitializedIgnitionHandleScope scope; - BytecodeExpectationsPrinter printer(CcTest::isolate(), - ConstantPoolType::kString); + BytecodeExpectationsPrinter printer(CcTest::isolate()); + printer.set_test_function_name("f"); + // clang-format off const char* snippets[] = { "eval('var x = 10;'); return x;\n", "eval('var x = 10;'); return typeof x;\n", "x = 20; return eval('');\n", + + "var x = 20;\n" + "f = function(){\n" + " eval('var x = 10');\n" + " return x;\n" + "}\n" + "f();\n", + + "x = 20;\n" + "f = function(){\n" + " eval('var x = 10');\n" + " return x;\n" + "}\n" + "f();\n" }; + // clang-format on CHECK(CompareTexts(BuildActual(printer, snippets), LoadGolden("LookupSlot.golden"))); @@ -1873,8 +1829,7 @@ TEST(LookupSlot) { TEST(CallLookupSlot) { InitializedIgnitionHandleScope scope; - BytecodeExpectationsPrinter printer(CcTest::isolate(), - ConstantPoolType::kMixed); + BytecodeExpectationsPrinter printer(CcTest::isolate()); const char* snippets[] = { "g = function(){}; eval(''); return g();\n", }; @@ -1887,8 +1842,7 @@ TEST(CallLookupSlot) { TEST(LookupSlotInEval) { InitializedIgnitionHandleScope scope; - BytecodeExpectationsPrinter printer(CcTest::isolate(), - ConstantPoolType::kString); + BytecodeExpectationsPrinter printer(CcTest::isolate()); printer.set_wrap(false); printer.set_test_function_name("f"); @@ -1917,8 +1871,7 @@ TEST(LookupSlotInEval) { TEST(LookupSlotWideInEval) { InitializedIgnitionHandleScope scope; - BytecodeExpectationsPrinter printer(CcTest::isolate(), - ConstantPoolType::kMixed); + BytecodeExpectationsPrinter printer(CcTest::isolate()); printer.set_wrap(false); printer.set_test_function_name("f"); @@ -1953,8 +1906,7 @@ TEST(LookupSlotWideInEval) { TEST(DeleteLookupSlotInEval) { InitializedIgnitionHandleScope scope; - BytecodeExpectationsPrinter printer(CcTest::isolate(), - ConstantPoolType::kString); + BytecodeExpectationsPrinter printer(CcTest::isolate()); printer.set_wrap(false); printer.set_test_function_name("f"); @@ -1990,8 +1942,7 @@ TEST(WideRegisters) { std::string prologue(os.str()); InitializedIgnitionHandleScope scope; - BytecodeExpectationsPrinter printer(CcTest::isolate(), - ConstantPoolType::kNumber); + BytecodeExpectationsPrinter printer(CcTest::isolate()); const char* snippets[] = { "x0 = x127;\n" "return x0;\n", @@ -2033,8 +1984,7 @@ TEST(WideRegisters) { TEST(ConstVariable) { InitializedIgnitionHandleScope scope; - BytecodeExpectationsPrinter printer(CcTest::isolate(), - ConstantPoolType::kString); + BytecodeExpectationsPrinter printer(CcTest::isolate()); const char* snippets[] = { "const x = 10;\n", @@ -2051,8 +2001,7 @@ TEST(ConstVariable) { TEST(LetVariable) { InitializedIgnitionHandleScope scope; - BytecodeExpectationsPrinter printer(CcTest::isolate(), - ConstantPoolType::kString); + BytecodeExpectationsPrinter printer(CcTest::isolate()); const char* snippets[] = { "let x = 10;\n", @@ -2071,8 +2020,7 @@ TEST(ConstVariableContextSlot) { // TODO(mythria): Add tests for initialization of this via super calls. // TODO(mythria): Add tests that walk the context chain. InitializedIgnitionHandleScope scope; - BytecodeExpectationsPrinter printer(CcTest::isolate(), - ConstantPoolType::kMixed); + BytecodeExpectationsPrinter printer(CcTest::isolate()); const char* snippets[] = { "const x = 10; function f1() {return x;}\n", @@ -2089,8 +2037,7 @@ TEST(ConstVariableContextSlot) { TEST(LetVariableContextSlot) { InitializedIgnitionHandleScope scope; - BytecodeExpectationsPrinter printer(CcTest::isolate(), - ConstantPoolType::kMixed); + BytecodeExpectationsPrinter printer(CcTest::isolate()); const char* snippets[] = { "let x = 10; function f1() {return x;}\n", @@ -2110,8 +2057,7 @@ TEST(DoExpression) { FLAG_harmony_do_expressions = true; InitializedIgnitionHandleScope scope; - BytecodeExpectationsPrinter printer(CcTest::isolate(), - ConstantPoolType::kString); + BytecodeExpectationsPrinter printer(CcTest::isolate()); const char* snippets[] = { "var a = do { }; return a;\n", @@ -2128,8 +2074,7 @@ TEST(DoExpression) { TEST(WithStatement) { InitializedIgnitionHandleScope scope; - BytecodeExpectationsPrinter printer(CcTest::isolate(), - ConstantPoolType::kMixed); + BytecodeExpectationsPrinter printer(CcTest::isolate()); const char* snippets[] = { "with ({x:42}) { return x; }\n", }; @@ -2140,8 +2085,7 @@ TEST(WithStatement) { TEST(DoDebugger) { InitializedIgnitionHandleScope scope; - BytecodeExpectationsPrinter printer(CcTest::isolate(), - ConstantPoolType::kString); + BytecodeExpectationsPrinter printer(CcTest::isolate()); const char* snippets[] = { "debugger;\n", }; @@ -2152,8 +2096,7 @@ TEST(DoDebugger) { TEST(ClassDeclarations) { InitializedIgnitionHandleScope scope; - BytecodeExpectationsPrinter printer(CcTest::isolate(), - ConstantPoolType::kMixed); + BytecodeExpectationsPrinter printer(CcTest::isolate()); const char* snippets[] = { "class Person {\n" " constructor(name) { this.name = name; }\n" @@ -2183,8 +2126,7 @@ TEST(ClassDeclarations) { TEST(ClassAndSuperClass) { InitializedIgnitionHandleScope scope; - BytecodeExpectationsPrinter printer(CcTest::isolate(), - ConstantPoolType::kMixed); + BytecodeExpectationsPrinter printer(CcTest::isolate()); printer.set_wrap(false); printer.set_test_function_name("test"); const char* snippets[] = { @@ -2242,8 +2184,7 @@ TEST(ClassAndSuperClass) { TEST(Generators) { InitializedIgnitionHandleScope scope; - BytecodeExpectationsPrinter printer(CcTest::isolate(), - ConstantPoolType::kMixed); + BytecodeExpectationsPrinter printer(CcTest::isolate()); printer.set_wrap(false); printer.set_test_function_name("f"); @@ -2262,6 +2203,47 @@ TEST(Generators) { LoadGolden("Generators.golden"))); } +TEST(Modules) { + InitializedIgnitionHandleScope scope; + BytecodeExpectationsPrinter printer(CcTest::isolate()); + printer.set_wrap(false); + printer.set_module(true); + printer.set_top_level(true); + + const char* snippets[] = { + "import \"bar\";\n", + + "import {foo} from \"bar\";\n", + + "import {foo as goo} from \"bar\";\n" + "goo(42);\n" + "{ let x; { goo(42) } };\n", + + "export var foo = 42;\n" + "foo++;\n" + "{ let x; { foo++ } };\n", + + "export let foo = 42;\n" + "foo++;\n" + "{ let x; { foo++ } };\n", + + "export const foo = 42;\n" + "foo++;\n" + "{ let x; { foo++ } };\n", + + "export default (function () {});\n", + + "export default (class {});\n", + + "export {foo as goo} from \"bar\"\n", + + "export * from \"bar\"\n", + }; + + CHECK(CompareTexts(BuildActual(printer, snippets), + LoadGolden("Modules.golden"))); +} + } // namespace interpreter } // namespace internal } // namespace v8 |