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

Side by Side Diff: runtime/lib/object.cc

Issue 2751543003: VM: Simplify lowering of is-tests. (Closed)
Patch Set: fix dbc build Created 3 years, 9 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 | « no previous file | runtime/lib/object_patch.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 #include "vm/bootstrap_natives.h" 5 #include "vm/bootstrap_natives.h"
6 6
7 #include "lib/invocation_mirror.h" 7 #include "lib/invocation_mirror.h"
8 #include "vm/code_patcher.h" 8 #include "vm/code_patcher.h"
9 #include "vm/exceptions.h" 9 #include "vm/exceptions.h"
10 #include "vm/heap.h" 10 #include "vm/heap.h"
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after
162 } 162 }
163 163
164 const TypeArguments& left_type_arguments = 164 const TypeArguments& left_type_arguments =
165 TypeArguments::Handle(left.GetTypeArguments()); 165 TypeArguments::Handle(left.GetTypeArguments());
166 const TypeArguments& right_type_arguments = 166 const TypeArguments& right_type_arguments =
167 TypeArguments::Handle(right.GetTypeArguments()); 167 TypeArguments::Handle(right.GetTypeArguments());
168 return Bool::Get(left_type_arguments.Equals(right_type_arguments)).raw(); 168 return Bool::Get(left_type_arguments.Equals(right_type_arguments)).raw();
169 } 169 }
170 170
171 171
172 DEFINE_NATIVE_ENTRY(Object_instanceOf, 4) { 172 DEFINE_NATIVE_ENTRY(Object_instanceOf, 3) {
173 const Instance& instance = 173 const Instance& instance =
174 Instance::CheckedHandle(zone, arguments->NativeArgAt(0)); 174 Instance::CheckedHandle(zone, arguments->NativeArgAt(0));
175 const TypeArguments& instantiator_type_arguments = 175 const TypeArguments& instantiator_type_arguments =
176 TypeArguments::CheckedHandle(zone, arguments->NativeArgAt(1)); 176 TypeArguments::CheckedHandle(zone, arguments->NativeArgAt(1));
177 const AbstractType& type = 177 const AbstractType& type =
178 AbstractType::CheckedHandle(zone, arguments->NativeArgAt(2)); 178 AbstractType::CheckedHandle(zone, arguments->NativeArgAt(2));
179 const Bool& negate = Bool::CheckedHandle(zone, arguments->NativeArgAt(3));
180 ASSERT(type.IsFinalized()); 179 ASSERT(type.IsFinalized());
181 ASSERT(!type.IsMalformed()); 180 ASSERT(!type.IsMalformed());
182 ASSERT(!type.IsMalbounded()); 181 ASSERT(!type.IsMalbounded());
183 Error& bound_error = Error::Handle(zone, Error::null()); 182 Error& bound_error = Error::Handle(zone, Error::null());
184 const bool is_instance_of = 183 const bool is_instance_of =
185 instance.IsInstanceOf(type, instantiator_type_arguments, &bound_error); 184 instance.IsInstanceOf(type, instantiator_type_arguments, &bound_error);
186 if (FLAG_trace_type_checks) { 185 if (FLAG_trace_type_checks) {
187 const char* result_str = is_instance_of ? "true" : "false"; 186 const char* result_str = is_instance_of ? "true" : "false";
188 OS::Print("Native Object.instanceOf: result %s\n", result_str); 187 OS::Print("Native Object.instanceOf: result %s\n", result_str);
189 const AbstractType& instance_type = 188 const AbstractType& instance_type =
(...skipping 12 matching lines...) Expand all
202 StackFrame* caller_frame = iterator.NextFrame(); 201 StackFrame* caller_frame = iterator.NextFrame();
203 ASSERT(caller_frame != NULL); 202 ASSERT(caller_frame != NULL);
204 const TokenPosition location = caller_frame->GetTokenPos(); 203 const TokenPosition location = caller_frame->GetTokenPos();
205 String& bound_error_message = 204 String& bound_error_message =
206 String::Handle(zone, String::New(bound_error.ToErrorCString())); 205 String::Handle(zone, String::New(bound_error.ToErrorCString()));
207 Exceptions::CreateAndThrowTypeError(location, AbstractType::Handle(zone), 206 Exceptions::CreateAndThrowTypeError(location, AbstractType::Handle(zone),
208 AbstractType::Handle(zone), 207 AbstractType::Handle(zone),
209 Symbols::Empty(), bound_error_message); 208 Symbols::Empty(), bound_error_message);
210 UNREACHABLE(); 209 UNREACHABLE();
211 } 210 }
212 return Bool::Get(negate.value() ? !is_instance_of : is_instance_of).raw(); 211 return Bool::Get(is_instance_of).raw();
213 } 212 }
214 213
215 DEFINE_NATIVE_ENTRY(Object_simpleInstanceOf, 2) { 214 DEFINE_NATIVE_ENTRY(Object_simpleInstanceOf, 2) {
216 // This native is only called when the right hand side passes 215 // This native is only called when the right hand side passes
217 // simpleInstanceOfType and it is a non-negative test. 216 // simpleInstanceOfType and it is a non-negative test.
218 const Instance& instance = 217 const Instance& instance =
219 Instance::CheckedHandle(zone, arguments->NativeArgAt(0)); 218 Instance::CheckedHandle(zone, arguments->NativeArgAt(0));
220 const AbstractType& type = 219 const AbstractType& type =
221 AbstractType::CheckedHandle(zone, arguments->NativeArgAt(1)); 220 AbstractType::CheckedHandle(zone, arguments->NativeArgAt(1));
222 const TypeArguments& instantiator_type_arguments = 221 const TypeArguments& instantiator_type_arguments =
(...skipping 13 matching lines...) Expand all
236 String& bound_error_message = 235 String& bound_error_message =
237 String::Handle(zone, String::New(bound_error.ToErrorCString())); 236 String::Handle(zone, String::New(bound_error.ToErrorCString()));
238 Exceptions::CreateAndThrowTypeError(location, AbstractType::Handle(zone), 237 Exceptions::CreateAndThrowTypeError(location, AbstractType::Handle(zone),
239 AbstractType::Handle(zone), 238 AbstractType::Handle(zone),
240 Symbols::Empty(), bound_error_message); 239 Symbols::Empty(), bound_error_message);
241 UNREACHABLE(); 240 UNREACHABLE();
242 } 241 }
243 return Bool::Get(is_instance_of).raw(); 242 return Bool::Get(is_instance_of).raw();
244 } 243 }
245 244
246 DEFINE_NATIVE_ENTRY(Object_instanceOfNum, 2) {
247 const Instance& instance =
248 Instance::CheckedHandle(zone, arguments->NativeArgAt(0));
249 const Bool& negate = Bool::CheckedHandle(zone, arguments->NativeArgAt(1));
250 bool is_instance_of = instance.IsNumber();
251 if (negate.value()) {
252 is_instance_of = !is_instance_of;
253 }
254 return Bool::Get(is_instance_of).raw();
255 }
256
257
258 DEFINE_NATIVE_ENTRY(Object_instanceOfInt, 2) {
259 const Instance& instance =
260 Instance::CheckedHandle(zone, arguments->NativeArgAt(0));
261 const Bool& negate = Bool::CheckedHandle(zone, arguments->NativeArgAt(1));
262 bool is_instance_of = instance.IsInteger();
263 if (negate.value()) {
264 is_instance_of = !is_instance_of;
265 }
266 return Bool::Get(is_instance_of).raw();
267 }
268
269
270 DEFINE_NATIVE_ENTRY(Object_instanceOfSmi, 2) {
271 const Instance& instance =
272 Instance::CheckedHandle(zone, arguments->NativeArgAt(0));
273 const Bool& negate = Bool::CheckedHandle(zone, arguments->NativeArgAt(1));
274 bool is_instance_of = instance.IsSmi();
275 if (negate.value()) {
276 is_instance_of = !is_instance_of;
277 }
278 return Bool::Get(is_instance_of).raw();
279 }
280
281
282 DEFINE_NATIVE_ENTRY(Object_instanceOfDouble, 2) {
283 const Instance& instance =
284 Instance::CheckedHandle(zone, arguments->NativeArgAt(0));
285 const Bool& negate = Bool::CheckedHandle(zone, arguments->NativeArgAt(1));
286 bool is_instance_of = instance.IsDouble();
287 if (negate.value()) {
288 is_instance_of = !is_instance_of;
289 }
290 return Bool::Get(is_instance_of).raw();
291 }
292
293
294 DEFINE_NATIVE_ENTRY(Object_instanceOfString, 2) {
295 const Instance& instance =
296 Instance::CheckedHandle(zone, arguments->NativeArgAt(0));
297 const Bool& negate = Bool::CheckedHandle(zone, arguments->NativeArgAt(1));
298 bool is_instance_of = instance.IsString();
299 if (negate.value()) {
300 is_instance_of = !is_instance_of;
301 }
302 return Bool::Get(is_instance_of).raw();
303 }
304
305 245
306 DEFINE_NATIVE_ENTRY(Object_as, 3) { 246 DEFINE_NATIVE_ENTRY(Object_as, 3) {
307 const Instance& instance = 247 const Instance& instance =
308 Instance::CheckedHandle(zone, arguments->NativeArgAt(0)); 248 Instance::CheckedHandle(zone, arguments->NativeArgAt(0));
309 const TypeArguments& instantiator_type_arguments = 249 const TypeArguments& instantiator_type_arguments =
310 TypeArguments::CheckedHandle(zone, arguments->NativeArgAt(1)); 250 TypeArguments::CheckedHandle(zone, arguments->NativeArgAt(1));
311 AbstractType& type = 251 AbstractType& type =
312 AbstractType::CheckedHandle(zone, arguments->NativeArgAt(2)); 252 AbstractType::CheckedHandle(zone, arguments->NativeArgAt(2));
313 ASSERT(type.IsFinalized()); 253 ASSERT(type.IsFinalized());
314 ASSERT(!type.IsMalformed()); 254 ASSERT(!type.IsMalformed());
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
405 345
406 DEFINE_NATIVE_ENTRY(Internal_inquireIs64Bit, 0) { 346 DEFINE_NATIVE_ENTRY(Internal_inquireIs64Bit, 0) {
407 #if defined(ARCH_IS_64_BIT) 347 #if defined(ARCH_IS_64_BIT)
408 return Bool::True().raw(); 348 return Bool::True().raw();
409 #else 349 #else
410 return Bool::False().raw(); 350 return Bool::False().raw();
411 #endif // defined(ARCH_IS_64_BIT) 351 #endif // defined(ARCH_IS_64_BIT)
412 } 352 }
413 353
414 } // namespace dart 354 } // namespace dart
OLDNEW
« no previous file with comments | « no previous file | runtime/lib/object_patch.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698