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

Side by Side Diff: src/builtins.cc

Issue 16399007: Move runtime array constructor functions from builtins.cc to runtime.cc. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Comment updates Created 7 years, 6 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/arm/code-stubs-arm.cc ('k') | src/builtins-decls.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 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 176 matching lines...) Expand 10 before | Expand all | Expand 10 after
187 UNREACHABLE(); 187 UNREACHABLE();
188 return isolate->heap()->undefined_value(); // Make compiler happy. 188 return isolate->heap()->undefined_value(); // Make compiler happy.
189 } 189 }
190 190
191 191
192 BUILTIN(EmptyFunction) { 192 BUILTIN(EmptyFunction) {
193 return isolate->heap()->undefined_value(); 193 return isolate->heap()->undefined_value();
194 } 194 }
195 195
196 196
197 static MaybeObject* ArrayConstructorStubFailureCommon(
198 Isolate* isolate,
199 Handle<JSFunction> constructor,
200 Handle<Object> type_info,
201 Arguments* caller_args) {
202 bool holey = false;
203 bool can_use_type_feedback = true;
204 if (caller_args->length() == 1) {
205 Object* argument_one = (*caller_args)[0];
206 if (argument_one->IsSmi()) {
207 int value = Smi::cast(argument_one)->value();
208 if (value < 0 || value >= JSObject::kInitialMaxFastElementArray) {
209 // the array is a dictionary in this case.
210 can_use_type_feedback = false;
211 } else if (value != 0) {
212 holey = true;
213 }
214 } else {
215 // Non-smi length argument produces a dictionary
216 can_use_type_feedback = false;
217 }
218 }
219
220 JSArray* array;
221 MaybeObject* maybe_array;
222 if (!type_info.is_null() &&
223 *type_info != isolate->heap()->undefined_value() &&
224 JSGlobalPropertyCell::cast(*type_info)->value()->IsSmi() &&
225 can_use_type_feedback) {
226 JSGlobalPropertyCell* cell = JSGlobalPropertyCell::cast(*type_info);
227 Smi* smi = Smi::cast(cell->value());
228 ElementsKind to_kind = static_cast<ElementsKind>(smi->value());
229 if (holey && !IsFastHoleyElementsKind(to_kind)) {
230 to_kind = GetHoleyElementsKind(to_kind);
231 // Update the allocation site info to reflect the advice alteration.
232 cell->set_value(Smi::FromInt(to_kind));
233 }
234
235 maybe_array = isolate->heap()->AllocateJSObjectWithAllocationSite(
236 *constructor, type_info);
237 if (!maybe_array->To(&array)) return maybe_array;
238 } else {
239 maybe_array = isolate->heap()->AllocateJSObject(*constructor);
240 if (!maybe_array->To(&array)) return maybe_array;
241 // We might need to transition to holey
242 ElementsKind kind = constructor->initial_map()->elements_kind();
243 if (holey && !IsFastHoleyElementsKind(kind)) {
244 kind = GetHoleyElementsKind(kind);
245 maybe_array = array->TransitionElementsKind(kind);
246 if (maybe_array->IsFailure()) return maybe_array;
247 }
248 }
249
250 maybe_array = isolate->heap()->AllocateJSArrayStorage(array, 0, 0,
251 DONT_INITIALIZE_ARRAY_ELEMENTS);
252 if (maybe_array->IsFailure()) return maybe_array;
253 maybe_array = ArrayConstructInitializeElements(array, caller_args);
254 if (maybe_array->IsFailure()) return maybe_array;
255 return array;
256 }
257
258
259 RUNTIME_FUNCTION(MaybeObject*, ArrayConstructor_StubFailure) {
260 // If we get 2 arguments then they are the stub parameters (constructor, type
261 // info). If we get 3, then the first one is a pointer to the arguments
262 // passed by the caller.
263 Arguments empty_args(0, NULL);
264 bool no_caller_args = args.length() == 2;
265 ASSERT(no_caller_args || args.length() == 3);
266 int parameters_start = no_caller_args ? 0 : 1;
267 Arguments* caller_args = no_caller_args
268 ? &empty_args
269 : reinterpret_cast<Arguments*>(args[0]);
270 Handle<JSFunction> constructor = args.at<JSFunction>(parameters_start);
271 Handle<Object> type_info = args.at<Object>(parameters_start + 1);
272
273 return ArrayConstructorStubFailureCommon(isolate,
274 constructor,
275 type_info,
276 caller_args);
277 }
278
279
280 RUNTIME_FUNCTION(MaybeObject*, InternalArrayConstructor_StubFailure) {
281 Arguments empty_args(0, NULL);
282 bool no_caller_args = args.length() == 1;
283 ASSERT(no_caller_args || args.length() == 2);
284 int parameters_start = no_caller_args ? 0 : 1;
285 Arguments* caller_args = no_caller_args
286 ? &empty_args
287 : reinterpret_cast<Arguments*>(args[0]);
288 Handle<JSFunction> constructor = args.at<JSFunction>(parameters_start);
289
290 return ArrayConstructorStubFailureCommon(isolate,
291 constructor,
292 Handle<Object>::null(),
293 caller_args);
294 }
295
296
297 static MaybeObject* ArrayCodeGenericCommon(Arguments* args, 197 static MaybeObject* ArrayCodeGenericCommon(Arguments* args,
298 Isolate* isolate, 198 Isolate* isolate,
299 JSFunction* constructor) { 199 JSFunction* constructor) {
300 ASSERT(args->length() >= 1); 200 ASSERT(args->length() >= 1);
301 Heap* heap = isolate->heap(); 201 Heap* heap = isolate->heap();
302 isolate->counters()->array_function_runtime()->Increment(); 202 isolate->counters()->array_function_runtime()->Increment();
303 203
304 JSArray* array; 204 JSArray* array;
305 if (CalledAsConstructor(isolate)) { 205 if (CalledAsConstructor(isolate)) {
306 array = JSArray::cast((*args)[0]); 206 array = JSArray::cast((*args)[0]);
(...skipping 1623 matching lines...) Expand 10 before | Expand all | Expand 10 after
1930 return Handle<Code>(code_address); \ 1830 return Handle<Code>(code_address); \
1931 } 1831 }
1932 BUILTIN_LIST_C(DEFINE_BUILTIN_ACCESSOR_C) 1832 BUILTIN_LIST_C(DEFINE_BUILTIN_ACCESSOR_C)
1933 BUILTIN_LIST_A(DEFINE_BUILTIN_ACCESSOR_A) 1833 BUILTIN_LIST_A(DEFINE_BUILTIN_ACCESSOR_A)
1934 BUILTIN_LIST_DEBUG_A(DEFINE_BUILTIN_ACCESSOR_A) 1834 BUILTIN_LIST_DEBUG_A(DEFINE_BUILTIN_ACCESSOR_A)
1935 #undef DEFINE_BUILTIN_ACCESSOR_C 1835 #undef DEFINE_BUILTIN_ACCESSOR_C
1936 #undef DEFINE_BUILTIN_ACCESSOR_A 1836 #undef DEFINE_BUILTIN_ACCESSOR_A
1937 1837
1938 1838
1939 } } // namespace v8::internal 1839 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/arm/code-stubs-arm.cc ('k') | src/builtins-decls.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698