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

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

Issue 22915008: Tests for GuardField length check along with bug fixes (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 3 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') | runtime/vm/raw_object.h » ('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 5344 matching lines...) Expand 10 before | Expand all | Expand 10 after
5355 } else { 5355 } else {
5356 result.SetOffset(0); 5356 result.SetOffset(0);
5357 } 5357 }
5358 result.set_is_final(is_final); 5358 result.set_is_final(is_final);
5359 result.set_is_const(is_const); 5359 result.set_is_const(is_const);
5360 result.set_owner(owner); 5360 result.set_owner(owner);
5361 result.set_token_pos(token_pos); 5361 result.set_token_pos(token_pos);
5362 result.set_has_initializer(false); 5362 result.set_has_initializer(false);
5363 result.set_guarded_cid(kIllegalCid); 5363 result.set_guarded_cid(kIllegalCid);
5364 result.set_is_nullable(false); 5364 result.set_is_nullable(false);
5365 result.set_guarded_list_length(Field::kUnknownFixedLength); 5365 // Presently, we only attempt to remember the list length for final fields.
5366 if (is_final) {
5367 result.set_guarded_list_length(Field::kUnknownFixedLength);
5368 } else {
5369 result.set_guarded_list_length(Field::kNoFixedLength);
5370 }
5366 result.set_dependent_code(Object::null_array()); 5371 result.set_dependent_code(Object::null_array());
5367 return result.raw(); 5372 return result.raw();
5368 } 5373 }
5369 5374
5370 5375
5371 5376
5372 RawField* Field::Clone(const Class& new_owner) const { 5377 RawField* Field::Clone(const Class& new_owner) const {
5373 Field& clone = Field::Handle(); 5378 Field& clone = Field::Handle();
5374 clone ^= Object::Clone(*this, Heap::kOld); 5379 clone ^= Object::Clone(*this, Heap::kOld);
5375 const Class& owner = Class::Handle(this->owner()); 5380 const Class& owner = Class::Handle(this->owner());
5376 const PatchClass& clone_owner = 5381 const PatchClass& clone_owner =
5377 PatchClass::Handle(PatchClass::New(new_owner, owner)); 5382 PatchClass::Handle(PatchClass::New(new_owner, owner));
5378 clone.set_owner(clone_owner); 5383 clone.set_owner(clone_owner);
5379 clone.set_dependent_code(Object::null_array()); 5384 clone.set_dependent_code(Object::null_array());
5380 if (!clone.is_static()) { 5385 if (!clone.is_static()) {
5381 clone.SetOffset(0); 5386 clone.SetOffset(0);
5382 } 5387 }
5383 return clone.raw(); 5388 return clone.raw();
5384 } 5389 }
5385 5390
5386 5391
5387 RawString* Field::UserVisibleName() const { 5392 RawString* Field::UserVisibleName() const {
5388 const String& str = String::Handle(name()); 5393 const String& str = String::Handle(name());
5389 return IdentifierPrettyName(str); 5394 return IdentifierPrettyName(str);
5390 } 5395 }
5391 5396
5392 5397
5398 intptr_t Field::guarded_list_length() const {
5399 return Smi::Value(raw_ptr()->guarded_list_length_);
5400 }
5401
5402
5403 void Field::set_guarded_list_length(intptr_t list_length) const {
5404 raw_ptr()->guarded_list_length_ = Smi::New(list_length);
5405 }
5406
5407
5393 const char* Field::ToCString() const { 5408 const char* Field::ToCString() const {
5394 if (IsNull()) { 5409 if (IsNull()) {
5395 return "Field::null"; 5410 return "Field::null";
5396 } 5411 }
5397 const char* kF0 = is_static() ? " static" : ""; 5412 const char* kF0 = is_static() ? " static" : "";
5398 const char* kF1 = is_final() ? " final" : ""; 5413 const char* kF1 = is_final() ? " final" : "";
5399 const char* kF2 = is_const() ? " const" : ""; 5414 const char* kF2 = is_const() ? " const" : "";
5400 const char* kFormat = "Field <%s.%s>:%s%s%s"; 5415 const char* kFormat = "Field <%s.%s>:%s%s%s";
5401 const char* field_name = String::Handle(name()).ToCString(); 5416 const char* field_name = String::Handle(name()).ToCString();
5402 const Class& cls = Class::Handle(owner()); 5417 const Class& cls = Class::Handle(owner());
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after
5575 if (list_length_unknown && list_length_changed && !force_invalidate) { 5590 if (list_length_unknown && list_length_changed && !force_invalidate) {
5576 // List length set for first time. 5591 // List length set for first time.
5577 set_guarded_list_length(list_length); 5592 set_guarded_list_length(list_length);
5578 return; 5593 return;
5579 } 5594 }
5580 5595
5581 if (!list_length_changed && !force_invalidate) { 5596 if (!list_length_changed && !force_invalidate) {
5582 // List length unchanged. 5597 // List length unchanged.
5583 return; 5598 return;
5584 } 5599 }
5585
5586 // Multiple list lengths assigned here, stop tracking length. 5600 // Multiple list lengths assigned here, stop tracking length.
5587 set_guarded_list_length(Field::kNoFixedLength); 5601 set_guarded_list_length(Field::kNoFixedLength);
5588 DeoptimizeDependentCode(); 5602 DeoptimizeDependentCode();
5589 } 5603 }
5590 5604
5591 5605
5592 void LiteralToken::set_literal(const String& literal) const { 5606 void LiteralToken::set_literal(const String& literal) const {
5593 StorePointer(&raw_ptr()->literal_, literal.raw()); 5607 StorePointer(&raw_ptr()->literal_, literal.raw());
5594 } 5608 }
5595 5609
(...skipping 9337 matching lines...) Expand 10 before | Expand all | Expand 10 after
14933 } 14947 }
14934 14948
14935 14949
14936 void MirrorReference::PrintToJSONStream(JSONStream* stream, bool ref) const { 14950 void MirrorReference::PrintToJSONStream(JSONStream* stream, bool ref) const {
14937 stream->OpenObject(); 14951 stream->OpenObject();
14938 stream->CloseObject(); 14952 stream->CloseObject();
14939 } 14953 }
14940 14954
14941 14955
14942 } // namespace dart 14956 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/object.h ('k') | runtime/vm/raw_object.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698