OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "src/runtime/runtime-utils.h" |
| 6 |
| 7 #include "src/arguments.h" |
| 8 #include "src/isolate-inl.h" |
| 9 |
| 10 namespace v8 { |
| 11 namespace internal { |
| 12 |
| 13 |
| 14 RUNTIME_FUNCTION(Runtime_InterpreterEquals) { |
| 15 HandleScope scope(isolate); |
| 16 DCHECK_EQ(2, args.length()); |
| 17 CONVERT_ARG_HANDLE_CHECKED(Object, x, 0); |
| 18 CONVERT_ARG_HANDLE_CHECKED(Object, y, 1); |
| 19 Maybe<bool> result = Object::Equals(x, y); |
| 20 if (result.IsJust()) { |
| 21 return isolate->heap()->ToBoolean(result.FromJust()); |
| 22 } else { |
| 23 return isolate->heap()->exception(); |
| 24 } |
| 25 } |
| 26 |
| 27 |
| 28 RUNTIME_FUNCTION(Runtime_InterpreterNotEquals) { |
| 29 HandleScope scope(isolate); |
| 30 DCHECK_EQ(2, args.length()); |
| 31 CONVERT_ARG_HANDLE_CHECKED(Object, x, 0); |
| 32 CONVERT_ARG_HANDLE_CHECKED(Object, y, 1); |
| 33 Maybe<bool> result = Object::Equals(x, y); |
| 34 if (result.IsJust()) { |
| 35 return isolate->heap()->ToBoolean(!result.FromJust()); |
| 36 } else { |
| 37 return isolate->heap()->exception(); |
| 38 } |
| 39 } |
| 40 |
| 41 |
| 42 RUNTIME_FUNCTION(Runtime_InterpreterLessThan) { |
| 43 HandleScope scope(isolate); |
| 44 DCHECK_EQ(2, args.length()); |
| 45 CONVERT_ARG_HANDLE_CHECKED(Object, x, 0); |
| 46 CONVERT_ARG_HANDLE_CHECKED(Object, y, 1); |
| 47 Maybe<bool> result = Object::LessThan(x, y); |
| 48 if (result.IsJust()) { |
| 49 return isolate->heap()->ToBoolean(result.FromJust()); |
| 50 } else { |
| 51 return isolate->heap()->exception(); |
| 52 } |
| 53 } |
| 54 |
| 55 |
| 56 RUNTIME_FUNCTION(Runtime_InterpreterGreaterThan) { |
| 57 HandleScope scope(isolate); |
| 58 DCHECK_EQ(2, args.length()); |
| 59 CONVERT_ARG_HANDLE_CHECKED(Object, x, 0); |
| 60 CONVERT_ARG_HANDLE_CHECKED(Object, y, 1); |
| 61 Maybe<bool> result = Object::GreaterThan(x, y); |
| 62 if (result.IsJust()) { |
| 63 return isolate->heap()->ToBoolean(result.FromJust()); |
| 64 } else { |
| 65 return isolate->heap()->exception(); |
| 66 } |
| 67 } |
| 68 |
| 69 |
| 70 RUNTIME_FUNCTION(Runtime_InterpreterLessThanOrEqual) { |
| 71 HandleScope scope(isolate); |
| 72 DCHECK_EQ(2, args.length()); |
| 73 CONVERT_ARG_HANDLE_CHECKED(Object, x, 0); |
| 74 CONVERT_ARG_HANDLE_CHECKED(Object, y, 1); |
| 75 Maybe<bool> result = Object::LessThanOrEqual(x, y); |
| 76 if (result.IsJust()) { |
| 77 return isolate->heap()->ToBoolean(result.FromJust()); |
| 78 } else { |
| 79 return isolate->heap()->exception(); |
| 80 } |
| 81 } |
| 82 |
| 83 |
| 84 RUNTIME_FUNCTION(Runtime_InterpreterGreaterThanOrEqual) { |
| 85 HandleScope scope(isolate); |
| 86 DCHECK_EQ(2, args.length()); |
| 87 CONVERT_ARG_HANDLE_CHECKED(Object, x, 0); |
| 88 CONVERT_ARG_HANDLE_CHECKED(Object, y, 1); |
| 89 Maybe<bool> result = Object::GreaterThanOrEqual(x, y); |
| 90 if (result.IsJust()) { |
| 91 return isolate->heap()->ToBoolean(result.FromJust()); |
| 92 } else { |
| 93 return isolate->heap()->exception(); |
| 94 } |
| 95 } |
| 96 |
| 97 |
| 98 RUNTIME_FUNCTION(Runtime_InterpreterStrictEquals) { |
| 99 SealHandleScope scope(isolate); |
| 100 DCHECK_EQ(2, args.length()); |
| 101 CONVERT_ARG_CHECKED(Object, x, 0); |
| 102 CONVERT_ARG_CHECKED(Object, y, 1); |
| 103 return isolate->heap()->ToBoolean(x->StrictEquals(y)); |
| 104 } |
| 105 |
| 106 |
| 107 RUNTIME_FUNCTION(Runtime_InterpreterStrictNotEquals) { |
| 108 SealHandleScope scope(isolate); |
| 109 DCHECK_EQ(2, args.length()); |
| 110 CONVERT_ARG_CHECKED(Object, x, 0); |
| 111 CONVERT_ARG_CHECKED(Object, y, 1); |
| 112 return isolate->heap()->ToBoolean(!x->StrictEquals(y)); |
| 113 } |
| 114 |
| 115 |
| 116 RUNTIME_FUNCTION(Runtime_InterpreterCastToBoolean) { |
| 117 SealHandleScope scope(isolate); |
| 118 DCHECK_EQ(1, args.length()); |
| 119 CONVERT_ARG_CHECKED(Object, x, 0); |
| 120 return isolate->heap()->ToBoolean(x->BooleanValue()); |
| 121 } |
| 122 |
| 123 |
| 124 } // namespace internal |
| 125 } // namespace v8 |
OLD | NEW |