| 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 "test/cctest/interpreter/interpreter-tester.h" | 5 #include "test/cctest/interpreter/interpreter-tester.h" |
| 6 | 6 |
| 7 namespace v8 { | 7 namespace v8 { |
| 8 namespace internal { | 8 namespace internal { |
| 9 namespace interpreter { | 9 namespace interpreter { |
| 10 | 10 |
| 11 MaybeHandle<Object> CallInterpreter(Isolate* isolate, | 11 MaybeHandle<Object> CallInterpreter(Isolate* isolate, |
| 12 Handle<JSFunction> function) { | 12 Handle<JSFunction> function) { |
| 13 return Execution::Call(isolate, function, | 13 return Execution::Call(isolate, function, |
| 14 isolate->factory()->undefined_value(), 0, nullptr); | 14 isolate->factory()->undefined_value(), 0, nullptr); |
| 15 } | 15 } |
| 16 | 16 |
| 17 InterpreterTester::InterpreterTester( | 17 InterpreterTester::InterpreterTester( |
| 18 Isolate* isolate, const char* source, MaybeHandle<BytecodeArray> bytecode, | 18 Isolate* isolate, const char* source, MaybeHandle<BytecodeArray> bytecode, |
| 19 MaybeHandle<TypeFeedbackVector> feedback_vector, const char* filter) | 19 MaybeHandle<TypeFeedbackVector> feedback_vector, const char* filter) |
| 20 : isolate_(isolate), | 20 : isolate_(isolate), |
| 21 source_(source), | 21 source_(source), |
| 22 bytecode_(bytecode), | 22 bytecode_(bytecode), |
| 23 feedback_vector_(feedback_vector) { | 23 feedback_vector_(feedback_vector) { |
| 24 i::FLAG_ignition = true; | 24 i::FLAG_ignition = true; |
| 25 i::FLAG_always_opt = false; | 25 i::FLAG_always_opt = false; |
| 26 // Set ignition filter flag via SetFlagsFromString to avoid double-free | |
| 27 // (or potential leak with StrDup() based on ownership confusion). | |
| 28 ScopedVector<char> ignition_filter(64); | |
| 29 SNPrintF(ignition_filter, "--ignition-filter=%s", filter); | |
| 30 FlagList::SetFlagsFromString(ignition_filter.start(), | |
| 31 ignition_filter.length()); | |
| 32 // Ensure handler table is generated. | 26 // Ensure handler table is generated. |
| 33 isolate->interpreter()->Initialize(); | 27 isolate->interpreter()->Initialize(); |
| 34 } | 28 } |
| 35 | 29 |
| 36 InterpreterTester::InterpreterTester( | 30 InterpreterTester::InterpreterTester( |
| 37 Isolate* isolate, Handle<BytecodeArray> bytecode, | 31 Isolate* isolate, Handle<BytecodeArray> bytecode, |
| 38 MaybeHandle<TypeFeedbackVector> feedback_vector, const char* filter) | 32 MaybeHandle<TypeFeedbackVector> feedback_vector, const char* filter) |
| 39 : InterpreterTester(isolate, nullptr, bytecode, feedback_vector, filter) {} | 33 : InterpreterTester(isolate, nullptr, bytecode, feedback_vector, filter) {} |
| 40 | 34 |
| 41 InterpreterTester::InterpreterTester(Isolate* isolate, const char* source, | 35 InterpreterTester::InterpreterTester(Isolate* isolate, const char* source, |
| (...skipping 28 matching lines...) Expand all Loading... |
| 70 return "function " + function_name() + "() {\n" + std::string(body) + "\n}"; | 64 return "function " + function_name() + "() {\n" + std::string(body) + "\n}"; |
| 71 } | 65 } |
| 72 | 66 |
| 73 std::string InterpreterTester::function_name() { | 67 std::string InterpreterTester::function_name() { |
| 74 return std::string(kFunctionName); | 68 return std::string(kFunctionName); |
| 75 } | 69 } |
| 76 | 70 |
| 77 } // namespace interpreter | 71 } // namespace interpreter |
| 78 } // namespace internal | 72 } // namespace internal |
| 79 } // namespace v8 | 73 } // namespace v8 |
| OLD | NEW |