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

Unified Diff: src/runtime.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/objects.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/runtime.cc
diff --git a/src/runtime.cc b/src/runtime.cc
index 5ec33895e44d50f568edeff1b0c944fd4eff5b53..3bae87d5a4f8427431ded12014bab11b667a85b0 100644
--- a/src/runtime.cc
+++ b/src/runtime.cc
@@ -5186,11 +5186,10 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_URIEscape) {
ASSERT(args.length() == 1);
CONVERT_ARG_HANDLE_CHECKED(String, source, 0);
Handle<String> string = FlattenGetString(source);
- String::FlatContent content = string->GetFlatContent();
- ASSERT(content.IsFlat());
- Handle<String> result =
- content.IsAscii() ? URIEscape::Escape<uint8_t>(isolate, source)
- : URIEscape::Escape<uc16>(isolate, source);
+ ASSERT(string->IsFlat());
+ Handle<String> result = string->IsOneByteRepresentationUnderneath()
+ ? URIEscape::Escape<uint8_t>(isolate, source)
+ : URIEscape::Escape<uc16>(isolate, source);
if (result.is_null()) return Failure::OutOfMemoryException(0x12);
return *result;
}
@@ -5201,10 +5200,10 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_URIUnescape) {
ASSERT(args.length() == 1);
CONVERT_ARG_HANDLE_CHECKED(String, source, 0);
Handle<String> string = FlattenGetString(source);
- String::FlatContent content = string->GetFlatContent();
- ASSERT(content.IsFlat());
- return content.IsAscii() ? *URIUnescape::Unescape<uint8_t>(isolate, source)
- : *URIUnescape::Unescape<uc16>(isolate, source);
+ ASSERT(string->IsFlat());
+ return string->IsOneByteRepresentationUnderneath()
+ ? *URIUnescape::Unescape<uint8_t>(isolate, source)
+ : *URIUnescape::Unescape<uc16>(isolate, source);
}
@@ -5733,6 +5732,7 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_StringToArray) {
if (!maybe_obj->ToObject(&obj)) return maybe_obj;
}
elements = Handle<FixedArray>(FixedArray::cast(obj), isolate);
+ AssertNoAllocation no_gc;
String::FlatContent content = s->GetFlatContent();
if (content.IsAscii()) {
Vector<const uint8_t> chars = content.ToOneByteVector();
@@ -6588,6 +6588,7 @@ static Object* FlatStringCompare(String* x, String* y) {
equal_prefix_result = Smi::FromInt(LESS);
}
int r;
+ AssertNoAllocation no_gc;
String::FlatContent x_content = x->GetFlatContent();
String::FlatContent y_content = y->GetFlatContent();
if (x_content.IsAscii()) {
@@ -12835,6 +12836,7 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_Log) {
ASSERT(args.length() == 2);
CONVERT_ARG_CHECKED(String, format, 0);
CONVERT_ARG_CHECKED(JSArray, elms, 1);
+ AssertNoAllocation no_gc;
String::FlatContent format_content = format->GetFlatContent();
RUNTIME_ASSERT(format_content.IsAscii());
Vector<const uint8_t> chars = format_content.ToOneByteVector();
« no previous file with comments | « src/objects.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698