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

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

Issue 186673003: Fix dartbug.com/17261 (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 6 years, 9 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 | « runtime/vm/object.h ('k') | no next file » | 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 2000 matching lines...) Expand 10 before | Expand all | Expand 10 after
2011 void Class::set_library(const Library& value) const { 2011 void Class::set_library(const Library& value) const {
2012 StorePointer(&raw_ptr()->library_, value.raw()); 2012 StorePointer(&raw_ptr()->library_, value.raw());
2013 } 2013 }
2014 2014
2015 2015
2016 void Class::set_type_parameters(const TypeArguments& value) const { 2016 void Class::set_type_parameters(const TypeArguments& value) const {
2017 StorePointer(&raw_ptr()->type_parameters_, value.raw()); 2017 StorePointer(&raw_ptr()->type_parameters_, value.raw());
2018 } 2018 }
2019 2019
2020 2020
2021 intptr_t Class::NumTypeParameters() const { 2021 intptr_t Class::NumTypeParameters(Isolate* isolate) const {
2022 if (IsMixinApplication() && !is_mixin_type_applied()) { 2022 if (IsMixinApplication() && !is_mixin_type_applied()) {
2023 ClassFinalizer::ApplyMixinType(*this); 2023 ClassFinalizer::ApplyMixinType(*this);
2024 } 2024 }
2025 if (type_parameters() == TypeArguments::null()) { 2025 if (type_parameters() == TypeArguments::null()) {
2026 return 0; 2026 return 0;
2027 } 2027 }
2028 const TypeArguments& type_params = TypeArguments::Handle(type_parameters()); 2028 ReusableHandleScope reused_handles(isolate);
2029 TypeArguments& type_params = reused_handles.TypeArgumentsHandle();
2030 type_params = type_parameters();
2029 return type_params.Length(); 2031 return type_params.Length();
2030 } 2032 }
2031 2033
2032 2034
2033 intptr_t Class::NumOwnTypeArguments() const { 2035 intptr_t Class::NumOwnTypeArguments() const {
2034 // Return cached value if already calculated. 2036 // Return cached value if already calculated.
2035 if (num_own_type_arguments() != kUnknownNumTypeArguments) { 2037 if (num_own_type_arguments() != kUnknownNumTypeArguments) {
2036 return num_own_type_arguments(); 2038 return num_own_type_arguments();
2037 } 2039 }
2038 Isolate* isolate = Isolate::Current(); 2040 Isolate* isolate = Isolate::Current();
(...skipping 10787 matching lines...) Expand 10 before | Expand all | Expand 10 after
12826 } 12828 }
12827 if (type_class() != other_type.type_class()) { 12829 if (type_class() != other_type.type_class()) {
12828 return false; 12830 return false;
12829 } 12831 }
12830 if (!IsFinalized() || !other_type.IsFinalized()) { 12832 if (!IsFinalized() || !other_type.IsFinalized()) {
12831 return false; 12833 return false;
12832 } 12834 }
12833 if (arguments() == other_type.arguments()) { 12835 if (arguments() == other_type.arguments()) {
12834 return true; 12836 return true;
12835 } 12837 }
12836 const Class& cls = Class::Handle(type_class()); 12838 Isolate* isolate = Isolate::Current();
srdjan 2014/03/04 17:57:07 Why not move this up and use it for all handles?
siva 2014/03/04 18:02:10 I would not move it up as there seem to be number
Ivan Posva 2014/03/04 18:08:59 As Siva says, but added it to the handle allocatio
12837 const intptr_t num_type_params = cls.NumTypeParameters(); 12839 const Class& cls = Class::Handle(isolate, type_class());
12840 const intptr_t num_type_params = cls.NumTypeParameters(isolate);
regis 2014/03/04 17:41:41 Passing the isolate looks really strange to me. Wh
Ivan Posva 2014/03/04 18:08:59 Yes.
12838 if (num_type_params == 0) { 12841 if (num_type_params == 0) {
12839 // Shortcut unnecessary handle allocation below. 12842 // Shortcut unnecessary handle allocation below.
12840 return true; 12843 return true;
12841 } 12844 }
12842 const intptr_t num_type_args = cls.NumTypeArguments(); 12845 const intptr_t num_type_args = cls.NumTypeArguments();
12843 const intptr_t from_index = num_type_args - num_type_params; 12846 const intptr_t from_index = num_type_args - num_type_params;
12844 const TypeArguments& type_args = TypeArguments::Handle(arguments()); 12847 const TypeArguments& type_args = TypeArguments::Handle(arguments());
12845 const TypeArguments& other_type_args = TypeArguments::Handle( 12848 const TypeArguments& other_type_args = TypeArguments::Handle(
12846 other_type.arguments()); 12849 other_type.arguments());
12847 if (type_args.IsNull()) { 12850 if (type_args.IsNull()) {
(...skipping 3458 matching lines...) Expand 10 before | Expand all | Expand 10 after
16306 obj = source.At(i); 16309 obj = source.At(i);
16307 result.SetAt(i, obj); 16310 result.SetAt(i, obj);
16308 } 16311 }
16309 return result.raw(); 16312 return result.raw();
16310 } 16313 }
16311 16314
16312 16315
16313 RawArray* Array::MakeArray(const GrowableObjectArray& growable_array) { 16316 RawArray* Array::MakeArray(const GrowableObjectArray& growable_array) {
16314 ASSERT(!growable_array.IsNull()); 16317 ASSERT(!growable_array.IsNull());
16315 intptr_t used_len = growable_array.Length(); 16318 intptr_t used_len = growable_array.Length();
16316 if (used_len == 0) { 16319 // Get the type arguments and prepare to copy them.
16320 const TypeArguments& type_arguments =
16321 TypeArguments::Handle(growable_array.GetTypeArguments());
16322 if ((used_len == 0) && (type_arguments.IsNull())) {
16323 // This is a raw List (as in no type arguments), so we can return the
16324 // simple empty array.
16317 return Object::empty_array().raw(); 16325 return Object::empty_array().raw();
16318 } 16326 }
16319 intptr_t capacity_len = growable_array.Capacity(); 16327 intptr_t capacity_len = growable_array.Capacity();
16320 Isolate* isolate = Isolate::Current(); 16328 Isolate* isolate = Isolate::Current();
16321 const Array& array = Array::Handle(isolate, growable_array.data()); 16329 const Array& array = Array::Handle(isolate, growable_array.data());
16330 array.SetTypeArguments(type_arguments);
16322 intptr_t capacity_size = Array::InstanceSize(capacity_len); 16331 intptr_t capacity_size = Array::InstanceSize(capacity_len);
16323 intptr_t used_size = Array::InstanceSize(used_len); 16332 intptr_t used_size = Array::InstanceSize(used_len);
16324 NoGCScope no_gc; 16333 NoGCScope no_gc;
16325 16334
16326 // Update the size in the header field and length of the array object. 16335 // Update the size in the header field and length of the array object.
16327 uword tags = array.raw_ptr()->tags_; 16336 uword tags = array.raw_ptr()->tags_;
16328 ASSERT(kArrayCid == RawObject::ClassIdTag::decode(tags)); 16337 ASSERT(kArrayCid == RawObject::ClassIdTag::decode(tags));
16329 tags = RawObject::SizeTag::update(used_size, tags); 16338 tags = RawObject::SizeTag::update(used_size, tags);
16330 array.raw_ptr()->tags_ = tags; 16339 array.raw_ptr()->tags_ = tags;
16331 array.SetLength(used_len); 16340 array.SetLength(used_len);
(...skipping 1141 matching lines...) Expand 10 before | Expand all | Expand 10 after
17473 return "_MirrorReference"; 17482 return "_MirrorReference";
17474 } 17483 }
17475 17484
17476 17485
17477 void MirrorReference::PrintToJSONStream(JSONStream* stream, bool ref) const { 17486 void MirrorReference::PrintToJSONStream(JSONStream* stream, bool ref) const {
17478 Instance::PrintToJSONStream(stream, ref); 17487 Instance::PrintToJSONStream(stream, ref);
17479 } 17488 }
17480 17489
17481 17490
17482 } // namespace dart 17491 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/object.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698