Push version 1.2.2 to trunk.
Fixed bug in array sorting for sparse arrays (issue 326).
Added support for adding a soname when building a shared library on Linux (issue 151).
Fixed bug caused by morphing internal ASCII strings to external two-byte strings. Slices over ASCII strings have to forward ASCII checks to the underlying buffer string.
Allowed API call-as-function handlers to be called as constructors.
Fixed a crash bug where an external string was disposed but a slice of the external string survived as a symbol.
git-svn-id: http://v8.googlecode.com/svn/trunk@1853 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
diff --git a/src/objects-inl.h b/src/objects-inl.h
index ff64d65..58e4f7c 100644
--- a/src/objects-inl.h
+++ b/src/objects-inl.h
@@ -144,14 +144,14 @@
bool Object::IsSeqAsciiString() {
if (!IsString()) return false;
return StringShape(String::cast(this)).IsSequential() &&
- StringShape(String::cast(this)).IsAsciiRepresentation();
+ String::cast(this)->IsAsciiRepresentation();
}
bool Object::IsSeqTwoByteString() {
if (!IsString()) return false;
return StringShape(String::cast(this)).IsSequential() &&
- StringShape(String::cast(this)).IsTwoByteRepresentation();
+ String::cast(this)->IsTwoByteRepresentation();
}
@@ -164,14 +164,14 @@
bool Object::IsExternalAsciiString() {
if (!IsString()) return false;
return StringShape(String::cast(this)).IsExternal() &&
- StringShape(String::cast(this)).IsAsciiRepresentation();
+ String::cast(this)->IsAsciiRepresentation();
}
bool Object::IsExternalTwoByteString() {
if (!IsString()) return false;
return StringShape(String::cast(this)).IsExternal() &&
- StringShape(String::cast(this)).IsTwoByteRepresentation();
+ String::cast(this)->IsTwoByteRepresentation();
}
@@ -211,13 +211,28 @@
}
-bool StringShape::IsAsciiRepresentation() {
- return (type_ & kStringEncodingMask) == kAsciiStringTag;
+bool String::IsAsciiRepresentation() {
+ uint32_t type = map()->instance_type();
+ if ((type & kStringRepresentationMask) == kSlicedStringTag) {
+ return SlicedString::cast(this)->buffer()->IsAsciiRepresentation();
+ }
+ if ((type & kStringRepresentationMask) == kConsStringTag &&
+ ConsString::cast(this)->second()->length() == 0) {
+ return ConsString::cast(this)->first()->IsAsciiRepresentation();
+ }
+ return (type & kStringEncodingMask) == kAsciiStringTag;
}
-bool StringShape::IsTwoByteRepresentation() {
- return (type_ & kStringEncodingMask) == kTwoByteStringTag;
+bool String::IsTwoByteRepresentation() {
+ uint32_t type = map()->instance_type();
+ if ((type & kStringRepresentationMask) == kSlicedStringTag) {
+ return SlicedString::cast(this)->buffer()->IsTwoByteRepresentation();
+ } else if ((type & kStringRepresentationMask) == kConsStringTag &&
+ ConsString::cast(this)->second()->length() == 0) {
+ return ConsString::cast(this)->first()->IsTwoByteRepresentation();
+ }
+ return (type & kStringEncodingMask) == kTwoByteStringTag;
}
@@ -668,7 +683,7 @@
int Smi::value() {
- return reinterpret_cast<int>(this) >> kSmiTagSize;
+ return static_cast<int>(reinterpret_cast<intptr_t>(this) >> kSmiTagSize);
}
@@ -724,7 +739,7 @@
int Failure::value() const {
- return reinterpret_cast<int>(this) >> kFailureTagSize;
+ return static_cast<int>(reinterpret_cast<intptr_t>(this) >> kFailureTagSize);
}
@@ -742,7 +757,8 @@
Failure* Failure::Construct(Type type, int value) {
int info = (value << kFailureTypeTagSize) | type;
ASSERT(Smi::IsValid(info)); // Same validation check as in Smi
- return reinterpret_cast<Failure*>((info << kFailureTagSize) | kFailureTag);
+ return reinterpret_cast<Failure*>(
+ static_cast<intptr_t>((info << kFailureTagSize) | kFailureTag));
}
@@ -1476,7 +1492,7 @@
ASSERT(index >= 0 && index < length());
ASSERT(StringShape(this).IsSequential());
- return StringShape(this).IsAsciiRepresentation()
+ return this->IsAsciiRepresentation()
? SeqAsciiString::cast(this)->SeqAsciiStringSet(index, value)
: SeqTwoByteString::cast(this)->SeqTwoByteStringSet(index, value);
}
@@ -1576,11 +1592,6 @@
String* ConsString::first() {
- ASSERT(String::cast(READ_FIELD(this, kSecondOffset))->length() != 0 ||
- StringShape(
- String::cast(
- READ_FIELD(this, kFirstOffset))).IsAsciiRepresentation()
- == StringShape(this).IsAsciiRepresentation());
return String::cast(READ_FIELD(this, kFirstOffset));
}
@@ -1613,10 +1624,6 @@
String* SlicedString::buffer() {
- ASSERT(
- StringShape(
- String::cast(READ_FIELD(this, kBufferOffset))).IsAsciiRepresentation()
- == StringShape(this).IsAsciiRepresentation());
return String::cast(READ_FIELD(this, kBufferOffset));
}