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

Side by Side Diff: runtime/vm/object.h

Issue 10928160: Limit the maximum number of formal parameters (32K fixed and 32K optional) (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 3 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
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 #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 1458 matching lines...) Expand 10 before | Expand all | Expand 10 after
1469 void set_end_token_pos(intptr_t value) const { 1469 void set_end_token_pos(intptr_t value) const {
1470 raw_ptr()->end_token_pos_ = value; 1470 raw_ptr()->end_token_pos_ = value;
1471 } 1471 }
1472 1472
1473 intptr_t num_fixed_parameters() const { 1473 intptr_t num_fixed_parameters() const {
1474 return raw_ptr()->num_fixed_parameters_; 1474 return raw_ptr()->num_fixed_parameters_;
1475 } 1475 }
1476 void set_num_fixed_parameters(intptr_t value) const; 1476 void set_num_fixed_parameters(intptr_t value) const;
1477 1477
1478 bool HasOptionalParameters() const { 1478 bool HasOptionalParameters() const {
1479 return (num_optional_positional_parameters() + 1479 return raw_ptr()->num_optional_parameters_ != 0;
1480 num_optional_named_parameters()) > 0; 1480 }
1481 intptr_t NumOptionalParameters() const {
1482 const intptr_t num_opt_params = raw_ptr()->num_optional_parameters_;
1483 return (num_opt_params > 0) ? num_opt_params : -num_opt_params;
siva 2012/09/12 22:19:50 Should this be (num_opt_params >= 0) ? num_opt_par
regis 2012/09/12 23:33:32 I think it does not matter. But I agree it is easi
1484 }
1485 void SetNumOptionalParameters(intptr_t num_optional_positional_parameters,
1486 intptr_t num_optional_named_parameters) const;
siva 2012/09/12 22:19:50 I feel this function would be more readable if the
regis 2012/09/12 23:33:32 Done.
1487
1488 intptr_t NumOptionalPositionalParameters() const {
1489 const intptr_t num_opt_params = raw_ptr()->num_optional_parameters_;
1490 return (num_opt_params > 0) ? num_opt_params : 0;
1491 }
1492 intptr_t NumOptionalNamedParameters() const {
1493 const intptr_t num_opt_params = raw_ptr()->num_optional_parameters_;
1494 return (num_opt_params < 0) ? -num_opt_params : 0;
1481 } 1495 }
1482 1496
1483 intptr_t num_optional_positional_parameters() const { 1497 intptr_t NumParameters() const;
1484 return raw_ptr()->num_optional_positional_parameters_;
1485 }
1486 void set_num_optional_positional_parameters(intptr_t value) const;
1487 1498
1488 intptr_t num_optional_named_parameters() const { 1499 intptr_t NumImplicitParameters() const;
1489 return raw_ptr()->num_optional_named_parameters_;
1490 }
1491 void set_num_optional_named_parameters(intptr_t value) const;
1492 1500
1493 static intptr_t usage_counter_offset() { 1501 static intptr_t usage_counter_offset() {
1494 return OFFSET_OF(RawFunction, usage_counter_); 1502 return OFFSET_OF(RawFunction, usage_counter_);
1495 } 1503 }
1496 intptr_t usage_counter() const { 1504 intptr_t usage_counter() const {
1497 return raw_ptr()->usage_counter_; 1505 return raw_ptr()->usage_counter_;
1498 } 1506 }
1499 void set_usage_counter(intptr_t value) const { 1507 void set_usage_counter(intptr_t value) const {
1500 raw_ptr()->usage_counter_ = value; 1508 raw_ptr()->usage_counter_ = value;
1501 } 1509 }
(...skipping 14 matching lines...) Expand all
1516 void set_has_finally(bool value) const; 1524 void set_has_finally(bool value) const;
1517 1525
1518 bool is_native() const { return NativeBit::decode(raw_ptr()->kind_tag_); } 1526 bool is_native() const { return NativeBit::decode(raw_ptr()->kind_tag_); }
1519 void set_is_native(bool value) const; 1527 void set_is_native(bool value) const;
1520 1528
1521 bool is_abstract() const { return AbstractBit::decode(raw_ptr()->kind_tag_); } 1529 bool is_abstract() const { return AbstractBit::decode(raw_ptr()->kind_tag_); }
1522 void set_is_abstract(bool value) const; 1530 void set_is_abstract(bool value) const;
1523 1531
1524 bool HasOptimizedCode() const; 1532 bool HasOptimizedCode() const;
1525 1533
1526 intptr_t NumberOfParameters() const;
1527 intptr_t NumberOfImplicitParameters() const;
1528 void SetNumberOfParameters(intptr_t num_fixed_parameters,
1529 intptr_t num_optional_parameters,
1530 bool are_optional_positional) const;
1531
1532 // Returns true if the argument counts are valid for calling this function. 1534 // Returns true if the argument counts are valid for calling this function.
1533 // Otherwise, it returns false and the reason (if error_message is not NULL). 1535 // Otherwise, it returns false and the reason (if error_message is not NULL).
1534 bool AreValidArgumentCounts(int num_arguments, 1536 bool AreValidArgumentCounts(int num_arguments,
1535 int num_named_arguments, 1537 int num_named_arguments,
1536 String* error_message) const; 1538 String* error_message) const;
1537 1539
1538 // Returns true if the total argument count and the names of optional 1540 // Returns true if the total argument count and the names of optional
1539 // arguments are valid for calling this function. 1541 // arguments are valid for calling this function.
1540 // Otherwise, it returns false and the reason (if error_message is not NULL). 1542 // Otherwise, it returns false and the reason (if error_message is not NULL).
1541 bool AreValidArguments(int num_arguments, 1543 bool AreValidArguments(int num_arguments,
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
1673 1675
1674 void set_name(const String& value) const; 1676 void set_name(const String& value) const;
1675 void set_kind(RawFunction::Kind value) const; 1677 void set_kind(RawFunction::Kind value) const;
1676 void set_is_static(bool value) const; 1678 void set_is_static(bool value) const;
1677 void set_is_const(bool value) const; 1679 void set_is_const(bool value) const;
1678 void set_is_external(bool value) const; 1680 void set_is_external(bool value) const;
1679 void set_parent_function(const Function& value) const; 1681 void set_parent_function(const Function& value) const;
1680 void set_owner(const Object& value) const; 1682 void set_owner(const Object& value) const;
1681 void set_token_pos(intptr_t value) const; 1683 void set_token_pos(intptr_t value) const;
1682 void set_implicit_closure_function(const Function& value) const; 1684 void set_implicit_closure_function(const Function& value) const;
1685 void set_num_optional_parameters(intptr_t value) const; // Encoded value.
1683 void set_kind_tag(intptr_t value) const; 1686 void set_kind_tag(intptr_t value) const;
1684 static RawFunction* New(); 1687 static RawFunction* New();
1685 1688
1686 RawString* BuildSignature(bool instantiate, 1689 RawString* BuildSignature(bool instantiate,
1687 NameVisibility name_visibility, 1690 NameVisibility name_visibility,
1688 const AbstractTypeArguments& instantiator) const; 1691 const AbstractTypeArguments& instantiator) const;
1689 1692
1690 // Check the subtype or 'more specific' relationship. 1693 // Check the subtype or 'more specific' relationship.
1691 bool TypeTest(TypeTestKind test_kind, 1694 bool TypeTest(TypeTestKind test_kind,
1692 const AbstractTypeArguments& type_arguments, 1695 const AbstractTypeArguments& type_arguments,
(...skipping 3882 matching lines...) Expand 10 before | Expand all | Expand 10 after
5575 if (this->CharAt(i) != str.CharAt(begin_index + i)) { 5578 if (this->CharAt(i) != str.CharAt(begin_index + i)) {
5576 return false; 5579 return false;
5577 } 5580 }
5578 } 5581 }
5579 return true; 5582 return true;
5580 } 5583 }
5581 5584
5582 } // namespace dart 5585 } // namespace dart
5583 5586
5584 #endif // VM_OBJECT_H_ 5587 #endif // VM_OBJECT_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698