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