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 2706 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2717 NoHandleAllocation ha; | 2717 NoHandleAllocation ha; |
2718 ASSERT(args.length() == 2); | 2718 ASSERT(args.length() == 2); |
2719 | 2719 |
2720 Handle<Object> object = args.at<Object>(0); | 2720 Handle<Object> object = args.at<Object>(0); |
2721 Handle<Object> key = args.at<Object>(1); | 2721 Handle<Object> key = args.at<Object>(1); |
2722 | 2722 |
2723 return Runtime::GetObjectProperty(object, key); | 2723 return Runtime::GetObjectProperty(object, key); |
2724 } | 2724 } |
2725 | 2725 |
2726 | 2726 |
2727 | |
2728 // KeyedStringGetProperty is called from KeyedLoadIC::GenerateGeneric. | 2727 // KeyedStringGetProperty is called from KeyedLoadIC::GenerateGeneric. |
2729 static Object* Runtime_KeyedGetProperty(Arguments args) { | 2728 static Object* Runtime_KeyedGetProperty(Arguments args) { |
2730 NoHandleAllocation ha; | 2729 NoHandleAllocation ha; |
2731 ASSERT(args.length() == 2); | 2730 ASSERT(args.length() == 2); |
2732 | 2731 |
2733 // Fast cases for getting named properties of the receiver JSObject | 2732 // Fast cases for getting named properties of the receiver JSObject |
2734 // itself. | 2733 // itself. |
2735 // | 2734 // |
2736 // The global proxy objects has to be excluded since LocalLookup on | 2735 // The global proxy objects has to be excluded since LocalLookup on |
2737 // the global proxy object can return a valid result even though the | 2736 // the global proxy object can return a valid result even though the |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2769 int entry = dictionary->FindEntry(key); | 2768 int entry = dictionary->FindEntry(key); |
2770 if ((entry != StringDictionary::kNotFound) && | 2769 if ((entry != StringDictionary::kNotFound) && |
2771 (dictionary->DetailsAt(entry).type() == NORMAL)) { | 2770 (dictionary->DetailsAt(entry).type() == NORMAL)) { |
2772 Object* value = dictionary->ValueAt(entry); | 2771 Object* value = dictionary->ValueAt(entry); |
2773 if (!receiver->IsGlobalObject()) return value; | 2772 if (!receiver->IsGlobalObject()) return value; |
2774 value = JSGlobalPropertyCell::cast(value)->value(); | 2773 value = JSGlobalPropertyCell::cast(value)->value(); |
2775 if (!value->IsTheHole()) return value; | 2774 if (!value->IsTheHole()) return value; |
2776 // If value is the hole do the general lookup. | 2775 // If value is the hole do the general lookup. |
2777 } | 2776 } |
2778 } | 2777 } |
| 2778 } else if (args[0]->IsString() && args[1]->IsSmi()) { |
| 2779 // Fast case for string indexing using [] with a smi index. |
| 2780 HandleScope scope; |
| 2781 Handle<String> str = args.at<String>(0); |
| 2782 int index = Smi::cast(args[1])->value(); |
| 2783 Handle<Object> result = GetCharAt(str, index); |
| 2784 return *result; |
2779 } | 2785 } |
2780 | 2786 |
2781 // Fall back to GetObjectProperty. | 2787 // Fall back to GetObjectProperty. |
2782 return Runtime::GetObjectProperty(args.at<Object>(0), | 2788 return Runtime::GetObjectProperty(args.at<Object>(0), |
2783 args.at<Object>(1)); | 2789 args.at<Object>(1)); |
2784 } | 2790 } |
2785 | 2791 |
2786 | 2792 |
2787 Object* Runtime::SetObjectProperty(Handle<Object> object, | 2793 Object* Runtime::SetObjectProperty(Handle<Object> object, |
2788 Handle<Object> key, | 2794 Handle<Object> key, |
(...skipping 5253 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8042 } else { | 8048 } else { |
8043 // Handle last resort GC and make sure to allow future allocations | 8049 // Handle last resort GC and make sure to allow future allocations |
8044 // to grow the heap without causing GCs (if possible). | 8050 // to grow the heap without causing GCs (if possible). |
8045 Counters::gc_last_resort_from_js.Increment(); | 8051 Counters::gc_last_resort_from_js.Increment(); |
8046 Heap::CollectAllGarbage(false); | 8052 Heap::CollectAllGarbage(false); |
8047 } | 8053 } |
8048 } | 8054 } |
8049 | 8055 |
8050 | 8056 |
8051 } } // namespace v8::internal | 8057 } } // namespace v8::internal |
OLD | NEW |