Chromium Code Reviews| 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 cadd4363857a833930b88fe98a40904f0d38d06c..d0892cf1403d1eddf533aadb384c5bdca765751d 100644 |
| --- a/test/cctest/compiler/test-run-bytecode-graph-builder.cc |
| +++ b/test/cctest/compiler/test-run-bytecode-graph-builder.cc |
| @@ -15,6 +15,7 @@ |
| #include "src/parser.h" |
| #include "test/cctest/cctest.h" |
| + |
|
rmcilroy
2015/11/09 15:23:00
nit - remove extra newline
mythria
2015/11/10 09:55:35
Done.
|
| namespace v8 { |
| namespace internal { |
| namespace compiler { |
| @@ -81,6 +82,10 @@ class BytecodeGraphTester { |
| return BytecodeGraphCallable<A...>(isolate_, GetFunction()); |
| } |
| + static Handle<Object> NewObject(const char* script) { |
| + return v8::Utils::OpenHandle(*CompileRun(script)); |
| + } |
| + |
| private: |
| Isolate* isolate_; |
| Zone* zone_; |
| @@ -100,8 +105,8 @@ class BytecodeGraphTester { |
| CompilationInfo compilation_info(&parse_info); |
| compilation_info.SetOptimizing(BailoutId::None(), Handle<Code>()); |
| - Parser parser(&parse_info); |
| - CHECK(parser.Parse(&parse_info)); |
| + // TODO(mythria): Remove this step once parse_info is not needed. |
| + CHECK(Compiler::ParseAndAnalyze(&parse_info)); |
| compiler::Pipeline pipeline(&compilation_info); |
| Handle<Code> code = pipeline.GenerateCode(); |
| function->ReplaceCode(*code); |
| @@ -113,6 +118,36 @@ class BytecodeGraphTester { |
| }; |
| +#define SPACE() |
| + |
| +#define REPEAT_2(SEP, ...) __VA_ARGS__ SEP() __VA_ARGS__ |
| +#define REPEAT_4(SEP, ...) \ |
| + REPEAT_2(SEP, __VA_ARGS__) SEP() REPEAT_2(SEP, __VA_ARGS__) |
| +#define REPEAT_8(SEP, ...) \ |
| + REPEAT_4(SEP, __VA_ARGS__) SEP() REPEAT_4(SEP, __VA_ARGS__) |
| +#define REPEAT_16(SEP, ...) \ |
| + REPEAT_8(SEP, __VA_ARGS__) SEP() REPEAT_8(SEP, __VA_ARGS__) |
| +#define REPEAT_32(SEP, ...) \ |
| + REPEAT_16(SEP, __VA_ARGS__) SEP() REPEAT_16(SEP, __VA_ARGS__) |
| +#define REPEAT_64(SEP, ...) \ |
| + REPEAT_32(SEP, __VA_ARGS__) SEP() REPEAT_32(SEP, __VA_ARGS__) |
| +#define REPEAT_128(SEP, ...) \ |
| + REPEAT_64(SEP, __VA_ARGS__) SEP() REPEAT_64(SEP, __VA_ARGS__) |
| +#define REPEAT_256(SEP, ...) \ |
| + REPEAT_128(SEP, __VA_ARGS__) SEP() REPEAT_128(SEP, __VA_ARGS__) |
| + |
| +#define REPEAT_127(SEP, ...) \ |
| + REPEAT_64(SEP, __VA_ARGS__) \ |
| + SEP() \ |
| + REPEAT_32(SEP, __VA_ARGS__) \ |
| + SEP() \ |
| + REPEAT_16(SEP, __VA_ARGS__) \ |
| + SEP() \ |
| + REPEAT_8(SEP, __VA_ARGS__) \ |
| + SEP() \ |
| + REPEAT_4(SEP, __VA_ARGS__) SEP() REPEAT_2(SEP, __VA_ARGS__) SEP() __VA_ARGS__ |
|
rmcilroy
2015/11/09 15:23:00
These are all unused in this test now, right? If s
mythria
2015/11/10 09:55:35
I use them for testing LoadICS in wide mode in tes
rmcilroy
2015/11/10 11:23:19
You're right, missed this.
|
| + |
| + |
| template <int N> |
| struct ExpectedSnippet { |
| const char* code_snippet; |
| @@ -254,6 +289,49 @@ TEST(BytecodeGraphBuilderTwoParameterTests) { |
| } |
| } |
| + |
| +TEST(BytecodeGraphBuilderNamedLoad) { |
| + HandleAndZoneScope scope; |
| + Isolate* isolate = scope.main_isolate(); |
| + Zone* zone = scope.main_zone(); |
| + Factory* factory = isolate->factory(); |
| + |
| + ExpectedSnippet<1> snippets[] = { |
| + {"return p1.val;", |
| + {factory->NewNumberFromInt(10), |
| + BytecodeGraphTester::NewObject("({ val : 10})")}}, |
| + {"return p1[\"name\"];", |
| + {factory->NewStringFromStaticChars("abc"), |
| + BytecodeGraphTester::NewObject("({ name : 'abc'})")}}, |
| + {"'use strict'; return p1.val;", |
| + {factory->NewNumberFromInt(10), |
| + BytecodeGraphTester::NewObject("({ val : 10 })")}}, |
| + {"'use strict'; return p1[\"val\"];", |
| + {factory->NewNumberFromInt(10), |
| + BytecodeGraphTester::NewObject("({ val : 10, name : 'abc'})")}}, |
| + {"var b;\n" REPEAT_127(SPACE, " b = p1.name; ") " return p1.name;\n", |
| + {factory->NewStringFromStaticChars("abc"), |
| + BytecodeGraphTester::NewObject("({ name : 'abc'})")}}, |
| + {" 'use strict'; var b;\n" REPEAT_127( |
| + SPACE, " b = p1.name; ") " return p1.name;\n", |
| + {factory->NewStringFromStaticChars("abc"), |
| + BytecodeGraphTester::NewObject("({ name : 'abc'})")}}, |
| + }; |
| + |
| + size_t num_snippets = sizeof(snippets) / sizeof(snippets[0]); |
| + for (size_t i = 0; i < num_snippets; i++) { |
| + ScopedVector<char> script(2048); |
| + SNPrintF(script, "function %s(p1) { %s };\n%s(0);", kFunctionName, |
| + snippets[i].code_snippet, kFunctionName); |
| + |
| + BytecodeGraphTester tester(isolate, zone, script.start()); |
| + auto callable = tester.GetCallable<Handle<Object>>(); |
| + Handle<Object> return_value = |
| + callable(snippets[i].parameter(0)).ToHandleChecked(); |
| + CHECK(return_value->SameValue(*snippets[i].return_value())); |
| + } |
| +} |
| + |
| } // namespace compiler |
| } // namespace internal |
| } // namespace v8 |