OLD | NEW |
1 // Copyright 2014 the V8 project authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "src/arguments.h" | 5 #include "src/arguments.h" |
6 #include "src/isolate-inl.h" | 6 #include "src/isolate-inl.h" |
7 #include "src/runtime/runtime-utils.h" | 7 #include "src/runtime/runtime-utils.h" |
8 | 8 |
9 namespace v8 { | 9 namespace v8 { |
10 namespace internal { | 10 namespace internal { |
11 | 11 |
12 RUNTIME_FUNCTION(Runtime_Multiply) { | 12 RUNTIME_FUNCTION(Runtime_Multiply) { |
13 HandleScope scope(isolate); | 13 HandleScope scope(isolate); |
14 DCHECK_EQ(2, args.length()); | 14 DCHECK_EQ(2, args.length()); |
15 CONVERT_ARG_HANDLE_CHECKED(Object, lhs, 0); | 15 CONVERT_ARG_HANDLE_CHECKED(Object, lhs, 0); |
16 CONVERT_ARG_HANDLE_CHECKED(Object, rhs, 1); | 16 CONVERT_ARG_HANDLE_CHECKED(Object, rhs, 1); |
17 Handle<Object> result; | 17 RETURN_RESULT_OR_FAILURE(isolate, Object::Multiply(isolate, lhs, rhs)); |
18 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, result, | |
19 Object::Multiply(isolate, lhs, rhs)); | |
20 return *result; | |
21 } | 18 } |
22 | 19 |
23 | 20 |
24 RUNTIME_FUNCTION(Runtime_Divide) { | 21 RUNTIME_FUNCTION(Runtime_Divide) { |
25 HandleScope scope(isolate); | 22 HandleScope scope(isolate); |
26 DCHECK_EQ(2, args.length()); | 23 DCHECK_EQ(2, args.length()); |
27 CONVERT_ARG_HANDLE_CHECKED(Object, lhs, 0); | 24 CONVERT_ARG_HANDLE_CHECKED(Object, lhs, 0); |
28 CONVERT_ARG_HANDLE_CHECKED(Object, rhs, 1); | 25 CONVERT_ARG_HANDLE_CHECKED(Object, rhs, 1); |
29 Handle<Object> result; | 26 RETURN_RESULT_OR_FAILURE(isolate, Object::Divide(isolate, lhs, rhs)); |
30 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, result, | |
31 Object::Divide(isolate, lhs, rhs)); | |
32 return *result; | |
33 } | 27 } |
34 | 28 |
35 | 29 |
36 RUNTIME_FUNCTION(Runtime_Modulus) { | 30 RUNTIME_FUNCTION(Runtime_Modulus) { |
37 HandleScope scope(isolate); | 31 HandleScope scope(isolate); |
38 DCHECK_EQ(2, args.length()); | 32 DCHECK_EQ(2, args.length()); |
39 CONVERT_ARG_HANDLE_CHECKED(Object, lhs, 0); | 33 CONVERT_ARG_HANDLE_CHECKED(Object, lhs, 0); |
40 CONVERT_ARG_HANDLE_CHECKED(Object, rhs, 1); | 34 CONVERT_ARG_HANDLE_CHECKED(Object, rhs, 1); |
41 Handle<Object> result; | 35 RETURN_RESULT_OR_FAILURE(isolate, Object::Modulus(isolate, lhs, rhs)); |
42 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, result, | |
43 Object::Modulus(isolate, lhs, rhs)); | |
44 return *result; | |
45 } | 36 } |
46 | 37 |
47 | 38 |
48 RUNTIME_FUNCTION(Runtime_Add) { | 39 RUNTIME_FUNCTION(Runtime_Add) { |
49 HandleScope scope(isolate); | 40 HandleScope scope(isolate); |
50 DCHECK_EQ(2, args.length()); | 41 DCHECK_EQ(2, args.length()); |
51 CONVERT_ARG_HANDLE_CHECKED(Object, lhs, 0); | 42 CONVERT_ARG_HANDLE_CHECKED(Object, lhs, 0); |
52 CONVERT_ARG_HANDLE_CHECKED(Object, rhs, 1); | 43 CONVERT_ARG_HANDLE_CHECKED(Object, rhs, 1); |
53 Handle<Object> result; | 44 RETURN_RESULT_OR_FAILURE(isolate, Object::Add(isolate, lhs, rhs)); |
54 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, result, | |
55 Object::Add(isolate, lhs, rhs)); | |
56 return *result; | |
57 } | 45 } |
58 | 46 |
59 | 47 |
60 RUNTIME_FUNCTION(Runtime_Subtract) { | 48 RUNTIME_FUNCTION(Runtime_Subtract) { |
61 HandleScope scope(isolate); | 49 HandleScope scope(isolate); |
62 DCHECK_EQ(2, args.length()); | 50 DCHECK_EQ(2, args.length()); |
63 CONVERT_ARG_HANDLE_CHECKED(Object, lhs, 0); | 51 CONVERT_ARG_HANDLE_CHECKED(Object, lhs, 0); |
64 CONVERT_ARG_HANDLE_CHECKED(Object, rhs, 1); | 52 CONVERT_ARG_HANDLE_CHECKED(Object, rhs, 1); |
65 Handle<Object> result; | 53 RETURN_RESULT_OR_FAILURE(isolate, Object::Subtract(isolate, lhs, rhs)); |
66 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, result, | |
67 Object::Subtract(isolate, lhs, rhs)); | |
68 return *result; | |
69 } | 54 } |
70 | 55 |
71 | 56 |
72 RUNTIME_FUNCTION(Runtime_ShiftLeft) { | 57 RUNTIME_FUNCTION(Runtime_ShiftLeft) { |
73 HandleScope scope(isolate); | 58 HandleScope scope(isolate); |
74 DCHECK_EQ(2, args.length()); | 59 DCHECK_EQ(2, args.length()); |
75 CONVERT_ARG_HANDLE_CHECKED(Object, lhs, 0); | 60 CONVERT_ARG_HANDLE_CHECKED(Object, lhs, 0); |
76 CONVERT_ARG_HANDLE_CHECKED(Object, rhs, 1); | 61 CONVERT_ARG_HANDLE_CHECKED(Object, rhs, 1); |
77 Handle<Object> result; | 62 RETURN_RESULT_OR_FAILURE(isolate, Object::ShiftLeft(isolate, lhs, rhs)); |
78 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, result, | |
79 Object::ShiftLeft(isolate, lhs, rhs)); | |
80 return *result; | |
81 } | 63 } |
82 | 64 |
83 | 65 |
84 RUNTIME_FUNCTION(Runtime_ShiftRight) { | 66 RUNTIME_FUNCTION(Runtime_ShiftRight) { |
85 HandleScope scope(isolate); | 67 HandleScope scope(isolate); |
86 DCHECK_EQ(2, args.length()); | 68 DCHECK_EQ(2, args.length()); |
87 CONVERT_ARG_HANDLE_CHECKED(Object, lhs, 0); | 69 CONVERT_ARG_HANDLE_CHECKED(Object, lhs, 0); |
88 CONVERT_ARG_HANDLE_CHECKED(Object, rhs, 1); | 70 CONVERT_ARG_HANDLE_CHECKED(Object, rhs, 1); |
89 Handle<Object> result; | 71 RETURN_RESULT_OR_FAILURE(isolate, Object::ShiftRight(isolate, lhs, rhs)); |
90 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, result, | |
91 Object::ShiftRight(isolate, lhs, rhs)); | |
92 return *result; | |
93 } | 72 } |
94 | 73 |
95 | 74 |
96 RUNTIME_FUNCTION(Runtime_ShiftRightLogical) { | 75 RUNTIME_FUNCTION(Runtime_ShiftRightLogical) { |
97 HandleScope scope(isolate); | 76 HandleScope scope(isolate); |
98 DCHECK_EQ(2, args.length()); | 77 DCHECK_EQ(2, args.length()); |
99 CONVERT_ARG_HANDLE_CHECKED(Object, lhs, 0); | 78 CONVERT_ARG_HANDLE_CHECKED(Object, lhs, 0); |
100 CONVERT_ARG_HANDLE_CHECKED(Object, rhs, 1); | 79 CONVERT_ARG_HANDLE_CHECKED(Object, rhs, 1); |
101 Handle<Object> result; | 80 RETURN_RESULT_OR_FAILURE(isolate, |
102 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( | 81 Object::ShiftRightLogical(isolate, lhs, rhs)); |
103 isolate, result, Object::ShiftRightLogical(isolate, lhs, rhs)); | |
104 return *result; | |
105 } | 82 } |
106 | 83 |
107 | 84 |
108 RUNTIME_FUNCTION(Runtime_BitwiseAnd) { | 85 RUNTIME_FUNCTION(Runtime_BitwiseAnd) { |
109 HandleScope scope(isolate); | 86 HandleScope scope(isolate); |
110 DCHECK_EQ(2, args.length()); | 87 DCHECK_EQ(2, args.length()); |
111 CONVERT_ARG_HANDLE_CHECKED(Object, lhs, 0); | 88 CONVERT_ARG_HANDLE_CHECKED(Object, lhs, 0); |
112 CONVERT_ARG_HANDLE_CHECKED(Object, rhs, 1); | 89 CONVERT_ARG_HANDLE_CHECKED(Object, rhs, 1); |
113 Handle<Object> result; | 90 RETURN_RESULT_OR_FAILURE(isolate, Object::BitwiseAnd(isolate, lhs, rhs)); |
114 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, result, | |
115 Object::BitwiseAnd(isolate, lhs, rhs)); | |
116 return *result; | |
117 } | 91 } |
118 | 92 |
119 | 93 |
120 RUNTIME_FUNCTION(Runtime_BitwiseOr) { | 94 RUNTIME_FUNCTION(Runtime_BitwiseOr) { |
121 HandleScope scope(isolate); | 95 HandleScope scope(isolate); |
122 DCHECK_EQ(2, args.length()); | 96 DCHECK_EQ(2, args.length()); |
123 CONVERT_ARG_HANDLE_CHECKED(Object, lhs, 0); | 97 CONVERT_ARG_HANDLE_CHECKED(Object, lhs, 0); |
124 CONVERT_ARG_HANDLE_CHECKED(Object, rhs, 1); | 98 CONVERT_ARG_HANDLE_CHECKED(Object, rhs, 1); |
125 Handle<Object> result; | 99 RETURN_RESULT_OR_FAILURE(isolate, Object::BitwiseOr(isolate, lhs, rhs)); |
126 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, result, | |
127 Object::BitwiseOr(isolate, lhs, rhs)); | |
128 return *result; | |
129 } | 100 } |
130 | 101 |
131 | 102 |
132 RUNTIME_FUNCTION(Runtime_BitwiseXor) { | 103 RUNTIME_FUNCTION(Runtime_BitwiseXor) { |
133 HandleScope scope(isolate); | 104 HandleScope scope(isolate); |
134 DCHECK_EQ(2, args.length()); | 105 DCHECK_EQ(2, args.length()); |
135 CONVERT_ARG_HANDLE_CHECKED(Object, lhs, 0); | 106 CONVERT_ARG_HANDLE_CHECKED(Object, lhs, 0); |
136 CONVERT_ARG_HANDLE_CHECKED(Object, rhs, 1); | 107 CONVERT_ARG_HANDLE_CHECKED(Object, rhs, 1); |
137 Handle<Object> result; | 108 RETURN_RESULT_OR_FAILURE(isolate, Object::BitwiseXor(isolate, lhs, rhs)); |
138 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, result, | |
139 Object::BitwiseXor(isolate, lhs, rhs)); | |
140 return *result; | |
141 } | 109 } |
142 | 110 |
143 RUNTIME_FUNCTION(Runtime_Equal) { | 111 RUNTIME_FUNCTION(Runtime_Equal) { |
144 HandleScope scope(isolate); | 112 HandleScope scope(isolate); |
145 DCHECK_EQ(2, args.length()); | 113 DCHECK_EQ(2, args.length()); |
146 CONVERT_ARG_HANDLE_CHECKED(Object, x, 0); | 114 CONVERT_ARG_HANDLE_CHECKED(Object, x, 0); |
147 CONVERT_ARG_HANDLE_CHECKED(Object, y, 1); | 115 CONVERT_ARG_HANDLE_CHECKED(Object, y, 1); |
148 Maybe<bool> result = Object::Equals(x, y); | 116 Maybe<bool> result = Object::Equals(x, y); |
149 if (!result.IsJust()) return isolate->heap()->exception(); | 117 if (!result.IsJust()) return isolate->heap()->exception(); |
150 return isolate->heap()->ToBoolean(result.FromJust()); | 118 return isolate->heap()->ToBoolean(result.FromJust()); |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
214 Maybe<bool> result = Object::GreaterThanOrEqual(x, y); | 182 Maybe<bool> result = Object::GreaterThanOrEqual(x, y); |
215 if (!result.IsJust()) return isolate->heap()->exception(); | 183 if (!result.IsJust()) return isolate->heap()->exception(); |
216 return isolate->heap()->ToBoolean(result.FromJust()); | 184 return isolate->heap()->ToBoolean(result.FromJust()); |
217 } | 185 } |
218 | 186 |
219 RUNTIME_FUNCTION(Runtime_InstanceOf) { | 187 RUNTIME_FUNCTION(Runtime_InstanceOf) { |
220 HandleScope shs(isolate); | 188 HandleScope shs(isolate); |
221 DCHECK_EQ(2, args.length()); | 189 DCHECK_EQ(2, args.length()); |
222 CONVERT_ARG_HANDLE_CHECKED(Object, object, 0); | 190 CONVERT_ARG_HANDLE_CHECKED(Object, object, 0); |
223 CONVERT_ARG_HANDLE_CHECKED(Object, callable, 1); | 191 CONVERT_ARG_HANDLE_CHECKED(Object, callable, 1); |
224 Handle<Object> result; | 192 RETURN_RESULT_OR_FAILURE(isolate, |
225 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( | 193 Object::InstanceOf(isolate, object, callable)); |
226 isolate, result, Object::InstanceOf(isolate, object, callable)); | |
227 return *result; | |
228 } | 194 } |
229 | 195 |
230 } // namespace internal | 196 } // namespace internal |
231 } // namespace v8 | 197 } // namespace v8 |
OLD | NEW |