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

Side by Side Diff: runtime/vm/code_generator_ia32.cc

Issue 8592004: null is an instance of Dynamic (fix issue 443). (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 9 years, 1 month 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 | Annotate | Revision Log
« no previous file with comments | « runtime/vm/code_generator.cc ('k') | runtime/vm/object.cc » ('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/globals.h" // Needed here to get TARGET_ARCH_IA32. 5 #include "vm/globals.h" // Needed here to get TARGET_ARCH_IA32.
6 #if defined(TARGET_ARCH_IA32) 6 #if defined(TARGET_ARCH_IA32)
7 7
8 #include "vm/code_generator.h" 8 #include "vm/code_generator.h"
9 9
10 #include "lib/error.h" 10 #include "lib/error.h"
(...skipping 1381 matching lines...) Expand 10 before | Expand all | Expand 10 after
1392 const Bool& bool_false = Bool::ZoneHandle(Bool::False()); 1392 const Bool& bool_false = Bool::ZoneHandle(Bool::False());
1393 1393
1394 // All instances are of a subtype of the Object type. 1394 // All instances are of a subtype of the Object type.
1395 const Type& object_type = 1395 const Type& object_type =
1396 Type::Handle(Isolate::Current()->object_store()->object_type()); 1396 Type::Handle(Isolate::Current()->object_store()->object_type());
1397 if (type.IsInstantiated() && object_type.IsSubtypeOf(type)) { 1397 if (type.IsInstantiated() && object_type.IsSubtypeOf(type)) {
1398 __ PushObject(negate_result ? bool_false : bool_true); 1398 __ PushObject(negate_result ? bool_false : bool_true);
1399 return; 1399 return;
1400 } 1400 }
1401 1401
1402 // A NULL object always returns false for all types other than Object
1403 // (and Null).
1404 const Immediate raw_null = 1402 const Immediate raw_null =
1405 Immediate(reinterpret_cast<intptr_t>(Object::null())); 1403 Immediate(reinterpret_cast<intptr_t>(Object::null()));
1406 Label non_null, done; 1404 Label done;
1407 __ cmpl(EAX, raw_null);
1408 __ j(NOT_EQUAL, &non_null, Assembler::kNearJump);
1409 __ PushObject(negate_result ? bool_true : bool_false);
1410 __ jmp(&done, Assembler::kNearJump);
1411
1412 __ Bind(&non_null);
1413 // If type is instantiated and non-parameterized, we can inline code 1405 // If type is instantiated and non-parameterized, we can inline code
1414 // checking whether the tested instance is a Smi. 1406 // checking whether the tested instance is a Smi.
1415 if (type.IsInstantiated()) { 1407 if (type.IsInstantiated()) {
1408 // A null object is not an instance of any type, except of Object, Dynamic,
1409 // and Null type.
srdjan 2011/11/21 19:37:08 It may be simpler to explain this in positive form
regis 2011/11/21 19:53:31 I'll remove the mention of Null type, since it is
1410 // We can only inline this null check if the type is instantiated at compile
1411 // time, since an uninstantiated type at compile time could be Object or
1412 // Dynamic at run time.
1413 Label non_null;
1414 __ cmpl(EAX, raw_null);
1415 __ j(NOT_EQUAL, &non_null, Assembler::kNearJump);
1416 __ PushObject(negate_result ? bool_true : bool_false);
1417 __ jmp(&done, Assembler::kNearJump);
1418
1419 __ Bind(&non_null);
1420
1416 const Class& type_class = Class::ZoneHandle(type.type_class()); 1421 const Class& type_class = Class::ZoneHandle(type.type_class());
1417 const bool requires_type_arguments = type_class.HasTypeArguments(); 1422 const bool requires_type_arguments = type_class.HasTypeArguments();
1418 // A Smi object cannot be the instance of a parameterized class. 1423 // A Smi object cannot be the instance of a parameterized class.
1419 // A class equality check is only applicable with a dst type of a 1424 // A class equality check is only applicable with a dst type of a
1420 // non-parameterized class or with a raw dst type of a parameterized class. 1425 // non-parameterized class or with a raw dst type of a parameterized class.
1421 if (requires_type_arguments) { 1426 if (requires_type_arguments) {
1422 const TypeArguments& type_arguments = 1427 const TypeArguments& type_arguments =
1423 TypeArguments::Handle(type.arguments()); 1428 TypeArguments::Handle(type.arguments());
1424 const bool is_raw_type = type_arguments.IsNull() || 1429 const bool is_raw_type = type_arguments.IsNull() ||
1425 type_arguments.IsDynamicTypes(type_arguments.Length()); 1430 type_arguments.IsDynamicTypes(type_arguments.Length());
(...skipping 1328 matching lines...) Expand 10 before | Expand all | Expand 10 after
2754 message_buffer, kMessageBufferSize, 2759 message_buffer, kMessageBufferSize,
2755 format, args); 2760 format, args);
2756 va_end(args); 2761 va_end(args);
2757 Isolate::Current()->long_jump_base()->Jump(1, message_buffer); 2762 Isolate::Current()->long_jump_base()->Jump(1, message_buffer);
2758 UNREACHABLE(); 2763 UNREACHABLE();
2759 } 2764 }
2760 2765
2761 } // namespace dart 2766 } // namespace dart
2762 2767
2763 #endif // defined TARGET_ARCH_IA32 2768 #endif // defined TARGET_ARCH_IA32
OLDNEW
« no previous file with comments | « runtime/vm/code_generator.cc ('k') | runtime/vm/object.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698