V8 API Reference, 7.2.502.16 (for Deno 0.2.4)
runtime-operators.cc
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/isolate-inl.h"
8 #include "src/runtime/runtime-utils.h"
9 
10 namespace v8 {
11 namespace internal {
12 
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));
19 }
20 
21 
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());
30 }
31 
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());
40 }
41 
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));
48 }
49 
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));
56 }
57 
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());
66 }
67 
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());
76 }
77 
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());
86 }
87 
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());
96 }
97 
98 } // namespace internal
99 } // namespace v8
Definition: libplatform.h:13