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