Generalized the EvalCache into a CompilationCache and enabled it for scripts too. The current strategy is to retire all entries whenever a mark-sweep collection is started.
Fixed bug where switch statements containing only a default case would lead to an unbalanced stack (issue 69).
Fixed bug that made access to the function in a named function expression impossible in certain situations (issue 24).
Fixed even more build issues.
Optimized calling conventions on ARM. The conventions on ARM and IA-32 now match.
Removed static initializers for flags and counters.
Improved inline caching behavior for uncommon cases where lazily loading Date and RegExp code could force certain code paths go megamorphic.
Removed arguments adaption for builtins written in C++. This makes Array.prototype.push and Array.prototype.pop slightly faster.
git-svn-id: http://v8.googlecode.com/svn/trunk@329 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
diff --git a/src/utils.h b/src/utils.h
index 1c07ba4..1f38525 100644
--- a/src/utils.h
+++ b/src/utils.h
@@ -279,6 +279,10 @@
ASSERT(length == 0 || (length > 0 && data != NULL));
}
+ static Vector<T> New(int length) {
+ return Vector<T>(NewArray<T>(length), length);
+ }
+
// Returns the length of the vector.
int length() const { return length_; }
@@ -310,6 +314,11 @@
length_ = 0;
}
+ inline Vector<T> operator+(int offset) {
+ ASSERT(offset < length_);
+ return Vector<T>(start_ + offset, length_ - offset);
+ }
+
// Factory method for creating empty vectors.
static Vector<T> empty() { return Vector<T>(NULL, 0); }
@@ -319,6 +328,15 @@
};
+template <typename T, int kSize>
+class EmbeddedVector : public Vector<T> {
+ public:
+ EmbeddedVector() : Vector<T>(buffer_, kSize) { }
+ private:
+ T buffer_[kSize];
+};
+
+
inline Vector<const char> CStrVector(const char* data) {
return Vector<const char>(data, strlen(data));
}
@@ -327,6 +345,11 @@
return Vector<char>(data, strlen(data));
}
+inline Vector<char> MutableCStrVector(char* data, int max) {
+ int length = strlen(data);
+ return Vector<char>(data, (length < max) ? length : max);
+}
+
template <typename T>
inline Vector< Handle<Object> > HandleVector(v8::internal::Handle<T>* elms,
int length) {
@@ -369,11 +392,11 @@
explicit StringBuilder(int size);
StringBuilder(char* buffer, int size)
- : buffer_(buffer), size_(size), position_(0) { }
+ : buffer_(buffer, size), position_(0) { }
~StringBuilder() { if (!is_finalized()) Finalize(); }
- int size() const { return size_; }
+ int size() const { return buffer_.length(); }
// Get the current position in the builder.
int position() const {
@@ -389,7 +412,7 @@
// instead.
void AddCharacter(char c) {
ASSERT(c != '\0');
- ASSERT(!is_finalized() && position_ < size_);
+ ASSERT(!is_finalized() && position_ < buffer_.length());
buffer_[position_++] = c;
}
@@ -412,8 +435,7 @@
char* Finalize();
private:
- char* buffer_;
- int size_;
+ Vector<char> buffer_;
int position_;
bool is_finalized() const { return position_ < 0; }