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

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

Issue 2226893002: Optimize AOT's switchable calls for the monomorphic case. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: sync Created 4 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/instructions_mips_test.cc ('k') | runtime/vm/object.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 #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 3942 matching lines...) Expand 10 before | Expand all | Expand 10 after
3953 friend class Class; 3953 friend class Class;
3954 friend class Object; 3954 friend class Object;
3955 friend class RawObjectPool; 3955 friend class RawObjectPool;
3956 }; 3956 };
3957 3957
3958 3958
3959 class Instructions : public Object { 3959 class Instructions : public Object {
3960 public: 3960 public:
3961 intptr_t size() const { return raw_ptr()->size_; } // Excludes HeaderSize(). 3961 intptr_t size() const { return raw_ptr()->size_; } // Excludes HeaderSize().
3962 3962
3963 uword EntryPoint() const { 3963 uword PayloadStart() const {
3964 return EntryPoint(raw()); 3964 return PayloadStart(raw());
3965 } 3965 }
3966 static uword EntryPoint(RawInstructions* instr) { 3966 uword UncheckedEntryPoint() const {
3967 return UncheckedEntryPoint(raw());
3968 }
3969 uword CheckedEntryPoint() const {
3970 return CheckedEntryPoint(raw());
3971 }
3972 static uword PayloadStart(RawInstructions* instr) {
3967 return reinterpret_cast<uword>(instr->ptr()) + HeaderSize(); 3973 return reinterpret_cast<uword>(instr->ptr()) + HeaderSize();
3968 } 3974 }
3969 3975
3976 #if defined(TARGET_ARCH_IA32)
3977 static const intptr_t kCheckedEntryOffset = 0;
3978 static const intptr_t kUncheckedEntryOffset = 0;
3979 #elif defined(TARGET_ARCH_X64)
3980 static const intptr_t kCheckedEntryOffset = 23;
3981 static const intptr_t kUncheckedEntryOffset = 44;
3982 #elif defined(TARGET_ARCH_ARM)
3983 static const intptr_t kCheckedEntryOffset = 3 * Instr::kInstrSize;
3984 static const intptr_t kUncheckedEntryOffset = 9 * Instr::kInstrSize;
3985 #elif defined(TARGET_ARCH_ARM64)
3986 static const intptr_t kCheckedEntryOffset = 6 * Instr::kInstrSize;
3987 static const intptr_t kUncheckedEntryOffset = 12 * Instr::kInstrSize;
3988 #elif defined(TARGET_ARCH_MIPS)
3989 static const intptr_t kCheckedEntryOffset = 4 * Instr::kInstrSize;
3990 static const intptr_t kUncheckedEntryOffset = 14 * Instr::kInstrSize;
3991 #elif defined(TARGET_ARCH_DBC)
3992 static const intptr_t kCheckedEntryOffset = 0;
3993 static const intptr_t kUncheckedEntryOffset = 0;
3994 #else
3995 #error Missing entry offsets for current architecture
3996 #endif
3997
3998 static uword UncheckedEntryPoint(RawInstructions* instr) {
3999 return PayloadStart(instr) + kUncheckedEntryOffset;
4000 }
4001 static uword CheckedEntryPoint(RawInstructions* instr) {
4002 return PayloadStart(instr) + kCheckedEntryOffset;
4003 }
4004
3970 static const intptr_t kMaxElements = (kMaxInt32 - 4005 static const intptr_t kMaxElements = (kMaxInt32 -
3971 (sizeof(RawInstructions) + 4006 (sizeof(RawInstructions) +
3972 sizeof(RawObject) + 4007 sizeof(RawObject) +
3973 (2 * OS::kMaxPreferredCodeAlignment))); 4008 (2 * OS::kMaxPreferredCodeAlignment)));
3974 4009
3975 static intptr_t InstanceSize() { 4010 static intptr_t InstanceSize() {
3976 ASSERT(sizeof(RawInstructions) == 4011 ASSERT(sizeof(RawInstructions) ==
3977 OFFSET_OF_RETURNED_VALUE(RawInstructions, data)); 4012 OFFSET_OF_RETURNED_VALUE(RawInstructions, data));
3978 return 0; 4013 return 0;
3979 } 4014 }
3980 4015
3981 static intptr_t InstanceSize(intptr_t size) { 4016 static intptr_t InstanceSize(intptr_t size) {
3982 intptr_t instructions_size = Utils::RoundUp(size, 4017 intptr_t instructions_size = Utils::RoundUp(size,
3983 OS::PreferredCodeAlignment()); 4018 OS::PreferredCodeAlignment());
3984 intptr_t result = instructions_size + HeaderSize(); 4019 intptr_t result = instructions_size + HeaderSize();
3985 ASSERT(result % OS::PreferredCodeAlignment() == 0); 4020 ASSERT(result % OS::PreferredCodeAlignment() == 0);
3986 return result; 4021 return result;
3987 } 4022 }
3988 4023
3989 static intptr_t HeaderSize() { 4024 static intptr_t HeaderSize() {
3990 intptr_t alignment = OS::PreferredCodeAlignment(); 4025 intptr_t alignment = OS::PreferredCodeAlignment();
3991 return Utils::RoundUp(sizeof(RawInstructions), alignment); 4026 return Utils::RoundUp(sizeof(RawInstructions), alignment);
3992 } 4027 }
3993 4028
3994 static RawInstructions* FromEntryPoint(uword entry_point) { 4029 static RawInstructions* FromUncheckedEntryPoint(uword entry_point) {
3995 return reinterpret_cast<RawInstructions*>( 4030 return reinterpret_cast<RawInstructions*>(
3996 entry_point - HeaderSize() + kHeapObjectTag); 4031 entry_point - HeaderSize() - kUncheckedEntryOffset + kHeapObjectTag);
3997 } 4032 }
3998 4033
3999 bool Equals(const Instructions& other) const { 4034 bool Equals(const Instructions& other) const {
4000 if (size() != other.size()) { 4035 if (size() != other.size()) {
4001 return false; 4036 return false;
4002 } 4037 }
4003 NoSafepointScope no_safepoint; 4038 NoSafepointScope no_safepoint;
4004 return memcmp(raw_ptr(), other.raw_ptr(), InstanceSize(size())) == 0; 4039 return memcmp(raw_ptr(), other.raw_ptr(), InstanceSize(size())) == 0;
4005 } 4040 }
4006 4041
(...skipping 431 matching lines...) Expand 10 before | Expand all | Expand 10 after
4438 4473
4439 RawInstructions* instructions() const { return raw_ptr()->instructions_; } 4474 RawInstructions* instructions() const { return raw_ptr()->instructions_; }
4440 4475
4441 static intptr_t saved_instructions_offset() { 4476 static intptr_t saved_instructions_offset() {
4442 return OFFSET_OF(RawCode, instructions_); 4477 return OFFSET_OF(RawCode, instructions_);
4443 } 4478 }
4444 4479
4445 static intptr_t entry_point_offset() { 4480 static intptr_t entry_point_offset() {
4446 return OFFSET_OF(RawCode, entry_point_); 4481 return OFFSET_OF(RawCode, entry_point_);
4447 } 4482 }
4483 static intptr_t checked_entry_point_offset() {
4484 return OFFSET_OF(RawCode, checked_entry_point_);
4485 }
4448 4486
4449 RawObjectPool* object_pool() const { return raw_ptr()->object_pool_; } 4487 RawObjectPool* object_pool() const { return raw_ptr()->object_pool_; }
4450 static intptr_t object_pool_offset() { 4488 static intptr_t object_pool_offset() {
4451 return OFFSET_OF(RawCode, object_pool_); 4489 return OFFSET_OF(RawCode, object_pool_);
4452 } 4490 }
4453 4491
4454 intptr_t pointer_offsets_length() const { 4492 intptr_t pointer_offsets_length() const {
4455 return PtrOffBits::decode(raw_ptr()->state_bits_); 4493 return PtrOffBits::decode(raw_ptr()->state_bits_);
4456 } 4494 }
4457 4495
4458 bool is_optimized() const { 4496 bool is_optimized() const {
4459 return OptimizedBit::decode(raw_ptr()->state_bits_); 4497 return OptimizedBit::decode(raw_ptr()->state_bits_);
4460 } 4498 }
4461 void set_is_optimized(bool value) const; 4499 void set_is_optimized(bool value) const;
4462 bool is_alive() const { 4500 bool is_alive() const {
4463 return AliveBit::decode(raw_ptr()->state_bits_); 4501 return AliveBit::decode(raw_ptr()->state_bits_);
4464 } 4502 }
4465 void set_is_alive(bool value) const; 4503 void set_is_alive(bool value) const;
4466 4504
4467 uword EntryPoint() const { 4505 uword PayloadStart() const {
4468 return Instructions::Handle(instructions()).EntryPoint(); 4506 return Instructions::PayloadStart(instructions());
4507 }
4508 uword UncheckedEntryPoint() const {
4509 return Instructions::UncheckedEntryPoint(instructions());
4510 }
4511 uword CheckedEntryPoint() const {
4512 return Instructions::CheckedEntryPoint(instructions());
4469 } 4513 }
4470 intptr_t Size() const { 4514 intptr_t Size() const {
4471 const Instructions& instr = Instructions::Handle(instructions()); 4515 const Instructions& instr = Instructions::Handle(instructions());
4472 return instr.size(); 4516 return instr.size();
4473 } 4517 }
4474 RawObjectPool* GetObjectPool() const { 4518 RawObjectPool* GetObjectPool() const {
4475 return object_pool(); 4519 return object_pool();
4476 } 4520 }
4477 bool ContainsInstructionAt(uword addr) const { 4521 bool ContainsInstructionAt(uword addr) const {
4478 const Instructions& instr = Instructions::Handle(instructions()); 4522 const Instructions& instr = Instructions::Handle(instructions());
4479 const uword offset = addr - instr.EntryPoint(); 4523 const uword offset = addr - instr.PayloadStart();
4480 return offset < static_cast<uword>(instr.size()); 4524 return offset < static_cast<uword>(instr.size());
4481 } 4525 }
4482 4526
4483 // Returns true if there is a debugger breakpoint set in this code object. 4527 // Returns true if there is a debugger breakpoint set in this code object.
4484 bool HasBreakpoint() const; 4528 bool HasBreakpoint() const;
4485 4529
4486 RawPcDescriptors* pc_descriptors() const { 4530 RawPcDescriptors* pc_descriptors() const {
4487 return raw_ptr()->pc_descriptors_; 4531 return raw_ptr()->pc_descriptors_;
4488 } 4532 }
4489 void set_pc_descriptors(const PcDescriptors& descriptors) const { 4533 void set_pc_descriptors(const PcDescriptors& descriptors) const {
(...skipping 4244 matching lines...) Expand 10 before | Expand all | Expand 10 after
8734 8778
8735 inline void TypeArguments::SetHash(intptr_t value) const { 8779 inline void TypeArguments::SetHash(intptr_t value) const {
8736 // This is only safe because we create a new Smi, which does not cause 8780 // This is only safe because we create a new Smi, which does not cause
8737 // heap allocation. 8781 // heap allocation.
8738 StoreSmi(&raw_ptr()->hash_, Smi::New(value)); 8782 StoreSmi(&raw_ptr()->hash_, Smi::New(value));
8739 } 8783 }
8740 8784
8741 } // namespace dart 8785 } // namespace dart
8742 8786
8743 #endif // VM_OBJECT_H_ 8787 #endif // VM_OBJECT_H_
OLDNEW
« no previous file with comments | « runtime/vm/instructions_mips_test.cc ('k') | runtime/vm/object.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698