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

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

Issue 1414493003: Remove some Isolate::current_zone() calls, as it gets the zone from mutator thread not the current … (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Zones and commentw Created 5 years, 2 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/object.h ('k') | runtime/vm/service.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 17623 matching lines...) Expand 10 before | Expand all | Expand 10 after
17634 // Bool field neg should always be canonical. 17634 // Bool field neg should always be canonical.
17635 ASSERT(Bool::Handle(neg()).IsCanonical()); 17635 ASSERT(Bool::Handle(neg()).IsCanonical());
17636 // Smi field used is canonical by definition. 17636 // Smi field used is canonical by definition.
17637 if (Used() > 0) { 17637 if (Used() > 0) {
17638 // Canonicalize TypedData field digits. 17638 // Canonicalize TypedData field digits.
17639 TypedData& digits_ = TypedData::Handle(digits()); 17639 TypedData& digits_ = TypedData::Handle(digits());
17640 digits_ ^= digits_.CheckAndCanonicalize(NULL); 17640 digits_ ^= digits_.CheckAndCanonicalize(NULL);
17641 ASSERT(!digits_.IsNull()); 17641 ASSERT(!digits_.IsNull());
17642 set_digits(digits_); 17642 set_digits(digits_);
17643 } else { 17643 } else {
17644 ASSERT(digits() == TypedData::EmptyUint32Array(Isolate::Current())); 17644 ASSERT(digits() == TypedData::EmptyUint32Array(Thread::Current()));
17645 } 17645 }
17646 return true; 17646 return true;
17647 } 17647 }
17648 17648
17649 17649
17650 RawBigint* Bigint::New(Heap::Space space) { 17650 RawBigint* Bigint::New(Heap::Space space) {
17651 Thread* thread = Thread::Current(); 17651 Thread* thread = Thread::Current();
17652 Zone* zone = thread->zone(); 17652 Zone* zone = thread->zone();
17653 Isolate* isolate = thread->isolate(); 17653 Isolate* isolate = thread->isolate();
17654 ASSERT(isolate->object_store()->bigint_class() != Class::null()); 17654 ASSERT(isolate->object_store()->bigint_class() != Class::null());
17655 Bigint& result = Bigint::Handle(zone); 17655 Bigint& result = Bigint::Handle(zone);
17656 { 17656 {
17657 RawObject* raw = Object::Allocate(Bigint::kClassId, 17657 RawObject* raw = Object::Allocate(Bigint::kClassId,
17658 Bigint::InstanceSize(), 17658 Bigint::InstanceSize(),
17659 space); 17659 space);
17660 NoSafepointScope no_safepoint; 17660 NoSafepointScope no_safepoint;
17661 result ^= raw; 17661 result ^= raw;
17662 } 17662 }
17663 result.SetNeg(false); 17663 result.SetNeg(false);
17664 result.SetUsed(0); 17664 result.SetUsed(0);
17665 result.set_digits( 17665 result.set_digits(
17666 TypedData::Handle(zone, TypedData::EmptyUint32Array(isolate))); 17666 TypedData::Handle(zone, TypedData::EmptyUint32Array(thread)));
17667 return result.raw(); 17667 return result.raw();
17668 } 17668 }
17669 17669
17670 17670
17671 RawBigint* Bigint::New(bool neg, intptr_t used, const TypedData& digits, 17671 RawBigint* Bigint::New(bool neg, intptr_t used, const TypedData& digits,
17672 Heap::Space space) { 17672 Heap::Space space) {
17673 ASSERT((used == 0) || 17673 ASSERT((used == 0) ||
17674 (!digits.IsNull() && (digits.Length() >= (used + (used & 1))))); 17674 (!digits.IsNull() && (digits.Length() >= (used + (used & 1)))));
17675 Thread* thread = Thread::Current(); 17675 Thread* thread = Thread::Current();
17676 Zone* zone = thread->zone(); 17676 Zone* zone = thread->zone();
(...skipping 13 matching lines...) Expand all
17690 } 17690 }
17691 if (used > 0) { 17691 if (used > 0) {
17692 if ((used & 1) != 0) { 17692 if ((used & 1) != 0) {
17693 // Set leading zero for 64-bit processing of digit pairs. 17693 // Set leading zero for 64-bit processing of digit pairs.
17694 digits.SetUint32(used << 2, 0); 17694 digits.SetUint32(used << 2, 0);
17695 } 17695 }
17696 result.set_digits(digits); 17696 result.set_digits(digits);
17697 } else { 17697 } else {
17698 neg = false; 17698 neg = false;
17699 result.set_digits( 17699 result.set_digits(
17700 TypedData::Handle(zone, TypedData::EmptyUint32Array(isolate))); 17700 TypedData::Handle(zone, TypedData::EmptyUint32Array(thread)));
17701 } 17701 }
17702 result.SetNeg(neg); 17702 result.SetNeg(neg);
17703 result.SetUsed(used); 17703 result.SetUsed(used);
17704 return result.raw(); 17704 return result.raw();
17705 } 17705 }
17706 17706
17707 17707
17708 RawBigint* Bigint::NewFromInt64(int64_t value, Heap::Space space) { 17708 RawBigint* Bigint::NewFromInt64(int64_t value, Heap::Space space) {
17709 const TypedData& digits = TypedData::Handle(NewDigits(2, space)); 17709 const TypedData& digits = TypedData::Handle(NewDigits(2, space));
17710 bool neg; 17710 bool neg;
(...skipping 3202 matching lines...) Expand 10 before | Expand all | Expand 10 after
20913 result ^= raw; 20913 result ^= raw;
20914 result.SetLength(len); 20914 result.SetLength(len);
20915 if (len > 0) { 20915 if (len > 0) {
20916 memset(result.DataAddr(0), 0, lengthInBytes); 20916 memset(result.DataAddr(0), 0, lengthInBytes);
20917 } 20917 }
20918 } 20918 }
20919 return result.raw(); 20919 return result.raw();
20920 } 20920 }
20921 20921
20922 20922
20923 RawTypedData* TypedData::EmptyUint32Array(Isolate* isolate) { 20923 RawTypedData* TypedData::EmptyUint32Array(Thread* thread) {
20924 ASSERT(thread != NULL);
20925 Isolate* isolate = thread->isolate();
20924 ASSERT(isolate != NULL); 20926 ASSERT(isolate != NULL);
20925 ASSERT(isolate->object_store() != NULL); 20927 ASSERT(isolate->object_store() != NULL);
20926 if (isolate->object_store()->empty_uint32_array() != TypedData::null()) { 20928 if (isolate->object_store()->empty_uint32_array() != TypedData::null()) {
20927 // Already created. 20929 // Already created.
20928 return isolate->object_store()->empty_uint32_array(); 20930 return isolate->object_store()->empty_uint32_array();
20929 } 20931 }
20930 const TypedData& array = TypedData::Handle(isolate->current_zone(), 20932 const TypedData& array = TypedData::Handle(thread->zone(),
20931 TypedData::New(kTypedDataUint32ArrayCid, 0, Heap::kOld)); 20933 TypedData::New(kTypedDataUint32ArrayCid, 0, Heap::kOld));
20932 isolate->object_store()->set_empty_uint32_array(array); 20934 isolate->object_store()->set_empty_uint32_array(array);
20933 return array.raw(); 20935 return array.raw();
20934 } 20936 }
20935 20937
20936 20938
20937 const char* TypedData::ToCString() const { 20939 const char* TypedData::ToCString() const {
20938 return "TypedData"; 20940 return "TypedData";
20939 } 20941 }
20940 20942
(...skipping 642 matching lines...) Expand 10 before | Expand all | Expand 10 after
21583 21585
21584 21586
21585 void UserTag::MakeActive() const { 21587 void UserTag::MakeActive() const {
21586 Isolate* isolate = Isolate::Current(); 21588 Isolate* isolate = Isolate::Current();
21587 ASSERT(isolate != NULL); 21589 ASSERT(isolate != NULL);
21588 isolate->set_current_tag(*this); 21590 isolate->set_current_tag(*this);
21589 } 21591 }
21590 21592
21591 21593
21592 RawUserTag* UserTag::New(const String& label, Heap::Space space) { 21594 RawUserTag* UserTag::New(const String& label, Heap::Space space) {
21593 Isolate* isolate = Isolate::Current(); 21595 Thread* thread = Thread::Current();
21596 Isolate* isolate = thread->isolate();
21594 ASSERT(isolate->tag_table() != GrowableObjectArray::null()); 21597 ASSERT(isolate->tag_table() != GrowableObjectArray::null());
21595 // Canonicalize by name. 21598 // Canonicalize by name.
21596 UserTag& result = UserTag::Handle(FindTagInIsolate(isolate, label)); 21599 UserTag& result = UserTag::Handle(FindTagInIsolate(thread, label));
21597 if (!result.IsNull()) { 21600 if (!result.IsNull()) {
21598 // Tag already exists, return existing instance. 21601 // Tag already exists, return existing instance.
21599 return result.raw(); 21602 return result.raw();
21600 } 21603 }
21601 if (TagTableIsFull(isolate)) { 21604 if (TagTableIsFull(isolate)) {
21602 const String& error = String::Handle( 21605 const String& error = String::Handle(
21603 String::NewFormatted("UserTag instance limit (%" Pd ") reached.", 21606 String::NewFormatted("UserTag instance limit (%" Pd ") reached.",
21604 UserTags::kMaxUserTags)); 21607 UserTags::kMaxUserTags));
21605 const Array& args = Array::Handle(Array::New(1)); 21608 const Array& args = Array::Handle(Array::New(1));
21606 args.SetAt(0, error); 21609 args.SetAt(0, error);
21607 Exceptions::ThrowByType(Exceptions::kUnsupported, args); 21610 Exceptions::ThrowByType(Exceptions::kUnsupported, args);
21608 } 21611 }
21609 // No tag with label exists, create and register with isolate tag table. 21612 // No tag with label exists, create and register with isolate tag table.
21610 { 21613 {
21611 RawObject* raw = Object::Allocate(UserTag::kClassId, 21614 RawObject* raw = Object::Allocate(UserTag::kClassId,
21612 UserTag::InstanceSize(), 21615 UserTag::InstanceSize(),
21613 space); 21616 space);
21614 NoSafepointScope no_safepoint; 21617 NoSafepointScope no_safepoint;
21615 result ^= raw; 21618 result ^= raw;
21616 } 21619 }
21617 result.set_label(label); 21620 result.set_label(label);
21618 AddTagToIsolate(isolate, result); 21621 AddTagToIsolate(thread, result);
21619 return result.raw(); 21622 return result.raw();
21620 } 21623 }
21621 21624
21622 21625
21623 RawUserTag* UserTag::DefaultTag() { 21626 RawUserTag* UserTag::DefaultTag() {
21624 Thread* thread = Thread::Current(); 21627 Thread* thread = Thread::Current();
21625 Zone* zone = thread->zone(); 21628 Zone* zone = thread->zone();
21626 Isolate* isolate = thread->isolate(); 21629 Isolate* isolate = thread->isolate();
21627 ASSERT(isolate != NULL); 21630 ASSERT(isolate != NULL);
21628 if (isolate->default_tag() != UserTag::null()) { 21631 if (isolate->default_tag() != UserTag::null()) {
21629 // Already created. 21632 // Already created.
21630 return isolate->default_tag(); 21633 return isolate->default_tag();
21631 } 21634 }
21632 // Create default tag. 21635 // Create default tag.
21633 const UserTag& result = UserTag::Handle(zone, 21636 const UserTag& result = UserTag::Handle(zone,
21634 UserTag::New(Symbols::Default())); 21637 UserTag::New(Symbols::Default()));
21635 ASSERT(result.tag() == UserTags::kDefaultUserTag); 21638 ASSERT(result.tag() == UserTags::kDefaultUserTag);
21636 isolate->set_default_tag(result); 21639 isolate->set_default_tag(result);
21637 return result.raw(); 21640 return result.raw();
21638 } 21641 }
21639 21642
21640 21643
21641 RawUserTag* UserTag::FindTagInIsolate(Isolate* isolate, const String& label) { 21644 RawUserTag* UserTag::FindTagInIsolate(Thread* thread, const String& label) {
21645 Isolate* isolate = thread->isolate();
21646 Zone* zone = thread->zone();
21642 ASSERT(isolate->tag_table() != GrowableObjectArray::null()); 21647 ASSERT(isolate->tag_table() != GrowableObjectArray::null());
21643 const GrowableObjectArray& tag_table = GrowableObjectArray::Handle( 21648 const GrowableObjectArray& tag_table = GrowableObjectArray::Handle(
21644 isolate->current_zone(), isolate->tag_table()); 21649 zone, isolate->tag_table());
21645 UserTag& other = UserTag::Handle(isolate->current_zone()); 21650 UserTag& other = UserTag::Handle(zone);
21646 String& tag_label = String::Handle(isolate->current_zone()); 21651 String& tag_label = String::Handle(zone);
21647 for (intptr_t i = 0; i < tag_table.Length(); i++) { 21652 for (intptr_t i = 0; i < tag_table.Length(); i++) {
21648 other ^= tag_table.At(i); 21653 other ^= tag_table.At(i);
21649 ASSERT(!other.IsNull()); 21654 ASSERT(!other.IsNull());
21650 tag_label ^= other.label(); 21655 tag_label ^= other.label();
21651 ASSERT(!tag_label.IsNull()); 21656 ASSERT(!tag_label.IsNull());
21652 if (tag_label.Equals(label)) { 21657 if (tag_label.Equals(label)) {
21653 return other.raw(); 21658 return other.raw();
21654 } 21659 }
21655 } 21660 }
21656 return UserTag::null(); 21661 return UserTag::null();
21657 } 21662 }
21658 21663
21659 21664
21660 void UserTag::AddTagToIsolate(Isolate* isolate, const UserTag& tag) { 21665 void UserTag::AddTagToIsolate(Thread* thread, const UserTag& tag) {
21666 Isolate* isolate = thread->isolate();
21667 Zone* zone = thread->zone();
21661 ASSERT(isolate->tag_table() != GrowableObjectArray::null()); 21668 ASSERT(isolate->tag_table() != GrowableObjectArray::null());
21662 const GrowableObjectArray& tag_table = GrowableObjectArray::Handle( 21669 const GrowableObjectArray& tag_table = GrowableObjectArray::Handle(
21663 isolate->current_zone(), isolate->tag_table()); 21670 zone, isolate->tag_table());
21664 ASSERT(!TagTableIsFull(isolate)); 21671 ASSERT(!TagTableIsFull(isolate));
21665 #if defined(DEBUG) 21672 #if defined(DEBUG)
21666 // Verify that no existing tag has the same tag id. 21673 // Verify that no existing tag has the same tag id.
21667 UserTag& other = UserTag::Handle(isolate->current_zone()); 21674 UserTag& other = UserTag::Handle(isolate->current_zone());
21668 for (intptr_t i = 0; i < tag_table.Length(); i++) { 21675 for (intptr_t i = 0; i < tag_table.Length(); i++) {
21669 other ^= tag_table.At(i); 21676 other ^= tag_table.At(i);
21670 ASSERT(!other.IsNull()); 21677 ASSERT(!other.IsNull());
21671 ASSERT(tag.tag() != other.tag()); 21678 ASSERT(tag.tag() != other.tag());
21672 } 21679 }
21673 #endif 21680 #endif
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
21713 return tag_label.ToCString(); 21720 return tag_label.ToCString();
21714 } 21721 }
21715 21722
21716 21723
21717 void UserTag::PrintJSONImpl(JSONStream* stream, bool ref) const { 21724 void UserTag::PrintJSONImpl(JSONStream* stream, bool ref) const {
21718 Instance::PrintJSONImpl(stream, ref); 21725 Instance::PrintJSONImpl(stream, ref);
21719 } 21726 }
21720 21727
21721 21728
21722 } // namespace dart 21729 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/object.h ('k') | runtime/vm/service.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698