| OLD | NEW |
| 1 // Copyright 2009 the V8 project authors. All rights reserved. | 1 // Copyright 2009 the V8 project authors. All rights reserved. |
| 2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
| 3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
| 4 // met: | 4 // met: |
| 5 // | 5 // |
| 6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
| 7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
| 8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
| 9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
| 10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
| (...skipping 847 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 858 Emit##name(expr->arguments()); \ | 858 Emit##name(expr->arguments()); \ |
| 859 return; \ | 859 return; \ |
| 860 } | 860 } |
| 861 | 861 |
| 862 INLINE_RUNTIME_FUNCTION_LIST(CHECK_EMIT_INLINE_CALL) | 862 INLINE_RUNTIME_FUNCTION_LIST(CHECK_EMIT_INLINE_CALL) |
| 863 UNREACHABLE(); | 863 UNREACHABLE(); |
| 864 #undef CHECK_EMIT_INLINE_CALL | 864 #undef CHECK_EMIT_INLINE_CALL |
| 865 } | 865 } |
| 866 | 866 |
| 867 | 867 |
| 868 void FullCodeGenerator::VisitBinaryOperation(BinaryOperation* expr) { |
| 869 Comment cmnt(masm_, "[ BinaryOperation"); |
| 870 switch (expr->op()) { |
| 871 case Token::COMMA: |
| 872 VisitForEffect(expr->left()); |
| 873 Visit(expr->right()); |
| 874 break; |
| 875 |
| 876 case Token::OR: |
| 877 case Token::AND: |
| 878 EmitLogicalOperation(expr); |
| 879 break; |
| 880 |
| 881 case Token::ADD: |
| 882 case Token::SUB: |
| 883 case Token::DIV: |
| 884 case Token::MOD: |
| 885 case Token::MUL: |
| 886 case Token::BIT_OR: |
| 887 case Token::BIT_AND: |
| 888 case Token::BIT_XOR: |
| 889 case Token::SHL: |
| 890 case Token::SHR: |
| 891 case Token::SAR: |
| 892 VisitForValue(expr->left(), kStack); |
| 893 VisitForValue(expr->right(), kAccumulator); |
| 894 EmitBinaryOp(expr->op(), context_); |
| 895 break; |
| 896 |
| 897 default: |
| 898 UNREACHABLE(); |
| 899 } |
| 900 } |
| 901 |
| 902 |
| 868 void FullCodeGenerator::EmitLogicalOperation(BinaryOperation* expr) { | 903 void FullCodeGenerator::EmitLogicalOperation(BinaryOperation* expr) { |
| 869 Label eval_right, done; | 904 Label eval_right, done; |
| 870 | 905 |
| 871 // Set up the appropriate context for the left subexpression based | 906 // Set up the appropriate context for the left subexpression based |
| 872 // on the operation and our own context. Initially assume we can | 907 // on the operation and our own context. Initially assume we can |
| 873 // inherit both true and false labels from our context. | 908 // inherit both true and false labels from our context. |
| 874 if (expr->op() == Token::OR) { | 909 if (expr->op() == Token::OR) { |
| 875 switch (context_) { | 910 switch (context_) { |
| 876 case Expression::kUninitialized: | 911 case Expression::kUninitialized: |
| 877 UNREACHABLE(); | 912 UNREACHABLE(); |
| 878 case Expression::kEffect: | 913 case Expression::kEffect: |
| 879 VisitForControl(expr->left(), &done, &eval_right); | 914 VisitForControl(expr->left(), &done, &eval_right); |
| 880 break; | 915 break; |
| 881 case Expression::kValue: | 916 case Expression::kValue: |
| 882 VisitForValueControl(expr->left(), | 917 VisitLogicalForValue(expr->left(), expr->op(), location_, &done); |
| 883 location_, | |
| 884 &done, | |
| 885 &eval_right); | |
| 886 break; | 918 break; |
| 887 case Expression::kTest: | 919 case Expression::kTest: |
| 888 VisitForControl(expr->left(), true_label_, &eval_right); | 920 VisitForControl(expr->left(), true_label_, &eval_right); |
| 889 break; | 921 break; |
| 890 case Expression::kValueTest: | |
| 891 VisitForValueControl(expr->left(), | |
| 892 location_, | |
| 893 true_label_, | |
| 894 &eval_right); | |
| 895 break; | |
| 896 case Expression::kTestValue: | |
| 897 VisitForControl(expr->left(), true_label_, &eval_right); | |
| 898 break; | |
| 899 } | 922 } |
| 900 } else { | 923 } else { |
| 901 ASSERT_EQ(Token::AND, expr->op()); | 924 ASSERT_EQ(Token::AND, expr->op()); |
| 902 switch (context_) { | 925 switch (context_) { |
| 903 case Expression::kUninitialized: | 926 case Expression::kUninitialized: |
| 904 UNREACHABLE(); | 927 UNREACHABLE(); |
| 905 case Expression::kEffect: | 928 case Expression::kEffect: |
| 906 VisitForControl(expr->left(), &eval_right, &done); | 929 VisitForControl(expr->left(), &eval_right, &done); |
| 907 break; | 930 break; |
| 908 case Expression::kValue: | 931 case Expression::kValue: |
| 909 VisitForControlValue(expr->left(), | 932 VisitLogicalForValue(expr->left(), expr->op(), location_, &done); |
| 910 location_, | |
| 911 &eval_right, | |
| 912 &done); | |
| 913 break; | 933 break; |
| 914 case Expression::kTest: | 934 case Expression::kTest: |
| 915 VisitForControl(expr->left(), &eval_right, false_label_); | 935 VisitForControl(expr->left(), &eval_right, false_label_); |
| 916 break; | 936 break; |
| 917 case Expression::kValueTest: | |
| 918 VisitForControl(expr->left(), &eval_right, false_label_); | |
| 919 break; | |
| 920 case Expression::kTestValue: | |
| 921 VisitForControlValue(expr->left(), | |
| 922 location_, | |
| 923 &eval_right, | |
| 924 false_label_); | |
| 925 break; | |
| 926 } | 937 } |
| 927 } | 938 } |
| 928 | 939 |
| 929 __ bind(&eval_right); | 940 __ bind(&eval_right); |
| 930 Visit(expr->right()); | 941 Visit(expr->right()); |
| 931 | 942 |
| 932 __ bind(&done); | 943 __ bind(&done); |
| 933 } | 944 } |
| 934 | 945 |
| 935 | 946 |
| 947 void FullCodeGenerator::VisitLogicalForValue(Expression* expr, |
| 948 Token::Value op, |
| 949 Location where, |
| 950 Label* done) { |
| 951 ASSERT(op == Token::AND || op == Token::OR); |
| 952 VisitForValue(expr, kAccumulator); |
| 953 __ push(result_register()); |
| 954 |
| 955 Label discard; |
| 956 switch (where) { |
| 957 case kAccumulator: { |
| 958 Label restore; |
| 959 if (op == Token::OR) { |
| 960 DoTest(&restore, &discard, &restore); |
| 961 } else { |
| 962 DoTest(&discard, &restore, &restore); |
| 963 } |
| 964 __ bind(&restore); |
| 965 __ pop(result_register()); |
| 966 __ jmp(done); |
| 967 break; |
| 968 } |
| 969 case kStack: { |
| 970 if (op == Token::OR) { |
| 971 DoTest(done, &discard, &discard); |
| 972 } else { |
| 973 DoTest(&discard, done, &discard); |
| 974 } |
| 975 break; |
| 976 } |
| 977 } |
| 978 |
| 979 __ bind(&discard); |
| 980 __ Drop(1); |
| 981 } |
| 982 |
| 983 |
| 936 void FullCodeGenerator::VisitBlock(Block* stmt) { | 984 void FullCodeGenerator::VisitBlock(Block* stmt) { |
| 937 Comment cmnt(masm_, "[ Block"); | 985 Comment cmnt(masm_, "[ Block"); |
| 938 Breakable nested_statement(this, stmt); | 986 Breakable nested_statement(this, stmt); |
| 939 SetStatementPosition(stmt); | 987 SetStatementPosition(stmt); |
| 940 VisitStatements(stmt->statements()); | 988 VisitStatements(stmt->statements()); |
| 941 __ bind(nested_statement.break_target()); | 989 __ bind(nested_statement.break_target()); |
| 942 } | 990 } |
| 943 | 991 |
| 944 | 992 |
| 945 void FullCodeGenerator::VisitExpressionStatement(ExpressionStatement* stmt) { | 993 void FullCodeGenerator::VisitExpressionStatement(ExpressionStatement* stmt) { |
| (...skipping 430 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1376 // The macros used here must preserve the result register. | 1424 // The macros used here must preserve the result register. |
| 1377 __ Drop(stack_depth); | 1425 __ Drop(stack_depth); |
| 1378 __ PopTryHandler(); | 1426 __ PopTryHandler(); |
| 1379 return 0; | 1427 return 0; |
| 1380 } | 1428 } |
| 1381 | 1429 |
| 1382 #undef __ | 1430 #undef __ |
| 1383 | 1431 |
| 1384 | 1432 |
| 1385 } } // namespace v8::internal | 1433 } } // namespace v8::internal |
| OLD | NEW |