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

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

Issue 1589643002: Source positions for constructors and lots of async machinery (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 years, 11 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
« no previous file with comments | « runtime/vm/intrinsifier.cc ('k') | runtime/vm/object_test.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/cpu.h" 10 #include "vm/cpu.h"
(...skipping 1158 matching lines...) Expand 10 before | Expand all | Expand 10 after
1169 cls = object_store->array_class(); // Was allocated above. 1169 cls = object_store->array_class(); // Was allocated above.
1170 RegisterPrivateClass(cls, Symbols::_List(), core_lib); 1170 RegisterPrivateClass(cls, Symbols::_List(), core_lib);
1171 pending_classes.Add(cls); 1171 pending_classes.Add(cls);
1172 // We cannot use NewNonParameterizedType(cls), because Array is parameterized. 1172 // We cannot use NewNonParameterizedType(cls), because Array is parameterized.
1173 // Warning: class _List has not been patched yet. Its declared number of type 1173 // Warning: class _List has not been patched yet. Its declared number of type
1174 // parameters is still 0. It will become 1 after patching. The array type 1174 // parameters is still 0. It will become 1 after patching. The array type
1175 // allocated below represents the raw type _List and not _List<E> as we 1175 // allocated below represents the raw type _List and not _List<E> as we
1176 // could expect. Use with caution. 1176 // could expect. Use with caution.
1177 type ^= Type::New(Object::Handle(zone, cls.raw()), 1177 type ^= Type::New(Object::Handle(zone, cls.raw()),
1178 TypeArguments::Handle(zone), 1178 TypeArguments::Handle(zone),
1179 Scanner::kNoSourcePos); 1179 Token::kNoSourcePos);
1180 type.SetIsFinalized(); 1180 type.SetIsFinalized();
1181 type ^= type.Canonicalize(); 1181 type ^= type.Canonicalize();
1182 object_store->set_array_type(type); 1182 object_store->set_array_type(type);
1183 1183
1184 cls = object_store->growable_object_array_class(); // Was allocated above. 1184 cls = object_store->growable_object_array_class(); // Was allocated above.
1185 RegisterPrivateClass(cls, Symbols::_GrowableList(), core_lib); 1185 RegisterPrivateClass(cls, Symbols::_GrowableList(), core_lib);
1186 pending_classes.Add(cls); 1186 pending_classes.Add(cls);
1187 1187
1188 cls = Class::New<Array>(kImmutableArrayCid); 1188 cls = Class::New<Array>(kImmutableArrayCid);
1189 object_store->set_immutable_array_class(cls); 1189 object_store->set_immutable_array_class(cls);
(...skipping 790 matching lines...) Expand 10 before | Expand all | Expand 10 after
1980 TypeArguments::Handle(zone, type_parameters()); 1980 TypeArguments::Handle(zone, type_parameters());
1981 // Return the still unfinalized signature type. 1981 // Return the still unfinalized signature type.
1982 return Type::New(*this, signature_type_arguments, token_pos()); 1982 return Type::New(*this, signature_type_arguments, token_pos());
1983 } 1983 }
1984 1984
1985 1985
1986 RawAbstractType* Class::RareType() const { 1986 RawAbstractType* Class::RareType() const {
1987 const Type& type = Type::Handle(Type::New( 1987 const Type& type = Type::Handle(Type::New(
1988 *this, 1988 *this,
1989 Object::null_type_arguments(), 1989 Object::null_type_arguments(),
1990 Scanner::kNoSourcePos)); 1990 Token::kNoSourcePos));
1991 return ClassFinalizer::FinalizeType(*this, 1991 return ClassFinalizer::FinalizeType(*this,
1992 type, 1992 type,
1993 ClassFinalizer::kCanonicalize); 1993 ClassFinalizer::kCanonicalize);
1994 } 1994 }
1995 1995
1996 1996
1997 RawAbstractType* Class::DeclarationType() const { 1997 RawAbstractType* Class::DeclarationType() const {
1998 const TypeArguments& args = TypeArguments::Handle(type_parameters()); 1998 const TypeArguments& args = TypeArguments::Handle(type_parameters());
1999 const Type& type = Type::Handle(Type::New( 1999 const Type& type = Type::Handle(Type::New(
2000 *this, 2000 *this,
2001 args, 2001 args,
2002 Scanner::kNoSourcePos)); 2002 Token::kNoSourcePos));
2003 return ClassFinalizer::FinalizeType(*this, 2003 return ClassFinalizer::FinalizeType(*this,
2004 type, 2004 type,
2005 ClassFinalizer::kCanonicalize); 2005 ClassFinalizer::kCanonicalize);
2006 } 2006 }
2007 2007
2008 2008
2009 template <class FakeObject> 2009 template <class FakeObject>
2010 RawClass* Class::New() { 2010 RawClass* Class::New() {
2011 ASSERT(Object::class_class() != Class::null()); 2011 ASSERT(Object::class_class() != Class::null());
2012 Class& result = Class::Handle(); 2012 Class& result = Class::Handle();
(...skipping 17 matching lines...) Expand all
2030 result.set_is_finalized(); 2030 result.set_is_finalized();
2031 } else { 2031 } else {
2032 // VM backed classes are almost ready: run checks and resolve class 2032 // VM backed classes are almost ready: run checks and resolve class
2033 // references, but do not recompute size. 2033 // references, but do not recompute size.
2034 result.set_is_prefinalized(); 2034 result.set_is_prefinalized();
2035 } 2035 }
2036 result.set_type_arguments_field_offset_in_words(kNoTypeArguments); 2036 result.set_type_arguments_field_offset_in_words(kNoTypeArguments);
2037 result.set_num_type_arguments(0); 2037 result.set_num_type_arguments(0);
2038 result.set_num_own_type_arguments(0); 2038 result.set_num_own_type_arguments(0);
2039 result.set_num_native_fields(0); 2039 result.set_num_native_fields(0);
2040 result.set_token_pos(Scanner::kNoSourcePos); 2040 result.set_token_pos(Token::kNoSourcePos);
2041 result.InitEmptyFields(); 2041 result.InitEmptyFields();
2042 Isolate::Current()->RegisterClass(result); 2042 Isolate::Current()->RegisterClass(result);
2043 return result.raw(); 2043 return result.raw();
2044 } 2044 }
2045 2045
2046 2046
2047 2047
2048 static void ReportTooManyTypeArguments(const Class& cls) { 2048 static void ReportTooManyTypeArguments(const Class& cls) {
2049 Report::MessageF(Report::kError, 2049 Report::MessageF(Report::kError,
2050 Script::Handle(cls.script()), 2050 Script::Handle(cls.script()),
(...skipping 637 matching lines...) Expand 10 before | Expand all | Expand 10 after
2688 const Class& owner = Class::Handle(closure_function.Owner()); 2688 const Class& owner = Class::Handle(closure_function.Owner());
2689 Function& extractor = Function::Handle( 2689 Function& extractor = Function::Handle(
2690 Function::New(String::Handle(Symbols::New(getter_name)), 2690 Function::New(String::Handle(Symbols::New(getter_name)),
2691 RawFunction::kMethodExtractor, 2691 RawFunction::kMethodExtractor,
2692 false, // Not static. 2692 false, // Not static.
2693 false, // Not const. 2693 false, // Not const.
2694 false, // Not abstract. 2694 false, // Not abstract.
2695 false, // Not external. 2695 false, // Not external.
2696 false, // Not native. 2696 false, // Not native.
2697 owner, 2697 owner,
2698 0)); // token_pos 2698 ClassifyingTokenPositions::kMethodExtractor)); // token_pos
2699 2699
2700 // Initialize signature: receiver is a single fixed parameter. 2700 // Initialize signature: receiver is a single fixed parameter.
2701 const intptr_t kNumParameters = 1; 2701 const intptr_t kNumParameters = 1;
2702 extractor.set_num_fixed_parameters(kNumParameters); 2702 extractor.set_num_fixed_parameters(kNumParameters);
2703 extractor.SetNumOptionalParameters(0, 0); 2703 extractor.SetNumOptionalParameters(0, 0);
2704 extractor.set_parameter_types(Object::extractor_parameter_types()); 2704 extractor.set_parameter_types(Object::extractor_parameter_types());
2705 extractor.set_parameter_names(Object::extractor_parameter_names()); 2705 extractor.set_parameter_names(Object::extractor_parameter_names());
2706 extractor.set_result_type(Object::dynamic_type()); 2706 extractor.set_result_type(Object::dynamic_type());
2707 2707
2708 extractor.set_extracted_method_closure(closure_function); 2708 extractor.set_extracted_method_closure(closure_function);
(...skipping 394 matching lines...) Expand 10 before | Expand all | Expand 10 after
3103 ASSERT(fake.IsInstance()); 3103 ASSERT(fake.IsInstance());
3104 result.set_handle_vtable(fake.vtable()); 3104 result.set_handle_vtable(fake.vtable());
3105 result.set_instance_size(FakeInstance::InstanceSize()); 3105 result.set_instance_size(FakeInstance::InstanceSize());
3106 result.set_next_field_offset(FakeInstance::NextFieldOffset()); 3106 result.set_next_field_offset(FakeInstance::NextFieldOffset());
3107 result.set_id(index); 3107 result.set_id(index);
3108 result.set_state_bits(0); 3108 result.set_state_bits(0);
3109 result.set_type_arguments_field_offset_in_words(kNoTypeArguments); 3109 result.set_type_arguments_field_offset_in_words(kNoTypeArguments);
3110 result.set_num_type_arguments(kUnknownNumTypeArguments); 3110 result.set_num_type_arguments(kUnknownNumTypeArguments);
3111 result.set_num_own_type_arguments(kUnknownNumTypeArguments); 3111 result.set_num_own_type_arguments(kUnknownNumTypeArguments);
3112 result.set_num_native_fields(0); 3112 result.set_num_native_fields(0);
3113 result.set_token_pos(Scanner::kNoSourcePos); 3113 result.set_token_pos(Token::kNoSourcePos);
3114 result.InitEmptyFields(); 3114 result.InitEmptyFields();
3115 Isolate::Current()->RegisterClass(result); 3115 Isolate::Current()->RegisterClass(result);
3116 return result.raw(); 3116 return result.raw();
3117 } 3117 }
3118 3118
3119 3119
3120 RawClass* Class::New(const String& name, 3120 RawClass* Class::New(const String& name,
3121 const Script& script, 3121 const Script& script,
3122 intptr_t token_pos) { 3122 intptr_t token_pos) {
3123 Class& result = Class::Handle(New<Instance>(kIllegalCid)); 3123 Class& result = Class::Handle(New<Instance>(kIllegalCid));
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
3193 } 3193 }
3194 set_is_prefinalized(); 3194 set_is_prefinalized();
3195 } 3195 }
3196 3196
3197 3197
3198 RawClass* Class::NewNativeWrapper(const Library& library, 3198 RawClass* Class::NewNativeWrapper(const Library& library,
3199 const String& name, 3199 const String& name,
3200 int field_count) { 3200 int field_count) {
3201 Class& cls = Class::Handle(library.LookupClass(name)); 3201 Class& cls = Class::Handle(library.LookupClass(name));
3202 if (cls.IsNull()) { 3202 if (cls.IsNull()) {
3203 cls = New(name, Script::Handle(), Scanner::kNoSourcePos); 3203 cls = New(name, Script::Handle(), Token::kNoSourcePos);
3204 cls.SetFields(Object::empty_array()); 3204 cls.SetFields(Object::empty_array());
3205 cls.SetFunctions(Object::empty_array()); 3205 cls.SetFunctions(Object::empty_array());
3206 // Set super class to Object. 3206 // Set super class to Object.
3207 cls.set_super_type(Type::Handle(Type::ObjectType())); 3207 cls.set_super_type(Type::Handle(Type::ObjectType()));
3208 // Compute instance size. First word contains a pointer to a properly 3208 // Compute instance size. First word contains a pointer to a properly
3209 // sized typed array once the first native field has been set. 3209 // sized typed array once the first native field has been set.
3210 intptr_t instance_size = sizeof(RawInstance) + kWordSize; 3210 intptr_t instance_size = sizeof(RawInstance) + kWordSize;
3211 cls.set_instance_size(RoundedAllocationSize(instance_size)); 3211 cls.set_instance_size(RoundedAllocationSize(instance_size));
3212 cls.set_next_field_offset(instance_size); 3212 cls.set_next_field_offset(instance_size);
3213 cls.set_num_native_fields(field_count); 3213 cls.set_num_native_fields(field_count);
(...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after
3445 UNREACHABLE(); 3445 UNREACHABLE();
3446 } 3446 }
3447 3447
3448 3448
3449 void Class::set_script(const Script& value) const { 3449 void Class::set_script(const Script& value) const {
3450 StorePointer(&raw_ptr()->script_, value.raw()); 3450 StorePointer(&raw_ptr()->script_, value.raw());
3451 } 3451 }
3452 3452
3453 3453
3454 void Class::set_token_pos(intptr_t token_pos) const { 3454 void Class::set_token_pos(intptr_t token_pos) const {
3455 ASSERT(Scanner::ValidSourcePosition(token_pos)); 3455 ASSERT(!Token::IsClassifying(token_pos));
3456 StoreNonPointer(&raw_ptr()->token_pos_, token_pos); 3456 StoreNonPointer(&raw_ptr()->token_pos_, token_pos);
3457 } 3457 }
3458 3458
3459 3459
3460 intptr_t Class::ComputeEndTokenPos() const { 3460 intptr_t Class::ComputeEndTokenPos() const {
3461 // Return the begin token for synthetic classes. 3461 // Return the begin token for synthetic classes.
3462 if (IsSignatureClass() || IsMixinApplication() || IsTopLevel()) { 3462 if (IsSignatureClass() || IsMixinApplication() || IsTopLevel()) {
3463 return token_pos(); 3463 return token_pos();
3464 } 3464 }
3465 const Script& scr = Script::Handle(script()); 3465 const Script& scr = Script::Handle(script());
(...skipping 915 matching lines...) Expand 10 before | Expand all | Expand 10 after
4381 RawUnresolvedClass* UnresolvedClass::New() { 4381 RawUnresolvedClass* UnresolvedClass::New() {
4382 ASSERT(Object::unresolved_class_class() != Class::null()); 4382 ASSERT(Object::unresolved_class_class() != Class::null());
4383 RawObject* raw = Object::Allocate(UnresolvedClass::kClassId, 4383 RawObject* raw = Object::Allocate(UnresolvedClass::kClassId,
4384 UnresolvedClass::InstanceSize(), 4384 UnresolvedClass::InstanceSize(),
4385 Heap::kOld); 4385 Heap::kOld);
4386 return reinterpret_cast<RawUnresolvedClass*>(raw); 4386 return reinterpret_cast<RawUnresolvedClass*>(raw);
4387 } 4387 }
4388 4388
4389 4389
4390 void UnresolvedClass::set_token_pos(intptr_t token_pos) const { 4390 void UnresolvedClass::set_token_pos(intptr_t token_pos) const {
4391 ASSERT(Scanner::ValidSourcePosition(token_pos)); 4391 ASSERT(!Token::IsClassifying(token_pos));
4392 StoreNonPointer(&raw_ptr()->token_pos_, token_pos); 4392 StoreNonPointer(&raw_ptr()->token_pos_, token_pos);
4393 } 4393 }
4394 4394
4395 4395
4396 void UnresolvedClass::set_ident(const String& ident) const { 4396 void UnresolvedClass::set_ident(const String& ident) const {
4397 StorePointer(&raw_ptr()->ident_, ident.raw()); 4397 StorePointer(&raw_ptr()->ident_, ident.raw());
4398 } 4398 }
4399 4399
4400 4400
4401 void UnresolvedClass::set_library_prefix( 4401 void UnresolvedClass::set_library_prefix(
(...skipping 1381 matching lines...) Expand 10 before | Expand all | Expand 10 after
5783 5783
5784 5784
5785 void Function::set_recognized_kind(MethodRecognizer::Kind value) const { 5785 void Function::set_recognized_kind(MethodRecognizer::Kind value) const {
5786 // Prevent multiple settings of kind. 5786 // Prevent multiple settings of kind.
5787 ASSERT((value == MethodRecognizer::kUnknown) || !IsRecognized()); 5787 ASSERT((value == MethodRecognizer::kUnknown) || !IsRecognized());
5788 set_kind_tag(RecognizedBits::update(value, raw_ptr()->kind_tag_)); 5788 set_kind_tag(RecognizedBits::update(value, raw_ptr()->kind_tag_));
5789 } 5789 }
5790 5790
5791 5791
5792 void Function::set_token_pos(intptr_t token_pos) const { 5792 void Function::set_token_pos(intptr_t token_pos) const {
5793 ASSERT(token_pos >= 0); 5793 ASSERT(!Token::IsClassifying(token_pos) || IsMethodExtractor());
5794 StoreNonPointer(&raw_ptr()->token_pos_, token_pos); 5794 StoreNonPointer(&raw_ptr()->token_pos_, token_pos);
5795 } 5795 }
5796 5796
5797 5797
5798 void Function::set_kind_tag(intptr_t value) const { 5798 void Function::set_kind_tag(intptr_t value) const {
5799 StoreNonPointer(&raw_ptr()->kind_tag_, static_cast<uint32_t>(value)); 5799 StoreNonPointer(&raw_ptr()->kind_tag_, static_cast<uint32_t>(value));
5800 } 5800 }
5801 5801
5802 5802
5803 void Function::set_num_fixed_parameters(intptr_t value) const { 5803 void Function::set_num_fixed_parameters(intptr_t value) const {
(...skipping 2740 matching lines...) Expand 10 before | Expand all | Expand 10 after
8544 : tokens_(TokenStream::Handle(tokens.raw())), 8544 : tokens_(TokenStream::Handle(tokens.raw())),
8545 data_(ExternalTypedData::Handle(tokens.GetStream())), 8545 data_(ExternalTypedData::Handle(tokens.GetStream())),
8546 stream_(reinterpret_cast<uint8_t*>(data_.DataAddr(0)), data_.Length()), 8546 stream_(reinterpret_cast<uint8_t*>(data_.DataAddr(0)), data_.Length()),
8547 token_objects_(Array::Handle( 8547 token_objects_(Array::Handle(
8548 GrowableObjectArray::Handle(tokens.TokenObjects()).data())), 8548 GrowableObjectArray::Handle(tokens.TokenObjects()).data())),
8549 obj_(Object::Handle()), 8549 obj_(Object::Handle()),
8550 cur_token_pos_(token_pos), 8550 cur_token_pos_(token_pos),
8551 cur_token_kind_(Token::kILLEGAL), 8551 cur_token_kind_(Token::kILLEGAL),
8552 cur_token_obj_index_(-1), 8552 cur_token_obj_index_(-1),
8553 stream_type_(stream_type) { 8553 stream_type_(stream_type) {
8554 SetCurrentPosition(token_pos); 8554 ASSERT(token_pos != Token::kNoSourcePos);
8555 if (token_pos >= 0) {
8556 SetCurrentPosition(token_pos);
8557 }
8555 } 8558 }
8556 8559
8557 8560
8558 void TokenStream::Iterator::SetStream(const TokenStream& tokens, 8561 void TokenStream::Iterator::SetStream(const TokenStream& tokens,
8559 intptr_t token_pos) { 8562 intptr_t token_pos) {
8560 tokens_ = tokens.raw(); 8563 tokens_ = tokens.raw();
8561 data_ = tokens.GetStream(); 8564 data_ = tokens.GetStream();
8562 stream_.SetStream(reinterpret_cast<uint8_t*>(data_.DataAddr(0)), 8565 stream_.SetStream(reinterpret_cast<uint8_t*>(data_.DataAddr(0)),
8563 data_.Length()); 8566 data_.Length());
8564 token_objects_ = GrowableObjectArray::Handle(tokens.TokenObjects()).data(); 8567 token_objects_ = GrowableObjectArray::Handle(tokens.TokenObjects()).data();
(...skipping 671 matching lines...) Expand 10 before | Expand all | Expand 10 after
9236 next_ix_++; 9239 next_ix_++;
9237 obj = array_.At(next_ix_); 9240 obj = array_.At(next_ix_);
9238 } 9241 }
9239 } 9242 }
9240 9243
9241 9244
9242 static void ReportTooManyImports(const Library& lib) { 9245 static void ReportTooManyImports(const Library& lib) {
9243 const String& url = String::Handle(lib.url()); 9246 const String& url = String::Handle(lib.url());
9244 Report::MessageF(Report::kError, 9247 Report::MessageF(Report::kError,
9245 Script::Handle(lib.LookupScript(url)), 9248 Script::Handle(lib.LookupScript(url)),
9246 Scanner::kNoSourcePos, 9249 Token::kNoSourcePos,
9247 Report::AtLocation, 9250 Report::AtLocation,
9248 "too many imports in library '%s'", 9251 "too many imports in library '%s'",
9249 url.ToCString()); 9252 url.ToCString());
9250 UNREACHABLE(); 9253 UNREACHABLE();
9251 } 9254 }
9252 9255
9253 9256
9254 void Library::set_num_imports(intptr_t value) const { 9257 void Library::set_num_imports(intptr_t value) const {
9255 if (!Utils::IsUint(16, value)) { 9258 if (!Utils::IsUint(16, value)) {
9256 ReportTooManyImports(*this); 9259 ReportTooManyImports(*this);
(...skipping 2000 matching lines...) Expand 10 before | Expand all | Expand 10 after
11257 return; 11260 return;
11258 } 11261 }
11259 } 11262 }
11260 11263
11261 11264
11262 // Encode integer in SLEB128 format. 11265 // Encode integer in SLEB128 format.
11263 void PcDescriptors::EncodeInteger(GrowableArray<uint8_t>* data, 11266 void PcDescriptors::EncodeInteger(GrowableArray<uint8_t>* data,
11264 intptr_t value) { 11267 intptr_t value) {
11265 bool is_last_part = false; 11268 bool is_last_part = false;
11266 while (!is_last_part) { 11269 while (!is_last_part) {
11267 intptr_t part = value & 0x7f; 11270 uint8_t part = value & 0x7f;
11268 value >>= 7; 11271 value >>= 7;
11269 if ((value == 0 && (part & 0x40) == 0) || 11272 if ((value == 0 && (part & 0x40) == 0) ||
11270 (value == -1 && (part & 0x40) != 0)) { 11273 (value == static_cast<intptr_t>(-1) && (part & 0x40) != 0)) {
11271 is_last_part = true; 11274 is_last_part = true;
11272 } else { 11275 } else {
11273 part |= 0x80; 11276 part |= 0x80;
11274 } 11277 }
11275 data->Add(part); 11278 data->Add(part);
11276 } 11279 }
11277 } 11280 }
11278 11281
11279 11282
11280 // Decode SLEB128 encoded integer. Update byte_index to the next integer. 11283 // Decode SLEB128 encoded integer. Update byte_index to the next integer.
11281 intptr_t PcDescriptors::DecodeInteger(intptr_t* byte_index) const { 11284 intptr_t PcDescriptors::DecodeInteger(intptr_t* byte_index) const {
11282 NoSafepointScope no_safepoint; 11285 NoSafepointScope no_safepoint;
11283 const uint8_t* data = raw_ptr()->data(); 11286 const uint8_t* data = raw_ptr()->data();
11284 ASSERT(*byte_index < Length()); 11287 ASSERT(*byte_index < Length());
11285 uword shift = 0; 11288 uword shift = 0;
11286 intptr_t value = 0; 11289 intptr_t value = 0;
11287 intptr_t part = 0; 11290 uint8_t part = 0;
11288 do { 11291 do {
11289 part = data[(*byte_index)++]; 11292 part = data[(*byte_index)++];
11290 value |= (part & 0x7f) << shift; 11293 value |= static_cast<intptr_t>(part & 0x7f) << shift;
11291 shift += 7; 11294 shift += 7;
11292 } while ((part & 0x80) != 0); 11295 } while ((part & 0x80) != 0);
11293 11296
11294 if (shift < sizeof(value) * 8 && (part & 0x40) != 0) { 11297 if ((shift < (sizeof(value) * 8)) && ((part & 0x40) != 0)) {
11295 value |= -(1 << shift); 11298 value |= static_cast<intptr_t>(-1) << shift;
11296 } 11299 }
11297 return value; 11300 return value;
11298 } 11301 }
11299 11302
11300 11303
11301 RawObjectPool* ObjectPool::New(intptr_t len) { 11304 RawObjectPool* ObjectPool::New(intptr_t len) {
11302 ASSERT(Object::object_pool_class() != Class::null()); 11305 ASSERT(Object::object_pool_class() != Class::null());
11303 if (len < 0 || len > kMaxElements) { 11306 if (len < 0 || len > kMaxElements) {
11304 // This should be caught before we reach here. 11307 // This should be caught before we reach here.
11305 FATAL1("Fatal error in ObjectPool::New: invalid length %" Pd "\n", len); 11308 FATAL1("Fatal error in ObjectPool::New: invalid length %" Pd "\n", len);
(...skipping 3275 matching lines...) Expand 10 before | Expand all | Expand 10 after
14581 StorePointer(&raw_ptr()->previous_error_, value.raw()); 14584 StorePointer(&raw_ptr()->previous_error_, value.raw());
14582 } 14585 }
14583 14586
14584 14587
14585 void LanguageError::set_script(const Script& value) const { 14588 void LanguageError::set_script(const Script& value) const {
14586 StorePointer(&raw_ptr()->script_, value.raw()); 14589 StorePointer(&raw_ptr()->script_, value.raw());
14587 } 14590 }
14588 14591
14589 14592
14590 void LanguageError::set_token_pos(intptr_t token_pos) const { 14593 void LanguageError::set_token_pos(intptr_t token_pos) const {
14591 ASSERT(Scanner::ValidSourcePosition(token_pos)); 14594 ASSERT(!Token::IsClassifying(token_pos));
14592 StoreNonPointer(&raw_ptr()->token_pos_, token_pos); 14595 StoreNonPointer(&raw_ptr()->token_pos_, token_pos);
14593 } 14596 }
14594 14597
14595 14598
14596 void LanguageError::set_report_after_token(bool value) { 14599 void LanguageError::set_report_after_token(bool value) {
14597 StoreNonPointer(&raw_ptr()->report_after_token_, value); 14600 StoreNonPointer(&raw_ptr()->report_after_token_, value);
14598 } 14601 }
14599 14602
14600 14603
14601 void LanguageError::set_kind(uint8_t value) const { 14604 void LanguageError::set_kind(uint8_t value) const {
(...skipping 383 matching lines...) Expand 10 before | Expand all | Expand 10 after
14985 const Class& cls = Class::Handle(clazz()); 14988 const Class& cls = Class::Handle(clazz());
14986 Type& type = Type::Handle(); 14989 Type& type = Type::Handle();
14987 if (!cls.IsGeneric()) { 14990 if (!cls.IsGeneric()) {
14988 type = cls.CanonicalType(); 14991 type = cls.CanonicalType();
14989 } 14992 }
14990 if (type.IsNull()) { 14993 if (type.IsNull()) {
14991 TypeArguments& type_arguments = TypeArguments::Handle(); 14994 TypeArguments& type_arguments = TypeArguments::Handle();
14992 if (cls.NumTypeArguments() > 0) { 14995 if (cls.NumTypeArguments() > 0) {
14993 type_arguments = GetTypeArguments(); 14996 type_arguments = GetTypeArguments();
14994 } 14997 }
14995 type = Type::New(cls, type_arguments, Scanner::kNoSourcePos); 14998 type = Type::New(cls, type_arguments, Token::kNoSourcePos);
14996 type.SetIsFinalized(); 14999 type.SetIsFinalized();
14997 type ^= type.Canonicalize(); 15000 type ^= type.Canonicalize();
14998 } 15001 }
14999 return type.raw(); 15002 return type.raw();
15000 } 15003 }
15001 15004
15002 15005
15003 RawTypeArguments* Instance::GetTypeArguments() const { 15006 RawTypeArguments* Instance::GetTypeArguments() const {
15004 const Class& cls = Class::Handle(clazz()); 15007 const Class& cls = Class::Handle(clazz());
15005 intptr_t field_offset = cls.type_arguments_field_offset(); 15008 intptr_t field_offset = cls.type_arguments_field_offset();
(...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after
15244 if (IsClosure()) { 15247 if (IsClosure()) {
15245 return Closure::ToCString(*this); 15248 return Closure::ToCString(*this);
15246 } 15249 }
15247 const Class& cls = Class::Handle(clazz()); 15250 const Class& cls = Class::Handle(clazz());
15248 TypeArguments& type_arguments = TypeArguments::Handle(); 15251 TypeArguments& type_arguments = TypeArguments::Handle();
15249 const intptr_t num_type_arguments = cls.NumTypeArguments(); 15252 const intptr_t num_type_arguments = cls.NumTypeArguments();
15250 if (num_type_arguments > 0) { 15253 if (num_type_arguments > 0) {
15251 type_arguments = GetTypeArguments(); 15254 type_arguments = GetTypeArguments();
15252 } 15255 }
15253 const Type& type = 15256 const Type& type =
15254 Type::Handle(Type::New(cls, type_arguments, Scanner::kNoSourcePos)); 15257 Type::Handle(Type::New(cls, type_arguments, Token::kNoSourcePos));
15255 const String& type_name = String::Handle(type.UserVisibleName()); 15258 const String& type_name = String::Handle(type.UserVisibleName());
15256 return OS::SCreate(Thread::Current()->zone(), 15259 return OS::SCreate(Thread::Current()->zone(),
15257 "Instance of '%s'", type_name.ToCString()); 15260 "Instance of '%s'", type_name.ToCString());
15258 } 15261 }
15259 } 15262 }
15260 15263
15261 15264
15262 void Instance::PrintSharedInstanceJSON(JSONObject* jsobj, 15265 void Instance::PrintSharedInstanceJSON(JSONObject* jsobj,
15263 bool ref) const { 15266 bool ref) const {
15264 AddCommonObjectProperties(jsobj, "Instance", ref); 15267 AddCommonObjectProperties(jsobj, "Instance", ref);
(...skipping 641 matching lines...) Expand 10 before | Expand all | Expand 10 after
15906 } 15909 }
15907 15910
15908 15911
15909 RawType* Type::NewNonParameterizedType(const Class& type_class) { 15912 RawType* Type::NewNonParameterizedType(const Class& type_class) {
15910 ASSERT(type_class.NumTypeArguments() == 0); 15913 ASSERT(type_class.NumTypeArguments() == 0);
15911 Type& type = Type::Handle(type_class.CanonicalType()); 15914 Type& type = Type::Handle(type_class.CanonicalType());
15912 if (type.IsNull()) { 15915 if (type.IsNull()) {
15913 const TypeArguments& no_type_arguments = TypeArguments::Handle(); 15916 const TypeArguments& no_type_arguments = TypeArguments::Handle();
15914 type ^= Type::New(Object::Handle(type_class.raw()), 15917 type ^= Type::New(Object::Handle(type_class.raw()),
15915 no_type_arguments, 15918 no_type_arguments,
15916 Scanner::kNoSourcePos); 15919 Token::kNoSourcePos);
15917 type.SetIsFinalized(); 15920 type.SetIsFinalized();
15918 type ^= type.Canonicalize(); 15921 type ^= type.Canonicalize();
15919 } 15922 }
15920 ASSERT(type.IsFinalized()); 15923 ASSERT(type.IsFinalized());
15921 return type.raw(); 15924 return type.raw();
15922 } 15925 }
15923 15926
15924 15927
15925 void Type::SetIsFinalized() const { 15928 void Type::SetIsFinalized() const {
15926 ASSERT(!IsFinalized()); 15929 ASSERT(!IsFinalized());
(...skipping 488 matching lines...) Expand 10 before | Expand all | Expand 10 after
16415 const Type& result = Type::Handle(Type::New(space)); 16418 const Type& result = Type::Handle(Type::New(space));
16416 result.set_type_class(clazz); 16419 result.set_type_class(clazz);
16417 result.set_arguments(arguments); 16420 result.set_arguments(arguments);
16418 result.set_token_pos(token_pos); 16421 result.set_token_pos(token_pos);
16419 result.StoreNonPointer(&result.raw_ptr()->type_state_, RawType::kAllocated); 16422 result.StoreNonPointer(&result.raw_ptr()->type_state_, RawType::kAllocated);
16420 return result.raw(); 16423 return result.raw();
16421 } 16424 }
16422 16425
16423 16426
16424 void Type::set_token_pos(intptr_t token_pos) const { 16427 void Type::set_token_pos(intptr_t token_pos) const {
16425 ASSERT(Scanner::ValidSourcePosition(token_pos)); 16428 ASSERT(!Token::IsClassifying(token_pos));
16426 StoreNonPointer(&raw_ptr()->token_pos_, token_pos); 16429 StoreNonPointer(&raw_ptr()->token_pos_, token_pos);
16427 } 16430 }
16428 16431
16429 16432
16430 void Type::set_type_state(int8_t state) const { 16433 void Type::set_type_state(int8_t state) const {
16431 ASSERT((state >= RawType::kAllocated) && 16434 ASSERT((state >= RawType::kAllocated) &&
16432 (state <= RawType::kFinalizedUninstantiated)); 16435 (state <= RawType::kFinalizedUninstantiated));
16433 StoreNonPointer(&raw_ptr()->type_state_, state); 16436 StoreNonPointer(&raw_ptr()->type_state_, state);
16434 } 16437 }
16435 16438
(...skipping 411 matching lines...) Expand 10 before | Expand all | Expand 10 after
16847 result.set_name(name); 16850 result.set_name(name);
16848 result.set_bound(bound); 16851 result.set_bound(bound);
16849 result.set_token_pos(token_pos); 16852 result.set_token_pos(token_pos);
16850 result.StoreNonPointer(&result.raw_ptr()->type_state_, 16853 result.StoreNonPointer(&result.raw_ptr()->type_state_,
16851 RawTypeParameter::kAllocated); 16854 RawTypeParameter::kAllocated);
16852 return result.raw(); 16855 return result.raw();
16853 } 16856 }
16854 16857
16855 16858
16856 void TypeParameter::set_token_pos(intptr_t token_pos) const { 16859 void TypeParameter::set_token_pos(intptr_t token_pos) const {
16857 ASSERT(Scanner::ValidSourcePosition(token_pos)); 16860 ASSERT(!Token::IsClassifying(token_pos));
16858 StoreNonPointer(&raw_ptr()->token_pos_, token_pos); 16861 StoreNonPointer(&raw_ptr()->token_pos_, token_pos);
16859 } 16862 }
16860 16863
16861 16864
16862 void TypeParameter::set_type_state(int8_t state) const { 16865 void TypeParameter::set_type_state(int8_t state) const {
16863 ASSERT((state == RawTypeParameter::kAllocated) || 16866 ASSERT((state == RawTypeParameter::kAllocated) ||
16864 (state == RawTypeParameter::kBeingFinalized) || 16867 (state == RawTypeParameter::kBeingFinalized) ||
16865 (state == RawTypeParameter::kFinalizedUninstantiated)); 16868 (state == RawTypeParameter::kFinalizedUninstantiated));
16866 StoreNonPointer(&raw_ptr()->type_state_, state); 16869 StoreNonPointer(&raw_ptr()->type_state_, state);
16867 } 16870 }
(...skipping 5256 matching lines...) Expand 10 before | Expand all | Expand 10 after
22124 return tag_label.ToCString(); 22127 return tag_label.ToCString();
22125 } 22128 }
22126 22129
22127 22130
22128 void UserTag::PrintJSONImpl(JSONStream* stream, bool ref) const { 22131 void UserTag::PrintJSONImpl(JSONStream* stream, bool ref) const {
22129 Instance::PrintJSONImpl(stream, ref); 22132 Instance::PrintJSONImpl(stream, ref);
22130 } 22133 }
22131 22134
22132 22135
22133 } // namespace dart 22136 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/intrinsifier.cc ('k') | runtime/vm/object_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698