| OLD | NEW |
| 1 // Copyright 2014 the V8 project authors. All rights reserved. | 1 // Copyright 2014 the V8 project authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "src/runtime/runtime-utils.h" | 5 #include "src/runtime/runtime-utils.h" |
| 6 | 6 |
| 7 #include "src/arguments.h" | 7 #include "src/arguments.h" |
| 8 #include "src/code-stubs.h" | 8 #include "src/code-stubs.h" |
| 9 #include "src/conversions-inl.h" | 9 #include "src/conversions-inl.h" |
| 10 #include "src/elements.h" | 10 #include "src/elements.h" |
| (...skipping 304 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 315 // can't be dealt with in the inlined hydrogen array constructor case. | 315 // can't be dealt with in the inlined hydrogen array constructor case. |
| 316 // We must mark the allocationsite as un-inlinable. | 316 // We must mark the allocationsite as un-inlinable. |
| 317 site->SetDoNotInlineCall(); | 317 site->SetDoNotInlineCall(); |
| 318 } | 318 } |
| 319 | 319 |
| 320 return *array; | 320 return *array; |
| 321 } | 321 } |
| 322 | 322 |
| 323 } // namespace | 323 } // namespace |
| 324 | 324 |
| 325 | |
| 326 RUNTIME_FUNCTION(Runtime_NewArray) { | 325 RUNTIME_FUNCTION(Runtime_NewArray) { |
| 327 HandleScope scope(isolate); | 326 HandleScope scope(isolate); |
| 328 DCHECK_LE(3, args.length()); | 327 DCHECK_LE(3, args.length()); |
| 329 int const argc = args.length() - 3; | 328 int const argc = args.length() - 3; |
| 330 // TODO(bmeurer): Remove this Arguments nonsense. | 329 // TODO(bmeurer): Remove this Arguments nonsense. |
| 331 Arguments argv(argc, args.arguments() - 1); | 330 Arguments argv(argc, args.arguments() - 1); |
| 332 CONVERT_ARG_HANDLE_CHECKED(JSFunction, constructor, 0); | 331 CONVERT_ARG_HANDLE_CHECKED(JSFunction, constructor, 0); |
| 333 CONVERT_ARG_HANDLE_CHECKED(JSReceiver, new_target, argc + 1); | 332 CONVERT_ARG_HANDLE_CHECKED(JSReceiver, new_target, argc + 1); |
| 334 CONVERT_ARG_HANDLE_CHECKED(HeapObject, type_info, argc + 2); | 333 CONVERT_ARG_HANDLE_CHECKED(HeapObject, type_info, argc + 2); |
| 335 // TODO(bmeurer): Use MaybeHandle to pass around the AllocationSite. | 334 // TODO(bmeurer): Use MaybeHandle to pass around the AllocationSite. |
| 336 Handle<AllocationSite> site = type_info->IsAllocationSite() | 335 Handle<AllocationSite> site = type_info->IsAllocationSite() |
| 337 ? Handle<AllocationSite>::cast(type_info) | 336 ? Handle<AllocationSite>::cast(type_info) |
| 338 : Handle<AllocationSite>::null(); | 337 : Handle<AllocationSite>::null(); |
| 339 return ArrayConstructorCommon(isolate, constructor, new_target, site, &argv); | 338 return ArrayConstructorCommon(isolate, constructor, new_target, site, &argv); |
| 340 } | 339 } |
| 341 | 340 |
| 342 | |
| 343 RUNTIME_FUNCTION(Runtime_ArrayConstructor) { | |
| 344 HandleScope scope(isolate); | |
| 345 // If we get 2 arguments then they are the stub parameters (constructor, type | |
| 346 // info). If we get 4, then the first one is a pointer to the arguments | |
| 347 // passed by the caller, and the last one is the length of the arguments | |
| 348 // passed to the caller (redundant, but useful to check on the deoptimizer | |
| 349 // with an assert). | |
| 350 Arguments empty_args(0, NULL); | |
| 351 bool no_caller_args = args.length() == 2; | |
| 352 DCHECK(no_caller_args || args.length() == 4); | |
| 353 int parameters_start = no_caller_args ? 0 : 1; | |
| 354 Arguments* caller_args = | |
| 355 no_caller_args ? &empty_args : reinterpret_cast<Arguments*>(args[0]); | |
| 356 CONVERT_ARG_HANDLE_CHECKED(JSFunction, constructor, parameters_start); | |
| 357 CONVERT_ARG_HANDLE_CHECKED(Object, type_info, parameters_start + 1); | |
| 358 #ifdef DEBUG | |
| 359 if (!no_caller_args) { | |
| 360 CONVERT_SMI_ARG_CHECKED(arg_count, parameters_start + 2); | |
| 361 DCHECK(arg_count == caller_args->length()); | |
| 362 } | |
| 363 #endif | |
| 364 | |
| 365 Handle<AllocationSite> site; | |
| 366 if (!type_info.is_null() && !type_info->IsUndefined(isolate)) { | |
| 367 site = Handle<AllocationSite>::cast(type_info); | |
| 368 DCHECK(!site->SitePointsToLiteral()); | |
| 369 } | |
| 370 | |
| 371 return ArrayConstructorCommon(isolate, constructor, constructor, site, | |
| 372 caller_args); | |
| 373 } | |
| 374 | |
| 375 RUNTIME_FUNCTION(Runtime_InternalArrayConstructor) { | |
| 376 HandleScope scope(isolate); | |
| 377 Arguments empty_args(0, NULL); | |
| 378 bool no_caller_args = args.length() == 1; | |
| 379 DCHECK(no_caller_args || args.length() == 3); | |
| 380 int parameters_start = no_caller_args ? 0 : 1; | |
| 381 Arguments* caller_args = | |
| 382 no_caller_args ? &empty_args : reinterpret_cast<Arguments*>(args[0]); | |
| 383 CONVERT_ARG_HANDLE_CHECKED(JSFunction, constructor, parameters_start); | |
| 384 #ifdef DEBUG | |
| 385 if (!no_caller_args) { | |
| 386 CONVERT_SMI_ARG_CHECKED(arg_count, parameters_start + 1); | |
| 387 DCHECK(arg_count == caller_args->length()); | |
| 388 } | |
| 389 #endif | |
| 390 return ArrayConstructorCommon(isolate, constructor, constructor, | |
| 391 Handle<AllocationSite>::null(), caller_args); | |
| 392 } | |
| 393 | |
| 394 RUNTIME_FUNCTION(Runtime_ArraySingleArgumentConstructor) { | |
| 395 HandleScope scope(isolate); | |
| 396 CONVERT_ARG_HANDLE_CHECKED(JSFunction, constructor, 0); | |
| 397 Object** argument_base = reinterpret_cast<Object**>(args[1]); | |
| 398 CONVERT_SMI_ARG_CHECKED(argument_count, 2); | |
| 399 CONVERT_ARG_HANDLE_CHECKED(Object, raw_site, 3); | |
| 400 Handle<AllocationSite> casted_site = | |
| 401 raw_site->IsUndefined(isolate) ? Handle<AllocationSite>::null() | |
| 402 : Handle<AllocationSite>::cast(raw_site); | |
| 403 Arguments constructor_args(argument_count, argument_base); | |
| 404 return ArrayConstructorCommon(isolate, constructor, constructor, casted_site, | |
| 405 &constructor_args); | |
| 406 } | |
| 407 | |
| 408 RUNTIME_FUNCTION(Runtime_NormalizeElements) { | 341 RUNTIME_FUNCTION(Runtime_NormalizeElements) { |
| 409 HandleScope scope(isolate); | 342 HandleScope scope(isolate); |
| 410 DCHECK(args.length() == 1); | 343 DCHECK(args.length() == 1); |
| 411 CONVERT_ARG_HANDLE_CHECKED(JSObject, array, 0); | 344 CONVERT_ARG_HANDLE_CHECKED(JSObject, array, 0); |
| 412 CHECK(!array->HasFixedTypedArrayElements()); | 345 CHECK(!array->HasFixedTypedArrayElements()); |
| 413 CHECK(!array->IsJSGlobalProxy()); | 346 CHECK(!array->IsJSGlobalProxy()); |
| 414 JSObject::NormalizeElements(array); | 347 JSObject::NormalizeElements(array); |
| 415 return *array; | 348 return *array; |
| 416 } | 349 } |
| 417 | 350 |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 502 RUNTIME_FUNCTION(Runtime_ArraySpeciesConstructor) { | 435 RUNTIME_FUNCTION(Runtime_ArraySpeciesConstructor) { |
| 503 HandleScope scope(isolate); | 436 HandleScope scope(isolate); |
| 504 DCHECK(args.length() == 1); | 437 DCHECK(args.length() == 1); |
| 505 CONVERT_ARG_HANDLE_CHECKED(Object, original_array, 0); | 438 CONVERT_ARG_HANDLE_CHECKED(Object, original_array, 0); |
| 506 RETURN_RESULT_OR_FAILURE( | 439 RETURN_RESULT_OR_FAILURE( |
| 507 isolate, Object::ArraySpeciesConstructor(isolate, original_array)); | 440 isolate, Object::ArraySpeciesConstructor(isolate, original_array)); |
| 508 } | 441 } |
| 509 | 442 |
| 510 } // namespace internal | 443 } // namespace internal |
| 511 } // namespace v8 | 444 } // namespace v8 |
| OLD | NEW |