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 4023 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4034 if (index < static_cast<uint32_t>(string->length())) { | 4034 if (index < static_cast<uint32_t>(string->length())) { |
4035 string->TryFlatten(); | 4035 string->TryFlatten(); |
4036 return LookupSingleCharacterStringFromCode( | 4036 return LookupSingleCharacterStringFromCode( |
4037 string->GetIsolate(), | 4037 string->GetIsolate(), |
4038 string->Get(index)); | 4038 string->Get(index)); |
4039 } | 4039 } |
4040 return Execution::CharAt(string, index); | 4040 return Execution::CharAt(string, index); |
4041 } | 4041 } |
4042 | 4042 |
4043 | 4043 |
| 4044 MaybeObject* Runtime::GetElementOrCharAtOrFail(Isolate* isolate, |
| 4045 Handle<Object> object, |
| 4046 uint32_t index) { |
| 4047 CALL_HEAP_FUNCTION_PASS_EXCEPTION(isolate, |
| 4048 GetElementOrCharAt(isolate, object, index)); |
| 4049 } |
| 4050 |
| 4051 |
4044 MaybeObject* Runtime::GetElementOrCharAt(Isolate* isolate, | 4052 MaybeObject* Runtime::GetElementOrCharAt(Isolate* isolate, |
4045 Handle<Object> object, | 4053 Handle<Object> object, |
4046 uint32_t index) { | 4054 uint32_t index) { |
4047 // Handle [] indexing on Strings | 4055 // Handle [] indexing on Strings |
4048 if (object->IsString()) { | 4056 if (object->IsString()) { |
4049 Handle<Object> result = GetCharAt(Handle<String>::cast(object), index); | 4057 Handle<Object> result = GetCharAt(Handle<String>::cast(object), index); |
4050 if (!result->IsUndefined()) return *result; | 4058 if (!result->IsUndefined()) return *result; |
4051 } | 4059 } |
4052 | 4060 |
4053 // Handle [] indexing on String objects | 4061 // Handle [] indexing on String objects |
(...skipping 9167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
13221 // Handle last resort GC and make sure to allow future allocations | 13229 // Handle last resort GC and make sure to allow future allocations |
13222 // to grow the heap without causing GCs (if possible). | 13230 // to grow the heap without causing GCs (if possible). |
13223 isolate->counters()->gc_last_resort_from_js()->Increment(); | 13231 isolate->counters()->gc_last_resort_from_js()->Increment(); |
13224 isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags, | 13232 isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags, |
13225 "Runtime::PerformGC"); | 13233 "Runtime::PerformGC"); |
13226 } | 13234 } |
13227 } | 13235 } |
13228 | 13236 |
13229 | 13237 |
13230 } } // namespace v8::internal | 13238 } } // namespace v8::internal |
OLD | NEW |