| OLD | NEW |
| 1 // Copyright 2013 the V8 project authors. All rights reserved. | 1 // Copyright 2013 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 // TODO(jochen): Remove this after the setting is turned on globally. | 5 // TODO(jochen): Remove this after the setting is turned on globally. |
| 6 #define V8_IMMINENT_DEPRECATION_WARNINGS | 6 #define V8_IMMINENT_DEPRECATION_WARNINGS |
| 7 | 7 |
| 8 #include "src/compiler.h" | 8 #include "src/compiler.h" |
| 9 #include "src/compiler/pipeline.h" | 9 #include "src/compiler/pipeline.h" |
| 10 #include "src/handles.h" | 10 #include "src/handles.h" |
| 11 #include "src/parser.h" | 11 #include "src/parser.h" |
| 12 #include "test/cctest/cctest.h" | 12 #include "test/cctest/cctest.h" |
| 13 | 13 |
| 14 using namespace v8::internal; | 14 namespace v8 { |
| 15 using namespace v8::internal::compiler; | 15 namespace internal { |
| 16 namespace compiler { |
| 16 | 17 |
| 17 static void RunPipeline(Zone* zone, const char* source) { | 18 static void RunPipeline(Zone* zone, const char* source) { |
| 18 Handle<JSFunction> function = Handle<JSFunction>::cast(v8::Utils::OpenHandle( | 19 Handle<JSFunction> function = Handle<JSFunction>::cast(v8::Utils::OpenHandle( |
| 19 *v8::Local<v8::Function>::Cast(CompileRun(source)))); | 20 *v8::Local<v8::Function>::Cast(CompileRun(source)))); |
| 20 ParseInfo parse_info(zone, function); | 21 ParseInfo parse_info(zone, function); |
| 21 CHECK(Compiler::ParseAndAnalyze(&parse_info)); | 22 CHECK(Compiler::ParseAndAnalyze(&parse_info)); |
| 22 CompilationInfo info(&parse_info); | 23 CompilationInfo info(&parse_info); |
| 23 info.SetOptimizing(BailoutId::None(), Handle<Code>(function->code())); | 24 info.SetOptimizing(BailoutId::None(), Handle<Code>(function->code())); |
| 24 | 25 |
| 25 Pipeline pipeline(&info); | 26 Pipeline pipeline(&info); |
| 26 Handle<Code> code = pipeline.GenerateCode(); | 27 Handle<Code> code = pipeline.GenerateCode(); |
| 27 CHECK(!code.is_null()); | 28 CHECK(!code.is_null()); |
| 28 } | 29 } |
| 29 | 30 |
| 30 | 31 |
| 31 TEST(PipelineTyped) { | 32 TEST(PipelineTyped) { |
| 32 HandleAndZoneScope handles; | 33 HandleAndZoneScope handles; |
| 33 FLAG_turbo_types = true; | 34 FLAG_turbo_types = true; |
| 34 RunPipeline(handles.main_zone(), "(function(a,b) { return a + b; })"); | 35 RunPipeline(handles.main_zone(), "(function(a,b) { return a + b; })"); |
| 35 } | 36 } |
| 36 | 37 |
| 37 | 38 |
| 38 TEST(PipelineGeneric) { | 39 TEST(PipelineGeneric) { |
| 39 HandleAndZoneScope handles; | 40 HandleAndZoneScope handles; |
| 40 FLAG_turbo_types = false; | 41 FLAG_turbo_types = false; |
| 41 RunPipeline(handles.main_zone(), "(function(a,b) { return a + b; })"); | 42 RunPipeline(handles.main_zone(), "(function(a,b) { return a + b; })"); |
| 42 } | 43 } |
| 44 |
| 45 } // namespace compiler |
| 46 } // namespace internal |
| 47 } // namespace v8 |
| OLD | NEW |