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

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

Issue 10796004: Consolidate a few fields in RawFunction using bitfields. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 5 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 1337 matching lines...) Expand 10 before | Expand all | Expand 10 after
1348 1348
1349 RawCode* closure_allocation_stub() const { 1349 RawCode* closure_allocation_stub() const {
1350 return raw_ptr()->closure_allocation_stub_; 1350 return raw_ptr()->closure_allocation_stub_;
1351 } 1351 }
1352 void set_closure_allocation_stub(const Code& value) const; 1352 void set_closure_allocation_stub(const Code& value) const;
1353 1353
1354 // Return the closure function implicitly created for this function. 1354 // Return the closure function implicitly created for this function.
1355 // If none exists yet, create one and remember it. 1355 // If none exists yet, create one and remember it.
1356 RawFunction* ImplicitClosureFunction() const; 1356 RawFunction* ImplicitClosureFunction() const;
1357 1357
1358 RawFunction::Kind kind() const { return raw_ptr()->kind_; } 1358 RawFunction::Kind kind() const { return raw()->GetKind(); }
1359 1359
1360 bool is_static() const { return raw_ptr()->is_static_; } 1360 bool is_static() const { return raw()->IsStatic(); }
1361 bool is_const() const { return raw_ptr()->is_const_; } 1361 bool is_const() const { return raw()->IsConst(); }
1362 bool IsConstructor() const { 1362 bool IsConstructor() const {
1363 return (kind() == RawFunction::kConstructor) && !is_static(); 1363 return (kind() == RawFunction::kConstructor) && !is_static();
1364 } 1364 }
1365 bool IsFactory() const { 1365 bool IsFactory() const {
1366 return (kind() == RawFunction::kConstructor) && is_static(); 1366 return (kind() == RawFunction::kConstructor) && is_static();
1367 } 1367 }
1368 bool IsAbstract() const {
1369 return kind() == RawFunction::kAbstract;
1370 }
1371 bool IsDynamicFunction() const { 1368 bool IsDynamicFunction() const {
1372 if (is_static()) { 1369 if (is_static() || is_abstract()) {
turnidge 2012/07/18 04:57:15 What do you think of this? I'm preserving the cur
1373 return false; 1370 return false;
1374 } 1371 }
1375 switch (kind()) { 1372 switch (kind()) {
1376 case RawFunction::kFunction: 1373 case RawFunction::kFunction:
1377 case RawFunction::kGetterFunction: 1374 case RawFunction::kGetterFunction:
1378 case RawFunction::kSetterFunction: 1375 case RawFunction::kSetterFunction:
1379 case RawFunction::kImplicitGetter: 1376 case RawFunction::kImplicitGetter:
1380 case RawFunction::kImplicitSetter: 1377 case RawFunction::kImplicitSetter:
1381 return true; 1378 return true;
1382 case RawFunction::kClosureFunction: 1379 case RawFunction::kClosureFunction:
1383 case RawFunction::kConstructor: 1380 case RawFunction::kConstructor:
1384 case RawFunction::kConstImplicitGetter: 1381 case RawFunction::kConstImplicitGetter:
1385 case RawFunction::kAbstract:
1386 return false; 1382 return false;
1387 default: 1383 default:
1388 UNREACHABLE(); 1384 UNREACHABLE();
1389 return false; 1385 return false;
1390 } 1386 }
1391 } 1387 }
1392 bool IsStaticFunction() const { 1388 bool IsStaticFunction() const {
1393 if (!is_static()) { 1389 if (!is_static()) {
1394 return false; 1390 return false;
1395 } 1391 }
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
1444 raw_ptr()->usage_counter_ = value; 1440 raw_ptr()->usage_counter_ = value;
1445 } 1441 }
1446 1442
1447 intptr_t deoptimization_counter() const { 1443 intptr_t deoptimization_counter() const {
1448 return raw_ptr()->deoptimization_counter_; 1444 return raw_ptr()->deoptimization_counter_;
1449 } 1445 }
1450 void set_deoptimization_counter(intptr_t value) const { 1446 void set_deoptimization_counter(intptr_t value) const {
1451 raw_ptr()->deoptimization_counter_ = value; 1447 raw_ptr()->deoptimization_counter_ = value;
1452 } 1448 }
1453 1449
1454 bool is_optimizable() const { 1450 bool is_optimizable() const { return raw()->IsOptimizable(); }
1455 return raw_ptr()->is_optimizable_;
1456 }
1457 void set_is_optimizable(bool value) const; 1451 void set_is_optimizable(bool value) const;
1458 1452
1459 bool is_native() const { return raw_ptr()->is_native_; } 1453 bool is_native() const { return raw()->IsNative(); }
1460 void set_is_native(bool value) const; 1454 void set_is_native(bool value) const;
1461 1455
1456 bool is_abstract() const { return raw()->IsAbstract(); }
1457 void set_is_abstract(bool value) const;
1458
1462 bool HasOptimizedCode() const; 1459 bool HasOptimizedCode() const;
1463 1460
1464 intptr_t NumberOfParameters() const; 1461 intptr_t NumberOfParameters() const;
1465 intptr_t NumberOfImplicitParameters() const; 1462 intptr_t NumberOfImplicitParameters() const;
1466 1463
1467 // Returns true if the argument counts are valid for calling this function. 1464 // Returns true if the argument counts are valid for calling this function.
1468 // Otherwise, it returns false and the reason (if error_message is not NULL). 1465 // Otherwise, it returns false and the reason (if error_message is not NULL).
1469 bool AreValidArgumentCounts(int num_arguments, 1466 bool AreValidArgumentCounts(int num_arguments,
1470 int num_named_arguments, 1467 int num_named_arguments,
1471 String* error_message) const; 1468 String* error_message) const;
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
1550 1547
1551 1548
1552 static intptr_t InstanceSize() { 1549 static intptr_t InstanceSize() {
1553 return RoundedAllocationSize(sizeof(RawFunction)); 1550 return RoundedAllocationSize(sizeof(RawFunction));
1554 } 1551 }
1555 1552
1556 static RawFunction* New(const String& name, 1553 static RawFunction* New(const String& name,
1557 RawFunction::Kind kind, 1554 RawFunction::Kind kind,
1558 bool is_static, 1555 bool is_static,
1559 bool is_const, 1556 bool is_const,
1557 bool is_abstract,
1560 intptr_t token_pos); 1558 intptr_t token_pos);
1561 1559
1562 // Allocates a new Function object representing a closure function, as well as 1560 // Allocates a new Function object representing a closure function, as well as
1563 // a new associated Class object representing the signature class of the 1561 // a new associated Class object representing the signature class of the
1564 // function. 1562 // function.
1565 // The function and the class share the same given name. 1563 // The function and the class share the same given name.
1566 static RawFunction* NewClosureFunction(const String& name, 1564 static RawFunction* NewClosureFunction(const String& name,
1567 const Function& parent, 1565 const Function& parent,
1568 intptr_t token_pos); 1566 intptr_t token_pos);
1569 1567
(...skipping 3598 matching lines...) Expand 10 before | Expand all | Expand 10 after
5168 if (this->CharAt(i) != str.CharAt(begin_index + i)) { 5166 if (this->CharAt(i) != str.CharAt(begin_index + i)) {
5169 return false; 5167 return false;
5170 } 5168 }
5171 } 5169 }
5172 return true; 5170 return true;
5173 } 5171 }
5174 5172
5175 } // namespace dart 5173 } // namespace dart
5176 5174
5177 #endif // VM_OBJECT_H_ 5175 #endif // VM_OBJECT_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698