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 36 : RUNTIME_FUNCTION(Runtime_Add) {
15 36 : HandleScope scope(isolate);
16 : DCHECK_EQ(2, args.length());
17 36 : CONVERT_ARG_HANDLE_CHECKED(Object, lhs, 0);
18 36 : CONVERT_ARG_HANDLE_CHECKED(Object, rhs, 1);
19 108 : RETURN_RESULT_OR_FAILURE(isolate, Object::Add(isolate, lhs, rhs));
20 : }
21 :
22 :
23 495 : RUNTIME_FUNCTION(Runtime_Equal) {
24 495 : HandleScope scope(isolate);
25 : DCHECK_EQ(2, args.length());
26 495 : CONVERT_ARG_HANDLE_CHECKED(Object, x, 0);
27 495 : 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 495 : return isolate->heap()->ToBoolean(result.FromJust());
31 : }
32 :
33 378 : RUNTIME_FUNCTION(Runtime_NotEqual) {
34 378 : HandleScope scope(isolate);
35 : DCHECK_EQ(2, args.length());
36 378 : CONVERT_ARG_HANDLE_CHECKED(Object, x, 0);
37 378 : 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 54 : RUNTIME_FUNCTION(Runtime_StrictEqual) {
44 : SealHandleScope scope(isolate);
45 : DCHECK_EQ(2, args.length());
46 54 : CONVERT_ARG_CHECKED(Object, x, 0);
47 54 : CONVERT_ARG_CHECKED(Object, y, 1);
48 54 : return isolate->heap()->ToBoolean(x->StrictEquals(y));
49 : }
50 :
51 54 : RUNTIME_FUNCTION(Runtime_StrictNotEqual) {
52 : SealHandleScope scope(isolate);
53 : DCHECK_EQ(2, args.length());
54 54 : CONVERT_ARG_CHECKED(Object, x, 0);
55 54 : CONVERT_ARG_CHECKED(Object, y, 1);
56 54 : return isolate->heap()->ToBoolean(!x->StrictEquals(y));
57 : }
58 :
59 117 : RUNTIME_FUNCTION(Runtime_LessThan) {
60 117 : HandleScope scope(isolate);
61 : DCHECK_EQ(2, args.length());
62 117 : CONVERT_ARG_HANDLE_CHECKED(Object, x, 0);
63 117 : 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 99 : return isolate->heap()->ToBoolean(result.FromJust());
67 : }
68 :
69 99 : RUNTIME_FUNCTION(Runtime_GreaterThan) {
70 99 : HandleScope scope(isolate);
71 : DCHECK_EQ(2, args.length());
72 99 : CONVERT_ARG_HANDLE_CHECKED(Object, x, 0);
73 99 : 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 99 : return isolate->heap()->ToBoolean(result.FromJust());
77 : }
78 :
79 72 : RUNTIME_FUNCTION(Runtime_LessThanOrEqual) {
80 72 : HandleScope scope(isolate);
81 : DCHECK_EQ(2, args.length());
82 72 : CONVERT_ARG_HANDLE_CHECKED(Object, x, 0);
83 72 : 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 72 : return isolate->heap()->ToBoolean(result.FromJust());
87 : }
88 :
89 81 : RUNTIME_FUNCTION(Runtime_GreaterThanOrEqual) {
90 81 : HandleScope scope(isolate);
91 : DCHECK_EQ(2, args.length());
92 81 : CONVERT_ARG_HANDLE_CHECKED(Object, x, 0);
93 81 : 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 81 : return isolate->heap()->ToBoolean(result.FromJust());
97 : }
98 :
99 : } // namespace internal
100 178779 : } // namespace v8
|