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 "src/v8.h" | 5 #include "src/v8.h" |
6 | 6 |
7 #include "src/compiler/pipeline.h" | 7 #include "src/compiler/pipeline.h" |
8 #include "src/handles.h" | 8 #include "src/handles.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 10 matching lines...) Expand all Loading... |
21 explicit BytecodeFrameInfo(int locals_count = -1) | 21 explicit BytecodeFrameInfo(int locals_count = -1) |
22 : number_of_locals(locals_count) {} | 22 : number_of_locals(locals_count) {} |
23 | 23 |
24 int number_of_locals; | 24 int number_of_locals; |
25 }; | 25 }; |
26 | 26 |
27 class OptimizedBytecodeSourcePositionTester final { | 27 class OptimizedBytecodeSourcePositionTester final { |
28 public: | 28 public: |
29 explicit OptimizedBytecodeSourcePositionTester(Isolate* isolate) | 29 explicit OptimizedBytecodeSourcePositionTester(Isolate* isolate) |
30 : isolate_(isolate) { | 30 : isolate_(isolate) { |
31 optimization_flags_ = {&FLAG_ignition_peephole, &FLAG_ignition_reo}; | 31 optimization_flags_ = {&FLAG_ignition_filter_positions, |
| 32 &FLAG_ignition_peephole, &FLAG_ignition_reo}; |
32 SaveFlags(); | 33 SaveFlags(); |
33 } | 34 } |
34 ~OptimizedBytecodeSourcePositionTester() { RestoreFlags(); } | 35 ~OptimizedBytecodeSourcePositionTester() { RestoreFlags(); } |
35 | 36 |
36 bool SourcePositionsMatch(const char* function_body, | 37 bool SourcePositionsMatch(const char* function_body, |
37 const char* function_decl_params = "", | 38 const char* function_decl_params = "", |
38 const char* function_args = ""); | 39 const char* function_args = ""); |
39 | 40 |
40 private: | 41 private: |
41 Handle<BytecodeArray> MakeBytecode(size_t optimization_flags, | 42 Handle<BytecodeArray> MakeBytecode(size_t optimization_flags, |
(...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
233 | 234 |
234 "while (x == 4) {\n" | 235 "while (x == 4) {\n" |
235 " var y = x + 1;\n" | 236 " var y = x + 1;\n" |
236 " if (y == 2) break;\n" | 237 " if (y == 2) break;\n" |
237 " for (z['a'] of [0]) {\n" | 238 " for (z['a'] of [0]) {\n" |
238 " x += (x *= 3) + y;" | 239 " x += (x *= 3) + y;" |
239 " }\n" | 240 " }\n" |
240 "}\n", | 241 "}\n", |
241 | 242 |
242 "function g(a, b) { return a.func(b + b, b); }\n" | 243 "function g(a, b) { return a.func(b + b, b); }\n" |
243 "g(new (function Obj() { this.func = function() { return; }})(), 1)\n"}; | 244 "g(new (function Obj() { this.func = function() { return; }})(), 1)\n", |
| 245 |
| 246 "var x = 55;\n" |
| 247 "var y = x + (x = 1) + (x = 2) + (x = 3);\n" |
| 248 "return y;\n", |
| 249 |
| 250 "var x = 55;\n" |
| 251 "var y = x + (x = 1) + (x = 2) + (x = 3);\n" |
| 252 "return y;\n", |
| 253 }; |
244 | 254 |
245 OptimizedBytecodeSourcePositionTester tester(handles.main_isolate()); | 255 OptimizedBytecodeSourcePositionTester tester(handles.main_isolate()); |
246 for (size_t i = 0; i < arraysize(test_scripts); ++i) { | 256 for (size_t i = 0; i < arraysize(test_scripts); ++i) { |
247 CHECK(tester.SourcePositionsMatch(test_scripts[i])); | 257 CHECK(tester.SourcePositionsMatch(test_scripts[i])); |
248 } | 258 } |
| 259 |
| 260 CHECK( |
| 261 tester.SourcePositionsMatch("return some_global[name];", "name", "'a'")); |
249 } | 262 } |
250 | 263 |
251 } // namespace interpreter | 264 } // namespace interpreter |
252 } // namespace internal | 265 } // namespace internal |
253 } // namespace v8 | 266 } // namespace v8 |
OLD | NEW |