2014-07-30 13:54:45 +00:00
|
|
|
// 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.
|
|
|
|
|
2015-10-28 13:09:46 +00:00
|
|
|
// TODO(jochen): Remove this after the setting is turned on globally.
|
|
|
|
#define V8_IMMINENT_DEPRECATION_WARNINGS
|
|
|
|
|
2014-07-30 13:54:45 +00:00
|
|
|
#include "src/compiler.h"
|
|
|
|
#include "src/compiler/pipeline.h"
|
|
|
|
#include "src/handles.h"
|
|
|
|
#include "src/parser.h"
|
2015-10-28 13:32:17 +00:00
|
|
|
#include "test/cctest/cctest.h"
|
2014-07-30 13:54:45 +00:00
|
|
|
|
2015-10-30 09:16:26 +00:00
|
|
|
namespace v8 {
|
|
|
|
namespace internal {
|
|
|
|
namespace compiler {
|
2014-07-30 13:54:45 +00:00
|
|
|
|
2015-06-18 04:52:36 +00:00
|
|
|
static void RunPipeline(Zone* zone, const char* source) {
|
2015-10-23 12:26:49 +00:00
|
|
|
Handle<JSFunction> function = Handle<JSFunction>::cast(v8::Utils::OpenHandle(
|
2015-10-28 13:09:46 +00:00
|
|
|
*v8::Local<v8::Function>::Cast(CompileRun(source))));
|
2015-06-18 04:52:36 +00:00
|
|
|
ParseInfo parse_info(zone, function);
|
2015-03-24 14:17:05 +00:00
|
|
|
CHECK(Compiler::ParseAndAnalyze(&parse_info));
|
|
|
|
CompilationInfo info(&parse_info);
|
2015-08-21 15:10:38 +00:00
|
|
|
info.SetOptimizing(BailoutId::None(), Handle<Code>(function->code()));
|
2014-07-30 13:54:45 +00:00
|
|
|
|
|
|
|
Pipeline pipeline(&info);
|
2014-07-31 11:59:49 +00:00
|
|
|
Handle<Code> code = pipeline.GenerateCode();
|
2014-07-30 13:54:45 +00:00
|
|
|
CHECK(!code.is_null());
|
|
|
|
}
|
2015-06-18 04:52:36 +00:00
|
|
|
|
|
|
|
|
|
|
|
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; })");
|
|
|
|
}
|
2015-10-30 09:16:26 +00:00
|
|
|
|
|
|
|
} // namespace compiler
|
|
|
|
} // namespace internal
|
|
|
|
} // namespace v8
|