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 #include "src/compiler.h" | 7 #include "src/compiler.h" |
8 #include "src/interpreter/bytecode-array-writer.h" | 8 #include "src/interpreter/bytecode-array-writer.h" |
9 #include "src/interpreter/bytecode-peephole-optimizer.h" | 9 #include "src/interpreter/bytecode-peephole-optimizer.h" |
10 #include "src/interpreter/interpreter-intrinsics.h" | 10 #include "src/interpreter/interpreter-intrinsics.h" |
(...skipping 345 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
356 OutputScaled(bytecode, operand_scale, UnsignedOperand(name_index)); | 356 OutputScaled(bytecode, operand_scale, UnsignedOperand(name_index)); |
357 return *this; | 357 return *this; |
358 } | 358 } |
359 | 359 |
360 BytecodeArrayBuilder& BytecodeArrayBuilder::LoadNamedProperty( | 360 BytecodeArrayBuilder& BytecodeArrayBuilder::LoadNamedProperty( |
361 Register object, const Handle<Name> name, int feedback_slot) { | 361 Register object, const Handle<Name> name, int feedback_slot) { |
362 size_t name_index = GetConstantPoolEntry(name); | 362 size_t name_index = GetConstantPoolEntry(name); |
363 OperandScale operand_scale = Bytecodes::OperandSizesToScale( | 363 OperandScale operand_scale = Bytecodes::OperandSizesToScale( |
364 object.SizeOfOperand(), Bytecodes::SizeForUnsignedOperand(name_index), | 364 object.SizeOfOperand(), Bytecodes::SizeForUnsignedOperand(name_index), |
365 Bytecodes::SizeForUnsignedOperand(feedback_slot)); | 365 Bytecodes::SizeForUnsignedOperand(feedback_slot)); |
366 OutputScaled(Bytecode::kLoadIC, operand_scale, RegisterOperand(object), | 366 OutputScaled(Bytecode::kLdaNamedProperty, operand_scale, |
367 UnsignedOperand(name_index), UnsignedOperand(feedback_slot)); | 367 RegisterOperand(object), UnsignedOperand(name_index), |
| 368 UnsignedOperand(feedback_slot)); |
368 return *this; | 369 return *this; |
369 } | 370 } |
370 | 371 |
371 BytecodeArrayBuilder& BytecodeArrayBuilder::LoadKeyedProperty( | 372 BytecodeArrayBuilder& BytecodeArrayBuilder::LoadKeyedProperty( |
372 Register object, int feedback_slot) { | 373 Register object, int feedback_slot) { |
373 OperandScale operand_scale = Bytecodes::OperandSizesToScale( | 374 OperandScale operand_scale = Bytecodes::OperandSizesToScale( |
374 object.SizeOfOperand(), Bytecodes::SizeForUnsignedOperand(feedback_slot)); | 375 object.SizeOfOperand(), Bytecodes::SizeForUnsignedOperand(feedback_slot)); |
375 OutputScaled(Bytecode::kKeyedLoadIC, operand_scale, RegisterOperand(object), | 376 OutputScaled(Bytecode::kLdaKeyedProperty, operand_scale, |
376 UnsignedOperand(feedback_slot)); | 377 RegisterOperand(object), UnsignedOperand(feedback_slot)); |
377 return *this; | 378 return *this; |
378 } | 379 } |
379 | 380 |
380 BytecodeArrayBuilder& BytecodeArrayBuilder::StoreNamedProperty( | 381 BytecodeArrayBuilder& BytecodeArrayBuilder::StoreNamedProperty( |
381 Register object, const Handle<Name> name, int feedback_slot, | 382 Register object, const Handle<Name> name, int feedback_slot, |
382 LanguageMode language_mode) { | 383 LanguageMode language_mode) { |
383 Bytecode bytecode = BytecodeForStoreIC(language_mode); | 384 Bytecode bytecode = BytecodeForStoreNamedProperty(language_mode); |
384 size_t name_index = GetConstantPoolEntry(name); | 385 size_t name_index = GetConstantPoolEntry(name); |
385 OperandScale operand_scale = Bytecodes::OperandSizesToScale( | 386 OperandScale operand_scale = Bytecodes::OperandSizesToScale( |
386 object.SizeOfOperand(), Bytecodes::SizeForUnsignedOperand(name_index), | 387 object.SizeOfOperand(), Bytecodes::SizeForUnsignedOperand(name_index), |
387 Bytecodes::SizeForUnsignedOperand(feedback_slot)); | 388 Bytecodes::SizeForUnsignedOperand(feedback_slot)); |
388 OutputScaled(bytecode, operand_scale, RegisterOperand(object), | 389 OutputScaled(bytecode, operand_scale, RegisterOperand(object), |
389 UnsignedOperand(name_index), UnsignedOperand(feedback_slot)); | 390 UnsignedOperand(name_index), UnsignedOperand(feedback_slot)); |
390 return *this; | 391 return *this; |
391 } | 392 } |
392 | 393 |
393 | 394 |
394 BytecodeArrayBuilder& BytecodeArrayBuilder::StoreKeyedProperty( | 395 BytecodeArrayBuilder& BytecodeArrayBuilder::StoreKeyedProperty( |
395 Register object, Register key, int feedback_slot, | 396 Register object, Register key, int feedback_slot, |
396 LanguageMode language_mode) { | 397 LanguageMode language_mode) { |
397 Bytecode bytecode = BytecodeForKeyedStoreIC(language_mode); | 398 Bytecode bytecode = BytecodeForStoreKeyedProperty(language_mode); |
398 OperandScale operand_scale = Bytecodes::OperandSizesToScale( | 399 OperandScale operand_scale = Bytecodes::OperandSizesToScale( |
399 object.SizeOfOperand(), key.SizeOfOperand(), | 400 object.SizeOfOperand(), key.SizeOfOperand(), |
400 Bytecodes::SizeForUnsignedOperand(feedback_slot)); | 401 Bytecodes::SizeForUnsignedOperand(feedback_slot)); |
401 OutputScaled(bytecode, operand_scale, RegisterOperand(object), | 402 OutputScaled(bytecode, operand_scale, RegisterOperand(object), |
402 RegisterOperand(key), UnsignedOperand(feedback_slot)); | 403 RegisterOperand(key), UnsignedOperand(feedback_slot)); |
403 return *this; | 404 return *this; |
404 } | 405 } |
405 | 406 |
406 | 407 |
407 BytecodeArrayBuilder& BytecodeArrayBuilder::CreateClosure( | 408 BytecodeArrayBuilder& BytecodeArrayBuilder::CreateClosure( |
(...skipping 735 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1143 case Token::Value::IN: | 1144 case Token::Value::IN: |
1144 return Bytecode::kTestIn; | 1145 return Bytecode::kTestIn; |
1145 default: | 1146 default: |
1146 UNREACHABLE(); | 1147 UNREACHABLE(); |
1147 return Bytecode::kIllegal; | 1148 return Bytecode::kIllegal; |
1148 } | 1149 } |
1149 } | 1150 } |
1150 | 1151 |
1151 | 1152 |
1152 // static | 1153 // static |
1153 Bytecode BytecodeArrayBuilder::BytecodeForStoreIC(LanguageMode language_mode) { | 1154 Bytecode BytecodeArrayBuilder::BytecodeForStoreNamedProperty( |
| 1155 LanguageMode language_mode) { |
1154 switch (language_mode) { | 1156 switch (language_mode) { |
1155 case SLOPPY: | 1157 case SLOPPY: |
1156 return Bytecode::kStoreICSloppy; | 1158 return Bytecode::kStaNamedPropertySloppy; |
1157 case STRICT: | 1159 case STRICT: |
1158 return Bytecode::kStoreICStrict; | 1160 return Bytecode::kStaNamedPropertyStrict; |
1159 default: | 1161 default: |
1160 UNREACHABLE(); | 1162 UNREACHABLE(); |
1161 } | 1163 } |
1162 return Bytecode::kIllegal; | 1164 return Bytecode::kIllegal; |
1163 } | 1165 } |
1164 | 1166 |
1165 | 1167 |
1166 // static | 1168 // static |
1167 Bytecode BytecodeArrayBuilder::BytecodeForKeyedStoreIC( | 1169 Bytecode BytecodeArrayBuilder::BytecodeForStoreKeyedProperty( |
1168 LanguageMode language_mode) { | 1170 LanguageMode language_mode) { |
1169 switch (language_mode) { | 1171 switch (language_mode) { |
1170 case SLOPPY: | 1172 case SLOPPY: |
1171 return Bytecode::kKeyedStoreICSloppy; | 1173 return Bytecode::kStaKeyedPropertySloppy; |
1172 case STRICT: | 1174 case STRICT: |
1173 return Bytecode::kKeyedStoreICStrict; | 1175 return Bytecode::kStaKeyedPropertyStrict; |
1174 default: | 1176 default: |
1175 UNREACHABLE(); | 1177 UNREACHABLE(); |
1176 } | 1178 } |
1177 return Bytecode::kIllegal; | 1179 return Bytecode::kIllegal; |
1178 } | 1180 } |
1179 | 1181 |
1180 | 1182 |
1181 // static | 1183 // static |
1182 Bytecode BytecodeArrayBuilder::BytecodeForLoadGlobal(TypeofMode typeof_mode) { | 1184 Bytecode BytecodeArrayBuilder::BytecodeForLoadGlobal(TypeofMode typeof_mode) { |
1183 return typeof_mode == INSIDE_TYPEOF ? Bytecode::kLdaGlobalInsideTypeof | 1185 return typeof_mode == INSIDE_TYPEOF ? Bytecode::kLdaGlobalInsideTypeof |
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1284 } | 1286 } |
1285 | 1287 |
1286 uint32_t BytecodeArrayBuilder::UnsignedOperand(size_t value) { | 1288 uint32_t BytecodeArrayBuilder::UnsignedOperand(size_t value) { |
1287 DCHECK_LE(value, kMaxUInt32); | 1289 DCHECK_LE(value, kMaxUInt32); |
1288 return static_cast<uint32_t>(value); | 1290 return static_cast<uint32_t>(value); |
1289 } | 1291 } |
1290 | 1292 |
1291 } // namespace interpreter | 1293 } // namespace interpreter |
1292 } // namespace internal | 1294 } // namespace internal |
1293 } // namespace v8 | 1295 } // namespace v8 |
OLD | NEW |