| OLD | NEW |
| 1 // Copyright 2006-2009 the V8 project authors. All rights reserved. | 1 // Copyright 2006-2009 the V8 project authors. All rights reserved. |
| 2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
| 3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
| 4 // met: | 4 // met: |
| 5 // | 5 // |
| 6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
| 7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
| 8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
| 9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
| 10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
| (...skipping 1625 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1636 subject_length); | 1636 subject_length); |
| 1637 } else { | 1637 } else { |
| 1638 ASSERT(replacement->IsTwoByteRepresentation()); | 1638 ASSERT(replacement->IsTwoByteRepresentation()); |
| 1639 AssertNoAllocation no_alloc; | 1639 AssertNoAllocation no_alloc; |
| 1640 | 1640 |
| 1641 ParseReplacementPattern(&parts_, | 1641 ParseReplacementPattern(&parts_, |
| 1642 replacement->ToUC16Vector(), | 1642 replacement->ToUC16Vector(), |
| 1643 capture_count, | 1643 capture_count, |
| 1644 subject_length); | 1644 subject_length); |
| 1645 } | 1645 } |
| 1646 // Find substrings of replacement string and create them as String objects.. | 1646 // Find substrings of replacement string and create them as String objects. |
| 1647 int substring_index = 0; | 1647 int substring_index = 0; |
| 1648 for (int i = 0, n = parts_.length(); i < n; i++) { | 1648 for (int i = 0, n = parts_.length(); i < n; i++) { |
| 1649 int tag = parts_[i].tag; | 1649 int tag = parts_[i].tag; |
| 1650 if (tag <= 0) { // A replacement string slice. | 1650 if (tag <= 0) { // A replacement string slice. |
| 1651 int from = -tag; | 1651 int from = -tag; |
| 1652 int to = parts_[i].data; | 1652 int to = parts_[i].data; |
| 1653 replacement_substrings_.Add(Factory::NewStringSlice(replacement, | 1653 replacement_substrings_.Add(Factory::NewSubString(replacement, from, to)); |
| 1654 from, | |
| 1655 to)); | |
| 1656 parts_[i].tag = REPLACEMENT_SUBSTRING; | 1654 parts_[i].tag = REPLACEMENT_SUBSTRING; |
| 1657 parts_[i].data = substring_index; | 1655 parts_[i].data = substring_index; |
| 1658 substring_index++; | 1656 substring_index++; |
| 1659 } else if (tag == REPLACEMENT_STRING) { | 1657 } else if (tag == REPLACEMENT_STRING) { |
| 1660 replacement_substrings_.Add(replacement); | 1658 replacement_substrings_.Add(replacement); |
| 1661 parts_[i].data = substring_index; | 1659 parts_[i].data = substring_index; |
| 1662 substring_index++; | 1660 substring_index++; |
| 1663 } | 1661 } |
| 1664 } | 1662 } |
| 1665 } | 1663 } |
| (...skipping 678 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2344 for (int i = 0; i < end; i++) { | 2342 for (int i = 0; i < end; i++) { |
| 2345 uint16_t char1 = buf1.GetNext(); | 2343 uint16_t char1 = buf1.GetNext(); |
| 2346 uint16_t char2 = buf2.GetNext(); | 2344 uint16_t char2 = buf2.GetNext(); |
| 2347 if (char1 != char2) return Smi::FromInt(char1 - char2); | 2345 if (char1 != char2) return Smi::FromInt(char1 - char2); |
| 2348 } | 2346 } |
| 2349 | 2347 |
| 2350 return Smi::FromInt(str1_length - str2_length); | 2348 return Smi::FromInt(str1_length - str2_length); |
| 2351 } | 2349 } |
| 2352 | 2350 |
| 2353 | 2351 |
| 2354 static Object* Runtime_StringSlice(Arguments args) { | 2352 static Object* Runtime_SubString(Arguments args) { |
| 2355 NoHandleAllocation ha; | 2353 NoHandleAllocation ha; |
| 2356 ASSERT(args.length() == 3); | 2354 ASSERT(args.length() == 3); |
| 2357 | 2355 |
| 2358 CONVERT_CHECKED(String, value, args[0]); | 2356 CONVERT_CHECKED(String, value, args[0]); |
| 2359 CONVERT_DOUBLE_CHECKED(from_number, args[1]); | 2357 CONVERT_DOUBLE_CHECKED(from_number, args[1]); |
| 2360 CONVERT_DOUBLE_CHECKED(to_number, args[2]); | 2358 CONVERT_DOUBLE_CHECKED(to_number, args[2]); |
| 2361 | 2359 |
| 2362 int start = FastD2I(from_number); | 2360 int start = FastD2I(from_number); |
| 2363 int end = FastD2I(to_number); | 2361 int end = FastD2I(to_number); |
| 2364 | 2362 |
| 2365 RUNTIME_ASSERT(end >= start); | 2363 RUNTIME_ASSERT(end >= start); |
| 2366 RUNTIME_ASSERT(start >= 0); | 2364 RUNTIME_ASSERT(start >= 0); |
| 2367 RUNTIME_ASSERT(end <= value->length()); | 2365 RUNTIME_ASSERT(end <= value->length()); |
| 2368 return value->Slice(start, end); | 2366 return value->SubString(start, end); |
| 2369 } | 2367 } |
| 2370 | 2368 |
| 2371 | 2369 |
| 2372 static Object* Runtime_StringMatch(Arguments args) { | 2370 static Object* Runtime_StringMatch(Arguments args) { |
| 2373 ASSERT_EQ(3, args.length()); | 2371 ASSERT_EQ(3, args.length()); |
| 2374 | 2372 |
| 2375 CONVERT_ARG_CHECKED(String, subject, 0); | 2373 CONVERT_ARG_CHECKED(String, subject, 0); |
| 2376 CONVERT_ARG_CHECKED(JSRegExp, regexp, 1); | 2374 CONVERT_ARG_CHECKED(JSRegExp, regexp, 1); |
| 2377 CONVERT_ARG_CHECKED(JSArray, regexp_info, 2); | 2375 CONVERT_ARG_CHECKED(JSArray, regexp_info, 2); |
| 2378 HandleScope handles; | 2376 HandleScope handles; |
| (...skipping 26 matching lines...) Expand all Loading... |
| 2405 match = RegExpImpl::Exec(regexp, subject, index, regexp_info); | 2403 match = RegExpImpl::Exec(regexp, subject, index, regexp_info); |
| 2406 if (match.is_null()) { | 2404 if (match.is_null()) { |
| 2407 return Failure::Exception(); | 2405 return Failure::Exception(); |
| 2408 } | 2406 } |
| 2409 } while (!match->IsNull()); | 2407 } while (!match->IsNull()); |
| 2410 int matches = offsets.length() / 2; | 2408 int matches = offsets.length() / 2; |
| 2411 Handle<FixedArray> elements = Factory::NewFixedArray(matches); | 2409 Handle<FixedArray> elements = Factory::NewFixedArray(matches); |
| 2412 for (int i = 0; i < matches ; i++) { | 2410 for (int i = 0; i < matches ; i++) { |
| 2413 int from = offsets.at(i * 2); | 2411 int from = offsets.at(i * 2); |
| 2414 int to = offsets.at(i * 2 + 1); | 2412 int to = offsets.at(i * 2 + 1); |
| 2415 elements->set(i, *Factory::NewStringSlice(subject, from, to)); | 2413 elements->set(i, *Factory::NewSubString(subject, from, to)); |
| 2416 } | 2414 } |
| 2417 Handle<JSArray> result = Factory::NewJSArrayWithElements(elements); | 2415 Handle<JSArray> result = Factory::NewJSArrayWithElements(elements); |
| 2418 result->set_length(Smi::FromInt(matches)); | 2416 result->set_length(Smi::FromInt(matches)); |
| 2419 return *result; | 2417 return *result; |
| 2420 } | 2418 } |
| 2421 | 2419 |
| 2422 | 2420 |
| 2423 static Object* Runtime_NumberToRadixString(Arguments args) { | 2421 static Object* Runtime_NumberToRadixString(Arguments args) { |
| 2424 NoHandleAllocation ha; | 2422 NoHandleAllocation ha; |
| 2425 ASSERT(args.length() == 2); | 2423 ASSERT(args.length() == 2); |
| (...skipping 1180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3606 left++; | 3604 left++; |
| 3607 } | 3605 } |
| 3608 } | 3606 } |
| 3609 | 3607 |
| 3610 int right = length; | 3608 int right = length; |
| 3611 if (trimRight) { | 3609 if (trimRight) { |
| 3612 while (right > left && IsTrimWhiteSpace(s->Get(right - 1))) { | 3610 while (right > left && IsTrimWhiteSpace(s->Get(right - 1))) { |
| 3613 right--; | 3611 right--; |
| 3614 } | 3612 } |
| 3615 } | 3613 } |
| 3616 return s->Slice(left, right); | 3614 return s->SubString(left, right); |
| 3617 } | 3615 } |
| 3618 | 3616 |
| 3619 bool Runtime::IsUpperCaseChar(uint16_t ch) { | 3617 bool Runtime::IsUpperCaseChar(uint16_t ch) { |
| 3620 unibrow::uchar chars[unibrow::ToUppercase::kMaxWidth]; | 3618 unibrow::uchar chars[unibrow::ToUppercase::kMaxWidth]; |
| 3621 int char_length = to_upper_mapping.get(ch, 0, chars); | 3619 int char_length = to_upper_mapping.get(ch, 0, chars); |
| 3622 return char_length == 0; | 3620 return char_length == 0; |
| 3623 } | 3621 } |
| 3624 | 3622 |
| 3625 | 3623 |
| 3626 static Object* Runtime_NumberToString(Arguments args) { | 3624 static Object* Runtime_NumberToString(Arguments args) { |
| (...skipping 4259 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7886 } else { | 7884 } else { |
| 7887 // Handle last resort GC and make sure to allow future allocations | 7885 // Handle last resort GC and make sure to allow future allocations |
| 7888 // to grow the heap without causing GCs (if possible). | 7886 // to grow the heap without causing GCs (if possible). |
| 7889 Counters::gc_last_resort_from_js.Increment(); | 7887 Counters::gc_last_resort_from_js.Increment(); |
| 7890 Heap::CollectAllGarbage(false); | 7888 Heap::CollectAllGarbage(false); |
| 7891 } | 7889 } |
| 7892 } | 7890 } |
| 7893 | 7891 |
| 7894 | 7892 |
| 7895 } } // namespace v8::internal | 7893 } } // namespace v8::internal |
| OLD | NEW |