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 |
index 4a4a68b5c7b566de38e8d857b625d060024e4b57..b0c84ec94a1a49fb72a828e462f69116087beba2 100644 |
--- a/test/cctest/compiler/code-assembler-tester.h |
+++ b/test/cctest/compiler/code-assembler-tester.h |
@@ -2,7 +2,6 @@ |
// Use of this source code is governed by a BSD-style license that can be |
// found in the LICENSE file. |
-#include "src/compiler/code-assembler.h" |
#include "src/handles.h" |
#include "src/interface-descriptors.h" |
#include "src/isolate.h" |
@@ -12,43 +11,51 @@ |
namespace internal { |
namespace compiler { |
-class CodeAssemblerTester { |
+class ZoneHolder { |
public: |
- // Test generating code for a stub. Assumes VoidDescriptor call interface. |
- explicit CodeAssemblerTester(Isolate* isolate) |
- : zone_(isolate->allocator(), ZONE_NAME), |
- scope_(isolate), |
- state_(isolate, &zone_, VoidDescriptor(isolate), |
- Code::ComputeFlags(Code::STUB), "test") {} |
+ explicit ZoneHolder(Isolate* isolate) |
+ : held_zone_(isolate->allocator(), ZONE_NAME) {} |
+ Zone* held_zone() { return &held_zone_; } |
+ |
+ private: |
+ Zone held_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::held_zone(), descriptor, |
+ Code::ComputeFlags(Code::STUB), "test"), |
+ scope_(isolate) {} |
// Test generating code for a JS function (e.g. builtins). |
- CodeAssemblerTester(Isolate* isolate, int parameter_count, |
- Code::Kind kind = Code::BUILTIN) |
- : zone_(isolate->allocator(), ZONE_NAME), |
- scope_(isolate), |
- state_(isolate, &zone_, parameter_count, Code::ComputeFlags(kind), |
- "test") {} |
+ CodeAssemblerTesterImpl(Isolate* isolate, int parameter_count, |
+ Code::Kind kind = Code::BUILTIN) |
+ : ZoneHolder(isolate), |
+ CodeAssemblerT(isolate, ZoneHolder::held_zone(), parameter_count, |
+ Code::ComputeFlags(kind), "test"), |
+ scope_(isolate) {} |
// This constructor is intended to be used for creating code objects with |
// specific flags. |
- CodeAssemblerTester(Isolate* isolate, Code::Flags flags) |
- : zone_(isolate->allocator(), ZONE_NAME), |
- scope_(isolate), |
- state_(isolate, &zone_, 0, flags, "test") {} |
- |
- CodeAssemblerState* state() { return &state_; } |
- |
- Handle<Code> GenerateCode() { return CodeAssembler::GenerateCode(&state_); } |
+ CodeAssemblerTesterImpl(Isolate* isolate, Code::Flags flags) |
+ : ZoneHolder(isolate), |
+ CodeAssemblerT(isolate, ZoneHolder::held_zone(), 0, flags, "test"), |
+ scope_(isolate) {} |
Handle<Code> GenerateCodeCloseAndEscape() { |
- return scope_.CloseAndEscape(CodeAssembler::GenerateCode(&state_)); |
+ return scope_.CloseAndEscape(CodeAssemblerT::GenerateCode()); |
} |
private: |
- Zone zone_; |
HandleScope scope_; |
LocalContext context_; |
- CodeAssemblerState state_; |
}; |
} // namespace compiler |