summaryrefslogtreecommitdiff
path: root/deps/v8/test/cctest/compiler/test-pipeline.cc
blob: 7efedeeea2ac1dcc2aacc1182f844d84421fbab2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
// 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/v8.h"
#include "test/cctest/cctest.h"

#include "src/compiler.h"
#include "src/compiler/pipeline.h"
#include "src/handles.h"
#include "src/parser.h"
#include "src/rewriter.h"
#include "src/scopes.h"

using namespace v8::internal;
using namespace v8::internal::compiler;

TEST(PipelineAdd) {
  InitializedHandleScope handles;
  const char* source = "(function(a,b) { return a + b; })";
  Handle<JSFunction> function = v8::Utils::OpenHandle(
      *v8::Handle<v8::Function>::Cast(CompileRun(source)));
  CompilationInfoWithZone info(function);

  CHECK(Parser::Parse(&info));
  StrictMode strict_mode = info.function()->strict_mode();
  info.SetStrictMode(strict_mode);
  CHECK(Rewriter::Rewrite(&info));
  CHECK(Scope::Analyze(&info));
  CHECK_NE(NULL, info.scope());

  Pipeline pipeline(&info);
#if V8_TURBOFAN_TARGET
  Handle<Code> code = pipeline.GenerateCode();
  CHECK(Pipeline::SupportedTarget());
  CHECK(!code.is_null());
#else
  USE(pipeline);
#endif
}