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

Side by Side Diff: src/virtual-frame.h

Issue 57052: * String type inference using compiler framework. (Closed)
Patch Set: Changes relative to head of bleeding edge (don't do diff with earlier versions) Created 11 years, 8 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 | « src/variables.cc ('k') | src/virtual-frame.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 2008 the V8 project authors. All rights reserved. 1 // Copyright 2008 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 29 matching lines...) Expand all
40 // * Invalid: elements that are uninitialized or not actually part 40 // * Invalid: elements that are uninitialized or not actually part
41 // of the virtual frame. They should not be read. 41 // of the virtual frame. They should not be read.
42 // * Memory: an element that resides in the actual frame. Its address is 42 // * Memory: an element that resides in the actual frame. Its address is
43 // given by its position in the virtual frame. 43 // given by its position in the virtual frame.
44 // * Register: an element that resides in a register. 44 // * Register: an element that resides in a register.
45 // * Constant: an element whose value is known at compile time. 45 // * Constant: an element whose value is known at compile time.
46 46
47 class FrameElement BASE_EMBEDDED { 47 class FrameElement BASE_EMBEDDED {
48 public: 48 public:
49 enum SyncFlag { 49 enum SyncFlag {
50 SYNCED, 50 NOT_SYNCED,
51 NOT_SYNCED 51 SYNCED
52 }; 52 };
53 53
54 // The default constructor creates an invalid frame element. 54 // The default constructor creates an invalid frame element.
55 FrameElement() { 55 FrameElement()
56 Initialize(INVALID, no_reg, NOT_SYNCED); 56 : static_type_(), type_(INVALID), copied_(false), synced_(false) {
57 data_.reg_ = no_reg;
57 } 58 }
58 59
59 // Factory function to construct an invalid frame element. 60 // Factory function to construct an invalid frame element.
60 static FrameElement InvalidElement() { 61 static FrameElement InvalidElement() {
61 FrameElement result; 62 FrameElement result;
62 return result; 63 return result;
63 } 64 }
64 65
65 // Factory function to construct an in-memory frame element. 66 // Factory function to construct an in-memory frame element.
66 static FrameElement MemoryElement() { 67 static FrameElement MemoryElement() {
67 FrameElement result(MEMORY, no_reg, SYNCED); 68 FrameElement result(MEMORY, no_reg, SYNCED);
68 return result; 69 return result;
69 } 70 }
70 71
71 // Factory function to construct an in-register frame element. 72 // Factory function to construct an in-register frame element.
72 static FrameElement RegisterElement(Register reg, SyncFlag is_synced) { 73 static FrameElement RegisterElement(Register reg,
73 FrameElement result(REGISTER, reg, is_synced); 74 SyncFlag is_synced,
74 return result; 75 StaticType static_type = StaticType()) {
76 return FrameElement(REGISTER, reg, is_synced, static_type);
75 } 77 }
76 78
77 // Factory function to construct a frame element whose value is known at 79 // Factory function to construct a frame element whose value is known at
78 // compile time. 80 // compile time.
79 static FrameElement ConstantElement(Handle<Object> value, 81 static FrameElement ConstantElement(Handle<Object> value,
80 SyncFlag is_synced) { 82 SyncFlag is_synced) {
81 FrameElement result(value, is_synced); 83 FrameElement result(value, is_synced);
82 return result; 84 return result;
83 } 85 }
84 86
85 bool is_synced() const { return SyncField::decode(type_) == SYNCED; } 87 bool is_synced() const { return synced_; }
86 88
87 void set_sync() { 89 void set_sync() {
88 ASSERT(type() != MEMORY); 90 ASSERT(type() != MEMORY);
89 type_ = (type_ & ~SyncField::mask()) | SyncField::encode(SYNCED); 91 synced_ = true;
90 } 92 }
91 93
92 void clear_sync() { 94 void clear_sync() {
93 ASSERT(type() != MEMORY); 95 ASSERT(type() != MEMORY);
94 type_ = (type_ & ~SyncField::mask()) | SyncField::encode(NOT_SYNCED); 96 synced_ = false;
95 } 97 }
96 98
97 bool is_valid() const { return type() != INVALID; } 99 bool is_valid() const { return type() != INVALID; }
98 bool is_memory() const { return type() == MEMORY; } 100 bool is_memory() const { return type() == MEMORY; }
99 bool is_register() const { return type() == REGISTER; } 101 bool is_register() const { return type() == REGISTER; }
100 bool is_constant() const { return type() == CONSTANT; } 102 bool is_constant() const { return type() == CONSTANT; }
101 bool is_copy() const { return type() == COPY; } 103 bool is_copy() const { return type() == COPY; }
102 104
103 bool is_copied() const { return IsCopiedField::decode(type_); } 105 bool is_copied() const { return copied_; }
104 106 void set_copied() { copied_ = true; }
105 void set_copied() { 107 void clear_copied() { copied_ = false; }
106 type_ = (type_ & ~IsCopiedField::mask()) | IsCopiedField::encode(true);
107 }
108
109 void clear_copied() {
110 type_ = (type_ & ~IsCopiedField::mask()) | IsCopiedField::encode(false);
111 }
112 108
113 Register reg() const { 109 Register reg() const {
114 ASSERT(is_register()); 110 ASSERT(is_register());
115 return data_.reg_; 111 return data_.reg_;
116 } 112 }
117 113
118 Handle<Object> handle() const { 114 Handle<Object> handle() const {
119 ASSERT(is_constant()); 115 ASSERT(is_constant());
120 return Handle<Object>(data_.handle_); 116 return Handle<Object>(data_.handle_);
121 } 117 }
122 118
123 int index() const { 119 int index() const {
124 ASSERT(is_copy()); 120 ASSERT(is_copy());
125 return data_.index_; 121 return data_.index_;
126 } 122 }
127 123
128 bool Equals(FrameElement other); 124 bool Equals(FrameElement other);
129 125
126 StaticType static_type() { return static_type_; }
127
128 void set_static_type(StaticType static_type) {
129 // TODO(lrn): If it's s copy, it would be better to update the real one,
130 // but we can't from here. The caller must handle this.
131 static_type_ = static_type;
132 }
133
130 private: 134 private:
131 enum Type { 135 enum Type {
132 INVALID, 136 INVALID,
133 MEMORY, 137 MEMORY,
134 REGISTER, 138 REGISTER,
135 CONSTANT, 139 CONSTANT,
136 COPY 140 COPY
137 }; 141 };
138 142
139 // BitField is <type, shift, size>. 143 Type type() const { return static_cast<Type>(type_); }
140 class SyncField : public BitField<SyncFlag, 0, 1> {};
141 class IsCopiedField : public BitField<bool, 1, 1> {};
142 class TypeField : public BitField<Type, 2, 32 - 2> {};
143 144
144 Type type() const { return TypeField::decode(type_); } 145 StaticType static_type_;
145 146
146 // The element's type and a dirty bit. The dirty bit can be cleared 147 // The element's type.
148 byte type_;
149
150 bool copied_;
151
152 // The element's dirty-bit. The dirty bit can be cleared
147 // for non-memory elements to indicate that the element agrees with 153 // for non-memory elements to indicate that the element agrees with
148 // the value in memory in the actual frame. 154 // the value in memory in the actual frame.
149 int type_; 155 bool synced_;
150 156
151 union { 157 union {
152 Register reg_; 158 Register reg_;
153 Object** handle_; 159 Object** handle_;
154 int index_; 160 int index_;
155 } data_; 161 } data_;
156 162
157 // Used to construct memory and register elements. 163 // Used to construct memory and register elements.
158 FrameElement(Type type, Register reg, SyncFlag is_synced) { 164 FrameElement(Type type, Register reg, SyncFlag is_synced)
159 Initialize(type, reg, is_synced); 165 : static_type_(),
166 type_(type),
167 copied_(false),
168 synced_(is_synced != NOT_SYNCED) {
169 data_.reg_ = reg;
170 }
171
172 FrameElement(Type type, Register reg, SyncFlag is_synced, StaticType stype)
173 : static_type_(stype),
174 type_(type),
175 copied_(false),
176 synced_(is_synced != NOT_SYNCED) {
177 data_.reg_ = reg;
160 } 178 }
161 179
162 // Used to construct constant elements. 180 // Used to construct constant elements.
163 inline FrameElement(Handle<Object> value, SyncFlag is_synced); 181 FrameElement(Handle<Object> value, SyncFlag is_synced)
164 182 : static_type_(StaticType::TypeOf(*value)),
165 // Used to initialize invalid, memory, and register elements. 183 type_(CONSTANT),
166 inline void Initialize(Type type, Register reg, SyncFlag is_synced); 184 copied_(false),
185 synced_(is_synced != NOT_SYNCED) {
186 data_.handle_ = value.location();
187 }
167 188
168 void set_index(int new_index) { 189 void set_index(int new_index) {
169 ASSERT(is_copy()); 190 ASSERT(is_copy());
170 data_.index_ = new_index; 191 data_.index_ = new_index;
171 } 192 }
172 193
173 friend class VirtualFrame; 194 friend class VirtualFrame;
174 }; 195 };
175 196
176 197
177 } } // namespace v8::internal 198 } } // namespace v8::internal
178 199
179 #ifdef ARM 200 #ifdef ARM
180 #include "virtual-frame-arm.h" 201 #include "virtual-frame-arm.h"
181 #else // ia32 202 #else // ia32
182 #include "virtual-frame-ia32.h" 203 #include "virtual-frame-ia32.h"
183 #endif 204 #endif
184 205
185
186 namespace v8 { namespace internal {
187
188 FrameElement::FrameElement(Handle<Object> value, SyncFlag is_synced) {
189 type_ = TypeField::encode(CONSTANT)
190 | IsCopiedField::encode(false)
191 | SyncField::encode(is_synced);
192 data_.handle_ = value.location();
193 }
194
195
196 void FrameElement::Initialize(Type type, Register reg, SyncFlag is_synced) {
197 type_ = TypeField::encode(type)
198 | IsCopiedField::encode(false)
199 | SyncField::encode(is_synced);
200 data_.reg_ = reg;
201 }
202
203
204 } } // namespace v8::internal
205
206 #endif // V8_VIRTUAL_FRAME_H_ 206 #endif // V8_VIRTUAL_FRAME_H_
OLDNEW
« no previous file with comments | « src/variables.cc ('k') | src/virtual-frame.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698