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 4194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4205 } | 4205 } |
4206 return Heap::undefined_value(); | 4206 return Heap::undefined_value(); |
4207 } | 4207 } |
4208 | 4208 |
4209 | 4209 |
4210 static MaybeObject* Runtime_LocalKeys(Arguments args) { | 4210 static MaybeObject* Runtime_LocalKeys(Arguments args) { |
4211 ASSERT_EQ(args.length(), 1); | 4211 ASSERT_EQ(args.length(), 1); |
4212 CONVERT_CHECKED(JSObject, raw_object, args[0]); | 4212 CONVERT_CHECKED(JSObject, raw_object, args[0]); |
4213 HandleScope scope; | 4213 HandleScope scope; |
4214 Handle<JSObject> object(raw_object); | 4214 Handle<JSObject> object(raw_object); |
| 4215 |
| 4216 if (object->IsJSGlobalProxy()) { |
| 4217 Handle<Object> proto(object->GetPrototype()); |
| 4218 // If proxy is detached we simply return an empty array. |
| 4219 if (proto->IsNull()) return *Factory::NewJSArray(0); |
| 4220 object = Handle<JSObject>::cast(proto); |
| 4221 } |
| 4222 |
4215 Handle<FixedArray> contents = GetKeysInFixedArrayFor(object, | 4223 Handle<FixedArray> contents = GetKeysInFixedArrayFor(object, |
4216 LOCAL_ONLY); | 4224 LOCAL_ONLY); |
4217 // Some fast paths through GetKeysInFixedArrayFor reuse a cached | 4225 // Some fast paths through GetKeysInFixedArrayFor reuse a cached |
4218 // property array and since the result is mutable we have to create | 4226 // property array and since the result is mutable we have to create |
4219 // a fresh clone on each invocation. | 4227 // a fresh clone on each invocation. |
4220 int length = contents->length(); | 4228 int length = contents->length(); |
4221 Handle<FixedArray> copy = Factory::NewFixedArray(length); | 4229 Handle<FixedArray> copy = Factory::NewFixedArray(length); |
4222 for (int i = 0; i < length; i++) { | 4230 for (int i = 0; i < length; i++) { |
4223 Object* entry = contents->get(i); | 4231 Object* entry = contents->get(i); |
4224 if (entry->IsString()) { | 4232 if (entry->IsString()) { |
(...skipping 6873 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
11098 } else { | 11106 } else { |
11099 // Handle last resort GC and make sure to allow future allocations | 11107 // Handle last resort GC and make sure to allow future allocations |
11100 // to grow the heap without causing GCs (if possible). | 11108 // to grow the heap without causing GCs (if possible). |
11101 Counters::gc_last_resort_from_js.Increment(); | 11109 Counters::gc_last_resort_from_js.Increment(); |
11102 Heap::CollectAllGarbage(false); | 11110 Heap::CollectAllGarbage(false); |
11103 } | 11111 } |
11104 } | 11112 } |
11105 | 11113 |
11106 | 11114 |
11107 } } // namespace v8::internal | 11115 } } // namespace v8::internal |
OLD | NEW |