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

Side by Side Diff: src/runtime.cc

Issue 3358025: Fix bug in Array.prototype.indexOf/lastIndexOf when called on non-sparse non-arrays. (Closed)
Patch Set: Few more tests and lint fixes Created 10 years, 3 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
« no previous file with comments | « no previous file | test/mjsunit/array-indexing.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 7964 matching lines...) Expand 10 before | Expand all | Expand 10 after
7975 to->set_map(Map::cast(new_map)); 7975 to->set_map(Map::cast(new_map));
7976 to->set_elements(new_elements); 7976 to->set_elements(new_elements);
7977 to->set_length(from->length()); 7977 to->set_length(from->length());
7978 Object* obj = from->ResetElements(); 7978 Object* obj = from->ResetElements();
7979 if (obj->IsFailure()) return obj; 7979 if (obj->IsFailure()) return obj;
7980 from->set_length(Smi::FromInt(0)); 7980 from->set_length(Smi::FromInt(0));
7981 return to; 7981 return to;
7982 } 7982 }
7983 7983
7984 7984
7985 // How many elements does this array have? 7985 // How many elements does this object/array have?
7986 static Object* Runtime_EstimateNumberOfElements(Arguments args) { 7986 static Object* Runtime_EstimateNumberOfElements(Arguments args) {
7987 ASSERT(args.length() == 1); 7987 ASSERT(args.length() == 1);
7988 CONVERT_CHECKED(JSArray, array, args[0]); 7988 CONVERT_CHECKED(JSObject, object, args[0]);
7989 HeapObject* elements = array->elements(); 7989 HeapObject* elements = object->elements();
7990 if (elements->IsDictionary()) { 7990 if (elements->IsDictionary()) {
7991 return Smi::FromInt(NumberDictionary::cast(elements)->NumberOfElements()); 7991 return Smi::FromInt(NumberDictionary::cast(elements)->NumberOfElements());
7992 } else if (object->IsJSArray()) {
7993 return JSArray::cast(object)->length();
7992 } else { 7994 } else {
7993 return array->length(); 7995 return Smi::FromInt(FixedArray::cast(elements)->length());
7994 } 7996 }
7995 } 7997 }
7996 7998
7997 7999
7998 static Object* Runtime_SwapElements(Arguments args) { 8000 static Object* Runtime_SwapElements(Arguments args) {
7999 HandleScope handle_scope; 8001 HandleScope handle_scope;
8000 8002
8001 ASSERT_EQ(3, args.length()); 8003 ASSERT_EQ(3, args.length());
8002 8004
8003 CONVERT_ARG_CHECKED(JSObject, object, 0); 8005 CONVERT_ARG_CHECKED(JSObject, object, 0);
(...skipping 2529 matching lines...) Expand 10 before | Expand all | Expand 10 after
10533 } else { 10535 } else {
10534 // Handle last resort GC and make sure to allow future allocations 10536 // Handle last resort GC and make sure to allow future allocations
10535 // to grow the heap without causing GCs (if possible). 10537 // to grow the heap without causing GCs (if possible).
10536 Counters::gc_last_resort_from_js.Increment(); 10538 Counters::gc_last_resort_from_js.Increment();
10537 Heap::CollectAllGarbage(false); 10539 Heap::CollectAllGarbage(false);
10538 } 10540 }
10539 } 10541 }
10540 10542
10541 10543
10542 } } // namespace v8::internal 10544 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « no previous file | test/mjsunit/array-indexing.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698