v8
V8 is Google’s open source high-performance JavaScript and WebAssembly engine, written in C++.
Loading...
Searching...
No Matches
runtime-operators.cc
Go to the documentation of this file.
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
7#include "src/heap/heap-inl.h" // For ToBoolean. TODO(jkummerow): Drop.
8
9namespace v8 {
10namespace internal {
11
12RUNTIME_FUNCTION(Runtime_Add) {
13 HandleScope scope(isolate);
14 DCHECK_EQ(2, args.length());
15 Handle<Object> lhs = args.at(0);
16 Handle<Object> rhs = args.at(1);
17 RETURN_RESULT_OR_FAILURE(isolate, Object::Add(isolate, lhs, rhs));
18}
19
20
21RUNTIME_FUNCTION(Runtime_Equal) {
22 HandleScope scope(isolate);
23 DCHECK_EQ(2, args.length());
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
31RUNTIME_FUNCTION(Runtime_NotEqual) {
32 HandleScope scope(isolate);
33 DCHECK_EQ(2, args.length());
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
41RUNTIME_FUNCTION(Runtime_StrictEqual) {
42 SealHandleScope scope(isolate);
43 DCHECK_EQ(2, args.length());
46 return isolate->heap()->ToBoolean(Object::StrictEquals(x, y));
47}
48
49RUNTIME_FUNCTION(Runtime_StrictNotEqual) {
50 SealHandleScope scope(isolate);
51 DCHECK_EQ(2, args.length());
54 return isolate->heap()->ToBoolean(!Object::StrictEquals(x, y));
55}
56
57RUNTIME_FUNCTION(Runtime_ReferenceEqual) {
58 SealHandleScope scope(isolate);
59 DCHECK_EQ(2, args.length());
62 return isolate->heap()->ToBoolean(x == y);
63}
64
65RUNTIME_FUNCTION(Runtime_LessThan) {
66 HandleScope scope(isolate);
67 DCHECK_EQ(2, args.length());
71 if (result.IsNothing()) return ReadOnlyRoots(isolate).exception();
72 return isolate->heap()->ToBoolean(result.FromJust());
73}
74
75RUNTIME_FUNCTION(Runtime_GreaterThan) {
76 HandleScope scope(isolate);
77 DCHECK_EQ(2, args.length());
81 if (result.IsNothing()) return ReadOnlyRoots(isolate).exception();
82 return isolate->heap()->ToBoolean(result.FromJust());
83}
84
85RUNTIME_FUNCTION(Runtime_LessThanOrEqual) {
86 HandleScope scope(isolate);
87 DCHECK_EQ(2, args.length());
91 if (result.IsNothing()) return ReadOnlyRoots(isolate).exception();
92 return isolate->heap()->ToBoolean(result.FromJust());
93}
94
95RUNTIME_FUNCTION(Runtime_GreaterThanOrEqual) {
96 HandleScope scope(isolate);
97 DCHECK_EQ(2, args.length());
101 if (result.IsNothing()) return ReadOnlyRoots(isolate).exception();
102 return isolate->heap()->ToBoolean(result.FromJust());
103}
104
105} // namespace internal
106} // namespace v8
static V8_WARN_UNUSED_RESULT Maybe< bool > GreaterThan(Isolate *isolate, DirectHandle< Object > x, DirectHandle< Object > y)
static V8_WARN_UNUSED_RESULT MaybeDirectHandle< Object > Add(Isolate *isolate, Handle< Object > lhs, Handle< Object > rhs)
Definition objects.cc:1016
V8_EXPORT_PRIVATE static V8_WARN_UNUSED_RESULT Maybe< bool > Equals(Isolate *isolate, DirectHandle< Object > x, DirectHandle< Object > y)
Definition objects.cc:886
static V8_WARN_UNUSED_RESULT Maybe< bool > LessThan(Isolate *isolate, DirectHandle< Object > x, DirectHandle< Object > y)
static V8_WARN_UNUSED_RESULT Maybe< bool > GreaterThanOrEqual(Isolate *isolate, DirectHandle< Object > x, DirectHandle< Object > y)
static V8_WARN_UNUSED_RESULT Maybe< bool > LessThanOrEqual(Isolate *isolate, DirectHandle< Object > x, DirectHandle< Object > y)
static V8_EXPORT_PRIVATE bool StrictEquals(Tagged< Object > obj, Tagged< Object > that)
Definition objects.cc:986
#define RUNTIME_FUNCTION(Name)
Definition arguments.h:162
#define RETURN_RESULT_OR_FAILURE(isolate, call)
Definition isolate.h:264
base::Vector< const DirectHandle< Object > > args
Definition execution.cc:74
ZoneVector< RpoNumber > & result
int x
#define DCHECK_EQ(v1, v2)
Definition logging.h:485