Commit b98e3949 authored by ishell's avatar ishell Committed by Commit bot

[test] Move CodeAssembler tests to a separate file.

Review-Url: https://codereview.chromium.org/2072813003
Cr-Commit-Position: refs/heads/master@{#37069}
parent e4fba99b
......@@ -366,8 +366,6 @@ class CodeAssembler {
virtual void CallEpilogue();
private:
friend class CodeAssemblerTester;
CodeAssembler(Isolate* isolate, Zone* zone, CallDescriptor* call_descriptor,
Code::Flags flags, const char* name);
......
......@@ -13,12 +13,14 @@ v8_executable("cctest") {
"$target_gen_dir/resources.cc",
"cctest.cc",
"compiler/c-signature.h",
"compiler/code-assembler-tester.h",
"compiler/codegen-tester.cc",
"compiler/codegen-tester.h",
"compiler/function-tester.h",
"compiler/graph-builder-tester.h",
"compiler/test-basic-block-profiler.cc",
"compiler/test-branch-combine.cc",
"compiler/test-code-assembler.cc",
"compiler/test-gap-resolver.cc",
"compiler/test-graph-visualizer.cc",
"compiler/test-instruction.cc",
......
......@@ -49,12 +49,14 @@
'compiler/c-signature.h',
'compiler/codegen-tester.cc',
'compiler/codegen-tester.h',
'compiler/code-assembler-tester.h',
'compiler/function-tester.h',
'compiler/graph-builder-tester.h',
'compiler/test-basic-block-profiler.cc',
'compiler/test-branch-combine.cc',
'compiler/test-gap-resolver.cc',
'compiler/test-graph-visualizer.cc',
'compiler/test-code-assembler.cc',
'compiler/test-instruction.cc',
'compiler/test-js-context-specialization.cc',
'compiler/test-js-constant-cache.cc',
......
// Copyright 2016 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/handles.h"
#include "src/interface-descriptors.h"
#include "src/isolate.h"
#include "test/cctest/compiler/function-tester.h"
namespace v8 {
namespace internal {
namespace compiler {
class ZoneHolder {
public:
explicit ZoneHolder(Isolate* isolate) : zone_(isolate->allocator()) {}
Zone* zone() { return &zone_; }
private:
Zone zone_;
};
// Inherit from ZoneHolder in order to create a zone that can be passed to
// CodeAssembler base class constructor.
template <typename CodeAssemblerT>
class CodeAssemblerTesterImpl : private ZoneHolder, public CodeAssemblerT {
public:
// Test generating code for a stub.
CodeAssemblerTesterImpl(Isolate* isolate,
const CallInterfaceDescriptor& descriptor)
: ZoneHolder(isolate),
CodeAssemblerT(isolate, ZoneHolder::zone(), descriptor,
Code::ComputeFlags(Code::STUB), "test"),
scope_(isolate) {}
// Test generating code for a JS function (e.g. builtins).
CodeAssemblerTesterImpl(Isolate* isolate, int parameter_count)
: ZoneHolder(isolate),
CodeAssemblerT(isolate, ZoneHolder::zone(), parameter_count,
Code::ComputeFlags(Code::FUNCTION), "test"),
scope_(isolate) {}
// This constructor is intended to be used for creating code objects with
// specific flags.
CodeAssemblerTesterImpl(Isolate* isolate, Code::Flags flags)
: ZoneHolder(isolate),
CodeAssemblerT(isolate, ZoneHolder::zone(), 0, flags, "test"),
scope_(isolate) {}
Handle<Code> GenerateCodeCloseAndEscape() {
return scope_.CloseAndEscape(CodeAssemblerT::GenerateCode());
}
// Expose some internal methods.
Node* SmiShiftBitsConstant() {
return CodeAssemblerT::SmiShiftBitsConstant();
}
private:
HandleScope scope_;
LocalContext context_;
};
} // namespace compiler
} // namespace internal
} // namespace v8
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment