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

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

Issue 2498073002: [refactoring] Split CodeAssemblerState out of CodeAssembler (Closed)
Patch Set: one more attempt Created 4 years, 1 month 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 unified diff | Download patch
« no previous file with comments | « src/interpreter/interpreter-assembler.cc ('k') | test/cctest/compiler/function-tester.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 the V8 project authors. All rights reserved. 1 // Copyright 2016 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "src/compiler/code-assembler.h"
5 #include "src/handles.h" 6 #include "src/handles.h"
6 #include "src/interface-descriptors.h" 7 #include "src/interface-descriptors.h"
7 #include "src/isolate.h" 8 #include "src/isolate.h"
8 #include "test/cctest/compiler/function-tester.h" 9 #include "test/cctest/compiler/function-tester.h"
9 10
10 namespace v8 { 11 namespace v8 {
11 namespace internal { 12 namespace internal {
12 namespace compiler { 13 namespace compiler {
13 14
14 class ZoneHolder { 15 class CodeAssemblerTester {
15 public: 16 public:
16 explicit ZoneHolder(Isolate* isolate) 17 // Test generating code for a stub. Assumes VoidDescriptor call interface.
17 : held_zone_(isolate->allocator(), ZONE_NAME) {} 18 explicit CodeAssemblerTester(Isolate* isolate)
18 Zone* held_zone() { return &held_zone_; } 19 : zone_(isolate->allocator(), ZONE_NAME),
19 20 scope_(isolate),
20 private: 21 state_(isolate, &zone_, VoidDescriptor(isolate),
21 Zone held_zone_; 22 Code::ComputeFlags(Code::STUB), "test") {}
22 };
23
24 // Inherit from ZoneHolder in order to create a zone that can be passed to
25 // CodeAssembler base class constructor.
26 template <typename CodeAssemblerT>
27 class CodeAssemblerTesterImpl : private ZoneHolder, public CodeAssemblerT {
28 public:
29 // Test generating code for a stub.
30 CodeAssemblerTesterImpl(Isolate* isolate,
31 const CallInterfaceDescriptor& descriptor)
32 : ZoneHolder(isolate),
33 CodeAssemblerT(isolate, ZoneHolder::held_zone(), descriptor,
34 Code::ComputeFlags(Code::STUB), "test"),
35 scope_(isolate) {}
36 23
37 // Test generating code for a JS function (e.g. builtins). 24 // Test generating code for a JS function (e.g. builtins).
38 CodeAssemblerTesterImpl(Isolate* isolate, int parameter_count, 25 CodeAssemblerTester(Isolate* isolate, int parameter_count,
39 Code::Kind kind = Code::BUILTIN) 26 Code::Kind kind = Code::BUILTIN)
40 : ZoneHolder(isolate), 27 : zone_(isolate->allocator(), ZONE_NAME),
41 CodeAssemblerT(isolate, ZoneHolder::held_zone(), parameter_count, 28 scope_(isolate),
42 Code::ComputeFlags(kind), "test"), 29 state_(isolate, &zone_, parameter_count, Code::ComputeFlags(kind),
43 scope_(isolate) {} 30 "test") {}
44 31
45 // This constructor is intended to be used for creating code objects with 32 // This constructor is intended to be used for creating code objects with
46 // specific flags. 33 // specific flags.
47 CodeAssemblerTesterImpl(Isolate* isolate, Code::Flags flags) 34 CodeAssemblerTester(Isolate* isolate, Code::Flags flags)
48 : ZoneHolder(isolate), 35 : zone_(isolate->allocator(), ZONE_NAME),
49 CodeAssemblerT(isolate, ZoneHolder::held_zone(), 0, flags, "test"), 36 scope_(isolate),
50 scope_(isolate) {} 37 state_(isolate, &zone_, 0, flags, "test") {}
38
39 CodeAssemblerState* state() { return &state_; }
40
41 Handle<Code> GenerateCode() { return CodeAssembler::GenerateCode(&state_); }
51 42
52 Handle<Code> GenerateCodeCloseAndEscape() { 43 Handle<Code> GenerateCodeCloseAndEscape() {
53 return scope_.CloseAndEscape(CodeAssemblerT::GenerateCode()); 44 return scope_.CloseAndEscape(CodeAssembler::GenerateCode(&state_));
54 } 45 }
55 46
56 private: 47 private:
48 Zone zone_;
57 HandleScope scope_; 49 HandleScope scope_;
58 LocalContext context_; 50 LocalContext context_;
51 CodeAssemblerState state_;
59 }; 52 };
60 53
61 } // namespace compiler 54 } // namespace compiler
62 } // namespace internal 55 } // namespace internal
63 } // namespace v8 56 } // namespace v8
OLDNEW
« no previous file with comments | « src/interpreter/interpreter-assembler.cc ('k') | test/cctest/compiler/function-tester.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698