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

Unified Diff: src/objects.cc

Issue 13841012: Add asserts to String::GetFlatContent. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 7 years, 8 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
« no previous file with comments | « src/json-stringifier.h ('k') | src/runtime.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/objects.cc
diff --git a/src/objects.cc b/src/objects.cc
index 1dc170410951f7e01238815dae3b62340e6f6721..d5e28abf8d4b8bff57aad760dc6e3c192d7fedbb 100644
--- a/src/objects.cc
+++ b/src/objects.cc
@@ -6880,6 +6880,7 @@ bool String::LooksValid() {
String::FlatContent String::GetFlatContent() {
+ ASSERT(!GetHeap()->allow_allocation(false));
int length = this->length();
StringShape shape(this);
String* string = this;
@@ -7106,6 +7107,8 @@ void FlatStringReader::PostGarbageCollection() {
if (str_ == NULL) return;
Handle<String> str(str_);
ASSERT(str->IsFlat());
+ AssertNoAllocation no_gc;
+ // This does not actually prevent the vector from being relocated later.
String::FlatContent content = str->GetFlatContent();
ASSERT(content.IsFlat());
is_ascii_ = content.IsAscii();
@@ -7656,6 +7659,7 @@ bool String::IsUtf8EqualTo(Vector<const char> str) {
bool String::IsOneByteEqualTo(Vector<const uint8_t> str) {
int slen = length();
if (str.length() != slen) return false;
+ AssertNoAllocation no_gc;
FlatContent content = GetFlatContent();
if (content.IsAscii()) {
return CompareChars(content.ToOneByteVector().start(),
@@ -7671,6 +7675,7 @@ bool String::IsOneByteEqualTo(Vector<const uint8_t> str) {
bool String::IsTwoByteEqualTo(Vector<const uc16> str) {
int slen = length();
if (str.length() != slen) return false;
+ AssertNoAllocation no_gc;
FlatContent content = GetFlatContent();
if (content.IsTwoByte()) {
return CompareChars(content.ToUC16Vector().start(), str.start(), slen) == 0;
« no previous file with comments | « src/json-stringifier.h ('k') | src/runtime.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698