5 #include "src/arguments.h" 6 #include "src/counters.h" 7 #include "src/isolate-inl.h" 8 #include "src/runtime/runtime-utils.h" 13 RUNTIME_FUNCTION(Runtime_Add) {
14 HandleScope scope(isolate);
15 DCHECK_EQ(2, args.length());
16 CONVERT_ARG_HANDLE_CHECKED(Object, lhs, 0);
17 CONVERT_ARG_HANDLE_CHECKED(Object, rhs, 1);
18 RETURN_RESULT_OR_FAILURE(isolate, Object::Add(isolate, lhs, rhs));
22 RUNTIME_FUNCTION(Runtime_Equal) {
23 HandleScope scope(isolate);
24 DCHECK_EQ(2, args.length());
25 CONVERT_ARG_HANDLE_CHECKED(Object, x, 0);
26 CONVERT_ARG_HANDLE_CHECKED(Object, y, 1);
27 Maybe<bool> result = Object::Equals(isolate, x, y);
28 if (result.IsNothing())
return ReadOnlyRoots(isolate).exception();
29 return isolate->heap()->ToBoolean(result.FromJust());
32 RUNTIME_FUNCTION(Runtime_NotEqual) {
33 HandleScope scope(isolate);
34 DCHECK_EQ(2, args.length());
35 CONVERT_ARG_HANDLE_CHECKED(Object, x, 0);
36 CONVERT_ARG_HANDLE_CHECKED(Object, y, 1);
37 Maybe<bool> result = Object::Equals(isolate, x, y);
38 if (result.IsNothing())
return ReadOnlyRoots(isolate).exception();
39 return isolate->heap()->ToBoolean(!result.FromJust());
42 RUNTIME_FUNCTION(Runtime_StrictEqual) {
43 SealHandleScope scope(isolate);
44 DCHECK_EQ(2, args.length());
45 CONVERT_ARG_CHECKED(Object, x, 0);
46 CONVERT_ARG_CHECKED(Object, y, 1);
47 return isolate->heap()->ToBoolean(x->StrictEquals(y));
50 RUNTIME_FUNCTION(Runtime_StrictNotEqual) {
51 SealHandleScope scope(isolate);
52 DCHECK_EQ(2, args.length());
53 CONVERT_ARG_CHECKED(Object, x, 0);
54 CONVERT_ARG_CHECKED(Object, y, 1);
55 return isolate->heap()->ToBoolean(!x->StrictEquals(y));
58 RUNTIME_FUNCTION(Runtime_LessThan) {
59 HandleScope scope(isolate);
60 DCHECK_EQ(2, args.length());
61 CONVERT_ARG_HANDLE_CHECKED(Object, x, 0);
62 CONVERT_ARG_HANDLE_CHECKED(Object, y, 1);
63 Maybe<bool> result = Object::LessThan(isolate, x, y);
64 if (result.IsNothing())
return ReadOnlyRoots(isolate).exception();
65 return isolate->heap()->ToBoolean(result.FromJust());
68 RUNTIME_FUNCTION(Runtime_GreaterThan) {
69 HandleScope scope(isolate);
70 DCHECK_EQ(2, args.length());
71 CONVERT_ARG_HANDLE_CHECKED(Object, x, 0);
72 CONVERT_ARG_HANDLE_CHECKED(Object, y, 1);
73 Maybe<bool> result = Object::GreaterThan(isolate, x, y);
74 if (result.IsNothing())
return ReadOnlyRoots(isolate).exception();
75 return isolate->heap()->ToBoolean(result.FromJust());
78 RUNTIME_FUNCTION(Runtime_LessThanOrEqual) {
79 HandleScope scope(isolate);
80 DCHECK_EQ(2, args.length());
81 CONVERT_ARG_HANDLE_CHECKED(Object, x, 0);
82 CONVERT_ARG_HANDLE_CHECKED(Object, y, 1);
83 Maybe<bool> result = Object::LessThanOrEqual(isolate, x, y);
84 if (result.IsNothing())
return ReadOnlyRoots(isolate).exception();
85 return isolate->heap()->ToBoolean(result.FromJust());
88 RUNTIME_FUNCTION(Runtime_GreaterThanOrEqual) {
89 HandleScope scope(isolate);
90 DCHECK_EQ(2, args.length());
91 CONVERT_ARG_HANDLE_CHECKED(Object, x, 0);
92 CONVERT_ARG_HANDLE_CHECKED(Object, y, 1);
93 Maybe<bool> result = Object::GreaterThanOrEqual(isolate, x, y);
94 if (result.IsNothing())
return ReadOnlyRoots(isolate).exception();
95 return isolate->heap()->ToBoolean(result.FromJust());