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(int slot_index) { | |
268 DCHECK(slot_index >= 0); | |
269 if (FitsInIdx8Operand(slot_index)) { | |
270 Output(Bytecode::kLdaGlobal, static_cast<uint8_t>(slot_index)); | |
271 } else { | |
272 UNIMPLEMENTED(); | |
273 } | |
274 return *this; | |
275 } | |
276 | |
277 | |
278 BytecodeArrayBuilder& BytecodeArrayBuilder::StoreGlobal( | |
279 int slot_index, LanguageMode language_mode) { | |
280 DCHECK(slot_index >= 0); | |
281 Bytecode bytecode = BytecodeForStoreGlobal(language_mode); | |
282 if (FitsInIdx8Operand(slot_index)) { | |
283 Output(bytecode, static_cast<uint8_t>(slot_index)); | |
284 } else { | |
285 UNIMPLEMENTED(); | |
286 } | |
287 return *this; | |
288 } | |
289 | |
290 | |
291 BytecodeArrayBuilder& BytecodeArrayBuilder::LoadContextSlot(Register context, | 267 BytecodeArrayBuilder& BytecodeArrayBuilder::LoadContextSlot(Register context, |
292 int slot_index) { | 268 int slot_index) { |
293 DCHECK(slot_index >= 0); | 269 DCHECK(slot_index >= 0); |
294 if (FitsInIdx8Operand(slot_index)) { | 270 if (FitsInIdx8Operand(slot_index)) { |
295 Output(Bytecode::kLdaContextSlot, context.ToOperand(), | 271 Output(Bytecode::kLdaContextSlot, context.ToOperand(), |
296 static_cast<uint8_t>(slot_index)); | 272 static_cast<uint8_t>(slot_index)); |
297 } else { | 273 } else { |
298 UNIMPLEMENTED(); | 274 UNIMPLEMENTED(); |
299 } | 275 } |
300 return *this; | 276 return *this; |
(...skipping 611 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
912 case STRONG: | 888 case STRONG: |
913 UNIMPLEMENTED(); | 889 UNIMPLEMENTED(); |
914 default: | 890 default: |
915 UNREACHABLE(); | 891 UNREACHABLE(); |
916 } | 892 } |
917 return static_cast<Bytecode>(-1); | 893 return static_cast<Bytecode>(-1); |
918 } | 894 } |
919 | 895 |
920 | 896 |
921 // static | 897 // static |
922 Bytecode BytecodeArrayBuilder::BytecodeForStoreGlobal( | |
923 LanguageMode language_mode) { | |
924 switch (language_mode) { | |
925 case SLOPPY: | |
926 return Bytecode::kStaGlobalSloppy; | |
927 case STRICT: | |
928 return Bytecode::kStaGlobalStrict; | |
929 case STRONG: | |
930 UNIMPLEMENTED(); | |
931 default: | |
932 UNREACHABLE(); | |
933 } | |
934 return static_cast<Bytecode>(-1); | |
935 } | |
936 | |
937 | |
938 // static | |
939 bool BytecodeArrayBuilder::FitsInIdx8Operand(int value) { | 898 bool BytecodeArrayBuilder::FitsInIdx8Operand(int value) { |
940 return kMinUInt8 <= value && value <= kMaxUInt8; | 899 return kMinUInt8 <= value && value <= kMaxUInt8; |
941 } | 900 } |
942 | 901 |
943 | 902 |
944 // static | 903 // static |
945 bool BytecodeArrayBuilder::FitsInIdx8Operand(size_t value) { | 904 bool BytecodeArrayBuilder::FitsInIdx8Operand(size_t value) { |
946 return value <= static_cast<size_t>(kMaxUInt8); | 905 return value <= static_cast<size_t>(kMaxUInt8); |
947 } | 906 } |
948 | 907 |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
995 DCHECK_GT(next_consecutive_count_, 0); | 954 DCHECK_GT(next_consecutive_count_, 0); |
996 builder_->BorrowConsecutiveTemporaryRegister(next_consecutive_register_); | 955 builder_->BorrowConsecutiveTemporaryRegister(next_consecutive_register_); |
997 allocated_.push_back(next_consecutive_register_); | 956 allocated_.push_back(next_consecutive_register_); |
998 next_consecutive_count_--; | 957 next_consecutive_count_--; |
999 return Register(next_consecutive_register_++); | 958 return Register(next_consecutive_register_++); |
1000 } | 959 } |
1001 | 960 |
1002 } // namespace interpreter | 961 } // namespace interpreter |
1003 } // namespace internal | 962 } // namespace internal |
1004 } // namespace v8 | 963 } // namespace v8 |
OLD | NEW |