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 |
3 | // found in the LICENSE file. |
4 | |
5 | #include "src/arguments.h" |
6 | #include "src/counters.h" |
7 | #include "src/heap/heap-inl.h" // For ToBoolean. TODO(jkummerow): Drop. |
8 | #include "src/isolate-inl.h" |
9 | #include "src/runtime/runtime-utils.h" |
10 | |
11 | namespace v8 { |
12 | namespace internal { |
13 | |
14 | RUNTIME_FUNCTION(Runtime_Add) { |
15 | HandleScope scope(isolate); |
16 | DCHECK_EQ(2, args.length()); |
17 | CONVERT_ARG_HANDLE_CHECKED(Object, lhs, 0); |
18 | CONVERT_ARG_HANDLE_CHECKED(Object, rhs, 1); |
19 | RETURN_RESULT_OR_FAILURE(isolate, Object::Add(isolate, lhs, rhs)); |
20 | } |
21 | |
22 | |
23 | RUNTIME_FUNCTION(Runtime_Equal) { |
24 | HandleScope scope(isolate); |
25 | DCHECK_EQ(2, args.length()); |
26 | CONVERT_ARG_HANDLE_CHECKED(Object, x, 0); |
27 | CONVERT_ARG_HANDLE_CHECKED(Object, y, 1); |
28 | Maybe<bool> result = Object::Equals(isolate, x, y); |
29 | if (result.IsNothing()) return ReadOnlyRoots(isolate).exception(); |
30 | return isolate->heap()->ToBoolean(result.FromJust()); |
31 | } |
32 | |
33 | RUNTIME_FUNCTION(Runtime_NotEqual) { |
34 | HandleScope scope(isolate); |
35 | DCHECK_EQ(2, args.length()); |
36 | CONVERT_ARG_HANDLE_CHECKED(Object, x, 0); |
37 | CONVERT_ARG_HANDLE_CHECKED(Object, y, 1); |
38 | Maybe<bool> result = Object::Equals(isolate, x, y); |
39 | if (result.IsNothing()) return ReadOnlyRoots(isolate).exception(); |
40 | return isolate->heap()->ToBoolean(!result.FromJust()); |
41 | } |
42 | |
43 | RUNTIME_FUNCTION(Runtime_StrictEqual) { |
44 | SealHandleScope scope(isolate); |
45 | DCHECK_EQ(2, args.length()); |
46 | CONVERT_ARG_CHECKED(Object, x, 0); |
47 | CONVERT_ARG_CHECKED(Object, y, 1); |
48 | return isolate->heap()->ToBoolean(x->StrictEquals(y)); |
49 | } |
50 | |
51 | RUNTIME_FUNCTION(Runtime_StrictNotEqual) { |
52 | SealHandleScope scope(isolate); |
53 | DCHECK_EQ(2, args.length()); |
54 | CONVERT_ARG_CHECKED(Object, x, 0); |
55 | CONVERT_ARG_CHECKED(Object, y, 1); |
56 | return isolate->heap()->ToBoolean(!x->StrictEquals(y)); |
57 | } |
58 | |
59 | RUNTIME_FUNCTION(Runtime_LessThan) { |
60 | HandleScope scope(isolate); |
61 | DCHECK_EQ(2, args.length()); |
62 | CONVERT_ARG_HANDLE_CHECKED(Object, x, 0); |
63 | CONVERT_ARG_HANDLE_CHECKED(Object, y, 1); |
64 | Maybe<bool> result = Object::LessThan(isolate, x, y); |
65 | if (result.IsNothing()) return ReadOnlyRoots(isolate).exception(); |
66 | return isolate->heap()->ToBoolean(result.FromJust()); |
67 | } |
68 | |
69 | RUNTIME_FUNCTION(Runtime_GreaterThan) { |
70 | HandleScope scope(isolate); |
71 | DCHECK_EQ(2, args.length()); |
72 | CONVERT_ARG_HANDLE_CHECKED(Object, x, 0); |
73 | CONVERT_ARG_HANDLE_CHECKED(Object, y, 1); |
74 | Maybe<bool> result = Object::GreaterThan(isolate, x, y); |
75 | if (result.IsNothing()) return ReadOnlyRoots(isolate).exception(); |
76 | return isolate->heap()->ToBoolean(result.FromJust()); |
77 | } |
78 | |
79 | RUNTIME_FUNCTION(Runtime_LessThanOrEqual) { |
80 | HandleScope scope(isolate); |
81 | DCHECK_EQ(2, args.length()); |
82 | CONVERT_ARG_HANDLE_CHECKED(Object, x, 0); |
83 | CONVERT_ARG_HANDLE_CHECKED(Object, y, 1); |
84 | Maybe<bool> result = Object::LessThanOrEqual(isolate, x, y); |
85 | if (result.IsNothing()) return ReadOnlyRoots(isolate).exception(); |
86 | return isolate->heap()->ToBoolean(result.FromJust()); |
87 | } |
88 | |
89 | RUNTIME_FUNCTION(Runtime_GreaterThanOrEqual) { |
90 | HandleScope scope(isolate); |
91 | DCHECK_EQ(2, args.length()); |
92 | CONVERT_ARG_HANDLE_CHECKED(Object, x, 0); |
93 | CONVERT_ARG_HANDLE_CHECKED(Object, y, 1); |
94 | Maybe<bool> result = Object::GreaterThanOrEqual(isolate, x, y); |
95 | if (result.IsNothing()) return ReadOnlyRoots(isolate).exception(); |
96 | return isolate->heap()->ToBoolean(result.FromJust()); |
97 | } |
98 | |
99 | } // namespace internal |
100 | } // namespace v8 |
101 | |