| OLD | NEW |
| 1 // Copyright 2015 the V8 project authors. All rights reserved. | 1 // Copyright 2015 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/base/macros.h" | 8 #include "src/base/macros.h" |
| 9 #include "src/base/platform/mutex.h" | 9 #include "src/base/platform/mutex.h" |
| 10 #include "src/conversions-inl.h" | 10 #include "src/conversions-inl.h" |
| (...skipping 331 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 342 | 342 |
| 343 RUNTIME_FUNCTION(Runtime_ThrowInvalidAtomicAccessIndexError) { | 343 RUNTIME_FUNCTION(Runtime_ThrowInvalidAtomicAccessIndexError) { |
| 344 HandleScope scope(isolate); | 344 HandleScope scope(isolate); |
| 345 DCHECK_EQ(0, args.length()); | 345 DCHECK_EQ(0, args.length()); |
| 346 THROW_NEW_ERROR_RETURN_FAILURE( | 346 THROW_NEW_ERROR_RETURN_FAILURE( |
| 347 isolate, NewRangeError(MessageTemplate::kInvalidAtomicAccessIndex)); | 347 isolate, NewRangeError(MessageTemplate::kInvalidAtomicAccessIndex)); |
| 348 } | 348 } |
| 349 | 349 |
| 350 RUNTIME_FUNCTION(Runtime_AtomicsCompareExchange) { | 350 RUNTIME_FUNCTION(Runtime_AtomicsCompareExchange) { |
| 351 HandleScope scope(isolate); | 351 HandleScope scope(isolate); |
| 352 DCHECK(args.length() == 4); | 352 DCHECK_EQ(4, args.length()); |
| 353 CONVERT_ARG_HANDLE_CHECKED(JSTypedArray, sta, 0); | 353 CONVERT_ARG_HANDLE_CHECKED(JSTypedArray, sta, 0); |
| 354 CONVERT_SIZE_ARG_CHECKED(index, 1); | 354 CONVERT_SIZE_ARG_CHECKED(index, 1); |
| 355 CONVERT_NUMBER_ARG_HANDLE_CHECKED(oldobj, 2); | 355 CONVERT_NUMBER_ARG_HANDLE_CHECKED(oldobj, 2); |
| 356 CONVERT_NUMBER_ARG_HANDLE_CHECKED(newobj, 3); | 356 CONVERT_NUMBER_ARG_HANDLE_CHECKED(newobj, 3); |
| 357 CHECK(sta->GetBuffer()->is_shared()); | 357 CHECK(sta->GetBuffer()->is_shared()); |
| 358 CHECK_LT(index, NumberToSize(sta->length())); | 358 CHECK_LT(index, NumberToSize(sta->length())); |
| 359 | 359 |
| 360 uint8_t* source = static_cast<uint8_t*>(sta->GetBuffer()->backing_store()) + | 360 uint8_t* source = static_cast<uint8_t*>(sta->GetBuffer()->backing_store()) + |
| 361 NumberToSize(sta->byte_offset()); | 361 NumberToSize(sta->byte_offset()); |
| 362 | 362 |
| (...skipping 13 matching lines...) Expand all Loading... |
| 376 break; | 376 break; |
| 377 } | 377 } |
| 378 | 378 |
| 379 UNREACHABLE(); | 379 UNREACHABLE(); |
| 380 return isolate->heap()->undefined_value(); | 380 return isolate->heap()->undefined_value(); |
| 381 } | 381 } |
| 382 | 382 |
| 383 | 383 |
| 384 RUNTIME_FUNCTION(Runtime_AtomicsAdd) { | 384 RUNTIME_FUNCTION(Runtime_AtomicsAdd) { |
| 385 HandleScope scope(isolate); | 385 HandleScope scope(isolate); |
| 386 DCHECK(args.length() == 3); | 386 DCHECK_EQ(3, args.length()); |
| 387 CONVERT_ARG_HANDLE_CHECKED(JSTypedArray, sta, 0); | 387 CONVERT_ARG_HANDLE_CHECKED(JSTypedArray, sta, 0); |
| 388 CONVERT_SIZE_ARG_CHECKED(index, 1); | 388 CONVERT_SIZE_ARG_CHECKED(index, 1); |
| 389 CONVERT_NUMBER_ARG_HANDLE_CHECKED(value, 2); | 389 CONVERT_NUMBER_ARG_HANDLE_CHECKED(value, 2); |
| 390 CHECK(sta->GetBuffer()->is_shared()); | 390 CHECK(sta->GetBuffer()->is_shared()); |
| 391 CHECK_LT(index, NumberToSize(sta->length())); | 391 CHECK_LT(index, NumberToSize(sta->length())); |
| 392 | 392 |
| 393 uint8_t* source = static_cast<uint8_t*>(sta->GetBuffer()->backing_store()) + | 393 uint8_t* source = static_cast<uint8_t*>(sta->GetBuffer()->backing_store()) + |
| 394 NumberToSize(sta->byte_offset()); | 394 NumberToSize(sta->byte_offset()); |
| 395 | 395 |
| 396 switch (sta->type()) { | 396 switch (sta->type()) { |
| (...skipping 11 matching lines...) Expand all Loading... |
| 408 break; | 408 break; |
| 409 } | 409 } |
| 410 | 410 |
| 411 UNREACHABLE(); | 411 UNREACHABLE(); |
| 412 return isolate->heap()->undefined_value(); | 412 return isolate->heap()->undefined_value(); |
| 413 } | 413 } |
| 414 | 414 |
| 415 | 415 |
| 416 RUNTIME_FUNCTION(Runtime_AtomicsSub) { | 416 RUNTIME_FUNCTION(Runtime_AtomicsSub) { |
| 417 HandleScope scope(isolate); | 417 HandleScope scope(isolate); |
| 418 DCHECK(args.length() == 3); | 418 DCHECK_EQ(3, args.length()); |
| 419 CONVERT_ARG_HANDLE_CHECKED(JSTypedArray, sta, 0); | 419 CONVERT_ARG_HANDLE_CHECKED(JSTypedArray, sta, 0); |
| 420 CONVERT_SIZE_ARG_CHECKED(index, 1); | 420 CONVERT_SIZE_ARG_CHECKED(index, 1); |
| 421 CONVERT_NUMBER_ARG_HANDLE_CHECKED(value, 2); | 421 CONVERT_NUMBER_ARG_HANDLE_CHECKED(value, 2); |
| 422 CHECK(sta->GetBuffer()->is_shared()); | 422 CHECK(sta->GetBuffer()->is_shared()); |
| 423 CHECK_LT(index, NumberToSize(sta->length())); | 423 CHECK_LT(index, NumberToSize(sta->length())); |
| 424 | 424 |
| 425 uint8_t* source = static_cast<uint8_t*>(sta->GetBuffer()->backing_store()) + | 425 uint8_t* source = static_cast<uint8_t*>(sta->GetBuffer()->backing_store()) + |
| 426 NumberToSize(sta->byte_offset()); | 426 NumberToSize(sta->byte_offset()); |
| 427 | 427 |
| 428 switch (sta->type()) { | 428 switch (sta->type()) { |
| (...skipping 11 matching lines...) Expand all Loading... |
| 440 break; | 440 break; |
| 441 } | 441 } |
| 442 | 442 |
| 443 UNREACHABLE(); | 443 UNREACHABLE(); |
| 444 return isolate->heap()->undefined_value(); | 444 return isolate->heap()->undefined_value(); |
| 445 } | 445 } |
| 446 | 446 |
| 447 | 447 |
| 448 RUNTIME_FUNCTION(Runtime_AtomicsAnd) { | 448 RUNTIME_FUNCTION(Runtime_AtomicsAnd) { |
| 449 HandleScope scope(isolate); | 449 HandleScope scope(isolate); |
| 450 DCHECK(args.length() == 3); | 450 DCHECK_EQ(3, args.length()); |
| 451 CONVERT_ARG_HANDLE_CHECKED(JSTypedArray, sta, 0); | 451 CONVERT_ARG_HANDLE_CHECKED(JSTypedArray, sta, 0); |
| 452 CONVERT_SIZE_ARG_CHECKED(index, 1); | 452 CONVERT_SIZE_ARG_CHECKED(index, 1); |
| 453 CONVERT_NUMBER_ARG_HANDLE_CHECKED(value, 2); | 453 CONVERT_NUMBER_ARG_HANDLE_CHECKED(value, 2); |
| 454 CHECK(sta->GetBuffer()->is_shared()); | 454 CHECK(sta->GetBuffer()->is_shared()); |
| 455 CHECK_LT(index, NumberToSize(sta->length())); | 455 CHECK_LT(index, NumberToSize(sta->length())); |
| 456 | 456 |
| 457 uint8_t* source = static_cast<uint8_t*>(sta->GetBuffer()->backing_store()) + | 457 uint8_t* source = static_cast<uint8_t*>(sta->GetBuffer()->backing_store()) + |
| 458 NumberToSize(sta->byte_offset()); | 458 NumberToSize(sta->byte_offset()); |
| 459 | 459 |
| 460 switch (sta->type()) { | 460 switch (sta->type()) { |
| (...skipping 11 matching lines...) Expand all Loading... |
| 472 break; | 472 break; |
| 473 } | 473 } |
| 474 | 474 |
| 475 UNREACHABLE(); | 475 UNREACHABLE(); |
| 476 return isolate->heap()->undefined_value(); | 476 return isolate->heap()->undefined_value(); |
| 477 } | 477 } |
| 478 | 478 |
| 479 | 479 |
| 480 RUNTIME_FUNCTION(Runtime_AtomicsOr) { | 480 RUNTIME_FUNCTION(Runtime_AtomicsOr) { |
| 481 HandleScope scope(isolate); | 481 HandleScope scope(isolate); |
| 482 DCHECK(args.length() == 3); | 482 DCHECK_EQ(3, args.length()); |
| 483 CONVERT_ARG_HANDLE_CHECKED(JSTypedArray, sta, 0); | 483 CONVERT_ARG_HANDLE_CHECKED(JSTypedArray, sta, 0); |
| 484 CONVERT_SIZE_ARG_CHECKED(index, 1); | 484 CONVERT_SIZE_ARG_CHECKED(index, 1); |
| 485 CONVERT_NUMBER_ARG_HANDLE_CHECKED(value, 2); | 485 CONVERT_NUMBER_ARG_HANDLE_CHECKED(value, 2); |
| 486 CHECK(sta->GetBuffer()->is_shared()); | 486 CHECK(sta->GetBuffer()->is_shared()); |
| 487 CHECK_LT(index, NumberToSize(sta->length())); | 487 CHECK_LT(index, NumberToSize(sta->length())); |
| 488 | 488 |
| 489 uint8_t* source = static_cast<uint8_t*>(sta->GetBuffer()->backing_store()) + | 489 uint8_t* source = static_cast<uint8_t*>(sta->GetBuffer()->backing_store()) + |
| 490 NumberToSize(sta->byte_offset()); | 490 NumberToSize(sta->byte_offset()); |
| 491 | 491 |
| 492 switch (sta->type()) { | 492 switch (sta->type()) { |
| (...skipping 11 matching lines...) Expand all Loading... |
| 504 break; | 504 break; |
| 505 } | 505 } |
| 506 | 506 |
| 507 UNREACHABLE(); | 507 UNREACHABLE(); |
| 508 return isolate->heap()->undefined_value(); | 508 return isolate->heap()->undefined_value(); |
| 509 } | 509 } |
| 510 | 510 |
| 511 | 511 |
| 512 RUNTIME_FUNCTION(Runtime_AtomicsXor) { | 512 RUNTIME_FUNCTION(Runtime_AtomicsXor) { |
| 513 HandleScope scope(isolate); | 513 HandleScope scope(isolate); |
| 514 DCHECK(args.length() == 3); | 514 DCHECK_EQ(3, args.length()); |
| 515 CONVERT_ARG_HANDLE_CHECKED(JSTypedArray, sta, 0); | 515 CONVERT_ARG_HANDLE_CHECKED(JSTypedArray, sta, 0); |
| 516 CONVERT_SIZE_ARG_CHECKED(index, 1); | 516 CONVERT_SIZE_ARG_CHECKED(index, 1); |
| 517 CONVERT_NUMBER_ARG_HANDLE_CHECKED(value, 2); | 517 CONVERT_NUMBER_ARG_HANDLE_CHECKED(value, 2); |
| 518 CHECK(sta->GetBuffer()->is_shared()); | 518 CHECK(sta->GetBuffer()->is_shared()); |
| 519 CHECK_LT(index, NumberToSize(sta->length())); | 519 CHECK_LT(index, NumberToSize(sta->length())); |
| 520 | 520 |
| 521 uint8_t* source = static_cast<uint8_t*>(sta->GetBuffer()->backing_store()) + | 521 uint8_t* source = static_cast<uint8_t*>(sta->GetBuffer()->backing_store()) + |
| 522 NumberToSize(sta->byte_offset()); | 522 NumberToSize(sta->byte_offset()); |
| 523 | 523 |
| 524 switch (sta->type()) { | 524 switch (sta->type()) { |
| (...skipping 11 matching lines...) Expand all Loading... |
| 536 break; | 536 break; |
| 537 } | 537 } |
| 538 | 538 |
| 539 UNREACHABLE(); | 539 UNREACHABLE(); |
| 540 return isolate->heap()->undefined_value(); | 540 return isolate->heap()->undefined_value(); |
| 541 } | 541 } |
| 542 | 542 |
| 543 | 543 |
| 544 RUNTIME_FUNCTION(Runtime_AtomicsExchange) { | 544 RUNTIME_FUNCTION(Runtime_AtomicsExchange) { |
| 545 HandleScope scope(isolate); | 545 HandleScope scope(isolate); |
| 546 DCHECK(args.length() == 3); | 546 DCHECK_EQ(3, args.length()); |
| 547 CONVERT_ARG_HANDLE_CHECKED(JSTypedArray, sta, 0); | 547 CONVERT_ARG_HANDLE_CHECKED(JSTypedArray, sta, 0); |
| 548 CONVERT_SIZE_ARG_CHECKED(index, 1); | 548 CONVERT_SIZE_ARG_CHECKED(index, 1); |
| 549 CONVERT_NUMBER_ARG_HANDLE_CHECKED(value, 2); | 549 CONVERT_NUMBER_ARG_HANDLE_CHECKED(value, 2); |
| 550 CHECK(sta->GetBuffer()->is_shared()); | 550 CHECK(sta->GetBuffer()->is_shared()); |
| 551 CHECK_LT(index, NumberToSize(sta->length())); | 551 CHECK_LT(index, NumberToSize(sta->length())); |
| 552 | 552 |
| 553 uint8_t* source = static_cast<uint8_t*>(sta->GetBuffer()->backing_store()) + | 553 uint8_t* source = static_cast<uint8_t*>(sta->GetBuffer()->backing_store()) + |
| 554 NumberToSize(sta->byte_offset()); | 554 NumberToSize(sta->byte_offset()); |
| 555 | 555 |
| 556 switch (sta->type()) { | 556 switch (sta->type()) { |
| (...skipping 11 matching lines...) Expand all Loading... |
| 568 break; | 568 break; |
| 569 } | 569 } |
| 570 | 570 |
| 571 UNREACHABLE(); | 571 UNREACHABLE(); |
| 572 return isolate->heap()->undefined_value(); | 572 return isolate->heap()->undefined_value(); |
| 573 } | 573 } |
| 574 | 574 |
| 575 | 575 |
| 576 RUNTIME_FUNCTION(Runtime_AtomicsIsLockFree) { | 576 RUNTIME_FUNCTION(Runtime_AtomicsIsLockFree) { |
| 577 HandleScope scope(isolate); | 577 HandleScope scope(isolate); |
| 578 DCHECK(args.length() == 1); | 578 DCHECK_EQ(1, args.length()); |
| 579 CONVERT_NUMBER_ARG_HANDLE_CHECKED(size, 0); | 579 CONVERT_NUMBER_ARG_HANDLE_CHECKED(size, 0); |
| 580 uint32_t usize = NumberToUint32(*size); | 580 uint32_t usize = NumberToUint32(*size); |
| 581 return isolate->heap()->ToBoolean(AtomicIsLockFree(usize)); | 581 return isolate->heap()->ToBoolean(AtomicIsLockFree(usize)); |
| 582 } | 582 } |
| 583 } // namespace internal | 583 } // namespace internal |
| 584 } // namespace v8 | 584 } // namespace v8 |
| OLD | NEW |