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

Unified Diff: src/compiler/machine-type.h

Issue 530783002: Convert Linkage to use MachineSignature. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Another try at size_t. Staunch the bleeding. Created 6 years, 3 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
Index: src/compiler/machine-type.h
diff --git a/src/compiler/machine-type.h b/src/compiler/machine-type.h
index 6e749abb1596a5d067690ed0819292e96dc991e2..19c249e139b510f20d5479b3c78b9df79af812d4 100644
--- a/src/compiler/machine-type.h
+++ b/src/compiler/machine-type.h
@@ -6,6 +6,7 @@
#define V8_COMPILER_MACHINE_TYPE_H_
#include "src/globals.h"
+#include "src/zone.h"
namespace v8 {
namespace internal {
@@ -108,32 +109,71 @@ inline int ElementSizeOf(MachineType machine_type) {
}
}
-// Describes the inputs and outputs of a function or call in terms of machine
-// types.
-class MachineSignature {
+// Describes the inputs and outputs of a function or call.
+template <typename T>
+class Signature : public ZoneObject {
public:
- MachineSignature(uint8_t return_count, uint16_t param_count,
- MachineType* reps)
- : return_count_(return_count), param_count_(param_count), reps_(reps) {}
+ Signature(size_t return_count, size_t parameter_count, T* reps)
+ : return_count_(return_count),
+ parameter_count_(parameter_count),
+ reps_(reps) {}
- int GetReturnCount() const { return return_count_; }
- int GetParamCount() const { return param_count_; }
+ size_t return_count() const { return return_count_; }
+ size_t parameter_count() const { return parameter_count_; }
- MachineType GetParameterType(int index) const {
- DCHECK(index >= 0 && index < param_count_);
+ T GetParam(size_t index) const {
+ DCHECK(index < parameter_count_);
return reps_[return_count_ + index];
}
- MachineType GetReturnType(int index = 0) const {
- DCHECK(index >= 0 && index < return_count_);
+ T GetReturn(size_t index = 0) const {
+ DCHECK(index < return_count_);
return reps_[index];
}
+ // For incrementally building signatures.
+ class Builder {
+ public:
+ Builder(Zone* zone, size_t return_count, size_t parameter_count)
+ : return_count_(return_count),
+ parameter_count_(parameter_count),
+ zone_(zone),
+ rcursor_(0),
+ pcursor_(0),
+ buffer_(zone->NewArray<T>(
+ static_cast<int>(return_count + parameter_count))) {}
+
+ const size_t return_count_;
+ const size_t parameter_count_;
+
+ void AddReturn(T val) {
+ DCHECK(rcursor_ < return_count_);
+ buffer_[rcursor_++] = val;
+ }
+ void AddParam(T val) {
+ DCHECK(pcursor_ < parameter_count_);
+ buffer_[return_count_ + pcursor_++] = val;
+ }
+ Signature<T>* Build() {
+ DCHECK(rcursor_ == return_count_);
+ DCHECK(pcursor_ == parameter_count_);
+ return new (zone_) Signature<T>(return_count_, parameter_count_, buffer_);
+ }
+
+ private:
+ Zone* zone_;
+ size_t rcursor_;
+ size_t pcursor_;
+ T* buffer_;
+ };
+
protected:
- uint8_t return_count_;
- uint16_t param_count_;
- MachineType* reps_;
+ size_t return_count_;
+ size_t parameter_count_;
+ T* reps_;
};
+
+typedef Signature<MachineType> MachineSignature;
} // namespace compiler
} // namespace internal
} // namespace v8

Powered by Google App Engine
This is Rietveld 408576698