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

Unified Diff: src/runtime.cc

Issue 341031: Reverting 3153 (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: Created 11 years, 2 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 | « no previous file | src/string.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/runtime.cc
===================================================================
--- src/runtime.cc (revision 3160)
+++ src/runtime.cc (working copy)
@@ -1357,9 +1357,8 @@
StringBuilderSubstringPosition::encode(from);
AddElement(Smi::FromInt(encoded_slice));
} else {
- // Otherwise encode as two smis.
- AddElement(Smi::FromInt(-length));
- AddElement(Smi::FromInt(from));
+ Handle<String> slice = Factory::NewStringSlice(subject_, from, to);
+ AddElement(*slice);
}
IncrementCharacterCount(length);
}
@@ -3767,21 +3766,9 @@
for (int i = 0; i < array_length; i++) {
Object* element = fixed_array->get(i);
if (element->IsSmi()) {
- // Smi encoding of position and length.
int encoded_slice = Smi::cast(element)->value();
- int pos;
- int len;
- if (encoded_slice > 0) {
- // Position and length encoded in one smi.
- pos = StringBuilderSubstringPosition::decode(encoded_slice);
- len = StringBuilderSubstringLength::decode(encoded_slice);
- } else {
- // Position and length encoded in two smis.
- Object* obj = fixed_array->get(++i);
- ASSERT(obj->IsSmi());
- pos = Smi::cast(obj)->value();
- len = -encoded_slice;
- }
+ int pos = StringBuilderSubstringPosition::decode(encoded_slice);
+ int len = StringBuilderSubstringLength::decode(encoded_slice);
String::WriteToFlat(special,
sink + position,
pos,
@@ -3802,10 +3789,6 @@
ASSERT(args.length() == 2);
CONVERT_CHECKED(JSArray, array, args[0]);
CONVERT_CHECKED(String, special, args[1]);
-
- // This assumption is used by the slice encoding in one or two smis.
- ASSERT(Smi::kMaxValue >= String::kMaxLength);
-
int special_length = special->length();
Object* smi_array_length = array->length();
if (!smi_array_length->IsSmi()) {
@@ -3833,29 +3816,13 @@
for (int i = 0; i < array_length; i++) {
Object* elt = fixed_array->get(i);
if (elt->IsSmi()) {
- // Smi encoding of position and length.
int len = Smi::cast(elt)->value();
- if (len > 0) {
- // Position and length encoded in one smi.
- int pos = len >> 11;
- len &= 0x7ff;
- if (pos + len > special_length) {
- return Top::Throw(Heap::illegal_argument_symbol());
- }
- position += len;
- } else {
- // Position and length encoded in two smis.
- position += (-len);
- // Get the position and check that it is also a smi.
- i++;
- if (i >= array_length) {
- return Top::Throw(Heap::illegal_argument_symbol());
- }
- Object* pos = fixed_array->get(i);
- if (!pos->IsSmi()) {
- return Top::Throw(Heap::illegal_argument_symbol());
- }
+ int pos = len >> 11;
+ len &= 0x7ff;
+ if (pos + len > special_length) {
+ return Top::Throw(Heap::illegal_argument_symbol());
}
+ position += len;
} else if (elt->IsString()) {
String* element = String::cast(elt);
int element_length = element->length();
« no previous file with comments | « no previous file | src/string.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698