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

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

Issue 1289813005: Use Object::null_instance and Object::null_function and do not create Handles everytime. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: code-review-patch Created 5 years, 4 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/dart_api_impl.cc ('k') | runtime/vm/parser.cc » ('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 7231 matching lines...) Expand 10 before | Expand all | Expand 10 after
7242 } else { 7242 } else {
7243 result.SetOffset(0); 7243 result.SetOffset(0);
7244 } 7244 }
7245 result.set_is_final(is_final); 7245 result.set_is_final(is_final);
7246 result.set_is_const(is_const); 7246 result.set_is_const(is_const);
7247 result.set_is_reflectable(is_reflectable); 7247 result.set_is_reflectable(is_reflectable);
7248 result.set_is_double_initialized(false); 7248 result.set_is_double_initialized(false);
7249 result.set_owner(owner); 7249 result.set_owner(owner);
7250 result.set_token_pos(token_pos); 7250 result.set_token_pos(token_pos);
7251 result.set_has_initializer(false); 7251 result.set_has_initializer(false);
7252 result.set_initializer(Function::Handle());
7253 result.set_is_unboxing_candidate(true); 7252 result.set_is_unboxing_candidate(true);
7254 result.set_guarded_cid(FLAG_use_field_guards ? kIllegalCid : kDynamicCid); 7253 result.set_guarded_cid(FLAG_use_field_guards ? kIllegalCid : kDynamicCid);
7255 result.set_is_nullable(FLAG_use_field_guards ? false : true); 7254 result.set_is_nullable(FLAG_use_field_guards ? false : true);
7256 result.set_guarded_list_length_in_object_offset(Field::kUnknownLengthOffset); 7255 result.set_guarded_list_length_in_object_offset(Field::kUnknownLengthOffset);
7257 // Presently, we only attempt to remember the list length for final fields. 7256 // Presently, we only attempt to remember the list length for final fields.
7258 if (is_final && FLAG_use_field_guards) { 7257 if (is_final && FLAG_use_field_guards) {
7259 result.set_guarded_list_length(Field::kUnknownFixedLength); 7258 result.set_guarded_list_length(Field::kUnknownFixedLength);
7260 } else { 7259 } else {
7261 result.set_guarded_list_length(Field::kNoFixedLength); 7260 result.set_guarded_list_length(Field::kNoFixedLength);
7262 } 7261 }
7263 result.set_dependent_code(Object::null_array());
7264 return result.raw(); 7262 return result.raw();
7265 } 7263 }
7266 7264
7267 7265
7268 7266
7269 RawField* Field::Clone(const Class& new_owner) const { 7267 RawField* Field::Clone(const Class& new_owner) const {
7270 Field& clone = Field::Handle(); 7268 Field& clone = Field::Handle();
7271 clone ^= Object::Clone(*this, Heap::kOld); 7269 clone ^= Object::Clone(*this, Heap::kOld);
7272 const Class& owner = Class::Handle(this->owner()); 7270 const Class& owner = Class::Handle(this->owner());
7273 const PatchClass& clone_owner = 7271 const PatchClass& clone_owner =
7274 PatchClass::Handle(PatchClass::New(new_owner, owner)); 7272 PatchClass::Handle(PatchClass::New(new_owner, owner));
7275 clone.set_owner(clone_owner); 7273 clone.set_owner(clone_owner);
7276 clone.set_dependent_code(Object::null_array());
7277 if (!clone.is_static()) { 7274 if (!clone.is_static()) {
7278 clone.SetOffset(0); 7275 clone.SetOffset(0);
7279 } 7276 }
7280 if (new_owner.NumTypeParameters() > 0) { 7277 if (new_owner.NumTypeParameters() > 0) {
7281 // Adjust the field type to refer to type parameters of the new owner. 7278 // Adjust the field type to refer to type parameters of the new owner.
7282 AbstractType& type = AbstractType::Handle(clone.type()); 7279 AbstractType& type = AbstractType::Handle(clone.type());
7283 type ^= type.CloneUninstantiated(new_owner); 7280 type ^= type.CloneUninstantiated(new_owner);
7284 clone.set_type(type); 7281 clone.set_type(type);
7285 } 7282 }
7286 return clone.raw(); 7283 return clone.raw();
(...skipping 3213 matching lines...) Expand 10 before | Expand all | Expand 10 after
10500 bool deferred_load, 10497 bool deferred_load,
10501 const Library& importer) { 10498 const Library& importer) {
10502 const LibraryPrefix& result = LibraryPrefix::Handle(LibraryPrefix::New()); 10499 const LibraryPrefix& result = LibraryPrefix::Handle(LibraryPrefix::New());
10503 result.set_name(name); 10500 result.set_name(name);
10504 result.set_num_imports(0); 10501 result.set_num_imports(0);
10505 result.set_importer(importer); 10502 result.set_importer(importer);
10506 result.StoreNonPointer(&result.raw_ptr()->is_deferred_load_, deferred_load); 10503 result.StoreNonPointer(&result.raw_ptr()->is_deferred_load_, deferred_load);
10507 result.StoreNonPointer(&result.raw_ptr()->is_loaded_, !deferred_load); 10504 result.StoreNonPointer(&result.raw_ptr()->is_loaded_, !deferred_load);
10508 result.set_imports(Array::Handle(Array::New(kInitialSize))); 10505 result.set_imports(Array::Handle(Array::New(kInitialSize)));
10509 result.AddImport(import); 10506 result.AddImport(import);
10510 result.set_dependent_code(Object::null_array());
10511 return result.raw(); 10507 return result.raw();
10512 } 10508 }
10513 10509
10514 10510
10515 void LibraryPrefix::set_name(const String& value) const { 10511 void LibraryPrefix::set_name(const String& value) const {
10516 ASSERT(value.IsSymbol()); 10512 ASSERT(value.IsSymbol());
10517 StorePointer(&raw_ptr()->name_, value.raw()); 10513 StorePointer(&raw_ptr()->name_, value.raw());
10518 } 10514 }
10519 10515
10520 10516
(...skipping 10847 matching lines...) Expand 10 before | Expand all | Expand 10 after
21368 return tag_label.ToCString(); 21364 return tag_label.ToCString();
21369 } 21365 }
21370 21366
21371 21367
21372 void UserTag::PrintJSONImpl(JSONStream* stream, bool ref) const { 21368 void UserTag::PrintJSONImpl(JSONStream* stream, bool ref) const {
21373 Instance::PrintJSONImpl(stream, ref); 21369 Instance::PrintJSONImpl(stream, ref);
21374 } 21370 }
21375 21371
21376 21372
21377 } // namespace dart 21373 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/dart_api_impl.cc ('k') | runtime/vm/parser.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698