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

Side by Side Diff: src/signature.h

Issue 1118823003: Extract Signature from src/compiler/machine-type.h to src/signature.h (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 7 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 unified diff | Download patch
« no previous file with comments | « src/compiler/machine-type.h ('k') | tools/gyp/v8.gyp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2015 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef V8_SIGNATURE_H_
6 #define V8_SIGNATURE_H_
7
8 #include "src/zone.h"
9
10 namespace v8 {
11 namespace internal {
12
13 // Describes the inputs and outputs of a function or call.
14 template <typename T>
15 class Signature : public ZoneObject {
16 public:
17 Signature(size_t return_count, size_t parameter_count, T* reps)
18 : return_count_(return_count),
19 parameter_count_(parameter_count),
20 reps_(reps) {}
21
22 size_t return_count() const { return return_count_; }
23 size_t parameter_count() const { return parameter_count_; }
24
25 T GetParam(size_t index) const {
26 DCHECK(index < parameter_count_);
27 return reps_[return_count_ + index];
28 }
29
30 T GetReturn(size_t index = 0) const {
31 DCHECK(index < return_count_);
32 return reps_[index];
33 }
34
35 // For incrementally building signatures.
36 class Builder {
37 public:
38 Builder(Zone* zone, size_t return_count, size_t parameter_count)
39 : return_count_(return_count),
40 parameter_count_(parameter_count),
41 zone_(zone),
42 rcursor_(0),
43 pcursor_(0),
44 buffer_(zone->NewArray<T>(
45 static_cast<int>(return_count + parameter_count))) {}
46
47 const size_t return_count_;
48 const size_t parameter_count_;
49
50 void AddReturn(T val) {
51 DCHECK(rcursor_ < return_count_);
52 buffer_[rcursor_++] = val;
53 }
54 void AddParam(T val) {
55 DCHECK(pcursor_ < parameter_count_);
56 buffer_[return_count_ + pcursor_++] = val;
57 }
58 Signature<T>* Build() {
59 DCHECK(rcursor_ == return_count_);
60 DCHECK(pcursor_ == parameter_count_);
61 return new (zone_) Signature<T>(return_count_, parameter_count_, buffer_);
62 }
63
64 private:
65 Zone* zone_;
66 size_t rcursor_;
67 size_t pcursor_;
68 T* buffer_;
69 };
70
71 protected:
72 size_t return_count_;
73 size_t parameter_count_;
74 T* reps_;
75 };
76
77 } // namespace internal
78 } // namespace v8
79
80 #endif // V8_SIGNATURE_H_
OLDNEW
« no previous file with comments | « src/compiler/machine-type.h ('k') | tools/gyp/v8.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698