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

Side by Side Diff: vm/object.cc

Issue 10967044: Fix the types used in bit fields. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/runtime/
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
« no previous file with comments | « vm/object.h ('k') | vm/raw_object_snapshot.cc » ('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/object.h" 5 #include "vm/object.h"
6 6
7 #include "include/dart_api.h" 7 #include "include/dart_api.h"
8 #include "platform/assert.h" 8 #include "platform/assert.h"
9 #include "vm/assembler.h" 9 #include "vm/assembler.h"
10 #include "vm/bigint_operations.h" 10 #include "vm/bigint_operations.h"
(...skipping 1416 matching lines...) Expand 10 before | Expand all | Expand 10 after
1427 void Class::set_signature_function(const Function& value) const { 1427 void Class::set_signature_function(const Function& value) const {
1428 ASSERT(value.IsClosureFunction() || value.IsSignatureFunction()); 1428 ASSERT(value.IsClosureFunction() || value.IsSignatureFunction());
1429 StorePointer(&raw_ptr()->signature_function_, value.raw()); 1429 StorePointer(&raw_ptr()->signature_function_, value.raw());
1430 } 1430 }
1431 1431
1432 1432
1433 void Class::set_class_state(RawClass::ClassState state) const { 1433 void Class::set_class_state(RawClass::ClassState state) const {
1434 ASSERT((state == RawClass::kAllocated) || 1434 ASSERT((state == RawClass::kAllocated) ||
1435 (state == RawClass::kPreFinalized) || 1435 (state == RawClass::kPreFinalized) ||
1436 (state == RawClass::kFinalized)); 1436 (state == RawClass::kFinalized));
1437 uword bits = raw_ptr()->state_bits_; 1437 raw_ptr()->state_bits_ = static_cast<uint8_t>(
1438 raw_ptr()->state_bits_ = StateBits::update(state, bits); 1438 StateBits::update(state, raw_ptr()->state_bits_));
1439 } 1439 }
1440 1440
1441 1441
1442 void Class::set_state_bits(uint8_t bits) const { 1442 void Class::set_state_bits(uint8_t bits) const {
1443 raw_ptr()->state_bits_ = bits; 1443 raw_ptr()->state_bits_ = bits;
1444 } 1444 }
1445 1445
1446 1446
1447 void Class::set_library(const Library& value) const { 1447 void Class::set_library(const Library& value) const {
1448 StorePointer(&raw_ptr()->library_, value.raw()); 1448 StorePointer(&raw_ptr()->library_, value.raw());
(...skipping 437 matching lines...) Expand 10 before | Expand all | Expand 10 after
1886 } 1886 }
1887 1887
1888 1888
1889 void Class::set_token_pos(intptr_t token_pos) const { 1889 void Class::set_token_pos(intptr_t token_pos) const {
1890 ASSERT(token_pos >= 0); 1890 ASSERT(token_pos >= 0);
1891 raw_ptr()->token_pos_ = token_pos; 1891 raw_ptr()->token_pos_ = token_pos;
1892 } 1892 }
1893 1893
1894 1894
1895 void Class::set_is_interface() const { 1895 void Class::set_is_interface() const {
1896 uword bits = raw_ptr()->state_bits_; 1896 raw_ptr()->state_bits_ = static_cast<uint8_t>(
1897 raw_ptr()->state_bits_ = InterfaceBit::update(true, bits); 1897 InterfaceBit::update(true, raw_ptr()->state_bits_));
1898 } 1898 }
1899 1899
1900 void Class::set_is_abstract() const { 1900 void Class::set_is_abstract() const {
1901 uword bits = raw_ptr()->state_bits_; 1901 raw_ptr()->state_bits_ = static_cast<uint8_t>(
1902 raw_ptr()->state_bits_ = AbstractBit::update(true, bits); 1902 AbstractBit::update(true, raw_ptr()->state_bits_));
1903 } 1903 }
1904 1904
1905 1905
1906 void Class::set_is_const() const { 1906 void Class::set_is_const() const {
1907 uword bits = raw_ptr()->state_bits_; 1907 raw_ptr()->state_bits_ = static_cast<uint8_t>(
1908 raw_ptr()->state_bits_ = ConstBit::update(true, bits); 1908 ConstBit::update(true, raw_ptr()->state_bits_));
1909 } 1909 }
1910 1910
1911 1911
1912 void Class::set_is_finalized() const { 1912 void Class::set_is_finalized() const {
1913 ASSERT(!is_finalized()); 1913 ASSERT(!is_finalized());
1914 uword bits = raw_ptr()->state_bits_; 1914 raw_ptr()->state_bits_ = static_cast<uint8_t>(
1915 raw_ptr()->state_bits_ = StateBits::update(RawClass::kFinalized, bits); 1915 StateBits::update(RawClass::kFinalized, raw_ptr()->state_bits_));
1916 } 1916 }
1917 1917
1918 1918
1919 void Class::set_is_prefinalized() const { 1919 void Class::set_is_prefinalized() const {
1920 ASSERT(!is_finalized()); 1920 ASSERT(!is_finalized());
1921 uword bits = raw_ptr()->state_bits_; 1921 raw_ptr()->state_bits_ = static_cast<uint8_t>(
1922 raw_ptr()->state_bits_ = StateBits::update(RawClass::kPreFinalized, bits); 1922 StateBits::update(RawClass::kPreFinalized, raw_ptr()->state_bits_));
1923 } 1923 }
1924 1924
1925 1925
1926 void Class::set_interfaces(const Array& value) const { 1926 void Class::set_interfaces(const Array& value) const {
1927 // Verification and resolving of interfaces occurs in finalizer. 1927 // Verification and resolving of interfaces occurs in finalizer.
1928 ASSERT(!value.IsNull()); 1928 ASSERT(!value.IsNull());
1929 StorePointer(&raw_ptr()->interfaces_, value.raw()); 1929 StorePointer(&raw_ptr()->interfaces_, value.raw());
1930 } 1930 }
1931 1931
1932 1932
(...skipping 2070 matching lines...) Expand 10 before | Expand all | Expand 10 after
4003 parameter_names.SetAt(index, value); 4003 parameter_names.SetAt(index, value);
4004 } 4004 }
4005 4005
4006 4006
4007 void Function::set_parameter_names(const Array& value) const { 4007 void Function::set_parameter_names(const Array& value) const {
4008 StorePointer(&raw_ptr()->parameter_names_, value.raw()); 4008 StorePointer(&raw_ptr()->parameter_names_, value.raw());
4009 } 4009 }
4010 4010
4011 4011
4012 void Function::set_kind(RawFunction::Kind value) const { 4012 void Function::set_kind(RawFunction::Kind value) const {
4013 uword bits = raw_ptr()->kind_tag_; 4013 set_kind_tag(KindBits::update(value, raw_ptr()->kind_tag_));
4014 raw_ptr()->kind_tag_ = KindBits::update(value, bits);
4015 } 4014 }
4016 4015
4017 4016
4018 void Function::set_is_static(bool value) const { 4017 void Function::set_is_static(bool value) const {
4019 uword bits = raw_ptr()->kind_tag_; 4018 set_kind_tag(StaticBit::update(value, raw_ptr()->kind_tag_));
4020 raw_ptr()->kind_tag_ = StaticBit::update(value, bits);
4021 } 4019 }
4022 4020
4023 4021
4024 void Function::set_is_const(bool value) const { 4022 void Function::set_is_const(bool value) const {
4025 uword bits = raw_ptr()->kind_tag_; 4023 set_kind_tag(ConstBit::update(value, raw_ptr()->kind_tag_));
4026 raw_ptr()->kind_tag_ = ConstBit::update(value, bits);
4027 } 4024 }
4028 4025
4029 4026
4030 void Function::set_is_external(bool value) const { 4027 void Function::set_is_external(bool value) const {
4031 uword bits = raw_ptr()->kind_tag_; 4028 set_kind_tag(ExternalBit::update(value, raw_ptr()->kind_tag_));
4032 raw_ptr()->kind_tag_ = ExternalBit::update(value, bits);
4033 } 4029 }
4034 4030
4035 4031
4036 void Function::set_token_pos(intptr_t value) const { 4032 void Function::set_token_pos(intptr_t value) const {
4037 ASSERT(value >= 0); 4033 ASSERT(value >= 0);
4038 raw_ptr()->token_pos_ = value; 4034 raw_ptr()->token_pos_ = value;
4039 } 4035 }
4040 4036
4041 4037
4042 void Function::set_kind_tag(intptr_t value) const { 4038 void Function::set_kind_tag(intptr_t value) const {
4043 raw_ptr()->kind_tag_ = value; 4039 raw_ptr()->kind_tag_ = static_cast<uint16_t>(value);
4044 } 4040 }
4045 4041
4046 4042
4047 void Function::set_num_fixed_parameters(intptr_t value) const { 4043 void Function::set_num_fixed_parameters(intptr_t value) const {
4048 ASSERT(value >= 0); 4044 ASSERT(value >= 0);
4049 ASSERT(Utils::IsInt(16, value)); 4045 ASSERT(Utils::IsInt(16, value));
4050 raw_ptr()->num_fixed_parameters_ = static_cast<int16_t>(value); 4046 raw_ptr()->num_fixed_parameters_ = static_cast<int16_t>(value);
4051 } 4047 }
4052 4048
4053 4049
(...skipping 14 matching lines...) Expand all
4068 4064
4069 4065
4070 bool Function::is_optimizable() const { 4066 bool Function::is_optimizable() const {
4071 return OptimizableBit::decode(raw_ptr()->kind_tag_) && 4067 return OptimizableBit::decode(raw_ptr()->kind_tag_) &&
4072 (script() != Script::null()) && 4068 (script() != Script::null()) &&
4073 !is_native(); 4069 !is_native();
4074 } 4070 }
4075 4071
4076 4072
4077 void Function::set_is_optimizable(bool value) const { 4073 void Function::set_is_optimizable(bool value) const {
4078 uword bits = raw_ptr()->kind_tag_; 4074 set_kind_tag(OptimizableBit::update(value, raw_ptr()->kind_tag_));
4079 raw_ptr()->kind_tag_ = OptimizableBit::update(value, bits);
4080 } 4075 }
4081 4076
4082 4077
4083 void Function::set_has_finally(bool value) const { 4078 void Function::set_has_finally(bool value) const {
4084 uword bits = raw_ptr()->kind_tag_; 4079 set_kind_tag(HasFinallyBit::update(value, raw_ptr()->kind_tag_));
4085 raw_ptr()->kind_tag_ = HasFinallyBit::update(value, bits);
4086 } 4080 }
4087 4081
4088 4082
4089 void Function::set_is_native(bool value) const { 4083 void Function::set_is_native(bool value) const {
4090 uword bits = raw_ptr()->kind_tag_; 4084 set_kind_tag(NativeBit::update(value, raw_ptr()->kind_tag_));
4091 raw_ptr()->kind_tag_ = NativeBit::update(value, bits);
4092 } 4085 }
4093 4086
4094 4087
4095 void Function::set_is_abstract(bool value) const { 4088 void Function::set_is_abstract(bool value) const {
4096 uword bits = raw_ptr()->kind_tag_; 4089 set_kind_tag(AbstractBit::update(value, raw_ptr()->kind_tag_));
4097 raw_ptr()->kind_tag_ = AbstractBit::update(value, bits);
4098 } 4090 }
4099 4091
4100 4092
4101 intptr_t Function::NumParameters() const { 4093 intptr_t Function::NumParameters() const {
4102 return num_fixed_parameters() + NumOptionalParameters(); 4094 return num_fixed_parameters() + NumOptionalParameters();
4103 } 4095 }
4104 4096
4105 4097
4106 intptr_t Function::NumImplicitParameters() const { 4098 intptr_t Function::NumImplicitParameters() const {
4107 if (kind() == RawFunction::kConstructor) { 4099 if (kind() == RawFunction::kConstructor) {
(...skipping 7726 matching lines...) Expand 10 before | Expand all | Expand 10 after
11834 } 11826 }
11835 return result.raw(); 11827 return result.raw();
11836 } 11828 }
11837 11829
11838 11830
11839 const char* WeakProperty::ToCString() const { 11831 const char* WeakProperty::ToCString() const {
11840 return "_WeakProperty"; 11832 return "_WeakProperty";
11841 } 11833 }
11842 11834
11843 } // namespace dart 11835 } // namespace dart
OLDNEW
« no previous file with comments | « vm/object.h ('k') | vm/raw_object_snapshot.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698