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

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

Issue 1192103004: VM: New calling convention for generated code. (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
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 2107 matching lines...) Expand 10 before | Expand all | Expand 10 after
2118 void AttachCode(const Code& value) const; 2118 void AttachCode(const Code& value) const;
2119 void SetInstructions(const Code& value) const; 2119 void SetInstructions(const Code& value) const;
2120 void ClearCode() const; 2120 void ClearCode() const;
2121 2121
2122 // Disables optimized code and switches to unoptimized code. 2122 // Disables optimized code and switches to unoptimized code.
2123 void SwitchToUnoptimizedCode() const; 2123 void SwitchToUnoptimizedCode() const;
2124 2124
2125 // Return the most recently compiled and installed code for this function. 2125 // Return the most recently compiled and installed code for this function.
2126 // It is not the only Code object that points to this function. 2126 // It is not the only Code object that points to this function.
2127 RawCode* CurrentCode() const { 2127 RawCode* CurrentCode() const {
2128 return raw_ptr()->instructions_->ptr()->code_; 2128 return raw_ptr()->code_;
2129 } 2129 }
2130 2130
2131 RawCode* unoptimized_code() const { return raw_ptr()->unoptimized_code_; } 2131 RawCode* unoptimized_code() const { return raw_ptr()->unoptimized_code_; }
2132 void set_unoptimized_code(const Code& value) const; 2132 void set_unoptimized_code(const Code& value) const;
2133 bool HasCode() const; 2133 bool HasCode() const;
2134 2134
2135 static intptr_t instructions_offset() { 2135
2136 return OFFSET_OF(RawFunction, instructions_); 2136 static intptr_t code_offset() {
2137 return OFFSET_OF(RawFunction, code_);
2137 } 2138 }
2138 2139
2139 // Returns true if there is at least one debugger breakpoint 2140 // Returns true if there is at least one debugger breakpoint
2140 // set in this function. 2141 // set in this function.
2141 bool HasBreakpoint() const; 2142 bool HasBreakpoint() const;
2142 2143
2143 RawContextScope* context_scope() const; 2144 RawContextScope* context_scope() const;
2144 void set_context_scope(const ContextScope& value) const; 2145 void set_context_scope(const ContextScope& value) const;
2145 2146
2146 // Enclosing function of this local function. 2147 // Enclosing function of this local function.
(...skipping 1453 matching lines...) Expand 10 before | Expand all | Expand 10 after
3600 FINAL_HEAP_OBJECT_IMPLEMENTATION(ObjectPool, Object); 3601 FINAL_HEAP_OBJECT_IMPLEMENTATION(ObjectPool, Object);
3601 friend class Class; 3602 friend class Class;
3602 friend class Object; 3603 friend class Object;
3603 friend class RawObjectPool; 3604 friend class RawObjectPool;
3604 }; 3605 };
3605 3606
3606 3607
3607 class Instructions : public Object { 3608 class Instructions : public Object {
3608 public: 3609 public:
3609 intptr_t size() const { return raw_ptr()->size_; } // Excludes HeaderSize(). 3610 intptr_t size() const { return raw_ptr()->size_; } // Excludes HeaderSize().
3610 RawCode* code() const { return raw_ptr()->code_; }
3611 static intptr_t code_offset() {
3612 return OFFSET_OF(RawInstructions, code_);
3613 }
3614 RawObjectPool* object_pool() const { return raw_ptr()->object_pool_; }
3615 static intptr_t object_pool_offset() {
3616 return OFFSET_OF(RawInstructions, object_pool_);
3617 }
3618 3611
3619 uword EntryPoint() const { 3612 uword EntryPoint() const {
3620 return reinterpret_cast<uword>(raw_ptr()) + HeaderSize(); 3613 return reinterpret_cast<uword>(raw_ptr()) + HeaderSize();
3621 } 3614 }
3622 3615
3623 static const intptr_t kMaxElements = (kMaxInt32 - 3616 static const intptr_t kMaxElements = (kMaxInt32 -
3624 (sizeof(RawInstructions) + 3617 (sizeof(RawInstructions) +
3625 sizeof(RawObject) + 3618 sizeof(RawObject) +
3626 (2 * OS::kMaxPreferredCodeAlignment))); 3619 (2 * OS::kMaxPreferredCodeAlignment)));
3627 3620
(...skipping 18 matching lines...) Expand all
3646 3639
3647 static RawInstructions* FromEntryPoint(uword entry_point) { 3640 static RawInstructions* FromEntryPoint(uword entry_point) {
3648 return reinterpret_cast<RawInstructions*>( 3641 return reinterpret_cast<RawInstructions*>(
3649 entry_point - HeaderSize() + kHeapObjectTag); 3642 entry_point - HeaderSize() + kHeapObjectTag);
3650 } 3643 }
3651 3644
3652 private: 3645 private:
3653 void set_size(intptr_t size) const { 3646 void set_size(intptr_t size) const {
3654 StoreNonPointer(&raw_ptr()->size_, size); 3647 StoreNonPointer(&raw_ptr()->size_, size);
3655 } 3648 }
3656 void set_code(RawCode* code) const {
3657 StorePointer(&raw_ptr()->code_, code);
3658 }
3659 void set_object_pool(RawObjectPool* object_pool) const {
3660 StorePointer(&raw_ptr()->object_pool_, object_pool);
3661 }
3662 3649
3663 // New is a private method as RawInstruction and RawCode objects should 3650 // New is a private method as RawInstruction and RawCode objects should
3664 // only be created using the Code::FinalizeCode method. This method creates 3651 // only be created using the Code::FinalizeCode method. This method creates
3665 // the RawInstruction and RawCode objects, sets up the pointer offsets 3652 // the RawInstruction and RawCode objects, sets up the pointer offsets
3666 // and links the two in a GC safe manner. 3653 // and links the two in a GC safe manner.
3667 static RawInstructions* New(intptr_t size); 3654 static RawInstructions* New(intptr_t size);
3668 3655
3669 FINAL_HEAP_OBJECT_IMPLEMENTATION(Instructions, Object); 3656 FINAL_HEAP_OBJECT_IMPLEMENTATION(Instructions, Object);
3670 friend class Class; 3657 friend class Class;
3671 friend class Code; 3658 friend class Code;
(...skipping 308 matching lines...) Expand 10 before | Expand all | Expand 10 after
3980 intptr_t length); 3967 intptr_t length);
3981 }; 3968 };
3982 3969
3983 3970
3984 class Code : public Object { 3971 class Code : public Object {
3985 public: 3972 public:
3986 RawInstructions* instructions() const { return raw_ptr()->instructions_; } 3973 RawInstructions* instructions() const { return raw_ptr()->instructions_; }
3987 static intptr_t instructions_offset() { 3974 static intptr_t instructions_offset() {
3988 return OFFSET_OF(RawCode, instructions_); 3975 return OFFSET_OF(RawCode, instructions_);
3989 } 3976 }
3977
3978 RawObjectPool* object_pool() const { return raw_ptr()->object_pool_; }
3979 static intptr_t object_pool_offset() {
3980 return OFFSET_OF(RawCode, object_pool_);
3981 }
3982
3990 intptr_t pointer_offsets_length() const { 3983 intptr_t pointer_offsets_length() const {
3991 return PtrOffBits::decode(raw_ptr()->state_bits_); 3984 return PtrOffBits::decode(raw_ptr()->state_bits_);
3992 } 3985 }
3993 3986
3994 bool is_optimized() const { 3987 bool is_optimized() const {
3995 return OptimizedBit::decode(raw_ptr()->state_bits_); 3988 return OptimizedBit::decode(raw_ptr()->state_bits_);
3996 } 3989 }
3997 void set_is_optimized(bool value) const; 3990 void set_is_optimized(bool value) const;
3998 bool is_alive() const { 3991 bool is_alive() const {
3999 return AliveBit::decode(raw_ptr()->state_bits_); 3992 return AliveBit::decode(raw_ptr()->state_bits_);
4000 } 3993 }
4001 void set_is_alive(bool value) const; 3994 void set_is_alive(bool value) const;
4002 3995
4003 uword EntryPoint() const { 3996 uword EntryPoint() const {
4004 const Instructions& instr = Instructions::Handle(instructions()); 3997 const Instructions& instr = Instructions::Handle(instructions());
4005 return instr.EntryPoint(); 3998 return instr.EntryPoint();
4006 } 3999 }
4007 intptr_t Size() const { 4000 intptr_t Size() const {
4008 const Instructions& instr = Instructions::Handle(instructions()); 4001 const Instructions& instr = Instructions::Handle(instructions());
4009 return instr.size(); 4002 return instr.size();
4010 } 4003 }
4011 RawObjectPool* GetObjectPool() const { 4004 RawObjectPool* GetObjectPool() const {
4012 const Instructions& instr = Instructions::Handle(instructions()); 4005 return object_pool();
4013 return instr.object_pool();
4014 } 4006 }
4015 bool ContainsInstructionAt(uword addr) const { 4007 bool ContainsInstructionAt(uword addr) const {
4016 const Instructions& instr = Instructions::Handle(instructions()); 4008 const Instructions& instr = Instructions::Handle(instructions());
4017 const uword offset = addr - instr.EntryPoint(); 4009 const uword offset = addr - instr.EntryPoint();
4018 return offset < static_cast<uword>(instr.size()); 4010 return offset < static_cast<uword>(instr.size());
4019 } 4011 }
4020 4012
4021 // Returns true if there is a debugger breakpoint set in this code object. 4013 // Returns true if there is a debugger breakpoint set in this code object.
4022 bool HasBreakpoint() const; 4014 bool HasBreakpoint() const;
4023 4015
(...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after
4243 StoreNonPointer(&raw_ptr()->lazy_deopt_pc_offset_, pc); 4235 StoreNonPointer(&raw_ptr()->lazy_deopt_pc_offset_, pc);
4244 } 4236 }
4245 4237
4246 bool IsAllocationStubCode() const; 4238 bool IsAllocationStubCode() const;
4247 bool IsStubCode() const; 4239 bool IsStubCode() const;
4248 bool IsFunctionCode() const; 4240 bool IsFunctionCode() const;
4249 4241
4250 private: 4242 private:
4251 void set_state_bits(intptr_t bits) const; 4243 void set_state_bits(intptr_t bits) const;
4252 4244
4245 void set_object_pool(RawObjectPool* object_pool) const {
4246 StorePointer(&raw_ptr()->object_pool_, object_pool);
4247 }
4248
4253 friend class RawObject; // For RawObject::SizeFromClass(). 4249 friend class RawObject; // For RawObject::SizeFromClass().
4254 friend class RawCode; 4250 friend class RawCode;
4255 enum { 4251 enum {
4256 kOptimizedBit = 0, 4252 kOptimizedBit = 0,
4257 kAliveBit = 1, 4253 kAliveBit = 1,
4258 kPtrOffBit = 2, 4254 kPtrOffBit = 2,
4259 kPtrOffSize = 30, 4255 kPtrOffSize = 30,
4260 }; 4256 };
4261 4257
4262 class OptimizedBit : public BitField<bool, kOptimizedBit, 1> {}; 4258 class OptimizedBit : public BitField<bool, kOptimizedBit, 1> {};
4263 class AliveBit : public BitField<bool, kAliveBit, 1> {}; 4259 class AliveBit : public BitField<bool, kAliveBit, 1> {};
4264 class PtrOffBits : public BitField<intptr_t, kPtrOffBit, kPtrOffSize> {}; 4260 class PtrOffBits : public BitField<intptr_t, kPtrOffBit, kPtrOffSize> {};
4265 4261
4266 // An object finder visitor interface. 4262 // An object finder visitor interface.
4267 class FindRawCodeVisitor : public FindObjectVisitor { 4263 class FindRawCodeVisitor : public FindObjectVisitor {
4268 public: 4264 public:
4269 explicit FindRawCodeVisitor(uword pc) 4265 explicit FindRawCodeVisitor(uword pc)
4270 : FindObjectVisitor(Isolate::Current()), pc_(pc) { } 4266 : FindObjectVisitor(Isolate::Current()), pc_(pc) { }
4271 virtual ~FindRawCodeVisitor() { } 4267 virtual ~FindRawCodeVisitor() { }
4272 4268
4273 virtual uword filter_addr() const { return pc_; }
4274
4275 // Check if object matches find condition. 4269 // Check if object matches find condition.
4276 virtual bool FindObject(RawObject* obj) const; 4270 virtual bool FindObject(RawObject* obj) const;
4277 4271
4278 private: 4272 private:
4279 const uword pc_; 4273 const uword pc_;
4280 4274
4281 DISALLOW_COPY_AND_ASSIGN(FindRawCodeVisitor); 4275 DISALLOW_COPY_AND_ASSIGN(FindRawCodeVisitor);
4282 }; 4276 };
4283 4277
4284 static const intptr_t kEntrySize = sizeof(int32_t); // NOLINT 4278 static const intptr_t kEntrySize = sizeof(int32_t); // NOLINT
(...skipping 3683 matching lines...) Expand 10 before | Expand all | Expand 10 after
7968 7962
7969 7963
7970 RawObject* MegamorphicCache::GetTargetFunction(const Array& array, 7964 RawObject* MegamorphicCache::GetTargetFunction(const Array& array,
7971 intptr_t index) { 7965 intptr_t index) {
7972 return array.At((index * kEntryLength) + kTargetFunctionIndex); 7966 return array.At((index * kEntryLength) + kTargetFunctionIndex);
7973 } 7967 }
7974 7968
7975 } // namespace dart 7969 } // namespace dart
7976 7970
7977 #endif // VM_OBJECT_H_ 7971 #endif // VM_OBJECT_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698