OLD | NEW |
1 // Copyright 2015 the V8 project authors. All rights reserved. | 1 // Copyright 2015 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "src/interpreter/bytecode-array-builder.h" | 5 #include "src/interpreter/bytecode-array-builder.h" |
6 | 6 |
7 namespace v8 { | 7 namespace v8 { |
8 namespace internal { | 8 namespace internal { |
9 namespace interpreter { | 9 namespace interpreter { |
10 | 10 |
(...skipping 19 matching lines...) Expand all Loading... |
30 | 30 |
31 | 31 |
32 void BytecodeArrayBuilder::set_parameter_count(int number_of_parameters) { | 32 void BytecodeArrayBuilder::set_parameter_count(int number_of_parameters) { |
33 parameter_count_ = number_of_parameters; | 33 parameter_count_ = number_of_parameters; |
34 } | 34 } |
35 | 35 |
36 | 36 |
37 int BytecodeArrayBuilder::parameter_count() const { return parameter_count_; } | 37 int BytecodeArrayBuilder::parameter_count() const { return parameter_count_; } |
38 | 38 |
39 | 39 |
| 40 bool BytecodeArrayBuilder::HasExplicitReturn() { |
| 41 // TODO(rmcilroy): When we have control flow we should return false here if |
| 42 // there is an outstanding jump target, even if the last bytecode is kReturn. |
| 43 return !bytecodes_.empty() && |
| 44 bytecodes_.back() == Bytecodes::ToByte(Bytecode::kReturn); |
| 45 } |
| 46 |
| 47 |
40 Register BytecodeArrayBuilder::Parameter(int parameter_index) { | 48 Register BytecodeArrayBuilder::Parameter(int parameter_index) { |
41 DCHECK_GE(parameter_index, 0); | 49 DCHECK_GE(parameter_index, 0); |
42 DCHECK_LT(parameter_index, parameter_count_); | 50 DCHECK_LT(parameter_index, parameter_count_); |
43 return Register::FromParameterIndex(parameter_index, parameter_count_); | 51 return Register::FromParameterIndex(parameter_index, parameter_count_); |
44 } | 52 } |
45 | 53 |
46 | 54 |
47 Handle<BytecodeArray> BytecodeArrayBuilder::ToBytecodeArray() { | 55 Handle<BytecodeArray> BytecodeArrayBuilder::ToBytecodeArray() { |
48 DCHECK_EQ(bytecode_generated_, false); | 56 DCHECK_EQ(bytecode_generated_, false); |
49 DCHECK_GE(parameter_count_, 0); | 57 DCHECK_GE(parameter_count_, 0); |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
139 | 147 |
140 BytecodeArrayBuilder& BytecodeArrayBuilder::StoreAccumulatorInRegister( | 148 BytecodeArrayBuilder& BytecodeArrayBuilder::StoreAccumulatorInRegister( |
141 Register reg) { | 149 Register reg) { |
142 Output(Bytecode::kStar, reg.ToOperand()); | 150 Output(Bytecode::kStar, reg.ToOperand()); |
143 return *this; | 151 return *this; |
144 } | 152 } |
145 | 153 |
146 | 154 |
147 BytecodeArrayBuilder& BytecodeArrayBuilder::LoadNamedProperty( | 155 BytecodeArrayBuilder& BytecodeArrayBuilder::LoadNamedProperty( |
148 Register object, int feedback_slot, LanguageMode language_mode) { | 156 Register object, int feedback_slot, LanguageMode language_mode) { |
149 if (is_strong(language_mode)) { | 157 if (!is_sloppy(language_mode)) { |
150 UNIMPLEMENTED(); | 158 UNIMPLEMENTED(); |
151 } | 159 } |
152 | 160 |
153 if (FitsInByteOperand(feedback_slot)) { | 161 if (FitsInByteOperand(feedback_slot)) { |
154 Output(Bytecode::kLoadIC, object.ToOperand(), | 162 Output(Bytecode::kLoadIC, object.ToOperand(), |
155 static_cast<uint8_t>(feedback_slot)); | 163 static_cast<uint8_t>(feedback_slot)); |
156 } else { | 164 } else { |
157 UNIMPLEMENTED(); | 165 UNIMPLEMENTED(); |
158 } | 166 } |
159 return *this; | 167 return *this; |
160 } | 168 } |
161 | 169 |
162 | 170 |
163 BytecodeArrayBuilder& BytecodeArrayBuilder::LoadKeyedProperty( | 171 BytecodeArrayBuilder& BytecodeArrayBuilder::LoadKeyedProperty( |
164 Register object, int feedback_slot, LanguageMode language_mode) { | 172 Register object, int feedback_slot, LanguageMode language_mode) { |
165 if (is_strong(language_mode)) { | 173 if (!is_sloppy(language_mode)) { |
166 UNIMPLEMENTED(); | 174 UNIMPLEMENTED(); |
167 } | 175 } |
168 | 176 |
169 if (FitsInByteOperand(feedback_slot)) { | 177 if (FitsInByteOperand(feedback_slot)) { |
170 Output(Bytecode::kKeyedLoadIC, object.ToOperand(), | 178 Output(Bytecode::kKeyedLoadIC, object.ToOperand(), |
171 static_cast<uint8_t>(feedback_slot)); | 179 static_cast<uint8_t>(feedback_slot)); |
172 } else { | 180 } else { |
173 UNIMPLEMENTED(); | 181 UNIMPLEMENTED(); |
174 } | 182 } |
175 return *this; | 183 return *this; |
176 } | 184 } |
177 | 185 |
178 | 186 |
| 187 BytecodeArrayBuilder& BytecodeArrayBuilder::StoreNamedProperty( |
| 188 Register object, Register name, int feedback_slot, |
| 189 LanguageMode language_mode) { |
| 190 if (!is_sloppy(language_mode)) { |
| 191 UNIMPLEMENTED(); |
| 192 } |
| 193 |
| 194 if (FitsInByteOperand(feedback_slot)) { |
| 195 Output(Bytecode::kStoreIC, object.ToOperand(), name.ToOperand(), |
| 196 static_cast<uint8_t>(feedback_slot)); |
| 197 } else { |
| 198 UNIMPLEMENTED(); |
| 199 } |
| 200 return *this; |
| 201 } |
| 202 |
| 203 |
| 204 BytecodeArrayBuilder& BytecodeArrayBuilder::StoreKeyedProperty( |
| 205 Register object, Register key, int feedback_slot, |
| 206 LanguageMode language_mode) { |
| 207 if (!is_sloppy(language_mode)) { |
| 208 UNIMPLEMENTED(); |
| 209 } |
| 210 |
| 211 if (FitsInByteOperand(feedback_slot)) { |
| 212 Output(Bytecode::kKeyedStoreIC, object.ToOperand(), key.ToOperand(), |
| 213 static_cast<uint8_t>(feedback_slot)); |
| 214 } else { |
| 215 UNIMPLEMENTED(); |
| 216 } |
| 217 return *this; |
| 218 } |
| 219 |
| 220 |
179 BytecodeArrayBuilder& BytecodeArrayBuilder::Return() { | 221 BytecodeArrayBuilder& BytecodeArrayBuilder::Return() { |
180 Output(Bytecode::kReturn); | 222 Output(Bytecode::kReturn); |
181 return *this; | 223 return *this; |
182 } | 224 } |
183 | 225 |
184 | 226 |
185 size_t BytecodeArrayBuilder::GetConstantPoolEntry(Handle<Object> object) { | 227 size_t BytecodeArrayBuilder::GetConstantPoolEntry(Handle<Object> object) { |
186 // These constants shouldn't be added to the constant pool, the should use | 228 // These constants shouldn't be added to the constant pool, the should use |
187 // specialzed bytecodes instead. | 229 // specialzed bytecodes instead. |
188 DCHECK(!object.is_identical_to(isolate_->factory()->undefined_value())); | 230 DCHECK(!object.is_identical_to(isolate_->factory()->undefined_value())); |
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
326 | 368 |
327 Register TemporaryRegisterScope::NewRegister() { | 369 Register TemporaryRegisterScope::NewRegister() { |
328 count_++; | 370 count_++; |
329 last_register_index_ = builder_->BorrowTemporaryRegister(); | 371 last_register_index_ = builder_->BorrowTemporaryRegister(); |
330 return Register(last_register_index_); | 372 return Register(last_register_index_); |
331 } | 373 } |
332 | 374 |
333 } // namespace interpreter | 375 } // namespace interpreter |
334 } // namespace internal | 376 } // namespace internal |
335 } // namespace v8 | 377 } // namespace v8 |
OLD | NEW |