Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(632)

Unified Diff: test/cctest/compiler/code-assembler-tester.h

Issue 2072813003: [test] Move CodeAssembler tests to a separate file. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Minor cleanup Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « test/cctest/cctest.gyp ('k') | test/cctest/compiler/test-code-assembler.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/cctest/compiler/code-assembler-tester.h
diff --git a/test/cctest/compiler/code-assembler-tester.h b/test/cctest/compiler/code-assembler-tester.h
new file mode 100644
index 0000000000000000000000000000000000000000..609a137f8c588139d650ea4a14f9b4646700fe5e
--- /dev/null
+++ b/test/cctest/compiler/code-assembler-tester.h
@@ -0,0 +1,67 @@
+// 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
« no previous file with comments | « test/cctest/cctest.gyp ('k') | test/cctest/compiler/test-code-assembler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698