From acdb5336a97eda5f0c4028e99c05107de4ff0c41 Mon Sep 17 00:00:00 2001 From: titzer Date: Mon, 4 May 2015 03:11:50 -0700 Subject: [PATCH] Extract Signature from src/compiler/machine-type.h to src/signature.h R=bmeurer@chromium.org BUG= Review URL: https://codereview.chromium.org/1118823003 Cr-Commit-Position: refs/heads/master@{#28191} --- BUILD.gn | 1 + src/compiler/machine-type.h | 65 +----------------------------------- src/signature.h | 80 +++++++++++++++++++++++++++++++++++++++++++++ tools/gyp/v8.gyp | 1 + 4 files changed, 83 insertions(+), 64 deletions(-) create mode 100644 src/signature.h diff --git a/BUILD.gn b/BUILD.gn index 64d7502..424738c 100644 --- a/BUILD.gn +++ b/BUILD.gn @@ -977,6 +977,7 @@ source_set("v8_base") { "src/scopeinfo.h", "src/scopes.cc", "src/scopes.h", + "src/signature.h", "src/small-pointer-list.h", "src/smart-pointers.h", "src/snapshot/natives.h", diff --git a/src/compiler/machine-type.h b/src/compiler/machine-type.h index 4c51a9f..0b56b7a 100644 --- a/src/compiler/machine-type.h +++ b/src/compiler/machine-type.h @@ -9,6 +9,7 @@ #include "src/base/bits.h" #include "src/globals.h" +#include "src/signature.h" #include "src/zone.h" namespace v8 { @@ -111,70 +112,6 @@ inline int ElementSizeOf(MachineType machine_type) { return 1 << shift; } -// Describes the inputs and outputs of a function or call. -template -class Signature : public ZoneObject { - public: - Signature(size_t return_count, size_t parameter_count, T* reps) - : return_count_(return_count), - parameter_count_(parameter_count), - reps_(reps) {} - - size_t return_count() const { return return_count_; } - size_t parameter_count() const { return parameter_count_; } - - T GetParam(size_t index) const { - DCHECK(index < parameter_count_); - return reps_[return_count_ + index]; - } - - 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( - static_cast(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* Build() { - DCHECK(rcursor_ == return_count_); - DCHECK(pcursor_ == parameter_count_); - return new (zone_) Signature(return_count_, parameter_count_, buffer_); - } - - private: - Zone* zone_; - size_t rcursor_; - size_t pcursor_; - T* buffer_; - }; - - protected: - size_t return_count_; - size_t parameter_count_; - T* reps_; -}; - typedef Signature MachineSignature; } // namespace compiler } // namespace internal diff --git a/src/signature.h b/src/signature.h new file mode 100644 index 0000000..076d17a --- /dev/null +++ b/src/signature.h @@ -0,0 +1,80 @@ +// Copyright 2015 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. + +#ifndef V8_SIGNATURE_H_ +#define V8_SIGNATURE_H_ + +#include "src/zone.h" + +namespace v8 { +namespace internal { + +// Describes the inputs and outputs of a function or call. +template +class Signature : public ZoneObject { + public: + Signature(size_t return_count, size_t parameter_count, T* reps) + : return_count_(return_count), + parameter_count_(parameter_count), + reps_(reps) {} + + size_t return_count() const { return return_count_; } + size_t parameter_count() const { return parameter_count_; } + + T GetParam(size_t index) const { + DCHECK(index < parameter_count_); + return reps_[return_count_ + index]; + } + + 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( + static_cast(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* Build() { + DCHECK(rcursor_ == return_count_); + DCHECK(pcursor_ == parameter_count_); + return new (zone_) Signature(return_count_, parameter_count_, buffer_); + } + + private: + Zone* zone_; + size_t rcursor_; + size_t pcursor_; + T* buffer_; + }; + + protected: + size_t return_count_; + size_t parameter_count_; + T* reps_; +}; + +} // namespace internal +} // namespace v8 + +#endif // V8_SIGNATURE_H_ diff --git a/tools/gyp/v8.gyp b/tools/gyp/v8.gyp index b0f7d67..b34af8c 100644 --- a/tools/gyp/v8.gyp +++ b/tools/gyp/v8.gyp @@ -863,6 +863,7 @@ '../../src/scopeinfo.h', '../../src/scopes.cc', '../../src/scopes.h', + '../../src/signature.h', '../../src/small-pointer-list.h', '../../src/smart-pointers.h', '../../src/snapshot/natives.h', -- 2.7.4