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

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

Issue 12260026: Add support for object pool (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 10 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
« no previous file with comments | « runtime/vm/instructions_ia32_test.cc ('k') | runtime/vm/instructions_mips.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) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, 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 // Classes that describe assembly patterns as used by inline caches. 4 // Classes that describe assembly patterns as used by inline caches.
5 5
6 #ifndef VM_INSTRUCTIONS_MIPS_H_ 6 #ifndef VM_INSTRUCTIONS_MIPS_H_
7 #define VM_INSTRUCTIONS_MIPS_H_ 7 #define VM_INSTRUCTIONS_MIPS_H_
8 8
9 #ifndef VM_INSTRUCTIONS_H_ 9 #ifndef VM_INSTRUCTIONS_H_
10 #error Do not include instructions_mips.h directly; use instructions.h instead. 10 #error Do not include instructions_mips.h directly; use instructions.h instead.
11 #endif 11 #endif
12 12
13 #include "vm/allocation.h" 13 #include "vm/allocation.h"
14 #include "vm/object.h"
14 15
15 namespace dart { 16 namespace dart {
16 17
17 // Forward declarations. 18 // Forward declarations.
18 class RawClass; 19 class RawClass;
19 class Immediate; 20 class Immediate;
20 class RawObject; 21 class RawObject;
21 22
22 // Abstract class for all instruction pattern classes. 23 // Abstract class for all instruction pattern classes.
23 class InstructionPattern : public ValueObject { 24 class InstructionPattern : public ValueObject {
24 public: 25 public:
25 explicit InstructionPattern(uword pc) : start_(pc) { 26 explicit InstructionPattern(uword pc) : end_(pc) {
26 ASSERT(pc != 0); 27 ASSERT(pc != 0);
27 } 28 }
28 virtual ~InstructionPattern() {} 29 virtual ~InstructionPattern() { }
29 30
30 // Call to check if the instruction pattern at 'pc' match the instruction. 31 // Check if the instruction ending at 'end_' matches the expected pattern.
31 virtual bool IsValid() const { 32 virtual bool IsValid() const {
32 return TestBytesWith(pattern(), pattern_length_in_bytes()); 33 return TestBytesWith(pattern(), pattern_length_in_bytes());
33 } 34 }
34 35
35 // 'pattern' returns the expected byte pattern in form of an integer array 36 // 'pattern' returns the expected byte pattern in form of an integer array
36 // with length of 'pattern_length_in_bytes'. A '-1' element means 'any byte'. 37 // with length of 'pattern_length_in_bytes'. A '-1' element means 'any byte'.
37 virtual const int* pattern() const = 0; 38 virtual const int* pattern() const = 0;
38 virtual int pattern_length_in_bytes() const = 0; 39 virtual int pattern_length_in_bytes() const = 0;
39 40
40 protected: 41 protected:
41 uword start() const { return start_; } 42 uword end() const { return end_; }
42 43
43 private: 44 private:
44 // Returns true if the 'num_bytes' bytes at 'start_' correspond to 45 // Returns true if the 'num_bytes' bytes at 'num_bytes' before 'end_'
45 // array of integers 'data'. 'data' elements are either a byte or -1, which 46 // correspond to array of integers 'data'. 'data' elements are either a byte
46 // represents any byte. 47 // or -1, which represents any byte.
47 bool TestBytesWith(const int* data, int num_bytes) const; 48 bool TestBytesWith(const int* data, int num_bytes) const;
48 49
49 const uword start_; 50 const uword end_;
50 51
51 DISALLOW_COPY_AND_ASSIGN(InstructionPattern); 52 DISALLOW_COPY_AND_ASSIGN(InstructionPattern);
52 }; 53 };
53 54
54 55
55 class CallOrJumpPattern : public InstructionPattern { 56 class CallPattern : public InstructionPattern {
56 public: 57 public:
58 CallPattern(uword pc, const Code& code)
59 : InstructionPattern(pc), code_(code) { }
60
61 static const int kLengthInBytes = 1*kWordSize;
62
57 virtual int pattern_length_in_bytes() const { 63 virtual int pattern_length_in_bytes() const {
58 return kLengthInBytes; 64 return kLengthInBytes;
59 } 65 }
60 uword TargetAddress() const; 66 uword TargetAddress() const;
61 void SetTargetAddress(uword new_target) const; 67 void SetTargetAddress(uword new_target) const;
62 68
63 protected:
64 explicit CallOrJumpPattern(uword pc) : InstructionPattern(pc) {}
65 static const int kLengthInBytes = 0;
66
67 private:
68 DISALLOW_COPY_AND_ASSIGN(CallOrJumpPattern);
69 };
70
71
72 class CallPattern : public CallOrJumpPattern {
73 public:
74 explicit CallPattern(uword pc) : CallOrJumpPattern(pc) {}
75 static int InstructionLength() {
76 return kLengthInBytes;
77 }
78
79 private: 69 private:
80 virtual const int* pattern() const; 70 virtual const int* pattern() const;
81 71
72 const Code& code_;
73
82 DISALLOW_COPY_AND_ASSIGN(CallPattern); 74 DISALLOW_COPY_AND_ASSIGN(CallPattern);
83 }; 75 };
84 76
85 77
86 class JumpPattern : public CallOrJumpPattern { 78 class JumpPattern : public InstructionPattern {
87 public: 79 public:
88 explicit JumpPattern(uword pc) : CallOrJumpPattern(pc) {} 80 explicit JumpPattern(uword pc) : InstructionPattern(pc) { }
81
82 static const int kLengthInBytes = 3*kWordSize;
83
84 virtual int pattern_length_in_bytes() const {
85 return kLengthInBytes;
86 }
87 uword TargetAddress() const;
88 void SetTargetAddress(uword new_target) const;
89 89
90 private: 90 private:
91 virtual const int* pattern() const; 91 virtual const int* pattern() const;
92 92
93 DISALLOW_COPY_AND_ASSIGN(JumpPattern); 93 DISALLOW_COPY_AND_ASSIGN(JumpPattern);
94 }; 94 };
95 95
96 } // namespace dart 96 } // namespace dart
97 97
98 #endif // VM_INSTRUCTIONS_MIPS_H_ 98 #endif // VM_INSTRUCTIONS_MIPS_H_
99 99
OLDNEW
« no previous file with comments | « runtime/vm/instructions_ia32_test.cc ('k') | runtime/vm/instructions_mips.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698