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/globals.h" | 7 #include "src/globals.h" |
8 #include "src/interpreter/bytecode-array-writer.h" | 8 #include "src/interpreter/bytecode-array-writer.h" |
9 #include "src/interpreter/bytecode-dead-code-optimizer.h" | 9 #include "src/interpreter/bytecode-dead-code-optimizer.h" |
10 #include "src/interpreter/bytecode-label.h" | 10 #include "src/interpreter/bytecode-label.h" |
(...skipping 371 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
382 break; | 382 break; |
383 case Token::Value::IN: | 383 case Token::Value::IN: |
384 OutputTestIn(reg); | 384 OutputTestIn(reg); |
385 break; | 385 break; |
386 default: | 386 default: |
387 UNREACHABLE(); | 387 UNREACHABLE(); |
388 } | 388 } |
389 return *this; | 389 return *this; |
390 } | 390 } |
391 | 391 |
| 392 BytecodeArrayBuilder& BytecodeArrayBuilder::CompareUndetectable() { |
| 393 OutputTestUndetectable(); |
| 394 return *this; |
| 395 } |
| 396 |
| 397 BytecodeArrayBuilder& BytecodeArrayBuilder::CompareUndefined() { |
| 398 OutputTestUndefined(); |
| 399 return *this; |
| 400 } |
| 401 |
| 402 BytecodeArrayBuilder& BytecodeArrayBuilder::CompareNull() { |
| 403 OutputTestNull(); |
| 404 return *this; |
| 405 } |
| 406 |
| 407 BytecodeArrayBuilder& BytecodeArrayBuilder::CompareNil(Token::Value op, |
| 408 NilValue nil) { |
| 409 if (op == Token::EQ) { |
| 410 return CompareUndetectable(); |
| 411 } else { |
| 412 DCHECK_EQ(Token::EQ_STRICT, op); |
| 413 if (nil == kUndefinedValue) { |
| 414 return CompareUndefined(); |
| 415 } else { |
| 416 DCHECK_EQ(kNullValue, nil); |
| 417 return CompareNull(); |
| 418 } |
| 419 } |
| 420 } |
| 421 |
392 BytecodeArrayBuilder& BytecodeArrayBuilder::CompareTypeOf( | 422 BytecodeArrayBuilder& BytecodeArrayBuilder::CompareTypeOf( |
393 TestTypeOfFlags::LiteralFlag literal_flag) { | 423 TestTypeOfFlags::LiteralFlag literal_flag) { |
394 DCHECK(literal_flag != TestTypeOfFlags::LiteralFlag::kOther); | 424 DCHECK(literal_flag != TestTypeOfFlags::LiteralFlag::kOther); |
395 OutputTestTypeOf(TestTypeOfFlags::Encode(literal_flag)); | 425 OutputTestTypeOf(TestTypeOfFlags::Encode(literal_flag)); |
396 return *this; | 426 return *this; |
397 } | 427 } |
398 | 428 |
399 BytecodeArrayBuilder& BytecodeArrayBuilder::LoadConstantPoolEntry( | 429 BytecodeArrayBuilder& BytecodeArrayBuilder::LoadConstantPoolEntry( |
400 size_t entry) { | 430 size_t entry) { |
401 OutputLdaConstant(entry); | 431 OutputLdaConstant(entry); |
(...skipping 476 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
878 OutputJumpIfToBooleanFalse(label, 0); | 908 OutputJumpIfToBooleanFalse(label, 0); |
879 return *this; | 909 return *this; |
880 } | 910 } |
881 | 911 |
882 BytecodeArrayBuilder& BytecodeArrayBuilder::JumpIfNull(BytecodeLabel* label) { | 912 BytecodeArrayBuilder& BytecodeArrayBuilder::JumpIfNull(BytecodeLabel* label) { |
883 DCHECK(!label->is_bound()); | 913 DCHECK(!label->is_bound()); |
884 OutputJumpIfNull(label, 0); | 914 OutputJumpIfNull(label, 0); |
885 return *this; | 915 return *this; |
886 } | 916 } |
887 | 917 |
| 918 BytecodeArrayBuilder& BytecodeArrayBuilder::JumpIfNotNull( |
| 919 BytecodeLabel* label) { |
| 920 DCHECK(!label->is_bound()); |
| 921 OutputJumpIfNotNull(label, 0); |
| 922 return *this; |
| 923 } |
| 924 |
888 BytecodeArrayBuilder& BytecodeArrayBuilder::JumpIfUndefined( | 925 BytecodeArrayBuilder& BytecodeArrayBuilder::JumpIfUndefined( |
889 BytecodeLabel* label) { | 926 BytecodeLabel* label) { |
890 DCHECK(!label->is_bound()); | 927 DCHECK(!label->is_bound()); |
891 OutputJumpIfUndefined(label, 0); | 928 OutputJumpIfUndefined(label, 0); |
892 return *this; | 929 return *this; |
893 } | 930 } |
894 | 931 |
| 932 BytecodeArrayBuilder& BytecodeArrayBuilder::JumpIfNotUndefined( |
| 933 BytecodeLabel* label) { |
| 934 DCHECK(!label->is_bound()); |
| 935 OutputJumpIfNotUndefined(label, 0); |
| 936 return *this; |
| 937 } |
| 938 |
| 939 BytecodeArrayBuilder& BytecodeArrayBuilder::JumpIfNil(BytecodeLabel* label, |
| 940 Token::Value op, |
| 941 NilValue nil) { |
| 942 if (op == Token::EQ) { |
| 943 // TODO(rmcilroy): Implement JumpIfUndetectable. |
| 944 return CompareUndetectable().JumpIfTrue(label); |
| 945 } else { |
| 946 DCHECK_EQ(Token::EQ_STRICT, op); |
| 947 if (nil == kUndefinedValue) { |
| 948 return JumpIfUndefined(label); |
| 949 } else { |
| 950 DCHECK_EQ(kNullValue, nil); |
| 951 return JumpIfNull(label); |
| 952 } |
| 953 } |
| 954 } |
| 955 |
| 956 BytecodeArrayBuilder& BytecodeArrayBuilder::JumpIfNotNil(BytecodeLabel* label, |
| 957 Token::Value op, |
| 958 NilValue nil) { |
| 959 if (op == Token::EQ) { |
| 960 // TODO(rmcilroy): Implement JumpIfUndetectable. |
| 961 return CompareUndetectable().JumpIfFalse(label); |
| 962 } else { |
| 963 DCHECK_EQ(Token::EQ_STRICT, op); |
| 964 if (nil == kUndefinedValue) { |
| 965 return JumpIfNotUndefined(label); |
| 966 } else { |
| 967 DCHECK_EQ(kNullValue, nil); |
| 968 return JumpIfNotNull(label); |
| 969 } |
| 970 } |
| 971 } |
| 972 |
895 BytecodeArrayBuilder& BytecodeArrayBuilder::JumpIfNotHole( | 973 BytecodeArrayBuilder& BytecodeArrayBuilder::JumpIfNotHole( |
896 BytecodeLabel* label) { | 974 BytecodeLabel* label) { |
897 DCHECK(!label->is_bound()); | 975 DCHECK(!label->is_bound()); |
898 OutputJumpIfNotHole(label, 0); | 976 OutputJumpIfNotHole(label, 0); |
899 return *this; | 977 return *this; |
900 } | 978 } |
901 | 979 |
902 BytecodeArrayBuilder& BytecodeArrayBuilder::JumpIfJSReceiver( | 980 BytecodeArrayBuilder& BytecodeArrayBuilder::JumpIfJSReceiver( |
903 BytecodeLabel* label) { | 981 BytecodeLabel* label) { |
904 DCHECK(!label->is_bound()); | 982 DCHECK(!label->is_bound()); |
(...skipping 341 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1246 RegisterList reg_list) { | 1324 RegisterList reg_list) { |
1247 DCHECK(RegisterListIsValid(reg_list)); | 1325 DCHECK(RegisterListIsValid(reg_list)); |
1248 if (register_optimizer_) | 1326 if (register_optimizer_) |
1249 register_optimizer_->PrepareOutputRegisterList(reg_list); | 1327 register_optimizer_->PrepareOutputRegisterList(reg_list); |
1250 return static_cast<uint32_t>(reg_list.first_register().ToOperand()); | 1328 return static_cast<uint32_t>(reg_list.first_register().ToOperand()); |
1251 } | 1329 } |
1252 | 1330 |
1253 } // namespace interpreter | 1331 } // namespace interpreter |
1254 } // namespace internal | 1332 } // namespace internal |
1255 } // namespace v8 | 1333 } // namespace v8 |
OLD | NEW |