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

Unified Diff: src/runtime.cc

Issue 59973004: Revert "Handlify concat string and substring." (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 7 years, 1 month 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') | test/mjsunit/string-slices.js » ('j') | 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 551d4d346f0f868cfb8b8c368369fc9d19d8216a..dd36a53929aa18c5cd0207d3db7561e1196cfd41 100644
--- a/src/runtime.cc
+++ b/src/runtime.cc
@@ -4387,10 +4387,10 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_StringLocaleCompare) {
RUNTIME_FUNCTION(MaybeObject*, Runtime_SubString) {
- HandleScope scope(isolate);
+ SealHandleScope shs(isolate);
ASSERT(args.length() == 3);
- CONVERT_ARG_HANDLE_CHECKED(String, string, 0);
+ CONVERT_ARG_CHECKED(String, value, 0);
int start, end;
// We have a fast integer-only case here to avoid a conversion to double in
// the common case where from and to are Smis.
@@ -4407,10 +4407,13 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_SubString) {
}
RUNTIME_ASSERT(end >= start);
RUNTIME_ASSERT(start >= 0);
- RUNTIME_ASSERT(end <= string->length());
+ RUNTIME_ASSERT(end <= value->length());
isolate->counters()->sub_string_runtime()->Increment();
-
- return *isolate->factory()->NewSubString(string, start, end);
+ if (end - start == 1) {
+ return isolate->heap()->LookupSingleCharacterStringFromCode(
+ value->Get(start));
+ }
+ return value->SubString(start, end);
}
@@ -6497,31 +6500,30 @@ static inline bool IsTrimWhiteSpace(unibrow::uchar c) {
RUNTIME_FUNCTION(MaybeObject*, Runtime_StringTrim) {
- HandleScope scope(isolate);
+ SealHandleScope shs(isolate);
ASSERT(args.length() == 3);
- CONVERT_ARG_HANDLE_CHECKED(String, string, 0);
+ CONVERT_ARG_CHECKED(String, s, 0);
CONVERT_BOOLEAN_ARG_CHECKED(trimLeft, 1);
CONVERT_BOOLEAN_ARG_CHECKED(trimRight, 2);
- string = FlattenGetString(string);
- int length = string->length();
+ s->TryFlatten();
+ int length = s->length();
int left = 0;
if (trimLeft) {
- while (left < length && IsTrimWhiteSpace(string->Get(left))) {
+ while (left < length && IsTrimWhiteSpace(s->Get(left))) {
left++;
}
}
int right = length;
if (trimRight) {
- while (right > left && IsTrimWhiteSpace(string->Get(right - 1))) {
+ while (right > left && IsTrimWhiteSpace(s->Get(right - 1))) {
right--;
}
}
-
- return *isolate->factory()->NewSubString(string, left, right);
+ return s->SubString(left, right);
}
@@ -6924,12 +6926,12 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_NumberImul) {
RUNTIME_FUNCTION(MaybeObject*, Runtime_StringAdd) {
- HandleScope scope(isolate);
+ SealHandleScope shs(isolate);
ASSERT(args.length() == 2);
- CONVERT_ARG_HANDLE_CHECKED(String, str1, 0);
- CONVERT_ARG_HANDLE_CHECKED(String, str2, 1);
+ CONVERT_ARG_CHECKED(String, str1, 0);
+ CONVERT_ARG_CHECKED(String, str2, 1);
isolate->counters()->string_add_runtime()->Increment();
- return *isolate->factory()->NewConsString(str1, str2);
+ return isolate->heap()->AllocateConsString(str1, str2);
}
« no previous file with comments | « src/objects.cc ('k') | test/mjsunit/string-slices.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698