OLD | NEW |
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 <utility> | 5 #include <utility> |
6 | 6 |
7 #include "src/compiler/pipeline.h" | 7 #include "src/compiler/pipeline.h" |
8 #include "src/execution.h" | 8 #include "src/execution.h" |
9 #include "src/handles.h" | 9 #include "src/handles.h" |
10 #include "src/interpreter/bytecode-array-builder.h" | 10 #include "src/interpreter/bytecode-array-builder.h" |
(...skipping 2614 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2625 | 2625 |
2626 BytecodeGraphTester tester(isolate, zone, script.start()); | 2626 BytecodeGraphTester tester(isolate, zone, script.start()); |
2627 auto callable = tester.GetCallable<>(); | 2627 auto callable = tester.GetCallable<>(); |
2628 Handle<Object> return_value = callable().ToHandleChecked(); | 2628 Handle<Object> return_value = callable().ToHandleChecked(); |
2629 CHECK(return_value->SameValue(*snippets[i].return_value())); | 2629 CHECK(return_value->SameValue(*snippets[i].return_value())); |
2630 } | 2630 } |
2631 | 2631 |
2632 FLAG_harmony_do_expressions = old_flag; | 2632 FLAG_harmony_do_expressions = old_flag; |
2633 } | 2633 } |
2634 | 2634 |
| 2635 TEST(BytecodeGraphBuilderWithStatement) { |
| 2636 HandleAndZoneScope scope; |
| 2637 Isolate* isolate = scope.main_isolate(); |
| 2638 Zone* zone = scope.main_zone(); |
| 2639 |
| 2640 ExpectedSnippet<0> snippets[] = { |
| 2641 {"with({x:42}) return x;", {handle(Smi::FromInt(42), isolate)}}, |
| 2642 {"with({}) { var y = 10; return y;}", |
| 2643 {handle(Smi::FromInt(10), isolate)}}, |
| 2644 {"var y = {x:42};" |
| 2645 " function inner() {" |
| 2646 " var x = 20;" |
| 2647 " with(y) return x;" |
| 2648 "}" |
| 2649 "return inner();", |
| 2650 {handle(Smi::FromInt(42), isolate)}}, |
| 2651 {"var y = {x:42};" |
| 2652 " function inner(o) {" |
| 2653 " var x = 20;" |
| 2654 " with(o) return x;" |
| 2655 "}" |
| 2656 "return inner(y);", |
| 2657 {handle(Smi::FromInt(42), isolate)}}, |
| 2658 }; |
| 2659 |
| 2660 for (size_t i = 0; i < arraysize(snippets); i++) { |
| 2661 ScopedVector<char> script(1024); |
| 2662 SNPrintF(script, "function %s() { %s }\n%s();", kFunctionName, |
| 2663 snippets[i].code_snippet, kFunctionName); |
| 2664 |
| 2665 BytecodeGraphTester tester(isolate, zone, script.start()); |
| 2666 auto callable = tester.GetCallable<>(); |
| 2667 Handle<Object> return_value = callable().ToHandleChecked(); |
| 2668 CHECK(return_value->SameValue(*snippets[i].return_value())); |
| 2669 } |
| 2670 } |
| 2671 |
2635 } // namespace compiler | 2672 } // namespace compiler |
2636 } // namespace internal | 2673 } // namespace internal |
2637 } // namespace v8 | 2674 } // namespace v8 |
OLD | NEW |