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

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

Issue 1149943009: Shrink some fields and add some bounds checks. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 5 years, 6 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/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 8680 matching lines...) Expand 10 before | Expand all | Expand 10 after
8691 8691
8692 void LibraryPrefixIterator::Advance() { 8692 void LibraryPrefixIterator::Advance() {
8693 Object& obj = Object::Handle(array_.At(next_ix_)); 8693 Object& obj = Object::Handle(array_.At(next_ix_));
8694 while (!obj.IsLibraryPrefix() && HasNext()) { 8694 while (!obj.IsLibraryPrefix() && HasNext()) {
8695 next_ix_++; 8695 next_ix_++;
8696 obj = array_.At(next_ix_); 8696 obj = array_.At(next_ix_);
8697 } 8697 }
8698 } 8698 }
8699 8699
8700 8700
8701 static void ReportTooManyImports(const Library& lib) {
8702 String& url = String::Handle(lib.url());
siva 2015/06/09 01:29:02 const String& url
rmacnak 2015/06/09 17:47:11 Done.
8703 Report::MessageF(Report::kError,
8704 Script::Handle(lib.LookupScript(url)),
8705 Scanner::kNoSourcePos,
8706 "too many imports in library '%s'",
8707 url.ToCString());
8708 UNREACHABLE();
8709 }
8710
8711
8712 void Library::set_num_imports(intptr_t value) const {
8713 if (!Utils::IsUint(16, value)) {
8714 ReportTooManyImports(*this);
8715 }
8716 StoreNonPointer(&raw_ptr()->num_imports_, value);
8717 }
8718
8719
8701 void Library::SetName(const String& name) const { 8720 void Library::SetName(const String& name) const {
8702 // Only set name once. 8721 // Only set name once.
8703 ASSERT(!Loaded()); 8722 ASSERT(!Loaded());
8704 ASSERT(name.IsSymbol()); 8723 ASSERT(name.IsSymbol());
8705 StorePointer(&raw_ptr()->name_, name.raw()); 8724 StorePointer(&raw_ptr()->name_, name.raw());
8706 } 8725 }
8707 8726
8708 8727
8709 void Library::SetLoadInProgress() const { 8728 void Library::SetLoadInProgress() const {
8710 // Must not already be in the process of being loaded. 8729 // Must not already be in the process of being loaded.
(...skipping 1576 matching lines...) Expand 10 before | Expand all | Expand 10 after
10287 StorePointer(&raw_ptr()->name_, value.raw()); 10306 StorePointer(&raw_ptr()->name_, value.raw());
10288 } 10307 }
10289 10308
10290 10309
10291 void LibraryPrefix::set_imports(const Array& value) const { 10310 void LibraryPrefix::set_imports(const Array& value) const {
10292 StorePointer(&raw_ptr()->imports_, value.raw()); 10311 StorePointer(&raw_ptr()->imports_, value.raw());
10293 } 10312 }
10294 10313
10295 10314
10296 void LibraryPrefix::set_num_imports(intptr_t value) const { 10315 void LibraryPrefix::set_num_imports(intptr_t value) const {
10316 if (!Utils::IsUint(16, value)) {
10317 ReportTooManyImports(Library::Handle(importer()));
10318 }
10297 StoreNonPointer(&raw_ptr()->num_imports_, value); 10319 StoreNonPointer(&raw_ptr()->num_imports_, value);
10298 } 10320 }
10299 10321
10300 10322
10301 void LibraryPrefix::set_importer(const Library& value) const { 10323 void LibraryPrefix::set_importer(const Library& value) const {
10302 StorePointer(&raw_ptr()->importer_, value.raw()); 10324 StorePointer(&raw_ptr()->importer_, value.raw());
10303 } 10325 }
10304 10326
10305 10327
10306 const char* LibraryPrefix::ToCString() const { 10328 const char* LibraryPrefix::ToCString() const {
(...skipping 5254 matching lines...) Expand 10 before | Expand all | Expand 10 after
15561 15583
15562 15584
15563 void TypeParameter::set_parameterized_class(const Class& value) const { 15585 void TypeParameter::set_parameterized_class(const Class& value) const {
15564 // Set value may be null. 15586 // Set value may be null.
15565 StorePointer(&raw_ptr()->parameterized_class_, value.raw()); 15587 StorePointer(&raw_ptr()->parameterized_class_, value.raw());
15566 } 15588 }
15567 15589
15568 15590
15569 void TypeParameter::set_index(intptr_t value) const { 15591 void TypeParameter::set_index(intptr_t value) const {
15570 ASSERT(value >= 0); 15592 ASSERT(value >= 0);
15593 ASSERT(Utils::IsInt(16, value));
15571 StoreNonPointer(&raw_ptr()->index_, value); 15594 StoreNonPointer(&raw_ptr()->index_, value);
15572 } 15595 }
15573 15596
15574 15597
15575 void TypeParameter::set_name(const String& value) const { 15598 void TypeParameter::set_name(const String& value) const {
15576 ASSERT(value.IsSymbol()); 15599 ASSERT(value.IsSymbol());
15577 StorePointer(&raw_ptr()->name_, value.raw()); 15600 StorePointer(&raw_ptr()->name_, value.raw());
15578 } 15601 }
15579 15602
15580 15603
(...skipping 5232 matching lines...) Expand 10 before | Expand all | Expand 10 after
20813 return tag_label.ToCString(); 20836 return tag_label.ToCString();
20814 } 20837 }
20815 20838
20816 20839
20817 void UserTag::PrintJSONImpl(JSONStream* stream, bool ref) const { 20840 void UserTag::PrintJSONImpl(JSONStream* stream, bool ref) const {
20818 Instance::PrintJSONImpl(stream, ref); 20841 Instance::PrintJSONImpl(stream, ref);
20819 } 20842 }
20820 20843
20821 20844
20822 } // namespace dart 20845 } // 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