| 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 246 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 257 } | 257 } |
| 258 | 258 |
| 259 | 259 |
| 260 BytecodeArrayBuilder& BytecodeArrayBuilder::StoreAccumulatorInRegister( | 260 BytecodeArrayBuilder& BytecodeArrayBuilder::StoreAccumulatorInRegister( |
| 261 Register reg) { | 261 Register reg) { |
| 262 Output(Bytecode::kStar, reg.ToOperand()); | 262 Output(Bytecode::kStar, reg.ToOperand()); |
| 263 return *this; | 263 return *this; |
| 264 } | 264 } |
| 265 | 265 |
| 266 | 266 |
| 267 BytecodeArrayBuilder& BytecodeArrayBuilder::LoadGlobal( |
| 268 size_t name_index, int feedback_slot, LanguageMode language_mode) { |
| 269 Bytecode bytecode = BytecodeForLoadGlobal(language_mode); |
| 270 if (FitsInIdx8Operand(name_index) && FitsInIdx8Operand(feedback_slot)) { |
| 271 Output(bytecode, static_cast<uint8_t>(name_index), |
| 272 static_cast<uint8_t>(feedback_slot)); |
| 273 } else { |
| 274 UNIMPLEMENTED(); |
| 275 } |
| 276 return *this; |
| 277 } |
| 278 |
| 279 |
| 280 BytecodeArrayBuilder& BytecodeArrayBuilder::StoreGlobal( |
| 281 size_t name_index, int feedback_slot, LanguageMode language_mode) { |
| 282 Bytecode bytecode = BytecodeForStoreGlobal(language_mode); |
| 283 if (FitsInIdx8Operand(name_index) && FitsInIdx8Operand(feedback_slot)) { |
| 284 Output(bytecode, static_cast<uint8_t>(name_index), |
| 285 static_cast<uint8_t>(feedback_slot)); |
| 286 } else { |
| 287 UNIMPLEMENTED(); |
| 288 } |
| 289 return *this; |
| 290 } |
| 291 |
| 292 |
| 267 BytecodeArrayBuilder& BytecodeArrayBuilder::LoadContextSlot(Register context, | 293 BytecodeArrayBuilder& BytecodeArrayBuilder::LoadContextSlot(Register context, |
| 268 int slot_index) { | 294 int slot_index) { |
| 269 DCHECK(slot_index >= 0); | 295 DCHECK(slot_index >= 0); |
| 270 if (FitsInIdx8Operand(slot_index)) { | 296 if (FitsInIdx8Operand(slot_index)) { |
| 271 Output(Bytecode::kLdaContextSlot, context.ToOperand(), | 297 Output(Bytecode::kLdaContextSlot, context.ToOperand(), |
| 272 static_cast<uint8_t>(slot_index)); | 298 static_cast<uint8_t>(slot_index)); |
| 273 } else { | 299 } else { |
| 274 UNIMPLEMENTED(); | 300 UNIMPLEMENTED(); |
| 275 } | 301 } |
| 276 return *this; | 302 return *this; |
| 277 } | 303 } |
| 278 | 304 |
| 279 | 305 |
| 280 BytecodeArrayBuilder& BytecodeArrayBuilder::StoreContextSlot(Register context, | 306 BytecodeArrayBuilder& BytecodeArrayBuilder::StoreContextSlot(Register context, |
| 281 int slot_index) { | 307 int slot_index) { |
| 282 DCHECK(slot_index >= 0); | 308 DCHECK(slot_index >= 0); |
| 283 if (FitsInIdx8Operand(slot_index)) { | 309 if (FitsInIdx8Operand(slot_index)) { |
| 284 Output(Bytecode::kStaContextSlot, context.ToOperand(), | 310 Output(Bytecode::kStaContextSlot, context.ToOperand(), |
| 285 static_cast<uint8_t>(slot_index)); | 311 static_cast<uint8_t>(slot_index)); |
| 286 } else { | 312 } else { |
| 287 UNIMPLEMENTED(); | 313 UNIMPLEMENTED(); |
| 288 } | 314 } |
| 289 return *this; | 315 return *this; |
| 290 } | 316 } |
| 291 | 317 |
| 292 | 318 |
| 293 BytecodeArrayBuilder& BytecodeArrayBuilder::LoadNamedProperty( | 319 BytecodeArrayBuilder& BytecodeArrayBuilder::LoadNamedProperty( |
| 294 Register object, int feedback_slot, LanguageMode language_mode) { | 320 Register object, size_t name_index, int feedback_slot, |
| 321 LanguageMode language_mode) { |
| 295 Bytecode bytecode = BytecodeForLoadIC(language_mode); | 322 Bytecode bytecode = BytecodeForLoadIC(language_mode); |
| 296 if (FitsInIdx8Operand(feedback_slot)) { | 323 if (FitsInIdx8Operand(name_index) && FitsInIdx8Operand(feedback_slot)) { |
| 297 Output(bytecode, object.ToOperand(), static_cast<uint8_t>(feedback_slot)); | 324 Output(bytecode, object.ToOperand(), static_cast<uint8_t>(name_index), |
| 325 static_cast<uint8_t>(feedback_slot)); |
| 298 } else { | 326 } else { |
| 299 UNIMPLEMENTED(); | 327 UNIMPLEMENTED(); |
| 300 } | 328 } |
| 301 return *this; | 329 return *this; |
| 302 } | 330 } |
| 303 | 331 |
| 304 | 332 |
| 305 BytecodeArrayBuilder& BytecodeArrayBuilder::LoadKeyedProperty( | 333 BytecodeArrayBuilder& BytecodeArrayBuilder::LoadKeyedProperty( |
| 306 Register object, int feedback_slot, LanguageMode language_mode) { | 334 Register object, int feedback_slot, LanguageMode language_mode) { |
| 307 Bytecode bytecode = BytecodeForKeyedLoadIC(language_mode); | 335 Bytecode bytecode = BytecodeForKeyedLoadIC(language_mode); |
| 308 if (FitsInIdx8Operand(feedback_slot)) { | 336 if (FitsInIdx8Operand(feedback_slot)) { |
| 309 Output(bytecode, object.ToOperand(), static_cast<uint8_t>(feedback_slot)); | 337 Output(bytecode, object.ToOperand(), static_cast<uint8_t>(feedback_slot)); |
| 310 } else { | 338 } else { |
| 311 UNIMPLEMENTED(); | 339 UNIMPLEMENTED(); |
| 312 } | 340 } |
| 313 return *this; | 341 return *this; |
| 314 } | 342 } |
| 315 | 343 |
| 316 | 344 |
| 317 BytecodeArrayBuilder& BytecodeArrayBuilder::StoreNamedProperty( | 345 BytecodeArrayBuilder& BytecodeArrayBuilder::StoreNamedProperty( |
| 318 Register object, Register name, int feedback_slot, | 346 Register object, size_t name_index, int feedback_slot, |
| 319 LanguageMode language_mode) { | 347 LanguageMode language_mode) { |
| 320 Bytecode bytecode = BytecodeForStoreIC(language_mode); | 348 Bytecode bytecode = BytecodeForStoreIC(language_mode); |
| 321 if (FitsInIdx8Operand(feedback_slot)) { | 349 if (FitsInIdx8Operand(name_index) && FitsInIdx8Operand(feedback_slot)) { |
| 322 Output(bytecode, object.ToOperand(), name.ToOperand(), | 350 Output(bytecode, object.ToOperand(), static_cast<uint8_t>(name_index), |
| 323 static_cast<uint8_t>(feedback_slot)); | 351 static_cast<uint8_t>(feedback_slot)); |
| 324 } else { | 352 } else { |
| 325 UNIMPLEMENTED(); | 353 UNIMPLEMENTED(); |
| 326 } | 354 } |
| 327 return *this; | 355 return *this; |
| 328 } | 356 } |
| 329 | 357 |
| 330 | 358 |
| 331 BytecodeArrayBuilder& BytecodeArrayBuilder::StoreKeyedProperty( | 359 BytecodeArrayBuilder& BytecodeArrayBuilder::StoreKeyedProperty( |
| 332 Register object, Register key, int feedback_slot, | 360 Register object, Register key, int feedback_slot, |
| (...skipping 555 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 888 case STRONG: | 916 case STRONG: |
| 889 UNIMPLEMENTED(); | 917 UNIMPLEMENTED(); |
| 890 default: | 918 default: |
| 891 UNREACHABLE(); | 919 UNREACHABLE(); |
| 892 } | 920 } |
| 893 return static_cast<Bytecode>(-1); | 921 return static_cast<Bytecode>(-1); |
| 894 } | 922 } |
| 895 | 923 |
| 896 | 924 |
| 897 // static | 925 // static |
| 926 Bytecode BytecodeArrayBuilder::BytecodeForLoadGlobal( |
| 927 LanguageMode language_mode) { |
| 928 switch (language_mode) { |
| 929 case SLOPPY: |
| 930 return Bytecode::kLdaGlobalSloppy; |
| 931 case STRICT: |
| 932 return Bytecode::kLdaGlobalStrict; |
| 933 case STRONG: |
| 934 UNIMPLEMENTED(); |
| 935 default: |
| 936 UNREACHABLE(); |
| 937 } |
| 938 return static_cast<Bytecode>(-1); |
| 939 } |
| 940 |
| 941 |
| 942 // static |
| 943 Bytecode BytecodeArrayBuilder::BytecodeForStoreGlobal( |
| 944 LanguageMode language_mode) { |
| 945 switch (language_mode) { |
| 946 case SLOPPY: |
| 947 return Bytecode::kStaGlobalSloppy; |
| 948 case STRICT: |
| 949 return Bytecode::kStaGlobalStrict; |
| 950 case STRONG: |
| 951 UNIMPLEMENTED(); |
| 952 default: |
| 953 UNREACHABLE(); |
| 954 } |
| 955 return static_cast<Bytecode>(-1); |
| 956 } |
| 957 |
| 958 |
| 959 // static |
| 898 bool BytecodeArrayBuilder::FitsInIdx8Operand(int value) { | 960 bool BytecodeArrayBuilder::FitsInIdx8Operand(int value) { |
| 899 return kMinUInt8 <= value && value <= kMaxUInt8; | 961 return kMinUInt8 <= value && value <= kMaxUInt8; |
| 900 } | 962 } |
| 901 | 963 |
| 902 | 964 |
| 903 // static | 965 // static |
| 904 bool BytecodeArrayBuilder::FitsInIdx8Operand(size_t value) { | 966 bool BytecodeArrayBuilder::FitsInIdx8Operand(size_t value) { |
| 905 return value <= static_cast<size_t>(kMaxUInt8); | 967 return value <= static_cast<size_t>(kMaxUInt8); |
| 906 } | 968 } |
| 907 | 969 |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 954 DCHECK_GT(next_consecutive_count_, 0); | 1016 DCHECK_GT(next_consecutive_count_, 0); |
| 955 builder_->BorrowConsecutiveTemporaryRegister(next_consecutive_register_); | 1017 builder_->BorrowConsecutiveTemporaryRegister(next_consecutive_register_); |
| 956 allocated_.push_back(next_consecutive_register_); | 1018 allocated_.push_back(next_consecutive_register_); |
| 957 next_consecutive_count_--; | 1019 next_consecutive_count_--; |
| 958 return Register(next_consecutive_register_++); | 1020 return Register(next_consecutive_register_++); |
| 959 } | 1021 } |
| 960 | 1022 |
| 961 } // namespace interpreter | 1023 } // namespace interpreter |
| 962 } // namespace internal | 1024 } // namespace internal |
| 963 } // namespace v8 | 1025 } // namespace v8 |
| OLD | NEW |