test-pipeline.cc 1.23 KB
Newer Older
1 2 3 4 5 6 7
// Copyright 2013 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "src/compiler.h"
#include "src/compiler/pipeline.h"
#include "src/handles.h"
8
#include "src/parsing/parser.h"
9
#include "test/cctest/cctest.h"
10

11 12 13
namespace v8 {
namespace internal {
namespace compiler {
14

15
static void RunPipeline(Zone* zone, const char* source) {
16
  Handle<JSFunction> function = Handle<JSFunction>::cast(v8::Utils::OpenHandle(
17
      *v8::Local<v8::Function>::Cast(CompileRun(source))));
18
  ParseInfo parse_info(zone, function);
19 20
  CHECK(Compiler::ParseAndAnalyze(&parse_info));
  CompilationInfo info(&parse_info);
21
  info.SetOptimizing(BailoutId::None(), Handle<Code>(function->code()));
22 23

  Pipeline pipeline(&info);
24
  Handle<Code> code = pipeline.GenerateCode();
25 26
  CHECK(!code.is_null());
}
27 28 29 30 31 32 33 34 35 36 37 38 39 40


TEST(PipelineTyped) {
  HandleAndZoneScope handles;
  FLAG_turbo_types = true;
  RunPipeline(handles.main_zone(), "(function(a,b) { return a + b; })");
}


TEST(PipelineGeneric) {
  HandleAndZoneScope handles;
  FLAG_turbo_types = false;
  RunPipeline(handles.main_zone(), "(function(a,b) { return a + b; })");
}
41 42 43 44

}  // namespace compiler
}  // namespace internal
}  // namespace v8