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

Side by Side Diff: src/builtins.cc

Issue 193125: Handle array construction on native code (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: '' Created 11 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 | Annotate | Revision Log
« no previous file with comments | « src/builtins.h ('k') | src/ia32/builtins-ia32.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 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 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
128 UNREACHABLE(); 128 UNREACHABLE();
129 } 129 }
130 BUILTIN_END 130 BUILTIN_END
131 131
132 132
133 BUILTIN(EmptyFunction) { 133 BUILTIN(EmptyFunction) {
134 } 134 }
135 BUILTIN_END 135 BUILTIN_END
136 136
137 137
138 BUILTIN(ArrayCode) { 138 BUILTIN(ArrayCodeGeneric) {
139 Counters::array_function_runtime.Increment();
140
139 JSArray* array; 141 JSArray* array;
140 if (CalledAsConstructor()) { 142 if (CalledAsConstructor()) {
141 array = JSArray::cast(*receiver); 143 array = JSArray::cast(*receiver);
142 } else { 144 } else {
143 // Allocate the JS Array 145 // Allocate the JS Array
144 JSFunction* constructor = 146 JSFunction* constructor =
145 Top::context()->global_context()->array_function(); 147 Top::context()->global_context()->array_function();
146 Object* obj = Heap::AllocateJSObject(constructor); 148 Object* obj = Heap::AllocateJSObject(constructor);
147 if (obj->IsFailure()) return obj; 149 if (obj->IsFailure()) return obj;
148 array = JSArray::cast(obj); 150 array = JSArray::cast(obj);
(...skipping 10 matching lines...) Expand all
159 if (len >= 0 && len < JSObject::kInitialMaxFastElementArray) { 161 if (len >= 0 && len < JSObject::kInitialMaxFastElementArray) {
160 Object* obj = Heap::AllocateFixedArrayWithHoles(len); 162 Object* obj = Heap::AllocateFixedArrayWithHoles(len);
161 if (obj->IsFailure()) return obj; 163 if (obj->IsFailure()) return obj;
162 array->SetContent(FixedArray::cast(obj)); 164 array->SetContent(FixedArray::cast(obj));
163 return array; 165 return array;
164 } 166 }
165 } 167 }
166 // Take the argument as the length. 168 // Take the argument as the length.
167 obj = array->Initialize(0); 169 obj = array->Initialize(0);
168 if (obj->IsFailure()) return obj; 170 if (obj->IsFailure()) return obj;
169 if (args.length() == 2) return array->SetElementsLength(args[1]); 171 return array->SetElementsLength(args[1]);
170 } 172 }
171 173
172 // Optimize the case where there are no parameters passed. 174 // Optimize the case where there are no parameters passed.
173 if (args.length() == 1) return array->Initialize(4); 175 if (args.length() == 1) return array->Initialize(4);
174 176
175 // Take the arguments as elements. 177 // Take the arguments as elements.
176 int number_of_elements = args.length() - 1; 178 int number_of_elements = args.length() - 1;
177 Smi* len = Smi::FromInt(number_of_elements); 179 Smi* len = Smi::FromInt(number_of_elements);
178 Object* obj = Heap::AllocateFixedArrayWithHoles(len->value()); 180 Object* obj = Heap::AllocateFixedArrayWithHoles(len->value());
179 if (obj->IsFailure()) return obj; 181 if (obj->IsFailure()) return obj;
(...skipping 571 matching lines...) Expand 10 before | Expand all | Expand 10 after
751 if (entry->contains(pc)) { 753 if (entry->contains(pc)) {
752 return names_[i]; 754 return names_[i];
753 } 755 }
754 } 756 }
755 } 757 }
756 return NULL; 758 return NULL;
757 } 759 }
758 760
759 761
760 } } // namespace v8::internal 762 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/builtins.h ('k') | src/ia32/builtins-ia32.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698