Chromium Code Reviews| OLD | NEW |
|---|---|
| 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/object.h" | 5 #include "vm/object.h" |
| 6 | 6 |
| 7 #include "platform/assert.h" | 7 #include "platform/assert.h" |
| 8 #include "vm/assembler.h" | 8 #include "vm/assembler.h" |
| 9 #include "vm/bigint_operations.h" | 9 #include "vm/bigint_operations.h" |
| 10 #include "vm/bootstrap.h" | 10 #include "vm/bootstrap.h" |
| (...skipping 16 matching lines...) Expand all Loading... | |
| 27 #include "vm/runtime_entry.h" | 27 #include "vm/runtime_entry.h" |
| 28 #include "vm/scopes.h" | 28 #include "vm/scopes.h" |
| 29 #include "vm/timer.h" | 29 #include "vm/timer.h" |
| 30 #include "vm/unicode.h" | 30 #include "vm/unicode.h" |
| 31 | 31 |
| 32 namespace dart { | 32 namespace dart { |
| 33 | 33 |
| 34 DEFINE_FLAG(bool, generate_gdb_symbols, false, | 34 DEFINE_FLAG(bool, generate_gdb_symbols, false, |
| 35 "Generate symbols of generated dart functions for debugging with GDB"); | 35 "Generate symbols of generated dart functions for debugging with GDB"); |
| 36 DECLARE_FLAG(bool, trace_compiler); | 36 DECLARE_FLAG(bool, trace_compiler); |
| 37 DECLARE_FLAG(bool, enable_type_checks); | |
| 37 | 38 |
| 38 static const char* kGetterPrefix = "get:"; | 39 static const char* kGetterPrefix = "get:"; |
| 39 static const intptr_t kGetterPrefixLength = strlen(kGetterPrefix); | 40 static const intptr_t kGetterPrefixLength = strlen(kGetterPrefix); |
| 40 static const char* kSetterPrefix = "set:"; | 41 static const char* kSetterPrefix = "set:"; |
| 41 static const intptr_t kSetterPrefixLength = strlen(kSetterPrefix); | 42 static const intptr_t kSetterPrefixLength = strlen(kSetterPrefix); |
| 42 | 43 |
| 43 cpp_vtable Object::handle_vtable_ = 0; | 44 cpp_vtable Object::handle_vtable_ = 0; |
| 44 cpp_vtable Smi::handle_vtable_ = 0; | 45 cpp_vtable Smi::handle_vtable_ = 0; |
| 45 | 46 |
| 46 // These are initialized to a value that will force a illegal memory access if | 47 // These are initialized to a value that will force a illegal memory access if |
| (...skipping 1403 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1450 if (other.is_interface()) { | 1451 if (other.is_interface()) { |
| 1451 Array& interfaces = Array::Handle(this->interfaces()); | 1452 Array& interfaces = Array::Handle(this->interfaces()); |
| 1452 AbstractType& interface = AbstractType::Handle(); | 1453 AbstractType& interface = AbstractType::Handle(); |
| 1453 Class& interface_class = Class::Handle(); | 1454 Class& interface_class = Class::Handle(); |
| 1454 AbstractTypeArguments& interface_args = AbstractTypeArguments::Handle(); | 1455 AbstractTypeArguments& interface_args = AbstractTypeArguments::Handle(); |
| 1455 for (intptr_t i = 0; i < interfaces.Length(); i++) { | 1456 for (intptr_t i = 0; i < interfaces.Length(); i++) { |
| 1456 interface ^= interfaces.At(i); | 1457 interface ^= interfaces.At(i); |
| 1457 interface_class = interface.type_class(); | 1458 interface_class = interface.type_class(); |
| 1458 interface_args = interface.arguments(); | 1459 interface_args = interface.arguments(); |
| 1459 if (!interface_args.IsNull() && !interface_args.IsInstantiated()) { | 1460 if (!interface_args.IsNull() && !interface_args.IsInstantiated()) { |
| 1460 // This type implements an interface that is parameterized with generic | 1461 // This type class implements an interface that is parameterized with |
| 1461 // type(s), e.g. it implements Array<T>. | 1462 // generic type(s), e.g. it implements List<T>. |
| 1462 // The uninstantiated type T must be instantiated using the type | 1463 // The uninstantiated type T must be instantiated using the type |
| 1463 // parameters of this type before performing the type test. | 1464 // parameters of this type before performing the type test. |
| 1464 if (type_arguments.IsNull()) { | 1465 // The type arguments of this type that are referred to by the type |
| 1465 // This type is raw, so the uninstantiated type arguments of the | 1466 // parameters of the interface are at the end of the type vector, |
| 1466 // interface cannot be instantiated and we must check against a raw | 1467 // after the type arguments of the super type of this type. |
| 1467 // interface. | 1468 // The index of the type parameters is adjusted upon finalization. |
| 1468 interface_args = TypeArguments::null(); | 1469 ASSERT(interface.IsFinalized()); |
| 1469 } else { | 1470 interface_args = interface_args.InstantiateFrom(type_arguments); |
| 1470 // The type arguments of this type that are referred to by the type | 1471 // In checked mode, verify that the instantiated interface type |
| 1471 // parameters of the interface are at the end of the type vector, | 1472 // arguments are within the bounds specified by the interface class. |
|
srdjan
2012/03/01 19:05:02
Can you please add comment how is the difference a
regis
2012/03/01 19:54:25
Done.
| |
| 1472 // after the type arguments of the super type of this type. | 1473 if (FLAG_enable_type_checks && !interface_args.IsNull()) { |
| 1473 // The index of the type parameters is adjusted upon finalization. | 1474 AbstractTypeArguments& interface_bounds = |
| 1474 ASSERT(interface.IsFinalized()); | 1475 AbstractTypeArguments::Handle( |
| 1475 interface_args = interface_args.InstantiateFrom(type_arguments); | 1476 interface_class.type_parameter_bounds()); |
| 1476 // TODO(regis): Do we have to consider the bounds of the type | 1477 ASSERT(!interface_bounds.IsNull()); |
| 1477 // parameters of the interface? | 1478 if (!interface_bounds.IsInstantiated()) { |
| 1479 interface_bounds = interface_bounds.InstantiateFrom(type_arguments); | |
| 1480 } | |
| 1481 const intptr_t len = interface_args.Length(); | |
| 1482 if (!interface_args.IsMoreSpecificThan(interface_bounds, len)) { | |
| 1483 // TODO(regis): Handle malformed type error. | |
| 1484 continue; | |
| 1485 } | |
| 1478 } | 1486 } |
| 1479 } | 1487 } |
| 1480 if (interface_class.IsMoreSpecificThan(interface_args, | 1488 if (interface_class.IsMoreSpecificThan(interface_args, |
| 1481 other, | 1489 other, |
| 1482 other_type_arguments)) { | 1490 other_type_arguments)) { |
| 1483 return true; | 1491 return true; |
| 1484 } | 1492 } |
| 1485 } | 1493 } |
| 1486 } | 1494 } |
| 1487 // Check the interface case. | 1495 // Check the interface case. |
| (...skipping 7024 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 8512 result.set_num_args_tested(num_args_tested); | 8520 result.set_num_args_tested(num_args_tested); |
| 8513 // Number of array elements in one test entry (num_args_tested + 1) | 8521 // Number of array elements in one test entry (num_args_tested + 1) |
| 8514 intptr_t len = num_args_tested + 1; | 8522 intptr_t len = num_args_tested + 1; |
| 8515 // IC data array must be null terminated (sentinel entry). | 8523 // IC data array must be null terminated (sentinel entry). |
| 8516 Array& ic_data = Array::Handle(Array::New(len, Heap::kOld)); | 8524 Array& ic_data = Array::Handle(Array::New(len, Heap::kOld)); |
| 8517 result.set_ic_data(ic_data); | 8525 result.set_ic_data(ic_data); |
| 8518 return result.raw(); | 8526 return result.raw(); |
| 8519 } | 8527 } |
| 8520 | 8528 |
| 8521 } // namespace dart | 8529 } // namespace dart |
| OLD | NEW |