Line data Source code
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 72 : 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 72 : RETURN_RESULT_OR_FAILURE(isolate, Object::Add(isolate, lhs, rhs));
20 : }
21 :
22 :
23 990 : 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 495 : Maybe<bool> result = Object::Equals(isolate, x, y);
29 495 : if (result.IsNothing()) return ReadOnlyRoots(isolate).exception();
30 : return isolate->heap()->ToBoolean(result.FromJust());
31 : }
32 :
33 756 : 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 378 : Maybe<bool> result = Object::Equals(isolate, x, y);
39 378 : if (result.IsNothing()) return ReadOnlyRoots(isolate).exception();
40 378 : return isolate->heap()->ToBoolean(!result.FromJust());
41 : }
42 :
43 108 : RUNTIME_FUNCTION(Runtime_StrictEqual) {
44 : SealHandleScope scope(isolate);
45 : DCHECK_EQ(2, args.length());
46 54 : CONVERT_ARG_CHECKED(Object, x, 0);
47 : CONVERT_ARG_CHECKED(Object, y, 1);
48 108 : return isolate->heap()->ToBoolean(x->StrictEquals(y));
49 : }
50 :
51 108 : RUNTIME_FUNCTION(Runtime_StrictNotEqual) {
52 : SealHandleScope scope(isolate);
53 : DCHECK_EQ(2, args.length());
54 54 : CONVERT_ARG_CHECKED(Object, x, 0);
55 : CONVERT_ARG_CHECKED(Object, y, 1);
56 108 : return isolate->heap()->ToBoolean(!x->StrictEquals(y));
57 : }
58 :
59 234 : 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 117 : Maybe<bool> result = Object::LessThan(isolate, x, y);
65 117 : if (result.IsNothing()) return ReadOnlyRoots(isolate).exception();
66 : return isolate->heap()->ToBoolean(result.FromJust());
67 : }
68 :
69 198 : 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 99 : Maybe<bool> result = Object::GreaterThan(isolate, x, y);
75 99 : if (result.IsNothing()) return ReadOnlyRoots(isolate).exception();
76 : return isolate->heap()->ToBoolean(result.FromJust());
77 : }
78 :
79 144 : 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 72 : Maybe<bool> result = Object::LessThanOrEqual(isolate, x, y);
85 72 : if (result.IsNothing()) return ReadOnlyRoots(isolate).exception();
86 : return isolate->heap()->ToBoolean(result.FromJust());
87 : }
88 :
89 162 : 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 81 : Maybe<bool> result = Object::GreaterThanOrEqual(isolate, x, y);
95 81 : if (result.IsNothing()) return ReadOnlyRoots(isolate).exception();
96 : return isolate->heap()->ToBoolean(result.FromJust());
97 : }
98 :
99 : } // namespace internal
100 122036 : } // namespace v8
|