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

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

Issue 10827288: - Support for patching of class methods and fields. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 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 | 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 #ifndef VM_OBJECT_H_ 5 #ifndef VM_OBJECT_H_
6 #define VM_OBJECT_H_ 6 #define VM_OBJECT_H_
7 7
8 #include "include/dart_api.h" 8 #include "include/dart_api.h"
9 #include "platform/assert.h" 9 #include "platform/assert.h"
10 #include "platform/utils.h" 10 #include "platform/utils.h"
(...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after
243 static RawInstance* sentinel() { return sentinel_; } 243 static RawInstance* sentinel() { return sentinel_; }
244 // Value marking that we are transitioning from sentinel, e.g., computing 244 // Value marking that we are transitioning from sentinel, e.g., computing
245 // a field value. Used to detect circular initialization. 245 // a field value. Used to detect circular initialization.
246 static RawInstance* transition_sentinel() { return transition_sentinel_; } 246 static RawInstance* transition_sentinel() { return transition_sentinel_; }
247 247
248 static RawClass* class_class() { return class_class_; } 248 static RawClass* class_class() { return class_class_; }
249 static RawClass* null_class() { return null_class_; } 249 static RawClass* null_class() { return null_class_; }
250 static RawClass* dynamic_class() { return dynamic_class_; } 250 static RawClass* dynamic_class() { return dynamic_class_; }
251 static RawClass* void_class() { return void_class_; } 251 static RawClass* void_class() { return void_class_; }
252 static RawClass* unresolved_class_class() { return unresolved_class_class_; } 252 static RawClass* unresolved_class_class() { return unresolved_class_class_; }
253 static RawClass* type_class() { 253 static RawClass* type_class() { return type_class_; }
254 return type_class_;
255 }
256 static RawClass* type_parameter_class() { return type_parameter_class_; } 254 static RawClass* type_parameter_class() { return type_parameter_class_; }
257 static RawClass* type_arguments_class() { return type_arguments_class_; } 255 static RawClass* type_arguments_class() { return type_arguments_class_; }
258 static RawClass* instantiated_type_arguments_class() { 256 static RawClass* instantiated_type_arguments_class() {
259 return instantiated_type_arguments_class_; 257 return instantiated_type_arguments_class_;
260 } 258 }
259 static RawClass* patch_class_class() { return patch_class_class_; }
261 static RawClass* function_class() { return function_class_; } 260 static RawClass* function_class() { return function_class_; }
262 static RawClass* field_class() { return field_class_; } 261 static RawClass* field_class() { return field_class_; }
263 static RawClass* literal_token_class() { return literal_token_class_; } 262 static RawClass* literal_token_class() { return literal_token_class_; }
264 static RawClass* token_stream_class() { return token_stream_class_; } 263 static RawClass* token_stream_class() { return token_stream_class_; }
265 static RawClass* script_class() { return script_class_; } 264 static RawClass* script_class() { return script_class_; }
266 static RawClass* library_class() { return library_class_; } 265 static RawClass* library_class() { return library_class_; }
267 static RawClass* library_prefix_class() { return library_prefix_class_; } 266 static RawClass* library_prefix_class() { return library_prefix_class_; }
268 static RawClass* code_class() { return code_class_; } 267 static RawClass* code_class() { return code_class_; }
269 static RawClass* instructions_class() { return instructions_class_; } 268 static RawClass* instructions_class() { return instructions_class_; }
270 static RawClass* pc_descriptors_class() { return pc_descriptors_class_; } 269 static RawClass* pc_descriptors_class() { return pc_descriptors_class_; }
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
380 static RawClass* class_class_; // Class of the Class vm object. 379 static RawClass* class_class_; // Class of the Class vm object.
381 static RawClass* null_class_; // Class of the null object. 380 static RawClass* null_class_; // Class of the null object.
382 static RawClass* dynamic_class_; // Class of the 'Dynamic' type. 381 static RawClass* dynamic_class_; // Class of the 'Dynamic' type.
383 static RawClass* void_class_; // Class of the 'void' type. 382 static RawClass* void_class_; // Class of the 'void' type.
384 static RawClass* unresolved_class_class_; // Class of UnresolvedClass. 383 static RawClass* unresolved_class_class_; // Class of UnresolvedClass.
385 static RawClass* type_class_; // Class of Type. 384 static RawClass* type_class_; // Class of Type.
386 static RawClass* type_parameter_class_; // Class of TypeParameter vm object. 385 static RawClass* type_parameter_class_; // Class of TypeParameter vm object.
387 // Class of the TypeArguments vm object. 386 // Class of the TypeArguments vm object.
388 static RawClass* type_arguments_class_; 387 static RawClass* type_arguments_class_;
389 static RawClass* instantiated_type_arguments_class_; // Class of Inst..ments. 388 static RawClass* instantiated_type_arguments_class_; // Class of Inst..ments.
389 static RawClass* patch_class_class_; // Class of the PatchClass vm object.
390 static RawClass* function_class_; // Class of the Function vm object. 390 static RawClass* function_class_; // Class of the Function vm object.
391 static RawClass* field_class_; // Class of the Field vm object. 391 static RawClass* field_class_; // Class of the Field vm object.
392 static RawClass* literal_token_class_; // Class of LiteralToken vm object. 392 static RawClass* literal_token_class_; // Class of LiteralToken vm object.
393 static RawClass* token_stream_class_; // Class of the TokenStream vm object. 393 static RawClass* token_stream_class_; // Class of the TokenStream vm object.
394 static RawClass* script_class_; // Class of the Script vm object. 394 static RawClass* script_class_; // Class of the Script vm object.
395 static RawClass* library_class_; // Class of the Library vm object. 395 static RawClass* library_class_; // Class of the Library vm object.
396 static RawClass* library_prefix_class_; // Class of Library prefix vm object. 396 static RawClass* library_prefix_class_; // Class of Library prefix vm object.
397 static RawClass* code_class_; // Class of the Code vm object. 397 static RawClass* code_class_; // Class of the Code vm object.
398 static RawClass* instructions_class_; // Class of the Instructions vm object. 398 static RawClass* instructions_class_; // Class of the Instructions vm object.
399 static RawClass* pc_descriptors_class_; // Class of PcDescriptors vm object. 399 static RawClass* pc_descriptors_class_; // Class of PcDescriptors vm object.
(...skipping 272 matching lines...) Expand 10 before | Expand all | Expand 10 after
672 672
673 RawCode* allocation_stub() const { 673 RawCode* allocation_stub() const {
674 return raw_ptr()->allocation_stub_; 674 return raw_ptr()->allocation_stub_;
675 } 675 }
676 void set_allocation_stub(const Code& value) const; 676 void set_allocation_stub(const Code& value) const;
677 677
678 RawArray* constants() const; 678 RawArray* constants() const;
679 679
680 void Finalize() const; 680 void Finalize() const;
681 681
682 void ApplyPatch(const Class& with) const;
683
682 // Allocate a class used for VM internal objects. 684 // Allocate a class used for VM internal objects.
683 template <class FakeObject> static RawClass* New(); 685 template <class FakeObject> static RawClass* New();
684 686
685 // Allocate instance classes and interfaces. 687 // Allocate instance classes and interfaces.
686 static RawClass* New(const String& name, 688 static RawClass* New(const String& name,
687 const Script& script, 689 const Script& script,
688 intptr_t token_pos); 690 intptr_t token_pos);
689 static RawClass* NewInterface(const String& name, 691 static RawClass* NewInterface(const String& name,
690 const Script& script, 692 const Script& script,
691 intptr_t token_pos); 693 intptr_t token_pos);
(...skipping 580 matching lines...) Expand 10 before | Expand all | Expand 10 after
1272 const AbstractTypeArguments& value) const; 1274 const AbstractTypeArguments& value) const;
1273 void set_instantiator_type_arguments( 1275 void set_instantiator_type_arguments(
1274 const AbstractTypeArguments& value) const; 1276 const AbstractTypeArguments& value) const;
1275 static RawInstantiatedTypeArguments* New(); 1277 static RawInstantiatedTypeArguments* New();
1276 1278
1277 HEAP_OBJECT_IMPLEMENTATION(InstantiatedTypeArguments, AbstractTypeArguments); 1279 HEAP_OBJECT_IMPLEMENTATION(InstantiatedTypeArguments, AbstractTypeArguments);
1278 friend class Class; 1280 friend class Class;
1279 }; 1281 };
1280 1282
1281 1283
1284 class PatchClass : public Object {
1285 public:
1286 RawClass* patched_class() const { return raw_ptr()->patched_class_; }
1287 RawScript* script() const { return raw_ptr()->script_; }
1288
1289 static intptr_t InstanceSize() {
1290 return RoundedAllocationSize(sizeof(RawPatchClass));
1291 }
1292
1293 static RawPatchClass* New(const Class& patched_class, const Script& script);
1294
1295 private:
1296 void set_patched_class(const Class& value) const;
1297 void set_script(const Script& value) const;
1298 static RawPatchClass* New();
1299
1300 HEAP_OBJECT_IMPLEMENTATION(PatchClass, Object);
1301 friend class Class;
1302 };
1303
1304
1282 class Function : public Object { 1305 class Function : public Object {
1283 public: 1306 public:
1284 RawString* name() const { return raw_ptr()->name_; } 1307 RawString* name() const { return raw_ptr()->name_; }
1285 RawString* UserVisibleName() const; 1308 RawString* UserVisibleName() const;
1286 RawString* QualifiedUserVisibleName() const; 1309 RawString* QualifiedUserVisibleName() const;
1287 1310
1288 // Build a string of the form '<T, R>(T, [b: B, c: C]) => R' representing the 1311 // Build a string of the form '<T, R>(T, [b: B, c: C]) => R' representing the
1289 // internal signature of the given function. 1312 // internal signature of the given function.
1290 RawString* Signature() const { 1313 RawString* Signature() const {
1291 const bool instantiate = false; 1314 const bool instantiate = false;
1292 return BuildSignature(instantiate, kInternalName, TypeArguments::Handle()); 1315 return BuildSignature(instantiate, kInternalName, TypeArguments::Handle());
1293 } 1316 }
1294 1317
1295 // Build a string of the form '(A, [b: B, c: C]) => D' representing the 1318 // Build a string of the form '(A, [b: B, c: C]) => D' representing the
1296 // signature of the given function, where all generic types (e.g. '<T, R>' in 1319 // signature of the given function, where all generic types (e.g. '<T, R>' in
1297 // '<T, R>(T, [b: B, c: C]) => R') are instantiated using the given 1320 // '<T, R>(T, [b: B, c: C]) => R') are instantiated using the given
1298 // instantiator type argument vector (e.g. '<A, D>'). 1321 // instantiator type argument vector (e.g. '<A, D>').
1299 RawString* InstantiatedSignatureFrom( 1322 RawString* InstantiatedSignatureFrom(
1300 const AbstractTypeArguments& instantiator, 1323 const AbstractTypeArguments& instantiator,
1301 NameVisibility name_visibility) const { 1324 NameVisibility name_visibility) const {
1302 const bool instantiate = true; 1325 const bool instantiate = true;
1303 return BuildSignature(instantiate, name_visibility, instantiator); 1326 return BuildSignature(instantiate, name_visibility, instantiator);
1304 } 1327 }
1305 1328
1306 // Returns true if the signature of this function is instantiated, i.e. if it 1329 // Returns true if the signature of this function is instantiated, i.e. if it
1307 // does not involve generic parameter types or generic result type. 1330 // does not involve generic parameter types or generic result type.
1308 bool HasInstantiatedSignature() const; 1331 bool HasInstantiatedSignature() const;
1309 1332
1310 RawClass* owner() const { return raw_ptr()->owner_; } 1333 RawClass* Owner() const;
1334
1335 RawScript* script() const;
1311 1336
1312 RawAbstractType* result_type() const { return raw_ptr()->result_type_; } 1337 RawAbstractType* result_type() const { return raw_ptr()->result_type_; }
1313 void set_result_type(const AbstractType& value) const; 1338 void set_result_type(const AbstractType& value) const;
1314 1339
1315 RawAbstractType* ParameterTypeAt(intptr_t index) const; 1340 RawAbstractType* ParameterTypeAt(intptr_t index) const;
1316 void SetParameterTypeAt(intptr_t index, const AbstractType& value) const; 1341 void SetParameterTypeAt(intptr_t index, const AbstractType& value) const;
1317 void set_parameter_types(const Array& value) const; 1342 void set_parameter_types(const Array& value) const;
1318 1343
1319 // Parameter names are valid for all valid parameter indices, and are not 1344 // Parameter names are valid for all valid parameter indices, and are not
1320 // limited to named optional parameters. 1345 // limited to named optional parameters.
(...skipping 292 matching lines...) Expand 10 before | Expand all | Expand 10 after
1613 class ExternalBit : public BitField<bool, kExternalBit, 1> {}; 1638 class ExternalBit : public BitField<bool, kExternalBit, 1> {};
1614 class KindBits : 1639 class KindBits :
1615 public BitField<RawFunction::Kind, kKindTagBit, kKindTagSize> {}; // NOLINT 1640 public BitField<RawFunction::Kind, kKindTagBit, kKindTagSize> {}; // NOLINT
1616 1641
1617 void set_name(const String& value) const; 1642 void set_name(const String& value) const;
1618 void set_kind(RawFunction::Kind value) const; 1643 void set_kind(RawFunction::Kind value) const;
1619 void set_is_static(bool is_static) const; 1644 void set_is_static(bool is_static) const;
1620 void set_is_const(bool is_const) const; 1645 void set_is_const(bool is_const) const;
1621 void set_is_external(bool value) const; 1646 void set_is_external(bool value) const;
1622 void set_parent_function(const Function& value) const; 1647 void set_parent_function(const Function& value) const;
1623 void set_owner(const Class& value) const; 1648 void set_owner(const Object& value) const;
1624 void set_token_pos(intptr_t value) const; 1649 void set_token_pos(intptr_t value) const;
1625 void set_implicit_closure_function(const Function& value) const; 1650 void set_implicit_closure_function(const Function& value) const;
1626 void set_kind_tag(intptr_t value) const; 1651 void set_kind_tag(intptr_t value) const;
1627 static RawFunction* New(); 1652 static RawFunction* New();
1628 1653
1629 RawString* BuildSignature(bool instantiate, 1654 RawString* BuildSignature(bool instantiate,
1630 NameVisibility name_visibility, 1655 NameVisibility name_visibility,
1631 const AbstractTypeArguments& instantiator) const; 1656 const AbstractTypeArguments& instantiator) const;
1632 1657
1633 // Check the subtype or 'more specific' relationship. 1658 // Check the subtype or 'more specific' relationship.
(...skipping 3818 matching lines...) Expand 10 before | Expand all | Expand 10 after
5452 if (this->CharAt(i) != str.CharAt(begin_index + i)) { 5477 if (this->CharAt(i) != str.CharAt(begin_index + i)) {
5453 return false; 5478 return false;
5454 } 5479 }
5455 } 5480 }
5456 return true; 5481 return true;
5457 } 5482 }
5458 5483
5459 } // namespace dart 5484 } // namespace dart
5460 5485
5461 #endif // VM_OBJECT_H_ 5486 #endif // VM_OBJECT_H_
OLDNEW
« no previous file with comments | « runtime/vm/intrinsifier.cc ('k') | runtime/vm/object.cc » ('j') | runtime/vm/object.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698