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

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
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 5332 matching lines...) Expand 10 before | Expand all | Expand 10 after
5343 result.set_value(Object::null_instance()); 5343 result.set_value(Object::null_instance());
5344 } else { 5344 } else {
5345 result.SetOffset(0); 5345 result.SetOffset(0);
5346 } 5346 }
5347 result.set_is_final(is_final); 5347 result.set_is_final(is_final);
5348 result.set_is_const(is_const); 5348 result.set_is_const(is_const);
5349 result.set_owner(owner); 5349 result.set_owner(owner);
5350 result.set_token_pos(token_pos); 5350 result.set_token_pos(token_pos);
5351 result.set_has_initializer(false); 5351 result.set_has_initializer(false);
5352 result.set_guarded_cid(kIllegalCid); 5352 result.set_guarded_cid(kIllegalCid);
5353 result.set_is_nullable(false); 5353 result.set_is_nullable(false);
srdjan 2013/08/28 16:00:55 Maybe add comment that list length guard is implem
Cutch 2013/08/29 08:27:17 Done.
5354 result.set_guarded_list_length(Field::kUnknownFixedLength); 5354 if (is_final) {
5355 result.set_guarded_list_length(Field::kUnknownFixedLength);
5356 } else {
5357 result.set_guarded_list_length(Field::kNoFixedLength);
5358 }
5355 result.set_dependent_code(Object::null_array()); 5359 result.set_dependent_code(Object::null_array());
5356 return result.raw(); 5360 return result.raw();
5357 } 5361 }
5358 5362
5359 5363
5360 5364
5361 RawField* Field::Clone(const Class& new_owner) const { 5365 RawField* Field::Clone(const Class& new_owner) const {
5362 Field& clone = Field::Handle(); 5366 Field& clone = Field::Handle();
5363 clone ^= Object::Clone(*this, Heap::kOld); 5367 clone ^= Object::Clone(*this, Heap::kOld);
5364 const Class& owner = Class::Handle(this->owner()); 5368 const Class& owner = Class::Handle(this->owner());
5365 const PatchClass& clone_owner = 5369 const PatchClass& clone_owner =
5366 PatchClass::Handle(PatchClass::New(new_owner, owner)); 5370 PatchClass::Handle(PatchClass::New(new_owner, owner));
5367 clone.set_owner(clone_owner); 5371 clone.set_owner(clone_owner);
5368 clone.set_dependent_code(Object::null_array()); 5372 clone.set_dependent_code(Object::null_array());
5369 if (!clone.is_static()) { 5373 if (!clone.is_static()) {
5370 clone.SetOffset(0); 5374 clone.SetOffset(0);
5371 } 5375 }
5372 return clone.raw(); 5376 return clone.raw();
5373 } 5377 }
5374 5378
5375 5379
5376 RawString* Field::UserVisibleName() const { 5380 RawString* Field::UserVisibleName() const {
5377 const String& str = String::Handle(name()); 5381 const String& str = String::Handle(name());
5378 return IdentifierPrettyName(str); 5382 return IdentifierPrettyName(str);
5379 } 5383 }
5380 5384
5381 5385
5386 intptr_t Field::guarded_list_length() const {
5387 return Smi::Value(raw_ptr()->guarded_list_length_);
5388 }
5389
5390
5391 void Field::set_guarded_list_length(intptr_t list_length) const {
5392 raw_ptr()->guarded_list_length_ = Smi::New(list_length);
5393 }
5394
5395
5382 const char* Field::ToCString() const { 5396 const char* Field::ToCString() const {
5383 if (IsNull()) { 5397 if (IsNull()) {
5384 return "Field::null"; 5398 return "Field::null";
5385 } 5399 }
5386 const char* kF0 = is_static() ? " static" : ""; 5400 const char* kF0 = is_static() ? " static" : "";
5387 const char* kF1 = is_final() ? " final" : ""; 5401 const char* kF1 = is_final() ? " final" : "";
5388 const char* kF2 = is_const() ? " const" : ""; 5402 const char* kF2 = is_const() ? " const" : "";
5389 const char* kFormat = "Field <%s.%s>:%s%s%s"; 5403 const char* kFormat = "Field <%s.%s>:%s%s%s";
5390 const char* field_name = String::Handle(name()).ToCString(); 5404 const char* field_name = String::Handle(name()).ToCString();
5391 const Class& cls = Class::Handle(owner()); 5405 const Class& cls = Class::Handle(owner());
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after
5564 if (list_length_unknown && list_length_changed && !force_invalidate) { 5578 if (list_length_unknown && list_length_changed && !force_invalidate) {
5565 // List length set for first time. 5579 // List length set for first time.
5566 set_guarded_list_length(list_length); 5580 set_guarded_list_length(list_length);
5567 return; 5581 return;
5568 } 5582 }
5569 5583
5570 if (!list_length_changed && !force_invalidate) { 5584 if (!list_length_changed && !force_invalidate) {
5571 // List length unchanged. 5585 // List length unchanged.
5572 return; 5586 return;
5573 } 5587 }
5574
5575 // Multiple list lengths assigned here, stop tracking length. 5588 // Multiple list lengths assigned here, stop tracking length.
5576 set_guarded_list_length(Field::kNoFixedLength); 5589 set_guarded_list_length(Field::kNoFixedLength);
5577 DeoptimizeDependentCode(); 5590 DeoptimizeDependentCode();
5578 } 5591 }
5579 5592
5580 5593
5581 void LiteralToken::set_literal(const String& literal) const { 5594 void LiteralToken::set_literal(const String& literal) const {
5582 StorePointer(&raw_ptr()->literal_, literal.raw()); 5595 StorePointer(&raw_ptr()->literal_, literal.raw());
5583 } 5596 }
5584 5597
(...skipping 9262 matching lines...) Expand 10 before | Expand all | Expand 10 after
14847 } 14860 }
14848 14861
14849 14862
14850 void MirrorReference::PrintToJSONStream(JSONStream* stream, bool ref) const { 14863 void MirrorReference::PrintToJSONStream(JSONStream* stream, bool ref) const {
14851 stream->OpenObject(); 14864 stream->OpenObject();
14852 stream->CloseObject(); 14865 stream->CloseObject();
14853 } 14866 }
14854 14867
14855 14868
14856 } // namespace dart 14869 } // namespace dart
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698