OLD | NEW |
1 // Copyright 2010 the V8 project authors. All rights reserved. | 1 // Copyright 2010 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 3469 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3480 value = JSGlobalPropertyCell::cast(value)->value(); | 3480 value = JSGlobalPropertyCell::cast(value)->value(); |
3481 if (!value->IsTheHole()) return value; | 3481 if (!value->IsTheHole()) return value; |
3482 // If value is the hole do the general lookup. | 3482 // If value is the hole do the general lookup. |
3483 } | 3483 } |
3484 } | 3484 } |
3485 } else if (args[0]->IsString() && args[1]->IsSmi()) { | 3485 } else if (args[0]->IsString() && args[1]->IsSmi()) { |
3486 // Fast case for string indexing using [] with a smi index. | 3486 // Fast case for string indexing using [] with a smi index. |
3487 HandleScope scope; | 3487 HandleScope scope; |
3488 Handle<String> str = args.at<String>(0); | 3488 Handle<String> str = args.at<String>(0); |
3489 int index = Smi::cast(args[1])->value(); | 3489 int index = Smi::cast(args[1])->value(); |
3490 Handle<Object> result = GetCharAt(str, index); | 3490 if (index >= 0 && index < str->length()) { |
3491 return *result; | 3491 Handle<Object> result = GetCharAt(str, index); |
| 3492 return *result; |
| 3493 } |
3492 } | 3494 } |
3493 | 3495 |
3494 // Fall back to GetObjectProperty. | 3496 // Fall back to GetObjectProperty. |
3495 return Runtime::GetObjectProperty(args.at<Object>(0), | 3497 return Runtime::GetObjectProperty(args.at<Object>(0), |
3496 args.at<Object>(1)); | 3498 args.at<Object>(1)); |
3497 } | 3499 } |
3498 | 3500 |
3499 | 3501 |
3500 static MaybeObject* Runtime_DefineOrRedefineAccessorProperty(Arguments args) { | 3502 static MaybeObject* Runtime_DefineOrRedefineAccessorProperty(Arguments args) { |
3501 ASSERT(args.length() == 5); | 3503 ASSERT(args.length() == 5); |
(...skipping 7368 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
10870 } else { | 10872 } else { |
10871 // Handle last resort GC and make sure to allow future allocations | 10873 // Handle last resort GC and make sure to allow future allocations |
10872 // to grow the heap without causing GCs (if possible). | 10874 // to grow the heap without causing GCs (if possible). |
10873 Counters::gc_last_resort_from_js.Increment(); | 10875 Counters::gc_last_resort_from_js.Increment(); |
10874 Heap::CollectAllGarbage(false); | 10876 Heap::CollectAllGarbage(false); |
10875 } | 10877 } |
10876 } | 10878 } |
10877 | 10879 |
10878 | 10880 |
10879 } } // namespace v8::internal | 10881 } } // namespace v8::internal |
OLD | NEW |