Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(196)

Side by Side Diff: src/runtime.cc

Issue 8113001: Check enumerability of array indices correctly in propertyIsEnumerable. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Address review comments. Created 9 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright 2011 the V8 project authors. All rights reserved. 1 // Copyright 2011 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 4686 matching lines...) Expand 10 before | Expand all | Expand 10 after
4697 4697
4698 RUNTIME_FUNCTION(MaybeObject*, Runtime_IsPropertyEnumerable) { 4698 RUNTIME_FUNCTION(MaybeObject*, Runtime_IsPropertyEnumerable) {
4699 NoHandleAllocation ha; 4699 NoHandleAllocation ha;
4700 ASSERT(args.length() == 2); 4700 ASSERT(args.length() == 2);
4701 4701
4702 CONVERT_CHECKED(JSObject, object, args[0]); 4702 CONVERT_CHECKED(JSObject, object, args[0]);
4703 CONVERT_CHECKED(String, key, args[1]); 4703 CONVERT_CHECKED(String, key, args[1]);
4704 4704
4705 uint32_t index; 4705 uint32_t index;
4706 if (key->AsArrayIndex(&index)) { 4706 if (key->AsArrayIndex(&index)) {
4707 return isolate->heap()->ToBoolean(object->HasElement(index)); 4707 JSObject::LocalElementType type = object->HasLocalElement(index);
4708 switch (type) {
4709 case JSObject::UNDEFINED_ELEMENT:
4710 case JSObject::STRING_CHARACTER_ELEMENT:
4711 return isolate->heap()->false_value();
4712 case JSObject::INTERCEPTED_ELEMENT:
4713 case JSObject::FAST_ELEMENT:
4714 return isolate->heap()->true_value();
4715 case JSObject::DICTIONARY_ELEMENT: {
4716 if (object->IsJSGlobalProxy()) {
4717 Object* proto = object->GetPrototype();
4718 if (proto->IsNull()) {
4719 return isolate->heap()->false_value();
4720 }
4721 ASSERT(proto->IsJSGlobalObject());
4722 object = JSObject::cast(proto);
4723 }
4724 FixedArray* elements = FixedArray::cast(object->elements());
4725 NumberDictionary* dictionary = NULL;
4726 if (elements->map() ==
4727 isolate->heap()->non_strict_arguments_elements_map()) {
4728 dictionary = NumberDictionary::cast(elements->get(1));
4729 } else {
4730 dictionary = NumberDictionary::cast(elements);
4731 }
4732 int entry = dictionary->FindEntry(index);
4733 ASSERT(entry != NumberDictionary::kNotFound);
4734 PropertyDetails details = dictionary->DetailsAt(entry);
4735 return isolate->heap()->ToBoolean(!details.IsDontEnum());
4736 }
4737 }
4708 } 4738 }
4709 4739
4710 PropertyAttributes att = object->GetLocalPropertyAttribute(key); 4740 PropertyAttributes att = object->GetLocalPropertyAttribute(key);
4711 return isolate->heap()->ToBoolean(att != ABSENT && (att & DONT_ENUM) == 0); 4741 return isolate->heap()->ToBoolean(att != ABSENT && (att & DONT_ENUM) == 0);
4712 } 4742 }
4713 4743
4714 4744
4715 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetPropertyNames) { 4745 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetPropertyNames) {
4716 HandleScope scope(isolate); 4746 HandleScope scope(isolate);
4717 ASSERT(args.length() == 1); 4747 ASSERT(args.length() == 1);
(...skipping 8499 matching lines...) Expand 10 before | Expand all | Expand 10 after
13217 } else { 13247 } else {
13218 // Handle last resort GC and make sure to allow future allocations 13248 // Handle last resort GC and make sure to allow future allocations
13219 // to grow the heap without causing GCs (if possible). 13249 // to grow the heap without causing GCs (if possible).
13220 isolate->counters()->gc_last_resort_from_js()->Increment(); 13250 isolate->counters()->gc_last_resort_from_js()->Increment();
13221 isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags); 13251 isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags);
13222 } 13252 }
13223 } 13253 }
13224 13254
13225 13255
13226 } } // namespace v8::internal 13256 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « no previous file | test/mjsunit/regress/regress-1692.js » ('j') | test/mjsunit/regress/regress-1692.js » ('J')

Powered by Google App Engine
This is Rietveld 408576698