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