| 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 973 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 984 __ bind(&discard); | 984 __ bind(&discard); |
| 985 __ addq(rsp, Immediate(kPointerSize)); | 985 __ addq(rsp, Immediate(kPointerSize)); |
| 986 __ jmp(true_label_); | 986 __ jmp(true_label_); |
| 987 break; | 987 break; |
| 988 } | 988 } |
| 989 } | 989 } |
| 990 } | 990 } |
| 991 | 991 |
| 992 | 992 |
| 993 void FastCodeGenerator::VisitUnaryOperation(UnaryOperation* expr) { | 993 void FastCodeGenerator::VisitUnaryOperation(UnaryOperation* expr) { |
| 994 Comment cmnt(masm_, "[ UnaryOperation"); | |
| 995 switch (expr->op()) { | 994 switch (expr->op()) { |
| 996 case Token::VOID: | 995 case Token::VOID: { |
| 996 Comment cmnt(masm_, "[ UnaryOperation (VOID)"); |
| 997 Visit(expr->expression()); | 997 Visit(expr->expression()); |
| 998 ASSERT_EQ(Expression::kEffect, expr->expression()->context()); | 998 ASSERT_EQ(Expression::kEffect, expr->expression()->context()); |
| 999 switch (expr->context()) { | 999 switch (expr->context()) { |
| 1000 case Expression::kUninitialized: | 1000 case Expression::kUninitialized: |
| 1001 UNREACHABLE(); | 1001 UNREACHABLE(); |
| 1002 break; | 1002 break; |
| 1003 case Expression::kEffect: | 1003 case Expression::kEffect: |
| 1004 break; | 1004 break; |
| 1005 case Expression::kValue: | 1005 case Expression::kValue: |
| 1006 __ PushRoot(Heap::kUndefinedValueRootIndex); | 1006 __ PushRoot(Heap::kUndefinedValueRootIndex); |
| 1007 break; | 1007 break; |
| 1008 case Expression::kTestValue: | 1008 case Expression::kTestValue: |
| 1009 // Value is false so it's needed. | 1009 // Value is false so it's needed. |
| 1010 __ PushRoot(Heap::kUndefinedValueRootIndex); | 1010 __ PushRoot(Heap::kUndefinedValueRootIndex); |
| 1011 // Fall through. | 1011 // Fall through. |
| 1012 case Expression::kTest: // Fall through. | 1012 case Expression::kTest: // Fall through. |
| 1013 case Expression::kValueTest: | 1013 case Expression::kValueTest: |
| 1014 __ jmp(false_label_); | 1014 __ jmp(false_label_); |
| 1015 break; | 1015 break; |
| 1016 } | 1016 } |
| 1017 break; | 1017 break; |
| 1018 } |
| 1018 | 1019 |
| 1019 case Token::NOT: { | 1020 case Token::NOT: { |
| 1021 Comment cmnt(masm_, "[ UnaryOperation (NOT)"); |
| 1020 ASSERT_EQ(Expression::kTest, expr->expression()->context()); | 1022 ASSERT_EQ(Expression::kTest, expr->expression()->context()); |
| 1021 | 1023 |
| 1022 Label push_true; | 1024 Label push_true; |
| 1023 Label push_false; | 1025 Label push_false; |
| 1024 Label done; | 1026 Label done; |
| 1025 Label* saved_true = true_label_; | 1027 Label* saved_true = true_label_; |
| 1026 Label* saved_false = false_label_; | 1028 Label* saved_false = false_label_; |
| 1027 switch (expr->context()) { | 1029 switch (expr->context()) { |
| 1028 case Expression::kUninitialized: | 1030 case Expression::kUninitialized: |
| 1029 UNREACHABLE(); | 1031 UNREACHABLE(); |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1070 __ bind(&push_false); | 1072 __ bind(&push_false); |
| 1071 __ PushRoot(Heap::kFalseValueRootIndex); | 1073 __ PushRoot(Heap::kFalseValueRootIndex); |
| 1072 __ jmp(saved_false); | 1074 __ jmp(saved_false); |
| 1073 break; | 1075 break; |
| 1074 } | 1076 } |
| 1075 true_label_ = saved_true; | 1077 true_label_ = saved_true; |
| 1076 false_label_ = saved_false; | 1078 false_label_ = saved_false; |
| 1077 break; | 1079 break; |
| 1078 } | 1080 } |
| 1079 | 1081 |
| 1082 case Token::TYPEOF: { |
| 1083 Comment cmnt(masm_, "[ UnaryOperation (TYPEOF)"); |
| 1084 ASSERT_EQ(Expression::kValue, expr->expression()->context()); |
| 1085 |
| 1086 VariableProxy* proxy = expr->expression()->AsVariableProxy(); |
| 1087 if (proxy != NULL && proxy->var()->is_global()) { |
| 1088 Comment cmnt(masm_, "Global variable"); |
| 1089 __ push(CodeGenerator::GlobalObject()); |
| 1090 __ Move(rcx, proxy->name()); |
| 1091 Handle<Code> ic(Builtins::builtin(Builtins::LoadIC_Initialize)); |
| 1092 // Use a regular load, not a contextual load, to avoid reference error. |
| 1093 __ Call(ic, RelocInfo::CODE_TARGET); |
| 1094 __ movq(Operand(rsp, 0), rax); |
| 1095 } else if (proxy != NULL && |
| 1096 proxy->var()->slot() != NULL && |
| 1097 proxy->var()->slot()->type() == Slot::LOOKUP) { |
| 1098 __ push(rsi); |
| 1099 __ Push(proxy->name()); |
| 1100 __ CallRuntime(Runtime::kLoadContextSlotNoReferenceError, 2); |
| 1101 __ push(rax); |
| 1102 } else { |
| 1103 // This expression cannot throw a reference error at the top level. |
| 1104 Visit(expr->expression()); |
| 1105 } |
| 1106 |
| 1107 __ CallRuntime(Runtime::kTypeof, 1); |
| 1108 Move(expr->context(), rax); |
| 1109 break; |
| 1110 } |
| 1111 |
| 1080 default: | 1112 default: |
| 1081 UNREACHABLE(); | 1113 UNREACHABLE(); |
| 1082 } | 1114 } |
| 1083 } | 1115 } |
| 1084 | 1116 |
| 1085 | 1117 |
| 1086 void FastCodeGenerator::VisitBinaryOperation(BinaryOperation* expr) { | 1118 void FastCodeGenerator::VisitBinaryOperation(BinaryOperation* expr) { |
| 1087 Comment cmnt(masm_, "[ BinaryOperation"); | 1119 Comment cmnt(masm_, "[ BinaryOperation"); |
| 1088 switch (expr->op()) { | 1120 switch (expr->op()) { |
| 1089 case Token::COMMA: | 1121 case Token::COMMA: |
| (...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1281 true_label_ = saved_true; | 1313 true_label_ = saved_true; |
| 1282 false_label_ = saved_false; | 1314 false_label_ = saved_false; |
| 1283 // Convert current context to test context: End post-test code. | 1315 // Convert current context to test context: End post-test code. |
| 1284 } | 1316 } |
| 1285 | 1317 |
| 1286 | 1318 |
| 1287 #undef __ | 1319 #undef __ |
| 1288 | 1320 |
| 1289 | 1321 |
| 1290 } } // namespace v8::internal | 1322 } } // namespace v8::internal |
| OLD | NEW |