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 2974 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2985 // the check for deletions during a for-in. | 2985 // the check for deletions during a for-in. |
2986 static Object* Runtime_GetPropertyNamesFast(Arguments args) { | 2986 static Object* Runtime_GetPropertyNamesFast(Arguments args) { |
2987 ASSERT(args.length() == 1); | 2987 ASSERT(args.length() == 1); |
2988 | 2988 |
2989 CONVERT_CHECKED(JSObject, raw_object, args[0]); | 2989 CONVERT_CHECKED(JSObject, raw_object, args[0]); |
2990 | 2990 |
2991 if (raw_object->IsSimpleEnum()) return raw_object->map(); | 2991 if (raw_object->IsSimpleEnum()) return raw_object->map(); |
2992 | 2992 |
2993 HandleScope scope; | 2993 HandleScope scope; |
2994 Handle<JSObject> object(raw_object); | 2994 Handle<JSObject> object(raw_object); |
2995 Handle<FixedArray> content = GetKeysInFixedArrayFor(object); | 2995 Handle<FixedArray> content = GetKeysInFixedArrayFor(object, |
| 2996 INCLUDE_PROTOS); |
2996 | 2997 |
2997 // Test again, since cache may have been built by preceding call. | 2998 // Test again, since cache may have been built by preceding call. |
2998 if (object->IsSimpleEnum()) return object->map(); | 2999 if (object->IsSimpleEnum()) return object->map(); |
2999 | 3000 |
3000 return *content; | 3001 return *content; |
3001 } | 3002 } |
3002 | 3003 |
3003 | 3004 |
| 3005 static Object* Runtime_LocalKeys(Arguments args) { |
| 3006 ASSERT_EQ(args.length(), 1); |
| 3007 CONVERT_CHECKED(JSObject, raw_object, args[0]); |
| 3008 HandleScope scope; |
| 3009 Handle<JSObject> object(raw_object); |
| 3010 Handle<FixedArray> contents = GetKeysInFixedArrayFor(object, |
| 3011 LOCAL_ONLY); |
| 3012 // Some fast paths through GetKeysInFixedArrayFor reuse a cached |
| 3013 // property array and since the result is mutable we have to create |
| 3014 // a fresh clone on each invocation. |
| 3015 Handle<FixedArray> copy = Factory::NewFixedArray(contents->length()); |
| 3016 contents->CopyTo(0, *copy, 0, contents->length()); |
| 3017 return *Factory::NewJSArrayWithElements(copy); |
| 3018 } |
| 3019 |
| 3020 |
3004 static Object* Runtime_GetArgumentsProperty(Arguments args) { | 3021 static Object* Runtime_GetArgumentsProperty(Arguments args) { |
3005 NoHandleAllocation ha; | 3022 NoHandleAllocation ha; |
3006 ASSERT(args.length() == 1); | 3023 ASSERT(args.length() == 1); |
3007 | 3024 |
3008 // Compute the frame holding the arguments. | 3025 // Compute the frame holding the arguments. |
3009 JavaScriptFrameIterator it; | 3026 JavaScriptFrameIterator it; |
3010 it.AdvanceToArgumentsFrame(); | 3027 it.AdvanceToArgumentsFrame(); |
3011 JavaScriptFrame* frame = it.frame(); | 3028 JavaScriptFrame* frame = it.frame(); |
3012 | 3029 |
3013 // Get the actual number of provided arguments. | 3030 // Get the actual number of provided arguments. |
(...skipping 2495 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5509 // might have elements. Can either return keys or intervals. Keys can have | 5526 // might have elements. Can either return keys or intervals. Keys can have |
5510 // gaps in (undefined). Intervals can also span over some undefined keys. | 5527 // gaps in (undefined). Intervals can also span over some undefined keys. |
5511 static Object* Runtime_GetArrayKeys(Arguments args) { | 5528 static Object* Runtime_GetArrayKeys(Arguments args) { |
5512 ASSERT(args.length() == 2); | 5529 ASSERT(args.length() == 2); |
5513 HandleScope scope; | 5530 HandleScope scope; |
5514 CONVERT_ARG_CHECKED(JSObject, array, 0); | 5531 CONVERT_ARG_CHECKED(JSObject, array, 0); |
5515 CONVERT_NUMBER_CHECKED(uint32_t, length, Uint32, args[1]); | 5532 CONVERT_NUMBER_CHECKED(uint32_t, length, Uint32, args[1]); |
5516 if (array->elements()->IsDictionary()) { | 5533 if (array->elements()->IsDictionary()) { |
5517 // Create an array and get all the keys into it, then remove all the | 5534 // Create an array and get all the keys into it, then remove all the |
5518 // keys that are not integers in the range 0 to length-1. | 5535 // keys that are not integers in the range 0 to length-1. |
5519 Handle<FixedArray> keys = GetKeysInFixedArrayFor(array); | 5536 Handle<FixedArray> keys = GetKeysInFixedArrayFor(array, INCLUDE_PROTOS); |
5520 int keys_length = keys->length(); | 5537 int keys_length = keys->length(); |
5521 for (int i = 0; i < keys_length; i++) { | 5538 for (int i = 0; i < keys_length; i++) { |
5522 Object* key = keys->get(i); | 5539 Object* key = keys->get(i); |
5523 uint32_t index; | 5540 uint32_t index; |
5524 if (!Array::IndexFromObject(key, &index) || index >= length) { | 5541 if (!Array::IndexFromObject(key, &index) || index >= length) { |
5525 // Zap invalid keys. | 5542 // Zap invalid keys. |
5526 keys->set_undefined(i); | 5543 keys->set_undefined(i); |
5527 } | 5544 } |
5528 } | 5545 } |
5529 return *Factory::NewJSArrayWithElements(keys); | 5546 return *Factory::NewJSArrayWithElements(keys); |
(...skipping 734 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6264 Handle<Context> function_context(frame_context->fcontext()); | 6281 Handle<Context> function_context(frame_context->fcontext()); |
6265 CopyContextLocalsToScopeObject(code, scope_info, | 6282 CopyContextLocalsToScopeObject(code, scope_info, |
6266 function_context, local_scope); | 6283 function_context, local_scope); |
6267 | 6284 |
6268 // Finally copy any properties from the function context extension. This will | 6285 // Finally copy any properties from the function context extension. This will |
6269 // be variables introduced by eval. | 6286 // be variables introduced by eval. |
6270 if (function_context->closure() == *function) { | 6287 if (function_context->closure() == *function) { |
6271 if (function_context->has_extension() && | 6288 if (function_context->has_extension() && |
6272 !function_context->IsGlobalContext()) { | 6289 !function_context->IsGlobalContext()) { |
6273 Handle<JSObject> ext(JSObject::cast(function_context->extension())); | 6290 Handle<JSObject> ext(JSObject::cast(function_context->extension())); |
6274 Handle<FixedArray> keys = GetKeysInFixedArrayFor(ext); | 6291 Handle<FixedArray> keys = GetKeysInFixedArrayFor(ext, INCLUDE_PROTOS); |
6275 for (int i = 0; i < keys->length(); i++) { | 6292 for (int i = 0; i < keys->length(); i++) { |
6276 // Names of variables introduced by eval are strings. | 6293 // Names of variables introduced by eval are strings. |
6277 ASSERT(keys->get(i)->IsString()); | 6294 ASSERT(keys->get(i)->IsString()); |
6278 Handle<String> key(String::cast(keys->get(i))); | 6295 Handle<String> key(String::cast(keys->get(i))); |
6279 SetProperty(local_scope, key, GetProperty(ext, key), NONE); | 6296 SetProperty(local_scope, key, GetProperty(ext, key), NONE); |
6280 } | 6297 } |
6281 } | 6298 } |
6282 } | 6299 } |
6283 return local_scope; | 6300 return local_scope; |
6284 } | 6301 } |
(...skipping 28 matching lines...) Expand all Loading... |
6313 } | 6330 } |
6314 } | 6331 } |
6315 | 6332 |
6316 // Fill all context locals to the context extension. | 6333 // Fill all context locals to the context extension. |
6317 CopyContextLocalsToScopeObject(code, scope_info, context, closure_scope); | 6334 CopyContextLocalsToScopeObject(code, scope_info, context, closure_scope); |
6318 | 6335 |
6319 // Finally copy any properties from the function context extension. This will | 6336 // Finally copy any properties from the function context extension. This will |
6320 // be variables introduced by eval. | 6337 // be variables introduced by eval. |
6321 if (context->has_extension()) { | 6338 if (context->has_extension()) { |
6322 Handle<JSObject> ext(JSObject::cast(context->extension())); | 6339 Handle<JSObject> ext(JSObject::cast(context->extension())); |
6323 Handle<FixedArray> keys = GetKeysInFixedArrayFor(ext); | 6340 Handle<FixedArray> keys = GetKeysInFixedArrayFor(ext, INCLUDE_PROTOS); |
6324 for (int i = 0; i < keys->length(); i++) { | 6341 for (int i = 0; i < keys->length(); i++) { |
6325 // Names of variables introduced by eval are strings. | 6342 // Names of variables introduced by eval are strings. |
6326 ASSERT(keys->get(i)->IsString()); | 6343 ASSERT(keys->get(i)->IsString()); |
6327 Handle<String> key(String::cast(keys->get(i))); | 6344 Handle<String> key(String::cast(keys->get(i))); |
6328 SetProperty(closure_scope, key, GetProperty(ext, key), NONE); | 6345 SetProperty(closure_scope, key, GetProperty(ext, key), NONE); |
6329 } | 6346 } |
6330 } | 6347 } |
6331 | 6348 |
6332 return closure_scope; | 6349 return closure_scope; |
6333 } | 6350 } |
(...skipping 1375 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7709 } else { | 7726 } else { |
7710 // Handle last resort GC and make sure to allow future allocations | 7727 // Handle last resort GC and make sure to allow future allocations |
7711 // to grow the heap without causing GCs (if possible). | 7728 // to grow the heap without causing GCs (if possible). |
7712 Counters::gc_last_resort_from_js.Increment(); | 7729 Counters::gc_last_resort_from_js.Increment(); |
7713 Heap::CollectAllGarbage(false); | 7730 Heap::CollectAllGarbage(false); |
7714 } | 7731 } |
7715 } | 7732 } |
7716 | 7733 |
7717 | 7734 |
7718 } } // namespace v8::internal | 7735 } } // namespace v8::internal |
OLD | NEW |