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

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

Issue 9649010: Fix type checks that wrongly ignore malformed types. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 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 | Annotate | Revision Log
« no previous file with comments | « runtime/vm/code_generator_ia32.cc ('k') | tests/language/src/TypeVariableBoundsTest.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) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, 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_X64. 5 #include "vm/globals.h" // Needed here to get TARGET_ARCH_X64.
6 #if defined(TARGET_ARCH_X64) 6 #if defined(TARGET_ARCH_X64)
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 1402 matching lines...) Expand 10 before | Expand all | Expand 10 after
1413 intptr_t token_index, 1413 intptr_t token_index,
1414 const AbstractType& dst_type, 1414 const AbstractType& dst_type,
1415 const String& dst_name) { 1415 const String& dst_name) {
1416 ASSERT(FLAG_enable_type_checks); 1416 ASSERT(FLAG_enable_type_checks);
1417 ASSERT(token_index >= 0); 1417 ASSERT(token_index >= 0);
1418 ASSERT(!dst_type.IsNull()); 1418 ASSERT(!dst_type.IsNull());
1419 ASSERT(dst_type.IsFinalized()); 1419 ASSERT(dst_type.IsFinalized());
1420 1420
1421 // Any expression is assignable to the Dynamic type and to the Object type. 1421 // Any expression is assignable to the Dynamic type and to the Object type.
1422 // Skip the test. 1422 // Skip the test.
1423 if (dst_type.IsDynamicType() || dst_type.IsObjectType()) { 1423 if (!dst_type.IsMalformed() &&
1424 (dst_type.IsDynamicType() || dst_type.IsObjectType())) {
1424 return; 1425 return;
1425 } 1426 }
1426 1427
1427 // It is a compile-time error to explicitly return a value (including null) 1428 // It is a compile-time error to explicitly return a value (including null)
1428 // from a void function. However, functions that do not explicitly return a 1429 // from a void function. However, functions that do not explicitly return a
1429 // value, implicitly return null. This includes void functions. Therefore, we 1430 // value, implicitly return null. This includes void functions. Therefore, we
1430 // skip the type test here and trust the parser to only return null in void 1431 // skip the type test here and trust the parser to only return null in void
1431 // function. 1432 // function.
1432 if (dst_type.IsVoidType()) { 1433 if (dst_type.IsVoidType()) {
1433 return; 1434 return;
(...skipping 14 matching lines...) Expand all
1448 __ PushObject(Object::ZoneHandle()); // Make room for the result. 1449 __ PushObject(Object::ZoneHandle()); // Make room for the result.
1449 const Immediate location = 1450 const Immediate location =
1450 Immediate(reinterpret_cast<int64_t>(Smi::New(token_index))); 1451 Immediate(reinterpret_cast<int64_t>(Smi::New(token_index)));
1451 __ pushq(location); // Push the source location. 1452 __ pushq(location); // Push the source location.
1452 __ pushq(RAX); // Push the source object. 1453 __ pushq(RAX); // Push the source object.
1453 __ PushObject(dst_name); // Push the name of the destination. 1454 __ PushObject(dst_name); // Push the name of the destination.
1454 __ PushObject(error_message); 1455 __ PushObject(error_message);
1455 GenerateCallRuntime(node_id, token_index, kMalformedTypeErrorRuntimeEntry); 1456 GenerateCallRuntime(node_id, token_index, kMalformedTypeErrorRuntimeEntry);
1456 // We should never return here. 1457 // We should never return here.
1457 __ int3(); 1458 __ int3();
1459
1460 __ Bind(&done); // For a null object.
1458 return; 1461 return;
1459 } 1462 }
1460 1463
1461 // If dst_type is instantiated and non-parameterized, we can inline code 1464 // If dst_type is instantiated and non-parameterized, we can inline code
1462 // checking whether the assigned instance is a Smi. 1465 // checking whether the assigned instance is a Smi.
1463 if (dst_type.IsInstantiated()) { 1466 if (dst_type.IsInstantiated()) {
1464 const Class& dst_type_class = Class::ZoneHandle(dst_type.type_class()); 1467 const Class& dst_type_class = Class::ZoneHandle(dst_type.type_class());
1465 const bool dst_class_has_type_arguments = dst_type_class.HasTypeArguments(); 1468 const bool dst_class_has_type_arguments = dst_type_class.HasTypeArguments();
1466 // A Smi object cannot be the instance of a parameterized class. 1469 // A Smi object cannot be the instance of a parameterized class.
1467 // A class equality check is only applicable with a dst type of a 1470 // A class equality check is only applicable with a dst type of a
(...skipping 1202 matching lines...) Expand 10 before | Expand all | Expand 10 after
2670 const Error& error = Error::Handle( 2673 const Error& error = Error::Handle(
2671 Parser::FormatError(script, token_index, "Error", format, args)); 2674 Parser::FormatError(script, token_index, "Error", format, args));
2672 va_end(args); 2675 va_end(args);
2673 Isolate::Current()->long_jump_base()->Jump(1, error); 2676 Isolate::Current()->long_jump_base()->Jump(1, error);
2674 UNREACHABLE(); 2677 UNREACHABLE();
2675 } 2678 }
2676 2679
2677 } // namespace dart 2680 } // namespace dart
2678 2681
2679 #endif // defined TARGET_ARCH_X64 2682 #endif // defined TARGET_ARCH_X64
OLDNEW
« no previous file with comments | « runtime/vm/code_generator_ia32.cc ('k') | tests/language/src/TypeVariableBoundsTest.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698