| 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 #ifndef VM_OBJECT_H_ | 5 #ifndef VM_OBJECT_H_ |
| 6 #define VM_OBJECT_H_ | 6 #define VM_OBJECT_H_ |
| 7 | 7 |
| 8 #include "include/dart_api.h" | 8 #include "include/dart_api.h" |
| 9 #include "platform/assert.h" | 9 #include "platform/assert.h" |
| 10 #include "platform/utils.h" | 10 #include "platform/utils.h" |
| (...skipping 1347 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1358 | 1358 |
| 1359 RawCode* closure_allocation_stub() const { | 1359 RawCode* closure_allocation_stub() const { |
| 1360 return raw_ptr()->closure_allocation_stub_; | 1360 return raw_ptr()->closure_allocation_stub_; |
| 1361 } | 1361 } |
| 1362 void set_closure_allocation_stub(const Code& value) const; | 1362 void set_closure_allocation_stub(const Code& value) const; |
| 1363 | 1363 |
| 1364 // Return the closure function implicitly created for this function. | 1364 // Return the closure function implicitly created for this function. |
| 1365 // If none exists yet, create one and remember it. | 1365 // If none exists yet, create one and remember it. |
| 1366 RawFunction* ImplicitClosureFunction() const; | 1366 RawFunction* ImplicitClosureFunction() const; |
| 1367 | 1367 |
| 1368 RawFunction::Kind kind() const { return raw()->GetKind(); } | 1368 RawFunction::Kind kind() const { |
| 1369 return KindBits::decode(raw_ptr()->kind_tag_); |
| 1370 } |
| 1369 | 1371 |
| 1370 bool is_static() const { return raw()->IsStatic(); } | 1372 bool is_static() const { return StaticBit::decode(raw_ptr()->kind_tag_); } |
| 1371 bool is_const() const { return raw()->IsConst(); } | 1373 bool is_const() const { return ConstBit::decode(raw_ptr()->kind_tag_); } |
| 1372 bool is_external() const { return raw()->IsExternal(); } | 1374 bool is_external() const { return ExternalBit::decode(raw_ptr()->kind_tag_); } |
| 1373 bool IsConstructor() const { | 1375 bool IsConstructor() const { |
| 1374 return (kind() == RawFunction::kConstructor) && !is_static(); | 1376 return (kind() == RawFunction::kConstructor) && !is_static(); |
| 1375 } | 1377 } |
| 1376 bool IsFactory() const { | 1378 bool IsFactory() const { |
| 1377 return (kind() == RawFunction::kConstructor) && is_static(); | 1379 return (kind() == RawFunction::kConstructor) && is_static(); |
| 1378 } | 1380 } |
| 1379 bool IsDynamicFunction() const { | 1381 bool IsDynamicFunction() const { |
| 1380 if (is_static() || is_abstract()) { | 1382 if (is_static() || is_abstract()) { |
| 1381 return false; | 1383 return false; |
| 1382 } | 1384 } |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1451 raw_ptr()->usage_counter_ = value; | 1453 raw_ptr()->usage_counter_ = value; |
| 1452 } | 1454 } |
| 1453 | 1455 |
| 1454 intptr_t deoptimization_counter() const { | 1456 intptr_t deoptimization_counter() const { |
| 1455 return raw_ptr()->deoptimization_counter_; | 1457 return raw_ptr()->deoptimization_counter_; |
| 1456 } | 1458 } |
| 1457 void set_deoptimization_counter(intptr_t value) const { | 1459 void set_deoptimization_counter(intptr_t value) const { |
| 1458 raw_ptr()->deoptimization_counter_ = value; | 1460 raw_ptr()->deoptimization_counter_ = value; |
| 1459 } | 1461 } |
| 1460 | 1462 |
| 1461 bool is_optimizable() const { return raw()->IsOptimizable(); } | 1463 bool is_optimizable() const { |
| 1464 return OptimizableBit::decode(raw_ptr()->kind_tag_); |
| 1465 } |
| 1462 void set_is_optimizable(bool value) const; | 1466 void set_is_optimizable(bool value) const; |
| 1463 | 1467 |
| 1464 bool has_finally() const { return raw()->HasFinally(); } | 1468 bool has_finally() const { |
| 1469 return HasFinallyBit::decode(raw_ptr()->kind_tag_); |
| 1470 } |
| 1465 void set_has_finally(bool value) const; | 1471 void set_has_finally(bool value) const; |
| 1466 | 1472 |
| 1467 bool is_native() const { return raw()->IsNative(); } | 1473 bool is_native() const { return NativeBit::decode(raw_ptr()->kind_tag_); } |
| 1468 void set_is_native(bool value) const; | 1474 void set_is_native(bool value) const; |
| 1469 | 1475 |
| 1470 bool is_abstract() const { return raw()->IsAbstract(); } | 1476 bool is_abstract() const { return AbstractBit::decode(raw_ptr()->kind_tag_); } |
| 1471 void set_is_abstract(bool value) const; | 1477 void set_is_abstract(bool value) const; |
| 1472 | 1478 |
| 1473 bool HasOptimizedCode() const; | 1479 bool HasOptimizedCode() const; |
| 1474 | 1480 |
| 1475 intptr_t NumberOfParameters() const; | 1481 intptr_t NumberOfParameters() const; |
| 1476 intptr_t NumberOfImplicitParameters() const; | 1482 intptr_t NumberOfImplicitParameters() const; |
| 1477 | 1483 |
| 1478 // Returns true if the argument counts are valid for calling this function. | 1484 // Returns true if the argument counts are valid for calling this function. |
| 1479 // Otherwise, it returns false and the reason (if error_message is not NULL). | 1485 // Otherwise, it returns false and the reason (if error_message is not NULL). |
| 1480 bool AreValidArgumentCounts(int num_arguments, | 1486 bool AreValidArgumentCounts(int num_arguments, |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1579 // The function and the class share the same given name. | 1585 // The function and the class share the same given name. |
| 1580 static RawFunction* NewClosureFunction(const String& name, | 1586 static RawFunction* NewClosureFunction(const String& name, |
| 1581 const Function& parent, | 1587 const Function& parent, |
| 1582 intptr_t token_pos); | 1588 intptr_t token_pos); |
| 1583 | 1589 |
| 1584 static const int kCtorPhaseInit = 1 << 0; | 1590 static const int kCtorPhaseInit = 1 << 0; |
| 1585 static const int kCtorPhaseBody = 1 << 1; | 1591 static const int kCtorPhaseBody = 1 << 1; |
| 1586 static const int kCtorPhaseAll = (kCtorPhaseInit | kCtorPhaseBody); | 1592 static const int kCtorPhaseAll = (kCtorPhaseInit | kCtorPhaseBody); |
| 1587 | 1593 |
| 1588 private: | 1594 private: |
| 1595 enum KindTagBits { |
| 1596 kStaticBit = 1, |
| 1597 kConstBit, |
| 1598 kOptimizableBit, |
| 1599 kHasFinallyBit, |
| 1600 kNativeBit, |
| 1601 kAbstractBit, |
| 1602 kExternalBit, |
| 1603 kKindTagBit, |
| 1604 kKindTagSize = 4, |
| 1605 }; |
| 1606 class StaticBit : public BitField<bool, kStaticBit, 1> {}; |
| 1607 class ConstBit : public BitField<bool, kConstBit, 1> {}; |
| 1608 class OptimizableBit : public BitField<bool, kOptimizableBit, 1> {}; |
| 1609 class HasFinallyBit : public BitField<bool, kHasFinallyBit, 1> {}; |
| 1610 class NativeBit : public BitField<bool, kNativeBit, 1> {}; |
| 1611 class AbstractBit : public BitField<bool, kAbstractBit, 1> {}; |
| 1612 class ExternalBit : public BitField<bool, kExternalBit, 1> {}; |
| 1613 class KindBits : |
| 1614 public BitField<RawFunction::Kind, kKindTagBit, kKindTagSize> {}; // NOLINT |
| 1615 |
| 1589 void set_name(const String& value) const; | 1616 void set_name(const String& value) const; |
| 1590 void set_kind(RawFunction::Kind value) const; | 1617 void set_kind(RawFunction::Kind value) const; |
| 1591 void set_is_static(bool is_static) const; | 1618 void set_is_static(bool is_static) const; |
| 1592 void set_is_const(bool is_const) const; | 1619 void set_is_const(bool is_const) const; |
| 1593 void set_is_external(bool value) const; | 1620 void set_is_external(bool value) const; |
| 1594 void set_parent_function(const Function& value) const; | 1621 void set_parent_function(const Function& value) const; |
| 1595 void set_owner(const Class& value) const; | 1622 void set_owner(const Class& value) const; |
| 1596 void set_token_pos(intptr_t value) const; | 1623 void set_token_pos(intptr_t value) const; |
| 1597 void set_implicit_closure_function(const Function& value) const; | 1624 void set_implicit_closure_function(const Function& value) const; |
| 1625 void set_kind_tag(intptr_t value) const; |
| 1598 static RawFunction* New(); | 1626 static RawFunction* New(); |
| 1599 | 1627 |
| 1600 RawString* BuildSignature(bool instantiate, | 1628 RawString* BuildSignature(bool instantiate, |
| 1601 NameVisibility name_visibility, | 1629 NameVisibility name_visibility, |
| 1602 const AbstractTypeArguments& instantiator) const; | 1630 const AbstractTypeArguments& instantiator) const; |
| 1603 | 1631 |
| 1604 // Check the subtype or 'more specific' relationship. | 1632 // Check the subtype or 'more specific' relationship. |
| 1605 bool TypeTest(TypeTestKind test_kind, | 1633 bool TypeTest(TypeTestKind test_kind, |
| 1606 const AbstractTypeArguments& type_arguments, | 1634 const AbstractTypeArguments& type_arguments, |
| 1607 const Function& other, | 1635 const Function& other, |
| (...skipping 3811 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5419 if (this->CharAt(i) != str.CharAt(begin_index + i)) { | 5447 if (this->CharAt(i) != str.CharAt(begin_index + i)) { |
| 5420 return false; | 5448 return false; |
| 5421 } | 5449 } |
| 5422 } | 5450 } |
| 5423 return true; | 5451 return true; |
| 5424 } | 5452 } |
| 5425 | 5453 |
| 5426 } // namespace dart | 5454 } // namespace dart |
| 5427 | 5455 |
| 5428 #endif // VM_OBJECT_H_ | 5456 #endif // VM_OBJECT_H_ |
| OLD | NEW |