| OLD | NEW |
| 1 // Copyright 2014 the V8 project authors. All rights reserved. | 1 // Copyright 2014 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 #ifndef V8_CCTEST_COMPILER_FUNCTION_TESTER_H_ | 5 #ifndef V8_CCTEST_COMPILER_FUNCTION_TESTER_H_ |
| 6 #define V8_CCTEST_COMPILER_FUNCTION_TESTER_H_ | 6 #define V8_CCTEST_COMPILER_FUNCTION_TESTER_H_ |
| 7 | 7 |
| 8 #include "src/v8.h" | 8 #include "src/v8.h" |
| 9 #include "test/cctest/cctest.h" | 9 #include "test/cctest/cctest.h" |
| 10 | 10 |
| 11 #include "src/compiler.h" | 11 #include "src/compiler.h" |
| 12 #include "src/compiler/pipeline.h" | 12 #include "src/compiler/pipeline.h" |
| 13 #include "src/execution.h" | 13 #include "src/execution.h" |
| 14 #include "src/full-codegen.h" | 14 #include "src/full-codegen.h" |
| 15 #include "src/handles.h" | 15 #include "src/handles.h" |
| 16 #include "src/objects-inl.h" | 16 #include "src/objects-inl.h" |
| 17 #include "src/parser.h" | 17 #include "src/parser.h" |
| 18 #include "src/rewriter.h" | 18 #include "src/rewriter.h" |
| 19 #include "src/scopes.h" | 19 #include "src/scopes.h" |
| 20 | 20 |
| 21 #define USE_CRANKSHAFT 0 | 21 #define USE_CRANKSHAFT 0 |
| 22 | 22 |
| 23 namespace v8 { | 23 namespace v8 { |
| 24 namespace internal { | 24 namespace internal { |
| 25 namespace compiler { | 25 namespace compiler { |
| 26 | 26 |
| 27 class FunctionTester : public InitializedHandleScope { | 27 class FunctionTester : public InitializedHandleScope { |
| 28 public: | 28 public: |
| 29 explicit FunctionTester(const char* source, bool context_specialization = | 29 explicit FunctionTester(const char* source, bool context_specialization = |
| 30 FLAG_context_specialization) | 30 FLAG_context_specialization, |
| 31 bool inlining = FLAG_turbo_inlining) |
| 31 : isolate(main_isolate()), | 32 : isolate(main_isolate()), |
| 32 function((FLAG_allow_natives_syntax = true, NewFunction(source))), | 33 function((FLAG_allow_natives_syntax = true, NewFunction(source))), |
| 33 context_specialization_(context_specialization) { | 34 context_specialization_(context_specialization), |
| 35 inlining_(inlining) { |
| 34 Compile(function); | 36 Compile(function); |
| 35 USE(context_specialization_); | 37 USE(context_specialization_); |
| 38 USE(inlining_); |
| 36 } | 39 } |
| 37 | 40 |
| 38 Isolate* isolate; | 41 Isolate* isolate; |
| 39 Handle<JSFunction> function; | 42 Handle<JSFunction> function; |
| 40 | 43 |
| 41 Handle<JSFunction> Compile(Handle<JSFunction> function) { | 44 Handle<JSFunction> Compile(Handle<JSFunction> function) { |
| 42 #if V8_TURBOFAN_TARGET | 45 #if V8_TURBOFAN_TARGET |
| 43 CompilationInfoWithZone info(function); | 46 CompilationInfoWithZone info(function); |
| 44 | 47 |
| 45 CHECK(Parser::Parse(&info)); | 48 CHECK(Parser::Parse(&info)); |
| 46 StrictMode strict_mode = info.function()->strict_mode(); | 49 StrictMode strict_mode = info.function()->strict_mode(); |
| 47 info.SetStrictMode(strict_mode); | 50 info.SetStrictMode(strict_mode); |
| 48 info.SetOptimizing(BailoutId::None(), Handle<Code>(function->code())); | 51 info.SetOptimizing(BailoutId::None(), Handle<Code>(function->code())); |
| 49 CHECK(Rewriter::Rewrite(&info)); | 52 CHECK(Rewriter::Rewrite(&info)); |
| 50 CHECK(Scope::Analyze(&info)); | 53 CHECK(Scope::Analyze(&info)); |
| 51 CHECK_NE(NULL, info.scope()); | 54 CHECK_NE(NULL, info.scope()); |
| 52 Handle<ScopeInfo> scope_info = ScopeInfo::Create(info.scope(), info.zone()); | 55 Handle<ScopeInfo> scope_info = ScopeInfo::Create(info.scope(), info.zone()); |
| 53 info.shared_info()->set_scope_info(*scope_info); | 56 info.shared_info()->set_scope_info(*scope_info); |
| 54 | 57 |
| 55 EnsureDeoptimizationSupport(&info); | 58 EnsureDeoptimizationSupport(&info); |
| 56 | 59 |
| 57 Pipeline pipeline(&info); | 60 Pipeline pipeline(&info); |
| 58 pipeline.set_context_specialization(context_specialization_); | 61 pipeline.set_context_specialization(context_specialization_); |
| 62 pipeline.set_inlining(inlining_); |
| 59 Handle<Code> code = pipeline.GenerateCode(); | 63 Handle<Code> code = pipeline.GenerateCode(); |
| 60 | 64 |
| 61 CHECK(!code.is_null()); | 65 CHECK(!code.is_null()); |
| 62 function->ReplaceCode(*code); | 66 function->ReplaceCode(*code); |
| 63 #elif USE_CRANKSHAFT | 67 #elif USE_CRANKSHAFT |
| 64 Handle<Code> unoptimized = Handle<Code>(function->code()); | 68 Handle<Code> unoptimized = Handle<Code>(function->code()); |
| 65 Handle<Code> code = Compiler::GetOptimizedCode(function, unoptimized, | 69 Handle<Code> code = Compiler::GetOptimizedCode(function, unoptimized, |
| 66 Compiler::NOT_CONCURRENT); | 70 Compiler::NOT_CONCURRENT); |
| 67 CHECK(!code.is_null()); | 71 CHECK(!code.is_null()); |
| 68 #if ENABLE_DISASSEMBLER | 72 #if ENABLE_DISASSEMBLER |
| (...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 188 Handle<Object> undefined() { return isolate->factory()->undefined_value(); } | 192 Handle<Object> undefined() { return isolate->factory()->undefined_value(); } |
| 189 | 193 |
| 190 Handle<Object> null() { return isolate->factory()->null_value(); } | 194 Handle<Object> null() { return isolate->factory()->null_value(); } |
| 191 | 195 |
| 192 Handle<Object> true_value() { return isolate->factory()->true_value(); } | 196 Handle<Object> true_value() { return isolate->factory()->true_value(); } |
| 193 | 197 |
| 194 Handle<Object> false_value() { return isolate->factory()->false_value(); } | 198 Handle<Object> false_value() { return isolate->factory()->false_value(); } |
| 195 | 199 |
| 196 private: | 200 private: |
| 197 bool context_specialization_; | 201 bool context_specialization_; |
| 202 bool inlining_; |
| 198 }; | 203 }; |
| 199 } | 204 } |
| 200 } | 205 } |
| 201 } // namespace v8::internal::compiler | 206 } // namespace v8::internal::compiler |
| 202 | 207 |
| 203 #endif // V8_CCTEST_COMPILER_FUNCTION_TESTER_H_ | 208 #endif // V8_CCTEST_COMPILER_FUNCTION_TESTER_H_ |
| OLD | NEW |