OLD | NEW |
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/become.h" | 10 #include "vm/become.h" |
(...skipping 7769 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7780 result.set_owner(owner); | 7780 result.set_owner(owner); |
7781 result.set_token_pos(token_pos); | 7781 result.set_token_pos(token_pos); |
7782 result.set_has_initializer(false); | 7782 result.set_has_initializer(false); |
7783 result.set_is_unboxing_candidate(true); | 7783 result.set_is_unboxing_candidate(true); |
7784 result.set_kernel_offset(0); | 7784 result.set_kernel_offset(0); |
7785 Isolate* isolate = Isolate::Current(); | 7785 Isolate* isolate = Isolate::Current(); |
7786 | 7786 |
7787 // Use field guards if they are enabled and the isolate has never reloaded. | 7787 // Use field guards if they are enabled and the isolate has never reloaded. |
7788 // TODO(johnmccutchan): The reload case assumes the worst case (everything is | 7788 // TODO(johnmccutchan): The reload case assumes the worst case (everything is |
7789 // dynamic and possibly null). Attempt to relax this later. | 7789 // dynamic and possibly null). Attempt to relax this later. |
7790 #if defined(PRODUCT) | |
7791 const bool use_guarded_cid = | |
7792 FLAG_precompiled_mode || isolate->use_field_guards(); | |
7793 #else | |
7794 const bool use_guarded_cid = | 7790 const bool use_guarded_cid = |
7795 FLAG_precompiled_mode || | 7791 FLAG_precompiled_mode || |
7796 (isolate->use_field_guards() && !isolate->HasAttemptedReload()); | 7792 (isolate->use_field_guards() && !isolate->HasAttemptedReload()); |
7797 #endif // !defined(PRODUCT) | |
7798 result.set_guarded_cid(use_guarded_cid ? kIllegalCid : kDynamicCid); | 7793 result.set_guarded_cid(use_guarded_cid ? kIllegalCid : kDynamicCid); |
7799 result.set_is_nullable(use_guarded_cid ? false : true); | 7794 result.set_is_nullable(use_guarded_cid ? false : true); |
7800 result.set_guarded_list_length_in_object_offset(Field::kUnknownLengthOffset); | 7795 result.set_guarded_list_length_in_object_offset(Field::kUnknownLengthOffset); |
7801 // Presently, we only attempt to remember the list length for final fields. | 7796 // Presently, we only attempt to remember the list length for final fields. |
7802 if (is_final && use_guarded_cid) { | 7797 if (is_final && use_guarded_cid) { |
7803 result.set_guarded_list_length(Field::kUnknownFixedLength); | 7798 result.set_guarded_list_length(Field::kUnknownFixedLength); |
7804 } else { | 7799 } else { |
7805 result.set_guarded_list_length(Field::kNoFixedLength); | 7800 result.set_guarded_list_length(Field::kNoFixedLength); |
7806 } | 7801 } |
7807 } | 7802 } |
(...skipping 3222 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
11030 } | 11025 } |
11031 | 11026 |
11032 // Create a private key for this library. It is based on the hash of the | 11027 // Create a private key for this library. It is based on the hash of the |
11033 // library URI and the sequence number of the library to guarantee unique | 11028 // library URI and the sequence number of the library to guarantee unique |
11034 // private keys without having to verify. | 11029 // private keys without having to verify. |
11035 void Library::AllocatePrivateKey() const { | 11030 void Library::AllocatePrivateKey() const { |
11036 Thread* thread = Thread::Current(); | 11031 Thread* thread = Thread::Current(); |
11037 Zone* zone = thread->zone(); | 11032 Zone* zone = thread->zone(); |
11038 Isolate* isolate = thread->isolate(); | 11033 Isolate* isolate = thread->isolate(); |
11039 | 11034 |
11040 #if !defined(PRODUCT) | |
11041 if (FLAG_support_reload && isolate->IsReloading()) { | 11035 if (FLAG_support_reload && isolate->IsReloading()) { |
11042 // When reloading, we need to make sure we use the original private key | 11036 // When reloading, we need to make sure we use the original private key |
11043 // if this library previously existed. | 11037 // if this library previously existed. |
11044 IsolateReloadContext* reload_context = isolate->reload_context(); | 11038 IsolateReloadContext* reload_context = isolate->reload_context(); |
11045 const String& original_key = | 11039 const String& original_key = |
11046 String::Handle(reload_context->FindLibraryPrivateKey(*this)); | 11040 String::Handle(reload_context->FindLibraryPrivateKey(*this)); |
11047 if (!original_key.IsNull()) { | 11041 if (!original_key.IsNull()) { |
11048 StorePointer(&raw_ptr()->private_key_, original_key.raw()); | 11042 StorePointer(&raw_ptr()->private_key_, original_key.raw()); |
11049 return; | 11043 return; |
11050 } | 11044 } |
11051 } | 11045 } |
11052 #endif // !defined(PRODUCT) | |
11053 | 11046 |
11054 // Format of the private key is: "@<sequence number><6 digits of hash> | 11047 // Format of the private key is: "@<sequence number><6 digits of hash> |
11055 const intptr_t hash_mask = 0x7FFFF; | 11048 const intptr_t hash_mask = 0x7FFFF; |
11056 | 11049 |
11057 const String& url = String::Handle(zone, this->url()); | 11050 const String& url = String::Handle(zone, this->url()); |
11058 intptr_t hash_value = url.Hash() & hash_mask; | 11051 intptr_t hash_value = url.Hash() & hash_mask; |
11059 | 11052 |
11060 const GrowableObjectArray& libs = | 11053 const GrowableObjectArray& libs = |
11061 GrowableObjectArray::Handle(zone, isolate->object_store()->libraries()); | 11054 GrowableObjectArray::Handle(zone, isolate->object_store()->libraries()); |
11062 intptr_t sequence_value = libs.Length(); | 11055 intptr_t sequence_value = libs.Length(); |
(...skipping 11470 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
22533 } | 22526 } |
22534 return UserTag::null(); | 22527 return UserTag::null(); |
22535 } | 22528 } |
22536 | 22529 |
22537 const char* UserTag::ToCString() const { | 22530 const char* UserTag::ToCString() const { |
22538 const String& tag_label = String::Handle(label()); | 22531 const String& tag_label = String::Handle(label()); |
22539 return tag_label.ToCString(); | 22532 return tag_label.ToCString(); |
22540 } | 22533 } |
22541 | 22534 |
22542 } // namespace dart | 22535 } // namespace dart |
OLD | NEW |