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

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

Issue 668193002: Remove isolate pointer from context objects. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: fixed initialization order bug Created 6 years, 1 month 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 489 matching lines...) Expand 10 before | Expand all | Expand 10 after
500 return megamorphic_cache_class_; 500 return megamorphic_cache_class_;
501 } 501 }
502 static RawClass* subtypetestcache_class() { return subtypetestcache_class_; } 502 static RawClass* subtypetestcache_class() { return subtypetestcache_class_; }
503 503
504 // Initialize the VM isolate. 504 // Initialize the VM isolate.
505 static void InitOnce(Isolate* isolate); 505 static void InitOnce(Isolate* isolate);
506 static void FinalizeVMIsolate(Isolate* isolate); 506 static void FinalizeVMIsolate(Isolate* isolate);
507 507
508 // Initialize a new isolate either from source or from a snapshot. 508 // Initialize a new isolate either from source or from a snapshot.
509 static RawError* Init(Isolate* isolate); 509 static RawError* Init(Isolate* isolate);
510 static RawError* FinishInit(Isolate* isolate);
510 static void InitFromSnapshot(Isolate* isolate); 511 static void InitFromSnapshot(Isolate* isolate);
511 512
512 static void MakeUnusedSpaceTraversable(const Object& obj, 513 static void MakeUnusedSpaceTraversable(const Object& obj,
513 intptr_t original_size, 514 intptr_t original_size,
514 intptr_t used_size); 515 intptr_t used_size);
515 516
516 static intptr_t InstanceSize() { 517 static intptr_t InstanceSize() {
517 return RoundedAllocationSize(sizeof(RawObject)); 518 return RoundedAllocationSize(sizeof(RawObject));
518 } 519 }
519 520
(...skipping 3540 matching lines...) Expand 10 before | Expand all | Expand 10 after
4060 // So that the RawFunction pointer visitor can determine whether code the 4061 // So that the RawFunction pointer visitor can determine whether code the
4061 // function points to is optimized. 4062 // function points to is optimized.
4062 friend class RawFunction; 4063 friend class RawFunction;
4063 }; 4064 };
4064 4065
4065 4066
4066 class Context : public Object { 4067 class Context : public Object {
4067 public: 4068 public:
4068 RawContext* parent() const { return raw_ptr()->parent_; } 4069 RawContext* parent() const { return raw_ptr()->parent_; }
4069 void set_parent(const Context& parent) const { 4070 void set_parent(const Context& parent) const {
4070 ASSERT(parent.IsNull() || parent.isolate() == Isolate::Current());
4071 StorePointer(&raw_ptr()->parent_, parent.raw()); 4071 StorePointer(&raw_ptr()->parent_, parent.raw());
4072 } 4072 }
4073 static intptr_t parent_offset() { return OFFSET_OF(RawContext, parent_); } 4073 static intptr_t parent_offset() { return OFFSET_OF(RawContext, parent_); }
4074 4074
4075 Isolate* isolate() const { return raw_ptr()->isolate_; }
4076 static intptr_t isolate_offset() { return OFFSET_OF(RawContext, isolate_); }
4077
4078 intptr_t num_variables() const { return raw_ptr()->num_variables_; } 4075 intptr_t num_variables() const { return raw_ptr()->num_variables_; }
4079 static intptr_t num_variables_offset() { 4076 static intptr_t num_variables_offset() {
4080 return OFFSET_OF(RawContext, num_variables_); 4077 return OFFSET_OF(RawContext, num_variables_);
4081 } 4078 }
4082 4079
4083 RawInstance* At(intptr_t context_index) const { 4080 RawInstance* At(intptr_t context_index) const {
4084 return *InstanceAddr(context_index); 4081 return *InstanceAddr(context_index);
4085 } 4082 }
4086 inline void SetAt(intptr_t context_index, const Instance& value) const; 4083 inline void SetAt(intptr_t context_index, const Instance& value) const;
4087 4084
(...skipping 19 matching lines...) Expand all
4107 4104
4108 static RawContext* New(intptr_t num_variables, 4105 static RawContext* New(intptr_t num_variables,
4109 Heap::Space space = Heap::kNew); 4106 Heap::Space space = Heap::kNew);
4110 4107
4111 private: 4108 private:
4112 RawInstance* const* InstanceAddr(intptr_t context_index) const { 4109 RawInstance* const* InstanceAddr(intptr_t context_index) const {
4113 ASSERT((context_index >= 0) && (context_index < num_variables())); 4110 ASSERT((context_index >= 0) && (context_index < num_variables()));
4114 return &raw_ptr()->data()[context_index]; 4111 return &raw_ptr()->data()[context_index];
4115 } 4112 }
4116 4113
4117 void set_isolate(Isolate* isolate) const {
4118 StoreNonPointer(&raw_ptr()->isolate_, isolate);
4119 }
4120
4121 void set_num_variables(intptr_t num_variables) const { 4114 void set_num_variables(intptr_t num_variables) const {
4122 StoreNonPointer(&raw_ptr()->num_variables_, num_variables); 4115 StoreNonPointer(&raw_ptr()->num_variables_, num_variables);
4123 } 4116 }
4124 4117
4125 FINAL_HEAP_OBJECT_IMPLEMENTATION(Context, Object); 4118 FINAL_HEAP_OBJECT_IMPLEMENTATION(Context, Object);
4126 friend class Class; 4119 friend class Class;
4127 }; 4120 };
4128 4121
4129 4122
4130 // The ContextScope class makes it possible to delay the compilation of a local 4123 // The ContextScope class makes it possible to delay the compilation of a local
(...skipping 3428 matching lines...) Expand 10 before | Expand all | Expand 10 after
7559 7552
7560 7553
7561 RawObject* MegamorphicCache::GetTargetFunction(const Array& array, 7554 RawObject* MegamorphicCache::GetTargetFunction(const Array& array,
7562 intptr_t index) { 7555 intptr_t index) {
7563 return array.At((index * kEntryLength) + kTargetFunctionIndex); 7556 return array.At((index * kEntryLength) + kTargetFunctionIndex);
7564 } 7557 }
7565 7558
7566 } // namespace dart 7559 } // namespace dart
7567 7560
7568 #endif // VM_OBJECT_H_ 7561 #endif // VM_OBJECT_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698