Commit 4b6b8cf6 authored by Sigurd Schneider's avatar Sigurd Schneider Committed by Commit Bot

[cleanup] Start cleaning up utils.h

Remove EmbeddedVector from utils.h

Bug: v8:8834, v8:8912
Change-Id: I04e9f12121757bd0b87c68d7a4a5b213c2d8b686
Reviewed-on: https://chromium-review.googlesource.com/c/1486473Reviewed-by: 's avatarYang Guo <yangguo@chromium.org>
Reviewed-by: 's avatarMichael Starzinger <mstarzinger@chromium.org>
Commit-Queue: Sigurd Schneider <sigurds@chromium.org>
Cr-Commit-Position: refs/heads/master@{#59854}
parent c89c54ef
...@@ -35,6 +35,7 @@ ...@@ -35,6 +35,7 @@
#include "src/base/bits.h" #include "src/base/bits.h"
#include "src/base/platform/platform.h" #include "src/base/platform/platform.h"
#include "src/disasm.h" #include "src/disasm.h"
#include "src/vector.h"
namespace v8 { namespace v8 {
namespace internal { namespace internal {
......
...@@ -19,6 +19,7 @@ ...@@ -19,6 +19,7 @@
#include "src/objects-inl.h" #include "src/objects-inl.h"
#include "src/ostreams.h" #include "src/ostreams.h"
#include "src/runtime/runtime-utils.h" #include "src/runtime/runtime-utils.h"
#include "src/vector.h"
// Only build the simulator if not compiling for real ARM hardware. // Only build the simulator if not compiling for real ARM hardware.
namespace v8 { namespace v8 {
......
...@@ -23,6 +23,7 @@ ...@@ -23,6 +23,7 @@
#include "src/parsing/scanner-character-streams.h" #include "src/parsing/scanner-character-streams.h"
#include "src/parsing/scanner.h" #include "src/parsing/scanner.h"
#include "src/unoptimized-compilation-info.h" #include "src/unoptimized-compilation-info.h"
#include "src/vector.h"
#include "src/wasm/wasm-engine.h" #include "src/wasm/wasm-engine.h"
#include "src/wasm/wasm-js.h" #include "src/wasm/wasm-js.h"
......
...@@ -12,6 +12,7 @@ ...@@ -12,6 +12,7 @@
#include "src/globals.h" #include "src/globals.h"
#include "src/objects-inl.h" #include "src/objects-inl.h"
#include "src/string-builder-inl.h" #include "src/string-builder-inl.h"
#include "src/vector.h"
namespace v8 { namespace v8 {
namespace internal { namespace internal {
......
...@@ -9,6 +9,7 @@ ...@@ -9,6 +9,7 @@
#include "src/flags.h" #include "src/flags.h"
#include "src/globals.h" #include "src/globals.h"
#include "src/utils.h" #include "src/utils.h"
#include "src/vector.h"
namespace v8 { namespace v8 {
namespace internal { namespace internal {
......
...@@ -11,6 +11,7 @@ ...@@ -11,6 +11,7 @@
#include "src/base/small-vector.h" #include "src/base/small-vector.h"
#include "src/compiler/linkage.h" #include "src/compiler/linkage.h"
#include "src/string-stream.h" #include "src/string-stream.h"
#include "src/vector.h"
namespace v8 { namespace v8 {
namespace internal { namespace internal {
......
...@@ -26,6 +26,7 @@ ...@@ -26,6 +26,7 @@
#include "src/optimized-compilation-info.h" #include "src/optimized-compilation-info.h"
#include "src/ostreams.h" #include "src/ostreams.h"
#include "src/source-position.h" #include "src/source-position.h"
#include "src/vector.h"
namespace v8 { namespace v8 {
namespace internal { namespace internal {
......
...@@ -40,6 +40,7 @@ ...@@ -40,6 +40,7 @@
#include "src/optimized-compilation-info.h" #include "src/optimized-compilation-info.h"
#include "src/tracing/trace-event.h" #include "src/tracing/trace-event.h"
#include "src/trap-handler/trap-handler.h" #include "src/trap-handler/trap-handler.h"
#include "src/vector.h"
#include "src/wasm/function-body-decoder.h" #include "src/wasm/function-body-decoder.h"
#include "src/wasm/function-compiler.h" #include "src/wasm/function-compiler.h"
#include "src/wasm/graph-builder-interface.h" #include "src/wasm/graph-builder-interface.h"
......
...@@ -5,10 +5,9 @@ ...@@ -5,10 +5,9 @@
#ifndef V8_CONVERSIONS_H_ #ifndef V8_CONVERSIONS_H_
#define V8_CONVERSIONS_H_ #define V8_CONVERSIONS_H_
#include <limits>
#include "src/base/logging.h" #include "src/base/logging.h"
#include "src/utils.h" #include "src/globals.h"
#include "src/vector.h"
namespace v8 { namespace v8 {
namespace internal { namespace internal {
......
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
#ifndef V8_DISASM_H_ #ifndef V8_DISASM_H_
#define V8_DISASM_H_ #define V8_DISASM_H_
#include "src/utils.h" #include "src/vector.h"
namespace disasm { namespace disasm {
......
...@@ -21,6 +21,7 @@ ...@@ -21,6 +21,7 @@
#include "src/snapshot/embedded-data.h" #include "src/snapshot/embedded-data.h"
#include "src/snapshot/serializer-common.h" #include "src/snapshot/serializer-common.h"
#include "src/string-stream.h" #include "src/string-stream.h"
#include "src/vector.h"
#include "src/wasm/wasm-code-manager.h" #include "src/wasm/wasm-code-manager.h"
#include "src/wasm/wasm-engine.h" #include "src/wasm/wasm-engine.h"
......
...@@ -18,6 +18,7 @@ ...@@ -18,6 +18,7 @@
#include "src/ostreams.h" #include "src/ostreams.h"
#include "src/snapshot/natives.h" #include "src/snapshot/natives.h"
#include "src/splay-tree-inl.h" #include "src/splay-tree-inl.h"
#include "src/vector.h"
#include "src/zone/zone-chunk-list.h" #include "src/zone/zone-chunk-list.h"
namespace v8 { namespace v8 {
......
...@@ -11,6 +11,7 @@ ...@@ -11,6 +11,7 @@
#include "src/base/compiler-specific.h" #include "src/base/compiler-specific.h"
#include "src/disasm.h" #include "src/disasm.h"
#include "src/ia32/sse-instr.h" #include "src/ia32/sse-instr.h"
#include "src/utils.h"
namespace disasm { namespace disasm {
......
...@@ -5,6 +5,7 @@ include_rules = [ ...@@ -5,6 +5,7 @@ include_rules = [
"+src/base/compiler-specific.h", "+src/base/compiler-specific.h",
"+src/base/macros.h", "+src/base/macros.h",
"+src/base/logging.h", "+src/base/logging.h",
"+src/base/v8-fallthrough.h",
"+src/base/platform/platform.h", "+src/base/platform/platform.h",
"+src/base/platform/mutex.h", "+src/base/platform/mutex.h",
"+src/conversions.h", "+src/conversions.h",
......
...@@ -12,6 +12,7 @@ ...@@ -12,6 +12,7 @@
#include <string> #include <string>
#include "src/base/platform/platform.h" #include "src/base/platform/platform.h"
#include "src/base/v8-fallthrough.h"
#include "src/conversions.h" #include "src/conversions.h"
namespace v8_inspector { namespace v8_inspector {
......
...@@ -20,6 +20,7 @@ ...@@ -20,6 +20,7 @@
#include "src/mips/constants-mips.h" #include "src/mips/constants-mips.h"
#include "src/ostreams.h" #include "src/ostreams.h"
#include "src/runtime/runtime-utils.h" #include "src/runtime/runtime-utils.h"
#include "src/vector.h"
namespace v8 { namespace v8 {
namespace internal { namespace internal {
......
...@@ -19,6 +19,7 @@ ...@@ -19,6 +19,7 @@
#include "src/mips64/constants-mips64.h" #include "src/mips64/constants-mips64.h"
#include "src/ostreams.h" #include "src/ostreams.h"
#include "src/runtime/runtime-utils.h" #include "src/runtime/runtime-utils.h"
#include "src/vector.h"
namespace v8 { namespace v8 {
namespace internal { namespace internal {
......
...@@ -33,6 +33,7 @@ ...@@ -33,6 +33,7 @@
#include "src/profiler/heap-snapshot-generator-inl.h" #include "src/profiler/heap-snapshot-generator-inl.h"
#include "src/prototype.h" #include "src/prototype.h"
#include "src/transitions-inl.h" #include "src/transitions-inl.h"
#include "src/vector.h"
#include "src/visitors.h" #include "src/visitors.h"
namespace v8 { namespace v8 {
......
...@@ -11,6 +11,7 @@ ...@@ -11,6 +11,7 @@
#include "src/objects-inl.h" #include "src/objects-inl.h"
#include "src/objects/js-array-inl.h" #include "src/objects/js-array-inl.h"
#include "src/prototype.h" #include "src/prototype.h"
#include "src/vector.h"
namespace v8 { namespace v8 {
namespace internal { namespace internal {
......
...@@ -6,6 +6,7 @@ ...@@ -6,6 +6,7 @@
#include "src/base/platform/platform.h" #include "src/base/platform/platform.h"
#include "src/conversions.h" #include "src/conversions.h"
#include "src/vector.h"
namespace v8 { namespace v8 {
namespace tracing { namespace tracing {
......
...@@ -52,11 +52,6 @@ inline char HexCharOfValue(int value) { ...@@ -52,11 +52,6 @@ inline char HexCharOfValue(int value) {
inline int BoolToInt(bool b) { return b ? 1 : 0; } inline int BoolToInt(bool b) { return b ? 1 : 0; }
// Same as strcmp, but can handle NULL arguments.
inline bool CStringEquals(const char* s1, const char* s2) {
return (s1 == s2) || (s1 != nullptr && s2 != nullptr && strcmp(s1, s2) == 0);
}
// Checks if value is in range [lower_limit, higher_limit] using a single // Checks if value is in range [lower_limit, higher_limit] using a single
// branch. // branch.
template <typename T, typename U> template <typename T, typename U>
...@@ -577,36 +572,6 @@ class SetOncePointer { ...@@ -577,36 +572,6 @@ class SetOncePointer {
T* pointer_ = nullptr; T* pointer_ = nullptr;
}; };
template <typename T, int kSize>
class EmbeddedVector : public Vector<T> {
public:
EmbeddedVector() : Vector<T>(buffer_, kSize) { }
explicit EmbeddedVector(T initial_value) : Vector<T>(buffer_, kSize) {
for (int i = 0; i < kSize; ++i) {
buffer_[i] = initial_value;
}
}
// When copying, make underlying Vector to reference our buffer.
EmbeddedVector(const EmbeddedVector& rhs) V8_NOEXCEPT : Vector<T>(rhs) {
MemCopy(buffer_, rhs.buffer_, sizeof(T) * kSize);
this->set_start(buffer_);
}
EmbeddedVector& operator=(const EmbeddedVector& rhs) V8_NOEXCEPT {
if (this == &rhs) return *this;
Vector<T>::operator=(rhs);
MemCopy(buffer_, rhs.buffer_, sizeof(T) * kSize);
this->set_start(buffer_);
return *this;
}
private:
T buffer_[kSize];
};
// Compare 8bit/16bit chars to 8bit/16bit chars. // Compare 8bit/16bit chars to 8bit/16bit chars.
template <typename lchar, typename rchar> template <typename lchar, typename rchar>
inline int CompareCharsUnsigned(const lchar* lhs, const rchar* rhs, inline int CompareCharsUnsigned(const lchar* lhs, const rchar* rhs,
......
...@@ -313,6 +313,35 @@ inline constexpr auto VectorOf(Container&& c) ...@@ -313,6 +313,35 @@ inline constexpr auto VectorOf(Container&& c)
return VectorOf(c.data(), c.size()); return VectorOf(c.data(), c.size());
} }
template <typename T, int kSize>
class EmbeddedVector : public Vector<T> {
public:
EmbeddedVector() : Vector<T>(buffer_, kSize) {}
explicit EmbeddedVector(T initial_value) : Vector<T>(buffer_, kSize) {
for (int i = 0; i < kSize; ++i) {
buffer_[i] = initial_value;
}
}
// When copying, make underlying Vector to reference our buffer.
EmbeddedVector(const EmbeddedVector& rhs) V8_NOEXCEPT : Vector<T>(rhs) {
MemCopy(buffer_, rhs.buffer_, sizeof(T) * kSize);
this->set_start(buffer_);
}
EmbeddedVector& operator=(const EmbeddedVector& rhs) V8_NOEXCEPT {
if (this == &rhs) return *this;
Vector<T>::operator=(rhs);
MemCopy(buffer_, rhs.buffer_, sizeof(T) * kSize);
this->set_start(buffer_);
return *this;
}
private:
T buffer_[kSize];
};
} // namespace internal } // namespace internal
} // namespace v8 } // namespace v8
......
...@@ -12,6 +12,7 @@ ...@@ -12,6 +12,7 @@
#include "src/flags.h" #include "src/flags.h"
#include "src/signature.h" #include "src/signature.h"
#include "src/v8memory.h" #include "src/v8memory.h"
#include "src/vector.h"
#include "src/wasm/wasm-result.h" #include "src/wasm/wasm-result.h"
#include "src/zone/zone-containers.h" #include "src/zone/zone-containers.h"
......
...@@ -6,6 +6,7 @@ ...@@ -6,6 +6,7 @@
#include "src/utils.h" #include "src/utils.h"
#include "src/v8memory.h" #include "src/v8memory.h"
#include "src/vector.h"
namespace v8 { namespace v8 {
namespace internal { namespace internal {
......
...@@ -18,6 +18,7 @@ ...@@ -18,6 +18,7 @@
#include "src/objects-inl.h" #include "src/objects-inl.h"
#include "src/ostreams.h" #include "src/ostreams.h"
#include "src/snapshot/embedded-data.h" #include "src/snapshot/embedded-data.h"
#include "src/vector.h"
#include "src/wasm/compilation-environment.h" #include "src/wasm/compilation-environment.h"
#include "src/wasm/function-compiler.h" #include "src/wasm/function-compiler.h"
#include "src/wasm/jump-table-assembler.h" #include "src/wasm/jump-table-assembler.h"
......
...@@ -16,6 +16,7 @@ ...@@ -16,6 +16,7 @@
#include "src/objects/shared-function-info.h" #include "src/objects/shared-function-info.h"
#include "src/objects/struct-inl.h" #include "src/objects/struct-inl.h"
#include "src/trap-handler/trap-handler.h" #include "src/trap-handler/trap-handler.h"
#include "src/vector.h"
#include "src/wasm/jump-table-assembler.h" #include "src/wasm/jump-table-assembler.h"
#include "src/wasm/module-compiler.h" #include "src/wasm/module-compiler.h"
#include "src/wasm/module-decoder.h" #include "src/wasm/module-decoder.h"
......
...@@ -9,7 +9,8 @@ ...@@ -9,7 +9,8 @@
#include <memory> #include <memory>
#include "src/base/compiler-specific.h" #include "src/base/compiler-specific.h"
#include "src/utils.h" #include "src/base/macros.h"
#include "src/base/platform/platform.h"
#include "src/globals.h" #include "src/globals.h"
......
...@@ -12,6 +12,7 @@ ...@@ -12,6 +12,7 @@
#include "src/base/lazy-instance.h" #include "src/base/lazy-instance.h"
#include "src/base/v8-fallthrough.h" #include "src/base/v8-fallthrough.h"
#include "src/disasm.h" #include "src/disasm.h"
#include "src/utils.h"
#include "src/x64/register-x64.h" #include "src/x64/register-x64.h"
#include "src/x64/sse-instr.h" #include "src/x64/sse-instr.h"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment