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

Side by Side Diff: src/builtins.cc

Issue 40163: Arrays created with new Array(n) are not assumed to be sparse unless the give... (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: Created 11 years, 9 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
« no previous file with comments | « no previous file | src/objects.h » ('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-2008 the V8 project authors. All rights reserved. 1 // Copyright 2006-2008 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 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
148 } 148 }
149 149
150 // 'array' now contains the JSArray we should initialize. 150 // 'array' now contains the JSArray we should initialize.
151 151
152 // Optimize the case where there is one argument and the argument is a 152 // Optimize the case where there is one argument and the argument is a
153 // small smi. 153 // small smi.
154 if (__argc__ == 2) { 154 if (__argc__ == 2) {
155 Object* obj = BUILTIN_ARG(1); 155 Object* obj = BUILTIN_ARG(1);
156 if (obj->IsSmi()) { 156 if (obj->IsSmi()) {
157 int len = Smi::cast(obj)->value(); 157 int len = Smi::cast(obj)->value();
158 if (len >= 0 && len < JSObject::kMaxFastElementsLength) { 158 if (len >= 0 && len < JSObject::kInitialMaxFastElementArray) {
159 Object* obj = Heap::AllocateFixedArrayWithHoles(len); 159 Object* obj = Heap::AllocateFixedArrayWithHoles(len);
160 if (obj->IsFailure()) return obj; 160 if (obj->IsFailure()) return obj;
161 array->SetContent(FixedArray::cast(obj)); 161 array->SetContent(FixedArray::cast(obj));
162 return array; 162 return array;
163 } 163 }
164 } 164 }
165 // Take the argument as the length. 165 // Take the argument as the length.
166 obj = array->Initialize(0); 166 obj = array->Initialize(0);
167 if (obj->IsFailure()) return obj; 167 if (obj->IsFailure()) return obj;
168 if (__argc__ == 2) return array->SetElementsLength(BUILTIN_ARG(1)); 168 if (__argc__ == 2) return array->SetElementsLength(BUILTIN_ARG(1));
(...skipping 566 matching lines...) Expand 10 before | Expand all | Expand 10 after
735 if (entry->contains(pc)) { 735 if (entry->contains(pc)) {
736 return names_[i]; 736 return names_[i];
737 } 737 }
738 } 738 }
739 } 739 }
740 return NULL; 740 return NULL;
741 } 741 }
742 742
743 743
744 } } // namespace v8::internal 744 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « no previous file | src/objects.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698