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/bootstrapper.h" | 8 #include "src/bootstrapper.h" |
9 #include "src/debug/debug.h" | 9 #include "src/debug/debug.h" |
10 #include "src/isolate-inl.h" | 10 #include "src/isolate-inl.h" |
(...skipping 1473 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1484 RUNTIME_FUNCTION(Runtime_StrictEquals) { | 1484 RUNTIME_FUNCTION(Runtime_StrictEquals) { |
1485 SealHandleScope scope(isolate); | 1485 SealHandleScope scope(isolate); |
1486 DCHECK_EQ(2, args.length()); | 1486 DCHECK_EQ(2, args.length()); |
1487 CONVERT_ARG_CHECKED(Object, x, 0); | 1487 CONVERT_ARG_CHECKED(Object, x, 0); |
1488 CONVERT_ARG_CHECKED(Object, y, 1); | 1488 CONVERT_ARG_CHECKED(Object, y, 1); |
1489 // TODO(bmeurer): Change this at some point to return true/false instead. | 1489 // TODO(bmeurer): Change this at some point to return true/false instead. |
1490 return Smi::FromInt(x->StrictEquals(y) ? EQUAL : NOT_EQUAL); | 1490 return Smi::FromInt(x->StrictEquals(y) ? EQUAL : NOT_EQUAL); |
1491 } | 1491 } |
1492 | 1492 |
1493 | 1493 |
| 1494 // TODO(bmeurer): Kill this special wrapper and use TF compatible LessThan, |
| 1495 // GreaterThan, etc. which return true or false. |
| 1496 RUNTIME_FUNCTION(Runtime_Compare) { |
| 1497 HandleScope scope(isolate); |
| 1498 DCHECK_EQ(3, args.length()); |
| 1499 CONVERT_ARG_HANDLE_CHECKED(Object, x, 0); |
| 1500 CONVERT_ARG_HANDLE_CHECKED(Object, y, 1); |
| 1501 CONVERT_ARG_HANDLE_CHECKED(Object, ncr, 2); |
| 1502 Maybe<ComparisonResult> result = Object::Compare(x, y); |
| 1503 if (result.IsJust()) { |
| 1504 switch (result.FromJust()) { |
| 1505 case ComparisonResult::kLessThan: |
| 1506 return Smi::FromInt(LESS); |
| 1507 case ComparisonResult::kEqual: |
| 1508 return Smi::FromInt(EQUAL); |
| 1509 case ComparisonResult::kGreaterThan: |
| 1510 return Smi::FromInt(GREATER); |
| 1511 case ComparisonResult::kUndefined: |
| 1512 return *ncr; |
| 1513 } |
| 1514 UNREACHABLE(); |
| 1515 } |
| 1516 return isolate->heap()->exception(); |
| 1517 } |
| 1518 |
| 1519 |
| 1520 // TODO(bmeurer): Kill this special wrapper and use TF compatible LessThan, |
| 1521 // GreaterThan, etc. which return true or false. |
| 1522 RUNTIME_FUNCTION(Runtime_Compare_Strong) { |
| 1523 HandleScope scope(isolate); |
| 1524 DCHECK_EQ(3, args.length()); |
| 1525 CONVERT_ARG_HANDLE_CHECKED(Object, x, 0); |
| 1526 CONVERT_ARG_HANDLE_CHECKED(Object, y, 1); |
| 1527 CONVERT_ARG_HANDLE_CHECKED(Object, ncr, 2); |
| 1528 Maybe<ComparisonResult> result = Object::Compare(x, y, Strength::STRONG); |
| 1529 if (result.IsJust()) { |
| 1530 switch (result.FromJust()) { |
| 1531 case ComparisonResult::kLessThan: |
| 1532 return Smi::FromInt(LESS); |
| 1533 case ComparisonResult::kEqual: |
| 1534 return Smi::FromInt(EQUAL); |
| 1535 case ComparisonResult::kGreaterThan: |
| 1536 return Smi::FromInt(GREATER); |
| 1537 case ComparisonResult::kUndefined: |
| 1538 return *ncr; |
| 1539 } |
| 1540 UNREACHABLE(); |
| 1541 } |
| 1542 return isolate->heap()->exception(); |
| 1543 } |
| 1544 |
| 1545 |
1494 RUNTIME_FUNCTION(Runtime_InstanceOf) { | 1546 RUNTIME_FUNCTION(Runtime_InstanceOf) { |
1495 // ECMA-262, section 11.8.6, page 54. | 1547 // ECMA-262, section 11.8.6, page 54. |
1496 HandleScope shs(isolate); | 1548 HandleScope shs(isolate); |
1497 DCHECK_EQ(2, args.length()); | 1549 DCHECK_EQ(2, args.length()); |
1498 DCHECK(args.length() == 2); | 1550 DCHECK(args.length() == 2); |
1499 CONVERT_ARG_HANDLE_CHECKED(Object, object, 0); | 1551 CONVERT_ARG_HANDLE_CHECKED(Object, object, 0); |
1500 CONVERT_ARG_HANDLE_CHECKED(Object, callable, 1); | 1552 CONVERT_ARG_HANDLE_CHECKED(Object, callable, 1); |
1501 // {callable} must have a [[Call]] internal method. | 1553 // {callable} must have a [[Call]] internal method. |
1502 if (!callable->IsCallable()) { | 1554 if (!callable->IsCallable()) { |
1503 THROW_NEW_ERROR_RETURN_FAILURE( | 1555 THROW_NEW_ERROR_RETURN_FAILURE( |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1558 RUNTIME_FUNCTION(Runtime_IsAccessCheckNeeded) { | 1610 RUNTIME_FUNCTION(Runtime_IsAccessCheckNeeded) { |
1559 SealHandleScope shs(isolate); | 1611 SealHandleScope shs(isolate); |
1560 DCHECK_EQ(1, args.length()); | 1612 DCHECK_EQ(1, args.length()); |
1561 CONVERT_ARG_CHECKED(Object, object, 0); | 1613 CONVERT_ARG_CHECKED(Object, object, 0); |
1562 return isolate->heap()->ToBoolean(object->IsAccessCheckNeeded()); | 1614 return isolate->heap()->ToBoolean(object->IsAccessCheckNeeded()); |
1563 } | 1615 } |
1564 | 1616 |
1565 | 1617 |
1566 } // namespace internal | 1618 } // namespace internal |
1567 } // namespace v8 | 1619 } // namespace v8 |
OLD | NEW |