Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(63)

Side by Side Diff: src/runtime/runtime-interpreter.cc

Issue 1369123002: [Interpreter] Add interpreter support for compare ops and ToBoolean. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Incorporate bmeurer's comments (https://codereview.chromium.org/1369123002/#msg4). Created 5 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/runtime/runtime.h ('k') | test/cctest/interpreter/test-bytecode-generator.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2015 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/runtime/runtime-utils.h"
6
7 #include "src/arguments.h"
8 #include "src/isolate-inl.h"
9
10 namespace v8 {
11 namespace internal {
12
13
14 static Object* MaybeBooleanHelper(Isolate* isolate, Maybe<bool> result,
15 bool negate = false) {
16 if (result.IsJust()) {
17 return isolate->heap()->ToBoolean(result.FromJust() ^ negate);
18 } else {
19 UNIMPLEMENTED();
20 return nullptr;
21 }
22 }
23
24
25 RUNTIME_FUNCTION(Runtime_InterpreterEquals) {
26 HandleScope scope(isolate);
27 DCHECK_EQ(2, args.length());
28 CONVERT_ARG_HANDLE_CHECKED(Object, x, 0);
29 CONVERT_ARG_HANDLE_CHECKED(Object, y, 1);
30 return MaybeBooleanHelper(isolate, Object::Equals(x, y));
Benedikt Meurer 2015/09/28 10:19:52 Please avoid this indirection and the bit flipping
31 }
32
33
34 RUNTIME_FUNCTION(Runtime_InterpreterNotEquals) {
35 HandleScope scope(isolate);
36 DCHECK_EQ(2, args.length());
37 CONVERT_ARG_HANDLE_CHECKED(Object, x, 0);
38 CONVERT_ARG_HANDLE_CHECKED(Object, y, 1);
39 return MaybeBooleanHelper(isolate, Object::Equals(x, y), true);
40 }
41
42
43 RUNTIME_FUNCTION(Runtime_InterpreterLessThan) {
44 HandleScope scope(isolate);
45 DCHECK_EQ(2, args.length());
46 CONVERT_ARG_HANDLE_CHECKED(Object, x, 0);
47 CONVERT_ARG_HANDLE_CHECKED(Object, y, 1);
48 return MaybeBooleanHelper(isolate, Object::LessThan(x, y));
49 }
50
51
52 RUNTIME_FUNCTION(Runtime_InterpreterGreaterThan) {
53 HandleScope scope(isolate);
54 DCHECK_EQ(2, args.length());
55 CONVERT_ARG_HANDLE_CHECKED(Object, x, 0);
56 CONVERT_ARG_HANDLE_CHECKED(Object, y, 1);
57 return MaybeBooleanHelper(isolate, Object::GreaterThan(x, y));
58 }
59
60
61 RUNTIME_FUNCTION(Runtime_InterpreterLessThanOrEqual) {
62 HandleScope scope(isolate);
63 DCHECK_EQ(2, args.length());
64 CONVERT_ARG_HANDLE_CHECKED(Object, x, 0);
65 CONVERT_ARG_HANDLE_CHECKED(Object, y, 1);
66 return MaybeBooleanHelper(isolate, Object::LessThanOrEqual(x, y));
67 }
68
69
70 RUNTIME_FUNCTION(Runtime_InterpreterGreaterThanOrEqual) {
71 HandleScope scope(isolate);
72 DCHECK_EQ(2, args.length());
73 CONVERT_ARG_HANDLE_CHECKED(Object, x, 0);
74 CONVERT_ARG_HANDLE_CHECKED(Object, y, 1);
75 return MaybeBooleanHelper(isolate, Object::GreaterThanOrEqual(x, y));
76 }
77
78
79 RUNTIME_FUNCTION(Runtime_InterpreterStrictEquals) {
80 SealHandleScope scope(isolate);
81 DCHECK_EQ(2, args.length());
82 CONVERT_ARG_CHECKED(Object, x, 0);
83 CONVERT_ARG_CHECKED(Object, y, 1);
84 return isolate->heap()->ToBoolean(x->StrictEquals(y));
85 }
86
87
88 RUNTIME_FUNCTION(Runtime_InterpreterStrictNotEquals) {
89 SealHandleScope scope(isolate);
90 DCHECK_EQ(2, args.length());
91 CONVERT_ARG_CHECKED(Object, x, 0);
92 CONVERT_ARG_CHECKED(Object, y, 1);
93 return isolate->heap()->ToBoolean(!x->StrictEquals(y));
94 }
95
96
97 RUNTIME_FUNCTION(Runtime_InterpreterCastToBoolean) {
98 SealHandleScope scope(isolate);
99 DCHECK_EQ(1, args.length());
100 CONVERT_ARG_CHECKED(Object, x, 0);
101 return isolate->heap()->ToBoolean(x->BooleanValue());
102 }
103
104
105 } // namespace internal
106 } // namespace v8
OLDNEW
« no previous file with comments | « src/runtime/runtime.h ('k') | test/cctest/interpreter/test-bytecode-generator.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698