OLD | NEW |
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 Loading... |
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 RUNTIME_FUNCTION(MaybeObject*, ArrayConstructor_StubFailure) { | 197 static MaybeObject* ArrayConstructorStubFailureCommon( |
198 // If we get 2 arguments then they are the stub parameters (constructor, type | 198 Isolate* isolate, |
199 // info). If we get 3, then the first one is a pointer to the arguments | 199 Handle<JSFunction> constructor, |
200 // passed by the caller. | 200 Handle<Object> type_info, |
201 Arguments empty_args(0, NULL); | 201 Arguments* caller_args) { |
202 bool no_caller_args = args.length() == 2; | |
203 ASSERT(no_caller_args || args.length() == 3); | |
204 int parameters_start = no_caller_args ? 0 : 1; | |
205 Arguments* caller_args = no_caller_args | |
206 ? &empty_args | |
207 : reinterpret_cast<Arguments*>(args[0]); | |
208 Handle<JSFunction> constructor = args.at<JSFunction>(parameters_start); | |
209 Handle<Object> type_info = args.at<Object>(parameters_start + 1); | |
210 | |
211 bool holey = false; | 202 bool holey = false; |
212 if (caller_args->length() == 1 && (*caller_args)[0]->IsSmi()) { | 203 if (caller_args->length() == 1 && (*caller_args)[0]->IsSmi()) { |
213 int value = Smi::cast((*caller_args)[0])->value(); | 204 int value = Smi::cast((*caller_args)[0])->value(); |
214 holey = (value > 0 && value < JSObject::kInitialMaxFastElementArray); | 205 holey = (value > 0 && value < JSObject::kInitialMaxFastElementArray); |
215 } | 206 } |
216 | 207 |
217 JSArray* array; | 208 JSArray* array; |
218 MaybeObject* maybe_array; | 209 MaybeObject* maybe_array; |
219 if (*type_info != isolate->heap()->undefined_value() && | 210 if (!type_info.is_null() && |
| 211 *type_info != isolate->heap()->undefined_value() && |
220 JSGlobalPropertyCell::cast(*type_info)->value()->IsSmi()) { | 212 JSGlobalPropertyCell::cast(*type_info)->value()->IsSmi()) { |
221 JSGlobalPropertyCell* cell = JSGlobalPropertyCell::cast(*type_info); | 213 JSGlobalPropertyCell* cell = JSGlobalPropertyCell::cast(*type_info); |
222 Smi* smi = Smi::cast(cell->value()); | 214 Smi* smi = Smi::cast(cell->value()); |
223 ElementsKind to_kind = static_cast<ElementsKind>(smi->value()); | 215 ElementsKind to_kind = static_cast<ElementsKind>(smi->value()); |
224 if (holey && !IsFastHoleyElementsKind(to_kind)) { | 216 if (holey && !IsFastHoleyElementsKind(to_kind)) { |
225 to_kind = GetHoleyElementsKind(to_kind); | 217 to_kind = GetHoleyElementsKind(to_kind); |
226 // Update the allocation site info to reflect the advice alteration. | 218 // Update the allocation site info to reflect the advice alteration. |
227 cell->set_value(Smi::FromInt(to_kind)); | 219 cell->set_value(Smi::FromInt(to_kind)); |
228 } | 220 } |
229 | 221 |
230 maybe_array = isolate->heap()->AllocateJSObjectWithAllocationSite( | 222 maybe_array = isolate->heap()->AllocateJSObjectWithAllocationSite( |
231 *constructor, type_info); | 223 *constructor, type_info); |
232 if (!maybe_array->To(&array)) return maybe_array; | 224 if (!maybe_array->To(&array)) return maybe_array; |
233 } else { | 225 } else { |
234 ElementsKind kind = constructor->initial_map()->elements_kind(); | |
235 ASSERT(kind == GetInitialFastElementsKind()); | |
236 maybe_array = isolate->heap()->AllocateJSObject(*constructor); | 226 maybe_array = isolate->heap()->AllocateJSObject(*constructor); |
237 if (!maybe_array->To(&array)) return maybe_array; | 227 if (!maybe_array->To(&array)) return maybe_array; |
238 // We might need to transition to holey | 228 // We might need to transition to holey |
239 if (holey) { | 229 ElementsKind kind = constructor->initial_map()->elements_kind(); |
| 230 if (holey && !IsFastHoleyElementsKind(kind)) { |
240 kind = GetHoleyElementsKind(kind); | 231 kind = GetHoleyElementsKind(kind); |
241 maybe_array = array->TransitionElementsKind(kind); | 232 maybe_array = array->TransitionElementsKind(kind); |
242 if (maybe_array->IsFailure()) return maybe_array; | 233 if (maybe_array->IsFailure()) return maybe_array; |
243 } | 234 } |
244 } | 235 } |
245 | 236 |
246 maybe_array = isolate->heap()->AllocateJSArrayStorage(array, 0, 0, | 237 maybe_array = isolate->heap()->AllocateJSArrayStorage(array, 0, 0, |
247 DONT_INITIALIZE_ARRAY_ELEMENTS); | 238 DONT_INITIALIZE_ARRAY_ELEMENTS); |
248 if (maybe_array->IsFailure()) return maybe_array; | 239 if (maybe_array->IsFailure()) return maybe_array; |
249 maybe_array = ArrayConstructInitializeElements(array, caller_args); | 240 maybe_array = ArrayConstructInitializeElements(array, caller_args); |
250 if (maybe_array->IsFailure()) return maybe_array; | 241 if (maybe_array->IsFailure()) return maybe_array; |
251 return array; | 242 return array; |
252 } | 243 } |
253 | 244 |
254 | 245 |
| 246 RUNTIME_FUNCTION(MaybeObject*, ArrayConstructor_StubFailure) { |
| 247 // If we get 2 arguments then they are the stub parameters (constructor, type |
| 248 // info). If we get 3, then the first one is a pointer to the arguments |
| 249 // passed by the caller. |
| 250 Arguments empty_args(0, NULL); |
| 251 bool no_caller_args = args.length() == 2; |
| 252 ASSERT(no_caller_args || args.length() == 3); |
| 253 int parameters_start = no_caller_args ? 0 : 1; |
| 254 Arguments* caller_args = no_caller_args |
| 255 ? &empty_args |
| 256 : reinterpret_cast<Arguments*>(args[0]); |
| 257 Handle<JSFunction> constructor = args.at<JSFunction>(parameters_start); |
| 258 Handle<Object> type_info = args.at<Object>(parameters_start + 1); |
| 259 |
| 260 return ArrayConstructorStubFailureCommon(isolate, |
| 261 constructor, |
| 262 type_info, |
| 263 caller_args); |
| 264 } |
| 265 |
| 266 |
| 267 RUNTIME_FUNCTION(MaybeObject*, InternalArrayConstructor_StubFailure) { |
| 268 Arguments empty_args(0, NULL); |
| 269 bool no_caller_args = args.length() == 1; |
| 270 ASSERT(no_caller_args || args.length() == 2); |
| 271 int parameters_start = no_caller_args ? 0 : 1; |
| 272 Arguments* caller_args = no_caller_args |
| 273 ? &empty_args |
| 274 : reinterpret_cast<Arguments*>(args[0]); |
| 275 Handle<JSFunction> constructor = args.at<JSFunction>(parameters_start); |
| 276 |
| 277 return ArrayConstructorStubFailureCommon(isolate, |
| 278 constructor, |
| 279 Handle<Object>::null(), |
| 280 caller_args); |
| 281 } |
| 282 |
| 283 |
255 static MaybeObject* ArrayCodeGenericCommon(Arguments* args, | 284 static MaybeObject* ArrayCodeGenericCommon(Arguments* args, |
256 Isolate* isolate, | 285 Isolate* isolate, |
257 JSFunction* constructor) { | 286 JSFunction* constructor) { |
258 ASSERT(args->length() >= 1); | 287 ASSERT(args->length() >= 1); |
259 Heap* heap = isolate->heap(); | 288 Heap* heap = isolate->heap(); |
260 isolate->counters()->array_function_runtime()->Increment(); | 289 isolate->counters()->array_function_runtime()->Increment(); |
261 | 290 |
262 JSArray* array; | 291 JSArray* array; |
263 if (CalledAsConstructor(isolate)) { | 292 if (CalledAsConstructor(isolate)) { |
264 array = JSArray::cast((*args)[0]); | 293 array = JSArray::cast((*args)[0]); |
(...skipping 1618 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1883 return Handle<Code>(code_address); \ | 1912 return Handle<Code>(code_address); \ |
1884 } | 1913 } |
1885 BUILTIN_LIST_C(DEFINE_BUILTIN_ACCESSOR_C) | 1914 BUILTIN_LIST_C(DEFINE_BUILTIN_ACCESSOR_C) |
1886 BUILTIN_LIST_A(DEFINE_BUILTIN_ACCESSOR_A) | 1915 BUILTIN_LIST_A(DEFINE_BUILTIN_ACCESSOR_A) |
1887 BUILTIN_LIST_DEBUG_A(DEFINE_BUILTIN_ACCESSOR_A) | 1916 BUILTIN_LIST_DEBUG_A(DEFINE_BUILTIN_ACCESSOR_A) |
1888 #undef DEFINE_BUILTIN_ACCESSOR_C | 1917 #undef DEFINE_BUILTIN_ACCESSOR_C |
1889 #undef DEFINE_BUILTIN_ACCESSOR_A | 1918 #undef DEFINE_BUILTIN_ACCESSOR_A |
1890 | 1919 |
1891 | 1920 |
1892 } } // namespace v8::internal | 1921 } } // namespace v8::internal |
OLD | NEW |