OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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 3529 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3540 } else { | 3540 } else { |
3541 CONVERT_DOUBLE_ARG_CHECKED(from_number, 1); | 3541 CONVERT_DOUBLE_ARG_CHECKED(from_number, 1); |
3542 CONVERT_DOUBLE_ARG_CHECKED(to_number, 2); | 3542 CONVERT_DOUBLE_ARG_CHECKED(to_number, 2); |
3543 start = FastD2IChecked(from_number); | 3543 start = FastD2IChecked(from_number); |
3544 end = FastD2IChecked(to_number); | 3544 end = FastD2IChecked(to_number); |
3545 } | 3545 } |
3546 RUNTIME_ASSERT(end >= start); | 3546 RUNTIME_ASSERT(end >= start); |
3547 RUNTIME_ASSERT(start >= 0); | 3547 RUNTIME_ASSERT(start >= 0); |
3548 RUNTIME_ASSERT(end <= value->length()); | 3548 RUNTIME_ASSERT(end <= value->length()); |
3549 isolate->counters()->sub_string_runtime()->Increment(); | 3549 isolate->counters()->sub_string_runtime()->Increment(); |
| 3550 if (end - start == 1) { |
| 3551 return isolate->heap()->LookupSingleCharacterStringFromCode( |
| 3552 value->Get(start)); |
| 3553 } |
3550 return value->SubString(start, end); | 3554 return value->SubString(start, end); |
3551 } | 3555 } |
3552 | 3556 |
3553 | 3557 |
3554 RUNTIME_FUNCTION(MaybeObject*, Runtime_StringMatch) { | 3558 RUNTIME_FUNCTION(MaybeObject*, Runtime_StringMatch) { |
3555 ASSERT_EQ(3, args.length()); | 3559 ASSERT_EQ(3, args.length()); |
3556 | 3560 |
3557 CONVERT_ARG_HANDLE_CHECKED(String, subject, 0); | 3561 CONVERT_ARG_HANDLE_CHECKED(String, subject, 0); |
3558 CONVERT_ARG_HANDLE_CHECKED(JSRegExp, regexp, 1); | 3562 CONVERT_ARG_HANDLE_CHECKED(JSRegExp, regexp, 1); |
3559 CONVERT_ARG_HANDLE_CHECKED(JSArray, regexp_info, 2); | 3563 CONVERT_ARG_HANDLE_CHECKED(JSArray, regexp_info, 2); |
(...skipping 9968 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
13528 // Handle last resort GC and make sure to allow future allocations | 13532 // Handle last resort GC and make sure to allow future allocations |
13529 // to grow the heap without causing GCs (if possible). | 13533 // to grow the heap without causing GCs (if possible). |
13530 isolate->counters()->gc_last_resort_from_js()->Increment(); | 13534 isolate->counters()->gc_last_resort_from_js()->Increment(); |
13531 isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags, | 13535 isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags, |
13532 "Runtime::PerformGC"); | 13536 "Runtime::PerformGC"); |
13533 } | 13537 } |
13534 } | 13538 } |
13535 | 13539 |
13536 | 13540 |
13537 } } // namespace v8::internal | 13541 } } // namespace v8::internal |
OLD | NEW |