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

Side by Side Diff: src/builtins.cc

Issue 9356002: Remove unnecessary elements type check when allocating array in runtime. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 8 years, 10 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/heap.cc » ('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 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 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 200 matching lines...) Expand 10 before | Expand all | Expand 10 after
211 if (!maybe_obj->To(&array)) return maybe_obj; 211 if (!maybe_obj->To(&array)) return maybe_obj;
212 } 212 }
213 213
214 // Optimize the case where there is one argument and the argument is a 214 // Optimize the case where there is one argument and the argument is a
215 // small smi. 215 // small smi.
216 if (args->length() == 2) { 216 if (args->length() == 2) {
217 Object* obj = (*args)[1]; 217 Object* obj = (*args)[1];
218 if (obj->IsSmi()) { 218 if (obj->IsSmi()) {
219 int len = Smi::cast(obj)->value(); 219 int len = Smi::cast(obj)->value();
220 if (len >= 0 && len < JSObject::kInitialMaxFastElementArray) { 220 if (len >= 0 && len < JSObject::kInitialMaxFastElementArray) {
221 Object* obj; 221 Object* fixed_array;
222 { MaybeObject* maybe_obj = heap->AllocateFixedArrayWithHoles(len); 222 { MaybeObject* maybe_obj = heap->AllocateFixedArrayWithHoles(len);
223 if (!maybe_obj->ToObject(&obj)) return maybe_obj; 223 if (!maybe_obj->ToObject(&fixed_array)) return maybe_obj;
224 } 224 }
225 MaybeObject* maybe_obj = array->SetContent(FixedArray::cast(obj)); 225 array->set_elements(FixedArray::cast(fixed_array));
danno 2012/02/15 12:08:11 Add a comment why SetContent isn't a good idea her
226 if (maybe_obj->IsFailure()) return maybe_obj; 226 array->set_length(Smi::cast(obj));
227 return array; 227 return array;
228 } 228 }
229 } 229 }
230 // Take the argument as the length. 230 // Take the argument as the length.
231 { MaybeObject* maybe_obj = array->Initialize(0); 231 { MaybeObject* maybe_obj = array->Initialize(0);
232 if (!maybe_obj->ToObject(&obj)) return maybe_obj; 232 if (!maybe_obj->ToObject(&obj)) return maybe_obj;
233 } 233 }
234 return array->SetElementsLength((*args)[1]); 234 return array->SetElementsLength((*args)[1]);
235 } 235 }
236 236
(...skipping 1519 matching lines...) Expand 10 before | Expand all | Expand 10 after
1756 return Handle<Code>(code_address); \ 1756 return Handle<Code>(code_address); \
1757 } 1757 }
1758 BUILTIN_LIST_C(DEFINE_BUILTIN_ACCESSOR_C) 1758 BUILTIN_LIST_C(DEFINE_BUILTIN_ACCESSOR_C)
1759 BUILTIN_LIST_A(DEFINE_BUILTIN_ACCESSOR_A) 1759 BUILTIN_LIST_A(DEFINE_BUILTIN_ACCESSOR_A)
1760 BUILTIN_LIST_DEBUG_A(DEFINE_BUILTIN_ACCESSOR_A) 1760 BUILTIN_LIST_DEBUG_A(DEFINE_BUILTIN_ACCESSOR_A)
1761 #undef DEFINE_BUILTIN_ACCESSOR_C 1761 #undef DEFINE_BUILTIN_ACCESSOR_C
1762 #undef DEFINE_BUILTIN_ACCESSOR_A 1762 #undef DEFINE_BUILTIN_ACCESSOR_A
1763 1763
1764 1764
1765 } } // namespace v8::internal 1765 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « no previous file | src/heap.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698